@rubenpazch/alert 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/alert
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
+ Aviso dentro de la página (info, success, warning, danger) con título, acción y cierre opcional.
6
+
7
+ - **Usar cuando:** Mensajes que deben quedar visibles en la página: errores de carga, advertencias de un formulario, avisos de estado.
8
+ - **Evitar cuando:** Confirmaciones pasajeras ("Guardado"): usa Toast. Pedir una decisión: usa ConfirmationDialog.
9
+
10
+ Se recomienda instalar el paquete completo `@rubenpazch/ui` (incluye este). Por separado:
11
+
12
+ ```bash
13
+ npm install @rubenpazch/alert
14
+ ```
15
+
16
+ ## Alert
17
+
18
+ Aviso dentro de la página (no flotante): información, éxito, advertencia o error.
19
+ `warning` y `danger` se anuncian de inmediato (role="alert"); el resto como estado.
20
+
21
+ | Prop | Tipo | Req. | Por defecto | Descripción |
22
+ | ------------ | ---------------------------------------------- | ---- | -------------- | -------------------------------------------------------------------- |
23
+ | `action` | `ReactNode` | | | Acción a la derecha o abajo (p. ej. un Button "Reintentar"). |
24
+ | `children` | `ReactNode` | | | Texto del aviso. |
25
+ | `className` | `string` | | | Clase extra. |
26
+ | `closeLabel` | `string` | | `Cerrar aviso` | Texto accesible del botón ×. |
27
+ | `icon` | `ReactNode` | | | Icono propio; `false` para ocultarlo. Por defecto uno según el tipo. |
28
+ | `onClose` | `() => void` | | | Si se pasa, muestra el botón × y se llama al cerrarlo. |
29
+ | `title` | `ReactNode` | | | Título en negrita (opcional). |
30
+ | `variant` | `"info" \| "success" \| "warning" \| "danger"` | | `info` | Tipo de mensaje: info (por defecto), success, warning o danger. |
31
+
32
+ Tipos: `AlertProps`, `AlertVariant`.
33
+
34
+ <!-- catalogo:fin -->
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ export type AlertVariant = "info" | "success" | "warning" | "danger";
3
+ export interface AlertProps {
4
+ /** Tipo de mensaje: info (por defecto), success, warning o danger. */
5
+ variant?: AlertVariant;
6
+ /** Título en negrita (opcional). */
7
+ title?: React.ReactNode;
8
+ /** Texto del aviso. */
9
+ children?: React.ReactNode;
10
+ /** Si se pasa, muestra el botón × y se llama al cerrarlo. */
11
+ onClose?: () => void;
12
+ /** Acción a la derecha o abajo (p. ej. un Button "Reintentar"). */
13
+ action?: React.ReactNode;
14
+ /** Icono propio; `false` para ocultarlo. Por defecto uno según el tipo. */
15
+ icon?: React.ReactNode | false;
16
+ /** Texto accesible del botón ×. */
17
+ closeLabel?: string;
18
+ /** Clase extra. */
19
+ className?: string;
20
+ }
21
+ /**
22
+ * Aviso dentro de la página (no flotante): información, éxito, advertencia o error.
23
+ * `warning` y `danger` se anuncian de inmediato (role="alert"); el resto como estado.
24
+ */
25
+ export default function Alert({ variant, title, children, onClose, action, icon, closeLabel, className, }: AlertProps): React.JSX.Element;
26
+ //# sourceMappingURL=Alert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../src/Alert.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErE,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,oCAAoC;IACpC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,mEAAmE;IACnE,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;IAC/B,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAeD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,OAAgB,EAChB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,IAAI,EACJ,UAA2B,EAC3B,SAAS,GACV,EAAE,UAAU,qBA0CZ"}
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("react/jsx-runtime");var l={alert:"Alert-module_alert__hwuIT",info:"Alert-module_info__KD71J",success:"Alert-module_success__ayQv-",warning:"Alert-module_warning__akwqv",danger:"Alert-module_danger__6TvpZ",icon:"Alert-module_icon__d5mez",content:"Alert-module_content__ZoStd",title:"Alert-module_title__M2SA8",text:"Alert-module_text__iT4Zu",action:"Alert-module_action__iFPW8",close:"Alert-module_close__4jXzy"};!function(e,l){void 0===l&&(l={});var r=l.insertAt;if("undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".Alert-module_alert__hwuIT {\n display: flex;\n align-items: flex-start;\n gap: var(--lb-space-3);\n padding: var(--lb-space-3) var(--lb-space-4);\n border: 1px solid;\n border-radius: var(--lb-radius-lg);\n font-family: var(--lb-font-sans);\n font-size: var(--lb-font-size-sm);\n line-height: var(--lb-line-height-normal);\n}\n\n.Alert-module_info__KD71J { background: var(--lb-color-blue-subtle); border-color: var(--lb-color-blue-border); color: var(--lb-color-blue-strong); }\n.Alert-module_success__ayQv- { background: var(--lb-color-emerald-subtle); border-color: var(--lb-color-emerald-border); color: var(--lb-color-emerald-strong); }\n.Alert-module_warning__akwqv { background: var(--lb-color-amber-subtle); border-color: var(--lb-color-amber-border); color: var(--lb-color-amber-strong); }\n.Alert-module_danger__6TvpZ { background: var(--lb-color-red-subtle); border-color: var(--lb-color-red-border); color: var(--lb-color-red-strong); }\n\n.Alert-module_icon__d5mez {\n display: inline-flex;\n flex: none;\n margin-top: 1px;\n}\n\n.Alert-module_content__ZoStd {\n flex: 1;\n min-width: 0;\n}\n\n.Alert-module_title__M2SA8 {\n margin: 0;\n font-weight: var(--lb-font-weight-semibold);\n}\n\n.Alert-module_title__M2SA8 + .Alert-module_text__iT4Zu {\n margin-top: var(--lb-space-1);\n}\n\n.Alert-module_text__iT4Zu {\n color: inherit;\n}\n\n.Alert-module_text__iT4Zu :where(p) {\n margin: 0;\n}\n\n.Alert-module_action__iFPW8 {\n margin-top: var(--lb-space-2);\n}\n\n.Alert-module_close__4jXzy {\n display: inline-flex;\n flex: none;\n padding: var(--lb-space-1);\n border: 0;\n border-radius: var(--lb-radius-sm);\n background: transparent;\n color: inherit;\n cursor: pointer;\n opacity: 0.75;\n}\n\n.Alert-module_close__4jXzy:hover {\n opacity: 1;\n}\n\n.Alert-module_close__4jXzy:focus-visible {\n outline: 2px solid var(--lb-color-ring);\n outline-offset: 1px;\n}\n");const r=(...e)=>e.filter(Boolean).join(" "),n={info:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm.75-11.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM9.25 9a.75.75 0 0 1 1.5 0v4.25a.75.75 0 0 1-1.5 0V9Z",success:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.86-9.81a.75.75 0 0 0-1.22-.88l-3.24 4.5-1.62-1.62a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.09l3.75-5.22Z",warning:"M8.48 2.94c.66-1.17 2.38-1.17 3.04 0l5.6 9.95c.65 1.16-.18 2.61-1.52 2.61H4.4c-1.34 0-2.17-1.45-1.52-2.61l5.6-9.95ZM10 6.5a.75.75 0 0 0-.75.75v3.5a.75.75 0 0 0 1.5 0v-3.5A.75.75 0 0 0 10 6.5Zm0 7.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",danger:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z"};module.exports=function({variant:o="info",title:t,children:a,onClose:i,action:d,icon:s,closeLabel:c="Cerrar aviso",className:_}){const u="warning"===o||"danger"===o;return e.jsxs("div",{role:u?"alert":"status",className:r(l.alert,l[o],_),"data-variant":o,children:[!1!==s&&e.jsx("span",{className:l.icon,"aria-hidden":"true",children:s??e.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",width:"20",height:"20",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:n[o]})})}),e.jsxs("div",{className:l.content,children:[t&&e.jsx("p",{className:l.title,children:t}),a&&e.jsx("div",{className:l.text,children:a}),d&&e.jsx("div",{className:l.action,children:d})]}),i&&e.jsx("button",{type:"button",className:l.close,onClick:i,"aria-label":c,children:e.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",width:"16",height:"16","aria-hidden":"true",children:e.jsx("path",{d:"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z"})})})]})};
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/Alert.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 styles from \"./Alert.module.css\";\n\nexport type AlertVariant = \"info\" | \"success\" | \"warning\" | \"danger\";\n\nexport interface AlertProps {\n /** Tipo de mensaje: info (por defecto), success, warning o danger. */\n variant?: AlertVariant;\n /** Título en negrita (opcional). */\n title?: React.ReactNode;\n /** Texto del aviso. */\n children?: React.ReactNode;\n /** Si se pasa, muestra el botón × y se llama al cerrarlo. */\n onClose?: () => void;\n /** Acción a la derecha o abajo (p. ej. un Button \"Reintentar\"). */\n action?: React.ReactNode;\n /** Icono propio; `false` para ocultarlo. Por defecto uno según el tipo. */\n icon?: React.ReactNode | false;\n /** Texto accesible del botón ×. */\n closeLabel?: string;\n /** Clase extra. */\n className?: string;\n}\n\nconst cx = (...c: Array<string | false | undefined>) =>\n c.filter(Boolean).join(\" \");\n\nconst ICONS: Record<AlertVariant, string> = {\n info: \"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm.75-11.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM9.25 9a.75.75 0 0 1 1.5 0v4.25a.75.75 0 0 1-1.5 0V9Z\",\n success:\n \"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.86-9.81a.75.75 0 0 0-1.22-.88l-3.24 4.5-1.62-1.62a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.09l3.75-5.22Z\",\n warning:\n \"M8.48 2.94c.66-1.17 2.38-1.17 3.04 0l5.6 9.95c.65 1.16-.18 2.61-1.52 2.61H4.4c-1.34 0-2.17-1.45-1.52-2.61l5.6-9.95ZM10 6.5a.75.75 0 0 0-.75.75v3.5a.75.75 0 0 0 1.5 0v-3.5A.75.75 0 0 0 10 6.5Zm0 7.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z\",\n danger:\n \"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z\",\n};\n\n/**\n * Aviso dentro de la página (no flotante): información, éxito, advertencia o error.\n * `warning` y `danger` se anuncian de inmediato (role=\"alert\"); el resto como estado.\n */\nexport default function Alert({\n variant = \"info\",\n title,\n children,\n onClose,\n action,\n icon,\n closeLabel = \"Cerrar aviso\",\n className,\n}: AlertProps) {\n const urgent = variant === \"warning\" || variant === \"danger\";\n return (\n <div\n role={urgent ? \"alert\" : \"status\"}\n className={cx(styles.alert, styles[variant], className)}\n data-variant={variant}\n >\n {icon !== false && (\n <span className={styles.icon} aria-hidden=\"true\">\n {icon ?? (\n <svg viewBox=\"0 0 20 20\" fill=\"currentColor\" width=\"20\" height=\"20\">\n <path fillRule=\"evenodd\" clipRule=\"evenodd\" d={ICONS[variant]} />\n </svg>\n )}\n </span>\n )}\n <div className={styles.content}>\n {title && <p className={styles.title}>{title}</p>}\n {children && <div className={styles.text}>{children}</div>}\n {action && <div className={styles.action}>{action}</div>}\n </div>\n {onClose && (\n <button\n type=\"button\"\n className={styles.close}\n onClick={onClose}\n aria-label={closeLabel}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n width=\"16\"\n height=\"16\"\n aria-hidden=\"true\"\n >\n <path d=\"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z\" />\n </svg>\n </button>\n )}\n </div>\n );\n}\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","cx","c","filter","Boolean","join","ICONS","info","success","warning","danger","variant","title","children","onClose","action","icon","closeLabel","className","urgent","_jsxs","role","styles","alert","_jsx","viewBox","fill","width","height","fillRule","clipRule","d","content","text","close","onClick"],"mappings":"ybAAA,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,83DCDA,MAAMe,EAAK,IAAIC,IACbA,EAAEC,OAAOC,SAASC,KAAK,KAEnBC,EAAsC,CAC1CC,KAAM,8IACNC,QACE,8JACFC,QACE,qOACFC,OACE,0OAOU,UAAgBC,QAC5BA,EAAU,OAAMC,MAChBA,EAAKC,SACLA,EAAQC,QACRA,EAAOC,OACPA,EAAMC,KACNA,EAAIC,WACJA,EAAa,eAAcC,UAC3BA,IAEA,MAAMC,EAAqB,YAAZR,GAAqC,WAAZA,EACxC,OACES,EAAAA,KAAA,MAAA,CACEC,KAAMF,EAAS,QAAU,SACzBD,UAAWjB,EAAGqB,EAAOC,MAAOD,EAAOX,GAAUO,kBAC/BP,EAAOE,SAAA,EAEX,IAATG,GACCQ,EAAAA,IAAA,OAAA,CAAMN,UAAWI,EAAON,KAAI,cAAc,OAAMH,SAC7CG,GACCQ,aAAKC,QAAQ,YAAYC,KAAK,eAAeC,MAAM,KAAKC,OAAO,KAAIf,SACjEW,EAAAA,IAAA,OAAA,CAAMK,SAAS,UAAUC,SAAS,UAAUC,EAAGzB,EAAMK,SAK7DS,EAAAA,YAAKF,UAAWI,EAAOU,QAAOnB,SAAA,CAC3BD,GAASY,EAAAA,IAAA,IAAA,CAAGN,UAAWI,EAAOV,MAAKC,SAAGD,IACtCC,GAAYW,EAAAA,IAAA,MAAA,CAAKN,UAAWI,EAAOW,KAAIpB,SAAGA,IAC1CE,GAAUS,EAAAA,IAAA,MAAA,CAAKN,UAAWI,EAAOP,OAAMF,SAAGE,OAE5CD,GACCU,EAAAA,IAAA,SAAA,CACE9B,KAAK,SACLwB,UAAWI,EAAOY,MAClBC,QAASrB,EAAO,aACJG,WAEZO,EAAAA,IAAA,MAAA,CACEC,QAAQ,YACRC,KAAK,eACLC,MAAM,KACNC,OAAO,mBACK,OAAMf,SAElBW,EAAAA,YAAMO,EAAE,6LAMpB","x_google_ignoreList":[0]}
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+
3
+ type AlertVariant = "info" | "success" | "warning" | "danger";
4
+ interface AlertProps {
5
+ /** Tipo de mensaje: info (por defecto), success, warning o danger. */
6
+ variant?: AlertVariant;
7
+ /** Título en negrita (opcional). */
8
+ title?: React.ReactNode;
9
+ /** Texto del aviso. */
10
+ children?: React.ReactNode;
11
+ /** Si se pasa, muestra el botón × y se llama al cerrarlo. */
12
+ onClose?: () => void;
13
+ /** Acción a la derecha o abajo (p. ej. un Button "Reintentar"). */
14
+ action?: React.ReactNode;
15
+ /** Icono propio; `false` para ocultarlo. Por defecto uno según el tipo. */
16
+ icon?: React.ReactNode | false;
17
+ /** Texto accesible del botón ×. */
18
+ closeLabel?: string;
19
+ /** Clase extra. */
20
+ className?: string;
21
+ }
22
+ /**
23
+ * Aviso dentro de la página (no flotante): información, éxito, advertencia o error.
24
+ * `warning` y `danger` se anuncian de inmediato (role="alert"); el resto como estado.
25
+ */
26
+ declare function Alert({ variant, title, children, onClose, action, icon, closeLabel, className, }: AlertProps): React.JSX.Element;
27
+
28
+ export { Alert as default };
29
+ export type { AlertProps, AlertVariant };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{jsxs as e,jsx as l}from"react/jsx-runtime";var r={alert:"Alert-module_alert__hwuIT",info:"Alert-module_info__KD71J",success:"Alert-module_success__ayQv-",warning:"Alert-module_warning__akwqv",danger:"Alert-module_danger__6TvpZ",icon:"Alert-module_icon__d5mez",content:"Alert-module_content__ZoStd",title:"Alert-module_title__M2SA8",text:"Alert-module_text__iT4Zu",action:"Alert-module_action__iFPW8",close:"Alert-module_close__4jXzy"};!function(e,l){void 0===l&&(l={});var r=l.insertAt;if("undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".Alert-module_alert__hwuIT {\n display: flex;\n align-items: flex-start;\n gap: var(--lb-space-3);\n padding: var(--lb-space-3) var(--lb-space-4);\n border: 1px solid;\n border-radius: var(--lb-radius-lg);\n font-family: var(--lb-font-sans);\n font-size: var(--lb-font-size-sm);\n line-height: var(--lb-line-height-normal);\n}\n\n.Alert-module_info__KD71J { background: var(--lb-color-blue-subtle); border-color: var(--lb-color-blue-border); color: var(--lb-color-blue-strong); }\n.Alert-module_success__ayQv- { background: var(--lb-color-emerald-subtle); border-color: var(--lb-color-emerald-border); color: var(--lb-color-emerald-strong); }\n.Alert-module_warning__akwqv { background: var(--lb-color-amber-subtle); border-color: var(--lb-color-amber-border); color: var(--lb-color-amber-strong); }\n.Alert-module_danger__6TvpZ { background: var(--lb-color-red-subtle); border-color: var(--lb-color-red-border); color: var(--lb-color-red-strong); }\n\n.Alert-module_icon__d5mez {\n display: inline-flex;\n flex: none;\n margin-top: 1px;\n}\n\n.Alert-module_content__ZoStd {\n flex: 1;\n min-width: 0;\n}\n\n.Alert-module_title__M2SA8 {\n margin: 0;\n font-weight: var(--lb-font-weight-semibold);\n}\n\n.Alert-module_title__M2SA8 + .Alert-module_text__iT4Zu {\n margin-top: var(--lb-space-1);\n}\n\n.Alert-module_text__iT4Zu {\n color: inherit;\n}\n\n.Alert-module_text__iT4Zu :where(p) {\n margin: 0;\n}\n\n.Alert-module_action__iFPW8 {\n margin-top: var(--lb-space-2);\n}\n\n.Alert-module_close__4jXzy {\n display: inline-flex;\n flex: none;\n padding: var(--lb-space-1);\n border: 0;\n border-radius: var(--lb-radius-sm);\n background: transparent;\n color: inherit;\n cursor: pointer;\n opacity: 0.75;\n}\n\n.Alert-module_close__4jXzy:hover {\n opacity: 1;\n}\n\n.Alert-module_close__4jXzy:focus-visible {\n outline: 2px solid var(--lb-color-ring);\n outline-offset: 1px;\n}\n");const n=(...e)=>e.filter(Boolean).join(" "),o={info:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm.75-11.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM9.25 9a.75.75 0 0 1 1.5 0v4.25a.75.75 0 0 1-1.5 0V9Z",success:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.86-9.81a.75.75 0 0 0-1.22-.88l-3.24 4.5-1.62-1.62a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.09l3.75-5.22Z",warning:"M8.48 2.94c.66-1.17 2.38-1.17 3.04 0l5.6 9.95c.65 1.16-.18 2.61-1.52 2.61H4.4c-1.34 0-2.17-1.45-1.52-2.61l5.6-9.95ZM10 6.5a.75.75 0 0 0-.75.75v3.5a.75.75 0 0 0 1.5 0v-3.5A.75.75 0 0 0 10 6.5Zm0 7.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",danger:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z"};function t({variant:t="info",title:a,children:i,onClose:d,action:c,icon:s,closeLabel:_="Cerrar aviso",className:u}){return e("div",{role:"warning"===t||"danger"===t?"alert":"status",className:n(r.alert,r[t],u),"data-variant":t,children:[!1!==s&&l("span",{className:r.icon,"aria-hidden":"true",children:s??l("svg",{viewBox:"0 0 20 20",fill:"currentColor",width:"20",height:"20",children:l("path",{fillRule:"evenodd",clipRule:"evenodd",d:o[t]})})}),e("div",{className:r.content,children:[a&&l("p",{className:r.title,children:a}),i&&l("div",{className:r.text,children:i}),c&&l("div",{className:r.action,children:c})]}),d&&l("button",{type:"button",className:r.close,onClick:d,"aria-label":_,children:l("svg",{viewBox:"0 0 20 20",fill:"currentColor",width:"16",height:"16","aria-hidden":"true",children:l("path",{d:"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z"})})})]})}export{t 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/Alert.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 styles from \"./Alert.module.css\";\n\nexport type AlertVariant = \"info\" | \"success\" | \"warning\" | \"danger\";\n\nexport interface AlertProps {\n /** Tipo de mensaje: info (por defecto), success, warning o danger. */\n variant?: AlertVariant;\n /** Título en negrita (opcional). */\n title?: React.ReactNode;\n /** Texto del aviso. */\n children?: React.ReactNode;\n /** Si se pasa, muestra el botón × y se llama al cerrarlo. */\n onClose?: () => void;\n /** Acción a la derecha o abajo (p. ej. un Button \"Reintentar\"). */\n action?: React.ReactNode;\n /** Icono propio; `false` para ocultarlo. Por defecto uno según el tipo. */\n icon?: React.ReactNode | false;\n /** Texto accesible del botón ×. */\n closeLabel?: string;\n /** Clase extra. */\n className?: string;\n}\n\nconst cx = (...c: Array<string | false | undefined>) =>\n c.filter(Boolean).join(\" \");\n\nconst ICONS: Record<AlertVariant, string> = {\n info: \"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm.75-11.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM9.25 9a.75.75 0 0 1 1.5 0v4.25a.75.75 0 0 1-1.5 0V9Z\",\n success:\n \"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.86-9.81a.75.75 0 0 0-1.22-.88l-3.24 4.5-1.62-1.62a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.09l3.75-5.22Z\",\n warning:\n \"M8.48 2.94c.66-1.17 2.38-1.17 3.04 0l5.6 9.95c.65 1.16-.18 2.61-1.52 2.61H4.4c-1.34 0-2.17-1.45-1.52-2.61l5.6-9.95ZM10 6.5a.75.75 0 0 0-.75.75v3.5a.75.75 0 0 0 1.5 0v-3.5A.75.75 0 0 0 10 6.5Zm0 7.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z\",\n danger:\n \"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z\",\n};\n\n/**\n * Aviso dentro de la página (no flotante): información, éxito, advertencia o error.\n * `warning` y `danger` se anuncian de inmediato (role=\"alert\"); el resto como estado.\n */\nexport default function Alert({\n variant = \"info\",\n title,\n children,\n onClose,\n action,\n icon,\n closeLabel = \"Cerrar aviso\",\n className,\n}: AlertProps) {\n const urgent = variant === \"warning\" || variant === \"danger\";\n return (\n <div\n role={urgent ? \"alert\" : \"status\"}\n className={cx(styles.alert, styles[variant], className)}\n data-variant={variant}\n >\n {icon !== false && (\n <span className={styles.icon} aria-hidden=\"true\">\n {icon ?? (\n <svg viewBox=\"0 0 20 20\" fill=\"currentColor\" width=\"20\" height=\"20\">\n <path fillRule=\"evenodd\" clipRule=\"evenodd\" d={ICONS[variant]} />\n </svg>\n )}\n </span>\n )}\n <div className={styles.content}>\n {title && <p className={styles.title}>{title}</p>}\n {children && <div className={styles.text}>{children}</div>}\n {action && <div className={styles.action}>{action}</div>}\n </div>\n {onClose && (\n <button\n type=\"button\"\n className={styles.close}\n onClick={onClose}\n aria-label={closeLabel}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n width=\"16\"\n height=\"16\"\n aria-hidden=\"true\"\n >\n <path d=\"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z\" />\n </svg>\n </button>\n )}\n </div>\n );\n}\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","cx","c","filter","Boolean","join","ICONS","info","success","warning","danger","Alert","variant","title","children","onClose","action","icon","closeLabel","className","_jsxs","role","styles","alert","_jsx","viewBox","fill","width","height","fillRule","clipRule","d","content","text","close","onClick"],"mappings":"2bAAA,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,83DCDA,MAAMe,EAAK,IAAIC,IACbA,EAAEC,OAAOC,SAASC,KAAK,KAEnBC,EAAsC,CAC1CC,KAAM,8IACNC,QACE,8JACFC,QACE,qOACFC,OACE,2NAOU,SAAUC,GAAMC,QAC5BA,EAAU,OAAMC,MAChBA,EAAKC,SACLA,EAAQC,QACRA,EAAOC,OACPA,EAAMC,KACNA,EAAIC,WACJA,EAAa,eAAcC,UAC3BA,IAGA,OACEC,EAAA,MAAA,CACEC,KAHuB,YAAZT,GAAqC,WAAZA,EAGrB,QAAU,SACzBO,UAAWlB,EAAGqB,EAAOC,MAAOD,EAAOV,GAAUO,kBAC/BP,EAAOE,SAAA,EAEX,IAATG,GACCO,EAAA,OAAA,CAAML,UAAWG,EAAOL,KAAI,cAAc,OAAMH,SAC7CG,GACCO,SAAKC,QAAQ,YAAYC,KAAK,eAAeC,MAAM,KAAKC,OAAO,KAAId,SACjEU,EAAA,OAAA,CAAMK,SAAS,UAAUC,SAAS,UAAUC,EAAGzB,EAAMM,SAK7DQ,SAAKD,UAAWG,EAAOU,QAAOlB,SAAA,CAC3BD,GAASW,EAAA,IAAA,CAAGL,UAAWG,EAAOT,MAAKC,SAAGD,IACtCC,GAAYU,EAAA,MAAA,CAAKL,UAAWG,EAAOW,KAAInB,SAAGA,IAC1CE,GAAUQ,EAAA,MAAA,CAAKL,UAAWG,EAAON,OAAMF,SAAGE,OAE5CD,GACCS,EAAA,SAAA,CACE9B,KAAK,SACLyB,UAAWG,EAAOY,MAClBC,QAASpB,EAAO,aACJG,WAEZM,EAAA,MAAA,CACEC,QAAQ,YACRC,KAAK,eACLC,MAAM,KACNC,OAAO,mBACK,OAAMd,SAElBU,UAAMO,EAAE,6LAMpB","x_google_ignoreList":[0]}
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "@rubenpazch/alert",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Aviso dentro de la página: info, éxito, advertencia o error",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/rubenpazch/lbyte-ui-library.git",
8
+ "directory": "packages/alert"
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": "retroalimentacion",
67
+ "resumen": "Aviso dentro de la página (info, success, warning, danger) con título, acción y cierre opcional.",
68
+ "usarCuando": "Mensajes que deben quedar visibles en la página: errores de carga, advertencias de un formulario, avisos de estado.",
69
+ "evitarCuando": "Confirmaciones pasajeras (\"Guardado\"): usa Toast. Pedir una decisión: usa ConfirmationDialog."
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
  }