@mastra/playground-ui 51.1.0 → 51.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -0
- package/dist/Composer.css +1 -4
- package/dist/components/Comment.cjs.js +170 -0
- package/dist/components/Comment.cjs.js.map +1 -0
- package/dist/components/Comment.d.ts +2 -0
- package/dist/components/Comment.es.js +156 -0
- package/dist/components/Comment.es.js.map +1 -0
- package/dist/components/Composer.cjs.js +1 -1
- package/dist/components/Composer.cjs.js.map +1 -1
- package/dist/components/Composer.es.js +1 -1
- package/dist/components/Composer.es.js.map +1 -1
- package/dist/components/DataList.cjs.js +9 -9
- package/dist/components/DataList.cjs.js.map +1 -1
- package/dist/components/DataList.es.js +9 -9
- package/dist/components/DataList.es.js.map +1 -1
- package/dist/components/DateTimePicker.cjs.js +1 -1
- package/dist/components/DateTimePicker.es.js +1 -1
- package/dist/components/EnvironmentVariablesEditor.cjs.js +6 -6
- package/dist/components/EnvironmentVariablesEditor.cjs.js.map +1 -1
- package/dist/components/EnvironmentVariablesEditor.es.js +6 -6
- package/dist/components/EnvironmentVariablesEditor.es.js.map +1 -1
- package/dist/components/FormFieldBlocks.cjs.js +1 -1
- package/dist/components/FormFieldBlocks.es.js +1 -1
- package/dist/components/JSONSchemaForm.cjs.js +1 -1
- package/dist/components/JSONSchemaForm.es.js +1 -1
- package/dist/components/LogsDataList.cjs.js +2 -3
- package/dist/components/LogsDataList.cjs.js.map +1 -1
- package/dist/components/LogsDataList.es.js +2 -3
- package/dist/components/LogsDataList.es.js.map +1 -1
- package/dist/components/MainSidebar.cjs.js +1 -1
- package/dist/components/MainSidebar.cjs.js.map +1 -1
- package/dist/components/MainSidebar.es.js +1 -1
- package/dist/components/MainSidebar.es.js.map +1 -1
- package/dist/components/SettingsRow.cjs.js +35 -14
- package/dist/components/SettingsRow.cjs.js.map +1 -1
- package/dist/components/SettingsRow.es.js +35 -14
- package/dist/components/SettingsRow.es.js.map +1 -1
- package/dist/components/ai/tool-call.cjs.js +1 -1
- package/dist/components/ai/tool-call.cjs.js.map +1 -1
- package/dist/components/ai/tool-call.es.js +1 -1
- package/dist/components/ai/tool-call.es.js.map +1 -1
- package/dist/{data-list-CfsEAR2E.js → data-list-BOI8fRuk.js} +7 -9
- package/dist/data-list-BOI8fRuk.js.map +1 -0
- package/dist/{data-list-BK_lJxMN.cjs → data-list-CCacNODd.cjs} +7 -9
- package/dist/data-list-CCacNODd.cjs.map +1 -0
- package/dist/{data-list-skeleton-dVbplSiW.cjs → data-list-skeleton-BHBSIQHN.cjs} +8 -4
- package/dist/data-list-skeleton-BHBSIQHN.cjs.map +1 -0
- package/dist/{data-list-skeleton-DQp3KwVO.js → data-list-skeleton-DDO_OE14.js} +8 -4
- package/dist/data-list-skeleton-DDO_OE14.js.map +1 -0
- package/dist/{data-list-top-cell-DyBSefIr.cjs → data-list-top-cell-BOXO5s7I.cjs} +55 -104
- package/dist/data-list-top-cell-BOXO5s7I.cjs.map +1 -0
- package/dist/{data-list-top-cell-DZiX9cTb.js → data-list-top-cell-CC5jjv5s.js} +54 -104
- package/dist/data-list-top-cell-CC5jjv5s.js.map +1 -0
- package/dist/domains/logs/components/logs-list-view.cjs.js +2 -2
- package/dist/domains/logs/components/logs-list-view.es.js +2 -2
- package/dist/domains/metrics/components/memory-card-view.cjs.js +3 -3
- package/dist/domains/metrics/components/memory-card-view.cjs.js.map +1 -1
- package/dist/domains/metrics/components/memory-card-view.es.js +3 -3
- package/dist/domains/metrics/components/memory-card-view.es.js.map +1 -1
- package/dist/domains/metrics/components/model-usage-cost-card-view.cjs.js +2 -2
- package/dist/domains/metrics/components/model-usage-cost-card-view.cjs.js.map +1 -1
- package/dist/domains/metrics/components/model-usage-cost-card-view.es.js +2 -2
- package/dist/domains/metrics/components/model-usage-cost-card-view.es.js.map +1 -1
- package/dist/domains/metrics/components/scores-card-view.cjs.js +2 -2
- package/dist/domains/metrics/components/scores-card-view.cjs.js.map +1 -1
- package/dist/domains/metrics/components/scores-card-view.es.js +2 -2
- package/dist/domains/metrics/components/scores-card-view.es.js.map +1 -1
- package/dist/domains/traces/components/span-data-panel-view.cjs.js +1 -1
- package/dist/domains/traces/components/span-data-panel-view.cjs.js.map +1 -1
- package/dist/domains/traces/components/span-data-panel-view.es.js +1 -1
- package/dist/domains/traces/components/span-data-panel-view.es.js.map +1 -1
- package/dist/domains/traces/components/trace-data-panel-view.cjs.js +16 -5
- package/dist/domains/traces/components/trace-data-panel-view.cjs.js.map +1 -1
- package/dist/domains/traces/components/trace-data-panel-view.es.js +16 -5
- package/dist/domains/traces/components/trace-data-panel-view.es.js.map +1 -1
- package/dist/domains/traces/components/traces-list-view.cjs.js +4 -4
- package/dist/domains/traces/components/traces-list-view.cjs.js.map +1 -1
- package/dist/domains/traces/components/traces-list-view.es.js +4 -4
- package/dist/domains/traces/components/traces-list-view.es.js.map +1 -1
- package/dist/ee/topics/components/topic-trace-summary-list.cjs.js +1 -1
- package/dist/ee/topics/components/topic-trace-summary-list.es.js +1 -1
- package/dist/{logs-data-list-COfm0LbS.js → logs-data-list-DRXJ89IZ.js} +7 -7
- package/dist/logs-data-list-DRXJ89IZ.js.map +1 -0
- package/dist/{logs-data-list-CEPdgKxp.cjs → logs-data-list-Xayqbjw4.cjs} +7 -7
- package/dist/logs-data-list-Xayqbjw4.cjs.map +1 -0
- package/dist/metrics-kpi-card-AhIw9eyu.js.map +1 -1
- package/dist/metrics-kpi-card-tAReOFYk.cjs.map +1 -1
- package/dist/src/domains/traces/components/trace-data-panel-view.d.ts +11 -2
- package/dist/src/ds/components/Comment/comment-composer.d.ts +12 -0
- package/dist/src/ds/components/Comment/comment-context.d.ts +3 -0
- package/dist/src/ds/components/Comment/comment.d.ts +21 -0
- package/dist/src/ds/components/Comment/comment.stories.d.ts +10 -0
- package/dist/src/ds/components/Comment/index.d.ts +5 -0
- package/dist/src/ds/components/DataList/data-list-cells.d.ts +16 -18
- package/dist/src/ds/components/DataList/data-list-root.d.ts +6 -7
- package/dist/src/ds/components/DataList/data-list-row-link.d.ts +1 -1
- package/dist/src/ds/components/DataList/data-list-row-wrapper.d.ts +2 -2
- package/dist/src/ds/components/DataList/data-list.d.ts +2 -2
- package/dist/src/ds/components/DataList/data-list.stories.d.ts +1 -1
- package/dist/src/ds/components/DataList/shared.d.ts +18 -18
- package/dist/src/ds/components/MetricsKpiCard/metrics-kpi-card-value.d.ts +2 -1
- package/dist/src/ds/components/SettingsRow/settings-row.d.ts +8 -3
- package/dist/src/ds/components/SettingsRow/settings-row.stories.d.ts +1 -0
- package/dist/style.css +67 -232
- package/dist/{text-field-block-BGlwSFYC.cjs → text-field-block-B4CvIwKh.cjs} +2 -1
- package/dist/text-field-block-B4CvIwKh.cjs.map +1 -0
- package/dist/{text-field-block-DOiM0dpY.js → text-field-block-Ddl2tJ6D.js} +2 -1
- package/dist/{text-field-block-DOiM0dpY.js.map → text-field-block-Ddl2tJ6D.js.map} +1 -1
- package/dist/{traces-data-list-CyaLRi1n.cjs → traces-data-list-BLZgf-Es.cjs} +7 -7
- package/dist/traces-data-list-BLZgf-Es.cjs.map +1 -0
- package/dist/{traces-data-list-BURMAmFH.js → traces-data-list-DmXGwe4Q.js} +7 -7
- package/dist/traces-data-list-DmXGwe4Q.js.map +1 -0
- package/package.json +7 -7
- package/theme.css +7 -0
- package/dist/data-list-BK_lJxMN.cjs.map +0 -1
- package/dist/data-list-CfsEAR2E.js.map +0 -1
- package/dist/data-list-skeleton-DQp3KwVO.js.map +0 -1
- package/dist/data-list-skeleton-dVbplSiW.cjs.map +0 -1
- package/dist/data-list-top-cell-DZiX9cTb.js.map +0 -1
- package/dist/data-list-top-cell-DyBSefIr.cjs.map +0 -1
- package/dist/logs-data-list-CEPdgKxp.cjs.map +0 -1
- package/dist/logs-data-list-COfm0LbS.js.map +0 -1
- package/dist/text-field-block-BGlwSFYC.cjs.map +0 -1
- package/dist/traces-data-list-BURMAmFH.js.map +0 -1
- package/dist/traces-data-list-CyaLRi1n.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
# @mastra/playground-ui
|
|
2
2
|
|
|
3
|
+
## 51.2.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Composer** — the ring keeps its geometry on the element, so a consumer can restyle its radius and width through `className` like any other component. Its idle edge colour now reads `--composer-ring-edge`, for apps whose chat surface needs a different one; unset, it keeps the current blend. ([#22403](https://github.com/mastra-ai/mastra/pull/22403))
|
|
8
|
+
|
|
9
|
+
**Tool call** — output blocks sit one step above the surface behind them instead of painting a fixed dark grey, so they stay visible on any chat background and in both themes.
|
|
10
|
+
|
|
11
|
+
- Sidebar links read a touch heavier, so they stay legible next to their icons instead of looking washed out. ([#22399](https://github.com/mastra-ai/mastra/pull/22399))
|
|
12
|
+
|
|
13
|
+
- Fixed the span Feedback tab in Studio's observability view showing the same list and count for every span of a trace: it now loads feedback strictly for the selected trace and span pair, so switching spans shows that span's own feedback. Trace-level feedback — including everything produced by the dataset review flows — now lives in a new Feedback tab on the trace panel, next to Details and Evaluations, which lists only records that aren't attached to a span. The span panel tabs also use the same pill styling as the rest of Studio instead of the deprecated underline variant. ([#22401](https://github.com/mastra-ai/mastra/pull/22401))
|
|
14
|
+
|
|
15
|
+
To see each kind of feedback:
|
|
16
|
+
|
|
17
|
+
1. Run `mastra dev` and open **Observability** in Studio.
|
|
18
|
+
2. Open a trace and select its **Feedback** tab — it lists trace-level feedback only, such as records left by dataset review.
|
|
19
|
+
3. Select a span in the trace tree and open the span's **Feedback** tab — it lists only that span's feedback, and the list changes as you select other spans.
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`7677a2c`](https://github.com/mastra-ai/mastra/commit/7677a2cd47729221ca28afc5067d26e22d925b59), [`f7a7467`](https://github.com/mastra-ai/mastra/commit/f7a74678193921e7ea4790232d707b3237626cac), [`f9c56f3`](https://github.com/mastra-ai/mastra/commit/f9c56f336ee8c250763a438990f8e60a428353c9)]:
|
|
22
|
+
- @mastra/core@1.63.0-alpha.1
|
|
23
|
+
- @mastra/client-js@1.42.2-alpha.1
|
|
24
|
+
- @mastra/react@1.4.7-alpha.1
|
|
25
|
+
|
|
26
|
+
## 51.2.0-alpha.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- Refreshed the DataList look: rows no longer draw separators, the sticky header and group subheaders share one lighter, theme-tuned band, and every corner uses the same radius. ([#22383](https://github.com/mastra-ai/mastra/pull/22383))
|
|
31
|
+
|
|
32
|
+
**Every row in a list is now the same height.** Row height used to be whatever the tallest cell happened to be, so a list with an actions column or a roomier cell drifted a few pixels away from the list next to it. The row owns its height now, and skeleton rows match the real ones — no jump when data lands.
|
|
33
|
+
|
|
34
|
+
**Typography follows the content.** Headers and name cells are medium weight instead of semibold, and the letter-spacing tightening is gone. IDs and timestamps left the monospace face — IDs get wider tracking to stay scannable, timestamps get tabular figures so their columns still line up.
|
|
35
|
+
|
|
36
|
+
**Row controls only appear on hover.** Selection checkboxes on unselected rows, and the new `DataList.ActionsCell`, stay hidden until you hover the row or reach it with the keyboard, so a resting list reads as content. The column keeps its width, so nothing shifts. On a touch screen, where nothing ever hovers, they stay visible.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
// Trailing row actions — alignment, spacing and the hover reveal come with the cell
|
|
40
|
+
<DataList.RowWrapper>
|
|
41
|
+
<DataList.RowButton colEnd={-2} onClick={open}>
|
|
42
|
+
{cells}
|
|
43
|
+
</DataList.RowButton>
|
|
44
|
+
<DataList.ActionsCell>
|
|
45
|
+
<Button variant="ghost" size="icon-xs" aria-label="Delete">
|
|
46
|
+
<Trash2 />
|
|
47
|
+
</Button>
|
|
48
|
+
</DataList.ActionsCell>
|
|
49
|
+
</DataList.RowWrapper>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Breaking:** a variant, three props and a component that no longer decide anything are gone.
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
// Before
|
|
56
|
+
<DataList columns={columns} variant="lined">
|
|
57
|
+
<DataList.RowButton flushLeft flushRight colEnd={-2}>
|
|
58
|
+
<DataList.Cell height="compact">{status}</DataList.Cell>
|
|
59
|
+
<DataList.MonoCell>{path}</DataList.MonoCell>
|
|
60
|
+
|
|
61
|
+
// After — rows are borderless, full-bleed and uniformly tall by default
|
|
62
|
+
<DataList columns={columns}>
|
|
63
|
+
<DataList.RowButton colEnd={-2}>
|
|
64
|
+
<DataList.Cell>{status}</DataList.Cell>
|
|
65
|
+
<DataList.TextCell font="mono">{path}</DataList.TextCell>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- `variant="lined"` existed only to draw row separators. Lists that want row banding can still ask for `variant="striped"`.
|
|
69
|
+
- `height` on cells set row height one cell at a time, which is what let rows drift apart.
|
|
70
|
+
- `flushLeft` / `flushRight` dropped a row margin that no longer exists.
|
|
71
|
+
- `DataList.MonoCell` was a cell that only changed the typeface. `DataList.TextCell font="mono"` replaces it — same rendering, one less component.
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Added a `Comment` family of compound components for text-only comment threads: `Comment`, `CommentList`, `CommentItem` (with header, author, timestamp, body and actions slots) and `CommentComposer` (input + send button). The root `variant` prop switches between `default`, a flat thread with hover-revealed per-item actions, and `embed`, the same thread on a bordered card surface with a compact composer and no per-item actions. ([#22396](https://github.com/mastra-ai/mastra/pull/22396))
|
|
76
|
+
|
|
77
|
+
- Improved the experiment page in Studio with a horizontal metadata bar showing when the run started, how long it took, the dataset it ran against, and which scorers were used ([#22377](https://github.com/mastra-ai/mastra/pull/22377))
|
|
78
|
+
|
|
79
|
+
- Added a `factory` variant to the `SettingsRow` component so settings rows can render the denser card-row layout (row padding, 12px description text) instead of only the studio spacing. ([#22375](https://github.com/mastra-ai/mastra/pull/22375))
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<SettingsRow variant="factory" label="Auto-approve tools" description="Run tool calls without asking">
|
|
83
|
+
<Switch checked={autoApprove} onCheckedChange={setAutoApprove} />
|
|
84
|
+
</SettingsRow>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- Updated dependencies [[`7176362`](https://github.com/mastra-ai/mastra/commit/717636281a3339911a05ea2cc8ae38afe4fd2cef), [`e3b796d`](https://github.com/mastra-ai/mastra/commit/e3b796d29a63f0d5c97dd815aadec40687346d70), [`49ccd14`](https://github.com/mastra-ai/mastra/commit/49ccd142268a61fb55ea75bc76287643a21f3677), [`3855b38`](https://github.com/mastra-ai/mastra/commit/3855b38c4c25af32ab8e298e148becc963abe92c)]:
|
|
88
|
+
- @mastra/core@1.63.0-alpha.0
|
|
89
|
+
- @mastra/client-js@1.42.2-alpha.0
|
|
90
|
+
- @mastra/react@1.4.7-alpha.0
|
|
91
|
+
|
|
3
92
|
## 51.1.0
|
|
4
93
|
|
|
5
94
|
### Minor Changes
|
package/dist/Composer.css
CHANGED
|
@@ -23,10 +23,7 @@
|
|
|
23
23
|
.composer-ring {
|
|
24
24
|
--composer-ring-color: var(--accent1);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
border-radius: 23px;
|
|
28
|
-
padding: 1px;
|
|
29
|
-
background-color: color-mix(in oklab, var(--border2) 40%, transparent);
|
|
26
|
+
background-color: var(--composer-ring-edge, color-mix(in oklab, var(--border2) 40%, transparent));
|
|
30
27
|
background-image: conic-gradient(
|
|
31
28
|
from calc(var(--composer-ring-angle) + var(--composer-ring-spin) - 60deg),
|
|
32
29
|
transparent 0deg,
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
const index = require('../index-C-Lt4Bx_.cjs');
|
|
7
|
+
const React = require('react');
|
|
8
|
+
const Txt = require('../Txt-I5lK8zy7.cjs');
|
|
9
|
+
const utils_cn = require('../cn-vA5sWo9W.cjs');
|
|
10
|
+
const lucideReact = require('lucide-react');
|
|
11
|
+
const inputGroup = require('../input-group-4EQi2l7H.cjs');
|
|
12
|
+
|
|
13
|
+
const CommentContext = React.createContext(null);
|
|
14
|
+
function useCommentVariant() {
|
|
15
|
+
const variant = React.useContext(CommentContext);
|
|
16
|
+
if (!variant) throw new Error("Comment compounds must be rendered within Comment");
|
|
17
|
+
return variant;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const commentVariants = index.cva("flex flex-col", {
|
|
21
|
+
variants: {
|
|
22
|
+
variant: {
|
|
23
|
+
default: "gap-2",
|
|
24
|
+
embed: "gap-1 rounded-xl border border-border1 bg-surface3 p-3"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
variant: "default"
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const Comment = React.forwardRef(({ className, variant = "default", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(CommentContext.Provider, { value: variant, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
ref,
|
|
35
|
+
"data-slot": "comment",
|
|
36
|
+
"data-variant": variant,
|
|
37
|
+
className: utils_cn.cn(commentVariants({ variant }), className),
|
|
38
|
+
...props
|
|
39
|
+
}
|
|
40
|
+
) }));
|
|
41
|
+
Comment.displayName = "Comment";
|
|
42
|
+
const commentListGap = {
|
|
43
|
+
default: "gap-3",
|
|
44
|
+
embed: "gap-2"
|
|
45
|
+
};
|
|
46
|
+
const CommentList = React.forwardRef(({ className, ...props }, ref) => {
|
|
47
|
+
const variant = useCommentVariant();
|
|
48
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
49
|
+
"ul",
|
|
50
|
+
{
|
|
51
|
+
ref,
|
|
52
|
+
"data-slot": "comment-list",
|
|
53
|
+
className: utils_cn.cn("flex flex-col", commentListGap[variant], className),
|
|
54
|
+
...props
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
CommentList.displayName = "CommentList";
|
|
59
|
+
const CommentItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
60
|
+
"li",
|
|
61
|
+
{
|
|
62
|
+
ref,
|
|
63
|
+
"data-slot": "comment-item",
|
|
64
|
+
className: utils_cn.cn("group/comment-item flex flex-col gap-1", className),
|
|
65
|
+
...props
|
|
66
|
+
}
|
|
67
|
+
));
|
|
68
|
+
CommentItem.displayName = "CommentItem";
|
|
69
|
+
const CommentItemHeader = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-slot": "comment-item-header", className: utils_cn.cn("flex items-center gap-2", className), ...props }));
|
|
70
|
+
CommentItemHeader.displayName = "CommentItemHeader";
|
|
71
|
+
const CommentItemAuthor = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
72
|
+
Txt.Txt,
|
|
73
|
+
{
|
|
74
|
+
ref,
|
|
75
|
+
as: "span",
|
|
76
|
+
variant: "ui-md",
|
|
77
|
+
"data-slot": "comment-item-author",
|
|
78
|
+
className: utils_cn.cn("font-medium text-neutral6", className),
|
|
79
|
+
...props
|
|
80
|
+
}
|
|
81
|
+
));
|
|
82
|
+
CommentItemAuthor.displayName = "CommentItemAuthor";
|
|
83
|
+
const CommentItemTimestamp = React.forwardRef(
|
|
84
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
85
|
+
"time",
|
|
86
|
+
{
|
|
87
|
+
ref,
|
|
88
|
+
"data-slot": "comment-item-timestamp",
|
|
89
|
+
className: utils_cn.cn("text-ui-sm leading-ui-sm text-neutral3", className),
|
|
90
|
+
...props
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
CommentItemTimestamp.displayName = "CommentItemTimestamp";
|
|
95
|
+
const commentItemBodyRule = {
|
|
96
|
+
default: "border-l border-border1 pl-3",
|
|
97
|
+
embed: ""
|
|
98
|
+
};
|
|
99
|
+
const CommentItemBody = React.forwardRef(({ className, ...props }, ref) => {
|
|
100
|
+
const variant = useCommentVariant();
|
|
101
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
102
|
+
Txt.Txt,
|
|
103
|
+
{
|
|
104
|
+
ref,
|
|
105
|
+
variant: "ui-md",
|
|
106
|
+
"data-slot": "comment-item-body",
|
|
107
|
+
className: utils_cn.cn("whitespace-pre-wrap text-neutral6", commentItemBodyRule[variant], className),
|
|
108
|
+
...props
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
CommentItemBody.displayName = "CommentItemBody";
|
|
113
|
+
const CommentItemActions = React.forwardRef(
|
|
114
|
+
({ className, ...props }, ref) => {
|
|
115
|
+
const variant = useCommentVariant();
|
|
116
|
+
if (variant === "embed") return null;
|
|
117
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
118
|
+
"div",
|
|
119
|
+
{
|
|
120
|
+
ref,
|
|
121
|
+
"data-slot": "comment-item-actions",
|
|
122
|
+
className: utils_cn.cn(
|
|
123
|
+
"flex items-center gap-1 opacity-0 group-focus-within/comment-item:opacity-100 group-hover/comment-item:opacity-100",
|
|
124
|
+
"motion-safe:transition-opacity",
|
|
125
|
+
className
|
|
126
|
+
),
|
|
127
|
+
...props
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
CommentItemActions.displayName = "CommentItemActions";
|
|
133
|
+
|
|
134
|
+
const CommentComposer = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("form", { ref, "data-slot": "comment-composer", className: utils_cn.cn("flex w-full items-center gap-2", className), ...props }));
|
|
135
|
+
CommentComposer.displayName = "CommentComposer";
|
|
136
|
+
const composerSize = {
|
|
137
|
+
default: "md",
|
|
138
|
+
embed: "sm"
|
|
139
|
+
};
|
|
140
|
+
const composerInputVariant = {
|
|
141
|
+
default: "outline",
|
|
142
|
+
embed: "default"
|
|
143
|
+
};
|
|
144
|
+
const CommentComposerInput = React.forwardRef(
|
|
145
|
+
({ groupClassName, children, ...props }, ref) => {
|
|
146
|
+
const variant = useCommentVariant();
|
|
147
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(inputGroup.InputGroup, { size: composerSize[variant], variant: composerInputVariant[variant], className: groupClassName, children: [
|
|
148
|
+
/* @__PURE__ */ jsxRuntime.jsx(inputGroup.InputGroupInput, { ref, "data-slot": "comment-composer-input", ...props }),
|
|
149
|
+
children
|
|
150
|
+
] });
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
CommentComposerInput.displayName = "CommentComposerInput";
|
|
154
|
+
const CommentComposerSend = React.forwardRef(
|
|
155
|
+
({ "aria-label": ariaLabel = "Send comment", type = "submit", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(inputGroup.InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsxRuntime.jsx(inputGroup.InputGroupButton, { ref, "data-slot": "comment-composer-send", type, "aria-label": ariaLabel, ...props, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, {}) }) })
|
|
156
|
+
);
|
|
157
|
+
CommentComposerSend.displayName = "CommentComposerSend";
|
|
158
|
+
|
|
159
|
+
exports.Comment = Comment;
|
|
160
|
+
exports.CommentComposer = CommentComposer;
|
|
161
|
+
exports.CommentComposerInput = CommentComposerInput;
|
|
162
|
+
exports.CommentComposerSend = CommentComposerSend;
|
|
163
|
+
exports.CommentItem = CommentItem;
|
|
164
|
+
exports.CommentItemActions = CommentItemActions;
|
|
165
|
+
exports.CommentItemAuthor = CommentItemAuthor;
|
|
166
|
+
exports.CommentItemBody = CommentItemBody;
|
|
167
|
+
exports.CommentItemHeader = CommentItemHeader;
|
|
168
|
+
exports.CommentItemTimestamp = CommentItemTimestamp;
|
|
169
|
+
exports.CommentList = CommentList;
|
|
170
|
+
//# sourceMappingURL=Comment.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Comment.cjs.js","sources":["../../src/ds/components/Comment/comment-context.ts","../../src/ds/components/Comment/comment.tsx","../../src/ds/components/Comment/comment-composer.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nexport type CommentVariant = 'default' | 'embed';\n\nexport const CommentContext = createContext<CommentVariant | null>(null);\n\nexport function useCommentVariant(): CommentVariant {\n const variant = useContext(CommentContext);\n if (!variant) throw new Error('Comment compounds must be rendered within Comment');\n return variant;\n}\n","import { cva } from 'class-variance-authority';\nimport type { ComponentPropsWithoutRef } from 'react';\nimport { forwardRef } from 'react';\n\nimport { CommentContext, useCommentVariant } from './comment-context';\nimport type { CommentVariant } from './comment-context';\nimport { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nconst commentVariants = cva('flex flex-col', {\n variants: {\n variant: {\n default: 'gap-2',\n embed: 'gap-1 rounded-xl border border-border1 bg-surface3 p-3',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\nexport interface CommentProps extends ComponentPropsWithoutRef<'div'> {\n variant?: CommentVariant;\n}\n\nexport const Comment = forwardRef<HTMLDivElement, CommentProps>(({ className, variant = 'default', ...props }, ref) => (\n <CommentContext.Provider value={variant}>\n <div\n ref={ref}\n data-slot=\"comment\"\n data-variant={variant}\n className={cn(commentVariants({ variant }), className)}\n {...props}\n />\n </CommentContext.Provider>\n));\nComment.displayName = 'Comment';\n\nconst commentListGap: Record<CommentVariant, string> = {\n default: 'gap-3',\n embed: 'gap-2',\n};\n\nexport type CommentListProps = ComponentPropsWithoutRef<'ul'>;\n\nexport const CommentList = forwardRef<HTMLUListElement, CommentListProps>(({ className, ...props }, ref) => {\n const variant = useCommentVariant();\n\n return (\n <ul\n ref={ref}\n data-slot=\"comment-list\"\n className={cn('flex flex-col', commentListGap[variant], className)}\n {...props}\n />\n );\n});\nCommentList.displayName = 'CommentList';\n\nexport type CommentItemProps = ComponentPropsWithoutRef<'li'>;\n\nexport const CommentItem = forwardRef<HTMLLIElement, CommentItemProps>(({ className, ...props }, ref) => (\n <li\n ref={ref}\n data-slot=\"comment-item\"\n className={cn('group/comment-item flex flex-col gap-1', className)}\n {...props}\n />\n));\nCommentItem.displayName = 'CommentItem';\n\nexport type CommentItemHeaderProps = ComponentPropsWithoutRef<'div'>;\n\nexport const CommentItemHeader = forwardRef<HTMLDivElement, CommentItemHeaderProps>(({ className, ...props }, ref) => (\n <div ref={ref} data-slot=\"comment-item-header\" className={cn('flex items-center gap-2', className)} {...props} />\n));\nCommentItemHeader.displayName = 'CommentItemHeader';\n\nexport type CommentItemAuthorProps = ComponentPropsWithoutRef<'span'>;\n\nexport const CommentItemAuthor = forwardRef<HTMLElement, CommentItemAuthorProps>(({ className, ...props }, ref) => (\n <Txt\n ref={ref}\n as=\"span\"\n variant=\"ui-md\"\n data-slot=\"comment-item-author\"\n className={cn('font-medium text-neutral6', className)}\n {...props}\n />\n));\nCommentItemAuthor.displayName = 'CommentItemAuthor';\n\nexport type CommentItemTimestampProps = ComponentPropsWithoutRef<'time'>;\n\nexport const CommentItemTimestamp = forwardRef<HTMLTimeElement, CommentItemTimestampProps>(\n ({ className, ...props }, ref) => (\n <time\n ref={ref}\n data-slot=\"comment-item-timestamp\"\n className={cn('text-ui-sm leading-ui-sm text-neutral3', className)}\n {...props}\n />\n ),\n);\nCommentItemTimestamp.displayName = 'CommentItemTimestamp';\n\nconst commentItemBodyRule: Record<CommentVariant, string> = {\n default: 'border-l border-border1 pl-3',\n embed: '',\n};\n\nexport type CommentItemBodyProps = ComponentPropsWithoutRef<'p'>;\n\nexport const CommentItemBody = forwardRef<HTMLElement, CommentItemBodyProps>(({ className, ...props }, ref) => {\n const variant = useCommentVariant();\n\n return (\n <Txt\n ref={ref}\n variant=\"ui-md\"\n data-slot=\"comment-item-body\"\n className={cn('whitespace-pre-wrap text-neutral6', commentItemBodyRule[variant], className)}\n {...props}\n />\n );\n});\nCommentItemBody.displayName = 'CommentItemBody';\n\nexport type CommentItemActionsProps = ComponentPropsWithoutRef<'div'>;\n\n/** Hidden in the `embed` variant, which drops per-item actions. */\nexport const CommentItemActions = forwardRef<HTMLDivElement, CommentItemActionsProps>(\n ({ className, ...props }, ref) => {\n const variant = useCommentVariant();\n if (variant === 'embed') return null;\n\n return (\n <div\n ref={ref}\n data-slot=\"comment-item-actions\"\n className={cn(\n 'flex items-center gap-1 opacity-0 group-focus-within/comment-item:opacity-100 group-hover/comment-item:opacity-100',\n 'motion-safe:transition-opacity',\n className,\n )}\n {...props}\n />\n );\n },\n);\nCommentItemActions.displayName = 'CommentItemActions';\n","import { ArrowUp } from 'lucide-react';\nimport type { ComponentPropsWithoutRef, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { useCommentVariant } from './comment-context';\nimport type { CommentVariant } from './comment-context';\nimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@/ds/components/InputGroup';\nimport type { InputGroupButtonProps, InputGroupInputProps } from '@/ds/components/InputGroup';\nimport type { ControlSize } from '@/ds/primitives/control-size';\nimport { cn } from '@/lib/utils';\n\nexport type CommentComposerProps = ComponentPropsWithoutRef<'form'>;\n\nexport const CommentComposer = forwardRef<HTMLFormElement, CommentComposerProps>(({ className, ...props }, ref) => (\n <form ref={ref} data-slot=\"comment-composer\" className={cn('flex w-full items-center gap-2', className)} {...props} />\n));\nCommentComposer.displayName = 'CommentComposer';\n\nconst composerSize: Record<CommentVariant, ControlSize> = {\n default: 'md',\n embed: 'sm',\n};\n\nconst composerInputVariant: Record<CommentVariant, 'default' | 'outline'> = {\n default: 'outline',\n embed: 'default',\n};\n\nexport interface CommentComposerInputProps extends InputGroupInputProps {\n /** Layout classes for the surrounding InputGroup. */\n groupClassName?: string;\n children?: ReactNode;\n}\n\nexport const CommentComposerInput = forwardRef<HTMLInputElement, CommentComposerInputProps>(\n ({ groupClassName, children, ...props }, ref) => {\n const variant = useCommentVariant();\n\n return (\n <InputGroup size={composerSize[variant]} variant={composerInputVariant[variant]} className={groupClassName}>\n <InputGroupInput ref={ref} data-slot=\"comment-composer-input\" {...props} />\n {children}\n </InputGroup>\n );\n },\n);\nCommentComposerInput.displayName = 'CommentComposerInput';\n\nexport type CommentComposerSendProps = Omit<InputGroupButtonProps, 'children'>;\n\nexport const CommentComposerSend = forwardRef<HTMLButtonElement, CommentComposerSendProps>(\n ({ 'aria-label': ariaLabel = 'Send comment', type = 'submit', ...props }, ref) => (\n <InputGroupAddon align=\"inline-end\">\n <InputGroupButton ref={ref} data-slot=\"comment-composer-send\" type={type} aria-label={ariaLabel} {...props}>\n <ArrowUp />\n </InputGroupButton>\n </InputGroupAddon>\n ),\n);\nCommentComposerSend.displayName = 'CommentComposerSend';\n"],"names":["createContext","useContext","cva","forwardRef","jsx","cn","Txt","jsxs","InputGroup","InputGroupInput","InputGroupAddon","InputGroupButton","ArrowUp"],"mappings":";;;;;;;;;;;;AAIO,MAAM,cAAA,GAAiBA,oBAAqC,IAAI,CAAA;AAEhE,SAAS,iBAAA,GAAoC;AAClD,EAAA,MAAM,OAAA,GAAUC,iBAAW,cAAc,CAAA;AACzC,EAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,mDAAmD,CAAA;AACjF,EAAA,OAAO,OAAA;AACT;;ACDA,MAAM,eAAA,GAAkBC,UAAI,eAAA,EAAiB;AAAA,EAC3C,QAAA,EAAU;AAAA,IACR,OAAA,EAAS;AAAA,MACP,OAAA,EAAS,OAAA;AAAA,MACT,KAAA,EAAO;AAAA;AACT,GACF;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,OAAA,EAAS;AAAA;AAEb,CAAC,CAAA;AAMM,MAAM,UAAUC,gBAAA,CAAyC,CAAC,EAAE,SAAA,EAAW,UAAU,SAAA,EAAW,GAAG,KAAA,EAAM,EAAG,wBAC7GC,cAAA,CAAC,cAAA,CAAe,QAAA,EAAf,EA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A,EAAS,oBAAA,CAAqB,OAAO,CAAA,EAAG,SAAA,EAAW,cAAA,EAC1F,QAAA,EAAA;AAAA,sBAAAJ,cAAA,CAACK,0BAAA,EAAA,EAAgB,GAAA,EAAU,WAAA,EAAU,wBAAA,EAA0B,GAAG,KAAA,EAAO,CAAA;AAAA,MACxE;AAAA,KAAA,EACH,CAAA;AAAA,EAEJ;AACF;AACA,oBAAA,CAAqB,WAAA,GAAc,sBAAA;AAI5B,MAAM,mBAAA,GAAsBN,gBAAA;AAAA,EACjC,CAAC,EAAE,YAAA,EAAc,SAAA,GAAY,cAAA,EAAgB,IAAA,GAAO,QAAA,EAAU,GAAG,KAAA,EAAM,EAAG,GAAA,qBACxEC,cAAA,CAACM,0BAAA,EAAA,EAAgB,KAAA,EAAM,YAAA,EACrB,QAAA,kBAAAN,cAAA,CAACO,2BAAA,EAAA,EAAiB,GAAA,EAAU,WAAA,EAAU,uBAAA,EAAwB,IAAA,EAAY,YAAA,EAAY,SAAA,EAAY,GAAG,KAAA,EACnG,QAAA,kBAAAP,cAAA,CAACQ,mBAAA,EAAA,EAAQ,CAAA,EACX,CAAA,EACF;AAEJ;AACA,mBAAA,CAAoB,WAAA,GAAc,qBAAA;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { c as cva } from '../index-CSm06eOE.js';
|
|
3
|
+
import { createContext, useContext, forwardRef } from 'react';
|
|
4
|
+
import { T as Txt } from '../Txt-Df42XG5p.js';
|
|
5
|
+
import { c as cn } from '../cn-BakJzhuv.js';
|
|
6
|
+
import { ArrowUp } from 'lucide-react';
|
|
7
|
+
import { I as InputGroup, c as InputGroupInput, a as InputGroupAddon, b as InputGroupButton } from '../input-group-U2f3A4Ya.js';
|
|
8
|
+
|
|
9
|
+
const CommentContext = createContext(null);
|
|
10
|
+
function useCommentVariant() {
|
|
11
|
+
const variant = useContext(CommentContext);
|
|
12
|
+
if (!variant) throw new Error("Comment compounds must be rendered within Comment");
|
|
13
|
+
return variant;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const commentVariants = cva("flex flex-col", {
|
|
17
|
+
variants: {
|
|
18
|
+
variant: {
|
|
19
|
+
default: "gap-2",
|
|
20
|
+
embed: "gap-1 rounded-xl border border-border1 bg-surface3 p-3"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: "default"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const Comment = forwardRef(({ className, variant = "default", ...props }, ref) => /* @__PURE__ */ jsx(CommentContext.Provider, { value: variant, children: /* @__PURE__ */ jsx(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
ref,
|
|
31
|
+
"data-slot": "comment",
|
|
32
|
+
"data-variant": variant,
|
|
33
|
+
className: cn(commentVariants({ variant }), className),
|
|
34
|
+
...props
|
|
35
|
+
}
|
|
36
|
+
) }));
|
|
37
|
+
Comment.displayName = "Comment";
|
|
38
|
+
const commentListGap = {
|
|
39
|
+
default: "gap-3",
|
|
40
|
+
embed: "gap-2"
|
|
41
|
+
};
|
|
42
|
+
const CommentList = forwardRef(({ className, ...props }, ref) => {
|
|
43
|
+
const variant = useCommentVariant();
|
|
44
|
+
return /* @__PURE__ */ jsx(
|
|
45
|
+
"ul",
|
|
46
|
+
{
|
|
47
|
+
ref,
|
|
48
|
+
"data-slot": "comment-list",
|
|
49
|
+
className: cn("flex flex-col", commentListGap[variant], className),
|
|
50
|
+
...props
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
CommentList.displayName = "CommentList";
|
|
55
|
+
const CommentItem = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
56
|
+
"li",
|
|
57
|
+
{
|
|
58
|
+
ref,
|
|
59
|
+
"data-slot": "comment-item",
|
|
60
|
+
className: cn("group/comment-item flex flex-col gap-1", className),
|
|
61
|
+
...props
|
|
62
|
+
}
|
|
63
|
+
));
|
|
64
|
+
CommentItem.displayName = "CommentItem";
|
|
65
|
+
const CommentItemHeader = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, "data-slot": "comment-item-header", className: cn("flex items-center gap-2", className), ...props }));
|
|
66
|
+
CommentItemHeader.displayName = "CommentItemHeader";
|
|
67
|
+
const CommentItemAuthor = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
68
|
+
Txt,
|
|
69
|
+
{
|
|
70
|
+
ref,
|
|
71
|
+
as: "span",
|
|
72
|
+
variant: "ui-md",
|
|
73
|
+
"data-slot": "comment-item-author",
|
|
74
|
+
className: cn("font-medium text-neutral6", className),
|
|
75
|
+
...props
|
|
76
|
+
}
|
|
77
|
+
));
|
|
78
|
+
CommentItemAuthor.displayName = "CommentItemAuthor";
|
|
79
|
+
const CommentItemTimestamp = forwardRef(
|
|
80
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
81
|
+
"time",
|
|
82
|
+
{
|
|
83
|
+
ref,
|
|
84
|
+
"data-slot": "comment-item-timestamp",
|
|
85
|
+
className: cn("text-ui-sm leading-ui-sm text-neutral3", className),
|
|
86
|
+
...props
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
CommentItemTimestamp.displayName = "CommentItemTimestamp";
|
|
91
|
+
const commentItemBodyRule = {
|
|
92
|
+
default: "border-l border-border1 pl-3",
|
|
93
|
+
embed: ""
|
|
94
|
+
};
|
|
95
|
+
const CommentItemBody = forwardRef(({ className, ...props }, ref) => {
|
|
96
|
+
const variant = useCommentVariant();
|
|
97
|
+
return /* @__PURE__ */ jsx(
|
|
98
|
+
Txt,
|
|
99
|
+
{
|
|
100
|
+
ref,
|
|
101
|
+
variant: "ui-md",
|
|
102
|
+
"data-slot": "comment-item-body",
|
|
103
|
+
className: cn("whitespace-pre-wrap text-neutral6", commentItemBodyRule[variant], className),
|
|
104
|
+
...props
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
CommentItemBody.displayName = "CommentItemBody";
|
|
109
|
+
const CommentItemActions = forwardRef(
|
|
110
|
+
({ className, ...props }, ref) => {
|
|
111
|
+
const variant = useCommentVariant();
|
|
112
|
+
if (variant === "embed") return null;
|
|
113
|
+
return /* @__PURE__ */ jsx(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
ref,
|
|
117
|
+
"data-slot": "comment-item-actions",
|
|
118
|
+
className: cn(
|
|
119
|
+
"flex items-center gap-1 opacity-0 group-focus-within/comment-item:opacity-100 group-hover/comment-item:opacity-100",
|
|
120
|
+
"motion-safe:transition-opacity",
|
|
121
|
+
className
|
|
122
|
+
),
|
|
123
|
+
...props
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
CommentItemActions.displayName = "CommentItemActions";
|
|
129
|
+
|
|
130
|
+
const CommentComposer = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("form", { ref, "data-slot": "comment-composer", className: cn("flex w-full items-center gap-2", className), ...props }));
|
|
131
|
+
CommentComposer.displayName = "CommentComposer";
|
|
132
|
+
const composerSize = {
|
|
133
|
+
default: "md",
|
|
134
|
+
embed: "sm"
|
|
135
|
+
};
|
|
136
|
+
const composerInputVariant = {
|
|
137
|
+
default: "outline",
|
|
138
|
+
embed: "default"
|
|
139
|
+
};
|
|
140
|
+
const CommentComposerInput = forwardRef(
|
|
141
|
+
({ groupClassName, children, ...props }, ref) => {
|
|
142
|
+
const variant = useCommentVariant();
|
|
143
|
+
return /* @__PURE__ */ jsxs(InputGroup, { size: composerSize[variant], variant: composerInputVariant[variant], className: groupClassName, children: [
|
|
144
|
+
/* @__PURE__ */ jsx(InputGroupInput, { ref, "data-slot": "comment-composer-input", ...props }),
|
|
145
|
+
children
|
|
146
|
+
] });
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
CommentComposerInput.displayName = "CommentComposerInput";
|
|
150
|
+
const CommentComposerSend = forwardRef(
|
|
151
|
+
({ "aria-label": ariaLabel = "Send comment", type = "submit", ...props }, ref) => /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx(InputGroupButton, { ref, "data-slot": "comment-composer-send", type, "aria-label": ariaLabel, ...props, children: /* @__PURE__ */ jsx(ArrowUp, {}) }) })
|
|
152
|
+
);
|
|
153
|
+
CommentComposerSend.displayName = "CommentComposerSend";
|
|
154
|
+
|
|
155
|
+
export { Comment, CommentComposer, CommentComposerInput, CommentComposerSend, CommentItem, CommentItemActions, CommentItemAuthor, CommentItemBody, CommentItemHeader, CommentItemTimestamp, CommentList };
|
|
156
|
+
//# sourceMappingURL=Comment.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Comment.es.js","sources":["../../src/ds/components/Comment/comment-context.ts","../../src/ds/components/Comment/comment.tsx","../../src/ds/components/Comment/comment-composer.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nexport type CommentVariant = 'default' | 'embed';\n\nexport const CommentContext = createContext<CommentVariant | null>(null);\n\nexport function useCommentVariant(): CommentVariant {\n const variant = useContext(CommentContext);\n if (!variant) throw new Error('Comment compounds must be rendered within Comment');\n return variant;\n}\n","import { cva } from 'class-variance-authority';\nimport type { ComponentPropsWithoutRef } from 'react';\nimport { forwardRef } from 'react';\n\nimport { CommentContext, useCommentVariant } from './comment-context';\nimport type { CommentVariant } from './comment-context';\nimport { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nconst commentVariants = cva('flex flex-col', {\n variants: {\n variant: {\n default: 'gap-2',\n embed: 'gap-1 rounded-xl border border-border1 bg-surface3 p-3',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\nexport interface CommentProps extends ComponentPropsWithoutRef<'div'> {\n variant?: CommentVariant;\n}\n\nexport const Comment = forwardRef<HTMLDivElement, CommentProps>(({ className, variant = 'default', ...props }, ref) => (\n <CommentContext.Provider value={variant}>\n <div\n ref={ref}\n data-slot=\"comment\"\n data-variant={variant}\n className={cn(commentVariants({ variant }), className)}\n {...props}\n />\n </CommentContext.Provider>\n));\nComment.displayName = 'Comment';\n\nconst commentListGap: Record<CommentVariant, string> = {\n default: 'gap-3',\n embed: 'gap-2',\n};\n\nexport type CommentListProps = ComponentPropsWithoutRef<'ul'>;\n\nexport const CommentList = forwardRef<HTMLUListElement, CommentListProps>(({ className, ...props }, ref) => {\n const variant = useCommentVariant();\n\n return (\n <ul\n ref={ref}\n data-slot=\"comment-list\"\n className={cn('flex flex-col', commentListGap[variant], className)}\n {...props}\n />\n );\n});\nCommentList.displayName = 'CommentList';\n\nexport type CommentItemProps = ComponentPropsWithoutRef<'li'>;\n\nexport const CommentItem = forwardRef<HTMLLIElement, CommentItemProps>(({ className, ...props }, ref) => (\n <li\n ref={ref}\n data-slot=\"comment-item\"\n className={cn('group/comment-item flex flex-col gap-1', className)}\n {...props}\n />\n));\nCommentItem.displayName = 'CommentItem';\n\nexport type CommentItemHeaderProps = ComponentPropsWithoutRef<'div'>;\n\nexport const CommentItemHeader = forwardRef<HTMLDivElement, CommentItemHeaderProps>(({ className, ...props }, ref) => (\n <div ref={ref} data-slot=\"comment-item-header\" className={cn('flex items-center gap-2', className)} {...props} />\n));\nCommentItemHeader.displayName = 'CommentItemHeader';\n\nexport type CommentItemAuthorProps = ComponentPropsWithoutRef<'span'>;\n\nexport const CommentItemAuthor = forwardRef<HTMLElement, CommentItemAuthorProps>(({ className, ...props }, ref) => (\n <Txt\n ref={ref}\n as=\"span\"\n variant=\"ui-md\"\n data-slot=\"comment-item-author\"\n className={cn('font-medium text-neutral6', className)}\n {...props}\n />\n));\nCommentItemAuthor.displayName = 'CommentItemAuthor';\n\nexport type CommentItemTimestampProps = ComponentPropsWithoutRef<'time'>;\n\nexport const CommentItemTimestamp = forwardRef<HTMLTimeElement, CommentItemTimestampProps>(\n ({ className, ...props }, ref) => (\n <time\n ref={ref}\n data-slot=\"comment-item-timestamp\"\n className={cn('text-ui-sm leading-ui-sm text-neutral3', className)}\n {...props}\n />\n ),\n);\nCommentItemTimestamp.displayName = 'CommentItemTimestamp';\n\nconst commentItemBodyRule: Record<CommentVariant, string> = {\n default: 'border-l border-border1 pl-3',\n embed: '',\n};\n\nexport type CommentItemBodyProps = ComponentPropsWithoutRef<'p'>;\n\nexport const CommentItemBody = forwardRef<HTMLElement, CommentItemBodyProps>(({ className, ...props }, ref) => {\n const variant = useCommentVariant();\n\n return (\n <Txt\n ref={ref}\n variant=\"ui-md\"\n data-slot=\"comment-item-body\"\n className={cn('whitespace-pre-wrap text-neutral6', commentItemBodyRule[variant], className)}\n {...props}\n />\n );\n});\nCommentItemBody.displayName = 'CommentItemBody';\n\nexport type CommentItemActionsProps = ComponentPropsWithoutRef<'div'>;\n\n/** Hidden in the `embed` variant, which drops per-item actions. */\nexport const CommentItemActions = forwardRef<HTMLDivElement, CommentItemActionsProps>(\n ({ className, ...props }, ref) => {\n const variant = useCommentVariant();\n if (variant === 'embed') return null;\n\n return (\n <div\n ref={ref}\n data-slot=\"comment-item-actions\"\n className={cn(\n 'flex items-center gap-1 opacity-0 group-focus-within/comment-item:opacity-100 group-hover/comment-item:opacity-100',\n 'motion-safe:transition-opacity',\n className,\n )}\n {...props}\n />\n );\n },\n);\nCommentItemActions.displayName = 'CommentItemActions';\n","import { ArrowUp } from 'lucide-react';\nimport type { ComponentPropsWithoutRef, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { useCommentVariant } from './comment-context';\nimport type { CommentVariant } from './comment-context';\nimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@/ds/components/InputGroup';\nimport type { InputGroupButtonProps, InputGroupInputProps } from '@/ds/components/InputGroup';\nimport type { ControlSize } from '@/ds/primitives/control-size';\nimport { cn } from '@/lib/utils';\n\nexport type CommentComposerProps = ComponentPropsWithoutRef<'form'>;\n\nexport const CommentComposer = forwardRef<HTMLFormElement, CommentComposerProps>(({ className, ...props }, ref) => (\n <form ref={ref} data-slot=\"comment-composer\" className={cn('flex w-full items-center gap-2', className)} {...props} />\n));\nCommentComposer.displayName = 'CommentComposer';\n\nconst composerSize: Record<CommentVariant, ControlSize> = {\n default: 'md',\n embed: 'sm',\n};\n\nconst composerInputVariant: Record<CommentVariant, 'default' | 'outline'> = {\n default: 'outline',\n embed: 'default',\n};\n\nexport interface CommentComposerInputProps extends InputGroupInputProps {\n /** Layout classes for the surrounding InputGroup. */\n groupClassName?: string;\n children?: ReactNode;\n}\n\nexport const CommentComposerInput = forwardRef<HTMLInputElement, CommentComposerInputProps>(\n ({ groupClassName, children, ...props }, ref) => {\n const variant = useCommentVariant();\n\n return (\n <InputGroup size={composerSize[variant]} variant={composerInputVariant[variant]} className={groupClassName}>\n <InputGroupInput ref={ref} data-slot=\"comment-composer-input\" {...props} />\n {children}\n </InputGroup>\n );\n },\n);\nCommentComposerInput.displayName = 'CommentComposerInput';\n\nexport type CommentComposerSendProps = Omit<InputGroupButtonProps, 'children'>;\n\nexport const CommentComposerSend = forwardRef<HTMLButtonElement, CommentComposerSendProps>(\n ({ 'aria-label': ariaLabel = 'Send comment', type = 'submit', ...props }, ref) => (\n <InputGroupAddon align=\"inline-end\">\n <InputGroupButton ref={ref} data-slot=\"comment-composer-send\" type={type} aria-label={ariaLabel} {...props}>\n <ArrowUp />\n </InputGroupButton>\n </InputGroupAddon>\n ),\n);\nCommentComposerSend.displayName = 'CommentComposerSend';\n"],"names":[],"mappings":";;;;;;;;AAIO,MAAM,cAAA,GAAiB,cAAqC,IAAI,CAAA;AAEhE,SAAS,iBAAA,GAAoC;AAClD,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,mDAAmD,CAAA;AACjF,EAAA,OAAO,OAAA;AACT;;ACDA,MAAM,eAAA,GAAkB,IAAI,eAAA,EAAiB;AAAA,EAC3C,Q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A,EACT,KAAA,EAAO;AACT,CAAA;AAQO,MAAM,oBAAA,GAAuB,UAAA;AAAA,EAClC,CAAC,EAAE,cAAA,EAAgB,UAAU,GAAG,KAAA,IAAS,GAAA,KAAQ;AAC/C,IAAA,MAAM,UAAU,iBAAA,EAAkB;AAElC,IAAA,uBACE,IAAA,CAAC,UAAA,EAAA,EAAW,IAAA,EAAM,YAAA,CAAa,OAAO,CAAA,EAAG,OAAA,EAAS,oBAAA,CAAqB,OAAO,CAAA,EAAG,SAAA,EAAW,cAAA,EAC1F,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,eAAA,EAAA,EAAgB,GAAA,EAAU,WAAA,EAAU,wBAAA,EAA0B,GAAG,KAAA,EAAO,CAAA;AAAA,MACxE;AAAA,KAAA,EACH,CAAA;AAAA,EAEJ;AACF;AACA,oBAAA,CAAqB,WAAA,GAAc,sBAAA;AAI5B,MAAM,mBAAA,GAAsB,UAAA;AAAA,EACjC,CAAC,EAAE,YAAA,EAAc,SAAA,GAAY,cAAA,EAAgB,IAAA,GAAO,QAAA,EAAU,GAAG,KAAA,EAAM,EAAG,GAAA,qBACxE,GAAA,CAAC,eAAA,EAAA,EAAgB,KAAA,EAAM,YAAA,EACrB,QAAA,kBAAA,GAAA,CAAC,gBAAA,EAAA,EAAiB,GAAA,EAAU,WAAA,EAAU,uBAAA,EAAwB,IAAA,EAAY,YAAA,EAAY,SAAA,EAAY,GAAG,KAAA,EACnG,QAAA,kBAAA,GAAA,CAAC,OAAA,EAAA,EAAQ,CAAA,EACX,CAAA,EACF;AAEJ;AACA,mBAAA,CAAoB,WAAA,GAAc,qBAAA;;;;"}
|
|
@@ -67,7 +67,7 @@ const ComposerRing = ({ busy = false, className, ...props }) => {
|
|
|
67
67
|
ref: ringRef,
|
|
68
68
|
"data-slot": "composer-ring",
|
|
69
69
|
"data-busy": busy ? "true" : "false",
|
|
70
|
-
className: utils_cn.cn("composer-ring mx-auto w-full max-w-3xl", className),
|
|
70
|
+
className: utils_cn.cn("composer-ring relative mx-auto w-full max-w-3xl rounded-[23px] p-px", className),
|
|
71
71
|
...props
|
|
72
72
|
}
|
|
73
73
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Composer.cjs.js","sources":["../../src/ds/components/Composer/use-composer-pointer-angle.ts","../../src/ds/components/Composer/composer.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\n/** Aims the composer ring at the cursor without re-rendering on every move. */\nexport function useComposerPointerAngle(enabled: boolean) {\n const elementRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element || !enabled) return;\n\n let animationFrame: number | undefined;\n let clientX = 0;\n let clientY = 0;\n\n const paintAngle = () => {\n animationFrame = undefined;\n const bounds = element.getBoundingClientRect();\n const radians = Math.atan2(\n clientY - (bounds.top + bounds.height / 2),\n clientX - (bounds.left + bounds.width / 2),\n );\n // conic-gradient starts at 12 o'clock, atan2 at 3 o'clock\n element.style.setProperty('--composer-ring-angle', `${(radians * 180) / Math.PI + 90}deg`);\n };\n\n const trackPointer = (event: PointerEvent) => {\n clientX = event.clientX;\n clientY = event.clientY;\n animationFrame ??= requestAnimationFrame(paintAngle);\n };\n\n window.addEventListener('pointermove', trackPointer, { passive: true });\n return () => {\n window.removeEventListener('pointermove', trackPointer);\n if (animationFrame !== undefined) cancelAnimationFrame(animationFrame);\n };\n }, [enabled]);\n\n return elementRef;\n}\n","import type { ComponentPropsWithoutRef } from 'react';\nimport { forwardRef } from 'react';\n\nimport { ScrollArea } from '../ScrollArea';\nimport { useComposerPointerAngle } from './use-composer-pointer-angle';\nimport { cn } from '@/lib/utils';\n\nimport './composer-ring.css';\nimport './composer-sending.css';\n\nexport type ComposerProps = ComponentPropsWithoutRef<'form'>;\n\nexport interface ComposerInputProps extends ComponentPropsWithoutRef<'textarea'> {\n /** Maximum height of the scrolling input viewport. */\n maxHeight?: string;\n}\n\nexport const Composer = forwardRef<HTMLFormElement, ComposerProps>(({ children, ...props }, ref) => (\n <form ref={ref} data-slot=\"composer\" {...props}>\n {children}\n </form>\n));\nComposer.displayName = 'Composer';\n\nexport interface ComposerBoxProps extends ComponentPropsWithoutRef<'div'> {\n sendingPulseKey?: number;\n}\n\nexport const ComposerBox = forwardRef<HTMLDivElement, ComposerBoxProps>(\n ({ children, className, sendingPulseKey = 0, ...props }, ref) => (\n <div\n ref={ref}\n data-slot=\"composer-box\"\n className={cn(\n 'duration-normal @container relative mx-auto mt-auto w-full max-w-3xl overflow-hidden rounded-[22px] border border-border2/40 bg-surface3 transition-colors focus-within:border-border2',\n className,\n )}\n {...props}\n >\n <ComposerSendingPulse pulseKey={sendingPulseKey} />\n <div className=\"relative z-10\">{children}</div>\n </div>\n ),\n);\nComposerBox.displayName = 'ComposerBox';\n\nexport interface ComposerRingProps extends ComponentPropsWithoutRef<'div'> {\n busy?: boolean;\n}\n\n/**\n * Edge for the composer box it wraps: a conic arc lit under the cursor on hover,\n * spinning on its own while the agent runs, never both at once. Wraps rather\n * than decorates because the box clips its overflow and would cut the arc off.\n */\nexport const ComposerRing = ({ busy = false, className, ...props }: ComposerRingProps) => {\n const ringRef = useComposerPointerAngle(!busy);\n\n return (\n <div\n ref={ringRef}\n data-slot=\"composer-ring\"\n data-busy={busy ? 'true' : 'false'}\n className={cn('composer-ring mx-auto w-full max-w-3xl', className)}\n {...props}\n />\n );\n};\nComposerRing.displayName = 'ComposerRing';\n\nexport const ComposerAttachments = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"region\"\n data-slot=\"composer-attachments\"\n className={cn('mx-auto w-full max-w-3xl pb-2', className)}\n {...props}\n />\n ),\n);\nComposerAttachments.displayName = 'ComposerAttachments';\n\nexport const ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n ({ className, maxHeight = '212px', ...props }, ref) => (\n <ScrollArea maxHeight={maxHeight}>\n <textarea\n ref={ref}\n data-slot=\"composer-input\"\n className={cn(\n 'min-h-17 field-sizing-content w-full resize-none overflow-hidden bg-transparent px-3 pt-3 pb-2 text-ui-lg leading-ui-lg text-neutral6 outline-hidden placeholder:text-neutral3 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',\n className,\n )}\n {...props}\n />\n </ScrollArea>\n ),\n);\nComposerInput.displayName = 'ComposerInput';\n\nexport const ComposerActions = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"region\"\n data-slot=\"composer-actions\"\n className={cn('flex flex-wrap-reverse items-center justify-between gap-2 px-1.5 pb-1.5', className)}\n {...props}\n />\n ),\n);\nComposerActions.displayName = 'ComposerActions';\n\nconst ComposerGradientColumn = ({ className }: { className?: string }) => (\n <div className={cn('flex size-full flex-col -space-y-3', className)}>\n <div className=\"bg-accent1 w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1Dark w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1 w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1Darker w-full flex-1 blur-xl\" />\n </div>\n);\n\nconst ComposerSendingPulse = ({ pulseKey }: { pulseKey: number }) => {\n if (pulseKey === 0) return null;\n\n return (\n <div\n key={pulseKey}\n aria-hidden=\"true\"\n data-slot=\"composer-sending-pulse\"\n className=\"composer-sending pointer-events-none absolute top-0 left-[-10%] z-0 flex h-10 w-[120%] transform-gpu\"\n >\n <ComposerGradientColumn />\n <ComposerGradientColumn className=\"-translate-y-2\" />\n <ComposerGradientColumn />\n </div>\n );\n};\n"],"names":["useRef","useEffect","forwardRef","jsx","jsxs","cn","ScrollArea"],"mappings":";;;;;;;;;AAGO,SAAS,wBAAwB,OAAA,EAAkB;AACxD,EAAA,MAAM,UAAA,GAAaA,aAAuB,IAAI,CAAA;AAE9C,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,UAAA,CAAW,OAAA;AAC3B,IAAA,IAAI,CAAC,OAAA,IAAW,C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,kCAAA,EAAmC,CAAA;AAAA,kBAClDA,cAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,sCAAA,EAAuC,CAAA;AAAA,kBACtDA,cAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,kCAAA,EAAmC,CAAA;AAAA,kBAClDA,cAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,wCAAA,EAAyC;AAAA,CAAA,EAC1D,CAAA;AAGF,MAAM,oBAAA,GAAuB,CAAC,EAAE,QAAA,EAAS,KAA4B;AACnE,EAAA,IAAI,QAAA,KAAa,GAAG,OAAO,IAAA;AAE3B,EAAA,uBACEC,eAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MAEC,aAAA,EAAY,MAAA;AAAA,MACZ,WAAA,EAAU,wBAAA;AAAA,MACV,SAAA,EAAU,sGAAA;AAAA,MAEV,QAAA,EAAA;AAAA,wBAAAD,cAAA,CAAC,sBAAA,EAAA,EAAuB,CAAA;AAAA,wBACxBA,cAAA,CAAC,sBAAA,EAAA,EAAuB,SAAA,EAAU,gBAAA,EAAiB,CAAA;AAAA,uCAClD,sBAAA,EAAA,EAAuB;AAAA;AAAA,KAAA;AAAA,IAPnB;AAAA,GAQP;AAEJ,CAAA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Composer.cjs.js","sources":["../../src/ds/components/Composer/use-composer-pointer-angle.ts","../../src/ds/components/Composer/composer.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\n/** Aims the composer ring at the cursor without re-rendering on every move. */\nexport function useComposerPointerAngle(enabled: boolean) {\n const elementRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element || !enabled) return;\n\n let animationFrame: number | undefined;\n let clientX = 0;\n let clientY = 0;\n\n const paintAngle = () => {\n animationFrame = undefined;\n const bounds = element.getBoundingClientRect();\n const radians = Math.atan2(\n clientY - (bounds.top + bounds.height / 2),\n clientX - (bounds.left + bounds.width / 2),\n );\n // conic-gradient starts at 12 o'clock, atan2 at 3 o'clock\n element.style.setProperty('--composer-ring-angle', `${(radians * 180) / Math.PI + 90}deg`);\n };\n\n const trackPointer = (event: PointerEvent) => {\n clientX = event.clientX;\n clientY = event.clientY;\n animationFrame ??= requestAnimationFrame(paintAngle);\n };\n\n window.addEventListener('pointermove', trackPointer, { passive: true });\n return () => {\n window.removeEventListener('pointermove', trackPointer);\n if (animationFrame !== undefined) cancelAnimationFrame(animationFrame);\n };\n }, [enabled]);\n\n return elementRef;\n}\n","import type { ComponentPropsWithoutRef } from 'react';\nimport { forwardRef } from 'react';\n\nimport { ScrollArea } from '../ScrollArea';\nimport { useComposerPointerAngle } from './use-composer-pointer-angle';\nimport { cn } from '@/lib/utils';\n\nimport './composer-ring.css';\nimport './composer-sending.css';\n\nexport type ComposerProps = ComponentPropsWithoutRef<'form'>;\n\nexport interface ComposerInputProps extends ComponentPropsWithoutRef<'textarea'> {\n /** Maximum height of the scrolling input viewport. */\n maxHeight?: string;\n}\n\nexport const Composer = forwardRef<HTMLFormElement, ComposerProps>(({ children, ...props }, ref) => (\n <form ref={ref} data-slot=\"composer\" {...props}>\n {children}\n </form>\n));\nComposer.displayName = 'Composer';\n\nexport interface ComposerBoxProps extends ComponentPropsWithoutRef<'div'> {\n sendingPulseKey?: number;\n}\n\nexport const ComposerBox = forwardRef<HTMLDivElement, ComposerBoxProps>(\n ({ children, className, sendingPulseKey = 0, ...props }, ref) => (\n <div\n ref={ref}\n data-slot=\"composer-box\"\n className={cn(\n 'duration-normal @container relative mx-auto mt-auto w-full max-w-3xl overflow-hidden rounded-[22px] border border-border2/40 bg-surface3 transition-colors focus-within:border-border2',\n className,\n )}\n {...props}\n >\n <ComposerSendingPulse pulseKey={sendingPulseKey} />\n <div className=\"relative z-10\">{children}</div>\n </div>\n ),\n);\nComposerBox.displayName = 'ComposerBox';\n\nexport interface ComposerRingProps extends ComponentPropsWithoutRef<'div'> {\n busy?: boolean;\n}\n\n/**\n * Edge for the composer box it wraps: a conic arc lit under the cursor on hover,\n * spinning on its own while the agent runs, never both at once. Wraps rather\n * than decorates because the box clips its overflow and would cut the arc off.\n */\nexport const ComposerRing = ({ busy = false, className, ...props }: ComposerRingProps) => {\n const ringRef = useComposerPointerAngle(!busy);\n\n return (\n <div\n ref={ringRef}\n data-slot=\"composer-ring\"\n data-busy={busy ? 'true' : 'false'}\n className={cn('composer-ring relative mx-auto w-full max-w-3xl rounded-[23px] p-px', className)}\n {...props}\n />\n );\n};\nComposerRing.displayName = 'ComposerRing';\n\nexport const ComposerAttachments = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"region\"\n data-slot=\"composer-attachments\"\n className={cn('mx-auto w-full max-w-3xl pb-2', className)}\n {...props}\n />\n ),\n);\nComposerAttachments.displayName = 'ComposerAttachments';\n\nexport const ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n ({ className, maxHeight = '212px', ...props }, ref) => (\n <ScrollArea maxHeight={maxHeight}>\n <textarea\n ref={ref}\n data-slot=\"composer-input\"\n className={cn(\n 'min-h-17 field-sizing-content w-full resize-none overflow-hidden bg-transparent px-3 pt-3 pb-2 text-ui-lg leading-ui-lg text-neutral6 outline-hidden placeholder:text-neutral3 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',\n className,\n )}\n {...props}\n />\n </ScrollArea>\n ),\n);\nComposerInput.displayName = 'ComposerInput';\n\nexport const ComposerActions = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"region\"\n data-slot=\"composer-actions\"\n className={cn('flex flex-wrap-reverse items-center justify-between gap-2 px-1.5 pb-1.5', className)}\n {...props}\n />\n ),\n);\nComposerActions.displayName = 'ComposerActions';\n\nconst ComposerGradientColumn = ({ className }: { className?: string }) => (\n <div className={cn('flex size-full flex-col -space-y-3', className)}>\n <div className=\"bg-accent1 w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1Dark w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1 w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1Darker w-full flex-1 blur-xl\" />\n </div>\n);\n\nconst ComposerSendingPulse = ({ pulseKey }: { pulseKey: number }) => {\n if (pulseKey === 0) return null;\n\n return (\n <div\n key={pulseKey}\n aria-hidden=\"true\"\n data-slot=\"composer-sending-pulse\"\n className=\"composer-sending pointer-events-none absolute top-0 left-[-10%] z-0 flex h-10 w-[120%] transform-gpu\"\n >\n <ComposerGradientColumn />\n <ComposerGradientColumn className=\"-translate-y-2\" />\n <ComposerGradientColumn />\n </div>\n );\n};\n"],"names":["useRef","useEffect","forwardRef","jsx","jsxs","cn","ScrollArea"],"mappings":";;;;;;;;;AAGO,SAAS,wBAAwB,OAAA,EAAkB;AACxD,EAAA,MAAM,UAAA,GAAaA,aAAuB,IAAI,CAAA;AAE9C,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,UAAA,CAAW,OAAA;AAC3B,IAAA,IAAI,CAAC,OAAA,IAAW,CAAC,OAAA,EAAS;AAE1B,IAAA,IAAI,cAAA;AACJ,IAAA,IAAI,OAAA,GAAU,CAAA;AACd,IAAA,IAAI,OAAA,GAAU,CAAA;AAEd,IAAA,MAAM,aAAa,MAAM;AACvB,MAAA,cAAA,GAAiB,MAAA;AACjB,MAAA,MAAM,MAAA,GAAS,QAAQ,qBAAA,EAAsB;AAC7C,MAAA,MAAM,UAAU,IAAA,CAAK,KAAA;AAAA,QACnB,OAAA,IAAW,MAAA,CAAO,GAAA,GAAM,MAAA,CAAO,MAAA,GAAS,CAAA,CAAA;AAAA,QACxC,OAAA,IAAW,MAAA,CAAO,IAAA,GAAO,MAAA,CAAO,KAAA,GAAQ,CAAA;AAAA,OAC1C;AAEA,MAAA,OAAA,CAAQ,KAAA,CAAM,YAAY,uBAAA,EAAyB,CAAA,EAAI,UAAU,GAAA,GAAO,IAAA,CAAK,EA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A;AAAA,wBAAAD,cAAA,CAAC,sBAAA,EAAA,EAAuB,CAAA;AAAA,wBACxBA,cAAA,CAAC,sBAAA,EAAA,EAAuB,SAAA,EAAU,gBAAA,EAAiB,CAAA;AAAA,uCAClD,sBAAA,EAAA,EAAuB;AAAA;AAAA,KAAA;AAAA,IAPnB;AAAA,GAQP;AAEJ,CAAA;;;;;;;;;"}
|
|
@@ -63,7 +63,7 @@ const ComposerRing = ({ busy = false, className, ...props }) => {
|
|
|
63
63
|
ref: ringRef,
|
|
64
64
|
"data-slot": "composer-ring",
|
|
65
65
|
"data-busy": busy ? "true" : "false",
|
|
66
|
-
className: cn("composer-ring mx-auto w-full max-w-3xl", className),
|
|
66
|
+
className: cn("composer-ring relative mx-auto w-full max-w-3xl rounded-[23px] p-px", className),
|
|
67
67
|
...props
|
|
68
68
|
}
|
|
69
69
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Composer.es.js","sources":["../../src/ds/components/Composer/use-composer-pointer-angle.ts","../../src/ds/components/Composer/composer.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\n/** Aims the composer ring at the cursor without re-rendering on every move. */\nexport function useComposerPointerAngle(enabled: boolean) {\n const elementRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element || !enabled) return;\n\n let animationFrame: number | undefined;\n let clientX = 0;\n let clientY = 0;\n\n const paintAngle = () => {\n animationFrame = undefined;\n const bounds = element.getBoundingClientRect();\n const radians = Math.atan2(\n clientY - (bounds.top + bounds.height / 2),\n clientX - (bounds.left + bounds.width / 2),\n );\n // conic-gradient starts at 12 o'clock, atan2 at 3 o'clock\n element.style.setProperty('--composer-ring-angle', `${(radians * 180) / Math.PI + 90}deg`);\n };\n\n const trackPointer = (event: PointerEvent) => {\n clientX = event.clientX;\n clientY = event.clientY;\n animationFrame ??= requestAnimationFrame(paintAngle);\n };\n\n window.addEventListener('pointermove', trackPointer, { passive: true });\n return () => {\n window.removeEventListener('pointermove', trackPointer);\n if (animationFrame !== undefined) cancelAnimationFrame(animationFrame);\n };\n }, [enabled]);\n\n return elementRef;\n}\n","import type { ComponentPropsWithoutRef } from 'react';\nimport { forwardRef } from 'react';\n\nimport { ScrollArea } from '../ScrollArea';\nimport { useComposerPointerAngle } from './use-composer-pointer-angle';\nimport { cn } from '@/lib/utils';\n\nimport './composer-ring.css';\nimport './composer-sending.css';\n\nexport type ComposerProps = ComponentPropsWithoutRef<'form'>;\n\nexport interface ComposerInputProps extends ComponentPropsWithoutRef<'textarea'> {\n /** Maximum height of the scrolling input viewport. */\n maxHeight?: string;\n}\n\nexport const Composer = forwardRef<HTMLFormElement, ComposerProps>(({ children, ...props }, ref) => (\n <form ref={ref} data-slot=\"composer\" {...props}>\n {children}\n </form>\n));\nComposer.displayName = 'Composer';\n\nexport interface ComposerBoxProps extends ComponentPropsWithoutRef<'div'> {\n sendingPulseKey?: number;\n}\n\nexport const ComposerBox = forwardRef<HTMLDivElement, ComposerBoxProps>(\n ({ children, className, sendingPulseKey = 0, ...props }, ref) => (\n <div\n ref={ref}\n data-slot=\"composer-box\"\n className={cn(\n 'duration-normal @container relative mx-auto mt-auto w-full max-w-3xl overflow-hidden rounded-[22px] border border-border2/40 bg-surface3 transition-colors focus-within:border-border2',\n className,\n )}\n {...props}\n >\n <ComposerSendingPulse pulseKey={sendingPulseKey} />\n <div className=\"relative z-10\">{children}</div>\n </div>\n ),\n);\nComposerBox.displayName = 'ComposerBox';\n\nexport interface ComposerRingProps extends ComponentPropsWithoutRef<'div'> {\n busy?: boolean;\n}\n\n/**\n * Edge for the composer box it wraps: a conic arc lit under the cursor on hover,\n * spinning on its own while the agent runs, never both at once. Wraps rather\n * than decorates because the box clips its overflow and would cut the arc off.\n */\nexport const ComposerRing = ({ busy = false, className, ...props }: ComposerRingProps) => {\n const ringRef = useComposerPointerAngle(!busy);\n\n return (\n <div\n ref={ringRef}\n data-slot=\"composer-ring\"\n data-busy={busy ? 'true' : 'false'}\n className={cn('composer-ring mx-auto w-full max-w-3xl', className)}\n {...props}\n />\n );\n};\nComposerRing.displayName = 'ComposerRing';\n\nexport const ComposerAttachments = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"region\"\n data-slot=\"composer-attachments\"\n className={cn('mx-auto w-full max-w-3xl pb-2', className)}\n {...props}\n />\n ),\n);\nComposerAttachments.displayName = 'ComposerAttachments';\n\nexport const ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n ({ className, maxHeight = '212px', ...props }, ref) => (\n <ScrollArea maxHeight={maxHeight}>\n <textarea\n ref={ref}\n data-slot=\"composer-input\"\n className={cn(\n 'min-h-17 field-sizing-content w-full resize-none overflow-hidden bg-transparent px-3 pt-3 pb-2 text-ui-lg leading-ui-lg text-neutral6 outline-hidden placeholder:text-neutral3 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',\n className,\n )}\n {...props}\n />\n </ScrollArea>\n ),\n);\nComposerInput.displayName = 'ComposerInput';\n\nexport const ComposerActions = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"region\"\n data-slot=\"composer-actions\"\n className={cn('flex flex-wrap-reverse items-center justify-between gap-2 px-1.5 pb-1.5', className)}\n {...props}\n />\n ),\n);\nComposerActions.displayName = 'ComposerActions';\n\nconst ComposerGradientColumn = ({ className }: { className?: string }) => (\n <div className={cn('flex size-full flex-col -space-y-3', className)}>\n <div className=\"bg-accent1 w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1Dark w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1 w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1Darker w-full flex-1 blur-xl\" />\n </div>\n);\n\nconst ComposerSendingPulse = ({ pulseKey }: { pulseKey: number }) => {\n if (pulseKey === 0) return null;\n\n return (\n <div\n key={pulseKey}\n aria-hidden=\"true\"\n data-slot=\"composer-sending-pulse\"\n className=\"composer-sending pointer-events-none absolute top-0 left-[-10%] z-0 flex h-10 w-[120%] transform-gpu\"\n >\n <ComposerGradientColumn />\n <ComposerGradientColumn className=\"-translate-y-2\" />\n <ComposerGradientColumn />\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;AAGO,SAAS,wBAAwB,OAAA,EAAkB;AACxD,EAAA,MAAM,UAAA,GAAa,OAAuB,IAAI,CAAA;AAE9C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,UAAA,CAAW,OAAA;AAC3B,IAAA,IAAI,CAAC,OAAA,IAAW,CAAC,OAAA,EAAS;AAE1B,IAAA,IAAI,cAAA;AACJ,IAAA,IAAI,OAAA,GAAU,CAAA;AACd,IAAA,IAAI,OAAA,GAAU,CAAA;AAEd,IAAA,MAAM,aAAa,MAAM;AACvB,MAAA,cAAA,GAAiB,MAAA;AACjB,MAAA,MAAM,MAAA,GAAS,QAAQ,qBAAA,EAAsB;AAC7C,MAAA,MAAM,UAAU,IAAA,CAAK,KAAA;AAAA,QACnB,OAAA,IAAW,MAAA,CAAO,GAAA,GAAM,MAAA,CAAO,MAAA,GAAS,CAAA,CAAA;AAAA,QACxC,OAAA,IAAW,MAAA,CAAO,IAAA,GAAO,MAAA,CAAO,KAAA,GAAQ,CAAA;AAAA,OAC1C;AAEA,MAAA,OAAA,CAAQ,KAAA,CAAM,YAAY,uBAAA,EAAyB,CAAA,EAAI,UAAU,GAAA,GAAO,IAAA,CAAK,EAAA,GAAK,EAAE,CAAA,GAAA,CAAK,CAAA;AAAA,IAC3F,CAAA;AAEA,IAAA,MAAM,YAAA,GAAe,CAAC,KAAA,KAAwB;AAC5C,MAAA,OAAA,GAAU,KAAA,CAAM,OAAA;AAChB,MAAA,OAAA,GAAU,KAAA,CAAM,OAAA;AAChB,MAAA,cAAA,KAAmB,sBAAsB,UAAU,CAAA;AAAA,IACrD,CAAA;AAEA,IAAA,MAAA,CAAO,iBAAiB,aAAA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EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,yEAAA,EAA2E,SAAS,CAAA;AAAA,MACjG,GAAG;AAAA;AAAA;AAGV;AACA,eAAA,CAAgB,WAAA,GAAc,iBAAA;AAE9B,MAAM,sBAAA,GAAyB,CAAC,EAAE,SAAA,EAAU,qBAC1C,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAW,EAAA,CAAG,oCAAA,EAAsC,SAAS,CAAA,EAChE,QAAA,EAAA;AAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAI,WAAU,kCAAA,EAAmC,CAAA;AAAA,kBAClD,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,sCAAA,EAAuC,CAAA;AAAA,kBACtD,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,kCAAA,EAAmC,CAAA;AAAA,kBAClD,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,wCAAA,EAAyC;AAAA,CAAA,EAC1D,CAAA;AAGF,MAAM,oBAAA,GAAuB,CAAC,EAAE,QAAA,EAAS,KAA4B;AACnE,EAAA,IAAI,QAAA,KAAa,GAAG,OAAO,IAAA;AAE3B,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MAEC,aAAA,EAAY,MAAA;AAAA,MACZ,WAAA,EAAU,wBAAA;AAAA,MACV,SAAA,EAAU,sGAAA;AAAA,MAEV,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,sBAAA,EAAA,EAAuB,CAAA;AAAA,wBACxB,GAAA,CAAC,sBAAA,EAAA,EAAuB,SAAA,EAAU,gBAAA,EAAiB,CAAA;AAAA,4BAClD,sBAAA,EAAA,EAAuB;AAAA;AAAA,KAAA;AAAA,IAPnB;AAAA,GAQP;AAEJ,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"Composer.es.js","sources":["../../src/ds/components/Composer/use-composer-pointer-angle.ts","../../src/ds/components/Composer/composer.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\n/** Aims the composer ring at the cursor without re-rendering on every move. */\nexport function useComposerPointerAngle(enabled: boolean) {\n const elementRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element || !enabled) return;\n\n let animationFrame: number | undefined;\n let clientX = 0;\n let clientY = 0;\n\n const paintAngle = () => {\n animationFrame = undefined;\n const bounds = element.getBoundingClientRect();\n const radians = Math.atan2(\n clientY - (bounds.top + bounds.height / 2),\n clientX - (bounds.left + bounds.width / 2),\n );\n // conic-gradient starts at 12 o'clock, atan2 at 3 o'clock\n element.style.setProperty('--composer-ring-angle', `${(radians * 180) / Math.PI + 90}deg`);\n };\n\n const trackPointer = (event: PointerEvent) => {\n clientX = event.clientX;\n clientY = event.clientY;\n animationFrame ??= requestAnimationFrame(paintAngle);\n };\n\n window.addEventListener('pointermove', trackPointer, { passive: true });\n return () => {\n window.removeEventListener('pointermove', trackPointer);\n if (animationFrame !== undefined) cancelAnimationFrame(animationFrame);\n };\n }, [enabled]);\n\n return elementRef;\n}\n","import type { ComponentPropsWithoutRef } from 'react';\nimport { forwardRef } from 'react';\n\nimport { ScrollArea } from '../ScrollArea';\nimport { useComposerPointerAngle } from './use-composer-pointer-angle';\nimport { cn } from '@/lib/utils';\n\nimport './composer-ring.css';\nimport './composer-sending.css';\n\nexport type ComposerProps = ComponentPropsWithoutRef<'form'>;\n\nexport interface ComposerInputProps extends ComponentPropsWithoutRef<'textarea'> {\n /** Maximum height of the scrolling input viewport. */\n maxHeight?: string;\n}\n\nexport const Composer = forwardRef<HTMLFormElement, ComposerProps>(({ children, ...props }, ref) => (\n <form ref={ref} data-slot=\"composer\" {...props}>\n {children}\n </form>\n));\nComposer.displayName = 'Composer';\n\nexport interface ComposerBoxProps extends ComponentPropsWithoutRef<'div'> {\n sendingPulseKey?: number;\n}\n\nexport const ComposerBox = forwardRef<HTMLDivElement, ComposerBoxProps>(\n ({ children, className, sendingPulseKey = 0, ...props }, ref) => (\n <div\n ref={ref}\n data-slot=\"composer-box\"\n className={cn(\n 'duration-normal @container relative mx-auto mt-auto w-full max-w-3xl overflow-hidden rounded-[22px] border border-border2/40 bg-surface3 transition-colors focus-within:border-border2',\n className,\n )}\n {...props}\n >\n <ComposerSendingPulse pulseKey={sendingPulseKey} />\n <div className=\"relative z-10\">{children}</div>\n </div>\n ),\n);\nComposerBox.displayName = 'ComposerBox';\n\nexport interface ComposerRingProps extends ComponentPropsWithoutRef<'div'> {\n busy?: boolean;\n}\n\n/**\n * Edge for the composer box it wraps: a conic arc lit under the cursor on hover,\n * spinning on its own while the agent runs, never both at once. Wraps rather\n * than decorates because the box clips its overflow and would cut the arc off.\n */\nexport const ComposerRing = ({ busy = false, className, ...props }: ComposerRingProps) => {\n const ringRef = useComposerPointerAngle(!busy);\n\n return (\n <div\n ref={ringRef}\n data-slot=\"composer-ring\"\n data-busy={busy ? 'true' : 'false'}\n className={cn('composer-ring relative mx-auto w-full max-w-3xl rounded-[23px] p-px', className)}\n {...props}\n />\n );\n};\nComposerRing.displayName = 'ComposerRing';\n\nexport const ComposerAttachments = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"region\"\n data-slot=\"composer-attachments\"\n className={cn('mx-auto w-full max-w-3xl pb-2', className)}\n {...props}\n />\n ),\n);\nComposerAttachments.displayName = 'ComposerAttachments';\n\nexport const ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n ({ className, maxHeight = '212px', ...props }, ref) => (\n <ScrollArea maxHeight={maxHeight}>\n <textarea\n ref={ref}\n data-slot=\"composer-input\"\n className={cn(\n 'min-h-17 field-sizing-content w-full resize-none overflow-hidden bg-transparent px-3 pt-3 pb-2 text-ui-lg leading-ui-lg text-neutral6 outline-hidden placeholder:text-neutral3 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',\n className,\n )}\n {...props}\n />\n </ScrollArea>\n ),\n);\nComposerInput.displayName = 'ComposerInput';\n\nexport const ComposerActions = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"region\"\n data-slot=\"composer-actions\"\n className={cn('flex flex-wrap-reverse items-center justify-between gap-2 px-1.5 pb-1.5', className)}\n {...props}\n />\n ),\n);\nComposerActions.displayName = 'ComposerActions';\n\nconst ComposerGradientColumn = ({ className }: { className?: string }) => (\n <div className={cn('flex size-full flex-col -space-y-3', className)}>\n <div className=\"bg-accent1 w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1Dark w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1 w-full flex-1 blur-xl\" />\n <div className=\"bg-accent1Darker w-full flex-1 blur-xl\" />\n </div>\n);\n\nconst ComposerSendingPulse = ({ pulseKey }: { pulseKey: number }) => {\n if (pulseKey === 0) return null;\n\n return (\n <div\n key={pulseKey}\n aria-hidden=\"true\"\n data-slot=\"composer-sending-pulse\"\n className=\"composer-sending pointer-events-none absolute top-0 left-[-10%] z-0 flex h-10 w-[120%] transform-gpu\"\n >\n <ComposerGradientColumn />\n <ComposerGradientColumn className=\"-translate-y-2\" />\n <ComposerGradientColumn />\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;AAGO,SAAS,wBAAwB,OAAA,EAAkB;AACxD,EAAA,MAAM,UAAA,GAAa,OAAuB,IAAI,CAAA;AAE9C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,UAAA,CAAW,OAAA;AAC3B,IAAA,IAAI,CAAC,OAAA,IAAW,CAAC,OAAA,EAAS;AAE1B,IAAA,IAAI,cAAA;AACJ,IAAA,IAAI,OAAA,GAAU,CAAA;AACd,IAAA,IAAI,OAAA,GAAU,CAAA;AAEd,IAAA,MAAM,aAAa,MAAM;AACvB,MAAA,cAAA,GAAiB,MAAA;AACjB,MAAA,MAAM,MAAA,GAAS,QAAQ,qBAAA,EAAsB;AAC7C,MAAA,MAAM,UAAU,IAAA,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