@rubenpazch/alert 0.1.0 → 0.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.
package/README.md CHANGED
@@ -18,16 +18,17 @@ npm install @rubenpazch/alert
18
18
  Aviso dentro de la página (no flotante): información, éxito, advertencia o error.
19
19
  `warning` y `danger` se anuncian de inmediato (role="alert"); el resto como estado.
20
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. |
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
+ | `role` | `"alert" \| "status" \| "note"` | | | Rol ARIA. Por defecto `alert` (warning/danger) o `status` (info/success), que se anuncian al aparecer. Para un aviso fijo que ya está en la página al cargar, usa `"note"`. |
30
+ | `title` | `ReactNode` | | | Título en negrita (opcional). |
31
+ | `variant` | `"info" \| "success" \| "warning" \| "danger"` | | `info` | Tipo de mensaje: info (por defecto), success, warning o danger. |
31
32
 
32
33
  Tipos: `AlertProps`, `AlertVariant`.
33
34
 
package/dist/Alert.d.ts CHANGED
@@ -17,10 +17,15 @@ export interface AlertProps {
17
17
  closeLabel?: string;
18
18
  /** Clase extra. */
19
19
  className?: string;
20
+ /**
21
+ * Rol ARIA. Por defecto `alert` (warning/danger) o `status` (info/success), que se anuncian al
22
+ * aparecer. Para un aviso fijo que ya está en la página al cargar, usa `"note"`.
23
+ */
24
+ role?: "alert" | "status" | "note";
20
25
  }
21
26
  /**
22
27
  * Aviso dentro de la página (no flotante): información, éxito, advertencia o error.
23
28
  * `warning` y `danger` se anuncian de inmediato (role="alert"); el resto como estado.
24
29
  */
25
- export default function Alert({ variant, title, children, onClose, action, icon, closeLabel, className, }: AlertProps): React.JSX.Element;
30
+ export default function Alert({ variant, title, children, onClose, action, icon, closeLabel, className, role, }: AlertProps): React.JSX.Element;
26
31
  //# sourceMappingURL=Alert.d.ts.map
@@ -1 +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"}
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;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;CACpC;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,EACT,IAAI,GACL,EAAE,UAAU,qBA0CZ"}
package/dist/index.cjs.js CHANGED
@@ -1,2 +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"})})})]})};
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 n=l.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.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 {\n background: var(--lb-color-blue-subtle);\n border-color: var(--lb-color-blue-border);\n color: var(--lb-color-blue-strong);\n}\n.Alert-module_success__ayQv- {\n background: var(--lb-color-emerald-subtle);\n border-color: var(--lb-color-emerald-border);\n color: var(--lb-color-emerald-strong);\n}\n.Alert-module_warning__akwqv {\n background: var(--lb-color-amber-subtle);\n border-color: var(--lb-color-amber-border);\n color: var(--lb-color-amber-strong);\n}\n.Alert-module_danger__6TvpZ {\n background: var(--lb-color-red-subtle);\n border-color: var(--lb-color-red-border);\n color: var(--lb-color-red-strong);\n}\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(" "),r={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:_,role:u}){const m="warning"===o||"danger"===o;return e.jsxs("div",{role:u??(m?"alert":"status"),className:n(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:r[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
2
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +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]}
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 * Rol ARIA. Por defecto `alert` (warning/danger) o `status` (info/success), que se anuncian al\n * aparecer. Para un aviso fijo que ya está en la página al cargar, usa `\"note\"`.\n */\n role?: \"alert\" | \"status\" | \"note\";\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 role,\n}: AlertProps) {\n const urgent = variant === \"warning\" || variant === \"danger\";\n return (\n <div\n role={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","role","urgent","_jsxs","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,s6DCIA,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,EAASC,KACTA,IAEA,MAAMC,EAAqB,YAAZT,GAAqC,WAAZA,EACxC,OACEU,EAAAA,KAAA,MAAA,CACEF,KAAMA,IAASC,EAAS,QAAU,UAClCF,UAAWjB,EAAGqB,EAAOC,MAAOD,EAAOX,GAAUO,kBAC/BP,EAAOE,SAAA,EAEX,IAATG,GACCQ,EAAAA,IAAA,OAAA,CAAMN,UAAWI,EAAON,mBAAkB,OAAMH,SAC7CG,GACCQ,EAAAA,WAAKC,QAAQ,YAAYC,KAAK,eAAeC,MAAM,KAAKC,OAAO,KAAIf,SACjEW,EAAAA,IAAA,OAAA,CAAMK,SAAS,UAAUC,SAAS,UAAUC,EAAGzB,EAAMK,SAK7DU,EAAAA,KAAA,MAAA,CAAKH,UAAWI,EAAOU,kBACpBpB,GAASY,EAAAA,SAAGN,UAAWI,EAAOV,eAAQA,IACtCC,GAAYW,EAAAA,WAAKN,UAAWI,EAAOW,cAAOpB,IAC1CE,GAAUS,EAAAA,WAAKN,UAAWI,EAAOP,gBAASA,OAE5CD,GACCU,EAAAA,IAAA,SAAA,CACE9B,KAAK,SACLwB,UAAWI,EAAOY,MAClBC,QAASrB,EAAO,aACJG,EAAUJ,SAEtBW,EAAAA,IAAA,MAAA,CACEC,QAAQ,YACRC,KAAK,eACLC,MAAM,KACNC,OAAO,mBACK,OAAMf,SAElBW,EAAAA,YAAMO,EAAE,6LAMpB","x_google_ignoreList":[0]}
package/dist/index.d.ts CHANGED
@@ -18,12 +18,17 @@ interface AlertProps {
18
18
  closeLabel?: string;
19
19
  /** Clase extra. */
20
20
  className?: string;
21
+ /**
22
+ * Rol ARIA. Por defecto `alert` (warning/danger) o `status` (info/success), que se anuncian al
23
+ * aparecer. Para un aviso fijo que ya está en la página al cargar, usa `"note"`.
24
+ */
25
+ role?: "alert" | "status" | "note";
21
26
  }
22
27
  /**
23
28
  * Aviso dentro de la página (no flotante): información, éxito, advertencia o error.
24
29
  * `warning` y `danger` se anuncian de inmediato (role="alert"); el resto como estado.
25
30
  */
26
- declare function Alert({ variant, title, children, onClose, action, icon, closeLabel, className, }: AlertProps): React.JSX.Element;
31
+ declare function Alert({ variant, title, children, onClose, action, icon, closeLabel, className, role, }: AlertProps): React.JSX.Element;
27
32
 
28
33
  export { Alert as default };
29
34
  export type { AlertProps, AlertVariant };
package/dist/index.esm.js CHANGED
@@ -1,2 +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};
1
+ import{jsxs as e,jsx as l}from"react/jsx-runtime";var n={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 n=l.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.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 {\n background: var(--lb-color-blue-subtle);\n border-color: var(--lb-color-blue-border);\n color: var(--lb-color-blue-strong);\n}\n.Alert-module_success__ayQv- {\n background: var(--lb-color-emerald-subtle);\n border-color: var(--lb-color-emerald-border);\n color: var(--lb-color-emerald-strong);\n}\n.Alert-module_warning__akwqv {\n background: var(--lb-color-amber-subtle);\n border-color: var(--lb-color-amber-border);\n color: var(--lb-color-amber-strong);\n}\n.Alert-module_danger__6TvpZ {\n background: var(--lb-color-red-subtle);\n border-color: var(--lb-color-red-border);\n color: var(--lb-color-red-strong);\n}\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(" "),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,role:m}){return e("div",{role:m??("warning"===t||"danger"===t?"alert":"status"),className:r(n.alert,n[t],u),"data-variant":t,children:[!1!==s&&l("span",{className:n.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:n.content,children:[a&&l("p",{className:n.title,children:a}),i&&l("div",{className:n.text,children:i}),c&&l("div",{className:n.action,children:c})]}),d&&l("button",{type:"button",className:n.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
2
  //# sourceMappingURL=index.esm.js.map
@@ -1 +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]}
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 * Rol ARIA. Por defecto `alert` (warning/danger) o `status` (info/success), que se anuncian al\n * aparecer. Para un aviso fijo que ya está en la página al cargar, usa `\"note\"`.\n */\n role?: \"alert\" | \"status\" | \"note\";\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 role,\n}: AlertProps) {\n const urgent = variant === \"warning\" || variant === \"danger\";\n return (\n <div\n role={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","role","_jsxs","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,s6DCIA,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,EAASC,KACTA,IAGA,OACEC,EAAA,MAAA,CACED,KAAMA,IAHiB,YAAZR,GAAqC,WAAZA,EAGZ,QAAU,UAClCO,UAAWlB,EAAGqB,EAAOC,MAAOD,EAAOV,GAAUO,kBAC/BP,EAAOE,SAAA,EAEX,IAATG,GACCO,EAAA,OAAA,CAAML,UAAWG,EAAOL,mBAAkB,OAAMH,SAC7CG,GACCO,SAAKC,QAAQ,YAAYC,KAAK,eAAeC,MAAM,KAAKC,OAAO,KAAId,SACjEU,EAAA,OAAA,CAAMK,SAAS,UAAUC,SAAS,UAAUC,EAAGzB,EAAMM,SAK7DS,EAAA,MAAA,CAAKF,UAAWG,EAAOU,kBACpBnB,GAASW,OAAGL,UAAWG,EAAOT,eAAQA,IACtCC,GAAYU,SAAKL,UAAWG,EAAOW,cAAOnB,IAC1CE,GAAUQ,SAAKL,UAAWG,EAAON,gBAASA,OAE5CD,GACCS,EAAA,SAAA,CACE9B,KAAK,SACLyB,UAAWG,EAAOY,MAClBC,QAASpB,EAAO,aACJG,EAAUJ,SAEtBU,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,6 @@
1
1
  {
2
2
  "name": "@rubenpazch/alert",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Aviso dentro de la página: info, éxito, advertencia o error",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "peerDependencies": {
28
28
  "react": "^19.2.3",
29
29
  "react-dom": "^19.2.3",
30
- "@rubenpazch/tokens": "0.4.0"
30
+ "@rubenpazch/tokens": "0.5.0"
31
31
  },
32
32
  "dependencies": {
33
33
  "@rubenpazch/shared": "5.2.0"
@@ -56,8 +56,8 @@
56
56
  "rollup-plugin-typescript2": "^0.37.0",
57
57
  "tslib": "^2.8.1",
58
58
  "typescript": "^6.0.3",
59
- "@rubenpazch/eslint-config": "4.0.0",
60
- "@rubenpazch/typescript-config": "3.0.0"
59
+ "@rubenpazch/typescript-config": "3.0.0",
60
+ "@rubenpazch/eslint-config": "4.0.0"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public"