@monkey-mini-app/ui 0.1.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/components.json +23 -0
- package/dist/globals.css +2 -0
- package/dist/index.js +138 -0
- package/dist/manifest.json +11 -0
- package/dist/src/blocks/activity-feed.tsx +9 -0
- package/dist/src/blocks/app-shell.tsx +37 -0
- package/dist/src/blocks/attachment-gallery.tsx +30 -0
- package/dist/src/blocks/bar-chart.tsx +33 -0
- package/dist/src/blocks/comment-thread.tsx +30 -0
- package/dist/src/blocks/description-list.tsx +16 -0
- package/dist/src/blocks/detail-panel.tsx +43 -0
- package/dist/src/blocks/donut-chart.tsx +38 -0
- package/dist/src/blocks/env-badge.tsx +23 -0
- package/dist/src/blocks/file-tree.tsx +5 -0
- package/dist/src/blocks/filter-bar.tsx +21 -0
- package/dist/src/blocks/gauge.tsx +13 -0
- package/dist/src/blocks/notification-center.tsx +22 -0
- package/dist/src/blocks/page-header.tsx +30 -0
- package/dist/src/blocks/progress-ring.tsx +25 -0
- package/dist/src/blocks/radar-chart.tsx +31 -0
- package/dist/src/blocks/request-inspector.tsx +34 -0
- package/dist/src/blocks/run-timeline.tsx +5 -0
- package/dist/src/blocks/scrollspy.tsx +42 -0
- package/dist/src/blocks/severity-chip.tsx +27 -0
- package/dist/src/blocks/sparkline.tsx +19 -0
- package/dist/src/blocks/stat-card.tsx +49 -0
- package/dist/src/blocks/status-badge.tsx +39 -0
- package/dist/src/blocks/terminal.tsx +10 -0
- package/dist/src/blocks/test-step-list.tsx +19 -0
- package/dist/src/blocks/trend-card.tsx +51 -0
- package/dist/src/components/accordion.tsx +72 -0
- package/dist/src/components/alert-dialog.tsx +185 -0
- package/dist/src/components/alert.tsx +76 -0
- package/dist/src/components/aspect-ratio.tsx +22 -0
- package/dist/src/components/attachment.tsx +207 -0
- package/dist/src/components/avatar.tsx +107 -0
- package/dist/src/components/badge.tsx +52 -0
- package/dist/src/components/breadcrumb.tsx +125 -0
- package/dist/src/components/bubble.tsx +128 -0
- package/dist/src/components/button-group.tsx +87 -0
- package/dist/src/components/button.tsx +58 -0
- package/dist/src/components/calendar.tsx +221 -0
- package/dist/src/components/card.tsx +103 -0
- package/dist/src/components/chart.tsx +371 -0
- package/dist/src/components/checkbox.tsx +29 -0
- package/dist/src/components/collapsible.tsx +19 -0
- package/dist/src/components/combobox.tsx +295 -0
- package/dist/src/components/command.tsx +196 -0
- package/dist/src/components/context-menu.tsx +271 -0
- package/dist/src/components/dialog.tsx +158 -0
- package/dist/src/components/drawer.tsx +226 -0
- package/dist/src/components/dropdown-menu.tsx +268 -0
- package/dist/src/components/empty.tsx +123 -0
- package/dist/src/components/field.tsx +236 -0
- package/dist/src/components/hover-card.tsx +49 -0
- package/dist/src/components/input-group.tsx +158 -0
- package/dist/src/components/input.tsx +20 -0
- package/dist/src/components/item.tsx +201 -0
- package/dist/src/components/kbd.tsx +26 -0
- package/dist/src/components/label.tsx +20 -0
- package/dist/src/components/marker.tsx +71 -0
- package/dist/src/components/menubar.tsx +280 -0
- package/dist/src/components/message-scroller.tsx +129 -0
- package/dist/src/components/message.tsx +92 -0
- package/dist/src/components/native-select.tsx +61 -0
- package/dist/src/components/navigation-menu.tsx +168 -0
- package/dist/src/components/pagination.tsx +135 -0
- package/dist/src/components/popover.tsx +88 -0
- package/dist/src/components/progress.tsx +83 -0
- package/dist/src/components/questionnaire.tsx +329 -0
- package/dist/src/components/radio-group.tsx +36 -0
- package/dist/src/components/resizable.tsx +50 -0
- package/dist/src/components/scroll-area.tsx +52 -0
- package/dist/src/components/select.tsx +201 -0
- package/dist/src/components/separator.tsx +23 -0
- package/dist/src/components/sheet.tsx +136 -0
- package/dist/src/components/sidebar.tsx +721 -0
- package/dist/src/components/skeleton.tsx +13 -0
- package/dist/src/components/slider.tsx +52 -0
- package/dist/src/components/spinner.tsx +10 -0
- package/dist/src/components/switch.tsx +32 -0
- package/dist/src/components/table.tsx +114 -0
- package/dist/src/components/tabs.tsx +82 -0
- package/dist/src/components/textarea.tsx +18 -0
- package/dist/src/components/toast.tsx +234 -0
- package/dist/src/components/toggle-group.tsx +89 -0
- package/dist/src/components/toggle.tsx +43 -0
- package/dist/src/components/tooltip.tsx +66 -0
- package/dist/src/composites/autocomplete.tsx +55 -0
- package/dist/src/composites/cascader.tsx +46 -0
- package/dist/src/composites/color-picker.tsx +19 -0
- package/dist/src/composites/confirm-dialog.tsx +56 -0
- package/dist/src/composites/copyable.tsx +37 -0
- package/dist/src/composites/currency-input.tsx +31 -0
- package/dist/src/composites/date-chrome.tsx +157 -0
- package/dist/src/composites/date-picker.tsx +91 -0
- package/dist/src/composites/date-range-picker.tsx +96 -0
- package/dist/src/composites/date-time-picker.tsx +115 -0
- package/dist/src/composites/date-time-range-picker.tsx +51 -0
- package/dist/src/composites/duration-input.tsx +122 -0
- package/dist/src/composites/mini-calendar.tsx +24 -0
- package/dist/src/composites/number-field.tsx +53 -0
- package/dist/src/composites/password-field.tsx +44 -0
- package/dist/src/composites/phone-input.tsx +22 -0
- package/dist/src/composites/rating.tsx +39 -0
- package/dist/src/composites/relative-date-picker.tsx +62 -0
- package/dist/src/composites/search-input.tsx +49 -0
- package/dist/src/composites/slider-range.tsx +30 -0
- package/dist/src/composites/tag-input.tsx +56 -0
- package/dist/src/composites/time-picker.tsx +199 -0
- package/dist/src/composites/time-range-picker.tsx +25 -0
- package/dist/src/composites/timezone-select.tsx +251 -0
- package/dist/src/composites/transfer.tsx +52 -0
- package/dist/src/composites/user-picker.tsx +40 -0
- package/dist/src/hooks/use-mobile.ts +19 -0
- package/dist/src/i18n/context.tsx +72 -0
- package/dist/src/i18n/en.ts +168 -0
- package/dist/src/i18n/zh.ts +160 -0
- package/dist/src/index.ts +134 -0
- package/dist/src/lib/icons.tsx +16 -0
- package/dist/src/lib/illustrations.tsx +573 -0
- package/dist/src/lib/utils.ts +6 -0
- package/dist/src/products/cells.tsx +18 -0
- package/dist/src/products/code-block.tsx +75 -0
- package/dist/src/products/code-editor.tsx +49 -0
- package/dist/src/products/column-meta.d.ts +9 -0
- package/dist/src/products/data-grid.tsx +689 -0
- package/dist/src/products/diff-viewer.tsx +129 -0
- package/dist/src/products/event-calendar.tsx +845 -0
- package/dist/src/products/export-csv.ts +25 -0
- package/dist/src/products/file-dropzone.tsx +41 -0
- package/dist/src/products/gantt.tsx +41 -0
- package/dist/src/products/jira-wiki-parse.ts +197 -0
- package/dist/src/products/jira-wiki.tsx +285 -0
- package/dist/src/products/jql-input.tsx +62 -0
- package/dist/src/products/jql-language.ts +70 -0
- package/dist/src/products/json-viewer.tsx +37 -0
- package/dist/src/products/kanban-issue-panel.tsx +98 -0
- package/dist/src/products/kanban.tsx +245 -0
- package/dist/src/products/log-viewer.tsx +33 -0
- package/dist/src/products/markdown-editor.tsx +63 -0
- package/dist/src/products/markdown.tsx +26 -0
- package/dist/src/products/rich-text-editor.tsx +84 -0
- package/dist/src/products/sortable-list.tsx +61 -0
- package/dist/src/products/stepper.tsx +89 -0
- package/dist/src/products/timeline.tsx +32 -0
- package/dist/src/products/tree-view.tsx +56 -0
- package/dist/src/styles/globals.css +352 -0
- package/package.json +100 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { diffLines } from "diff"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@monkey-mini-app/ui/lib/utils"
|
|
6
|
+
|
|
7
|
+
type Row = {
|
|
8
|
+
type: "equal" | "add" | "del"
|
|
9
|
+
text: string
|
|
10
|
+
left?: number
|
|
11
|
+
right?: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function toRows(original: string, modified: string): Row[] {
|
|
15
|
+
const parts = diffLines(original, modified)
|
|
16
|
+
const rows: Row[] = []
|
|
17
|
+
let left = 1
|
|
18
|
+
let right = 1
|
|
19
|
+
for (const part of parts) {
|
|
20
|
+
const lines = part.value.replace(/\n$/, "").split("\n")
|
|
21
|
+
for (const text of lines) {
|
|
22
|
+
if (part.added) {
|
|
23
|
+
rows.push({ type: "add", text, right: right++ })
|
|
24
|
+
} else if (part.removed) {
|
|
25
|
+
rows.push({ type: "del", text, left: left++ })
|
|
26
|
+
} else {
|
|
27
|
+
rows.push({ type: "equal", text, left: left++, right: right++ })
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return rows
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function stats(rows: Row[]) {
|
|
35
|
+
return {
|
|
36
|
+
added: rows.filter((row) => row.type === "add").length,
|
|
37
|
+
removed: rows.filter((row) => row.type === "del").length,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function Gutter({ n }: { n?: number }) {
|
|
42
|
+
return (
|
|
43
|
+
<span className="w-8 shrink-0 pr-2 text-right text-[11px] text-muted-foreground/70 select-none">
|
|
44
|
+
{n ?? ""}
|
|
45
|
+
</span>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function Line({
|
|
50
|
+
row,
|
|
51
|
+
side,
|
|
52
|
+
}: {
|
|
53
|
+
row: Row
|
|
54
|
+
side?: "left" | "right"
|
|
55
|
+
}) {
|
|
56
|
+
const hidden =
|
|
57
|
+
(side === "left" && row.type === "add") ||
|
|
58
|
+
(side === "right" && row.type === "del")
|
|
59
|
+
const mark = row.type === "add" ? "+" : row.type === "del" ? "-" : " "
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
className={cn(
|
|
63
|
+
"flex px-2",
|
|
64
|
+
hidden && "bg-muted/40",
|
|
65
|
+
!hidden && row.type === "add" && "bg-emerald-500/15 text-emerald-800 dark:text-emerald-300",
|
|
66
|
+
!hidden && row.type === "del" && "bg-destructive/10 text-destructive"
|
|
67
|
+
)}
|
|
68
|
+
>
|
|
69
|
+
{side !== "right" ? <Gutter n={hidden ? undefined : row.left} /> : null}
|
|
70
|
+
{side !== "left" ? <Gutter n={hidden ? undefined : row.right} /> : null}
|
|
71
|
+
<span className="w-4 shrink-0 select-none">{hidden ? " " : mark}</span>
|
|
72
|
+
<span className="min-w-0 flex-1 whitespace-pre-wrap break-all">
|
|
73
|
+
{hidden ? "" : row.text}
|
|
74
|
+
</span>
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function DiffViewer({
|
|
80
|
+
original,
|
|
81
|
+
modified,
|
|
82
|
+
mode = "unified",
|
|
83
|
+
fileName,
|
|
84
|
+
}: {
|
|
85
|
+
original: string
|
|
86
|
+
modified: string
|
|
87
|
+
mode?: "unified" | "split"
|
|
88
|
+
fileName?: string
|
|
89
|
+
}) {
|
|
90
|
+
const rows = toRows(original, modified)
|
|
91
|
+
const { added, removed } = stats(rows)
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div
|
|
95
|
+
data-testid="diff-viewer"
|
|
96
|
+
data-mode={mode}
|
|
97
|
+
className="overflow-hidden rounded-xl border bg-card font-mono text-xs leading-6"
|
|
98
|
+
>
|
|
99
|
+
<div className="flex flex-wrap items-center justify-between gap-2 border-b bg-muted/40 px-3 py-1.5">
|
|
100
|
+
<span className="truncate text-muted-foreground">{fileName ?? "diff"}</span>
|
|
101
|
+
<span className="tabular-nums">
|
|
102
|
+
<span className="text-emerald-700 dark:text-emerald-400">+{added}</span>
|
|
103
|
+
{" "}
|
|
104
|
+
<span className="text-destructive">-{removed}</span>
|
|
105
|
+
</span>
|
|
106
|
+
</div>
|
|
107
|
+
{mode === "split" ? (
|
|
108
|
+
<div className="grid max-h-[28rem] grid-cols-2 overflow-auto">
|
|
109
|
+
<div className="border-r">
|
|
110
|
+
{rows.map((row, index) => (
|
|
111
|
+
<Line key={`l${index}`} row={row} side="left" />
|
|
112
|
+
))}
|
|
113
|
+
</div>
|
|
114
|
+
<div>
|
|
115
|
+
{rows.map((row, index) => (
|
|
116
|
+
<Line key={`r${index}`} row={row} side="right" />
|
|
117
|
+
))}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
) : (
|
|
121
|
+
<div className="max-h-[28rem] overflow-auto">
|
|
122
|
+
{rows.map((row, index) => (
|
|
123
|
+
<Line key={index} row={row} />
|
|
124
|
+
))}
|
|
125
|
+
</div>
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
)
|
|
129
|
+
}
|