@dinachi/cli 1.0.0 → 1.3.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 +69 -0
- package/dist/index.js +244 -72
- package/package.json +5 -1
- package/templates/accordion/accordion.tsx +5 -1
- package/templates/agent/agent.tsx +35 -18
- package/templates/alert/alert.tsx +345 -0
- package/templates/alert/index.ts +16 -0
- package/templates/alert-dialog/alert-dialog.tsx +14 -3
- package/templates/animated-icon/animated-icon.tsx +1 -0
- package/templates/animated-list/animated-list.tsx +2 -1
- package/templates/animated-tabs/animated-tabs.tsx +4 -0
- package/templates/ask-bar/ask-bar.tsx +1061 -0
- package/templates/ask-bar/index.ts +1 -0
- package/templates/autocomplete/autocomplete.tsx +14 -4
- package/templates/avatar/avatar.tsx +3 -0
- package/templates/badge/badge.tsx +1 -0
- package/templates/breadcrumb/breadcrumb.tsx +606 -0
- package/templates/breadcrumb/index.ts +9 -0
- package/templates/button/button.tsx +1 -0
- package/templates/calendar/calendar.tsx +1155 -0
- package/templates/calendar/index.ts +15 -0
- package/templates/card/card.tsx +6 -1
- package/templates/carousel/carousel.tsx +7 -0
- package/templates/checkbox/checkbox.tsx +1 -0
- package/templates/checkbox-group/checkbox-group.tsx +1 -0
- package/templates/collapsible/collapsible.tsx +3 -1
- package/templates/combobox/combobox.tsx +15 -4
- package/templates/command-items/command-items.tsx +69 -0
- package/templates/command-items/index.ts +1 -0
- package/templates/command-palette/command-palette.tsx +954 -0
- package/templates/command-palette/index.ts +1 -0
- package/templates/compare-slider/compare-slider.tsx +1 -0
- package/templates/comparison-table/comparison-table.tsx +540 -0
- package/templates/comparison-table/index.ts +15 -0
- package/templates/context-menu/context-menu.tsx +61 -14
- package/templates/data-table/data-table.tsx +2077 -0
- package/templates/data-table/index.ts +14 -0
- package/templates/date-picker/date-picker.tsx +527 -0
- package/templates/date-picker/index.ts +2 -0
- package/templates/date-range-picker/date-range-picker.tsx +504 -0
- package/templates/date-range-picker/index.ts +2 -0
- package/templates/detail-list/detail-list.tsx +419 -0
- package/templates/detail-list/index.ts +12 -0
- package/templates/dialog/dialog.tsx +13 -3
- package/templates/drawer/drawer.tsx +19 -6
- package/templates/expandable-card/expandable-card.tsx +5 -1
- package/templates/field/field.tsx +5 -1
- package/templates/fieldset/fieldset.tsx +2 -0
- package/templates/form/form.tsx +1 -0
- package/templates/heat-table/heat-table.tsx +613 -0
- package/templates/heat-table/index.ts +9 -0
- package/templates/hold-to-confirm/hold-to-confirm.tsx +1 -0
- package/templates/input/input.tsx +1 -0
- package/templates/label/label.tsx +1 -0
- package/templates/link/link.tsx +1 -0
- package/templates/load-transition/load-transition.tsx +1 -0
- package/templates/marquee/marquee.tsx +1 -0
- package/templates/menu/menu.tsx +27 -6
- package/templates/menubar/menubar.tsx +15 -3
- package/templates/meter/meter.tsx +5 -1
- package/templates/month-picker/index.ts +1 -0
- package/templates/month-picker/month-picker.tsx +351 -0
- package/templates/navigation-menu/navigation-menu.tsx +13 -2
- package/templates/number-field/number-field.tsx +7 -1
- package/templates/number-ticker/number-ticker.tsx +3 -0
- package/templates/omnibar/index.ts +1 -0
- package/templates/omnibar/omnibar.tsx +1009 -0
- package/templates/otp-field/otp-field.tsx +4 -0
- package/templates/pagination/index.ts +8 -0
- package/templates/pagination/pagination.tsx +389 -0
- package/templates/popover/popover.tsx +19 -5
- package/templates/preview-card/preview-card.tsx +11 -3
- package/templates/progress/progress.tsx +5 -1
- package/templates/progress-ring/progress-ring.tsx +1 -0
- package/templates/radio/radio.tsx +3 -0
- package/templates/scroll-area/scroll-area.tsx +14 -4
- package/templates/scroll-progress/scroll-progress.tsx +1 -0
- package/templates/scroll-reveal/scroll-reveal.tsx +1 -0
- package/templates/select/select.tsx +18 -2
- package/templates/separator/separator.tsx +1 -0
- package/templates/skeleton/skeleton.tsx +1 -0
- package/templates/slider/slider.tsx +7 -0
- package/templates/sortable/sortable.tsx +3 -0
- package/templates/stagger-list/stagger-list.tsx +2 -0
- package/templates/streaming-text/streaming-text.tsx +1 -0
- package/templates/swipeable-row/swipeable-row.tsx +1 -0
- package/templates/switch/switch.tsx +2 -0
- package/templates/table/index.ts +13 -0
- package/templates/table/table.tsx +265 -0
- package/templates/tabs/tabs.tsx +5 -0
- package/templates/text/text.tsx +1 -0
- package/templates/text-morph/text-morph.tsx +2 -0
- package/templates/text-shimmer/text-shimmer.tsx +1 -0
- package/templates/textarea/textarea.tsx +1 -0
- package/templates/time-slots/index.ts +1 -0
- package/templates/time-slots/time-slots.tsx +589 -0
- package/templates/toast/toast.tsx +10 -1
- package/templates/toggle/toggle.tsx +1 -0
- package/templates/toggle-group/toggle-group.tsx +2 -0
- package/templates/toolbar/toolbar.tsx +6 -0
- package/templates/tooltip/tooltip.tsx +9 -3
- package/templates/week-strip/index.ts +1 -0
- package/templates/week-strip/week-strip.tsx +329 -0
- package/templates/year-view/index.ts +1 -0
- package/templates/year-view/year-view.tsx +362 -0
|
@@ -8,6 +8,16 @@ import { type AgentOpenParts, useAgentOpen, useHasAgent, useMergedRef } from "@/
|
|
|
8
8
|
|
|
9
9
|
const ContextMenuAgentContext = React.createContext<(AgentOpenParts & { disabled?: boolean }) | null>(null)
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Base UI places the popup at the point a right-click or long press set. Opened any other
|
|
13
|
+
* way, by an agent or a controlled `open`, there is no such point and it lands in the top
|
|
14
|
+
* left corner, so the positioner anchors on the middle of the trigger area instead.
|
|
15
|
+
*/
|
|
16
|
+
const ContextMenuAnchorContext = React.createContext<{
|
|
17
|
+
pointed: React.RefObject<boolean>
|
|
18
|
+
trigger: React.RefObject<HTMLElement | null>
|
|
19
|
+
} | null>(null)
|
|
20
|
+
|
|
11
21
|
/**
|
|
12
22
|
* Base UI's root, holding its own open state so an agent can open and close it. Closed,
|
|
13
23
|
* the agent sees the trigger area, named by its `aria-label` or text; open, the popup.
|
|
@@ -20,10 +30,20 @@ const ContextMenu: React.FC<React.ComponentProps<typeof BaseContextMenu.Root>> =
|
|
|
20
30
|
...props
|
|
21
31
|
}) => {
|
|
22
32
|
const [state, change, parts] = useAgentOpen("menu", open, defaultOpen, onOpenChange)
|
|
33
|
+
const pointed = React.useRef(false)
|
|
34
|
+
const trigger = React.useRef<HTMLElement | null>(null)
|
|
35
|
+
const anchor = React.useMemo(() => ({ pointed, trigger }), [])
|
|
36
|
+
if (!state) pointed.current = false
|
|
37
|
+
const onChange: typeof change = (next, details) => {
|
|
38
|
+
if (next) pointed.current = details.reason === "trigger-press"
|
|
39
|
+
change(next, details)
|
|
40
|
+
}
|
|
23
41
|
return (
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
42
|
+
<ContextMenuAnchorContext.Provider value={anchor}>
|
|
43
|
+
<ContextMenuAgentContext.Provider value={useHasAgent() ? { ...parts, disabled: props.disabled } : null}>
|
|
44
|
+
<BaseContextMenu.Root {...props} open={state} onOpenChange={onChange} />
|
|
45
|
+
</ContextMenuAgentContext.Provider>
|
|
46
|
+
</ContextMenuAnchorContext.Provider>
|
|
27
47
|
)
|
|
28
48
|
}
|
|
29
49
|
ContextMenu.displayName = "ContextMenu"
|
|
@@ -33,11 +53,13 @@ const ContextMenuTrigger = React.forwardRef<
|
|
|
33
53
|
React.ComponentProps<typeof BaseContextMenu.Trigger>
|
|
34
54
|
>(({ className, ...props }, ref) => {
|
|
35
55
|
const agent = React.useContext(ContextMenuAgentContext)
|
|
56
|
+
const anchor = React.useContext(ContextMenuAnchorContext)
|
|
36
57
|
return (
|
|
37
58
|
<BaseContextMenu.Trigger
|
|
38
|
-
ref={useMergedRef(ref, agent?.trigger)}
|
|
59
|
+
ref={useMergedRef(ref, agent?.trigger, anchor?.trigger)}
|
|
39
60
|
data-disabled={agent?.disabled ? "" : undefined}
|
|
40
61
|
className={cn("select-none", className)}
|
|
62
|
+
data-slot="context-menu-trigger"
|
|
41
63
|
{...props}
|
|
42
64
|
/>
|
|
43
65
|
)
|
|
@@ -46,19 +68,34 @@ ContextMenuTrigger.displayName = "ContextMenuTrigger"
|
|
|
46
68
|
|
|
47
69
|
const ContextMenuPortal: React.FC<
|
|
48
70
|
React.ComponentProps<typeof BaseContextMenu.Portal>
|
|
49
|
-
> = (props) => <BaseContextMenu.Portal {...props} />
|
|
71
|
+
> = (props) => <BaseContextMenu.Portal data-slot="context-menu-portal" {...props} />
|
|
50
72
|
ContextMenuPortal.displayName = "ContextMenuPortal"
|
|
51
73
|
|
|
52
74
|
const ContextMenuPositioner = React.forwardRef<
|
|
53
75
|
React.ComponentRef<typeof BaseContextMenu.Positioner>,
|
|
54
76
|
React.ComponentProps<typeof BaseContextMenu.Positioner>
|
|
55
|
-
>(({ className, ...props }, ref) =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
77
|
+
>(({ className, anchor, ...props }, ref) => {
|
|
78
|
+
const ctx = React.useContext(ContextMenuAnchorContext)
|
|
79
|
+
const middle = React.useMemo(
|
|
80
|
+
() =>
|
|
81
|
+
ctx && {
|
|
82
|
+
getBoundingClientRect() {
|
|
83
|
+
const r = ctx.trigger.current?.getBoundingClientRect()
|
|
84
|
+
return r ? DOMRect.fromRect({ x: r.x + r.width / 2, y: r.y + r.height / 2, width: 0, height: 0 }) : new DOMRect()
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
[ctx]
|
|
88
|
+
)
|
|
89
|
+
return (
|
|
90
|
+
<BaseContextMenu.Positioner
|
|
91
|
+
ref={ref}
|
|
92
|
+
anchor={anchor ?? (ctx && !ctx.pointed.current ? middle : undefined)}
|
|
93
|
+
className={cn("z-50 outline-none", className)}
|
|
94
|
+
data-slot="context-menu-positioner"
|
|
95
|
+
{...props}
|
|
96
|
+
/>
|
|
97
|
+
)
|
|
98
|
+
})
|
|
62
99
|
ContextMenuPositioner.displayName = "ContextMenuPositioner"
|
|
63
100
|
|
|
64
101
|
const ContextMenuContent = React.forwardRef<
|
|
@@ -79,6 +116,7 @@ const ContextMenuContent = React.forwardRef<
|
|
|
79
116
|
"motion-reduce:data-[starting-style]:scale-100 motion-reduce:data-[ending-style]:scale-100",
|
|
80
117
|
className
|
|
81
118
|
)}
|
|
119
|
+
data-slot="context-menu-content"
|
|
82
120
|
{...props}
|
|
83
121
|
/>
|
|
84
122
|
</ContextMenuPositioner>
|
|
@@ -102,6 +140,7 @@ const ContextMenuItem = React.forwardRef<
|
|
|
102
140
|
inset && "pl-8",
|
|
103
141
|
className
|
|
104
142
|
)}
|
|
143
|
+
data-slot="context-menu-item"
|
|
105
144
|
{...props}
|
|
106
145
|
/>
|
|
107
146
|
))
|
|
@@ -119,6 +158,7 @@ const ContextMenuLinkItem = React.forwardRef<
|
|
|
119
158
|
"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",
|
|
120
159
|
className
|
|
121
160
|
)}
|
|
161
|
+
data-slot="context-menu-link-item"
|
|
122
162
|
{...props}
|
|
123
163
|
/>
|
|
124
164
|
))
|
|
@@ -137,6 +177,7 @@ const ContextMenuCheckboxItem = React.forwardRef<
|
|
|
137
177
|
"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",
|
|
138
178
|
className
|
|
139
179
|
)}
|
|
180
|
+
data-slot="context-menu-checkbox-item"
|
|
140
181
|
{...props}
|
|
141
182
|
>
|
|
142
183
|
<BaseContextMenu.CheckboxItemIndicator className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
@@ -151,7 +192,7 @@ const ContextMenuRadioGroup = React.forwardRef<
|
|
|
151
192
|
React.ComponentRef<typeof BaseContextMenu.RadioGroup>,
|
|
152
193
|
React.ComponentProps<typeof BaseContextMenu.RadioGroup>
|
|
153
194
|
>(({ className, ...props }, ref) => (
|
|
154
|
-
<BaseContextMenu.RadioGroup ref={ref} className={className} {...props} />
|
|
195
|
+
<BaseContextMenu.RadioGroup ref={ref} className={className} data-slot="context-menu-radio-group" {...props} />
|
|
155
196
|
))
|
|
156
197
|
ContextMenuRadioGroup.displayName = "ContextMenuRadioGroup"
|
|
157
198
|
|
|
@@ -168,6 +209,7 @@ const ContextMenuRadioItem = React.forwardRef<
|
|
|
168
209
|
"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",
|
|
169
210
|
className
|
|
170
211
|
)}
|
|
212
|
+
data-slot="context-menu-radio-item"
|
|
171
213
|
{...props}
|
|
172
214
|
>
|
|
173
215
|
<BaseContextMenu.RadioItemIndicator className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
@@ -182,7 +224,7 @@ const ContextMenuGroup = React.forwardRef<
|
|
|
182
224
|
React.ComponentRef<typeof BaseContextMenu.Group>,
|
|
183
225
|
React.ComponentProps<typeof BaseContextMenu.Group>
|
|
184
226
|
>(({ className, ...props }, ref) => (
|
|
185
|
-
<BaseContextMenu.Group ref={ref} className={className} {...props} />
|
|
227
|
+
<BaseContextMenu.Group ref={ref} className={className} data-slot="context-menu-group" {...props} />
|
|
186
228
|
))
|
|
187
229
|
ContextMenuGroup.displayName = "ContextMenuGroup"
|
|
188
230
|
|
|
@@ -199,6 +241,7 @@ const ContextMenuLabel = React.forwardRef<
|
|
|
199
241
|
inset && "pl-8",
|
|
200
242
|
className
|
|
201
243
|
)}
|
|
244
|
+
data-slot="context-menu-label"
|
|
202
245
|
{...props}
|
|
203
246
|
/>
|
|
204
247
|
))
|
|
@@ -211,6 +254,7 @@ const ContextMenuSeparator = React.forwardRef<
|
|
|
211
254
|
<BaseContextMenu.Separator
|
|
212
255
|
ref={ref}
|
|
213
256
|
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
257
|
+
data-slot="context-menu-separator"
|
|
214
258
|
{...props}
|
|
215
259
|
/>
|
|
216
260
|
))
|
|
@@ -225,6 +269,7 @@ const ContextMenuShortcut = ({
|
|
|
225
269
|
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
226
270
|
className
|
|
227
271
|
)}
|
|
272
|
+
data-slot="context-menu-shortcut"
|
|
228
273
|
{...props}
|
|
229
274
|
/>
|
|
230
275
|
)
|
|
@@ -252,6 +297,7 @@ const ContextMenuSubTrigger = React.forwardRef<
|
|
|
252
297
|
inset && "pl-8",
|
|
253
298
|
className
|
|
254
299
|
)}
|
|
300
|
+
data-slot="context-menu-sub-trigger"
|
|
255
301
|
{...props}
|
|
256
302
|
>
|
|
257
303
|
{children}
|
|
@@ -278,6 +324,7 @@ const ContextMenuSubContent = React.forwardRef<
|
|
|
278
324
|
"motion-reduce:data-[starting-style]:scale-100 motion-reduce:data-[ending-style]:scale-100",
|
|
279
325
|
className
|
|
280
326
|
)}
|
|
327
|
+
data-slot="context-menu-sub-content"
|
|
281
328
|
{...props}
|
|
282
329
|
/>
|
|
283
330
|
</BaseContextMenu.Positioner>
|