@dinachi/cli 1.1.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 +55 -0
- package/dist/index.js +244 -72
- package/package.json +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/ask-bar/ask-bar.tsx +1061 -0
- package/templates/ask-bar/index.ts +1 -0
- package/templates/autocomplete/autocomplete.tsx +0 -1
- package/templates/breadcrumb/breadcrumb.tsx +606 -0
- package/templates/breadcrumb/index.ts +9 -0
- package/templates/calendar/calendar.tsx +1155 -0
- package/templates/calendar/index.ts +15 -0
- package/templates/combobox/combobox.tsx +0 -1
- 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/comparison-table/comparison-table.tsx +540 -0
- package/templates/comparison-table/index.ts +15 -0
- 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/heat-table/heat-table.tsx +613 -0
- package/templates/heat-table/index.ts +9 -0
- package/templates/menu/menu.tsx +8 -3
- package/templates/month-picker/index.ts +1 -0
- package/templates/month-picker/month-picker.tsx +351 -0
- package/templates/omnibar/index.ts +1 -0
- package/templates/omnibar/omnibar.tsx +1009 -0
- package/templates/pagination/index.ts +8 -0
- package/templates/pagination/pagination.tsx +389 -0
- package/templates/table/index.ts +13 -0
- package/templates/table/table.tsx +265 -0
- package/templates/time-slots/index.ts +1 -0
- package/templates/time-slots/time-slots.tsx +589 -0
- 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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Calendar,
|
|
3
|
+
parseDate,
|
|
4
|
+
dayFirst,
|
|
5
|
+
startOfDay,
|
|
6
|
+
addDays,
|
|
7
|
+
addMonths,
|
|
8
|
+
isSameDay,
|
|
9
|
+
daysBetween,
|
|
10
|
+
monthsBetween,
|
|
11
|
+
isoWeek,
|
|
12
|
+
toISODate,
|
|
13
|
+
fromISODate,
|
|
14
|
+
} from "./calendar";
|
|
15
|
+
export type { CalendarProps, CalendarMode, CalendarChangeDetails, DateRange, ParseDateOptions } from "./calendar";
|
|
@@ -108,7 +108,6 @@ function typeInto(s: ComboboxAgent, input: HTMLInputElement, text: string) {
|
|
|
108
108
|
|
|
109
109
|
/** Waits a turn for React to filter, then for the list to be open with every item registered. */
|
|
110
110
|
async function settled({ list, items }: ComboboxAgent) {
|
|
111
|
-
await new Promise((resolve) => setTimeout(resolve))
|
|
112
111
|
await waitForAgent(
|
|
113
112
|
() => list.current?.isConnected && list.current.querySelectorAll('[role="option"]').length === items.size
|
|
114
113
|
)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type * as React from "react"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Something an item can do. Order is part of the contract: `actions[0]` is what Enter
|
|
5
|
+
* runs and `actions[1]` what Mod+Enter runs. The rest are reached from the preview.
|
|
6
|
+
*/
|
|
7
|
+
export interface CommandAction {
|
|
8
|
+
id: string
|
|
9
|
+
label: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One command: a page, an action or a record. Every field is plain data except `icon`
|
|
14
|
+
* and `meta`, which are React nodes, so a list from a server or a model sends the rest
|
|
15
|
+
* and the app adds those two before passing it on.
|
|
16
|
+
*/
|
|
17
|
+
export interface CommandItem {
|
|
18
|
+
/** Unique across the whole list. */
|
|
19
|
+
id: string
|
|
20
|
+
/** What the row shows and the search matches first. */
|
|
21
|
+
label: string
|
|
22
|
+
/** A second line, also searched. */
|
|
23
|
+
description?: string
|
|
24
|
+
/** The heading the item sits under. Items with the same group are listed together. */
|
|
25
|
+
group?: string
|
|
26
|
+
/** What the item is, such as "Page" or "Order". Shown in the preview. */
|
|
27
|
+
kind?: string
|
|
28
|
+
icon?: React.ReactNode
|
|
29
|
+
/** A key hint, such as "G O" or "⌘ ,". Shown only; binding it is up to the app. */
|
|
30
|
+
shortcut?: string
|
|
31
|
+
/** Trailing text, such as an amount. */
|
|
32
|
+
meta?: React.ReactNode
|
|
33
|
+
/** More words the search matches, not shown. */
|
|
34
|
+
keywords?: string[]
|
|
35
|
+
disabled?: boolean
|
|
36
|
+
/** What it can do. Without them, running the item passes no action. */
|
|
37
|
+
actions?: CommandAction[]
|
|
38
|
+
/** A sub-list. Picking the item opens these in place of the list. */
|
|
39
|
+
items?: CommandItem[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* How a run was reached: `item-press` picks the row (a click, Enter or an agent's
|
|
44
|
+
* select), `action-press` a button for one action, `keyboard` Mod+Enter.
|
|
45
|
+
*/
|
|
46
|
+
export type CommandRunReason = "item-press" | "action-press" | "keyboard"
|
|
47
|
+
|
|
48
|
+
/** Passed to `onRun`. `cancel()` refuses the run, which an agent is told about. */
|
|
49
|
+
export interface CommandRunDetails {
|
|
50
|
+
reason: CommandRunReason
|
|
51
|
+
event: Event | undefined
|
|
52
|
+
isCanceled: boolean
|
|
53
|
+
cancel(): void
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** True when every word of `query` is in the item's label, description or keywords. */
|
|
57
|
+
export function filterCommands(item: CommandItem, query: string): boolean {
|
|
58
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean)
|
|
59
|
+
const hay = [item.label, item.description, ...(item.keywords ?? [])].join(" ").toLowerCase()
|
|
60
|
+
return words.every((w) => hay.includes(w))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** An agent's hint: each group's actions once, so it stays short however many items there are. */
|
|
64
|
+
export function commandsHint(items: CommandItem[]): string {
|
|
65
|
+
const groups = new Map<string | undefined, Set<string>>()
|
|
66
|
+
for (const { group, actions = [] } of items) for (const { label } of actions) groups.set(group, (groups.get(group) ?? new Set()).add(label))
|
|
67
|
+
const lists = [...groups].map(([group, labels]) => (group ? `${group}: ` : "") + [...labels].join(", ")).join("; ")
|
|
68
|
+
return `Runs commands. select takes a label${lists && `, then an action: ${lists}`}.`
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./command-items"
|