asterui 0.12.44 → 0.12.47

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.
Files changed (59) hide show
  1. package/dist/components/Button.d.ts +0 -1
  2. package/dist/components/Button.js +8 -9
  3. package/dist/components/Button.js.map +1 -1
  4. package/dist/components/Checkbox.d.ts +4 -1
  5. package/dist/components/Checkbox.js +106 -77
  6. package/dist/components/Checkbox.js.map +1 -1
  7. package/dist/components/ConfigProvider.d.ts +59 -0
  8. package/dist/components/ConfigProvider.js +46 -0
  9. package/dist/components/ConfigProvider.js.map +1 -0
  10. package/dist/components/CopyButton.d.ts +3 -0
  11. package/dist/components/CopyButton.js +90 -64
  12. package/dist/components/CopyButton.js.map +1 -1
  13. package/dist/components/Message.d.ts +20 -0
  14. package/dist/components/Message.js +56 -0
  15. package/dist/components/Message.js.map +1 -0
  16. package/dist/components/Notification.d.ts +8 -1
  17. package/dist/components/Notification.js +84 -60
  18. package/dist/components/Notification.js.map +1 -1
  19. package/dist/components/Tour.d.ts +71 -9
  20. package/dist/components/Tour.js +361 -198
  21. package/dist/components/Tour.js.map +1 -1
  22. package/dist/contexts/IconSizeContext.d.ts +2 -0
  23. package/dist/contexts/IconSizeContext.js +6 -0
  24. package/dist/contexts/IconSizeContext.js.map +1 -0
  25. package/dist/index.d.ts +14 -6
  26. package/dist/index.js +237 -207
  27. package/dist/index.js.map +1 -1
  28. package/dist/locale/de-DE.d.ts +3 -0
  29. package/dist/locale/de-DE.js +100 -0
  30. package/dist/locale/de-DE.js.map +1 -0
  31. package/dist/locale/en-CA.d.ts +3 -0
  32. package/dist/locale/en-CA.js +11 -0
  33. package/dist/locale/en-CA.js.map +1 -0
  34. package/dist/locale/en-GB.d.ts +3 -0
  35. package/dist/locale/en-GB.js +11 -0
  36. package/dist/locale/en-GB.js.map +1 -0
  37. package/dist/locale/en-US.d.ts +3 -0
  38. package/dist/locale/en-US.js +100 -0
  39. package/dist/locale/en-US.js.map +1 -0
  40. package/dist/locale/es-ES.d.ts +3 -0
  41. package/dist/locale/es-ES.js +100 -0
  42. package/dist/locale/es-ES.js.map +1 -0
  43. package/dist/locale/fr-FR.d.ts +3 -0
  44. package/dist/locale/fr-FR.js +100 -0
  45. package/dist/locale/fr-FR.js.map +1 -0
  46. package/dist/locale/index.d.ts +107 -0
  47. package/dist/locale/ja-JP.d.ts +3 -0
  48. package/dist/locale/ja-JP.js +100 -0
  49. package/dist/locale/ja-JP.js.map +1 -0
  50. package/dist/locale/ko-KR.d.ts +3 -0
  51. package/dist/locale/ko-KR.js +100 -0
  52. package/dist/locale/ko-KR.js.map +1 -0
  53. package/dist/locale/pt-BR.d.ts +3 -0
  54. package/dist/locale/pt-BR.js +100 -0
  55. package/dist/locale/pt-BR.js.map +1 -0
  56. package/dist/locale/zh-CN.d.ts +3 -0
  57. package/dist/locale/zh-CN.js +100 -0
  58. package/dist/locale/zh-CN.js.map +1 -0
  59. package/package.json +1 -1
@@ -1,48 +1,68 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { useClipboard as z } from "../hooks/useClipboard.js";
3
- const W = () => /* @__PURE__ */ n(
4
- "svg",
5
- {
6
- className: "w-4 h-4",
7
- fill: "none",
8
- viewBox: "0 0 24 24",
9
- stroke: "currentColor",
10
- children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" })
11
- }
12
- ), E = () => /* @__PURE__ */ n(
13
- "svg",
14
- {
15
- className: "w-4 h-4",
16
- fill: "none",
17
- viewBox: "0 0 24 24",
18
- stroke: "currentColor",
19
- children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m4.5 12.75 6 6 9-13.5" })
20
- }
21
- ), F = ({
22
- text: l,
23
- timeout: u = 2e3,
24
- color: t,
25
- variant: o,
26
- size: d = "md",
27
- shape: e,
28
- icon: b,
29
- copiedIcon: p,
30
- children: h,
31
- copiedChildren: m,
32
- onCopy: f,
33
- onError: C,
34
- showTooltip: k = !1,
35
- tooltipText: c = "Copy",
36
- copiedTooltipText: r = "Copied!",
37
- className: y = "",
38
- disabled: a,
39
- onClick: g,
40
- ...v
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { useContext as f } from "react";
3
+ import { useClipboard as M } from "../hooks/useClipboard.js";
4
+ import { IconSizeContext as r } from "../contexts/IconSizeContext.js";
5
+ const C = {
6
+ xs: "w-3.5 h-3.5",
7
+ sm: "w-3.5 h-3.5",
8
+ md: "w-4 h-4",
9
+ lg: "w-5 h-5",
10
+ xl: "w-6 h-6"
11
+ }, P = () => {
12
+ const o = f(r) ?? "md";
13
+ return /* @__PURE__ */ t(
14
+ "svg",
15
+ {
16
+ className: C[o],
17
+ fill: "none",
18
+ viewBox: "0 0 24 24",
19
+ stroke: "currentColor",
20
+ children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" })
21
+ }
22
+ );
23
+ }, V = () => {
24
+ const o = f(r) ?? "md";
25
+ return /* @__PURE__ */ t(
26
+ "svg",
27
+ {
28
+ className: C[o],
29
+ fill: "none",
30
+ viewBox: "0 0 24 24",
31
+ stroke: "currentColor",
32
+ children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m4.5 12.75 6 6 9-13.5" })
33
+ }
34
+ );
35
+ }, p = {
36
+ "top-right": "absolute top-2 right-2",
37
+ "top-left": "absolute top-2 left-2",
38
+ "bottom-right": "absolute bottom-2 right-2",
39
+ "bottom-left": "absolute bottom-2 left-2"
40
+ }, A = ({
41
+ text: o,
42
+ timeout: g = 2e3,
43
+ color: c,
44
+ variant: a,
45
+ size: l = "md",
46
+ shape: i,
47
+ position: s,
48
+ icon: k,
49
+ copiedIcon: y,
50
+ children: v,
51
+ copiedChildren: w,
52
+ onCopy: x,
53
+ onError: I,
54
+ showTooltip: u = !1,
55
+ tooltipText: b = "Copy",
56
+ copiedTooltipText: d = "Copied!",
57
+ className: B = "",
58
+ disabled: m,
59
+ onClick: j,
60
+ ...z
41
61
  }) => {
42
- const { copy: w, copied: s } = z(u), x = async (q) => {
43
- if (g?.(q), a) return;
44
- await w(l) ? f?.() : C?.(new Error("Failed to copy to clipboard"));
45
- }, I = {
62
+ const { copy: N, copied: n } = M(g), L = async (e) => {
63
+ if (j?.(e), m) return;
64
+ await N(o) ? x?.() : I?.(new Error("Failed to copy to clipboard"));
65
+ }, q = {
46
66
  primary: "btn-primary",
47
67
  secondary: "btn-secondary",
48
68
  accent: "btn-accent",
@@ -51,46 +71,52 @@ const W = () => /* @__PURE__ */ n(
51
71
  warning: "btn-warning",
52
72
  error: "btn-error",
53
73
  neutral: "btn-neutral"
54
- }, B = {
74
+ }, S = {
55
75
  solid: "",
56
76
  outline: "btn-outline",
57
77
  dash: "btn-dash",
58
78
  soft: "btn-soft",
59
79
  ghost: "btn-ghost",
60
80
  link: "btn-link"
61
- }, N = {
81
+ }, W = {
62
82
  xs: "btn-xs",
63
83
  sm: "btn-sm",
64
84
  md: "",
65
85
  lg: "btn-lg",
66
86
  xl: "btn-xl"
67
- }, j = {
87
+ }, E = {
68
88
  square: "btn-square",
69
89
  circle: "btn-circle"
70
- }, L = [
90
+ }, F = [
71
91
  "btn",
72
- t && I[t],
73
- s && "btn-success",
74
- o && B[o],
75
- N[d],
76
- e && j[e],
77
- y
78
- ].filter(Boolean).join(" "), i = /* @__PURE__ */ n(
92
+ c && q[c],
93
+ n && "btn-success",
94
+ a && S[a],
95
+ W[l],
96
+ i && E[i],
97
+ // Only add position classes if not using tooltip (tooltip wrapper gets them instead)
98
+ !u && s && p[s],
99
+ B
100
+ ].filter(Boolean).join(" "), H = n ? w ?? (y ?? /* @__PURE__ */ t(V, {})) : v ?? (k ?? /* @__PURE__ */ t(P, {})), h = /* @__PURE__ */ t(
79
101
  "button",
80
102
  {
81
103
  type: "button",
82
- className: L,
83
- onClick: x,
84
- disabled: a,
85
- "aria-label": s ? r : c,
86
- ...v,
87
- children: s ? m ?? (p ?? /* @__PURE__ */ n(E, {})) : h ?? (b ?? /* @__PURE__ */ n(W, {}))
104
+ className: F,
105
+ onClick: L,
106
+ disabled: m,
107
+ "aria-label": n ? d : b,
108
+ ...z,
109
+ children: /* @__PURE__ */ t(r.Provider, { value: l, children: H })
88
110
  }
89
111
  );
90
- return k ? /* @__PURE__ */ n("div", { className: "tooltip", "data-tip": s ? r : c, children: i }) : i;
112
+ if (u) {
113
+ const e = ["tooltip", s && p[s]].filter(Boolean).join(" ");
114
+ return /* @__PURE__ */ t("div", { className: e, "data-tip": n ? d : b, children: h });
115
+ }
116
+ return h;
91
117
  };
92
- F.displayName = "CopyButton";
118
+ A.displayName = "CopyButton";
93
119
  export {
94
- F as CopyButton
120
+ A as CopyButton
95
121
  };
96
122
  //# sourceMappingURL=CopyButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyButton.js","sources":["../../src/components/CopyButton.tsx"],"sourcesContent":["import React from 'react'\nimport { useClipboard } from '../hooks/useClipboard'\n\nexport interface CopyButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onError'> {\n /** Text to copy to clipboard */\n text: string\n /** Duration in ms to show copied state */\n timeout?: number\n /** Button color */\n color?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'neutral'\n /** Button style variant */\n variant?: 'solid' | 'outline' | 'dash' | 'soft' | 'ghost' | 'link'\n /** Button size */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Button shape */\n shape?: 'square' | 'circle'\n /** Custom icon for default state */\n icon?: React.ReactNode\n /** Custom icon for copied state */\n copiedIcon?: React.ReactNode\n /** Custom content for default state (overrides icon) */\n children?: React.ReactNode\n /** Custom content for copied state */\n copiedChildren?: React.ReactNode\n /** Callback when copy succeeds */\n onCopy?: () => void\n /** Callback when copy fails */\n onError?: (error: Error) => void\n /** Show tooltip with copy status */\n showTooltip?: boolean\n /** Tooltip text for default state */\n tooltipText?: string\n /** Tooltip text for copied state */\n copiedTooltipText?: string\n}\n\nconst CopyIcon: React.FC = () => (\n <svg\n className=\"w-4 h-4\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\" />\n </svg>\n)\n\nconst CheckIcon: React.FC = () => (\n <svg\n className=\"w-4 h-4\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"m4.5 12.75 6 6 9-13.5\" />\n </svg>\n)\n\nexport const CopyButton: React.FC<CopyButtonProps> = ({\n text,\n timeout = 2000,\n color,\n variant,\n size = 'md',\n shape,\n icon,\n copiedIcon,\n children,\n copiedChildren,\n onCopy,\n onError,\n showTooltip = false,\n tooltipText = 'Copy',\n copiedTooltipText = 'Copied!',\n className = '',\n disabled,\n onClick,\n ...rest\n}) => {\n const { copy, copied } = useClipboard(timeout)\n\n const handleClick = async (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e)\n if (disabled) return\n\n const success = await copy(text)\n if (success) {\n onCopy?.()\n } else {\n onError?.(new Error('Failed to copy to clipboard'))\n }\n }\n\n const colorClasses = {\n primary: 'btn-primary',\n secondary: 'btn-secondary',\n accent: 'btn-accent',\n info: 'btn-info',\n success: 'btn-success',\n warning: 'btn-warning',\n error: 'btn-error',\n neutral: 'btn-neutral',\n }\n\n const variantClasses = {\n solid: '',\n outline: 'btn-outline',\n dash: 'btn-dash',\n soft: 'btn-soft',\n ghost: 'btn-ghost',\n link: 'btn-link',\n }\n\n const sizeClasses = {\n xs: 'btn-xs',\n sm: 'btn-sm',\n md: '',\n lg: 'btn-lg',\n xl: 'btn-xl',\n }\n\n const shapeClasses = {\n square: 'btn-square',\n circle: 'btn-circle',\n }\n\n const classes = [\n 'btn',\n color && colorClasses[color],\n copied && 'btn-success',\n variant && variantClasses[variant],\n sizeClasses[size],\n shape && shapeClasses[shape],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const defaultIcon = icon ?? <CopyIcon />\n const successIcon = copiedIcon ?? <CheckIcon />\n\n const content = copied\n ? (copiedChildren ?? successIcon)\n : (children ?? defaultIcon)\n\n const button = (\n <button\n type=\"button\"\n className={classes}\n onClick={handleClick}\n disabled={disabled}\n aria-label={copied ? copiedTooltipText : tooltipText}\n {...rest}\n >\n {content}\n </button>\n )\n\n if (showTooltip) {\n return (\n <div className=\"tooltip\" data-tip={copied ? copiedTooltipText : tooltipText}>\n {button}\n </div>\n )\n }\n\n return button\n}\n\nCopyButton.displayName = 'CopyButton'\n"],"names":["CopyIcon","jsx","CheckIcon","CopyButton","text","timeout","color","variant","size","shape","icon","copiedIcon","children","copiedChildren","onCopy","onError","showTooltip","tooltipText","copiedTooltipText","className","disabled","onClick","rest","copy","copied","useClipboard","handleClick","e","colorClasses","variantClasses","sizeClasses","shapeClasses","classes","button"],"mappings":";;AAoCA,MAAMA,IAAqB,MACzB,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAU;AAAA,IACV,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,QAAO;AAAA,IAEP,UAAA,gBAAAA,EAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,aAAY,KAAI,GAAE,wHAAA,CAA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AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EAAA,GAGAC,IAAe;AAAA,IACnB,QAAQ;AAAA,IACR,QAAQ;AAAA,EAAA,GAGJC,IAAU;AAAA,IACd;AAAA,IACA1B,KAASsB,EAAatB,CAAK;AAAA,IAC3BkB,KAAU;AAAA,IACVjB,KAAWsB,EAAetB,CAAO;AAAA,IACjCuB,EAAYtB,CAAI;AAAA,IAChBC,KAASsB,EAAatB,CAAK;AAAA,IAC3BU;AAAA,EAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG,GASLc,IACJ,gBAAAhC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAW+B;AAAA,MACX,SAASN;AAAA,MACT,UAAAN;AAAA,MACA,cAAYI,IAASN,IAAoBD;AAAA,MACxC,GAAGK;AAAA,MAEH,UAbWE,IACXX,MAHeF,KAAc,gBAAAV,EAACC,GAAA,CAAA,CAAU,KAIxCU,MALeF,KAAQ,gBAAAT,EAACD,GAAA,CAAA,CAAS;AAAA,IAgBjC;AAAA,EAAA;AAIL,SAAIgB,IAEA,gBAAAf,EAAC,SAAI,WAAU,WAAU,YAAUuB,IAASN,IAAoBD,GAC7D,UAAAgB,EAAA,CACH,IAIGA;AACT;AAEA9B,EAAW,cAAc;"}
1
+ {"version":3,"file":"CopyButton.js","sources":["../../src/components/CopyButton.tsx"],"sourcesContent":["import React, { useContext } from 'react'\nimport { useClipboard } from '../hooks/useClipboard'\nimport { IconSizeContext } from '../contexts/IconSizeContext'\n\nconst iconSizeClasses = {\n xs: 'w-3.5 h-3.5',\n sm: 'w-3.5 h-3.5',\n md: 'w-4 h-4',\n lg: 'w-5 h-5',\n xl: 'w-6 h-6',\n}\n\nexport type CopyButtonPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'\n\nexport interface CopyButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onError'> {\n /** Text to copy to clipboard */\n text: string\n /** Duration in ms to show copied state */\n timeout?: number\n /** Button color */\n color?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'neutral'\n /** Button style variant */\n variant?: 'solid' | 'outline' | 'dash' | 'soft' | 'ghost' | 'link'\n /** Button size */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Button shape */\n shape?: 'square' | 'circle'\n /** Absolute position within parent (parent must have position: relative) */\n position?: CopyButtonPosition\n /** Custom icon for default state */\n icon?: React.ReactNode\n /** Custom icon for copied state */\n copiedIcon?: React.ReactNode\n /** Custom content for default state (overrides icon) */\n children?: React.ReactNode\n /** Custom content for copied state */\n copiedChildren?: React.ReactNode\n /** Callback when copy succeeds */\n onCopy?: () => void\n /** Callback when copy fails */\n onError?: (error: Error) => void\n /** Show tooltip with copy status */\n showTooltip?: boolean\n /** Tooltip text for default state */\n tooltipText?: string\n /** Tooltip text for copied state */\n copiedTooltipText?: string\n}\n\nconst CopyIcon: React.FC = () => {\n const size = useContext(IconSizeContext) ?? 'md'\n return (\n <svg\n className={iconSizeClasses[size]}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\" />\n </svg>\n )\n}\n\nconst CheckIcon: React.FC = () => {\n const size = useContext(IconSizeContext) ?? 'md'\n return (\n <svg\n className={iconSizeClasses[size]}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"m4.5 12.75 6 6 9-13.5\" />\n </svg>\n )\n}\n\nconst positionClasses: Record<CopyButtonPosition, string> = {\n 'top-right': 'absolute top-2 right-2',\n 'top-left': 'absolute top-2 left-2',\n 'bottom-right': 'absolute bottom-2 right-2',\n 'bottom-left': 'absolute bottom-2 left-2',\n}\n\nexport const CopyButton: React.FC<CopyButtonProps> = ({\n text,\n timeout = 2000,\n color,\n variant,\n size = 'md',\n shape,\n position,\n icon,\n copiedIcon,\n children,\n copiedChildren,\n onCopy,\n onError,\n showTooltip = false,\n tooltipText = 'Copy',\n copiedTooltipText = 'Copied!',\n className = '',\n disabled,\n onClick,\n ...rest\n}) => {\n const { copy, copied } = useClipboard(timeout)\n\n const handleClick = async (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e)\n if (disabled) return\n\n const success = await copy(text)\n if (success) {\n onCopy?.()\n } else {\n onError?.(new Error('Failed to copy to clipboard'))\n }\n }\n\n const colorClasses = {\n primary: 'btn-primary',\n secondary: 'btn-secondary',\n accent: 'btn-accent',\n info: 'btn-info',\n success: 'btn-success',\n warning: 'btn-warning',\n error: 'btn-error',\n neutral: 'btn-neutral',\n }\n\n const variantClasses = {\n solid: '',\n outline: 'btn-outline',\n dash: 'btn-dash',\n soft: 'btn-soft',\n ghost: 'btn-ghost',\n link: 'btn-link',\n }\n\n const sizeClasses = {\n xs: 'btn-xs',\n sm: 'btn-sm',\n md: '',\n lg: 'btn-lg',\n xl: 'btn-xl',\n }\n\n const shapeClasses = {\n square: 'btn-square',\n circle: 'btn-circle',\n }\n\n const classes = [\n 'btn',\n color && colorClasses[color],\n copied && 'btn-success',\n variant && variantClasses[variant],\n sizeClasses[size],\n shape && shapeClasses[shape],\n // Only add position classes if not using tooltip (tooltip wrapper gets them instead)\n !showTooltip && position && positionClasses[position],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const defaultIcon = icon ?? <CopyIcon />\n const successIcon = copiedIcon ?? <CheckIcon />\n\n const content = copied\n ? (copiedChildren ?? successIcon)\n : (children ?? defaultIcon)\n\n const button = (\n <button\n type=\"button\"\n className={classes}\n onClick={handleClick}\n disabled={disabled}\n aria-label={copied ? copiedTooltipText : tooltipText}\n {...rest}\n >\n <IconSizeContext.Provider value={size}>\n {content}\n </IconSizeContext.Provider>\n </button>\n )\n\n if (showTooltip) {\n const tooltipClasses = ['tooltip', position && positionClasses[position]].filter(Boolean).join(' ')\n return (\n <div className={tooltipClasses} data-tip={copied ? copiedTooltipText : tooltipText}>\n {button}\n </div>\n )\n }\n\n return button\n}\n\nCopyButton.displayName = 'CopyButton'\n"],"names":["iconSizeClasses","CopyIcon","size","useContext","IconSizeContext","jsx","CheckIcon","positionClasses","CopyButton","text","timeout","color","variant","shape","position","icon","copiedIcon","children","copiedChildren","onCopy","onError","showTooltip","tooltipText","copiedTooltipText","className","disabled","onClick","rest","copy","copied","useClipboard","handleClick","colorClasses","variantClasses","sizeClasses","shapeClasses","classes","content","button","tooltipClasses"],"mappings":";;;;AAIA,MAAMA,IAAkB;AAAA,EACtB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAuCMC,IAAqB,MAAM;AAC/B,QAAMC,IAAOC,EAAWC,CAAe,KAAK;AAC5C,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWL,EAAgBE,CAAI;AAAA,MAC/B,MAAK;AAAA,MACL,SAAQ;AAAA,MACR,QAAO;AAAA,MAEP,UAAA,gBAAAG,EAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,aAAY,KAAI,GAAE,wHAAA,CAAwH;AAAA,IAAA;AAAA,EAAA;AAGnM,GAEMC,IAAsB,MAAM;AAChC,QAAMJ,IAAOC,EAAWC,CAAe,KAAK;AAC5C,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWL,EAAgBE,CAAI;AAAA,MAC/B,MAAK;AAAA,MACL,SAAQ;AAAA,MACR,QAAO;AAAA,MAEP,UAAA,gBAAAG,EAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,aAAY,KA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AAA,IACnB,QAAQ;AAAA,IACR,QAAQ;AAAA,EAAA,GAGJC,IAAU;AAAA,IACd;AAAA,IACAzB,KAASqB,EAAarB,CAAK;AAAA,IAC3BkB,KAAU;AAAA,IACVjB,KAAWqB,EAAerB,CAAO;AAAA,IACjCsB,EAAYhC,CAAI;AAAA,IAChBW,KAASsB,EAAatB,CAAK;AAAA;AAAA,IAE3B,CAACQ,KAAeP,KAAYP,EAAgBO,CAAQ;AAAA,IACpDU;AAAA,EAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG,GAKLa,IAAUR,IACXX,MAHeF,KAAc,gBAAAX,EAACC,GAAA,CAAA,CAAU,KAIxCW,MALeF,KAAQ,gBAAAV,EAACJ,GAAA,CAAA,CAAS,IAOhCqC,IACJ,gBAAAjC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAW+B;AAAA,MACX,SAASL;AAAA,MACT,UAAAN;AAAA,MACA,cAAYI,IAASN,IAAoBD;AAAA,MACxC,GAAGK;AAAA,MAEJ,4BAACvB,EAAgB,UAAhB,EAAyB,OAAOF,GAC9B,UAAAmC,EAAA,CACH;AAAA,IAAA;AAAA,EAAA;AAIJ,MAAIhB,GAAa;AACf,UAAMkB,IAAiB,CAAC,WAAWzB,KAAYP,EAAgBO,CAAQ,CAAC,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAClG,WACE,gBAAAT,EAAC,SAAI,WAAWkC,GAAgB,YAAUV,IAASN,IAAoBD,GACpE,UAAAgB,EAAA,CACH;AAAA,EAEJ;AAEA,SAAOA;AACT;AAEA9B,EAAW,cAAc;"}
@@ -0,0 +1,20 @@
1
+ import { default as React } from 'react';
2
+ export interface MessageConfig {
3
+ duration?: number;
4
+ key?: string;
5
+ icon?: React.ReactNode;
6
+ className?: string;
7
+ style?: React.CSSProperties;
8
+ 'data-testid'?: string;
9
+ onClick?: () => void;
10
+ onClose?: () => void;
11
+ }
12
+ export declare class MessageManager {
13
+ success(content: React.ReactNode, config?: MessageConfig): string;
14
+ error(content: React.ReactNode, config?: MessageConfig): string;
15
+ info(content: React.ReactNode, config?: MessageConfig): string;
16
+ warning(content: React.ReactNode, config?: MessageConfig): string;
17
+ loading(content: React.ReactNode, config?: MessageConfig): string;
18
+ destroy(id?: string): void;
19
+ }
20
+ export declare const message: MessageManager;
@@ -0,0 +1,56 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { notification as a } from "./Notification.js";
3
+ class r {
4
+ success(e, n) {
5
+ return a.open({
6
+ message: e,
7
+ type: "success",
8
+ variant: "compact",
9
+ ...n
10
+ });
11
+ }
12
+ error(e, n) {
13
+ return a.open({
14
+ message: e,
15
+ type: "error",
16
+ variant: "compact",
17
+ ...n
18
+ });
19
+ }
20
+ info(e, n) {
21
+ return a.open({
22
+ message: e,
23
+ type: "info",
24
+ variant: "compact",
25
+ ...n
26
+ });
27
+ }
28
+ warning(e, n) {
29
+ return a.open({
30
+ message: e,
31
+ type: "warning",
32
+ variant: "compact",
33
+ ...n
34
+ });
35
+ }
36
+ loading(e, n) {
37
+ const o = /* @__PURE__ */ s("span", { className: "loading loading-spinner loading-sm" });
38
+ return a.open({
39
+ message: e,
40
+ type: "info",
41
+ variant: "compact",
42
+ duration: 0,
43
+ icon: o,
44
+ ...n
45
+ });
46
+ }
47
+ destroy(e) {
48
+ e ? a.close(e) : a.destroy();
49
+ }
50
+ }
51
+ const p = new r();
52
+ export {
53
+ r as MessageManager,
54
+ p as message
55
+ };
56
+ //# sourceMappingURL=Message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Message.js","sources":["../../src/components/Message.tsx"],"sourcesContent":["import React from 'react'\nimport { notification } from './Notification'\n\nexport interface MessageConfig {\n duration?: number\n key?: string\n icon?: React.ReactNode\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n onClick?: () => void\n onClose?: () => void\n}\n\nexport class MessageManager {\n success(content: React.ReactNode, config?: MessageConfig) {\n return notification.open({\n message: content,\n type: 'success',\n variant: 'compact',\n ...config,\n })\n }\n\n error(content: React.ReactNode, config?: MessageConfig) {\n return notification.open({\n message: content,\n type: 'error',\n variant: 'compact',\n ...config,\n })\n }\n\n info(content: React.ReactNode, config?: MessageConfig) {\n return notification.open({\n message: content,\n type: 'info',\n variant: 'compact',\n ...config,\n })\n }\n\n warning(content: React.ReactNode, config?: MessageConfig) {\n return notification.open({\n message: content,\n type: 'warning',\n variant: 'compact',\n ...config,\n })\n }\n\n loading(content: React.ReactNode, config?: MessageConfig) {\n const loadingIcon = (\n <span className=\"loading loading-spinner loading-sm\" />\n )\n return notification.open({\n message: content,\n type: 'info',\n variant: 'compact',\n duration: 0,\n icon: loadingIcon,\n ...config,\n })\n }\n\n destroy(id?: string) {\n if (id) {\n notification.close(id)\n } else {\n notification.destroy()\n }\n }\n}\n\nexport const message = new MessageManager()\n"],"names":["MessageManager","content","config","notification","loadingIcon","jsx","id","message"],"mappings":";;AAcO,MAAMA,EAAe;AAAA,EAC1B,QAAQC,GAA0BC,GAAwB;AACxD,WAAOC,EAAa,KAAK;AAAA,MACvB,SAASF;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,GAAGC;AAAA,IAAA,CACJ;AAAA,EACH;AAAA,EAEA,MAAMD,GAA0BC,GAAwB;AACtD,WAAOC,EAAa,KAAK;AAAA,MACvB,SAASF;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,GAAGC;AAAA,IAAA,CACJ;AAAA,EACH;AAAA,EAEA,KAAKD,GAA0BC,GAAwB;AACrD,WAAOC,EAAa,KAAK;AAAA,MACvB,SAASF;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,GAAGC;AAAA,IAAA,CACJ;AAAA,EACH;AAAA,EAEA,QAAQD,GAA0BC,GAAwB;AACxD,WAAOC,EAAa,KAAK;AAAA,MACvB,SAASF;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,GAAGC;AAAA,IAAA,CACJ;AAAA,EACH;AAAA,EAEA,QAAQD,GAA0BC,GAAwB;AACxD,UAAME,IACJ,gBAAAC,EAAC,QAAA,EAAK,WAAU,qCAAA,CAAqC;AAEvD,WAAOF,EAAa,KAAK;AAAA,MACvB,SAASF;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,MACV,MAAMG;AAAA,MACN,GAAGF;AAAA,IAAA,CACJ;AAAA,EACH;AAAA,EAEA,QAAQI,GAAa;AACnB,IAAIA,IACFH,EAAa,MAAMG,CAAE,IAErBH,EAAa,QAAA;AAAA,EAEjB;AACF;AAEO,MAAMI,IAAU,IAAIP,EAAA;"}
@@ -1,13 +1,20 @@
1
1
  import { default as React } from 'react';
2
2
  export type NotificationType = 'success' | 'info' | 'warning' | 'error';
3
- export type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
3
+ export type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'topCenter' | 'bottomCenter';
4
+ export type NotificationVariant = 'default' | 'compact';
4
5
  export interface NotificationConfig {
5
6
  message: React.ReactNode;
6
7
  description?: React.ReactNode;
7
8
  type?: NotificationType;
8
9
  duration?: number;
9
10
  placement?: NotificationPlacement;
11
+ variant?: NotificationVariant;
10
12
  closable?: boolean;
13
+ icon?: React.ReactNode;
14
+ key?: string;
15
+ className?: string;
16
+ style?: React.CSSProperties;
17
+ 'data-testid'?: string;
11
18
  onClick?: () => void;
12
19
  onClose?: () => void;
13
20
  }
@@ -1,115 +1,139 @@
1
- import { jsx as i, Fragment as h, jsxs as l } from "react/jsx-runtime";
2
- import { useState as u, useEffect as p } from "react";
3
- import d from "react-dom/client";
1
+ import { jsx as s, Fragment as d, jsxs as c } from "react/jsx-runtime";
2
+ import { useState as h, useEffect as p } from "react";
3
+ import u from "react-dom/client";
4
4
  class m {
5
5
  notifications = [];
6
6
  listeners = [];
7
7
  container = null;
8
8
  root = null;
9
9
  idCounter = 0;
10
- subscribe(t) {
11
- return this.listeners.push(t), () => {
12
- this.listeners = this.listeners.filter((o) => o !== t);
10
+ subscribe(e) {
11
+ return this.listeners.push(e), () => {
12
+ this.listeners = this.listeners.filter((o) => o !== e);
13
13
  };
14
14
  }
15
15
  getNotifications() {
16
16
  return this.notifications;
17
17
  }
18
18
  emit() {
19
- this.listeners.forEach((t) => t());
19
+ this.listeners.forEach((e) => e());
20
20
  }
21
21
  ensureContainer() {
22
- this.container || (this.container = document.createElement("div"), document.body.appendChild(this.container), this.root = d.createRoot(this.container), this.root.render(/* @__PURE__ */ i(f, { manager: this })));
22
+ this.container || (this.container = document.createElement("div"), document.body.appendChild(this.container), this.root = u.createRoot(this.container), this.root.render(/* @__PURE__ */ s(v, { manager: this })));
23
23
  }
24
- open(t) {
24
+ open(e) {
25
25
  this.ensureContainer();
26
- const o = `notification-${++this.idCounter}`, s = {
27
- ...t,
26
+ const o = e.key ?? `notification-${++this.idCounter}`, r = e.variant === "compact", a = {
27
+ ...e,
28
28
  id: o,
29
29
  createdAt: Date.now(),
30
- duration: t.duration ?? 4.5,
31
- placement: t.placement ?? "topRight",
32
- closable: t.closable ?? !0,
33
- type: t.type ?? "info"
34
- };
35
- return this.notifications.push(s), this.emit(), s.duration && s.duration > 0 && setTimeout(() => {
30
+ duration: e.duration ?? (r ? 3 : 4.5),
31
+ placement: e.placement ?? (r ? "topCenter" : "topRight"),
32
+ variant: e.variant ?? "default",
33
+ closable: e.closable ?? !r,
34
+ type: e.type ?? "info"
35
+ }, n = this.notifications.findIndex((i) => i.id === o);
36
+ return n !== -1 ? this.notifications[n] = a : this.notifications.push(a), this.emit(), a.duration && a.duration > 0 && setTimeout(() => {
36
37
  this.close(o);
37
- }, s.duration * 1e3), o;
38
+ }, a.duration * 1e3), o;
38
39
  }
39
- close(t) {
40
- const o = this.notifications.find((s) => s.id === t);
41
- this.notifications = this.notifications.filter((s) => s.id !== t), this.emit(), o?.onClose && o.onClose();
40
+ close(e) {
41
+ const o = this.notifications.find((r) => r.id === e);
42
+ this.notifications = this.notifications.filter((r) => r.id !== e), this.emit(), o?.onClose && o.onClose();
42
43
  }
43
- success(t) {
44
- return this.open({ ...t, type: "success" });
44
+ success(e) {
45
+ return this.open({ ...e, type: "success" });
45
46
  }
46
- error(t) {
47
- return this.open({ ...t, type: "error" });
47
+ error(e) {
48
+ return this.open({ ...e, type: "error" });
48
49
  }
49
- info(t) {
50
- return this.open({ ...t, type: "info" });
50
+ info(e) {
51
+ return this.open({ ...e, type: "info" });
51
52
  }
52
- warning(t) {
53
- return this.open({ ...t, type: "warning" });
53
+ warning(e) {
54
+ return this.open({ ...e, type: "warning" });
54
55
  }
55
56
  destroy() {
56
57
  this.notifications = [], this.emit();
57
58
  }
58
59
  }
59
- function f({ manager: e }) {
60
- const [, t] = u({});
61
- p(() => e.subscribe(() => {
62
- t({});
63
- }), [e]);
64
- const o = e.getNotifications(), s = {
60
+ function v({ manager: t }) {
61
+ const [, e] = h({});
62
+ p(() => t.subscribe(() => {
63
+ e({});
64
+ }), [t]);
65
+ const o = t.getNotifications(), r = {
65
66
  topLeft: [],
66
67
  topRight: [],
68
+ topCenter: [],
67
69
  bottomLeft: [],
68
- bottomRight: []
70
+ bottomRight: [],
71
+ bottomCenter: []
69
72
  };
70
73
  o.forEach((n) => {
71
- s[n.placement].push(n);
74
+ r[n.placement].push(n);
72
75
  });
73
- const r = {
76
+ const a = {
74
77
  topRight: "toast toast-top toast-end",
75
78
  topLeft: "toast toast-top toast-start",
79
+ topCenter: "toast toast-top toast-center",
76
80
  bottomRight: "toast toast-bottom toast-end",
77
- bottomLeft: "toast toast-bottom toast-start"
81
+ bottomLeft: "toast toast-bottom toast-start",
82
+ bottomCenter: "toast toast-bottom toast-center"
78
83
  };
79
- return /* @__PURE__ */ i(h, { children: Object.entries(s).map(([n, c]) => c.length === 0 ? null : /* @__PURE__ */ i("div", { className: r[n], children: c.map((a) => /* @__PURE__ */ i(
80
- b,
84
+ return /* @__PURE__ */ s(d, { children: Object.entries(r).map(([n, i]) => i.length === 0 ? null : /* @__PURE__ */ s("div", { className: a[n], children: i.map((l) => /* @__PURE__ */ s(
85
+ w,
81
86
  {
82
- notification: a,
83
- onClose: () => e.close(a.id)
87
+ notification: l,
88
+ onClose: () => t.close(l.id)
84
89
  },
85
- a.id
90
+ l.id
86
91
  )) }, n)) });
87
92
  }
88
- function b({ notification: e, onClose: t }) {
89
- const o = {
93
+ function w({ notification: t, onClose: e }) {
94
+ const o = t.variant === "compact", r = {
90
95
  success: "alert-success",
91
96
  error: "alert-error",
92
97
  info: "alert-info",
93
98
  warning: "alert-warning"
94
- }, s = () => {
95
- e.onClick && e.onClick();
96
- };
97
- return /* @__PURE__ */ l(
99
+ }, a = {
100
+ success: /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z", clipRule: "evenodd" }) }),
101
+ error: /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z", clipRule: "evenodd" }) }),
102
+ info: /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", clipRule: "evenodd" }) }),
103
+ warning: /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s("path", { fillRule: "evenodd", d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z", clipRule: "evenodd" }) })
104
+ }, n = () => {
105
+ t.onClick && t.onClick();
106
+ }, i = t.icon ?? a[t.type];
107
+ return o ? /* @__PURE__ */ s(
108
+ "div",
109
+ {
110
+ className: `alert ${r[t.type]} shadow-md py-2 px-4 cursor-pointer${t.className ? ` ${t.className}` : ""}`,
111
+ style: t.style,
112
+ "data-testid": t["data-testid"],
113
+ onClick: n,
114
+ children: /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
115
+ i,
116
+ /* @__PURE__ */ s("span", { children: t.message })
117
+ ] })
118
+ }
119
+ ) : /* @__PURE__ */ c(
98
120
  "div",
99
121
  {
100
- className: `alert ${o[e.type]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative`,
101
- onClick: s,
122
+ className: `alert ${r[t.type]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative${t.className ? ` ${t.className}` : ""}`,
123
+ style: t.style,
124
+ "data-testid": t["data-testid"],
125
+ onClick: n,
102
126
  children: [
103
- /* @__PURE__ */ l("div", { className: e.closable ? "pr-8" : "", children: [
104
- e.message && /* @__PURE__ */ i("div", { className: "font-bold", children: e.message }),
105
- e.description && /* @__PURE__ */ i("div", { className: "text-sm", children: e.description })
127
+ /* @__PURE__ */ c("div", { className: t.closable ? "pr-8" : "", children: [
128
+ t.message && /* @__PURE__ */ s("div", { className: "font-bold", children: t.message }),
129
+ t.description && /* @__PURE__ */ s("div", { className: "text-sm", children: t.description })
106
130
  ] }),
107
- e.closable && /* @__PURE__ */ i(
131
+ t.closable && /* @__PURE__ */ s(
108
132
  "button",
109
133
  {
110
134
  className: "btn btn-xs btn-ghost btn-circle absolute top-2 right-2",
111
- onClick: (r) => {
112
- r.stopPropagation(), t();
135
+ onClick: (l) => {
136
+ l.stopPropagation(), e();
113
137
  },
114
138
  children: "✕"
115
139
  }
@@ -118,8 +142,8 @@ function b({ notification: e, onClose: t }) {
118
142
  }
119
143
  );
120
144
  }
121
- const y = new m();
145
+ const C = new m();
122
146
  export {
123
- y as notification
147
+ C as notification
124
148
  };
125
149
  //# sourceMappingURL=Notification.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Notification.js","sources":["../../src/components/Notification.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport ReactDOM from 'react-dom/client'\n\nexport type NotificationType = 'success' | 'info' | 'warning' | 'error'\nexport type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight'\n\nexport interface NotificationConfig {\n message: React.ReactNode\n description?: React.ReactNode\n type?: NotificationType\n duration?: number // in seconds, 0 = no auto close\n placement?: NotificationPlacement\n closable?: boolean\n onClick?: () => void\n onClose?: () => void\n}\n\ninterface NotificationItem extends NotificationConfig {\n id: string\n createdAt: number\n}\n\ntype Listener = () => void\n\nclass NotificationManager {\n private notifications: NotificationItem[] = []\n private listeners: Listener[] = []\n private container: HTMLDivElement | null = null\n private root: ReactDOM.Root | null = null\n private idCounter = 0\n\n subscribe(listener: Listener) {\n this.listeners.push(listener)\n return () => {\n this.listeners = this.listeners.filter((l) => l !== listener)\n }\n }\n\n getNotifications() {\n return this.notifications\n }\n\n private emit() {\n this.listeners.forEach((listener) => listener())\n }\n\n private ensureContainer() {\n if (!this.container) {\n this.container = document.createElement('div')\n document.body.appendChild(this.container)\n this.root = ReactDOM.createRoot(this.container)\n this.root.render(<NotificationContainer manager={this} />)\n }\n }\n\n open(config: NotificationConfig) {\n this.ensureContainer()\n\n const id = `notification-${++this.idCounter}`\n const notification: NotificationItem = {\n ...config,\n id,\n createdAt: Date.now(),\n duration: config.duration ?? 4.5,\n placement: config.placement ?? 'topRight',\n closable: config.closable ?? true,\n type: config.type ?? 'info',\n }\n\n this.notifications.push(notification)\n this.emit()\n\n // Auto-dismiss\n if (notification.duration && notification.duration > 0) {\n setTimeout(() => {\n this.close(id)\n }, notification.duration * 1000)\n }\n\n return id\n }\n\n close(id: string) {\n const notification = this.notifications.find((n) => n.id === id)\n this.notifications = this.notifications.filter((n) => n.id !== id)\n this.emit()\n\n if (notification?.onClose) {\n notification.onClose()\n }\n }\n\n success(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'success' })\n }\n\n error(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'error' })\n }\n\n info(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'info' })\n }\n\n warning(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'warning' })\n }\n\n destroy() {\n this.notifications = []\n this.emit()\n }\n}\n\ninterface NotificationContainerProps {\n manager: NotificationManager\n}\n\nfunction NotificationContainer({ manager }: NotificationContainerProps) {\n const [, forceUpdate] = useState({})\n\n useEffect(() => {\n const unsubscribe = manager.subscribe(() => {\n forceUpdate({})\n })\n return unsubscribe\n }, [manager])\n\n const notifications = manager.getNotifications()\n\n // Group by placement\n const grouped: Record<NotificationPlacement, NotificationItem[]> = {\n topLeft: [],\n topRight: [],\n bottomLeft: [],\n bottomRight: [],\n }\n\n notifications.forEach((notification) => {\n grouped[notification.placement!].push(notification)\n })\n\n const placementClasses: Record<NotificationPlacement, string> = {\n topRight: 'toast toast-top toast-end',\n topLeft: 'toast toast-top toast-start',\n bottomRight: 'toast toast-bottom toast-end',\n bottomLeft: 'toast toast-bottom toast-start',\n }\n\n return (\n <>\n {Object.entries(grouped).map(([placement, items]) => {\n if (items.length === 0) return null\n\n return (\n <div key={placement} className={placementClasses[placement as NotificationPlacement]}>\n {items.map((notification) => (\n <NotificationItem\n key={notification.id}\n notification={notification}\n onClose={() => manager.close(notification.id)}\n />\n ))}\n </div>\n )\n })}\n </>\n )\n}\n\ninterface NotificationItemProps {\n notification: NotificationItem\n onClose: () => void\n}\n\nfunction NotificationItem({ notification, onClose }: NotificationItemProps) {\n const alertTypeClasses: Record<NotificationType, string> = {\n success: 'alert-success',\n error: 'alert-error',\n info: 'alert-info',\n warning: 'alert-warning',\n }\n\n const handleClick = () => {\n if (notification.onClick) {\n notification.onClick()\n }\n }\n\n return (\n <div\n className={`alert ${alertTypeClasses[notification.type!]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative`}\n onClick={handleClick}\n >\n <div className={notification.closable ? 'pr-8' : ''}>\n {notification.message && <div className=\"font-bold\">{notification.message}</div>}\n {notification.description && <div className=\"text-sm\">{notification.description}</div>}\n </div>\n {notification.closable && (\n <button\n className=\"btn btn-xs btn-ghost btn-circle absolute top-2 right-2\"\n onClick={(e) => {\n e.stopPropagation()\n onClose()\n }}\n >\n ✕\n </button>\n )}\n </div>\n )\n}\n\nexport const notification = new NotificationManager()\n"],"names":["NotificationManager","listener","l","ReactDOM","jsx","NotificationContainer","config","id","notification","n","manager","forceUpdate","useState","useEffect","notifications","grouped","placementClasses","Fragment","placement","items","NotificationItem","onClose","alertTypeClasses","handleClick","jsxs","e"],"mappings":";;;AAwBA,MAAMA,EAAoB;AAAA,EAChB,gBAAoC,CAAA;AAAA,EACpC,YAAwB,CAAA;AAAA,EACxB,YAAmC;AAAA,EACnC,OAA6B;AAAA,EAC7B,YAAY;AAAA,EAEpB,UAAUC,GAAoB;AAC5B,gBAAK,UAAU,KAAKA,CAAQ,GACrB,MAAM;AACX,WAAK,YAAY,KAAK,UAAU,OAAO,CAACC,MAAMA,MAAMD,CAAQ;AAAA,IAC9D;AAAA,EACF;A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AAA,IAFvCA,EAAa;AAAA,EAAA,CAIrB,KAPOU,CAQV,CAEH,EAAA,CACH;AAEJ;AAOA,SAASE,EAAiB,EAAE,cAAAZ,GAAc,SAAAa,KAAkC;AAC1E,QAAMC,IAAqD;AAAA,IACzD,SAAS;AAAA,IACT,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,EAAA,GAGLC,IAAc,MAAM;AACxB,IAAIf,EAAa,WACfA,EAAa,QAAA;AAAA,EAEjB;AAEA,SACE,gBAAAgB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,SAASF,EAAiBd,EAAa,IAAK,CAAC;AAAA,MACxD,SAASe;AAAA,MAET,UAAA;AAAA,QAAA,gBAAAC,EAAC,OAAA,EAAI,WAAWhB,EAAa,WAAW,SAAS,IAC9C,UAAA;AAAA,UAAAA,EAAa,WAAW,gBAAAJ,EAAC,OAAA,EAAI,WAAU,aAAa,UAAAI,EAAa,SAAQ;AAAA,UACzEA,EAAa,eAAe,gBAAAJ,EAAC,OAAA,EAAI,WAAU,WAAW,UAAAI,EAAa,YAAA,CAAY;AAAA,QAAA,GAClF;AAAA,QACCA,EAAa,YACZ,gBAAAJ;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,SAAS,CAACqB,MAAM;AACd,cAAAA,EAAE,gBAAA,GACFJ,EAAA;AAAA,YACF;AAAA,YACD,UAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAED;AAAA,IAAA;AAAA,EAAA;AAIR;AAEO,MAAMb,IAAe,IAAIR,EAAA;"}
1
+ {"version":3,"file":"Notification.js","sources":["../../src/components/Notification.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport ReactDOM from 'react-dom/client'\n\nexport type NotificationType = 'success' | 'info' | 'warning' | 'error'\nexport type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'topCenter' | 'bottomCenter'\nexport type NotificationVariant = 'default' | 'compact'\n\nexport interface NotificationConfig {\n message: React.ReactNode\n description?: React.ReactNode\n type?: NotificationType\n duration?: number // in seconds, 0 = no auto close\n placement?: NotificationPlacement\n variant?: NotificationVariant\n closable?: boolean\n icon?: React.ReactNode\n key?: string\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n onClick?: () => void\n onClose?: () => void\n}\n\ninterface NotificationItem extends NotificationConfig {\n id: string\n createdAt: number\n}\n\ntype Listener = () => void\n\nclass NotificationManager {\n private notifications: NotificationItem[] = []\n private listeners: Listener[] = []\n private container: HTMLDivElement | null = null\n private root: ReactDOM.Root | null = null\n private idCounter = 0\n\n subscribe(listener: Listener) {\n this.listeners.push(listener)\n return () => {\n this.listeners = this.listeners.filter((l) => l !== listener)\n }\n }\n\n getNotifications() {\n return this.notifications\n }\n\n private emit() {\n this.listeners.forEach((listener) => listener())\n }\n\n private ensureContainer() {\n if (!this.container) {\n this.container = document.createElement('div')\n document.body.appendChild(this.container)\n this.root = ReactDOM.createRoot(this.container)\n this.root.render(<NotificationContainer manager={this} />)\n }\n }\n\n open(config: NotificationConfig) {\n this.ensureContainer()\n\n const id = config.key ?? `notification-${++this.idCounter}`\n const isCompact = config.variant === 'compact'\n const notificationItem: NotificationItem = {\n ...config,\n id,\n createdAt: Date.now(),\n duration: config.duration ?? (isCompact ? 3 : 4.5),\n placement: config.placement ?? (isCompact ? 'topCenter' : 'topRight'),\n variant: config.variant ?? 'default',\n closable: config.closable ?? !isCompact,\n type: config.type ?? 'info',\n }\n\n // If key exists, update the existing notification\n const existingIndex = this.notifications.findIndex((n) => n.id === id)\n if (existingIndex !== -1) {\n this.notifications[existingIndex] = notificationItem\n } else {\n this.notifications.push(notificationItem)\n }\n this.emit()\n\n // Auto-dismiss\n if (notificationItem.duration && notificationItem.duration > 0) {\n setTimeout(() => {\n this.close(id)\n }, notificationItem.duration * 1000)\n }\n\n return id\n }\n\n close(id: string) {\n const notification = this.notifications.find((n) => n.id === id)\n this.notifications = this.notifications.filter((n) => n.id !== id)\n this.emit()\n\n if (notification?.onClose) {\n notification.onClose()\n }\n }\n\n success(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'success' })\n }\n\n error(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'error' })\n }\n\n info(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'info' })\n }\n\n warning(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'warning' })\n }\n\n destroy() {\n this.notifications = []\n this.emit()\n }\n}\n\ninterface NotificationContainerProps {\n manager: NotificationManager\n}\n\nfunction NotificationContainer({ manager }: NotificationContainerProps) {\n const [, forceUpdate] = useState({})\n\n useEffect(() => {\n const unsubscribe = manager.subscribe(() => {\n forceUpdate({})\n })\n return unsubscribe\n }, [manager])\n\n const notifications = manager.getNotifications()\n\n // Group by placement\n const grouped: Record<NotificationPlacement, NotificationItem[]> = {\n topLeft: [],\n topRight: [],\n topCenter: [],\n bottomLeft: [],\n bottomRight: [],\n bottomCenter: [],\n }\n\n notifications.forEach((notification) => {\n grouped[notification.placement!].push(notification)\n })\n\n const placementClasses: Record<NotificationPlacement, string> = {\n topRight: 'toast toast-top toast-end',\n topLeft: 'toast toast-top toast-start',\n topCenter: 'toast toast-top toast-center',\n bottomRight: 'toast toast-bottom toast-end',\n bottomLeft: 'toast toast-bottom toast-start',\n bottomCenter: 'toast toast-bottom toast-center',\n }\n\n return (\n <>\n {Object.entries(grouped).map(([placement, items]) => {\n if (items.length === 0) return null\n\n return (\n <div key={placement} className={placementClasses[placement as NotificationPlacement]}>\n {items.map((notification) => (\n <NotificationItem\n key={notification.id}\n notification={notification}\n onClose={() => manager.close(notification.id)}\n />\n ))}\n </div>\n )\n })}\n </>\n )\n}\n\ninterface NotificationItemProps {\n notification: NotificationItem\n onClose: () => void\n}\n\nfunction NotificationItem({ notification, onClose }: NotificationItemProps) {\n const isCompact = notification.variant === 'compact'\n\n const alertTypeClasses: Record<NotificationType, string> = {\n success: 'alert-success',\n error: 'alert-error',\n info: 'alert-info',\n warning: 'alert-warning',\n }\n\n const typeIcons: Record<NotificationType, React.ReactNode> = {\n success: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\" clipRule=\"evenodd\" /></svg>,\n error: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z\" clipRule=\"evenodd\" /></svg>,\n info: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z\" clipRule=\"evenodd\" /></svg>,\n warning: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clipRule=\"evenodd\" /></svg>,\n }\n\n const handleClick = () => {\n if (notification.onClick) {\n notification.onClick()\n }\n }\n\n const icon = notification.icon ?? typeIcons[notification.type!]\n\n if (isCompact) {\n return (\n <div\n className={`alert ${alertTypeClasses[notification.type!]} shadow-md py-2 px-4 cursor-pointer${notification.className ? ` ${notification.className}` : ''}`}\n style={notification.style}\n data-testid={notification['data-testid']}\n onClick={handleClick}\n >\n <div className=\"flex items-center gap-2\">\n {icon}\n <span>{notification.message}</span>\n </div>\n </div>\n )\n }\n\n return (\n <div\n className={`alert ${alertTypeClasses[notification.type!]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative${notification.className ? ` ${notification.className}` : ''}`}\n style={notification.style}\n data-testid={notification['data-testid']}\n onClick={handleClick}\n >\n <div className={notification.closable ? 'pr-8' : ''}>\n {notification.message && <div className=\"font-bold\">{notification.message}</div>}\n {notification.description && <div className=\"text-sm\">{notification.description}</div>}\n </div>\n {notification.closable && (\n <button\n className=\"btn btn-xs btn-ghost btn-circle absolute top-2 right-2\"\n onClick={(e) => {\n e.stopPropagation()\n onClose()\n }}\n >\n ✕\n </button>\n )}\n </div>\n )\n}\n\nexport const notification = new NotificationManager()\n"],"names":["NotificationManager","listener","l","ReactDOM","jsx","NotificationContainer","config","id","isCompact","notificationItem","existingIndex","n","notification","manager","forceUpdate","useState","useEffect","notifications","grouped","placementClasses","Fragment","placement","items","NotificationItem","onClose","alertTypeClasses","typeIcons","handleClick","icon","jsxs","e"],"mappings":";;;AA+BA,MAAMA,EAAoB;AAAA,EAChB,gBAAoC,CAAA;AAAA,EACpC,YAAwB,CAAA;AAAA,EACxB,YAAmC;AAAA,EACnC,OAA6B;AAAA,EAC7B,YAAY;AAAA,EAEpB,UAAUC,GAAoB;AAC5B,gBAAK,UAAU,KAAKA,CAAQ,GACrB,MAAM;AACX,WAAK,YAAY,KAAK,UAAU,OAAO,CAACC,MAAMA,MAAMD,CAAQ;AAAA,IAC9D;AAAA,EACF;AAAA,EAEA,mBA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