@stackone/malachite 2.55.0 → 2.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPONENTS.md +4 -4
- package/dist/assets/empty_logo.svg.js +6 -0
- package/dist/assets/empty_logo.svg.js.map +1 -0
- package/dist/components/Alert.js +56 -55
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Avatar.js +26 -44
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Skeleton.js +45 -42
- package/dist/components/Skeleton.js.map +1 -1
- package/dist/components/Typography/Text.js +14 -13
- package/dist/components/Typography/Text.js.map +1 -1
- package/dist/components/Typography/index.js.map +1 -1
- package/dist/components/Typography/textStyles.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/package.json +1 -1
package/COMPONENTS.md
CHANGED
|
@@ -34,7 +34,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
34
34
|
## Feedback & status
|
|
35
35
|
|
|
36
36
|
- **`ChangeReview`** — Reviewing changes a machine made. `ChangeReview.Item` attaches to one changed thing: it names what changed with an `assistant` Tag, shows the value it displaced struck through, and offers approve and deny as two equally reachable icon buttons — a review affordance that made keeping easier than rejecting would not be one. Given `children`, it wraps the field the change is annotating: the tag/label/actions become a header band above it and the before/after line moves below, so "Was …" reads next to the value it describes instead of stacked with the header; without children it renders as the standalone card it always has. `ChangeReview.Summary` counts what is still undecided across the whole form, which is what a per-item control cannot do and what a caller gates a save on; at zero it either says so or collapses to nothing. `ChangeReview.Removed` is for something the assistant took out: a dashed, tinted card listing what would be lost, because a removal that simply vanished would leave nothing to reject. `ChangeReview.Jump` is a chip an assistant turn carries to point at a field it touched. _Key props:_ `Item`: `label`, `before`, `after`, `kind` (`changed` | `added` | `removed`), `origin`, `children`, `onApprove`, `onDeny`, `disabled`, `className`. `Summary`: `count`, `origin`, `onApproveAll`, `onDenyAll`, `disabled`, `settledMessage`, `className`. `Removed`: `title`, `details` (`{label, value}[]`), `onRestore`, `onDiscard`, `restoreLabel`, `discardLabel`, `origin`, `disabled`, `className`. `Jump`: `label`, `onClick`, `disabled`, `className`. `Item` also takes `onPreviewRevert(previewing)`, fired on hover and on focus.
|
|
37
|
-
- **`Alert`** — Inline alert/callout. Four severities (info, success, warning, error) plus `assistant` — a violet, sparkle-marked ground that says a machine wrote the message rather than that anything is wrong, so provenance never has to borrow a severity colour. `action` puts a control at the end — the link or button that resolves what the alert reports — and `icon` replaces the status icon; an svg that paints with `currentColor` (a CustomIcon) is drawn in the colour and size of the built-in one. _Key props:_ `type`, `message`, `action`, `icon`, `hasMargin`, `children` (expandable body), `isExpanded`, `onToggle`, `className`.
|
|
37
|
+
- **`Alert`** — Inline alert/callout. Four severities (info, success, warning, error) plus `assistant` — a violet, sparkle-marked ground that says a machine wrote the message rather than that anything is wrong, so provenance never has to borrow a severity colour. `action` puts a control at the end — the link or button that resolves what the alert reports — and `icon` replaces the status icon; an svg that paints with `currentColor` (a CustomIcon) is drawn in the colour and size of the built-in one. _Key props:_ `type`, `message`, `action`, `icon`, `hasMargin`, `live` (makes the message a live region — `role="alert"` for error/warning, announced as it mounts; `status` otherwise, announced when its `message` changes, so keep it mounted; off by default), `children` (expandable body), `isExpanded`, `onToggle`, `className`.
|
|
38
38
|
- **`IconIndicator`** — A non-interactive icon that carries a meaning, such as a capability shown on a page that cannot switch it on. Same square as an icon-only `Button` at each `size`, so it lines up where a sibling view shows the button. Renders `role="img"`, named by `aria-label`; with a `tooltip` it takes focus so the tooltip is reachable by keyboard. Reach for it instead of a hand-sized `<span>` around an icon. _Key props:_ `icon`, `aria-label`, `tooltip`, `size`.
|
|
39
39
|
- **`StatusBadge`** — Large status indicator (e.g. success checkmark) for terminal/confirmation screens. _Key props:_ `type`.
|
|
40
40
|
- **`StatBadge`** — Pill showing a numeric value with a label (e.g. "3 accounts selected"). _Key props:_ `count`, `label`.
|
|
@@ -44,7 +44,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
44
44
|
- **`Progress`** — Progress bar.
|
|
45
45
|
- **`LoadingBar`** — Indeterminate full-width loading line; the variant colour sweeps across a pale track for work of unknown duration. Toggle `active` rather than unmounting, so the reserved height prevents layout shift. _Key props:_ `active`, `LoadingBarVariant` (`default` | `warning` | `error`), `LoadingBarSize` (`small` | `medium` | `large`), `aria-label`, `aria-labelledby`, `className`, `style`.
|
|
46
46
|
- **`Spinner`** — Loading spinner.
|
|
47
|
-
- **`Skeleton`** — Loading placeholders. Includes `Skeleton.Avatar` and `Skeleton.Input`.
|
|
47
|
+
- **`Skeleton`** — Loading placeholders. Includes `Skeleton.Avatar` and `Skeleton.Input`. The shimmer stops under `prefers-reduced-motion`, leaving the plain placeholder.
|
|
48
48
|
- **`Tooltip`** — Hover/focus tooltip; also works on disabled controls (see CLAUDE.md). It describes its trigger once shown, so `describesTrigger={false}` where the same sentence is already on screen and referenced — otherwise a screen reader reads it twice. _Key props:_ `text`, `placement`, `delay`, `maxWidth`, `shouldShow`, `triggerAs`, `describesTrigger`, `isShrinkable`, `fill`, `wrapChildren`, `suppressed` (holds the tooltip back, e.g. while the popup its trigger opens is up), `showOnFocus` (false where script can move focus onto the trigger, e.g. an option a panel focuses on open), `focusableTrigger` (makes a trigger that cannot take focus — text, a static `Tag` — a tab stop, so the tooltip is not mouse-only; not for focusable children).
|
|
49
49
|
- **`TruncatedTooltip`** — Shows a tooltip only when its text is truncated.
|
|
50
50
|
- **`Confetti`** — Celebratory confetti burst for success moments. _Key props:_ `pieces`.
|
|
@@ -103,14 +103,14 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
103
103
|
## Typography
|
|
104
104
|
|
|
105
105
|
- **`ClampText`** — Clamps text to N lines; expands to full text on hover/focus with a height animation. Wrapping markdown? Pass `variant="flow"` to the `Typography.MarkdownBlock` inside it, or the clamp counts blocks instead of lines.
|
|
106
|
-
- **`Typography`** — Text primitives — use these instead of raw colour tokens on `<span>`s. Includes `Typography.Text`, `Typography.SecondaryText`, `Typography.EllipsisText`, etc., with size/weight/color props. `Typography.Text` takes `font="sans" | "heading" | "body" | "mono"
|
|
106
|
+
- **`Typography`** — Text primitives — use these instead of raw colour tokens on `<span>`s. Includes `Typography.Text`, `Typography.SecondaryText`, `Typography.EllipsisText`, etc., with size/weight/color props. `Typography.Text` takes `font="sans" | "heading" | "body" | "mono"`, and `as` (`p`, `h1`–`h6`) for a heading or paragraph that keeps its look; `Typography.CodeText` takes `variant="inline"` for a chip mid-sentence; `Typography.MarkdownBlock` takes `variant="flow"` for use inside `ClampText`, `variant="inline"` for one line of inline syntax set inside another component (no autolinks, images as alt text), `links="inert"` to draw links without an anchor inside a button, and `normalizeSource` for machine-generated descriptions that omit blank lines between blocks. `Typography.EllipsisText` takes a `size` so a truncating label can match the text beside it, and shows its `tooltip` on every hover unless `tooltipWhenTruncated` is set, which limits it to text that is actually cut off — for a tooltip that repeats the label, where a tooltip carrying something the label does not say should keep the default.
|
|
107
107
|
|
|
108
108
|
## Data display
|
|
109
109
|
|
|
110
110
|
- **`Table`** — Data table with columns, sizing, pagination and row selection. `column.align` places a column's header as well as its cells. What lands on the aligned edge is the last thing in the header row rather than the title: the sort caret on a sortable column, the info icon on one carrying `info` without a sorter. `headerVariant` picks the header layout, and only `inline` lines header and body up exactly, because both are cells of one `<table>`. `detached` builds them from flex rows, where a sortable header cell is 32px narrower than a non-sortable one — its padding sits on the inner button rather than on the flex item — so its header cells sit 15–17px off their column at any alignment; reach for `inline` where exact alignment matters. Sorting is internal, so the array passed as `data` is not the order rendered once a column is sorted: `onVisibleOrderChange` reports the rows in render order — the whole of `data`, compared by `rowKey` so an equal order never re-fires — for a consumer stepping a master-detail view the way the user sees it. _Key props:_ `TableColumns` (incl. `align`), `TableSize`, `TableType`, `TableRowSelection`, `TablePaginationPosition`, `headerVariant`, `onVisibleOrderChange`.
|
|
111
111
|
- **`Statistic`** — Displays a statistic value with a label; primary/secondary sizes. _Key props:_ `StatisticValueSize`.
|
|
112
112
|
- **`Avatar`** — Logo/initial avatar. Renders the image when available, otherwise a coloured tile with the first letter of `name`, or with `fallback="placeholder"` the generic "no logo available" tile. Encapsulates the fallback colour. _Key props:_ `src`, `name`, `size`, `shape="square" | "circle"`, `fallback="initial" | "placeholder"`.
|
|
113
|
-
- **`AppLogo`** — A connector's mark, optionally with its name and version tag. Builds on `Avatar`, so a missing or broken logo falls back to the generic "no logo available" placeholder,
|
|
113
|
+
- **`AppLogo`** — A connector's mark, optionally with its name and version tag. Builds on `Avatar`, so a missing or broken logo falls back to the generic "no logo available" placeholder, a neutral grey tile with a darker square, the same mark stackone-logos.com serves. The gap tightens below 18px so the mark and label still read as one unit. _Key props:_ `src`, `name`, `showName`, `size`, `nameSize`, `nameWeight`, `version`, `truncate`, `className`.
|
|
114
114
|
- **`ConnectionHeader`** — Two tilted logo tiles (from → to) showing a connection between apps. _Key props:_ `from`, `to` (`ConnectionEndpoint`: `icon`, `label`, `background`).
|
|
115
115
|
- **`CodeBlock`** — Syntax-styled code block. _Key props:_ `code`.
|
|
116
116
|
- **`Stepper`** — Progress dots/segments for a multi-step flow; optionally clickable. _Key props:_ `steps`, `active`, `onChange`.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
const a = (t) => /* @__PURE__ */ e.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...t }, /* @__PURE__ */ e.createElement("path", { "data-malachite-shape": "", d: "M16 0H8C3.58172 0 0 3.58172 0 8V16C0 20.4183 3.58172 24 8 24H16C20.4183 24 24 20.4183 24 16V8C24 3.58172 20.4183 0 16 0Z", fill: "#D5D4D2" }), /* @__PURE__ */ e.createElement("path", { "data-malachite-shape": "", d: "M13.3333 8H10.6667C9.19391 8 8 9.19391 8 10.6667V13.3333C8 14.8061 9.19391 16 10.6667 16H13.3333C14.8061 16 16 14.8061 16 13.3333V10.6667C16 9.19391 14.8061 8 13.3333 8Z", fill: "#A19F9E" }));
|
|
3
|
+
export {
|
|
4
|
+
a as default
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=empty_logo.svg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty_logo.svg.js","sources":["../../src/assets/empty_logo.svg?react"],"sourcesContent":["import * as React from \"react\";\nconst SvgEmptyLogo = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { \"data-malachite-shape\": \"\", d: \"M16 0H8C3.58172 0 0 3.58172 0 8V16C0 20.4183 3.58172 24 8 24H16C20.4183 24 24 20.4183 24 16V8C24 3.58172 20.4183 0 16 0Z\", fill: \"#D5D4D2\" }), /* @__PURE__ */ React.createElement(\"path\", { \"data-malachite-shape\": \"\", d: \"M13.3333 8H10.6667C9.19391 8 8 9.19391 8 10.6667V13.3333C8 14.8061 9.19391 16 10.6667 16H13.3333C14.8061 16 16 14.8061 16 13.3333V10.6667C16 9.19391 14.8061 8 13.3333 8Z\", fill: \"#A19F9E\" }));\nexport default SvgEmptyLogo;\n"],"names":["SvgEmptyLogo","props","React"],"mappings":";AACK,MAACA,IAAe,CAACC,MAA0B,gBAAAC,EAAM,cAAc,OAAO,EAAE,OAAO,IAAI,QAAQ,IAAI,SAAS,aAAa,MAAM,QAAQ,OAAO,8BAA8B,GAAGD,EAAK,GAAoB,gBAAAC,EAAM,cAAc,QAAQ,EAAE,wBAAwB,IAAI,GAAG,4HAA4H,MAAM,UAAS,CAAE,GAAmB,gBAAAA,EAAM,cAAc,QAAQ,EAAE,wBAAwB,IAAI,GAAG,6KAA6K,MAAM,WAAW,CAAC;"}
|
package/dist/components/Alert.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Button as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { getTextColor as
|
|
13
|
-
const
|
|
1
|
+
import { jsxs as i, jsx as e, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import { useState as B } from "react";
|
|
3
|
+
import { Button as E } from "./Button.js";
|
|
4
|
+
import F from "./CustomIcons/CaretDownIcon.js";
|
|
5
|
+
import S from "./CustomIcons/CaretUpIcon.js";
|
|
6
|
+
import O from "./CustomIcons/CheckCircleFilled.js";
|
|
7
|
+
import z from "./CustomIcons/ErrorCircleFilled.js";
|
|
8
|
+
import A from "./CustomIcons/InfoCircleFilled.js";
|
|
9
|
+
import R from "./CustomIcons/SparkleIcon.js";
|
|
10
|
+
import W from "./CustomIcons/WarningCircleFilled.js";
|
|
11
|
+
import H from "./Typography/MarkdownBlock.js";
|
|
12
|
+
import { getTextColor as L } from "./Typography/textStyles.js";
|
|
13
|
+
const g = (r) => {
|
|
14
14
|
switch (r) {
|
|
15
15
|
case "info":
|
|
16
16
|
return "primary";
|
|
@@ -31,108 +31,109 @@ const v = (r) => {
|
|
|
31
31
|
width: "13px",
|
|
32
32
|
height: "13px",
|
|
33
33
|
flexShrink: 0
|
|
34
|
-
},
|
|
34
|
+
}, n = {
|
|
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
|
-
},
|
|
40
|
+
}, M = {
|
|
41
41
|
info: /* @__PURE__ */ e(
|
|
42
|
-
|
|
42
|
+
A,
|
|
43
43
|
{
|
|
44
|
-
style: { ...s, color:
|
|
44
|
+
style: { ...s, color: n.info }
|
|
45
45
|
}
|
|
46
46
|
),
|
|
47
47
|
success: /* @__PURE__ */ e(
|
|
48
|
-
|
|
48
|
+
O,
|
|
49
49
|
{
|
|
50
|
-
style: { ...s, color:
|
|
50
|
+
style: { ...s, color: n.success }
|
|
51
51
|
}
|
|
52
52
|
),
|
|
53
53
|
error: /* @__PURE__ */ e(
|
|
54
|
-
|
|
54
|
+
z,
|
|
55
55
|
{
|
|
56
|
-
style: { ...s, color:
|
|
56
|
+
style: { ...s, color: n.error }
|
|
57
57
|
}
|
|
58
58
|
),
|
|
59
59
|
warning: /* @__PURE__ */ e(
|
|
60
|
-
|
|
60
|
+
W,
|
|
61
61
|
{
|
|
62
|
-
style: { ...s, color:
|
|
62
|
+
style: { ...s, color: n.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
|
-
|
|
68
|
+
R,
|
|
69
69
|
{
|
|
70
|
-
style: { ...s, color:
|
|
70
|
+
style: { ...s, color: n.assistant }
|
|
71
71
|
}
|
|
72
72
|
)
|
|
73
|
-
},
|
|
73
|
+
}, p = (r, l) => l ? /* @__PURE__ */ e(
|
|
74
74
|
"span",
|
|
75
75
|
{
|
|
76
76
|
className: "alert-status-icon inline-flex shrink-0 [&_svg]:size-full!",
|
|
77
|
-
style: { ...s, color:
|
|
77
|
+
style: { ...s, color: n[r] },
|
|
78
78
|
children: l
|
|
79
79
|
}
|
|
80
|
-
) :
|
|
80
|
+
) : M[r], v = ({ text: r, type: l }) => /* @__PURE__ */ e(H, { text: r, color: g(l), size: "small", omitMargin: !0 }), Z = ({
|
|
81
81
|
type: r = "info",
|
|
82
82
|
message: l,
|
|
83
|
-
hasMargin:
|
|
84
|
-
className:
|
|
83
|
+
hasMargin: w = !0,
|
|
84
|
+
className: C,
|
|
85
85
|
children: m,
|
|
86
86
|
isExpanded: c,
|
|
87
87
|
onToggle: d,
|
|
88
88
|
action: o,
|
|
89
|
-
icon: f
|
|
89
|
+
icon: f,
|
|
90
|
+
live: N = !1
|
|
90
91
|
}) => {
|
|
91
|
-
const t = !!m, [
|
|
92
|
-
const
|
|
93
|
-
c === void 0 &&
|
|
94
|
-
},
|
|
92
|
+
const t = !!m, x = N ? r === "error" || r === "warning" ? "alert" : "status" : void 0, [b, I] = B(!1), a = c !== void 0 ? c : b, k = () => {
|
|
93
|
+
const h = !a;
|
|
94
|
+
c === void 0 && I(h), d == null || d(h);
|
|
95
|
+
}, u = [
|
|
95
96
|
"alert-base",
|
|
96
97
|
`alert-${r}`,
|
|
97
98
|
"flex",
|
|
98
99
|
"w-full",
|
|
99
100
|
// Ensure full width
|
|
100
101
|
t && a ? "flex-col" : "gap-2 items-center min-h-[2rem]",
|
|
101
|
-
|
|
102
|
+
w ? "" : "alert-no-margin",
|
|
102
103
|
"text-left",
|
|
103
104
|
t ? "rounded-xl !p-0" : "!px-2.5 !py-1.5",
|
|
104
105
|
// Slightly more vertical padding for centering
|
|
105
|
-
|
|
106
|
+
C
|
|
106
107
|
].filter(Boolean).join(" "), y = [
|
|
107
108
|
"flex items-center justify-between w-full",
|
|
108
109
|
t ? "gap-2 px-2.5 py-1" : "gap-2",
|
|
109
110
|
t && a ? "rounded-t-xl" : t ? "rounded-xl" : ""
|
|
110
|
-
].filter(Boolean).join(" "),
|
|
111
|
-
return t ? /* @__PURE__ */
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
-
/* @__PURE__ */
|
|
114
|
-
|
|
115
|
-
/* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", children: /* @__PURE__ */ e(
|
|
111
|
+
].filter(Boolean).join(" "), _ = ["w-full", "overflow-hidden"].filter(Boolean).join(" ");
|
|
112
|
+
return t ? /* @__PURE__ */ i("div", { className: `${u} alert-expandable`, children: [
|
|
113
|
+
/* @__PURE__ */ i("div", { className: y, children: [
|
|
114
|
+
/* @__PURE__ */ i("div", { className: "flex-1 flex gap-2 items-center", children: [
|
|
115
|
+
p(r, f),
|
|
116
|
+
/* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", role: x, children: /* @__PURE__ */ e(v, { text: l, type: r }) }) })
|
|
116
117
|
] }),
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
118
119
|
o && /* @__PURE__ */ e("div", { className: "alert-action flex items-center", children: o }),
|
|
119
120
|
/* @__PURE__ */ e(
|
|
120
|
-
|
|
121
|
+
E,
|
|
121
122
|
{
|
|
122
123
|
variant: "no-style",
|
|
123
124
|
size: "xsmall",
|
|
124
|
-
onClick:
|
|
125
|
+
onClick: k,
|
|
125
126
|
"aria-label": a ? "Collapse" : "Expand",
|
|
126
127
|
style: {
|
|
127
|
-
color:
|
|
128
|
+
color: L(g(r))
|
|
128
129
|
},
|
|
129
130
|
children: a ? /* @__PURE__ */ e(
|
|
130
|
-
|
|
131
|
+
S,
|
|
131
132
|
{
|
|
132
133
|
style: { minWidth: "13px", minHeight: "13px" }
|
|
133
134
|
}
|
|
134
135
|
) : /* @__PURE__ */ e(
|
|
135
|
-
|
|
136
|
+
F,
|
|
136
137
|
{
|
|
137
138
|
style: { minWidth: "13px", minHeight: "13px" }
|
|
138
139
|
}
|
|
@@ -141,15 +142,15 @@ const v = (r) => {
|
|
|
141
142
|
)
|
|
142
143
|
] })
|
|
143
144
|
] }),
|
|
144
|
-
a && /* @__PURE__ */ e(
|
|
145
|
-
] }) : /* @__PURE__ */
|
|
146
|
-
|
|
147
|
-
/* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", children: /* @__PURE__ */ e(
|
|
145
|
+
a && /* @__PURE__ */ e(j, { children: /* @__PURE__ */ e("div", { className: _, 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: m }) }) })
|
|
146
|
+
] }) : /* @__PURE__ */ i("div", { className: u, children: [
|
|
147
|
+
p(r, f),
|
|
148
|
+
/* @__PURE__ */ e("div", { className: "flex-1 flex items-center", children: /* @__PURE__ */ e("div", { className: "[&>div]:mb-0", role: x, children: /* @__PURE__ */ e(v, { text: l, type: r }) }) }),
|
|
148
149
|
o && /* @__PURE__ */ e("div", { className: "alert-action shrink-0 flex items-center", children: o })
|
|
149
150
|
] });
|
|
150
151
|
};
|
|
151
152
|
export {
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
Z as Alert,
|
|
154
|
+
Z as default
|
|
154
155
|
};
|
|
155
156
|
//# 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 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}\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<{ text: string; type: AlertType }> = ({ text, type }) => {\n return <MarkdownBlock text={text} color={getAlertTextColor(type)} size=\"small\" omitMargin />;\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}) => {\n const isExpandable = !!children;\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\">\n <SimpleTextRenderer text={message} type={type} />\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\">\n <SimpleTextRenderer text={message} type={type} />\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","MarkdownBlock","Alert","message","hasMargin","className","children","isExpanded","onToggle","action","isExpandable","internalExpanded","setInternalExpanded","useState","expanded","handleToggle","newExpanded","alertClasses","headerClasses","expandableContentClasses","jsxs","Button","getTextColor","CaretUpIcon","CaretDownIcon","Fragment"],"mappings":";;;;;;;;;;;;AAuCA,MAAMA,IAAoB,CAACC,MAAoC;AAC3D,UAAQA,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AAC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,UAAA,gBAAAA,EAACS,GAAA,EAAmB,MAAMI,GAAS,MAAAN,EAAA,CAAY,GACnD,GACJ;AAAA,IACCY,KAAU,gBAAAnB,EAAC,OAAA,EAAI,WAAU,2CAA2C,UAAAmB,EAAA,CAAO;AAAA,EAAA,GAChF;AAwDZ;"}
|
|
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 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}\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<{ text: string; type: AlertType }> = ({ text, type }) => {\n return <MarkdownBlock text={text} color={getAlertTextColor(type)} size=\"small\" omitMargin />;\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}) => {\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} />\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 text={message} type={type} />\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","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":";;;;;;;;;;;;AA2CA,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,aAA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AmB,MAAMI,GAAS,MAAAN,EAAA,CAAY,GACnD,GACJ;AAAA,IACCY,KAAU,gBAAAnB,EAAC,OAAA,EAAI,WAAU,2CAA2C,UAAAmB,EAAA,CAAO;AAAA,EAAA,GAChF;AAwDZ;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u } from "react";
|
|
3
|
+
import g from "../assets/empty_logo.svg.js";
|
|
3
4
|
const p = (e) => {
|
|
4
5
|
let r = 0;
|
|
5
6
|
for (let t = 0; t < e.length; t += 1)
|
|
@@ -9,20 +10,20 @@ const p = (e) => {
|
|
|
9
10
|
src: e,
|
|
10
11
|
name: r,
|
|
11
12
|
size: t = 24,
|
|
12
|
-
shape:
|
|
13
|
-
fallback:
|
|
13
|
+
shape: l = "square",
|
|
14
|
+
fallback: h = "initial",
|
|
14
15
|
className: o = ""
|
|
15
16
|
}) => {
|
|
16
|
-
const [
|
|
17
|
-
if (e &&
|
|
18
|
-
return /* @__PURE__ */
|
|
17
|
+
const [c, f] = u(void 0), i = (r == null ? void 0 : r.trim()) ?? "", a = l === "circle" ? "50%" : `${Math.round(t * 0.25)}px`;
|
|
18
|
+
if (e && c !== e)
|
|
19
|
+
return /* @__PURE__ */ n(
|
|
19
20
|
"img",
|
|
20
21
|
{
|
|
21
22
|
src: e,
|
|
22
|
-
alt:
|
|
23
|
+
alt: i,
|
|
23
24
|
loading: "lazy",
|
|
24
25
|
decoding: "async",
|
|
25
|
-
onError: () =>
|
|
26
|
+
onError: () => f(e),
|
|
26
27
|
className: o,
|
|
27
28
|
style: {
|
|
28
29
|
width: `${t}px`,
|
|
@@ -33,42 +34,23 @@ const p = (e) => {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
flexShrink: 0,
|
|
48
|
-
borderRadius: a,
|
|
49
|
-
display: "flex",
|
|
50
|
-
alignItems: "center",
|
|
51
|
-
justifyContent: "center",
|
|
52
|
-
background: "var(--malachite-accent-background, rgb(0, 175, 102))"
|
|
53
|
-
},
|
|
54
|
-
children: /* @__PURE__ */ i(
|
|
55
|
-
"span",
|
|
56
|
-
{
|
|
57
|
-
style: {
|
|
58
|
-
width: d,
|
|
59
|
-
height: d,
|
|
60
|
-
borderRadius: "50%",
|
|
61
|
-
background: "rgba(255, 255, 255, 0.8)"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
)
|
|
37
|
+
const d = i ? { role: "img", "aria-label": i } : { "aria-hidden": !0 };
|
|
38
|
+
return h === "placeholder" ? /* @__PURE__ */ n(
|
|
39
|
+
g,
|
|
40
|
+
{
|
|
41
|
+
...d,
|
|
42
|
+
className: o,
|
|
43
|
+
width: t,
|
|
44
|
+
height: t,
|
|
45
|
+
style: {
|
|
46
|
+
flexShrink: 0,
|
|
47
|
+
borderRadius: l === "circle" ? "50%" : void 0
|
|
65
48
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return /* @__PURE__ */ i(
|
|
49
|
+
}
|
|
50
|
+
) : /* @__PURE__ */ n(
|
|
69
51
|
"div",
|
|
70
52
|
{
|
|
71
|
-
...
|
|
53
|
+
...d,
|
|
72
54
|
className: o,
|
|
73
55
|
style: {
|
|
74
56
|
width: `${t}px`,
|
|
@@ -78,14 +60,14 @@ const p = (e) => {
|
|
|
78
60
|
display: "flex",
|
|
79
61
|
alignItems: "center",
|
|
80
62
|
justifyContent: "center",
|
|
81
|
-
background: p(
|
|
63
|
+
background: p(i),
|
|
82
64
|
color: "#ffffff",
|
|
83
65
|
fontWeight: 600,
|
|
84
66
|
fontSize: `${Math.round(t * 0.45)}px`,
|
|
85
67
|
lineHeight: 1,
|
|
86
68
|
textTransform: "uppercase"
|
|
87
69
|
},
|
|
88
|
-
children:
|
|
70
|
+
children: i.charAt(0) || "?"
|
|
89
71
|
}
|
|
90
72
|
);
|
|
91
73
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sources":["../../src/components/Avatar.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nexport type AvatarShape = 'square' | 'circle';\n\n/** `initial` suits a named entity (a person, a model); `placeholder` says \"no logo available\". */\nexport type AvatarFallback = 'initial' | 'placeholder';\n\nexport interface AvatarProps {\n /** Image URL (logo/photo). Falls back to `fallback` when missing or it fails to load. */\n src?: string;\n /** Used for the initial fallback and as the image alt / accessible label. */\n name?: string;\n /** Pixel size of the (square) avatar. */\n size?: number;\n shape?: AvatarShape;\n /** What shows when `src` is missing or fails to load. Defaults to `initial`. */\n fallback?: AvatarFallback;\n className?: string;\n}\n\n// Deterministic, evenly-distributed hue from the label so the same entity always gets\n// the same colour. Saturation/lightness are fixed for a consistent, on-brand feel.\n// NOTE: avatar identity colours (this hue and the white text below) are intentionally\n// NOT theme tokens — they are a generated identity palette, an explicit exception to\n// the \"colours come from theme tokens\" rule (there is no avatar-colour token group).\nconst backgroundFor = (seed: string): string => {\n let hash = 0;\n for (let index = 0; index < seed.length; index += 1) {\n hash = seed.charCodeAt(index) + ((hash << 5) - hash);\n }\n return `hsl(${Math.abs(hash) % 360}, 55%, 52%)`;\n};\n\n/**\n * A logo/initial avatar. Renders `src` when available, otherwise a coloured tile\n * with the first letter of `name`. Encapsulates the fallback colour so consumers\n * never hand-roll it.\n */\nconst Avatar: React.FC<AvatarProps> = ({\n src,\n name,\n size = 24,\n shape = 'square',\n fallback = 'initial',\n className = '',\n}) => {\n // Track which src failed (not a boolean) so switching `src` to a new URL retries the\n // image instead of staying stuck on the fallback.\n const [failedSrc, setFailedSrc] = useState<string | undefined>(undefined);\n const label = name?.trim() ?? '';\n const borderRadius = shape === 'circle' ? '50%' : `${Math.round(size * 0.25)}px`;\n\n if (src && failedSrc !== src) {\n return (\n <img\n src={src}\n alt={label}\n loading=\"lazy\"\n decoding=\"async\"\n onError={() => setFailedSrc(src)}\n className={className}\n style={{\n width: `${size}px`,\n height: `${size}px`,\n borderRadius,\n objectFit: 'contain',\n flexShrink: 0,\n }}\n />\n );\n }\n\n // With a label the tile is an image with an accessible name; without one it carries\n // no information, so mark it decorative (aria-hidden, no role) to avoid an unnamed\n // image in the accessibility tree.\n const tileSemantics = label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true };\n\n if (fallback === 'placeholder') {\n
|
|
1
|
+
{"version":3,"file":"Avatar.js","sources":["../../src/components/Avatar.tsx"],"sourcesContent":["import React, { useState } from 'react';\n// The no-logo mark stackone-logos.com serves; the same in every theme, so its colours are fixed.\nimport EmptyLogoSvg from '../assets/empty_logo.svg?react';\n\nexport type AvatarShape = 'square' | 'circle';\n\n/** `initial` suits a named entity (a person, a model); `placeholder` says \"no logo available\". */\nexport type AvatarFallback = 'initial' | 'placeholder';\n\nexport interface AvatarProps {\n /** Image URL (logo/photo). Falls back to `fallback` when missing or it fails to load. */\n src?: string;\n /** Used for the initial fallback and as the image alt / accessible label. */\n name?: string;\n /** Pixel size of the (square) avatar. */\n size?: number;\n shape?: AvatarShape;\n /** What shows when `src` is missing or fails to load. Defaults to `initial`. */\n fallback?: AvatarFallback;\n className?: string;\n}\n\n// Deterministic, evenly-distributed hue from the label so the same entity always gets\n// the same colour. Saturation/lightness are fixed for a consistent, on-brand feel.\n// NOTE: avatar identity colours (this hue and the white text below) are intentionally\n// NOT theme tokens — they are a generated identity palette, an explicit exception to\n// the \"colours come from theme tokens\" rule (there is no avatar-colour token group).\nconst backgroundFor = (seed: string): string => {\n let hash = 0;\n for (let index = 0; index < seed.length; index += 1) {\n hash = seed.charCodeAt(index) + ((hash << 5) - hash);\n }\n return `hsl(${Math.abs(hash) % 360}, 55%, 52%)`;\n};\n\n/**\n * A logo/initial avatar. Renders `src` when available, otherwise a coloured tile\n * with the first letter of `name`. Encapsulates the fallback colour so consumers\n * never hand-roll it.\n */\nconst Avatar: React.FC<AvatarProps> = ({\n src,\n name,\n size = 24,\n shape = 'square',\n fallback = 'initial',\n className = '',\n}) => {\n // Track which src failed (not a boolean) so switching `src` to a new URL retries the\n // image instead of staying stuck on the fallback.\n const [failedSrc, setFailedSrc] = useState<string | undefined>(undefined);\n const label = name?.trim() ?? '';\n const borderRadius = shape === 'circle' ? '50%' : `${Math.round(size * 0.25)}px`;\n\n if (src && failedSrc !== src) {\n return (\n <img\n src={src}\n alt={label}\n loading=\"lazy\"\n decoding=\"async\"\n onError={() => setFailedSrc(src)}\n className={className}\n style={{\n width: `${size}px`,\n height: `${size}px`,\n borderRadius,\n objectFit: 'contain',\n flexShrink: 0,\n }}\n />\n );\n }\n\n // With a label the tile is an image with an accessible name; without one it carries\n // no information, so mark it decorative (aria-hidden, no role) to avoid an unnamed\n // image in the accessibility tree.\n const tileSemantics = label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true };\n\n if (fallback === 'placeholder') {\n return (\n <EmptyLogoSvg\n {...tileSemantics}\n className={className}\n width={size}\n height={size}\n style={{\n flexShrink: 0,\n borderRadius: shape === 'circle' ? '50%' : undefined,\n }}\n />\n );\n }\n\n return (\n <div\n {...tileSemantics}\n className={className}\n style={{\n width: `${size}px`,\n height: `${size}px`,\n flexShrink: 0,\n borderRadius,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: backgroundFor(label),\n color: '#ffffff',\n fontWeight: 600,\n fontSize: `${Math.round(size * 0.45)}px`,\n lineHeight: 1,\n textTransform: 'uppercase',\n }}\n >\n {label.charAt(0) || '?'}\n </div>\n );\n};\n\nexport default Avatar;\nexport { Avatar };\n"],"names":["backgroundFor","seed","hash","index","Avatar","src","name","size","shape","fallback","className","failedSrc","setFailedSrc","useState","label","borderRadius","jsx","tileSemantics","EmptyLogoSvg"],"mappings":";;;AA2BA,MAAMA,IAAgB,CAACC,MAAyB;AAC5C,MAAIC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AAA,IAAA;AAAA,MACI,GAAGC;AAAA,MACJ,WAAAP;AAAA,MACA,OAAO;AAAA,QACH,OAAO,GAAGH,CAAI;AAAA,QACd,QAAQ,GAAGA,CAAI;AAAA,QACf,YAAY;AAAA,QACZ,cAAAQ;AAAA,QACA,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,YAAYf,EAAcc,CAAK;AAAA,QAC/B,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,UAAU,GAAG,KAAK,MAAMP,IAAO,IAAI,CAAC;AAAA,QACpC,YAAY;AAAA,QACZ,eAAe;AAAA,MAAA;AAAA,MAGlB,UAAAO,EAAM,OAAO,CAAC,KAAK;AAAA,IAAA;AAAA,EAAA;AAGhC;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as d } from "react";
|
|
3
|
-
import { useAdoptedStyleSheet as
|
|
4
|
-
const
|
|
3
|
+
import { useAdoptedStyleSheet as u } from "./useAdoptedStyleSheet.js";
|
|
4
|
+
const E = { small: 24, default: 32, large: 40 }, S = { small: 64, default: 96, large: 128 }, T = { small: 24, default: 32, large: 40 }, b = { small: 24, default: 32, large: 40 }, g = "malachite-skeleton-loading", s = "rgba(190, 190, 190, 0.2)", p = "rgba(129, 129, 129, 0.24)", A = `linear-gradient(90deg, ${s} 25%, ${p} 37%, ${s} 63%)`, k = "data-malachite-skeleton-active", m = `@keyframes ${g} { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
|
|
5
|
+
[${k}] { background-image: ${A}; background-size: 400% 100%; animation: ${g} 1.4s ease infinite; }
|
|
6
|
+
@media (prefers-reduced-motion: reduce) { [${k}] { animation: none; background-image: none; } }`, _ = (e) => {
|
|
5
7
|
switch (e) {
|
|
6
8
|
case "round":
|
|
7
9
|
case "circle":
|
|
@@ -11,93 +13,94 @@ const k = { small: 24, default: 32, large: 40 }, S = { small: 64, default: 96, l
|
|
|
11
13
|
default:
|
|
12
14
|
return 6;
|
|
13
15
|
}
|
|
14
|
-
},
|
|
16
|
+
}, f = {
|
|
15
17
|
display: "inline-block",
|
|
16
18
|
verticalAlign: "middle",
|
|
17
|
-
|
|
18
|
-
backgroundSize: e ? "400% 100%" : void 0,
|
|
19
|
-
animation: e ? `${g} 1.4s ease infinite` : void 0,
|
|
19
|
+
backgroundColor: s,
|
|
20
20
|
flexShrink: 0
|
|
21
|
-
}
|
|
21
|
+
}, v = ({
|
|
22
22
|
size: e = "default",
|
|
23
|
-
shape:
|
|
24
|
-
block:
|
|
25
|
-
active:
|
|
23
|
+
shape: n = "default",
|
|
24
|
+
block: r = !1,
|
|
25
|
+
active: o = !0,
|
|
26
26
|
className: t,
|
|
27
27
|
width: a,
|
|
28
|
-
height:
|
|
29
|
-
minWidth:
|
|
28
|
+
height: i,
|
|
29
|
+
minWidth: l
|
|
30
30
|
}) => {
|
|
31
31
|
const h = d(null);
|
|
32
|
-
return
|
|
32
|
+
return u(h, m, "malachite-skeleton"), /* @__PURE__ */ c(
|
|
33
33
|
"span",
|
|
34
34
|
{
|
|
35
35
|
ref: h,
|
|
36
36
|
className: t,
|
|
37
|
+
"data-malachite-skeleton-active": o ? "" : void 0,
|
|
37
38
|
"aria-busy": "true",
|
|
38
39
|
"aria-hidden": "true",
|
|
39
40
|
style: {
|
|
40
|
-
...
|
|
41
|
-
width:
|
|
42
|
-
height:
|
|
43
|
-
minWidth:
|
|
44
|
-
borderRadius:
|
|
41
|
+
...f,
|
|
42
|
+
width: r ? "100%" : a ?? S[e],
|
|
43
|
+
height: i ?? E[e],
|
|
44
|
+
minWidth: l,
|
|
45
|
+
borderRadius: _(n)
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
);
|
|
48
|
-
},
|
|
49
|
+
}, y = ({
|
|
49
50
|
size: e = "default",
|
|
50
|
-
block:
|
|
51
|
-
active:
|
|
52
|
-
className:
|
|
51
|
+
block: n = !1,
|
|
52
|
+
active: r = !0,
|
|
53
|
+
className: o,
|
|
53
54
|
width: t,
|
|
54
55
|
height: a,
|
|
55
|
-
minWidth:
|
|
56
|
+
minWidth: i
|
|
56
57
|
}) => {
|
|
57
|
-
const
|
|
58
|
-
return
|
|
58
|
+
const l = d(null);
|
|
59
|
+
return u(l, m, "malachite-skeleton"), /* @__PURE__ */ c(
|
|
59
60
|
"span",
|
|
60
61
|
{
|
|
61
|
-
ref:
|
|
62
|
-
className:
|
|
62
|
+
ref: l,
|
|
63
|
+
className: o,
|
|
64
|
+
"data-malachite-skeleton-active": r ? "" : void 0,
|
|
63
65
|
"aria-busy": "true",
|
|
64
66
|
"aria-hidden": "true",
|
|
65
67
|
style: {
|
|
66
|
-
...
|
|
67
|
-
width:
|
|
68
|
-
height: a ??
|
|
69
|
-
minWidth:
|
|
68
|
+
...f,
|
|
69
|
+
width: n ? "100%" : t ?? 160,
|
|
70
|
+
height: a ?? T[e],
|
|
71
|
+
minWidth: i,
|
|
70
72
|
borderRadius: 6
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
);
|
|
74
76
|
}, I = ({
|
|
75
77
|
size: e = "default",
|
|
76
|
-
shape:
|
|
77
|
-
active:
|
|
78
|
-
className:
|
|
78
|
+
shape: n = "circle",
|
|
79
|
+
active: r = !0,
|
|
80
|
+
className: o
|
|
79
81
|
}) => {
|
|
80
82
|
const t = d(null);
|
|
81
|
-
|
|
83
|
+
u(t, m, "malachite-skeleton");
|
|
82
84
|
const a = typeof e == "number" ? e : b[e];
|
|
83
|
-
return /* @__PURE__ */
|
|
85
|
+
return /* @__PURE__ */ c(
|
|
84
86
|
"span",
|
|
85
87
|
{
|
|
86
88
|
ref: t,
|
|
87
|
-
className:
|
|
89
|
+
className: o,
|
|
90
|
+
"data-malachite-skeleton-active": r ? "" : void 0,
|
|
88
91
|
"aria-busy": "true",
|
|
89
92
|
"aria-hidden": "true",
|
|
90
93
|
style: {
|
|
91
|
-
...
|
|
94
|
+
...f,
|
|
92
95
|
width: a,
|
|
93
96
|
height: a,
|
|
94
|
-
borderRadius:
|
|
97
|
+
borderRadius: n === "circle" ? 9999 : 6
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
);
|
|
98
101
|
}, B = {
|
|
99
|
-
Button:
|
|
100
|
-
Input:
|
|
102
|
+
Button: v,
|
|
103
|
+
Input: y,
|
|
101
104
|
Avatar: I
|
|
102
105
|
};
|
|
103
106
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Skeleton.js","sources":["../../src/components/Skeleton.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { useAdoptedStyleSheet } from './useAdoptedStyleSheet';\n\ntype SkeletonSize = 'small' | 'default' | 'large';\ntype SkeletonShape = 'default' | 'round' | 'circle' | 'square';\n\ninterface BaseSkeletonProps {\n active?: boolean;\n className?: string;\n}\n\ninterface SkeletonButtonProps extends BaseSkeletonProps {\n size?: SkeletonSize;\n shape?: SkeletonShape;\n block?: boolean;\n width?: number | string;\n height?: number | string;\n minWidth?: number | string;\n}\n\ninterface SkeletonInputProps extends BaseSkeletonProps {\n size?: SkeletonSize;\n block?: boolean;\n width?: number | string;\n height?: number | string;\n minWidth?: number | string;\n}\n\ninterface SkeletonAvatarProps extends BaseSkeletonProps {\n size?: SkeletonSize | number;\n shape?: 'circle' | 'square';\n}\n\nconst BUTTON_HEIGHT: Record<SkeletonSize, number> = { small: 24, default: 32, large: 40 };\nconst BUTTON_WIDTH: Record<SkeletonSize, number> = { small: 64, default: 96, large: 128 };\nconst INPUT_HEIGHT: Record<SkeletonSize, number> = { small: 24, default: 32, large: 40 };\nconst AVATAR_SIZE: Record<SkeletonSize, number> = { small: 24, default: 32, large: 40 };\n\nconst KEYFRAME_NAME = 'malachite-skeleton-loading';\nconst SKELETON_BASE = 'rgba(190, 190, 190, 0.2)';\nconst SKELETON_SHIMMER = 'rgba(129, 129, 129, 0.24)';\nconst SKELETON_GRADIENT = `linear-gradient(90deg, ${SKELETON_BASE} 25%, ${SKELETON_SHIMMER} 37%, ${SKELETON_BASE} 63%)`;\nconst
|
|
1
|
+
{"version":3,"file":"Skeleton.js","sources":["../../src/components/Skeleton.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { useAdoptedStyleSheet } from './useAdoptedStyleSheet';\n\ntype SkeletonSize = 'small' | 'default' | 'large';\ntype SkeletonShape = 'default' | 'round' | 'circle' | 'square';\n\ninterface BaseSkeletonProps {\n active?: boolean;\n className?: string;\n}\n\ninterface SkeletonButtonProps extends BaseSkeletonProps {\n size?: SkeletonSize;\n shape?: SkeletonShape;\n block?: boolean;\n width?: number | string;\n height?: number | string;\n minWidth?: number | string;\n}\n\ninterface SkeletonInputProps extends BaseSkeletonProps {\n size?: SkeletonSize;\n block?: boolean;\n width?: number | string;\n height?: number | string;\n minWidth?: number | string;\n}\n\ninterface SkeletonAvatarProps extends BaseSkeletonProps {\n size?: SkeletonSize | number;\n shape?: 'circle' | 'square';\n}\n\nconst BUTTON_HEIGHT: Record<SkeletonSize, number> = { small: 24, default: 32, large: 40 };\nconst BUTTON_WIDTH: Record<SkeletonSize, number> = { small: 64, default: 96, large: 128 };\nconst INPUT_HEIGHT: Record<SkeletonSize, number> = { small: 24, default: 32, large: 40 };\nconst AVATAR_SIZE: Record<SkeletonSize, number> = { small: 24, default: 32, large: 40 };\n\nconst KEYFRAME_NAME = 'malachite-skeleton-loading';\nconst SKELETON_BASE = 'rgba(190, 190, 190, 0.2)';\nconst SKELETON_SHIMMER = 'rgba(129, 129, 129, 0.24)';\nconst SKELETON_GRADIENT = `linear-gradient(90deg, ${SKELETON_BASE} 25%, ${SKELETON_SHIMMER} 37%, ${SKELETON_BASE} 63%)`;\nconst ACTIVE_ATTR = 'data-malachite-skeleton-active';\n// The shimmer lives in the sheet, not inline, so the reduced-motion query can switch it off.\nconst SKELETON_CSS = `@keyframes ${KEYFRAME_NAME} { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }\n[${ACTIVE_ATTR}] { background-image: ${SKELETON_GRADIENT}; background-size: 400% 100%; animation: ${KEYFRAME_NAME} 1.4s ease infinite; }\n@media (prefers-reduced-motion: reduce) { [${ACTIVE_ATTR}] { animation: none; background-image: none; } }`;\n\nconst getRadius = (shape: SkeletonShape): string | number => {\n switch (shape) {\n case 'round':\n case 'circle':\n return 9999;\n case 'square':\n return 0;\n default:\n return 6;\n }\n};\n\nconst BASE_STYLE: React.CSSProperties = {\n display: 'inline-block',\n verticalAlign: 'middle',\n backgroundColor: SKELETON_BASE,\n flexShrink: 0,\n};\n\nconst SkeletonButton: React.FC<SkeletonButtonProps> = ({\n size = 'default',\n shape = 'default',\n block = false,\n active = true,\n className,\n width,\n height,\n minWidth,\n}) => {\n const ref = useRef<HTMLSpanElement>(null);\n useAdoptedStyleSheet(ref, SKELETON_CSS, 'malachite-skeleton');\n return (\n <span\n ref={ref}\n className={className}\n data-malachite-skeleton-active={active ? '' : undefined}\n aria-busy=\"true\"\n aria-hidden=\"true\"\n style={{\n ...BASE_STYLE,\n width: block ? '100%' : (width ?? BUTTON_WIDTH[size]),\n height: height ?? BUTTON_HEIGHT[size],\n minWidth,\n borderRadius: getRadius(shape),\n }}\n />\n );\n};\n\nconst SkeletonInput: React.FC<SkeletonInputProps> = ({\n size = 'default',\n block = false,\n active = true,\n className,\n width,\n height,\n minWidth,\n}) => {\n const ref = useRef<HTMLSpanElement>(null);\n useAdoptedStyleSheet(ref, SKELETON_CSS, 'malachite-skeleton');\n return (\n <span\n ref={ref}\n className={className}\n data-malachite-skeleton-active={active ? '' : undefined}\n aria-busy=\"true\"\n aria-hidden=\"true\"\n style={{\n ...BASE_STYLE,\n width: block ? '100%' : (width ?? 160),\n height: height ?? INPUT_HEIGHT[size],\n minWidth,\n borderRadius: 6,\n }}\n />\n );\n};\n\nconst SkeletonAvatar: React.FC<SkeletonAvatarProps> = ({\n size = 'default',\n shape = 'circle',\n active = true,\n className,\n}) => {\n const ref = useRef<HTMLSpanElement>(null);\n useAdoptedStyleSheet(ref, SKELETON_CSS, 'malachite-skeleton');\n const px = typeof size === 'number' ? size : AVATAR_SIZE[size];\n return (\n <span\n ref={ref}\n className={className}\n data-malachite-skeleton-active={active ? '' : undefined}\n aria-busy=\"true\"\n aria-hidden=\"true\"\n style={{\n ...BASE_STYLE,\n width: px,\n height: px,\n borderRadius: shape === 'circle' ? 9999 : 6,\n }}\n />\n );\n};\n\nconst Skeleton = {\n Button: SkeletonButton,\n Input: SkeletonInput,\n Avatar: SkeletonAvatar,\n};\n\nexport default Skeleton;\n"],"names":["BUTTON_HEIGHT","BUTTON_WIDTH","INPUT_HEIGHT","AVATAR_SIZE","KEYFRAME_NAME","SKELETON_BASE","SKELETON_SHIMMER","SKELETON_GRADIENT","ACTIVE_ATTR","SKELETON_CSS","getRadius","shape","BASE_STYLE","SkeletonButton","size","block","active","className","width","height","minWidth","ref","useRef","useAdoptedStyleSheet","jsx","SkeletonInput","SkeletonAvatar","px","Skeleton"],"mappings":";;;AAiCA,MAAMA,IAA8C,EAAE,OAAO,IAAI,SAAS,IAAI,OAAO,GAAA,GAC/EC,IAA6C,EAAE,OAAO,IAAI,SAAS,IAAI,OAAO,IAAA,GAC9EC,IAA6C,EAAE,OAAO,IAAI,SAAS,IAAI,OAAO,GAAA,GAC9EC,IAA4C,EAAE,OAAO,IAAI,SAAS,IAAI,OAAO,GAAA,GAE7EC,IAAgB,8BAChBC,IAAgB,4BAChBC,IAAmB,6BACnBC,IAAoB,0BAA0BF,CAAa,SAASC,CAAgB,SAASD,CAAa,SAC1GG,IAAc,kCAEdC,IAAe,cAAcL,CAAa;AAAA,GAC7CI,CAAW,yBAAyBD,CAAiB,4CAA4CH,CAAa;AAAA,6CACpEI,CAAW,oDAElDE,IAAY,CAACC,MAA0C;AACzD,UAAQA,GAAA;AAAA,IACJ,KAAK;AAAA,IACL,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB,G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,QAAQC,KAAUjB,EAAaY,CAAI;AAAA,QACnC,UAAAM;AAAA,QACA,cAAc;AAAA,MAAA;AAAA,IAClB;AAAA,EAAA;AAGZ,GAEMM,IAAgD,CAAC;AAAA,EACnD,MAAAZ,IAAO;AAAA,EACP,OAAAH,IAAQ;AAAA,EACR,QAAAK,IAAS;AAAA,EACT,WAAAC;AACJ,MAAM;AACF,QAAMI,IAAMC,EAAwB,IAAI;AACxC,EAAAC,EAAqBF,GAAKZ,GAAc,oBAAoB;AAC5D,QAAMkB,IAAK,OAAOb,KAAS,WAAWA,IAAOX,EAAYW,CAAI;AAC7D,SACI,gBAAAU;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,KAAAH;AAAA,MACA,WAAAJ;AAAA,MACA,kCAAgCD,IAAS,KAAK;AAAA,MAC9C,aAAU;AAAA,MACV,eAAY;AAAA,MACZ,OAAO;AAAA,QACH,GAAGJ;AAAA,QACH,OAAOe;AAAA,QACP,QAAQA;AAAA,QACR,cAAchB,MAAU,WAAW,OAAO;AAAA,MAAA;AAAA,IAC9C;AAAA,EAAA;AAGZ,GAEMiB,IAAW;AAAA,EACb,QAAQf;AAAA,EACR,OAAOY;AAAA,EACP,QAAQC;AACZ;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { getFontWeight as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { getFontWeight as c, getFontFamily as d, getFontSize as g, getTextColor as x } from "./textStyles.js";
|
|
3
|
+
const S = ({
|
|
4
4
|
underline: e = !1,
|
|
5
5
|
children: i,
|
|
6
6
|
color: l = "primary",
|
|
@@ -9,23 +9,24 @@ const u = ({
|
|
|
9
9
|
fontWeight: r = "normal",
|
|
10
10
|
tooltip: a,
|
|
11
11
|
textAlign: o,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
as: s = "span",
|
|
13
|
+
className: m = "",
|
|
14
|
+
style: f = {}
|
|
14
15
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
color:
|
|
17
|
-
fontSize:
|
|
16
|
+
const p = {
|
|
17
|
+
color: x(l),
|
|
18
|
+
fontSize: g(n),
|
|
18
19
|
// Left unset when not asked for, so Text keeps inheriting whatever the surrounding context…
|
|
19
|
-
fontFamily: t ?
|
|
20
|
-
fontWeight:
|
|
20
|
+
fontFamily: t ? d(t) : void 0,
|
|
21
|
+
fontWeight: c(r),
|
|
21
22
|
textAlign: o,
|
|
22
23
|
textDecoration: e ? "underline" : "none",
|
|
23
24
|
display: o ? "block" : void 0,
|
|
24
|
-
...
|
|
25
|
+
...f
|
|
25
26
|
};
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ y(s, { className: m, style: p, title: a, children: i });
|
|
27
28
|
};
|
|
28
29
|
export {
|
|
29
|
-
|
|
30
|
+
S as default
|
|
30
31
|
};
|
|
31
32
|
//# sourceMappingURL=Text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","sources":["../../../src/components/Typography/Text.tsx"],"sourcesContent":["import React from 'react';\nimport type { FontFamily, FontSize, FontWeight, TextColor } from './textStyles';\nimport { getFontFamily, getFontSize, getFontWeight, getTextColor } from './textStyles';\n\n// Types only: a value re-export would put the non-component exports back in this file.\nexport type { FontSize, FontFamily, FontWeight, TextColor } from './textStyles';\n\nexport interface TextProps {\n color?: TextColor;\n size?: FontSize;\n /**\n * Typeface. Defaults to `sans` (Inter), the library's body face. `heading` is Stack Sans\n * Text and `body` is Geist — both are loaded on mount and declared in the theme.\n */\n font?: FontFamily;\n underline?: boolean;\n fontWeight?: FontWeight;\n children: React.ReactNode;\n tooltip?: string;\n textAlign?: 'left' | 'center' | 'right' | 'justify';\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst Text: React.FC<TextProps> = ({\n underline = false,\n children,\n color = 'primary',\n size = 'small',\n font,\n fontWeight = 'normal',\n tooltip,\n textAlign,\n className = '',\n style = {},\n}) => {\n const textStyles: React.CSSProperties = {\n color: getTextColor(color),\n fontSize: getFontSize(size),\n // Left unset when not asked for, so Text keeps inheriting whatever the surrounding context…\n fontFamily: font ? getFontFamily(font) : undefined,\n fontWeight: getFontWeight(fontWeight),\n textAlign,\n textDecoration: underline ? 'underline' : 'none',\n display: textAlign ? 'block' : undefined,\n ...style,\n };\n\n return (\n <
|
|
1
|
+
{"version":3,"file":"Text.js","sources":["../../../src/components/Typography/Text.tsx"],"sourcesContent":["import React from 'react';\nimport type { FontFamily, FontSize, FontWeight, TextColor, TextElement } from './textStyles';\nimport { getFontFamily, getFontSize, getFontWeight, getTextColor } from './textStyles';\n\n// Types only: a value re-export would put the non-component exports back in this file.\nexport type { FontSize, FontFamily, FontWeight, TextColor, TextElement } from './textStyles';\n\nexport interface TextProps {\n color?: TextColor;\n size?: FontSize;\n /**\n * Typeface. Defaults to `sans` (Inter), the library's body face. `heading` is Stack Sans\n * Text and `body` is Geist — both are loaded on mount and declared in the theme.\n */\n font?: FontFamily;\n underline?: boolean;\n fontWeight?: FontWeight;\n children: React.ReactNode;\n tooltip?: string;\n textAlign?: 'left' | 'center' | 'right' | 'justify';\n /** The element it renders, for a heading or paragraph that keeps Text's look. */\n as?: TextElement;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst Text: React.FC<TextProps> = ({\n underline = false,\n children,\n color = 'primary',\n size = 'small',\n font,\n fontWeight = 'normal',\n tooltip,\n textAlign,\n as: Element = 'span',\n className = '',\n style = {},\n}) => {\n const textStyles: React.CSSProperties = {\n color: getTextColor(color),\n fontSize: getFontSize(size),\n // Left unset when not asked for, so Text keeps inheriting whatever the surrounding context…\n fontFamily: font ? getFontFamily(font) : undefined,\n fontWeight: getFontWeight(fontWeight),\n textAlign,\n textDecoration: underline ? 'underline' : 'none',\n display: textAlign ? 'block' : undefined,\n ...style,\n };\n\n return (\n <Element className={className} style={textStyles} title={tooltip}>\n {children}\n </Element>\n );\n};\n\nexport default Text;\n"],"names":["Text","underline","children","color","size","font","fontWeight","tooltip","textAlign","Element","className","style","textStyles","getTextColor","getFontSize","getFontFamily","getFontWeight"],"mappings":";;AA0BA,MAAMA,IAA4B,CAAC;AAAA,EAC/B,WAAAC,IAAY;AAAA,EACZ,UAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,MAAAC,IAAO;AAAA,EACP,MAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,IAAIC,IAAU;AAAA,EACd,WAAAC,IAAY;AAAA,EACZ,OAAAC,IAAQ,CAAA;AACZ,MAAM;AACF,QAAMC,IAAkC;AAAA,IACpC,OAAOC,EAAaV,CAAK;AAAA,IACzB,UAAUW,EAAYV,CAAI;AAAA;AAAA,IAE1B,YAAYC,IAAOU,EAAcV,CAAI,IAAI;AAAA,IACzC,YAAYW,EAAcV,CAAU;AAAA,IACpC,WAAAE;AAAA,IACA,gBAAgBP,IAAY,cAAc;AAAA,IAC1C,SAASO,IAAY,UAAU;AAAA,IAC/B,GAAGG;AAAA,EAAA;AAGP,2BACKF,GAAA,EAAQ,WAAAC,GAAsB,OAAOE,GAAY,OAAOL,GACpD,UAAAL,GACL;AAER;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Typography/index.tsx"],"sourcesContent":["import { default as CodeText } from './CodeText';\nimport { default as EllipsisText } from './EllipsisText';\nimport { default as FormSectionTitle } from './FormSectionTitle';\nimport { default as LinkText } from './LinkText';\nimport { default as MarkdownBlock } from './MarkdownBlock';\nimport { default as PageTitle } from './PageTitle';\nimport { default as SecondaryText } from './SecondaryText';\nimport { default as SectionTitle } from './SectionTitle';\nimport { default as StatisticLabel } from './StatisticLabel';\nimport { default as StatisticValue } from './StatisticValue';\nimport { default as TerminalText } from './TerminalText';\nimport { default as Text } from './Text';\n\nexport type { CodeTextProps, CodeTextVariant } from './CodeText';\nexport type { MarkdownLinks, MarkdownProps, MarkdownVariant } from './MarkdownBlock';\nexport type { FontSize, FontWeight, TextColor, TextProps } from './Text';\n\nexport const Typography = {\n CodeText,\n EllipsisText,\n FormSectionTitle,\n LinkText,\n MarkdownBlock,\n PageTitle,\n SecondaryText,\n SectionTitle,\n StatisticLabel,\n StatisticValue,\n TerminalText,\n Text,\n};\n\nexport default Typography;\n"],"names":["Typography","CodeText","EllipsisText","FormSectionTitle","LinkText","MarkdownBlock","PageTitle","SecondaryText","SectionTitle","StatisticLabel","StatisticValue","TerminalText","Text"],"mappings":";;;;;;;;;;;;AAiBO,MAAMA,IAAa;AAAA,EACtB,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,cAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,MAAAC;AACJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Typography/index.tsx"],"sourcesContent":["import { default as CodeText } from './CodeText';\nimport { default as EllipsisText } from './EllipsisText';\nimport { default as FormSectionTitle } from './FormSectionTitle';\nimport { default as LinkText } from './LinkText';\nimport { default as MarkdownBlock } from './MarkdownBlock';\nimport { default as PageTitle } from './PageTitle';\nimport { default as SecondaryText } from './SecondaryText';\nimport { default as SectionTitle } from './SectionTitle';\nimport { default as StatisticLabel } from './StatisticLabel';\nimport { default as StatisticValue } from './StatisticValue';\nimport { default as TerminalText } from './TerminalText';\nimport { default as Text } from './Text';\n\nexport type { CodeTextProps, CodeTextVariant } from './CodeText';\nexport type { MarkdownLinks, MarkdownProps, MarkdownVariant } from './MarkdownBlock';\nexport type { FontSize, FontWeight, TextColor, TextElement, TextProps } from './Text';\n\nexport const Typography = {\n CodeText,\n EllipsisText,\n FormSectionTitle,\n LinkText,\n MarkdownBlock,\n PageTitle,\n SecondaryText,\n SectionTitle,\n StatisticLabel,\n StatisticValue,\n TerminalText,\n Text,\n};\n\nexport default Typography;\n"],"names":["Typography","CodeText","EllipsisText","FormSectionTitle","LinkText","MarkdownBlock","PageTitle","SecondaryText","SectionTitle","StatisticLabel","StatisticValue","TerminalText","Text"],"mappings":";;;;;;;;;;;;AAiBO,MAAMA,IAAa;AAAA,EACtB,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,cAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,MAAAC;AACJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textStyles.js","sources":["../../../src/components/Typography/textStyles.ts"],"sourcesContent":["export type FontSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';\n/** Which theme typeface to render in. Defaults to the sans body face. */\nexport type FontFamily = 'sans' | 'heading' | 'body' | 'mono';\nexport type FontWeight = 'normal' | 'semi-bold' | 'bold';\nexport type TextColor =\n | 'primary'\n | 'secondary'\n | 'dimmed'\n | 'placeholder'\n | 'emphasis'\n | 'muted'\n | 'destructive'\n | 'success'\n | 'highlight'\n | 'warning'\n | 'error'\n | 'info'\n | 'link'\n /** Machine-authored text — what an assistant wrote, or what it is proposing. */\n | 'assistant'\n // Takes the surrounding colour instead of pinning a token.\n | 'inherit';\n\nexport const getTextColor = (color: TextColor): string => {\n switch (color) {\n case 'inherit':\n return 'inherit';\n case 'primary':\n // Chained so an ancestor (a selected Table row) can recolour text without setting…\n return 'var(--malachite-ctx-text-primary, var(--malachite-text-primary))';\n case 'assistant':\n return 'var(--malachite-assistant-foreground)';\n case 'secondary':\n return 'var(--malachite-text-secondary)';\n case 'dimmed':\n return 'var(--malachite-text-dimmed)';\n case 'placeholder':\n return 'var(--malachite-text-placeholder)';\n case 'emphasis':\n return 'var(--malachite-text-emphasis)';\n case 'muted':\n return 'var(--malachite-text-muted)';\n case 'destructive':\n return 'var(--malachite-text-destructive)';\n case 'success':\n return 'var(--malachite-text-success)';\n case 'highlight':\n return 'var(--malachite-text-highlight)';\n case 'warning':\n return 'var(--malachite-text-warning)';\n case 'error':\n return 'var(--malachite-text-error)';\n case 'info':\n return 'var(--malachite-text-info)';\n case 'link':\n return 'var(--malachite-text-link-foreground)';\n default:\n // Reachable from a non-TextColor argument (Alert passes an AlertType); keep it on the same…\n return 'var(--malachite-ctx-text-primary, var(--malachite-text-primary))';\n }\n};\n\n// Fallbacks only — the theme var wins, so overriding `fontSizes` moves Text with it. Text's\n// OWN scale: SecondaryText, CodeText and TerminalText each keep a different local getFontSize.\nconst FONT_SIZE_FALLBACKS: Record<FontSize, string> = {\n xsmall: '11px',\n small: '13px',\n medium: '14px',\n large: '16px',\n xlarge: '18px',\n xxlarge: '22px',\n};\n\nexport const getFontSize = (size: FontSize): string =>\n `var(--malachite-font-size-${size}, ${FONT_SIZE_FALLBACKS[size] ?? FONT_SIZE_FALLBACKS.small})`;\n\nconst FONT_FAMILY_VARS: Record<FontFamily, string> = {\n sans: 'var(--font-sans)',\n heading: 'var(--font-heading)',\n body: 'var(--font-body)',\n mono: 'var(--font-mono)',\n};\n\nexport const getFontFamily = (font: FontFamily): string => FONT_FAMILY_VARS[font];\n\nexport const getFontWeight = (weight: FontWeight): number => {\n switch (weight) {\n case 'normal':\n return 400;\n case 'semi-bold':\n return 500;\n case 'bold':\n return 600;\n default:\n return 400;\n }\n};\n\n"],"names":["getTextColor","color","FONT_SIZE_FALLBACKS","getFontSize","size","FONT_FAMILY_VARS","getFontFamily","font","getFontWeight","weight"],"mappings":"AAuBO,MAAMA,IAAe,CAACC,MAA6B;AACtD,UAAQA,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AAED,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX;AAEI,aAAO;AAAA,EAAA;AAEnB,GAIMC,IAAgD;AAAA,EAClD,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACb,GAEaC,IAAc,CAACC,MACxB,6BAA6BA,CAAI,KAAKF,EAAoBE,CAAI,KAAKF,EAAoB,KAAK,KAE1FG,IAA+C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AACV,GAEaC,IAAgB,CAACC,MAA6BF,EAAiBE,CAAI,GAEnEC,IAAgB,CAACC,MAA+B;AACzD,UAAQA,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB;"}
|
|
1
|
+
{"version":3,"file":"textStyles.js","sources":["../../../src/components/Typography/textStyles.ts"],"sourcesContent":["export type FontSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';\n/** Which theme typeface to render in. Defaults to the sans body face. */\nexport type FontFamily = 'sans' | 'heading' | 'body' | 'mono';\nexport type FontWeight = 'normal' | 'semi-bold' | 'bold';\nexport type TextColor =\n | 'primary'\n | 'secondary'\n | 'dimmed'\n | 'placeholder'\n | 'emphasis'\n | 'muted'\n | 'destructive'\n | 'success'\n | 'highlight'\n | 'warning'\n | 'error'\n | 'info'\n | 'link'\n /** Machine-authored text — what an assistant wrote, or what it is proposing. */\n | 'assistant'\n // Takes the surrounding colour instead of pinning a token.\n | 'inherit';\n\nexport const getTextColor = (color: TextColor): string => {\n switch (color) {\n case 'inherit':\n return 'inherit';\n case 'primary':\n // Chained so an ancestor (a selected Table row) can recolour text without setting…\n return 'var(--malachite-ctx-text-primary, var(--malachite-text-primary))';\n case 'assistant':\n return 'var(--malachite-assistant-foreground)';\n case 'secondary':\n return 'var(--malachite-text-secondary)';\n case 'dimmed':\n return 'var(--malachite-text-dimmed)';\n case 'placeholder':\n return 'var(--malachite-text-placeholder)';\n case 'emphasis':\n return 'var(--malachite-text-emphasis)';\n case 'muted':\n return 'var(--malachite-text-muted)';\n case 'destructive':\n return 'var(--malachite-text-destructive)';\n case 'success':\n return 'var(--malachite-text-success)';\n case 'highlight':\n return 'var(--malachite-text-highlight)';\n case 'warning':\n return 'var(--malachite-text-warning)';\n case 'error':\n return 'var(--malachite-text-error)';\n case 'info':\n return 'var(--malachite-text-info)';\n case 'link':\n return 'var(--malachite-text-link-foreground)';\n default:\n // Reachable from a non-TextColor argument (Alert passes an AlertType); keep it on the same…\n return 'var(--malachite-ctx-text-primary, var(--malachite-text-primary))';\n }\n};\n\n// Fallbacks only — the theme var wins, so overriding `fontSizes` moves Text with it. Text's\n// OWN scale: SecondaryText, CodeText and TerminalText each keep a different local getFontSize.\nconst FONT_SIZE_FALLBACKS: Record<FontSize, string> = {\n xsmall: '11px',\n small: '13px',\n medium: '14px',\n large: '16px',\n xlarge: '18px',\n xxlarge: '22px',\n};\n\nexport const getFontSize = (size: FontSize): string =>\n `var(--malachite-font-size-${size}, ${FONT_SIZE_FALLBACKS[size] ?? FONT_SIZE_FALLBACKS.small})`;\n\nconst FONT_FAMILY_VARS: Record<FontFamily, string> = {\n sans: 'var(--font-sans)',\n heading: 'var(--font-heading)',\n body: 'var(--font-body)',\n mono: 'var(--font-mono)',\n};\n\nexport const getFontFamily = (font: FontFamily): string => FONT_FAMILY_VARS[font];\n\nexport const getFontWeight = (weight: FontWeight): number => {\n switch (weight) {\n case 'normal':\n return 400;\n case 'semi-bold':\n return 500;\n case 'bold':\n return 600;\n default:\n return 400;\n }\n};\n\nexport type TextElement = 'span' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n"],"names":["getTextColor","color","FONT_SIZE_FALLBACKS","getFontSize","size","FONT_FAMILY_VARS","getFontFamily","font","getFontWeight","weight"],"mappings":"AAuBO,MAAMA,IAAe,CAACC,MAA6B;AACtD,UAAQA,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AAED,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX;AAEI,aAAO;AAAA,EAAA;AAEnB,GAIMC,IAAgD;AAAA,EAClD,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACb,GAEaC,IAAc,CAACC,MACxB,6BAA6BA,CAAI,KAAKF,EAAoBE,CAAI,KAAKF,EAAoB,KAAK,KAE1FG,IAA+C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AACV,GAEaC,IAAgB,CAACC,MAA6BF,EAAiBE,CAAI,GAEnEC,IAAgB,CAACC,MAA+B;AACzD,UAAQA,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EAAA;AAEnB;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,10 @@ declare interface AlertProps {
|
|
|
170
170
|
/** Replaces the type's status icon: an svg painting with `currentColor`, such as a CustomIcon,
|
|
171
171
|
* is drawn in the type's colour at the same size. */
|
|
172
172
|
icon?: default_2.ReactNode;
|
|
173
|
+
/** Makes its message a live region: `role="alert"` for error and warning, `status` otherwise.
|
|
174
|
+
* Screen readers reliably announce an `alert` as it mounts; a `status` is read when its
|
|
175
|
+
* `message` changes, so keep a live info or success alert mounted. Off by default. */
|
|
176
|
+
live?: boolean;
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
export declare type AlertType = 'info' | 'success' | 'error' | 'warning' | 'assistant';
|
|
@@ -4954,6 +4958,8 @@ export declare type TextColor = 'primary' | 'secondary' | 'dimmed' | 'placeholde
|
|
|
4954
4958
|
/** Machine-authored text — what an assistant wrote, or what it is proposing. */
|
|
4955
4959
|
| 'assistant' | 'inherit';
|
|
4956
4960
|
|
|
4961
|
+
export declare type TextElement = 'span' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
4962
|
+
|
|
4957
4963
|
export declare interface TextProps {
|
|
4958
4964
|
color?: TextColor;
|
|
4959
4965
|
size?: FontSize;
|
|
@@ -4967,6 +4973,8 @@ export declare interface TextProps {
|
|
|
4967
4973
|
children: default_2.ReactNode;
|
|
4968
4974
|
tooltip?: string;
|
|
4969
4975
|
textAlign?: 'left' | 'center' | 'right' | 'justify';
|
|
4976
|
+
/** The element it renders, for a heading or paragraph that keeps Text's look. */
|
|
4977
|
+
as?: TextElement;
|
|
4970
4978
|
className?: string;
|
|
4971
4979
|
style?: default_2.CSSProperties;
|
|
4972
4980
|
}
|
package/package.json
CHANGED