@stackone/malachite 2.70.0 → 2.72.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.
Files changed (34) hide show
  1. package/COMPONENTS.md +12 -11
  2. package/dist/components/Accordion.js +59 -53
  3. package/dist/components/Accordion.js.map +1 -1
  4. package/dist/components/Alert.js +100 -75
  5. package/dist/components/Alert.js.map +1 -1
  6. package/dist/components/Button.js +89 -82
  7. package/dist/components/Button.js.map +1 -1
  8. package/dist/components/Modal.js +75 -74
  9. package/dist/components/Modal.js.map +1 -1
  10. package/dist/components/PopoverParts.js +35 -35
  11. package/dist/components/PopoverParts.js.map +1 -1
  12. package/dist/components/Search.js +30 -29
  13. package/dist/components/Search.js.map +1 -1
  14. package/dist/components/SidePanel.js +124 -106
  15. package/dist/components/SidePanel.js.map +1 -1
  16. package/dist/components/StatusPill.js +61 -0
  17. package/dist/components/StatusPill.js.map +1 -0
  18. package/dist/components/Surface.js +138 -133
  19. package/dist/components/Surface.js.map +1 -1
  20. package/dist/components/Toolbar.js +40 -33
  21. package/dist/components/Toolbar.js.map +1 -1
  22. package/dist/components/Typography/EllipsisText.js +27 -25
  23. package/dist/components/Typography/EllipsisText.js.map +1 -1
  24. package/dist/components/Typography/MarkdownBlock.js +36 -28
  25. package/dist/components/Typography/MarkdownBlock.js.map +1 -1
  26. package/dist/components/Typography/Text.js +24 -22
  27. package/dist/components/Typography/Text.js.map +1 -1
  28. package/dist/components/WizardLayout.js +81 -67
  29. package/dist/components/WizardLayout.js.map +1 -1
  30. package/dist/index.d.ts +65 -2
  31. package/dist/index.js +356 -354
  32. package/dist/index.js.map +1 -1
  33. package/dist/tailwind.css.js +1 -1
  34. package/package.json +1 -1
@@ -1,16 +1,16 @@
1
- import { jsxs as i, jsx as e, Fragment as B } from "react/jsx-runtime";
2
- import { useState as E } from "react";
3
- import { Button as F } from "./Button.js";
4
- import S from "./CustomIcons/CaretDownIcon.js";
5
- import O from "./CustomIcons/CaretUpIcon.js";
6
- import z from "./CustomIcons/CheckCircleFilled.js";
7
- import A from "./CustomIcons/ErrorCircleFilled.js";
8
- import R from "./CustomIcons/InfoCircleFilled.js";
9
- import W from "./CustomIcons/SparkleIcon.js";
10
- import H from "./CustomIcons/WarningCircleFilled.js";
11
- import M from "./Typography/MarkdownBlock.js";
12
- import { getTextColor as $ } from "./Typography/textStyles.js";
13
- const C = (r) => {
1
+ import { jsxs as i, jsx as e, Fragment as O } from "react/jsx-runtime";
2
+ import { useState as A } from "react";
3
+ import { Button as R } from "./Button.js";
4
+ import W from "./CustomIcons/CaretDownIcon.js";
5
+ import H from "./CustomIcons/CaretUpIcon.js";
6
+ import M from "./CustomIcons/CheckCircleFilled.js";
7
+ import T from "./CustomIcons/ErrorCircleFilled.js";
8
+ import Y from "./CustomIcons/InfoCircleFilled.js";
9
+ import $ from "./CustomIcons/SparkleIcon.js";
10
+ import D from "./CustomIcons/WarningCircleFilled.js";
11
+ import L from "./Typography/MarkdownBlock.js";
12
+ import { getTextColor as y, getFontSize as U } from "./Typography/textStyles.js";
13
+ const h = (r) => {
14
14
  switch (r) {
15
15
  case "info":
16
16
  return "primary";
@@ -27,130 +27,147 @@ const C = (r) => {
27
27
  default:
28
28
  return "primary";
29
29
  }
30
- }, s = {
30
+ }, a = {
31
31
  width: "13px",
32
32
  height: "13px",
33
33
  flexShrink: 0
34
- }, n = {
34
+ }, o = {
35
35
  info: "var(--malachite-alert-info-foreground)",
36
36
  success: "var(--malachite-alert-success-foreground)",
37
37
  error: "var(--malachite-alert-error-foreground)",
38
38
  warning: "var(--malachite-alert-warning-foreground)",
39
39
  assistant: "var(--malachite-alert-assistant-foreground)"
40
- }, D = {
40
+ }, I = {
41
41
  info: /* @__PURE__ */ e(
42
- R,
42
+ Y,
43
43
  {
44
- style: { ...s, color: n.info }
44
+ style: { ...a, color: o.info }
45
45
  }
46
46
  ),
47
47
  success: /* @__PURE__ */ e(
48
- z,
48
+ M,
49
49
  {
50
- style: { ...s, color: n.success }
50
+ style: { ...a, color: o.success }
51
51
  }
52
52
  ),
53
53
  error: /* @__PURE__ */ e(
54
- A,
54
+ T,
55
55
  {
56
- style: { ...s, color: n.error }
56
+ style: { ...a, color: o.error }
57
57
  }
58
58
  ),
59
59
  warning: /* @__PURE__ */ e(
60
- H,
60
+ D,
61
61
  {
62
- style: { ...s, color: n.warning }
62
+ style: { ...a, color: o.warning }
63
63
  }
64
64
  ),
65
65
  // The same sparkle the control that produced the message carries, so the two read as
66
66
  // one thread rather than two unrelated affordances.
67
67
  assistant: /* @__PURE__ */ e(
68
- W,
68
+ $,
69
69
  {
70
- style: { ...s, color: n.assistant }
70
+ style: { ...a, color: o.assistant }
71
71
  }
72
72
  )
73
- }, g = (r, l) => l ? /* @__PURE__ */ e(
73
+ }, q = { ...a, width: "16px", height: "16px" }, _ = (r, l, t = !1) => !l && !t ? I[r] : /* @__PURE__ */ e(
74
74
  "span",
75
75
  {
76
76
  className: "alert-status-icon inline-flex shrink-0 [&_svg]:size-full!",
77
- style: { ...s, color: n[r] },
78
- children: l
77
+ style: { ...t ? q : a, color: o[r] },
78
+ children: l || I[r]
79
79
  }
80
- ) : D[r], w = ({ text: r, type: l, renderLink: c }) => /* @__PURE__ */ e(
81
- M,
80
+ ), u = ({ text: r, type: l, lead: t, renderLink: c }) => t ? /* @__PURE__ */ i("div", { className: "alert-lead", children: [
81
+ /* @__PURE__ */ e(
82
+ "strong",
83
+ {
84
+ style: {
85
+ color: y(h(l)),
86
+ fontSize: U("small"),
87
+ fontWeight: 600
88
+ },
89
+ children: t
90
+ }
91
+ ),
92
+ " ",
93
+ /* @__PURE__ */ e(u, { text: r, type: l, renderLink: c })
94
+ ] }) : /* @__PURE__ */ e(
95
+ L,
82
96
  {
83
97
  text: r,
84
- color: C(l),
98
+ color: h(l),
85
99
  size: "small",
86
100
  omitMargin: !0,
87
101
  renderLink: c
88
102
  }
89
- ), ee = ({
103
+ ), ae = ({
90
104
  type: r = "info",
91
105
  message: l,
92
- hasMargin: c = !0,
93
- className: N,
94
- children: f,
95
- isExpanded: d,
96
- onToggle: m,
97
- action: o,
98
- icon: x,
99
- live: b = !1,
100
- renderLink: u
106
+ hasMargin: t = !0,
107
+ className: c,
108
+ children: p,
109
+ isExpanded: m,
110
+ onToggle: f,
111
+ action: d,
112
+ icon: v,
113
+ live: S = !1,
114
+ renderLink: g,
115
+ layout: E = "inline",
116
+ lead: w
101
117
  }) => {
102
- const t = !!f, h = b ? r === "error" || r === "warning" ? "alert" : "status" : void 0, [I, y] = E(!1), a = d !== void 0 ? d : I, k = () => {
103
- const v = !a;
104
- d === void 0 && y(v), m == null || m(v);
105
- }, p = [
118
+ const s = !!p, x = E === "banner" && !s, N = S ? r === "error" || r === "warning" ? "alert" : "status" : void 0, [j, k] = A(!1), n = m !== void 0 ? m : j, B = () => {
119
+ const b = !n;
120
+ m === void 0 && k(b), f == null || f(b);
121
+ }, C = [
106
122
  "alert-base",
107
123
  `alert-${r}`,
108
124
  "flex",
109
125
  "w-full",
110
126
  // Ensure full width
111
- t && a ? "flex-col" : "gap-2 items-center min-h-[2rem]",
112
- c ? "" : "alert-no-margin",
127
+ x ? "alert-banner" : s && n ? "flex-col" : "gap-2 items-center min-h-[2rem]",
128
+ t ? "" : "alert-no-margin",
113
129
  "text-left",
114
- t ? "rounded-xl !p-0" : "!px-2.5 !py-1.5",
130
+ x ? "" : s ? "rounded-xl !p-0" : "!px-2.5 !py-1.5",
115
131
  // Slightly more vertical padding for centering
116
- N
117
- ].filter(Boolean).join(" "), _ = [
132
+ c
133
+ ].filter(Boolean).join(" "), F = [
118
134
  "flex items-center justify-between w-full",
119
- t ? "gap-2 px-2.5 py-1" : "gap-2",
120
- t && a ? "rounded-t-xl" : t ? "rounded-xl" : ""
121
- ].filter(Boolean).join(" "), j = ["w-full", "overflow-hidden"].filter(Boolean).join(" ");
122
- return t ? /* @__PURE__ */ i("div", { className: `${p} alert-expandable`, children: [
123
- /* @__PURE__ */ i("div", { className: _, children: [
135
+ s ? "gap-2 px-2.5 py-1" : "gap-2",
136
+ s && n ? "rounded-t-xl" : s ? "rounded-xl" : ""
137
+ ].filter(Boolean).join(" "), z = ["w-full", "overflow-hidden"].filter(Boolean).join(" ");
138
+ return s ? /* @__PURE__ */ i("div", { className: `${C} alert-expandable`, children: [
139
+ /* @__PURE__ */ i("div", { className: F, children: [
124
140
  /* @__PURE__ */ i("div", { className: "flex-1 flex gap-2 items-center", children: [
125
- g(r, x),
126
- /* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", role: h, children: /* @__PURE__ */ e(
127
- w,
141
+ _(r, v),
142
+ /* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", role: N, children: /* @__PURE__ */ e(
143
+ u,
128
144
  {
129
145
  text: l,
146
+ lead: w,
130
147
  type: r,
131
- renderLink: u
148
+ renderLink: g
132
149
  }
133
150
  ) }) })
134
151
  ] }),
135
152
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
136
- o && /* @__PURE__ */ e("div", { className: "alert-action flex items-center", children: o }),
153
+ d && /* @__PURE__ */ e("div", { className: "alert-action flex items-center", children: d }),
137
154
  /* @__PURE__ */ e(
138
- F,
155
+ R,
139
156
  {
140
157
  variant: "no-style",
141
158
  size: "xsmall",
142
- onClick: k,
143
- "aria-label": a ? "Collapse" : "Expand",
159
+ onClick: B,
160
+ "aria-label": n ? "Collapse" : "Expand",
144
161
  style: {
145
- color: $(C(r))
162
+ color: y(h(r))
146
163
  },
147
- children: a ? /* @__PURE__ */ e(
148
- O,
164
+ children: n ? /* @__PURE__ */ e(
165
+ H,
149
166
  {
150
167
  style: { minWidth: "13px", minHeight: "13px" }
151
168
  }
152
169
  ) : /* @__PURE__ */ e(
153
- S,
170
+ W,
154
171
  {
155
172
  style: { minWidth: "13px", minHeight: "13px" }
156
173
  }
@@ -159,15 +176,23 @@ const C = (r) => {
159
176
  )
160
177
  ] })
161
178
  ] }),
162
- a && /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e("div", { className: j, children: /* @__PURE__ */ e("div", { className: "bg-white rounded-[var(--malachite-radius-10,10px)] shadow-[0px_1px_0px_0px_rgba(0,0,0,0.15)] border border-[#e8e8e8] border-solid mx-2 mb-2 max-h-[553px] overflow-y-auto", children: f }) }) })
163
- ] }) : /* @__PURE__ */ i("div", { className: p, children: [
164
- g(r, x),
165
- /* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", role: h, children: /* @__PURE__ */ e(w, { text: l, type: r, renderLink: u }) }) }),
166
- o && /* @__PURE__ */ e("div", { className: "alert-action shrink-0 flex items-center", children: o })
179
+ n && /* @__PURE__ */ e(O, { children: /* @__PURE__ */ e("div", { className: z, children: /* @__PURE__ */ e("div", { className: "bg-white rounded-[var(--malachite-radius-10,10px)] shadow-[0px_1px_0px_0px_rgba(0,0,0,0.15)] border border-[#e8e8e8] border-solid mx-2 mb-2 max-h-[553px] overflow-y-auto", children: p }) }) })
180
+ ] }) : /* @__PURE__ */ i("div", { className: C, children: [
181
+ _(r, v, x),
182
+ /* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", role: N, children: /* @__PURE__ */ e(
183
+ u,
184
+ {
185
+ text: l,
186
+ type: r,
187
+ lead: w,
188
+ renderLink: g
189
+ }
190
+ ) }) }),
191
+ d && /* @__PURE__ */ e("div", { className: "alert-action shrink-0 flex items-center", children: d })
167
192
  ] });
168
193
  };
169
194
  export {
170
- ee as Alert,
171
- ee as default
195
+ ae as Alert,
196
+ ae as default
172
197
  };
173
198
  //# sourceMappingURL=Alert.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.js","sources":["../../src/components/Alert.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Button, ButtonVariant } from './Button';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport CaretUpIcon from './CustomIcons/CaretUpIcon';\nimport CheckCircleFilled from './CustomIcons/CheckCircleFilled';\nimport ErrorCircleFilled from './CustomIcons/ErrorCircleFilled';\nimport InfoCircleFilled from './CustomIcons/InfoCircleFilled';\nimport SparkleIcon from './CustomIcons/SparkleIcon';\nimport WarningCircleFilled from './CustomIcons/WarningCircleFilled';\nimport type { RenderLink } from './PageLayout/types';\nimport MarkdownBlock from './Typography/MarkdownBlock';\nimport type { TextColor } from './Typography/Text';\nimport { getTextColor } from './Typography/textStyles';\n\nexport type AlertType = 'info' | 'success' | 'error' | 'warning' | 'assistant';\n\ninterface AlertButtonConfig {\n label: string;\n onClick: () => void;\n variant?: ButtonVariant;\n icon?: React.ReactNode;\n}\n\ninterface AlertProps {\n type?: AlertType;\n message: string;\n hasMargin?: boolean;\n className?: string;\n children?: React.ReactNode;\n isExpanded?: boolean;\n onToggle?: (expanded: boolean) => void;\n /** A control at the end of the alert — a link or button that resolves what it reports. */\n action?: React.ReactNode;\n /** Replaces the type's status icon: an svg painting with `currentColor`, such as a CustomIcon,\n * is drawn in the type's colour at the same size. */\n icon?: React.ReactNode;\n /** Makes its message a live region: `role=\"alert\"` for error and warning, `status` otherwise.\n * Screen readers reliably announce an `alert` as it mounts; a `status` is read when its\n * `message` changes, so keep a live info or success alert mounted. Off by default. */\n live?: boolean;\n /** Routes root-relative links in `message` through the app's router; see `MarkdownBlock`. */\n renderLink?: RenderLink;\n}\n\n// Distinct from the imported `getTextColor`, which maps a TextColor to a CSS variable.\n// This maps an AlertType to a TextColor token; both are used in this file.\nconst getAlertTextColor = (alertType: AlertType): TextColor => {\n switch (alertType) {\n case 'info':\n return 'primary';\n case 'success':\n return 'success';\n case 'error':\n return 'error';\n case 'warning':\n return 'warning';\n // The violet is on `.alert-assistant` itself; inheriting it keeps one definition\n // rather than a TextColor token that only this alert would ever name.\n case 'assistant':\n return 'inherit';\n default:\n return 'primary';\n }\n};\n\nconst ICON_STYLE = {\n width: '13px',\n height: '13px',\n flexShrink: 0,\n};\n\nconst ICON_COLOR: Record<AlertType, string> = {\n info: 'var(--malachite-alert-info-foreground)',\n success: 'var(--malachite-alert-success-foreground)',\n error: 'var(--malachite-alert-error-foreground)',\n warning: 'var(--malachite-alert-warning-foreground)',\n assistant: 'var(--malachite-alert-assistant-foreground)',\n};\n\nconst AlertIcon = {\n info: (\n <InfoCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.info }}\n />\n ),\n success: (\n <CheckCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.success }}\n />\n ),\n error: (\n <ErrorCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.error }}\n />\n ),\n warning: (\n <WarningCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.warning }}\n />\n ),\n // The same sparkle the control that produced the message carries, so the two read as\n // one thread rather than two unrelated affordances.\n assistant: (\n <SparkleIcon\n style={{ ...ICON_STYLE, color: ICON_COLOR.assistant }}\n />\n ),\n};\n\nconst statusIcon = (type: AlertType, icon: React.ReactNode) =>\n icon ? (\n <span\n className=\"alert-status-icon inline-flex shrink-0 [&_svg]:size-full!\"\n style={{ ...ICON_STYLE, color: ICON_COLOR[type] }}\n >\n {icon}\n </span>\n ) : (\n AlertIcon[type]\n );\n\nconst SimpleTextRenderer: React.FC<{\n text: string;\n type: AlertType;\n renderLink?: RenderLink;\n}> = ({ text, type, renderLink }) => {\n return (\n <MarkdownBlock\n text={text}\n color={getAlertTextColor(type)}\n size=\"small\"\n omitMargin\n renderLink={renderLink}\n />\n );\n};\n\nconst Alert: React.FC<AlertProps> = ({\n type = 'info',\n message,\n hasMargin = true,\n className,\n children,\n isExpanded,\n onToggle,\n action,\n icon,\n live = false,\n renderLink,\n}) => {\n const isExpandable = !!children;\n const urgent = type === 'error' || type === 'warning';\n const liveRole = live ? (urgent ? 'alert' : 'status') : undefined;\n const [internalExpanded, setInternalExpanded] = useState(false);\n\n // Use controlled state if isExpanded is provided, otherwise use internal state\n const expanded = isExpanded !== undefined ? isExpanded : internalExpanded;\n\n const handleToggle = () => {\n const newExpanded = !expanded;\n if (isExpanded === undefined) {\n // Uncontrolled mode\n setInternalExpanded(newExpanded);\n }\n // Call onToggle if provided (for both controlled and uncontrolled)\n onToggle?.(newExpanded);\n };\n\n const alertClasses = [\n 'alert-base',\n `alert-${type}`,\n 'flex',\n 'w-full', // Ensure full width\n isExpandable && expanded ? 'flex-col' : 'gap-2 items-center min-h-[2rem]',\n !hasMargin ? 'alert-no-margin' : '',\n 'text-left',\n isExpandable ? 'rounded-xl !p-0' : '!px-2.5 !py-1.5', // Slightly more vertical padding for centering\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const headerClasses = [\n 'flex items-center justify-between w-full',\n isExpandable ? 'gap-2 px-2.5 py-1' : 'gap-2',\n isExpandable && expanded ? 'rounded-t-xl' : isExpandable ? 'rounded-xl' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const expandableContentClasses = ['w-full', 'overflow-hidden'].filter(Boolean).join(' ');\n\n // Non-expandable alert (original behavior)\n if (!isExpandable) {\n return (\n <div className={alertClasses}>\n {statusIcon(type, icon)}\n <div className=\"flex-1 flex items-center\">\n <div className=\"[&>div]:mb-0\" role={liveRole}>\n <SimpleTextRenderer text={message} type={type} renderLink={renderLink} />\n </div>\n </div>\n {action && <div className=\"alert-action shrink-0 flex items-center\">{action}</div>}\n </div>\n );\n }\n\n // Expandable alert\n return (\n <div className={`${alertClasses} alert-expandable`}>\n {/* Header section with title and expand/collapse button */}\n <div className={headerClasses}>\n <div className=\"flex-1 flex gap-2 items-center\">\n {statusIcon(type, icon)}\n <div className=\"flex-1 flex items-center\">\n <div className=\"[&>div]:mb-0\" role={liveRole}>\n <SimpleTextRenderer\n text={message}\n type={type}\n renderLink={renderLink}\n />\n </div>\n </div>\n </div>\n\n {/* Right side buttons container */}\n <div className=\"flex items-center gap-2\">\n {action && <div className=\"alert-action flex items-center\">{action}</div>}\n {/* Expand/collapse button */}\n <Button\n variant=\"no-style\"\n size=\"xsmall\"\n onClick={handleToggle}\n aria-label={expanded ? 'Collapse' : 'Expand'}\n style={{\n color: getTextColor(getAlertTextColor(type)),\n }}\n >\n {expanded ? (\n <CaretUpIcon\n style={{ minWidth: '13px', minHeight: '13px' }}\n />\n ) : (\n <CaretDownIcon\n style={{ minWidth: '13px', minHeight: '13px' }}\n />\n )}\n </Button>\n </div>\n </div>\n\n {/* Expandable content */}\n {expanded && (\n <>\n <div className={expandableContentClasses}>\n <div className=\"bg-white rounded-[var(--malachite-radius-10,10px)] shadow-[0px_1px_0px_0px_rgba(0,0,0,0.15)] border border-[#e8e8e8] border-solid mx-2 mb-2 max-h-[553px] overflow-y-auto\">\n {children}\n </div>\n </div>\n </>\n )}\n </div>\n );\n};\n\nexport default Alert;\nexport { Alert };\nexport type { AlertButtonConfig };\n"],"names":["getAlertTextColor","alertType","ICON_STYLE","ICON_COLOR","AlertIcon","jsx","InfoCircleFilled","CheckCircleFilled","ErrorCircleFilled","WarningCircleFilled","SparkleIcon","statusIcon","type","icon","SimpleTextRenderer","text","renderLink","MarkdownBlock","Alert","message","hasMargin","className","children","isExpanded","onToggle","action","live","isExpandable","liveRole","internalExpanded","setInternalExpanded","useState","expanded","handleToggle","newExpanded","alertClasses","headerClasses","expandableContentClasses","jsxs","Button","getTextColor","CaretUpIcon","CaretDownIcon","Fragment"],"mappings":";;;;;;;;;;;;AA8CA,MAAMA,IAAoB,CAACC,MAAoC;AAC3D,UAAQA,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA;AAAA;AAAA,IAGX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB,GAEMC,IAAa;AAAA,EACf,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAChB,GAEMC,IAAwC;AAAA,EAC1C,MAAM;AAA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MuB,GAChC,4BAACd,GAAA,EAAmB,MAAMK,GAAS,MAAAP,GAAY,YAAAI,EAAA,CAAwB,GAC3E,GACJ;AAAA,IACCS,KAAU,gBAAApB,EAAC,OAAA,EAAI,WAAU,2CAA2C,UAAAoB,EAAA,CAAO;AAAA,EAAA,GAChF;AA4DZ;"}
1
+ {"version":3,"file":"Alert.js","sources":["../../src/components/Alert.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Button, ButtonVariant } from './Button';\nimport CaretDownIcon from './CustomIcons/CaretDownIcon';\nimport CaretUpIcon from './CustomIcons/CaretUpIcon';\nimport CheckCircleFilled from './CustomIcons/CheckCircleFilled';\nimport ErrorCircleFilled from './CustomIcons/ErrorCircleFilled';\nimport InfoCircleFilled from './CustomIcons/InfoCircleFilled';\nimport SparkleIcon from './CustomIcons/SparkleIcon';\nimport WarningCircleFilled from './CustomIcons/WarningCircleFilled';\nimport type { RenderLink } from './PageLayout/types';\nimport MarkdownBlock from './Typography/MarkdownBlock';\nimport type { TextColor } from './Typography/Text';\nimport { getFontSize, getTextColor } from './Typography/textStyles';\n\nexport type AlertType = 'info' | 'success' | 'error' | 'warning' | 'assistant';\n\nexport type AlertLayout = 'inline' | 'banner';\n\ninterface AlertButtonConfig {\n label: string;\n onClick: () => void;\n variant?: ButtonVariant;\n icon?: React.ReactNode;\n}\n\ninterface AlertProps {\n type?: AlertType;\n message: string;\n hasMargin?: boolean;\n className?: string;\n children?: React.ReactNode;\n isExpanded?: boolean;\n onToggle?: (expanded: boolean) => void;\n /** A control at the end of the alert — a link or button that resolves what it reports. */\n action?: React.ReactNode;\n /** Replaces the type's status icon: an svg painting with `currentColor`, such as a CustomIcon,\n * is drawn in the type's colour at the same size. */\n icon?: React.ReactNode;\n /** Makes its message a live region: `role=\"alert\"` for error and warning, `status` otherwise.\n * Screen readers reliably announce an `alert` as it mounts; a `status` is read when its\n * `message` changes, so keep a live info or success alert mounted. Off by default. */\n live?: boolean;\n /** Routes root-relative links in `message` through the app's router; see `MarkdownBlock`. */\n renderLink?: RenderLink;\n /** `banner`: a 48px page-wide band. Applies only without `children`. */\n layout?: AlertLayout;\n /** A bold sentence the message runs on from. Plain text, not markdown. */\n lead?: string;\n}\n\n// Distinct from the imported `getTextColor`, which maps a TextColor to a CSS variable.\n// This maps an AlertType to a TextColor token; both are used in this file.\nconst getAlertTextColor = (alertType: AlertType): TextColor => {\n switch (alertType) {\n case 'info':\n return 'primary';\n case 'success':\n return 'success';\n case 'error':\n return 'error';\n case 'warning':\n return 'warning';\n // The violet is on `.alert-assistant` itself; inheriting it keeps one definition\n // rather than a TextColor token that only this alert would ever name.\n case 'assistant':\n return 'inherit';\n default:\n return 'primary';\n }\n};\n\nconst ICON_STYLE = {\n width: '13px',\n height: '13px',\n flexShrink: 0,\n};\n\nconst ICON_COLOR: Record<AlertType, string> = {\n info: 'var(--malachite-alert-info-foreground)',\n success: 'var(--malachite-alert-success-foreground)',\n error: 'var(--malachite-alert-error-foreground)',\n warning: 'var(--malachite-alert-warning-foreground)',\n assistant: 'var(--malachite-alert-assistant-foreground)',\n};\n\nconst AlertIcon = {\n info: (\n <InfoCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.info }}\n />\n ),\n success: (\n <CheckCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.success }}\n />\n ),\n error: (\n <ErrorCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.error }}\n />\n ),\n warning: (\n <WarningCircleFilled\n style={{ ...ICON_STYLE, color: ICON_COLOR.warning }}\n />\n ),\n // The same sparkle the control that produced the message carries, so the two read as\n // one thread rather than two unrelated affordances.\n assistant: (\n <SparkleIcon\n style={{ ...ICON_STYLE, color: ICON_COLOR.assistant }}\n />\n ),\n};\n\nconst BANNER_ICON_STYLE = { ...ICON_STYLE, width: '16px', height: '16px' };\n\nconst statusIcon = (type: AlertType, icon: React.ReactNode, banner = false) => {\n if (!icon && !banner) return AlertIcon[type];\n const style = banner ? BANNER_ICON_STYLE : ICON_STYLE;\n return (\n <span\n className=\"alert-status-icon inline-flex shrink-0 [&_svg]:size-full!\"\n style={{ ...style, color: ICON_COLOR[type] }}\n >\n {icon || AlertIcon[type]}\n </span>\n );\n};\n\nconst SimpleTextRenderer: React.FC<{\n text: string;\n type: AlertType;\n lead?: string;\n renderLink?: RenderLink;\n}> = ({ text, type, lead, renderLink }) => {\n if (lead) {\n return (\n <div className=\"alert-lead\">\n <strong\n style={{\n color: getTextColor(getAlertTextColor(type)),\n fontSize: getFontSize('small'),\n fontWeight: 600,\n }}\n >\n {lead}\n </strong>{' '}\n <SimpleTextRenderer text={text} type={type} renderLink={renderLink} />\n </div>\n );\n }\n return (\n <MarkdownBlock\n text={text}\n color={getAlertTextColor(type)}\n size=\"small\"\n omitMargin\n renderLink={renderLink}\n />\n );\n};\n\nconst Alert: React.FC<AlertProps> = ({\n type = 'info',\n message,\n hasMargin = true,\n className,\n children,\n isExpanded,\n onToggle,\n action,\n icon,\n live = false,\n renderLink,\n layout = 'inline',\n lead,\n}) => {\n const isExpandable = !!children;\n const banner = layout === 'banner' && !isExpandable;\n const urgent = type === 'error' || type === 'warning';\n const liveRole = live ? (urgent ? 'alert' : 'status') : undefined;\n const [internalExpanded, setInternalExpanded] = useState(false);\n\n // Use controlled state if isExpanded is provided, otherwise use internal state\n const expanded = isExpanded !== undefined ? isExpanded : internalExpanded;\n\n const handleToggle = () => {\n const newExpanded = !expanded;\n if (isExpanded === undefined) {\n // Uncontrolled mode\n setInternalExpanded(newExpanded);\n }\n // Call onToggle if provided (for both controlled and uncontrolled)\n onToggle?.(newExpanded);\n };\n\n const alertClasses = [\n 'alert-base',\n `alert-${type}`,\n 'flex',\n 'w-full', // Ensure full width\n banner\n ? 'alert-banner'\n : isExpandable && expanded\n ? 'flex-col'\n : 'gap-2 items-center min-h-[2rem]',\n !hasMargin ? 'alert-no-margin' : '',\n 'text-left',\n banner ? '' : isExpandable ? 'rounded-xl !p-0' : '!px-2.5 !py-1.5', // Slightly more vertical padding for centering\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const headerClasses = [\n 'flex items-center justify-between w-full',\n isExpandable ? 'gap-2 px-2.5 py-1' : 'gap-2',\n isExpandable && expanded ? 'rounded-t-xl' : isExpandable ? 'rounded-xl' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const expandableContentClasses = ['w-full', 'overflow-hidden'].filter(Boolean).join(' ');\n\n // Non-expandable alert (original behavior)\n if (!isExpandable) {\n return (\n <div className={alertClasses}>\n {statusIcon(type, icon, banner)}\n <div className=\"flex-1 flex items-center\">\n <div className=\"[&>div]:mb-0\" role={liveRole}>\n <SimpleTextRenderer\n text={message}\n type={type}\n lead={lead}\n renderLink={renderLink}\n />\n </div>\n </div>\n {action && <div className=\"alert-action shrink-0 flex items-center\">{action}</div>}\n </div>\n );\n }\n\n // Expandable alert\n return (\n <div className={`${alertClasses} alert-expandable`}>\n {/* Header section with title and expand/collapse button */}\n <div className={headerClasses}>\n <div className=\"flex-1 flex gap-2 items-center\">\n {statusIcon(type, icon)}\n <div className=\"flex-1 flex items-center\">\n <div className=\"[&>div]:mb-0\" role={liveRole}>\n <SimpleTextRenderer\n text={message}\n lead={lead}\n type={type}\n renderLink={renderLink}\n />\n </div>\n </div>\n </div>\n\n {/* Right side buttons container */}\n <div className=\"flex items-center gap-2\">\n {action && <div className=\"alert-action flex items-center\">{action}</div>}\n {/* Expand/collapse button */}\n <Button\n variant=\"no-style\"\n size=\"xsmall\"\n onClick={handleToggle}\n aria-label={expanded ? 'Collapse' : 'Expand'}\n style={{\n color: getTextColor(getAlertTextColor(type)),\n }}\n >\n {expanded ? (\n <CaretUpIcon\n style={{ minWidth: '13px', minHeight: '13px' }}\n />\n ) : (\n <CaretDownIcon\n style={{ minWidth: '13px', minHeight: '13px' }}\n />\n )}\n </Button>\n </div>\n </div>\n\n {/* Expandable content */}\n {expanded && (\n <>\n <div className={expandableContentClasses}>\n <div className=\"bg-white rounded-[var(--malachite-radius-10,10px)] shadow-[0px_1px_0px_0px_rgba(0,0,0,0.15)] border border-[#e8e8e8] border-solid mx-2 mb-2 max-h-[553px] overflow-y-auto\">\n {children}\n </div>\n </div>\n </>\n )}\n </div>\n );\n};\n\nexport default Alert;\nexport { Alert };\nexport type { AlertButtonConfig };\n"],"names":["getAlertTextColor","alertType","ICON_STYLE","ICON_COLOR","AlertIcon","jsx","InfoCircleFilled","CheckCircleFilled","ErrorCircleFilled","WarningCircleFilled","SparkleIcon","BANNER_ICON_STYLE","statusIcon","type","icon","banner","SimpleTextRenderer","text","lead","renderLink","jsxs","getTextColor","getFontSize","MarkdownBlock","Alert","message","hasMargin","className","children","isExpanded","onToggle","action","live","layout","isExpandable","liveRole","internalExpanded","setInternalExpanded","useState","expanded","handleToggle","newExpanded","alertClasses","headerClasses","expandableContentClasses","Button","CaretUpIcon","CaretDownIcon","Fragment"],"mappings":";;;;;;;;;;;;AAoDA,MAAMA,IAAoB,CAACC,MAAoC;AAC3D,UAAQA,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA;AAAA;AAAA,IAGX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB,GAEMC,IAAa;AAAA,EACf,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAChB,GAEMC,IAAwC;AAAA,EAC1C,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AACf,GAEMC,IAAY;AAAA,EACd,MACI,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,OAAO,EAAE,GAAGJ,GAAY,OAAOC,EAAW,KAAA;AAAA,IAAK;AAAA,EAAA;AAAA,EAGvD,SACI,gBAAAE;AAAA,IAACE;AAAA,IAAA;AAAA,MACG,OAAO,EAAE,GAAGL,GAAY,OAAOC,EAAW,QAAA;AAAA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EAAA2C,GAAA,EACI,UAAA,gBAAA3C,EAAC,OAAA,EAAI,WAAWuC,GACZ,UAAA,gBAAAvC,EAAC,OAAA,EAAI,WAAU,6KACV,UAAAuB,EAAA,CACL,EAAA,CACJ,EAAA,CACJ;AAAA,EAAA,GAER,IAxEI,gBAAAR,EAAC,OAAA,EAAI,WAAWsB,GACX,UAAA;AAAA,IAAA9B,EAAWC,GAAMC,GAAMC,CAAM;AAAA,IAC9B,gBAAAV,EAAC,SAAI,WAAU,4BACX,4BAAC,OAAA,EAAI,WAAU,gBAAe,MAAM8B,GAChC,UAAA,gBAAA9B;AAAA,MAACW;AAAA,MAAA;AAAA,QACG,MAAMS;AAAA,QACN,MAAAZ;AAAA,QACA,MAAAK;AAAA,QACA,YAAAC;AAAA,MAAA;AAAA,IAAA,GAER,EAAA,CACJ;AAAA,IACCY,KAAU,gBAAA1B,EAAC,OAAA,EAAI,WAAU,2CAA2C,UAAA0B,EAAA,CAAO;AAAA,EAAA,GAChF;AA6DZ;"}
@@ -1,27 +1,27 @@
1
1
  import { jsx as r, jsxs as i, Fragment as d } from "react/jsx-runtime";
2
- import { forwardRef as O } from "react";
3
- import T from "./Tooltip.js";
4
- import { getIconOnlySizeClasses as U, getIconSizeClass as V } from "./buttonSizing.js";
5
- import { resolveRel as W } from "./linkRel.js";
6
- const A = (s) => {
7
- switch (s) {
2
+ import { forwardRef as E } from "react";
3
+ import H from "./Tooltip.js";
4
+ import { getIconOnlySizeClasses as M, getIconSizeClass as q } from "./buttonSizing.js";
5
+ import { resolveRel as D } from "./linkRel.js";
6
+ const O = (t) => {
7
+ switch (t) {
8
8
  // Figma has no text X-Small button, only the icon-only square — nothing to align to.
9
9
  case "xsmall":
10
- return "px-2 py-1 text-xs";
10
+ return "[--btn-px:calc(var(--spacing)*2)] px-[var(--btn-px)] py-1 text-xs";
11
11
  case "small":
12
- return "min-h-[var(--malachite-control-height-small,28px)] px-[10px] text-[length:var(--malachite-font-size-small,13px)] leading-[16px] whitespace-nowrap";
12
+ return "min-h-[var(--malachite-control-height-small,28px)] [--btn-px:10px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-small,13px)] leading-[16px] whitespace-nowrap";
13
13
  case "medium":
14
- return "min-h-[var(--malachite-control-height-medium,32px)] px-[10px] text-[length:var(--malachite-font-size-small,13px)] leading-[16px] whitespace-nowrap";
14
+ return "min-h-[var(--malachite-control-height-medium,32px)] [--btn-px:10px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-small,13px)] leading-[16px] whitespace-nowrap";
15
15
  case "large":
16
- return "min-h-[var(--malachite-control-height-large,42px)] px-[12px] text-[length:var(--malachite-font-size-15,15px)] leading-[18px] whitespace-nowrap";
16
+ return "min-h-[var(--malachite-control-height-large,42px)] [--btn-px:12px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-15,15px)] leading-[18px] whitespace-nowrap";
17
17
  default:
18
- return "min-h-[var(--malachite-control-height-large,42px)] px-[12px] text-[length:var(--malachite-font-size-15,15px)] leading-[18px] whitespace-nowrap";
18
+ return "min-h-[var(--malachite-control-height-large,42px)] [--btn-px:12px] px-[var(--btn-px)] text-[length:var(--malachite-font-size-15,15px)] leading-[18px] whitespace-nowrap";
19
19
  }
20
- }, D = (s, t) => {
21
- switch (s) {
20
+ }, T = "-mx-[calc(var(--btn-px)+1px)]", V = "-mx-[var(--btn-px)]", W = (t, a) => {
21
+ switch (t) {
22
22
  // Only the square rounds at 8px — text buttons at this size keep their 6px corner.
23
23
  case "xsmall":
24
- return t ? "rounded-lg" : "rounded-md";
24
+ return a ? "rounded-lg" : "rounded-md";
25
25
  case "small":
26
26
  return "rounded-[var(--malachite-radius-10,10px)]";
27
27
  case "medium":
@@ -31,17 +31,17 @@ const A = (s) => {
31
31
  default:
32
32
  return "rounded-[var(--malachite-radius-xxl,14px)]";
33
33
  }
34
- }, k = (s, t) => {
35
- const e = t === "start";
36
- switch (s) {
34
+ }, R = (t, a) => {
35
+ const e = a === "start";
36
+ switch (t) {
37
37
  case "small":
38
38
  case "medium":
39
39
  return e ? "mr-[6px]" : "ml-[6px]";
40
40
  default:
41
41
  return e ? "mr-2" : "ml-2";
42
42
  }
43
- }, E = (s) => {
44
- switch (s) {
43
+ }, G = (t) => {
44
+ switch (t) {
45
45
  case "md":
46
46
  return "rounded-md";
47
47
  case "lg":
@@ -51,40 +51,43 @@ const A = (s) => {
51
51
  default:
52
52
  return "rounded-xl";
53
53
  }
54
- }, a = {
54
+ }, s = {
55
55
  neutral: "focus-visible:[outline:2px_solid_var(--malachite-text-primary)]",
56
56
  destructive: "focus-visible:[outline:2px_solid_var(--malachite-text-destructive)]",
57
57
  success: "focus-visible:[outline:2px_solid_var(--malachite-text-success)]",
58
58
  warning: "focus-visible:[outline:2px_solid_var(--malachite-text-warning)]",
59
59
  error: "focus-visible:[outline:2px_solid_var(--malachite-text-error)]",
60
- assistant: "focus-visible:[outline:2px_solid_var(--malachite-assistant-foreground)]"
61
- }, H = (s, t) => {
62
- const e = `font-medium transition-[color,background-color,border-color,opacity,box-shadow] duration-200 ease-in-out outline-none focus-visible:outline-offset-2 border border-solid ${t} cursor-pointer`;
63
- switch (s) {
60
+ assistant: "focus-visible:[outline:2px_solid_var(--malachite-assistant-foreground)]",
61
+ accent: "focus-visible:[outline:2px_solid_var(--malachite-accent-foreground)]"
62
+ }, J = (t, a) => {
63
+ const e = `font-medium transition-[color,background-color,border-color,opacity,box-shadow] duration-200 ease-in-out outline-none focus-visible:outline-offset-2 border border-solid ${a} cursor-pointer`;
64
+ switch (t) {
64
65
  case "filled":
65
- return `${e} ${a.neutral} btn-filled shadow-default`;
66
+ return `${e} ${s.neutral} btn-filled shadow-default`;
66
67
  case "outline":
67
- return `${e} ${a.neutral} btn-outline shadow-default`;
68
+ return `${e} ${s.neutral} btn-outline shadow-default`;
68
69
  case "surface":
69
- return `${e} ${a.neutral} btn-surface shadow-default`;
70
+ return `${e} ${s.neutral} btn-surface shadow-default`;
70
71
  case "assistant":
71
- return `${e} ${a.assistant} btn-assistant shadow-default`;
72
+ return `${e} ${s.assistant} btn-assistant shadow-default`;
72
73
  case "destructive":
73
- return `${e} ${a.destructive} btn-destructive`;
74
+ return `${e} ${s.destructive} btn-destructive`;
74
75
  case "success":
75
- return `${e} ${a.success} btn-glass-success`;
76
+ return `${e} ${s.success} btn-glass-success`;
76
77
  case "warning":
77
- return `${e} ${a.warning} btn-glass-warning`;
78
+ return `${e} ${s.warning} btn-glass-warning`;
78
79
  case "error":
79
- return `${e} ${a.error} btn-glass-error`;
80
+ return `${e} ${s.error} btn-glass-error`;
80
81
  case "ghost":
81
- return `${e} ${a.neutral} btn-ghost`;
82
+ return `${e} ${s.neutral} btn-ghost`;
83
+ case "quiet":
84
+ return `${e} ${s.accent} btn-quiet`;
82
85
  case "no-style":
83
- return `${e} ${a.neutral} btn-no-style border-none`;
86
+ return `${e} ${s.neutral} btn-no-style border-none`;
84
87
  default:
85
- return `${e} ${a.neutral} btn-filled shadow-default`;
88
+ return `${e} ${s.neutral} btn-filled shadow-default`;
86
89
  }
87
- }, M = () => /* @__PURE__ */ i(
90
+ }, K = () => /* @__PURE__ */ i(
88
91
  "svg",
89
92
  {
90
93
  className: "animate-spin -ml-1 mr-2 h-4 w-4",
@@ -113,103 +116,107 @@ const A = (s) => {
113
116
  )
114
117
  ]
115
118
  }
116
- ), q = O(
119
+ ), Q = E(
117
120
  ({
118
- variant: s,
119
- size: t = "large",
121
+ variant: t,
122
+ size: a = "large",
120
123
  radius: e,
121
- loading: f = !1,
122
- disabled: j = !1,
123
- icon: o,
124
- iconPosition: g = "start",
124
+ loading: g = !1,
125
+ disabled: I = !1,
126
+ icon: c,
127
+ iconPosition: b = "start",
125
128
  leading: v,
126
- contentAlign: I = "center",
129
+ contentAlign: k = "center",
127
130
  flexGrow: m = !1,
128
- fill: z = !1,
131
+ width: j = "auto",
132
+ fill: B = !1,
129
133
  tooltip: x,
130
- tooltipPlacement: B = "top",
131
- iconOnly: w = !1,
134
+ tooltipPlacement: L = "top",
135
+ iconOnly: p = !1,
136
+ flush: z = !1,
132
137
  children: n,
133
- className: R = "",
134
- href: b,
138
+ className: F = "",
139
+ href: w,
135
140
  target: $,
136
- rel: F,
137
- ...C
138
- }, _) => {
139
- const L = e ? E(e) : D(t, w), l = j || f, N = I === "start", y = [
141
+ rel: U,
142
+ ..._
143
+ }, C) => {
144
+ const A = e ? G(e) : W(a, p), l = I || g, N = k === "start", y = [
140
145
  N ? "flex items-center justify-start text-left" : "flex items-center justify-center",
141
- w ? `p-0 ${U(t)}` : A(t),
142
- H(s, L),
146
+ p ? `p-0 ${M(a)}` : O(a),
147
+ J(t, A),
143
148
  m ? "w-full" : "",
144
- z ? "max-w-full" : "",
149
+ j === "wide" ? "min-w-[120px]" : "",
150
+ B ? "max-w-full" : "",
145
151
  l ? "cursor-not-allowed" : "",
146
152
  x && l ? "pointer-events-none" : "",
147
- R
148
- ].filter(Boolean).join(" "), c = N ? /* @__PURE__ */ r("span", { className: "flex min-w-0 flex-1 items-center", children: n }) : n, u = v ? /* @__PURE__ */ r(
153
+ z && !p ? t === "no-style" ? V : T : "",
154
+ F
155
+ ].filter(Boolean).join(" "), o = N ? /* @__PURE__ */ r("span", { className: "flex min-w-0 flex-1 items-center", children: n }) : n, u = v ? /* @__PURE__ */ r(
149
156
  "span",
150
157
  {
151
158
  className: n ? "btn-leading inline-flex shrink-0 items-center me-2" : "btn-leading inline-flex shrink-0 items-center",
152
159
  children: v
153
160
  }
154
161
  ) : null, S = () => {
155
- if (f)
162
+ if (g)
156
163
  return /* @__PURE__ */ i(d, { children: [
157
164
  u,
158
- /* @__PURE__ */ r(M, {}),
159
- c
165
+ /* @__PURE__ */ r(K, {}),
166
+ o
160
167
  ] });
161
- const h = `inline-flex items-center shrink-0 ${V(t)}`;
162
- return o && g === "start" ? /* @__PURE__ */ i(d, { children: [
168
+ const f = `inline-flex items-center shrink-0 ${q(a)}`;
169
+ return c && b === "start" ? /* @__PURE__ */ i(d, { children: [
163
170
  u,
164
171
  /* @__PURE__ */ r(
165
172
  "span",
166
173
  {
167
- className: `${h}${n ? ` ${k(t, "start")}` : ""}`,
168
- children: o
174
+ className: `${f}${n ? ` ${R(a, "start")}` : ""}`,
175
+ children: c
169
176
  }
170
177
  ),
171
- c
172
- ] }) : o && g === "end" ? /* @__PURE__ */ i(d, { children: [
178
+ o
179
+ ] }) : c && b === "end" ? /* @__PURE__ */ i(d, { children: [
173
180
  u,
174
- c,
181
+ o,
175
182
  /* @__PURE__ */ r(
176
183
  "span",
177
184
  {
178
- className: `${h}${n ? ` ${k(t, "end")}` : ""}`,
179
- children: o
185
+ className: `${f}${n ? ` ${R(a, "end")}` : ""}`,
186
+ children: c
180
187
  }
181
188
  )
182
189
  ] }) : /* @__PURE__ */ i(d, { children: [
183
190
  u,
184
- c
191
+ o
185
192
  ] });
186
- }, p = b && !l ? /* @__PURE__ */ r(
193
+ }, h = w && !l ? /* @__PURE__ */ r(
187
194
  "a",
188
195
  {
189
- ref: _,
190
- href: b,
196
+ ref: C,
197
+ href: w,
191
198
  target: $,
192
- rel: W(F, $),
199
+ rel: D(U, $),
193
200
  className: y,
194
- ...C,
201
+ ..._,
195
202
  children: S()
196
203
  }
197
204
  ) : /* @__PURE__ */ r(
198
205
  "button",
199
206
  {
200
- ref: _,
207
+ ref: C,
201
208
  disabled: l,
202
209
  className: y,
203
- ...C,
210
+ ..._,
204
211
  children: S()
205
212
  }
206
213
  );
207
- return x ? /* @__PURE__ */ r(T, { text: x, placement: B, fill: m, children: l ? /* @__PURE__ */ r("span", { className: `inline-flex cursor-not-allowed${m ? " w-full" : ""}`, children: p }) : p }) : p;
214
+ return x ? /* @__PURE__ */ r(H, { text: x, placement: L, fill: m, children: l ? /* @__PURE__ */ r("span", { className: `inline-flex cursor-not-allowed${m ? " w-full" : ""}`, children: h }) : h }) : h;
208
215
  }
209
216
  );
210
- q.displayName = "Button";
217
+ Q.displayName = "Button";
211
218
  export {
212
- q as Button,
213
- q as default
219
+ Q as Button,
220
+ Q as default
214
221
  };
215
222
  //# sourceMappingURL=Button.js.map