@nucleux/md3-modes 0.0.0-stage → 0.8.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/LICENSE +21 -0
- package/README.md +50 -2
- package/dist/index.cjs +520 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +55 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +493 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nucleux
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nucleux/md3-modes
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Material 3 Modes — choose how the agent approaches a request (Brainstorm, Draft, Review, Plan), shown as a chip in the composer and switchable before sending — Nucleux agentic UI for React.
|
|
4
|
+
|
|
5
|
+
Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
|
|
6
|
+
|
|
7
|
+
**Same API as the shadcn twin.** The props, callbacks, states, keyboard model and accessible names are those of [`@nucleux/modes`](https://www.npmjs.com/package/@nucleux/modes) (`Modes`) — the props types are re-exported from it and the state logic (`useModes`) is shared — so you switch families by changing only the import. Only the look differs: Material 3 colour roles, shape, elevation, state layers and motion (reduced under `prefers-reduced-motion`). In the `composer` variant the Mode chip sits in an `Md3AgentComposer` toolbar and the picker grows up from the composer.
|
|
8
|
+
|
|
9
|
+
## Exports
|
|
10
|
+
|
|
11
|
+
- **`Md3Modes`** — the whole pattern (`variant`: `composer` · `segmented` · `list` · `chip`)
|
|
12
|
+
- **`Md3ModesSegmented`** — an `Md3SegmentedButton` of modes (radio group)
|
|
13
|
+
- **`Md3ModesList`** — mode rows: 40dp icon tile, name, what changes, unavailable reason, trailing check
|
|
14
|
+
- **`Md3ModesChip`** — outlined "Mode ▾" assist chip, or tonal "Mode **Plan** ▾ ×" once set
|
|
15
|
+
- **`Md3ModesPicker`** — the menu-surface dialog: heading, rows, error-container alert, "No mode"
|
|
16
|
+
- **`Md3ModesNote`** — "Mode changed to … Your text is unchanged." with Undo
|
|
17
|
+
- Types: `Md3ModesProps`, `Md3ModeOption`, `Md3ModesVariant`, `Md3ModesNotice`, `Md3ModesSubmitDetails`, and each sub-component's `Md3…Props`
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @nucleux/md3-modes @nucleux/tokens
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`react` / `react-dom` are peer dependencies.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { Md3Modes } from "@nucleux/md3-modes";
|
|
31
|
+
import { Flag, Lightbulb, NotebookPen, Eye } from "lucide-react";
|
|
32
|
+
|
|
33
|
+
<Md3Modes
|
|
34
|
+
modes={[
|
|
35
|
+
{ id: "brainstorm", name: "Brainstorm", icon: <Lightbulb />, description: "Explore several possible directions." },
|
|
36
|
+
{ id: "draft", name: "Draft", icon: <NotebookPen />, description: "Write a first version you can edit." },
|
|
37
|
+
{ id: "review", name: "Review", icon: <Eye />, description: "Check existing work for gaps and risks." },
|
|
38
|
+
{ id: "plan", name: "Plan", icon: <Flag />, description: "Break the work into steps with owners and dates." },
|
|
39
|
+
]}
|
|
40
|
+
onSubmit={(text, { mode }) => send(text, { mode: mode?.id })}
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`sendLabel` is accepted for API parity; the send button is named by `Md3AgentComposer` ("Send").
|
|
45
|
+
|
|
46
|
+
Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
|
|
47
|
+
and the Tailwind preset from `@nucleux/tokens/preset`.
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT © Nucleux
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var lucideReact = require('lucide-react');
|
|
6
|
+
var utils = require('@nucleux/utils');
|
|
7
|
+
var modes = require('@nucleux/modes');
|
|
8
|
+
var md3OpenInput = require('@nucleux/md3-open-input');
|
|
9
|
+
var md3AgentComposer = require('@nucleux/md3-agent-composer');
|
|
10
|
+
var md3Button = require('@nucleux/md3-button');
|
|
11
|
+
var md3Chip = require('@nucleux/md3-chip');
|
|
12
|
+
var md3IconButton = require('@nucleux/md3-icon-button');
|
|
13
|
+
var md3Menu = require('@nucleux/md3-menu');
|
|
14
|
+
var md3SegmentedButton = require('@nucleux/md3-segmented-button');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
|
|
17
|
+
function _interopNamespace(e) {
|
|
18
|
+
if (e && e.__esModule) return e;
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
Object.keys(e).forEach(function (k) {
|
|
22
|
+
if (k !== 'default') {
|
|
23
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
24
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return e[k]; }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
n.default = e;
|
|
32
|
+
return Object.freeze(n);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
36
|
+
|
|
37
|
+
// src/index.tsx
|
|
38
|
+
var stateLayer = "before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:content-[''] hover:before:opacity-[0.08] focus-visible:before:opacity-[0.12] active:before:opacity-[0.12] motion-reduce:before:transition-none";
|
|
39
|
+
var Md3ModesSegmented = React__namespace.forwardRef(
|
|
40
|
+
({ modes: modes$1, value, onSelect, label = "Mode", className, ...props }, ref) => {
|
|
41
|
+
const roving = modes.useModesRoving(modes$1, value);
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
43
|
+
md3SegmentedButton.Md3SegmentedButton,
|
|
44
|
+
{
|
|
45
|
+
ref,
|
|
46
|
+
role: "radiogroup",
|
|
47
|
+
"aria-label": label,
|
|
48
|
+
value: value ?? "",
|
|
49
|
+
className: utils.cn("divide-md-outline-variant border-md-outline-variant", className),
|
|
50
|
+
...props,
|
|
51
|
+
children: modes$1.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
52
|
+
md3SegmentedButton.Md3SegmentedButtonItem,
|
|
53
|
+
{
|
|
54
|
+
value: m.id,
|
|
55
|
+
icon: m.icon,
|
|
56
|
+
role: "radio",
|
|
57
|
+
"aria-checked": m.id === value,
|
|
58
|
+
"aria-pressed": void 0,
|
|
59
|
+
"aria-disabled": m.unavailable ? true : void 0,
|
|
60
|
+
title: m.unavailable,
|
|
61
|
+
...roving.getItemProps(i),
|
|
62
|
+
onClick: () => onSelect(m.id),
|
|
63
|
+
className: utils.cn("min-w-[5.5rem] motion-reduce:transition-none", m.unavailable && "cursor-not-allowed opacity-[0.38]"),
|
|
64
|
+
children: m.shortName ?? m.name
|
|
65
|
+
},
|
|
66
|
+
m.id
|
|
67
|
+
))
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
Md3ModesSegmented.displayName = "Md3ModesSegmented";
|
|
73
|
+
var Md3ModesList = React__namespace.forwardRef(
|
|
74
|
+
({ modes: modes$1, value, onSelect, label = "Mode", showDescriptions = true, framed = true, className, ...props }, ref) => {
|
|
75
|
+
const roving = modes.useModesRoving(modes$1, value);
|
|
76
|
+
const baseId = React__namespace.useId();
|
|
77
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
ref,
|
|
81
|
+
role: "radiogroup",
|
|
82
|
+
"aria-label": label,
|
|
83
|
+
className: utils.cn(
|
|
84
|
+
"flex flex-col gap-0.5",
|
|
85
|
+
framed && "rounded-md-lg border border-md-outline-variant bg-md-surface p-2",
|
|
86
|
+
className
|
|
87
|
+
),
|
|
88
|
+
...props,
|
|
89
|
+
children: modes$1.map((m, i) => {
|
|
90
|
+
const on = m.id === value;
|
|
91
|
+
const support = modes.modeSupportingText(m, showDescriptions);
|
|
92
|
+
const descId = `${baseId}-${i}`;
|
|
93
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
94
|
+
"button",
|
|
95
|
+
{
|
|
96
|
+
type: "button",
|
|
97
|
+
role: "radio",
|
|
98
|
+
"aria-checked": on,
|
|
99
|
+
"aria-disabled": m.unavailable ? true : void 0,
|
|
100
|
+
"aria-labelledby": `${descId}-n`,
|
|
101
|
+
"aria-describedby": support || m.unavailable ? descId : void 0,
|
|
102
|
+
...roving.getItemProps(i),
|
|
103
|
+
onClick: () => onSelect(m.id),
|
|
104
|
+
className: utils.cn(
|
|
105
|
+
"relative flex min-h-14 w-full items-center gap-3 overflow-hidden rounded-md-md px-3 py-2.5 text-left transition-colors motion-reduce:transition-none",
|
|
106
|
+
stateLayer,
|
|
107
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-md-primary",
|
|
108
|
+
on ? "bg-md-secondary-container text-md-on-secondary-container" : "text-md-on-surface",
|
|
109
|
+
m.unavailable && "cursor-not-allowed"
|
|
110
|
+
),
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
113
|
+
"span",
|
|
114
|
+
{
|
|
115
|
+
"aria-hidden": "true",
|
|
116
|
+
className: utils.cn(
|
|
117
|
+
"relative grid size-10 shrink-0 place-items-center rounded-md-md text-base [&_svg]:size-[22px]",
|
|
118
|
+
on ? "bg-md-primary text-md-on-primary" : "bg-md-surface-container-high text-md-on-surface-variant",
|
|
119
|
+
m.unavailable && "opacity-[0.55]"
|
|
120
|
+
),
|
|
121
|
+
children: m.icon
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { id: `${descId}-n`, className: utils.cn("text-sm font-medium leading-5", m.unavailable && "opacity-[0.55]"), children: m.name }),
|
|
126
|
+
(support || m.unavailable) && /* @__PURE__ */ jsxRuntime.jsxs("span", { id: descId, className: "flex flex-col gap-0.5 text-xs leading-[18px]", children: [
|
|
127
|
+
support && /* @__PURE__ */ jsxRuntime.jsx("span", { className: utils.cn(on ? "text-current" : "text-md-on-surface-variant", m.unavailable && "opacity-[0.55]"), children: support }),
|
|
128
|
+
m.unavailable && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1 text-md-on-surface", children: [
|
|
129
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { "aria-hidden": "true", className: "size-3.5 shrink-0" }),
|
|
130
|
+
m.unavailable
|
|
131
|
+
] })
|
|
132
|
+
] })
|
|
133
|
+
] }),
|
|
134
|
+
on && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { "aria-hidden": "true", className: "relative size-[22px] shrink-0 text-md-on-secondary-container" })
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
m.id
|
|
138
|
+
);
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
Md3ModesList.displayName = "Md3ModesList";
|
|
145
|
+
var Md3ModesChip = React__namespace.forwardRef(
|
|
146
|
+
({ mode, label = "Mode", open = false, onRemove, className, ...props }, ref) => {
|
|
147
|
+
const chevron = /* @__PURE__ */ jsxRuntime.jsx(
|
|
148
|
+
lucideReact.ChevronDown,
|
|
149
|
+
{
|
|
150
|
+
"aria-hidden": "true",
|
|
151
|
+
className: utils.cn("relative -mr-1 size-[18px] transition-transform motion-reduce:transition-none", open && "rotate-180")
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
if (!mode) {
|
|
155
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
156
|
+
md3Chip.Md3Chip,
|
|
157
|
+
{
|
|
158
|
+
ref,
|
|
159
|
+
variant: "assist",
|
|
160
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SlidersHorizontal, { "aria-hidden": "true" }),
|
|
161
|
+
"aria-haspopup": "dialog",
|
|
162
|
+
"aria-expanded": open,
|
|
163
|
+
"aria-label": modes.modesLabels.chip(label, null),
|
|
164
|
+
className: utils.cn("shrink-0 border-md-outline-variant font-normal [&_svg]:size-4", open && "border-md-primary", className),
|
|
165
|
+
...props,
|
|
166
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
167
|
+
label,
|
|
168
|
+
chevron
|
|
169
|
+
] })
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
174
|
+
"span",
|
|
175
|
+
{
|
|
176
|
+
className: utils.cn(
|
|
177
|
+
"inline-flex h-8 shrink-0 items-center rounded-md-sm bg-md-secondary-container text-md-on-secondary-container animate-nx-fade-in motion-reduce:animate-none",
|
|
178
|
+
className
|
|
179
|
+
),
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
182
|
+
md3Chip.Md3Chip,
|
|
183
|
+
{
|
|
184
|
+
ref,
|
|
185
|
+
variant: "assist",
|
|
186
|
+
selected: true,
|
|
187
|
+
icon: mode.icon,
|
|
188
|
+
"aria-haspopup": "dialog",
|
|
189
|
+
"aria-expanded": open,
|
|
190
|
+
"aria-label": modes.modesLabels.chip(label, mode),
|
|
191
|
+
className: utils.cn("bg-transparent pl-2 font-normal [&_svg]:size-4", onRemove ? "rounded-r-none pr-1.5" : "pr-2.5"),
|
|
192
|
+
...props,
|
|
193
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
|
|
195
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "max-w-[18ch] truncate font-semibold", children: mode.shortName ?? mode.name }),
|
|
196
|
+
chevron
|
|
197
|
+
] })
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
201
|
+
md3IconButton.Md3IconButton,
|
|
202
|
+
{
|
|
203
|
+
"aria-label": modes.modesLabels.remove(label, mode),
|
|
204
|
+
onClick: onRemove,
|
|
205
|
+
className: "h-8 w-7 rounded-none rounded-r-md-sm pr-1 text-current focus-visible:ring-offset-0 [&_svg]:size-3.5",
|
|
206
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": "true" })
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
Md3ModesChip.displayName = "Md3ModesChip";
|
|
215
|
+
var Md3ModesPicker = React__namespace.forwardRef(
|
|
216
|
+
({
|
|
217
|
+
modes: modes$1,
|
|
218
|
+
value,
|
|
219
|
+
onSelect,
|
|
220
|
+
onClear,
|
|
221
|
+
onClose,
|
|
222
|
+
label = "Mode",
|
|
223
|
+
description = "How the agent approaches this request. Model and effort stay as they are.",
|
|
224
|
+
rejected,
|
|
225
|
+
showDescriptions = true,
|
|
226
|
+
autoFocus = false,
|
|
227
|
+
showClose = false,
|
|
228
|
+
className,
|
|
229
|
+
onKeyDown,
|
|
230
|
+
...props
|
|
231
|
+
}, ref) => {
|
|
232
|
+
const listRef = React__namespace.useRef(null);
|
|
233
|
+
React__namespace.useEffect(() => {
|
|
234
|
+
if (!autoFocus) return;
|
|
235
|
+
const el = listRef.current?.querySelector('[role="radio"][aria-checked="true"]') ?? listRef.current?.querySelector('[role="radio"]');
|
|
236
|
+
el?.focus();
|
|
237
|
+
}, [autoFocus]);
|
|
238
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
239
|
+
md3Menu.Md3Menu,
|
|
240
|
+
{
|
|
241
|
+
ref,
|
|
242
|
+
role: "dialog",
|
|
243
|
+
"aria-label": modes.modesLabels.picker(label),
|
|
244
|
+
className: utils.cn(
|
|
245
|
+
"min-w-[18rem] rounded-md-lg border border-md-outline-variant bg-md-surface p-2 shadow-md-2 animate-nx-fade-in motion-reduce:animate-none",
|
|
246
|
+
className
|
|
247
|
+
),
|
|
248
|
+
onKeyDown: (e) => {
|
|
249
|
+
onKeyDown?.(e);
|
|
250
|
+
if (e.key === "Escape") {
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
e.stopPropagation();
|
|
253
|
+
onClose?.();
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
...props,
|
|
257
|
+
children: [
|
|
258
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: utils.cn("relative flex flex-col gap-0.5 px-3 pb-2 pt-2.5", showClose && "pr-12"), children: [
|
|
259
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base font-medium leading-6 text-md-on-surface", children: label }),
|
|
260
|
+
description != null && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-[18px] text-md-on-surface-variant", children: description }),
|
|
261
|
+
showClose && /* @__PURE__ */ jsxRuntime.jsx(md3IconButton.Md3IconButton, { "aria-label": modes.modesLabels.close, onClick: onClose, className: "absolute right-0 top-0", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": "true" }) })
|
|
262
|
+
] }),
|
|
263
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
264
|
+
Md3ModesList,
|
|
265
|
+
{
|
|
266
|
+
ref: listRef,
|
|
267
|
+
modes: modes$1,
|
|
268
|
+
value,
|
|
269
|
+
onSelect,
|
|
270
|
+
label,
|
|
271
|
+
framed: false,
|
|
272
|
+
showDescriptions
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
rejected && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
276
|
+
"p",
|
|
277
|
+
{
|
|
278
|
+
role: "alert",
|
|
279
|
+
className: "mx-2 mb-1 mt-2 flex items-center gap-2 rounded-md-md bg-md-error-container px-3 py-2 text-[13px] leading-5 text-md-on-error-container",
|
|
280
|
+
children: [
|
|
281
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { "aria-hidden": "true", className: "size-[18px] shrink-0" }),
|
|
282
|
+
modes.modesLabels.unavailable(rejected)
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
onClear && value != null && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-1 mt-1.5", children: /* @__PURE__ */ jsxRuntime.jsx(md3Button.Md3Button, { variant: "text", onClick: onClear, children: modes.modesLabels.clear }) })
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
Md3ModesPicker.displayName = "Md3ModesPicker";
|
|
293
|
+
var Md3ModesNote = React__namespace.forwardRef(
|
|
294
|
+
({ onUndo, className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
295
|
+
"div",
|
|
296
|
+
{
|
|
297
|
+
ref,
|
|
298
|
+
className: utils.cn(
|
|
299
|
+
"flex items-center gap-2 px-2 text-[13px] leading-5 text-md-on-surface-variant animate-nx-fade-in motion-reduce:animate-none",
|
|
300
|
+
className
|
|
301
|
+
),
|
|
302
|
+
...props,
|
|
303
|
+
children: [
|
|
304
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { "aria-hidden": "true", className: "size-[18px] shrink-0 text-md-primary" }),
|
|
305
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1", children }),
|
|
306
|
+
onUndo && /* @__PURE__ */ jsxRuntime.jsx(md3Button.Md3Button, { variant: "text", onClick: onUndo, className: "h-8 px-2", children: modes.modesLabels.undo })
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
);
|
|
311
|
+
Md3ModesNote.displayName = "Md3ModesNote";
|
|
312
|
+
var Md3Modes = React__namespace.forwardRef(
|
|
313
|
+
({
|
|
314
|
+
modes: modes$1,
|
|
315
|
+
value,
|
|
316
|
+
defaultValue,
|
|
317
|
+
onValueChange,
|
|
318
|
+
variant = "composer",
|
|
319
|
+
open,
|
|
320
|
+
defaultOpen,
|
|
321
|
+
onOpenChange,
|
|
322
|
+
clearable = true,
|
|
323
|
+
showDescriptions = true,
|
|
324
|
+
label = "Mode",
|
|
325
|
+
pickerDescription,
|
|
326
|
+
defaultNotice,
|
|
327
|
+
onUnavailable,
|
|
328
|
+
draft: draftProp,
|
|
329
|
+
defaultDraft = "",
|
|
330
|
+
onDraftChange,
|
|
331
|
+
onSubmit,
|
|
332
|
+
placeholder = "Ask Aria\u2026",
|
|
333
|
+
composerLeading,
|
|
334
|
+
composerActions,
|
|
335
|
+
sendLabel: _sendLabel,
|
|
336
|
+
trigger = "chip",
|
|
337
|
+
settingsItems,
|
|
338
|
+
onSettingsSelect,
|
|
339
|
+
className,
|
|
340
|
+
...props
|
|
341
|
+
}, ref) => {
|
|
342
|
+
const s = modes.useModes({
|
|
343
|
+
modes: modes$1,
|
|
344
|
+
value,
|
|
345
|
+
defaultValue,
|
|
346
|
+
onValueChange,
|
|
347
|
+
open,
|
|
348
|
+
defaultOpen,
|
|
349
|
+
onOpenChange,
|
|
350
|
+
defaultNotice,
|
|
351
|
+
onUnavailable
|
|
352
|
+
});
|
|
353
|
+
const [internalDraft, setInternalDraft] = React__namespace.useState(defaultDraft);
|
|
354
|
+
const draft = draftProp ?? internalDraft;
|
|
355
|
+
const setDraft = (t) => {
|
|
356
|
+
if (draftProp === void 0) setInternalDraft(t);
|
|
357
|
+
onDraftChange?.(t);
|
|
358
|
+
};
|
|
359
|
+
const chipRef = React__namespace.useRef(null);
|
|
360
|
+
const chipBoxRef = React__namespace.useRef(null);
|
|
361
|
+
const pickerRef = React__namespace.useRef(null);
|
|
362
|
+
const [userOpened, setUserOpened] = React__namespace.useState(false);
|
|
363
|
+
modes.useModesDismiss([chipBoxRef, pickerRef], s.open, () => s.setOpen(false));
|
|
364
|
+
const [refocus, setRefocus] = React__namespace.useState(0);
|
|
365
|
+
React__namespace.useEffect(() => {
|
|
366
|
+
if (refocus) chipRef.current?.focus();
|
|
367
|
+
}, [refocus]);
|
|
368
|
+
const choose = (id) => {
|
|
369
|
+
const m = modes$1.find((x) => x.id === id);
|
|
370
|
+
const wasOpen = s.open;
|
|
371
|
+
s.select(id);
|
|
372
|
+
if (wasOpen && m && !m.unavailable) setRefocus((n) => n + 1);
|
|
373
|
+
};
|
|
374
|
+
const clearMode = () => {
|
|
375
|
+
s.clear();
|
|
376
|
+
setRefocus((n) => n + 1);
|
|
377
|
+
};
|
|
378
|
+
const undoChange = () => {
|
|
379
|
+
s.undo();
|
|
380
|
+
setRefocus((n) => n + 1);
|
|
381
|
+
};
|
|
382
|
+
const closePicker = () => {
|
|
383
|
+
s.setOpen(false);
|
|
384
|
+
setRefocus((n) => n + 1);
|
|
385
|
+
};
|
|
386
|
+
const notice = s.notice;
|
|
387
|
+
const rejected = notice?.type === "unavailable" ? modes$1.find((m) => m.id === notice.id) ?? null : null;
|
|
388
|
+
const changedTo = notice?.type === "changed" ? s.mode : null;
|
|
389
|
+
const note = changedTo ? /* @__PURE__ */ jsxRuntime.jsx(Md3ModesNote, { onUndo: undoChange, children: modes.modesLabels.changed(changedTo) }) : null;
|
|
390
|
+
const inlineAlert = rejected && !s.open ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
391
|
+
"p",
|
|
392
|
+
{
|
|
393
|
+
role: "alert",
|
|
394
|
+
className: "flex items-center gap-2 rounded-md-md bg-md-error-container px-3 py-2 text-[13px] leading-5 text-md-on-error-container",
|
|
395
|
+
children: [
|
|
396
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { "aria-hidden": "true", className: "size-[18px] shrink-0" }),
|
|
397
|
+
modes.modesLabels.unavailable(rejected)
|
|
398
|
+
]
|
|
399
|
+
}
|
|
400
|
+
) : null;
|
|
401
|
+
const chip = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: chipBoxRef, className: "inline-flex", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
402
|
+
Md3ModesChip,
|
|
403
|
+
{
|
|
404
|
+
ref: chipRef,
|
|
405
|
+
mode: s.mode,
|
|
406
|
+
label,
|
|
407
|
+
open: s.open,
|
|
408
|
+
onClick: () => {
|
|
409
|
+
setUserOpened(!s.open);
|
|
410
|
+
s.setOpen(!s.open);
|
|
411
|
+
},
|
|
412
|
+
onRemove: clearable ? clearMode : void 0
|
|
413
|
+
}
|
|
414
|
+
) });
|
|
415
|
+
const settings = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: chipBoxRef, className: "inline-flex", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
416
|
+
md3OpenInput.Md3RequestSettings,
|
|
417
|
+
{
|
|
418
|
+
ref: chipRef,
|
|
419
|
+
items: md3OpenInput.mergeRequestSettingsItems(modes.modesSettingsItem(label, s.mode, /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SlidersHorizontal, {})), settingsItems),
|
|
420
|
+
onSelect: (id) => {
|
|
421
|
+
if (id !== "mode") return onSettingsSelect?.(id);
|
|
422
|
+
setUserOpened(true);
|
|
423
|
+
s.setOpen(true);
|
|
424
|
+
},
|
|
425
|
+
onOpenChange: (o) => {
|
|
426
|
+
if (o && s.open) s.setOpen(false);
|
|
427
|
+
},
|
|
428
|
+
className: variant === "composer" ? "static [&>[role=menu]]:left-10" : void 0
|
|
429
|
+
}
|
|
430
|
+
) });
|
|
431
|
+
const control = trigger === "settings" ? settings : chip;
|
|
432
|
+
const picker = s.open ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
433
|
+
Md3ModesPicker,
|
|
434
|
+
{
|
|
435
|
+
ref: pickerRef,
|
|
436
|
+
modes: modes$1,
|
|
437
|
+
value: s.value,
|
|
438
|
+
onSelect: choose,
|
|
439
|
+
onClear: clearable ? clearMode : void 0,
|
|
440
|
+
onClose: closePicker,
|
|
441
|
+
label,
|
|
442
|
+
description: pickerDescription,
|
|
443
|
+
rejected,
|
|
444
|
+
showDescriptions,
|
|
445
|
+
autoFocus: userOpened,
|
|
446
|
+
showClose: trigger === "settings",
|
|
447
|
+
className: utils.cn(
|
|
448
|
+
"absolute z-50",
|
|
449
|
+
variant === "chip" ? "bottom-full left-0 mb-2 w-[22rem]" : "inset-x-0 bottom-full mb-2"
|
|
450
|
+
)
|
|
451
|
+
}
|
|
452
|
+
) : null;
|
|
453
|
+
const live = /* @__PURE__ */ jsxRuntime.jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: s.announcement });
|
|
454
|
+
if (variant === "segmented" || variant === "list") {
|
|
455
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: utils.cn("flex flex-col gap-2", variant === "segmented" && "items-start", className), ...props, children: [
|
|
456
|
+
variant === "segmented" ? /* @__PURE__ */ jsxRuntime.jsx(Md3ModesSegmented, { modes: modes$1, value: s.value, onSelect: s.select, label }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
457
|
+
Md3ModesList,
|
|
458
|
+
{
|
|
459
|
+
modes: modes$1,
|
|
460
|
+
value: s.value,
|
|
461
|
+
onSelect: s.select,
|
|
462
|
+
label,
|
|
463
|
+
showDescriptions,
|
|
464
|
+
className: "w-full max-w-[30rem]"
|
|
465
|
+
}
|
|
466
|
+
),
|
|
467
|
+
inlineAlert,
|
|
468
|
+
note,
|
|
469
|
+
live
|
|
470
|
+
] });
|
|
471
|
+
}
|
|
472
|
+
if (variant === "chip") {
|
|
473
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: utils.cn("relative inline-flex flex-col items-start gap-2", className), ...props, children: [
|
|
474
|
+
control,
|
|
475
|
+
picker,
|
|
476
|
+
note,
|
|
477
|
+
live
|
|
478
|
+
] });
|
|
479
|
+
}
|
|
480
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: utils.cn("relative flex w-full max-w-[38rem] flex-col gap-2", className), ...props, children: [
|
|
481
|
+
picker,
|
|
482
|
+
note,
|
|
483
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
484
|
+
md3AgentComposer.Md3AgentComposer,
|
|
485
|
+
{
|
|
486
|
+
value: draft,
|
|
487
|
+
onValueChange: setDraft,
|
|
488
|
+
onSubmit: (text) => {
|
|
489
|
+
onSubmit?.(text, { mode: s.mode });
|
|
490
|
+
s.dismissNotice();
|
|
491
|
+
if (draftProp === void 0) setInternalDraft("");
|
|
492
|
+
},
|
|
493
|
+
placeholder,
|
|
494
|
+
leftActions: trigger === "settings" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
495
|
+
composerLeading,
|
|
496
|
+
settings
|
|
497
|
+
] }) : composerLeading,
|
|
498
|
+
rightActions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
499
|
+
trigger === "chip" && chip,
|
|
500
|
+
composerActions
|
|
501
|
+
] }),
|
|
502
|
+
className: utils.cn(
|
|
503
|
+
"relative gap-2 rounded-md-xl border border-md-outline-variant bg-md-surface px-4 pb-2.5 pt-4 shadow-md-1"
|
|
504
|
+
)
|
|
505
|
+
}
|
|
506
|
+
),
|
|
507
|
+
live
|
|
508
|
+
] });
|
|
509
|
+
}
|
|
510
|
+
);
|
|
511
|
+
Md3Modes.displayName = "Md3Modes";
|
|
512
|
+
|
|
513
|
+
exports.Md3Modes = Md3Modes;
|
|
514
|
+
exports.Md3ModesChip = Md3ModesChip;
|
|
515
|
+
exports.Md3ModesList = Md3ModesList;
|
|
516
|
+
exports.Md3ModesNote = Md3ModesNote;
|
|
517
|
+
exports.Md3ModesPicker = Md3ModesPicker;
|
|
518
|
+
exports.Md3ModesSegmented = Md3ModesSegmented;
|
|
519
|
+
//# sourceMappingURL=index.cjs.map
|
|
520
|
+
//# sourceMappingURL=index.cjs.map
|