@monkey-mini-app/ui 0.1.1 → 0.1.4
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/README.md +12 -6
- package/dist/globals.css +1 -1
- package/dist/index.js +12 -2
- package/dist/manifest.json +6 -6
- package/dist/runtime.js +9 -0
- package/dist/sdk.js +158 -0
- package/dist/src/blocks/activity-feed.tsx +7 -0
- package/dist/src/blocks/app-shell.tsx +1 -0
- package/dist/src/blocks/attachment-gallery.tsx +7 -0
- package/dist/src/blocks/bar-chart.tsx +11 -0
- package/dist/src/blocks/comment-thread.tsx +7 -0
- package/dist/src/blocks/dashboard-shell.tsx +109 -0
- package/dist/src/blocks/description-list.tsx +7 -0
- package/dist/src/blocks/detail-panel.tsx +1 -0
- package/dist/src/blocks/donut-chart.tsx +7 -0
- package/dist/src/blocks/env-badge.tsx +7 -0
- package/dist/src/blocks/env-table.tsx +316 -0
- package/dist/src/blocks/file-tree.tsx +7 -0
- package/dist/src/blocks/filter-bar.tsx +1 -0
- package/dist/src/blocks/form-sheet.tsx +160 -0
- package/dist/src/blocks/gauge.tsx +7 -0
- package/dist/src/blocks/list-detail.tsx +121 -0
- package/dist/src/blocks/notification-center.tsx +7 -0
- package/dist/src/blocks/page-header.tsx +1 -0
- package/dist/src/blocks/progress-ring.tsx +7 -0
- package/dist/src/blocks/radar-chart.tsx +7 -0
- package/dist/src/blocks/request-inspector.tsx +7 -0
- package/dist/src/blocks/reveal.tsx +56 -0
- package/dist/src/blocks/run-timeline.tsx +7 -0
- package/dist/src/blocks/scrollspy.tsx +7 -0
- package/dist/src/blocks/settings-split.tsx +154 -0
- package/dist/src/blocks/severity-chip.tsx +7 -0
- package/dist/src/blocks/sparkline.tsx +7 -0
- package/dist/src/blocks/stat-card.tsx +1 -0
- package/dist/src/blocks/status-badge.tsx +1 -0
- package/dist/src/blocks/table-page.tsx +83 -0
- package/dist/src/blocks/terminal.tsx +21 -3
- package/dist/src/blocks/test-step-list.tsx +7 -0
- package/dist/src/blocks/trend-card.tsx +7 -0
- package/dist/src/blocks/wizard-shell.tsx +132 -0
- package/dist/src/cdn-modules.d.ts +5 -0
- package/dist/src/components/accordion.tsx +7 -0
- package/dist/src/components/alert-dialog.tsx +7 -0
- package/dist/src/components/alert.tsx +7 -0
- package/dist/src/components/aspect-ratio.tsx +4 -0
- package/dist/src/components/attachment.tsx +4 -0
- package/dist/src/components/avatar.tsx +4 -0
- package/dist/src/components/badge.tsx +7 -0
- package/dist/src/components/breadcrumb.tsx +4 -0
- package/dist/src/components/bubble.tsx +4 -0
- package/dist/src/components/button-group.tsx +6 -0
- package/dist/src/components/button.tsx +7 -0
- package/dist/src/components/calendar.tsx +4 -0
- package/dist/src/components/card.tsx +8 -1
- package/dist/src/components/chart.tsx +7 -0
- package/dist/src/components/checkbox.tsx +5 -0
- package/dist/src/components/collapsible.tsx +4 -0
- package/dist/src/components/combobox.tsx +4 -0
- package/dist/src/components/command.tsx +6 -0
- package/dist/src/components/context-menu.tsx +4 -0
- package/dist/src/components/dialog.tsx +21 -0
- package/dist/src/components/drawer.tsx +4 -0
- package/dist/src/components/dropdown-menu.tsx +7 -0
- package/dist/src/components/empty.tsx +7 -0
- package/dist/src/components/field.tsx +6 -0
- package/dist/src/components/hover-card.tsx +4 -0
- package/dist/src/components/input-group.tsx +4 -0
- package/dist/src/components/input.tsx +7 -0
- package/dist/src/components/item.tsx +4 -0
- package/dist/src/components/kbd.tsx +4 -0
- package/dist/src/components/label.tsx +7 -0
- package/dist/src/components/marker.tsx +4 -0
- package/dist/src/components/menubar.tsx +4 -0
- package/dist/src/components/message-scroller.tsx +4 -0
- package/dist/src/components/message.tsx +4 -0
- package/dist/src/components/native-select.tsx +4 -0
- package/dist/src/components/navigation-menu.tsx +4 -0
- package/dist/src/components/pagination.tsx +4 -0
- package/dist/src/components/popover.tsx +7 -0
- package/dist/src/components/progress.tsx +7 -0
- package/dist/src/components/questionnaire.tsx +4 -0
- package/dist/src/components/radio-group.tsx +4 -0
- package/dist/src/components/resizable.tsx +7 -0
- package/dist/src/components/scroll-area.tsx +4 -0
- package/dist/src/components/select.tsx +7 -0
- package/dist/src/components/separator.tsx +5 -0
- package/dist/src/components/sheet.tsx +22 -0
- package/dist/src/components/sidebar.tsx +4 -0
- package/dist/src/components/skeleton.tsx +7 -0
- package/dist/src/components/slider.tsx +4 -0
- package/dist/src/components/spinner.tsx +6 -0
- package/dist/src/components/switch.tsx +7 -0
- package/dist/src/components/table.tsx +7 -0
- package/dist/src/components/tabs.tsx +7 -0
- package/dist/src/components/textarea.tsx +7 -0
- package/dist/src/components/toast.tsx +7 -0
- package/dist/src/components/toggle-group.tsx +4 -0
- package/dist/src/components/toggle.tsx +4 -0
- package/dist/src/components/tooltip.tsx +7 -0
- package/dist/src/composites/autocomplete.tsx +7 -0
- package/dist/src/composites/cascader.tsx +7 -0
- package/dist/src/composites/color-picker.tsx +7 -0
- package/dist/src/composites/confirm-dialog.tsx +7 -0
- package/dist/src/composites/copyable.tsx +9 -1
- package/dist/src/composites/currency-input.tsx +7 -0
- package/dist/src/composites/date-picker.tsx +7 -0
- package/dist/src/composites/date-range-picker.tsx +4 -0
- package/dist/src/composites/date-time-picker.tsx +7 -0
- package/dist/src/composites/date-time-range-picker.tsx +7 -0
- package/dist/src/composites/duration-input.tsx +7 -0
- package/dist/src/composites/mini-calendar.tsx +7 -0
- package/dist/src/composites/number-field.tsx +7 -0
- package/dist/src/composites/password-field.tsx +7 -0
- package/dist/src/composites/phone-input.tsx +7 -0
- package/dist/src/composites/rating.tsx +7 -0
- package/dist/src/composites/relative-date-picker.tsx +7 -0
- package/dist/src/composites/search-input.tsx +7 -0
- package/dist/src/composites/slider-range.tsx +7 -0
- package/dist/src/composites/tag-input.tsx +7 -0
- package/dist/src/composites/time-picker.tsx +11 -1
- package/dist/src/composites/time-range-picker.tsx +7 -0
- package/dist/src/composites/timezone-select.tsx +7 -0
- package/dist/src/composites/transfer.tsx +7 -0
- package/dist/src/composites/user-picker.tsx +7 -0
- package/dist/src/hooks/use-html-dark.ts +37 -0
- package/dist/src/hooks/use-mobile.ts +3 -0
- package/dist/src/i18n/en.ts +109 -2
- package/dist/src/i18n/zh.ts +99 -2
- package/dist/src/index.ts +147 -134
- package/dist/src/lib/clipboard.ts +10 -0
- package/dist/src/lib/illustrations.tsx +2 -2
- package/dist/src/products/code-block.tsx +35 -18
- package/dist/src/products/code-editor.tsx +156 -24
- package/dist/src/products/commit-graph.tsx +644 -0
- package/dist/src/products/data-grid.tsx +2 -1
- package/dist/src/products/diff-viewer.tsx +104 -8
- package/dist/src/products/event-calendar.tsx +28 -823
- package/dist/src/products/file-dropzone.tsx +7 -0
- package/dist/src/products/full-calendar/animations.ts +38 -0
- package/dist/src/products/full-calendar/calendar-body.tsx +77 -0
- package/dist/src/products/full-calendar/constants.ts +10 -0
- package/dist/src/products/full-calendar/contexts/calendar-context.tsx +255 -0
- package/dist/src/products/full-calendar/contexts/dnd-context.tsx +157 -0
- package/dist/src/products/full-calendar/dialogs/add-edit-event-dialog.tsx +187 -0
- package/dist/src/products/full-calendar/dialogs/delete-event-dialog.tsx +39 -0
- package/dist/src/products/full-calendar/dialogs/event-details-dialog.tsx +100 -0
- package/dist/src/products/full-calendar/dialogs/events-list-dialog.tsx +87 -0
- package/dist/src/products/full-calendar/dnd/draggable-event.tsx +45 -0
- package/dist/src/products/full-calendar/dnd/droppable-area.tsx +45 -0
- package/dist/src/products/full-calendar/dnd/resizable-event.tsx +179 -0
- package/dist/src/products/full-calendar/header/calendar-header.tsx +65 -0
- package/dist/src/products/full-calendar/header/date-navigator.tsx +110 -0
- package/dist/src/products/full-calendar/header/filter.tsx +58 -0
- package/dist/src/products/full-calendar/header/today-button.tsx +45 -0
- package/dist/src/products/full-calendar/header/user-select.tsx +64 -0
- package/dist/src/products/full-calendar/header/view-tabs.tsx +36 -0
- package/dist/src/products/full-calendar/helpers.ts +453 -0
- package/dist/src/products/full-calendar/hooks/use-time-range-create.ts +152 -0
- package/dist/src/products/full-calendar/hooks.ts +70 -0
- package/dist/src/products/full-calendar/interfaces.ts +23 -0
- package/dist/src/products/full-calendar/settings/settings.tsx +80 -0
- package/dist/src/products/full-calendar/shims/avatar-group.tsx +16 -0
- package/dist/src/products/full-calendar/shims/day-picker.tsx +1 -0
- package/dist/src/products/full-calendar/shims/motion.tsx +97 -0
- package/dist/src/products/full-calendar/shims/next-themes.ts +6 -0
- package/dist/src/products/full-calendar/shims/re-resizable.tsx +25 -0
- package/dist/src/products/full-calendar/shims/sonner.ts +4 -0
- package/dist/src/products/full-calendar/types.ts +8 -0
- package/dist/src/products/full-calendar/views/agenda-view/agenda-events.tsx +140 -0
- package/dist/src/products/full-calendar/views/month-view/calendar-month-view.tsx +69 -0
- package/dist/src/products/full-calendar/views/month-view/day-cell.tsx +201 -0
- package/dist/src/products/full-calendar/views/month-view/event-bullet.tsx +40 -0
- package/dist/src/products/full-calendar/views/month-view/month-event-badge.tsx +143 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/calendar-day-view.tsx +295 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/calendar-time-line.tsx +35 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/calendar-week-view.tsx +253 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/day-view-multi-day-events-row.tsx +73 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/event-block.tsx +114 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/render-grouped-events.tsx +49 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/week-view-multi-day-events-row.tsx +143 -0
- package/dist/src/products/full-calendar/views/year-view/calendar-year-view.tsx +161 -0
- package/dist/src/products/gantt.tsx +7 -0
- package/dist/src/products/jira-wiki.tsx +1 -0
- package/dist/src/products/jql-input.tsx +340 -37
- package/dist/src/products/json-viewer.tsx +7 -0
- package/dist/src/products/kanban-issue-panel.tsx +7 -0
- package/dist/src/products/kanban.tsx +1 -0
- package/dist/src/products/log-viewer.tsx +390 -18
- package/dist/src/products/markdown-editor.tsx +21 -6
- package/dist/src/products/markdown.tsx +7 -0
- package/dist/src/products/rich-text-editor.tsx +65 -59
- package/dist/src/products/sortable-list.tsx +7 -0
- package/dist/src/products/stepper.tsx +219 -70
- package/dist/src/products/timeline.tsx +7 -0
- package/dist/src/products/tree-view.tsx +7 -0
- package/dist/src/sdk/app-error-boundary.tsx +240 -0
- package/dist/src/sdk/app-id.ts +7 -0
- package/dist/src/sdk/use-app.ts +126 -0
- package/dist/src/styles/globals.css +1 -0
- package/dist/vendors/lodash.js +20 -0
- package/dist/vendors/motion.js +12 -0
- package/package.json +20 -19
- package/dist/src/products/jql-language.ts +0 -70
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { useEffect, useState } from "react"
|
|
3
4
|
import { diffLines } from "diff"
|
|
4
5
|
|
|
6
|
+
import { useHtmlDark } from "@monkey-mini-app/ui/hooks/use-html-dark"
|
|
5
7
|
import { cn } from "@monkey-mini-app/ui/lib/utils"
|
|
6
8
|
|
|
7
9
|
type Row = {
|
|
@@ -11,6 +13,8 @@ type Row = {
|
|
|
11
13
|
right?: number
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
type Token = { content: string; color?: string }
|
|
17
|
+
|
|
14
18
|
function toRows(original: string, modified: string): Row[] {
|
|
15
19
|
const parts = diffLines(original, modified)
|
|
16
20
|
const rows: Row[] = []
|
|
@@ -38,6 +42,39 @@ function stats(rows: Row[]) {
|
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
function escapeHtml(s: string): string {
|
|
46
|
+
return s
|
|
47
|
+
.replace(/&/g, "&")
|
|
48
|
+
.replace(/</g, "<")
|
|
49
|
+
.replace(/>/g, ">")
|
|
50
|
+
.replace(/"/g, """)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function lineToHtml(tokens: Token[]): string {
|
|
54
|
+
return tokens
|
|
55
|
+
.map((t) =>
|
|
56
|
+
t.color
|
|
57
|
+
? `<span style="color:${escapeHtml(t.color)}">${escapeHtml(t.content)}</span>`
|
|
58
|
+
: escapeHtml(t.content),
|
|
59
|
+
)
|
|
60
|
+
.join("")
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function langFromFile(name?: string): string {
|
|
64
|
+
const ext = name?.split(".").pop()?.toLowerCase()
|
|
65
|
+
const map: Record<string, string> = {
|
|
66
|
+
ts: "ts",
|
|
67
|
+
tsx: "tsx",
|
|
68
|
+
js: "js",
|
|
69
|
+
jsx: "jsx",
|
|
70
|
+
json: "json",
|
|
71
|
+
html: "html",
|
|
72
|
+
md: "md",
|
|
73
|
+
css: "css",
|
|
74
|
+
}
|
|
75
|
+
return (ext && map[ext]) || "ts"
|
|
76
|
+
}
|
|
77
|
+
|
|
41
78
|
function Gutter({ n }: { n?: number }) {
|
|
42
79
|
return (
|
|
43
80
|
<span className="w-8 shrink-0 pr-2 text-right text-[11px] text-muted-foreground/70 select-none">
|
|
@@ -49,9 +86,11 @@ function Gutter({ n }: { n?: number }) {
|
|
|
49
86
|
function Line({
|
|
50
87
|
row,
|
|
51
88
|
side,
|
|
89
|
+
html,
|
|
52
90
|
}: {
|
|
53
91
|
row: Row
|
|
54
92
|
side?: "left" | "right"
|
|
93
|
+
html?: string
|
|
55
94
|
}) {
|
|
56
95
|
const hidden =
|
|
57
96
|
(side === "left" && row.type === "add") ||
|
|
@@ -62,33 +101,90 @@ function Line({
|
|
|
62
101
|
className={cn(
|
|
63
102
|
"flex px-2",
|
|
64
103
|
hidden && "bg-muted/40",
|
|
65
|
-
!hidden && row.type === "add" && "bg-emerald-500/15
|
|
66
|
-
!hidden && row.type === "del" && "bg-destructive/10
|
|
104
|
+
!hidden && row.type === "add" && "bg-emerald-500/15",
|
|
105
|
+
!hidden && row.type === "del" && "bg-destructive/10",
|
|
106
|
+
!html && !hidden && row.type === "add" && "text-emerald-800 dark:text-emerald-300",
|
|
107
|
+
!html && !hidden && row.type === "del" && "text-destructive",
|
|
67
108
|
)}
|
|
68
109
|
>
|
|
69
110
|
{side !== "right" ? <Gutter n={hidden ? undefined : row.left} /> : null}
|
|
70
111
|
{side !== "left" ? <Gutter n={hidden ? undefined : row.right} /> : null}
|
|
71
112
|
<span className="w-4 shrink-0 select-none">{hidden ? " " : mark}</span>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
113
|
+
{hidden ? (
|
|
114
|
+
<span className="min-w-0 flex-1" />
|
|
115
|
+
) : html ? (
|
|
116
|
+
<span
|
|
117
|
+
className="min-w-0 flex-1 whitespace-pre-wrap break-all"
|
|
118
|
+
dangerouslySetInnerHTML={{ __html: html }}
|
|
119
|
+
/>
|
|
120
|
+
) : (
|
|
121
|
+
<span className="min-w-0 flex-1 whitespace-pre-wrap break-all">{row.text}</span>
|
|
122
|
+
)}
|
|
75
123
|
</div>
|
|
76
124
|
)
|
|
77
125
|
}
|
|
78
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Unified or split diff view.
|
|
129
|
+
* @when Comparing two versions of text. Pass `original` + `modified` strings.
|
|
130
|
+
* @example
|
|
131
|
+
* <DiffViewer original={a} modified={b} language="ts" mode="split" />
|
|
132
|
+
* @family Discovery & inspect
|
|
133
|
+
*/
|
|
79
134
|
export function DiffViewer({
|
|
80
135
|
original,
|
|
81
136
|
modified,
|
|
82
137
|
mode = "unified",
|
|
83
138
|
fileName,
|
|
139
|
+
language,
|
|
84
140
|
}: {
|
|
85
141
|
original: string
|
|
86
142
|
modified: string
|
|
87
143
|
mode?: "unified" | "split"
|
|
88
144
|
fileName?: string
|
|
145
|
+
language?: string
|
|
89
146
|
}) {
|
|
90
147
|
const rows = toRows(original, modified)
|
|
91
148
|
const { added, removed } = stats(rows)
|
|
149
|
+
const lang = language ?? langFromFile(fileName)
|
|
150
|
+
const [hi, setHi] = useState<{ orig: string[]; mod: string[] } | null>(null)
|
|
151
|
+
const dark = useHtmlDark()
|
|
152
|
+
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
let cancelled = false
|
|
155
|
+
;(async () => {
|
|
156
|
+
try {
|
|
157
|
+
const shiki = (await import("https://esm.sh/shiki@4.4.3")) as {
|
|
158
|
+
codeToTokens?: (code: string, opts: object) => Promise<{ tokens: Token[][] }>
|
|
159
|
+
default?: { codeToTokens?: (code: string, opts: object) => Promise<{ tokens: Token[][] }> }
|
|
160
|
+
}
|
|
161
|
+
const codeToTokens = shiki.codeToTokens ?? shiki.default?.codeToTokens
|
|
162
|
+
if (!codeToTokens) throw new Error("shiki.codeToTokens missing")
|
|
163
|
+
const theme = dark ? "github-dark" : "github-light"
|
|
164
|
+
const [a, b] = await Promise.all([
|
|
165
|
+
codeToTokens(original, { lang, theme }),
|
|
166
|
+
codeToTokens(modified, { lang, theme }),
|
|
167
|
+
])
|
|
168
|
+
if (cancelled) return
|
|
169
|
+
setHi({
|
|
170
|
+
orig: a.tokens.map(lineToHtml),
|
|
171
|
+
mod: b.tokens.map(lineToHtml),
|
|
172
|
+
})
|
|
173
|
+
} catch (err) {
|
|
174
|
+
console.warn("[DiffViewer] shiki CDN failed", err)
|
|
175
|
+
}
|
|
176
|
+
})()
|
|
177
|
+
return () => {
|
|
178
|
+
cancelled = true
|
|
179
|
+
}
|
|
180
|
+
}, [original, modified, lang, dark])
|
|
181
|
+
|
|
182
|
+
function htmlFor(row: Row): string | undefined {
|
|
183
|
+
if (!hi) return undefined
|
|
184
|
+
if (row.type === "del") return hi.orig[(row.left ?? 1) - 1]
|
|
185
|
+
if (row.type === "add") return hi.mod[(row.right ?? 1) - 1]
|
|
186
|
+
return hi.orig[(row.left ?? 1) - 1] ?? hi.mod[(row.right ?? 1) - 1]
|
|
187
|
+
}
|
|
92
188
|
|
|
93
189
|
return (
|
|
94
190
|
<div
|
|
@@ -108,19 +204,19 @@ export function DiffViewer({
|
|
|
108
204
|
<div className="grid max-h-[28rem] grid-cols-2 overflow-auto">
|
|
109
205
|
<div className="border-r">
|
|
110
206
|
{rows.map((row, index) => (
|
|
111
|
-
<Line key={`l${index}`} row={row} side="left" />
|
|
207
|
+
<Line key={`l${index}`} row={row} side="left" html={htmlFor(row)} />
|
|
112
208
|
))}
|
|
113
209
|
</div>
|
|
114
210
|
<div>
|
|
115
211
|
{rows.map((row, index) => (
|
|
116
|
-
<Line key={`r${index}`} row={row} side="right" />
|
|
212
|
+
<Line key={`r${index}`} row={row} side="right" html={htmlFor(row)} />
|
|
117
213
|
))}
|
|
118
214
|
</div>
|
|
119
215
|
</div>
|
|
120
216
|
) : (
|
|
121
217
|
<div className="max-h-[28rem] overflow-auto">
|
|
122
218
|
{rows.map((row, index) => (
|
|
123
|
-
<Line key={index} row={row} />
|
|
219
|
+
<Line key={index} row={row} html={htmlFor(row)} />
|
|
124
220
|
))}
|
|
125
221
|
</div>
|
|
126
222
|
)}
|