@dinachi/cli 0.11.0 → 1.0.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/CHANGELOG.md +146 -0
- package/dist/index.js +74 -8
- package/package.json +2 -2
- package/templates/accordion/accordion.tsx +66 -12
- package/templates/agent/agent.tsx +1865 -0
- package/templates/agent/index.ts +52 -0
- package/templates/alert-dialog/alert-dialog.tsx +46 -17
- package/templates/alert-dialog/index.ts +2 -0
- package/templates/animated-tabs/animated-tabs.tsx +65 -5
- package/templates/autocomplete/autocomplete.tsx +174 -18
- package/templates/avatar/avatar.tsx +5 -2
- package/templates/carousel/carousel.tsx +102 -24
- package/templates/checkbox/checkbox.tsx +60 -4
- package/templates/checkbox-group/checkbox-group.tsx +82 -8
- package/templates/collapsible/collapsible.tsx +13 -4
- package/templates/combobox/combobox.tsx +299 -23
- package/templates/combobox/index.ts +1 -0
- package/templates/compare-slider/compare-slider.tsx +103 -28
- package/templates/compare-slider/index.ts +1 -1
- package/templates/context-menu/context-menu.tsx +37 -15
- package/templates/dialog/dialog.tsx +41 -12
- package/templates/drawer/drawer.tsx +18 -3
- package/templates/expandable-card/expandable-card.tsx +65 -42
- package/templates/field/field.tsx +2 -0
- package/templates/hold-to-confirm/hold-to-confirm.tsx +99 -16
- package/templates/hold-to-confirm/index.ts +1 -1
- package/templates/input/input.tsx +59 -1
- package/templates/menu/index.ts +5 -0
- package/templates/menu/menu.tsx +105 -10
- package/templates/menubar/menubar.tsx +26 -8
- package/templates/navigation-menu/navigation-menu.tsx +67 -23
- package/templates/number-field/index.ts +1 -0
- package/templates/number-field/number-field.tsx +71 -2
- package/templates/otp-field/otp-field.tsx +57 -11
- package/templates/popover/popover.tsx +18 -3
- package/templates/preview-card/preview-card.tsx +16 -2
- package/templates/radio/radio.tsx +71 -6
- package/templates/select/select.tsx +223 -10
- package/templates/slider/slider.tsx +77 -8
- package/templates/sortable/sortable.tsx +76 -9
- package/templates/swipeable-row/index.ts +1 -1
- package/templates/swipeable-row/swipeable-row.tsx +125 -41
- package/templates/switch/switch.tsx +41 -4
- package/templates/tabs/tabs.tsx +74 -10
- package/templates/textarea/index.ts +1 -1
- package/templates/textarea/textarea.tsx +70 -4
- package/templates/toast/toast.tsx +3 -1
- package/templates/toggle/toggle.tsx +39 -7
- package/templates/toggle-group/toggle-group.tsx +96 -18
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,149 @@ All notable changes to `@dinachi/cli` will be documented in this file.
|
|
|
5
5
|
The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.0.0] - 2026-11-15
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Agent**: `dinachi add agent` installs a bridge that lets an AI agent read and
|
|
15
|
+
operate the page (`snapshot`, `query`, `act`), with an `allow` gate and
|
|
16
|
+
WebMCP registration. Inside `AgentProvider`, Input, Select and Dialog register
|
|
17
|
+
their state and actions directly; everything else is reached through the
|
|
18
|
+
accessibility tree.
|
|
19
|
+
- **Agent**: Textarea, OTPField, NumberField, Slider, CompareSlider, Combobox,
|
|
20
|
+
Autocomplete, Checkbox, CheckboxGroup, RadioGroup, Switch, Toggle and ToggleGroup
|
|
21
|
+
register with the bridge. Each change goes through the component's own callback
|
|
22
|
+
with details the app can cancel. Choices match by label, then by value.
|
|
23
|
+
- **Agent**: a control inside a Field reports the Field's error, and `in` names the
|
|
24
|
+
Fieldset or Form around it. An agent's change to an Input is a real input event,
|
|
25
|
+
so `onChange` and the Field's dirty and filled state see it.
|
|
26
|
+
- **Agent**: `data-agent-part` marks an element that belongs to a registered
|
|
27
|
+
control, so it is not listed twice. `useAgentItem`, `agentChoicesOf` and
|
|
28
|
+
`AgentGroupContext` let a group component register its items.
|
|
29
|
+
- **Agent**: a Slider or NumberField change by an agent also calls
|
|
30
|
+
`onValueCommitted`, and lands on the step without float drift (`agentRound`).
|
|
31
|
+
A refused change leaves Input and Textarea untouched, and a Combobox or
|
|
32
|
+
Autocomplete the agent opened closes again.
|
|
33
|
+
- **Agent**: OTPField reports one redacted value, and a masked field is secret
|
|
34
|
+
whatever its `autoComplete`.
|
|
35
|
+
- **Agent**: AlertDialog, Drawer, Popover, PreviewCard, Collapsible, Accordion,
|
|
36
|
+
ExpandableCard, Menu, ContextMenu, Menubar and NavigationMenu register with the
|
|
37
|
+
bridge, each as one control with `open` and `close`. Menu items take `press`, and
|
|
38
|
+
`setChecked` when they can be checked. A popup with no title of its own goes by
|
|
39
|
+
its trigger's name.
|
|
40
|
+
- **Agent**: Tabs, AnimatedTabs, Carousel (`goTo`), Sortable (`move`), SwipeableRow
|
|
41
|
+
and HoldToConfirm register with the bridge. A HoldToConfirm press completes the
|
|
42
|
+
hold at once and needs a person's approval by default. Plain links (`a[href]`)
|
|
43
|
+
are listed as `link`, with their href as the value.
|
|
44
|
+
- **Agent**: progress bars and meters, including Progress, ProgressRing and Meter,
|
|
45
|
+
are read with `value`, `min` and `max`. A Toast is listed as `toast` with its
|
|
46
|
+
description and `type`, and `dismiss` presses its close button, which
|
|
47
|
+
`data-agent-dismiss` marks. A high-priority toast is listed too, though Base UI
|
|
48
|
+
hides it from assistive tech until focused.
|
|
49
|
+
- **Carousel**: `onIndexChange` also receives cancelable `details` with a `reason`,
|
|
50
|
+
and a `disabled` prop turns off the drag, arrows and dots.
|
|
51
|
+
- **Sortable**: `onValueChange` also receives `details` with a `reason`, and a
|
|
52
|
+
`disabled` prop turns off the handles. It stays controlled: refuse a move by not
|
|
53
|
+
applying `next`.
|
|
54
|
+
- **SwipeableRow**: `onSelect` and `onDismiss` receive cancelable `details`, and an
|
|
55
|
+
action can be `disabled`.
|
|
56
|
+
- **HoldToConfirm**: `onConfirm` receives `details`; `details.cancel()` unwinds
|
|
57
|
+
the hold.
|
|
58
|
+
- **ExpandableCard**: `onOpenChange` also receives `details` with a `reason`, and
|
|
59
|
+
`details.cancel()` keeps the card as it was.
|
|
60
|
+
- **Textarea**: `onValueChange(value, details)`, which an agent's change goes through.
|
|
61
|
+
- **CompareSlider**: a `disabled` prop. `onPositionChange` also receives `details`
|
|
62
|
+
with a `reason`, and `details.cancel()` puts the divider back.
|
|
63
|
+
- **Agent**: `useAgentAction` exposes an app action (`inviteMember`, `archiveProject`)
|
|
64
|
+
whose `input` is any Standard Schema that can describe itself as JSON Schema
|
|
65
|
+
(zod 4.2+, arktype 2.1.28+, or valibot wrapped in `toStandardJsonSchema`).
|
|
66
|
+
Pass `element` to tie it to a card or row, so the same action on many items has
|
|
67
|
+
one target each. Each action is its own tool by default, in `agentToolsFor` and
|
|
68
|
+
in WebMCP; `{ actions: "act" }` keeps them behind `act`. The bridge installs no
|
|
69
|
+
packages.
|
|
70
|
+
- **Agent**: snapshots report where a control sits (`in`), whether it is required
|
|
71
|
+
or invalid with its error text, number and slider bounds, and every choice of a
|
|
72
|
+
closed Select. Dialogs come first, and an open modal hides the page behind it.
|
|
73
|
+
Long values and lists are cut short and say so.
|
|
74
|
+
- **Agent**: `confirm` and `data-agent-confirm` mark a step that needs a person.
|
|
75
|
+
Each entry's `approval` says whether the app will ask (`allow` is set) or only
|
|
76
|
+
the person can do it. Controls inside an alert dialog need approval by default;
|
|
77
|
+
`data-agent-confirm="none"` lifts it.
|
|
78
|
+
- **Agent**: `agent.subscribe` reports when app actions mount or unmount.
|
|
79
|
+
- `add --v1` installs a component as it was before agent registration, by
|
|
80
|
+
running `@dinachi/cli@0.12.0`. It stays frozen there, is deprecated in 1.1 and
|
|
81
|
+
removed in 1.2.
|
|
82
|
+
- **Docs**: an Agents guide, a Safety page and Recipes for Claude, OpenAI, the
|
|
83
|
+
Vercel AI SDK and WebMCP. Each component that registers, or is read from the
|
|
84
|
+
tree, says what the agent sees and can do on its own page.
|
|
85
|
+
|
|
86
|
+
### Changed
|
|
87
|
+
|
|
88
|
+
- **Input, Select, Dialog**: now depend on `agent` and install it alongside.
|
|
89
|
+
Outside `AgentProvider` they behave as before and render nothing extra. Inside
|
|
90
|
+
it, an agent can pick a Select choice by its label without opening it. `isAgentChange(details)` tells
|
|
91
|
+
an agent's change from a person's in `onValueChange` and `onOpenChange`.
|
|
92
|
+
- **AlertDialog, Drawer, Popover, PreviewCard, Collapsible, Accordion,
|
|
93
|
+
ExpandableCard, Menu, ContextMenu, Menubar, NavigationMenu, Tabs, AnimatedTabs,
|
|
94
|
+
Carousel, Sortable, SwipeableRow, HoldToConfirm**: now depend on
|
|
95
|
+
`agent` and install it alongside. Outside `AgentProvider` nothing changes.
|
|
96
|
+
- **Accordion, NavigationMenu**: an item with no `value` gets one from `useId`, so
|
|
97
|
+
the id `onValueChange` reports for it differs from Base UI's generated one.
|
|
98
|
+
- **ContextMenu**: inside `AgentProvider`, a disabled menu marks its trigger area
|
|
99
|
+
`data-disabled`.
|
|
100
|
+
- **AnimatedTabs**: `details.cancel()` in `onValueChange` now keeps the current tab
|
|
101
|
+
when uncontrolled.
|
|
102
|
+
- **Agent**: a `data-agent-confirm` on an ancestor now overrides a control's own
|
|
103
|
+
default approval, not only one on the element itself.
|
|
104
|
+
- **Agent**: text marked `aria-hidden` is left out of labels, so a decorative
|
|
105
|
+
glyph does not join a control's name.
|
|
106
|
+
- **JSON Render**: installs zod `^4.3.6`, the version the workspace tests against.
|
|
107
|
+
- Templates can import other components; `add` rewrites
|
|
108
|
+
`@/components/ui/<name>` to your configured `ui` alias.
|
|
109
|
+
|
|
110
|
+
### Fixed
|
|
111
|
+
|
|
112
|
+
- **Dialog, AlertDialog**: `DialogClose`, `AlertDialogAction` and
|
|
113
|
+
`AlertDialogCancel` applied their own styles over an element passed through
|
|
114
|
+
`render`, so `<DialogClose render={<Button />}>` lost the Button's variant. The
|
|
115
|
+
defaults now apply only without `render`.
|
|
116
|
+
- **Menu, ContextMenu, Menubar**: the popup's `z-50` never applied, so a sticky
|
|
117
|
+
header or other `z-50` layer painted over an open menu. It now sits on the
|
|
118
|
+
positioner.
|
|
119
|
+
- **AlertDialog**: the barrel exports `AlertDialogContent` and
|
|
120
|
+
`AlertDialogViewport`.
|
|
121
|
+
- **Toast**: an action's `onClick` ran twice per click. Base UI's `Toast.Action`
|
|
122
|
+
already applies `actionProps`, and the default list passed them again.
|
|
123
|
+
|
|
124
|
+
## [0.12.0] - 2026-10-09
|
|
125
|
+
|
|
126
|
+
### Added
|
|
127
|
+
|
|
128
|
+
- **Menu**: filtering. Wrap a menu in `MenuFilter`, add `MenuInput` (with
|
|
129
|
+
`MenuClear` inside it) to the popup, and put the items in `MenuList`.
|
|
130
|
+
`MenuEmpty` shows when nothing matches. A submenu takes its own
|
|
131
|
+
`MenuFilter`. Also works in a Menubar menu. Filtering is a Base UI preview
|
|
132
|
+
API and may change.
|
|
133
|
+
- **Avatar**: `keepMounted` on `AvatarImage` renders the image right away, for
|
|
134
|
+
`next/image` and `loading="lazy"`. The fallback shows beneath it until the
|
|
135
|
+
image loads, and stays if it fails.
|
|
136
|
+
- **Combobox**: `createComboboxItems` builds `items` from objects with
|
|
137
|
+
`getValue` and `getLabel`, so selection uses IDs while the list renders the
|
|
138
|
+
full objects.
|
|
139
|
+
|
|
140
|
+
### Changed
|
|
141
|
+
|
|
142
|
+
- `@base-ui/react` is now installed at `^1.9.0`, up from `^1.7.0`. It brings
|
|
143
|
+
fixes across Drawer swipes, Dialog and Popover outside clicks, Field
|
|
144
|
+
validation, and Select and Combobox `readOnly`.
|
|
145
|
+
- **Avatar**: the image and fallback are stacked in the same box, and the
|
|
146
|
+
image uses `object-cover`, so a non-square source crops instead of
|
|
147
|
+
stretching.
|
|
148
|
+
- **Collapsible**: with a native button, the trigger now gets the `disabled`
|
|
149
|
+
attribute instead of `aria-disabled` (a Base UI 1.9 change).
|
|
150
|
+
|
|
8
151
|
## [0.11.0] - 2026-08-10
|
|
9
152
|
|
|
10
153
|
### Added
|
|
@@ -184,5 +327,8 @@ Re-run `dinachi add select`, `dinachi add slider`, and `dinachi add otp-field`
|
|
|
184
327
|
See [git history](https://github.com/raymond-UI/dinachiUI/commits/main/packages/cli)
|
|
185
328
|
for changes prior to 0.9.0.
|
|
186
329
|
|
|
330
|
+
[1.0.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v1.0.0
|
|
331
|
+
[0.12.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v0.12.0
|
|
332
|
+
[0.11.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v0.11.0
|
|
187
333
|
[0.10.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v0.10.0
|
|
188
334
|
[0.9.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v0.9.0
|
package/dist/index.js
CHANGED
|
@@ -76,13 +76,21 @@ function getComponentRegistry() {
|
|
|
76
76
|
description: "A vertically stacked set of interactive headings that each reveal a section of content.",
|
|
77
77
|
files: [{ name: "accordion.tsx" }, { name: "index.ts" }],
|
|
78
78
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
79
|
+
componentDependencies: ["agent"],
|
|
79
80
|
utilityDependencies: ["cn"]
|
|
80
81
|
},
|
|
82
|
+
agent: {
|
|
83
|
+
name: "agent",
|
|
84
|
+
description: "Lets an AI agent read and operate the controls on a page and call actions the app offers, with a gate on every action and optional WebMCP tools.",
|
|
85
|
+
files: [{ name: "agent.tsx" }, { name: "index.ts" }],
|
|
86
|
+
dependencies: []
|
|
87
|
+
},
|
|
81
88
|
"alert-dialog": {
|
|
82
89
|
name: "alert-dialog",
|
|
83
90
|
description: "A modal dialog that interrupts the user with important content and expects a response.",
|
|
84
91
|
files: [{ name: "alert-dialog.tsx" }, { name: "index.ts" }],
|
|
85
92
|
dependencies: ["@base-ui/react"],
|
|
93
|
+
componentDependencies: ["agent"],
|
|
86
94
|
utilityDependencies: ["cn"]
|
|
87
95
|
},
|
|
88
96
|
autocomplete: {
|
|
@@ -90,6 +98,7 @@ function getComponentRegistry() {
|
|
|
90
98
|
description: "A text input with dynamic suggestions that helps users find and select values quickly.",
|
|
91
99
|
files: [{ name: "autocomplete.tsx" }, { name: "index.ts" }],
|
|
92
100
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
101
|
+
componentDependencies: ["agent"],
|
|
93
102
|
utilityDependencies: ["cn"]
|
|
94
103
|
},
|
|
95
104
|
avatar: {
|
|
@@ -125,6 +134,7 @@ function getComponentRegistry() {
|
|
|
125
134
|
description: "A control that allows the user to select one or more options from a set.",
|
|
126
135
|
files: [{ name: "checkbox.tsx" }, { name: "index.ts" }],
|
|
127
136
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
137
|
+
componentDependencies: ["agent"],
|
|
128
138
|
utilityDependencies: ["cn"]
|
|
129
139
|
},
|
|
130
140
|
"checkbox-group": {
|
|
@@ -132,7 +142,7 @@ function getComponentRegistry() {
|
|
|
132
142
|
description: "A group of checkboxes that share a common state.",
|
|
133
143
|
files: [{ name: "checkbox-group.tsx" }, { name: "index.ts" }],
|
|
134
144
|
dependencies: ["@base-ui/react"],
|
|
135
|
-
componentDependencies: ["checkbox"],
|
|
145
|
+
componentDependencies: ["agent", "checkbox"],
|
|
136
146
|
utilityDependencies: ["cn"]
|
|
137
147
|
},
|
|
138
148
|
collapsible: {
|
|
@@ -140,6 +150,7 @@ function getComponentRegistry() {
|
|
|
140
150
|
description: "A collapsible panel controlled by a button.",
|
|
141
151
|
files: [{ name: "collapsible.tsx" }, { name: "index.ts" }],
|
|
142
152
|
dependencies: ["@base-ui/react"],
|
|
153
|
+
componentDependencies: ["agent"],
|
|
143
154
|
utilityDependencies: ["cn"]
|
|
144
155
|
},
|
|
145
156
|
combobox: {
|
|
@@ -147,6 +158,7 @@ function getComponentRegistry() {
|
|
|
147
158
|
description: "A combobox that combines text input with a selectable popup list of options.",
|
|
148
159
|
files: [{ name: "combobox.tsx" }, { name: "index.ts" }],
|
|
149
160
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
161
|
+
componentDependencies: ["agent"],
|
|
150
162
|
utilityDependencies: ["cn"]
|
|
151
163
|
},
|
|
152
164
|
"context-menu": {
|
|
@@ -154,6 +166,7 @@ function getComponentRegistry() {
|
|
|
154
166
|
description: "A menu that appears at the pointer on right click or long press.",
|
|
155
167
|
files: [{ name: "context-menu.tsx" }, { name: "index.ts" }],
|
|
156
168
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
169
|
+
componentDependencies: ["agent"],
|
|
157
170
|
utilityDependencies: ["cn"]
|
|
158
171
|
},
|
|
159
172
|
dialog: {
|
|
@@ -161,6 +174,7 @@ function getComponentRegistry() {
|
|
|
161
174
|
description: "A popup that opens on top of the entire page, providing a modal interface for user interactions.",
|
|
162
175
|
files: [{ name: "dialog.tsx" }, { name: "index.ts" }],
|
|
163
176
|
dependencies: ["@base-ui/react"],
|
|
177
|
+
componentDependencies: ["agent"],
|
|
164
178
|
utilityDependencies: ["cn"]
|
|
165
179
|
},
|
|
166
180
|
drawer: {
|
|
@@ -168,6 +182,7 @@ function getComponentRegistry() {
|
|
|
168
182
|
description: "A panel that slides in from the edge of the screen for focused workflows.",
|
|
169
183
|
files: [{ name: "drawer.tsx" }, { name: "index.ts" }],
|
|
170
184
|
dependencies: ["@base-ui/react"],
|
|
185
|
+
componentDependencies: ["agent"],
|
|
171
186
|
utilityDependencies: ["cn"]
|
|
172
187
|
},
|
|
173
188
|
field: {
|
|
@@ -196,6 +211,7 @@ function getComponentRegistry() {
|
|
|
196
211
|
description: "A customizable input field component with variants and sizes.",
|
|
197
212
|
files: [{ name: "input.tsx" }, { name: "index.ts" }],
|
|
198
213
|
dependencies: ["@base-ui/react"],
|
|
214
|
+
componentDependencies: ["agent"],
|
|
199
215
|
utilityDependencies: ["cn"]
|
|
200
216
|
},
|
|
201
217
|
label: {
|
|
@@ -217,6 +233,7 @@ function getComponentRegistry() {
|
|
|
217
233
|
description: "A popup menu for actions and options triggered by a button.",
|
|
218
234
|
files: [{ name: "menu.tsx" }, { name: "index.ts" }],
|
|
219
235
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
236
|
+
componentDependencies: ["agent"],
|
|
220
237
|
utilityDependencies: ["cn"]
|
|
221
238
|
},
|
|
222
239
|
menubar: {
|
|
@@ -224,6 +241,7 @@ function getComponentRegistry() {
|
|
|
224
241
|
description: "A visually persistent menu common in desktop applications that provides access to a consistent set of commands.",
|
|
225
242
|
files: [{ name: "menubar.tsx" }, { name: "index.ts" }],
|
|
226
243
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
244
|
+
componentDependencies: ["agent"],
|
|
227
245
|
utilityDependencies: ["cn"]
|
|
228
246
|
},
|
|
229
247
|
meter: {
|
|
@@ -238,6 +256,7 @@ function getComponentRegistry() {
|
|
|
238
256
|
description: "A collection of links and menus for website navigation.",
|
|
239
257
|
files: [{ name: "navigation-menu.tsx" }, { name: "index.ts" }],
|
|
240
258
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
259
|
+
componentDependencies: ["agent"],
|
|
241
260
|
utilityDependencies: ["cn"]
|
|
242
261
|
},
|
|
243
262
|
"number-field": {
|
|
@@ -245,6 +264,7 @@ function getComponentRegistry() {
|
|
|
245
264
|
description: "A numeric input with increment, decrement, and optional scrubbing controls.",
|
|
246
265
|
files: [{ name: "number-field.tsx" }, { name: "index.ts" }],
|
|
247
266
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
267
|
+
componentDependencies: ["agent"],
|
|
248
268
|
utilityDependencies: ["cn"]
|
|
249
269
|
},
|
|
250
270
|
"otp-field": {
|
|
@@ -252,6 +272,7 @@ function getComponentRegistry() {
|
|
|
252
272
|
description: "A one-time password / verification code input with auto-focus, paste handling, and validation.",
|
|
253
273
|
files: [{ name: "otp-field.tsx" }, { name: "index.ts" }],
|
|
254
274
|
dependencies: ["@base-ui/react"],
|
|
275
|
+
componentDependencies: ["agent"],
|
|
255
276
|
utilityDependencies: ["cn"]
|
|
256
277
|
},
|
|
257
278
|
popover: {
|
|
@@ -259,6 +280,7 @@ function getComponentRegistry() {
|
|
|
259
280
|
description: "An anchored floating panel for contextual information and lightweight interactions.",
|
|
260
281
|
files: [{ name: "popover.tsx" }, { name: "index.ts" }],
|
|
261
282
|
dependencies: ["@base-ui/react"],
|
|
283
|
+
componentDependencies: ["agent"],
|
|
262
284
|
utilityDependencies: ["cn"]
|
|
263
285
|
},
|
|
264
286
|
"preview-card": {
|
|
@@ -266,6 +288,7 @@ function getComponentRegistry() {
|
|
|
266
288
|
description: "A popup that appears when a link is hovered, showing a preview for sighted users.",
|
|
267
289
|
files: [{ name: "preview-card.tsx" }, { name: "index.ts" }],
|
|
268
290
|
dependencies: ["@base-ui/react"],
|
|
291
|
+
componentDependencies: ["agent"],
|
|
269
292
|
utilityDependencies: ["cn"]
|
|
270
293
|
},
|
|
271
294
|
progress: {
|
|
@@ -280,6 +303,7 @@ function getComponentRegistry() {
|
|
|
280
303
|
description: "A radio input and group for selecting a single option from a set.",
|
|
281
304
|
files: [{ name: "radio.tsx" }, { name: "index.ts" }],
|
|
282
305
|
dependencies: ["@base-ui/react"],
|
|
306
|
+
componentDependencies: ["agent"],
|
|
283
307
|
utilityDependencies: ["cn"]
|
|
284
308
|
},
|
|
285
309
|
"scroll-area": {
|
|
@@ -294,6 +318,7 @@ function getComponentRegistry() {
|
|
|
294
318
|
description: "A common form component for choosing a predefined value in a dropdown menu.",
|
|
295
319
|
files: [{ name: "select.tsx" }, { name: "index.ts" }],
|
|
296
320
|
dependencies: ["@base-ui/react", "lucide-react"],
|
|
321
|
+
componentDependencies: ["agent"],
|
|
297
322
|
utilityDependencies: ["cn"]
|
|
298
323
|
},
|
|
299
324
|
separator: {
|
|
@@ -315,6 +340,7 @@ function getComponentRegistry() {
|
|
|
315
340
|
description: "An input where the user selects a value from within a given range.",
|
|
316
341
|
files: [{ name: "slider.tsx" }, { name: "index.ts" }],
|
|
317
342
|
dependencies: ["@base-ui/react"],
|
|
343
|
+
componentDependencies: ["agent"],
|
|
318
344
|
utilityDependencies: ["cn"]
|
|
319
345
|
},
|
|
320
346
|
switch: {
|
|
@@ -322,6 +348,7 @@ function getComponentRegistry() {
|
|
|
322
348
|
description: "A control that allows users to toggle a setting on or off.",
|
|
323
349
|
files: [{ name: "switch.tsx" }, { name: "index.ts" }],
|
|
324
350
|
dependencies: ["@base-ui/react"],
|
|
351
|
+
componentDependencies: ["agent"],
|
|
325
352
|
utilityDependencies: ["cn"]
|
|
326
353
|
},
|
|
327
354
|
tabs: {
|
|
@@ -329,6 +356,7 @@ function getComponentRegistry() {
|
|
|
329
356
|
description: "A component for toggling between related panels on the same page.",
|
|
330
357
|
files: [{ name: "tabs.tsx" }, { name: "index.ts" }],
|
|
331
358
|
dependencies: ["@base-ui/react"],
|
|
359
|
+
componentDependencies: ["agent"],
|
|
332
360
|
utilityDependencies: ["cn"]
|
|
333
361
|
},
|
|
334
362
|
text: {
|
|
@@ -342,7 +370,8 @@ function getComponentRegistry() {
|
|
|
342
370
|
name: "textarea",
|
|
343
371
|
description: "A multi-line text input for longer form content.",
|
|
344
372
|
files: [{ name: "textarea.tsx" }, { name: "index.ts" }],
|
|
345
|
-
dependencies: [],
|
|
373
|
+
dependencies: ["@base-ui/react"],
|
|
374
|
+
componentDependencies: ["agent"],
|
|
346
375
|
utilityDependencies: ["cn"]
|
|
347
376
|
},
|
|
348
377
|
toast: {
|
|
@@ -357,6 +386,7 @@ function getComponentRegistry() {
|
|
|
357
386
|
description: "A two-state button that can be on or off.",
|
|
358
387
|
files: [{ name: "toggle.tsx" }, { name: "index.ts" }],
|
|
359
388
|
dependencies: ["@base-ui/react", "class-variance-authority"],
|
|
389
|
+
componentDependencies: ["agent"],
|
|
360
390
|
utilityDependencies: ["cn"]
|
|
361
391
|
},
|
|
362
392
|
"toggle-group": {
|
|
@@ -364,6 +394,7 @@ function getComponentRegistry() {
|
|
|
364
394
|
description: "A grouped set of toggles supporting single or multiple pressed states.",
|
|
365
395
|
files: [{ name: "toggle-group.tsx" }, { name: "index.ts" }],
|
|
366
396
|
dependencies: ["@base-ui/react", "class-variance-authority"],
|
|
397
|
+
componentDependencies: ["agent"],
|
|
367
398
|
utilityDependencies: ["cn"]
|
|
368
399
|
},
|
|
369
400
|
toolbar: {
|
|
@@ -404,6 +435,7 @@ function getComponentRegistry() {
|
|
|
404
435
|
description: "Tabs whose active pill travels between triggers using a shared layout animation.",
|
|
405
436
|
files: [{ name: "animated-tabs.tsx" }, { name: "index.ts" }],
|
|
406
437
|
dependencies: ["@base-ui/react", "motion"],
|
|
438
|
+
componentDependencies: ["agent"],
|
|
407
439
|
utilityDependencies: ["cn"],
|
|
408
440
|
tier: "motion"
|
|
409
441
|
},
|
|
@@ -412,6 +444,7 @@ function getComponentRegistry() {
|
|
|
412
444
|
description: "A carousel that snaps to where the flick was aimed, not to where it stopped.",
|
|
413
445
|
files: [{ name: "carousel.tsx" }, { name: "index.ts" }],
|
|
414
446
|
dependencies: ["motion"],
|
|
447
|
+
componentDependencies: ["agent"],
|
|
415
448
|
utilityDependencies: ["cn"],
|
|
416
449
|
tier: "motion"
|
|
417
450
|
},
|
|
@@ -420,6 +453,7 @@ function getComponentRegistry() {
|
|
|
420
453
|
description: "A draggable divider for comparing two layers side by side.",
|
|
421
454
|
files: [{ name: "compare-slider.tsx" }, { name: "index.ts" }],
|
|
422
455
|
dependencies: ["motion"],
|
|
456
|
+
componentDependencies: ["agent"],
|
|
423
457
|
utilityDependencies: ["cn"],
|
|
424
458
|
tier: "motion"
|
|
425
459
|
},
|
|
@@ -428,6 +462,7 @@ function getComponentRegistry() {
|
|
|
428
462
|
description: "A card that opens into its own detail view using a shared layout animation.",
|
|
429
463
|
files: [{ name: "expandable-card.tsx" }, { name: "index.ts" }],
|
|
430
464
|
dependencies: ["motion"],
|
|
465
|
+
componentDependencies: ["agent"],
|
|
431
466
|
utilityDependencies: ["cn"],
|
|
432
467
|
tier: "motion"
|
|
433
468
|
},
|
|
@@ -436,6 +471,7 @@ function getComponentRegistry() {
|
|
|
436
471
|
description: "A destructive action gated behind a deliberate press-and-hold.",
|
|
437
472
|
files: [{ name: "hold-to-confirm.tsx" }, { name: "index.ts" }],
|
|
438
473
|
dependencies: ["@base-ui/react", "motion"],
|
|
474
|
+
componentDependencies: ["agent"],
|
|
439
475
|
utilityDependencies: ["cn"],
|
|
440
476
|
tier: "motion"
|
|
441
477
|
},
|
|
@@ -492,6 +528,7 @@ function getComponentRegistry() {
|
|
|
492
528
|
description: "A list reordered by drag or by keyboard, both ending in the same place.",
|
|
493
529
|
files: [{ name: "sortable.tsx" }, { name: "index.ts" }],
|
|
494
530
|
dependencies: ["motion"],
|
|
531
|
+
componentDependencies: ["agent"],
|
|
495
532
|
utilityDependencies: ["cn"],
|
|
496
533
|
tier: "motion"
|
|
497
534
|
},
|
|
@@ -516,6 +553,7 @@ function getComponentRegistry() {
|
|
|
516
553
|
description: "A row whose actions are revealed by a velocity-projected swipe.",
|
|
517
554
|
files: [{ name: "swipeable-row.tsx" }, { name: "index.ts" }],
|
|
518
555
|
dependencies: ["motion"],
|
|
556
|
+
componentDependencies: ["agent"],
|
|
519
557
|
utilityDependencies: ["cn"],
|
|
520
558
|
tier: "motion"
|
|
521
559
|
},
|
|
@@ -697,7 +735,7 @@ function parseJsonWithComments(content) {
|
|
|
697
735
|
|
|
698
736
|
// src/utils/dependencies.ts
|
|
699
737
|
var DEPENDENCY_VERSION_MAP = {
|
|
700
|
-
"@base-ui/react": "^1.
|
|
738
|
+
"@base-ui/react": "^1.9.0",
|
|
701
739
|
"lucide-react": "^0.552.0",
|
|
702
740
|
"motion": "^12.23.6",
|
|
703
741
|
"class-variance-authority": "^0.7.1",
|
|
@@ -707,13 +745,34 @@ var DEPENDENCY_VERSION_MAP = {
|
|
|
707
745
|
"tailwind-merge": "^3.5.0",
|
|
708
746
|
"@json-render/core": "^0.14.0",
|
|
709
747
|
"@json-render/react": "^0.14.0",
|
|
710
|
-
"zod": "^4.
|
|
748
|
+
"zod": "^4.3.6"
|
|
711
749
|
};
|
|
712
750
|
function toInstallSpec(dep) {
|
|
713
751
|
const version = DEPENDENCY_VERSION_MAP[dep];
|
|
714
752
|
return version ? `${dep}@${version}` : dep;
|
|
715
753
|
}
|
|
716
754
|
|
|
755
|
+
// src/utils/legacy.ts
|
|
756
|
+
import { spawnSync } from "child_process";
|
|
757
|
+
var V1_CLI_VERSION = "0.12.0";
|
|
758
|
+
function runV1Add(argv = process.argv) {
|
|
759
|
+
const windows = process.platform === "win32";
|
|
760
|
+
const args = ["--yes", `@dinachi/cli@${V1_CLI_VERSION}`, "add", ...v1AddArgs(argv)];
|
|
761
|
+
const result = windows ? spawnSync("npx.cmd", args.map(quoteForCmd), { stdio: "inherit", shell: true }) : spawnSync("npx", args, { stdio: "inherit" });
|
|
762
|
+
if (result.error) {
|
|
763
|
+
console.error(`Could not run @dinachi/cli@${V1_CLI_VERSION}: ${result.error.message}`);
|
|
764
|
+
return 1;
|
|
765
|
+
}
|
|
766
|
+
return result.status ?? 1;
|
|
767
|
+
}
|
|
768
|
+
function quoteForCmd(arg) {
|
|
769
|
+
return /^[\w@./:=-]+$/.test(arg) ? arg : `"${arg.replace(/"/g, '""')}"`;
|
|
770
|
+
}
|
|
771
|
+
function v1AddArgs(argv) {
|
|
772
|
+
const at = argv.indexOf("add");
|
|
773
|
+
return at === -1 ? [] : argv.slice(at + 1).filter((arg) => arg !== "--v1");
|
|
774
|
+
}
|
|
775
|
+
|
|
717
776
|
// src/commands/add.ts
|
|
718
777
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
719
778
|
var __dirname2 = path3.dirname(__filename2);
|
|
@@ -814,9 +873,13 @@ function tryResolveAsAlias(absoluteFilePath, compilerConfig) {
|
|
|
814
873
|
}
|
|
815
874
|
return null;
|
|
816
875
|
}
|
|
817
|
-
function rewriteTemplateImports(content, targetFilePath, utilsFilePath, compilerConfig) {
|
|
876
|
+
function rewriteTemplateImports(content, targetFilePath, utilsFilePath, componentDir, compilerConfig) {
|
|
818
877
|
const utilsImportPath = tryResolveAsAlias(utilsFilePath, compilerConfig) ?? toImportPath(targetFilePath, utilsFilePath);
|
|
819
|
-
|
|
878
|
+
const componentImportPath = (name) => {
|
|
879
|
+
const filePath = path3.join(componentDir, `${name}.tsx`);
|
|
880
|
+
return tryResolveAsAlias(filePath, compilerConfig) ?? toImportPath(targetFilePath, filePath);
|
|
881
|
+
};
|
|
882
|
+
return content.replace(/(['"])@\/lib\/utils\1/g, `$1${utilsImportPath}$1`).replace(/(['"])@\/components\/ui\/([a-z0-9-]+)\1/g, (_match, quote, name) => `${quote}${componentImportPath(name)}${quote}`);
|
|
820
883
|
}
|
|
821
884
|
function getComponentDependencies(componentName, visited = /* @__PURE__ */ new Set()) {
|
|
822
885
|
if (visited.has(componentName)) {
|
|
@@ -1066,8 +1129,11 @@ function withComponentDependencies(names) {
|
|
|
1066
1129
|
}
|
|
1067
1130
|
return [...resolved];
|
|
1068
1131
|
}
|
|
1069
|
-
var addCommand = new Command("add").description("Add a component to your project").argument("[components...]", "Names of the components to add (optional when using --all or --motion)").option("-y, --yes", "Skip confirmation prompts").option("-o, --overwrite", "Overwrite existing files").option("-a, --all", "Install every core component").option("-m, --motion", "With component names, install their motion build. On its own, install every motion component").option("--skip-install", "Skip package installation").action(
|
|
1132
|
+
var addCommand = new Command("add").description("Add a component to your project").argument("[components...]", "Names of the components to add (optional when using --all or --motion)").option("-y, --yes", "Skip confirmation prompts").option("-o, --overwrite", "Overwrite existing files").option("-a, --all", "Install every core component").option("-m, --motion", "With component names, install their motion build. On its own, install every motion component").option("--skip-install", "Skip package installation").option("--v1", `Install the v1 build, from before components registered with the agent bridge (runs @dinachi/cli@${V1_CLI_VERSION})`).action(
|
|
1070
1133
|
async (componentNames, options) => {
|
|
1134
|
+
if (options.v1) {
|
|
1135
|
+
process.exit(runV1Add());
|
|
1136
|
+
}
|
|
1071
1137
|
const spinner = ora("Adding component...").start();
|
|
1072
1138
|
try {
|
|
1073
1139
|
const config = await getConfig();
|
|
@@ -1187,7 +1253,7 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
1187
1253
|
spinner.start();
|
|
1188
1254
|
}
|
|
1189
1255
|
const templateContent = stripTemplateDirective(await fs3.readFile(sourcePath, "utf-8"));
|
|
1190
|
-
const rewrittenContent = rewriteTemplateImports(templateContent, targetPath, utilsFilePath, compilerPathConfig);
|
|
1256
|
+
const rewrittenContent = rewriteTemplateImports(templateContent, targetPath, utilsFilePath, componentDir, compilerPathConfig);
|
|
1191
1257
|
await fs3.writeFile(targetPath, rewrittenContent);
|
|
1192
1258
|
allFilesAdded.push({ name: file.name, path: targetPath });
|
|
1193
1259
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dinachi/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "CLI for adding Dinachi UI components to your project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"ts-morph": "^27.0.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@base-ui/react": "1.
|
|
47
|
+
"@base-ui/react": "1.9.0",
|
|
48
48
|
"@json-render/core": "^0.14.0",
|
|
49
49
|
"@json-render/react": "^0.14.0",
|
|
50
50
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -2,25 +2,79 @@ import * as React from "react";
|
|
|
2
2
|
import { Accordion as BaseAccordion } from "@base-ui/react/accordion";
|
|
3
3
|
import { cn } from "@/lib/utils";
|
|
4
4
|
import { ChevronDown } from "lucide-react";
|
|
5
|
+
import { changeAsAgent, useAgentControl, useAgentState, useHasAgent, useMergedRef } from "@/components/ui/agent";
|
|
5
6
|
|
|
7
|
+
type Details = BaseAccordion.Root.ChangeEventDetails;
|
|
8
|
+
|
|
9
|
+
interface AccordionAgent {
|
|
10
|
+
value: unknown[];
|
|
11
|
+
multiple: boolean;
|
|
12
|
+
change: (next: unknown[], details: Details) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const AccordionAgentContext = React.createContext<AccordionAgent | null>(null);
|
|
16
|
+
type Ref<T> = React.MutableRefObject<T | null>;
|
|
17
|
+
const AccordionPartsContext = React.createContext<{ trigger: Ref<HTMLButtonElement>; panel: Ref<HTMLDivElement> } | null>(null);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Base UI's root, holding its own value so an agent can open and close items the way a
|
|
21
|
+
* parent would. Controlled use is unchanged, and `onValueChange` sees the agent's changes
|
|
22
|
+
* first and can cancel them.
|
|
23
|
+
*/
|
|
6
24
|
const Accordion = React.forwardRef<
|
|
7
25
|
React.ComponentRef<typeof BaseAccordion.Root>,
|
|
8
26
|
React.ComponentProps<typeof BaseAccordion.Root>
|
|
9
|
-
>(({ className, ...props }, ref) =>
|
|
10
|
-
|
|
11
|
-
)
|
|
27
|
+
>(({ className, value: valueProp, defaultValue, onValueChange, ...props }, ref) => {
|
|
28
|
+
const [value, change] = useAgentState<unknown[], Details>(valueProp, defaultValue ?? [], onValueChange);
|
|
29
|
+
const agent = { value, multiple: Boolean(props.multiple), change };
|
|
30
|
+
return (
|
|
31
|
+
<AccordionAgentContext.Provider value={useHasAgent() ? agent : null}>
|
|
32
|
+
<BaseAccordion.Root ref={ref} data-agent-in={props["aria-label"]} className={cn(className)} {...props} value={value} onValueChange={change} />
|
|
33
|
+
</AccordionAgentContext.Provider>
|
|
34
|
+
);
|
|
35
|
+
});
|
|
12
36
|
Accordion.displayName = "Accordion";
|
|
13
37
|
|
|
38
|
+
/** Each item is its own disclosure to the agent, standing at its trigger. Open, it reads as its panel's text. */
|
|
14
39
|
const AccordionItem = React.forwardRef<
|
|
15
40
|
HTMLDivElement,
|
|
16
41
|
React.ComponentProps<typeof BaseAccordion.Item>
|
|
17
|
-
>(({ className, ...props }, ref) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
));
|
|
42
|
+
>(({ className, value: valueProp, ...props }, ref) => {
|
|
43
|
+
const fallback = React.useId();
|
|
44
|
+
const value = valueProp ?? fallback;
|
|
45
|
+
const root = React.useContext(AccordionAgentContext);
|
|
46
|
+
const trigger = React.useRef<HTMLButtonElement | null>(null);
|
|
47
|
+
const panel = React.useRef<HTMLDivElement | null>(null);
|
|
48
|
+
const [parts] = React.useState(() => ({ trigger, panel }));
|
|
49
|
+
|
|
50
|
+
useAgentControl(() => {
|
|
51
|
+
if (!root) return null;
|
|
52
|
+
const open = root.value.includes(value);
|
|
53
|
+
const next = open
|
|
54
|
+
? root.value.filter((v) => v !== value)
|
|
55
|
+
: root.multiple
|
|
56
|
+
? [...root.value, value]
|
|
57
|
+
: [value];
|
|
58
|
+
return {
|
|
59
|
+
kind: "disclosure",
|
|
60
|
+
element: trigger.current,
|
|
61
|
+
open,
|
|
62
|
+
value: open ? panel.current?.textContent?.replace(/\s+/g, " ").trim() || undefined : undefined,
|
|
63
|
+
actions: { [open ? "close" : "open"]: () => changeAsAgent(root.change, next) },
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<AccordionPartsContext.Provider value={root ? parts : null}>
|
|
69
|
+
<BaseAccordion.Item
|
|
70
|
+
ref={ref}
|
|
71
|
+
className={cn("border-b", className)}
|
|
72
|
+
value={value}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
</AccordionPartsContext.Provider>
|
|
76
|
+
);
|
|
77
|
+
});
|
|
24
78
|
AccordionItem.displayName = "AccordionItem";
|
|
25
79
|
|
|
26
80
|
const AccordionHeader = React.forwardRef<
|
|
@@ -42,7 +96,7 @@ const AccordionTrigger = React.forwardRef<
|
|
|
42
96
|
}
|
|
43
97
|
>(({ className, children, ...props }, ref) => (
|
|
44
98
|
<BaseAccordion.Trigger
|
|
45
|
-
ref={ref}
|
|
99
|
+
ref={useMergedRef(ref, React.useContext(AccordionPartsContext)?.trigger)}
|
|
46
100
|
className={cn(
|
|
47
101
|
"flex flex-1 items-center justify-between py-4 font-medium transition-colors hover:underline",
|
|
48
102
|
"[&[data-panel-open]>svg]:rotate-180",
|
|
@@ -62,7 +116,7 @@ const AccordionPanel = React.forwardRef<
|
|
|
62
116
|
React.ComponentProps<typeof BaseAccordion.Panel>
|
|
63
117
|
>(({ className, children, ...props }, ref) => (
|
|
64
118
|
<BaseAccordion.Panel
|
|
65
|
-
ref={ref}
|
|
119
|
+
ref={useMergedRef(ref, React.useContext(AccordionPartsContext)?.panel)}
|
|
66
120
|
className={cn(
|
|
67
121
|
"overflow-hidden text-sm h-[var(--accordion-panel-height)]",
|
|
68
122
|
"transition-[height] duration-[var(--motion-duration-base,200ms)] ease-[var(--motion-ease-out,cubic-bezier(0.23,1,0.32,1))]",
|