@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.
Files changed (149) hide show
  1. package/components.json +23 -0
  2. package/dist/globals.css +2 -0
  3. package/dist/index.js +138 -0
  4. package/dist/manifest.json +11 -0
  5. package/dist/src/blocks/activity-feed.tsx +9 -0
  6. package/dist/src/blocks/app-shell.tsx +37 -0
  7. package/dist/src/blocks/attachment-gallery.tsx +30 -0
  8. package/dist/src/blocks/bar-chart.tsx +33 -0
  9. package/dist/src/blocks/comment-thread.tsx +30 -0
  10. package/dist/src/blocks/description-list.tsx +16 -0
  11. package/dist/src/blocks/detail-panel.tsx +43 -0
  12. package/dist/src/blocks/donut-chart.tsx +38 -0
  13. package/dist/src/blocks/env-badge.tsx +23 -0
  14. package/dist/src/blocks/file-tree.tsx +5 -0
  15. package/dist/src/blocks/filter-bar.tsx +21 -0
  16. package/dist/src/blocks/gauge.tsx +13 -0
  17. package/dist/src/blocks/notification-center.tsx +22 -0
  18. package/dist/src/blocks/page-header.tsx +30 -0
  19. package/dist/src/blocks/progress-ring.tsx +25 -0
  20. package/dist/src/blocks/radar-chart.tsx +31 -0
  21. package/dist/src/blocks/request-inspector.tsx +34 -0
  22. package/dist/src/blocks/run-timeline.tsx +5 -0
  23. package/dist/src/blocks/scrollspy.tsx +42 -0
  24. package/dist/src/blocks/severity-chip.tsx +27 -0
  25. package/dist/src/blocks/sparkline.tsx +19 -0
  26. package/dist/src/blocks/stat-card.tsx +49 -0
  27. package/dist/src/blocks/status-badge.tsx +39 -0
  28. package/dist/src/blocks/terminal.tsx +10 -0
  29. package/dist/src/blocks/test-step-list.tsx +19 -0
  30. package/dist/src/blocks/trend-card.tsx +51 -0
  31. package/dist/src/components/accordion.tsx +72 -0
  32. package/dist/src/components/alert-dialog.tsx +185 -0
  33. package/dist/src/components/alert.tsx +76 -0
  34. package/dist/src/components/aspect-ratio.tsx +22 -0
  35. package/dist/src/components/attachment.tsx +207 -0
  36. package/dist/src/components/avatar.tsx +107 -0
  37. package/dist/src/components/badge.tsx +52 -0
  38. package/dist/src/components/breadcrumb.tsx +125 -0
  39. package/dist/src/components/bubble.tsx +128 -0
  40. package/dist/src/components/button-group.tsx +87 -0
  41. package/dist/src/components/button.tsx +58 -0
  42. package/dist/src/components/calendar.tsx +221 -0
  43. package/dist/src/components/card.tsx +103 -0
  44. package/dist/src/components/chart.tsx +371 -0
  45. package/dist/src/components/checkbox.tsx +29 -0
  46. package/dist/src/components/collapsible.tsx +19 -0
  47. package/dist/src/components/combobox.tsx +295 -0
  48. package/dist/src/components/command.tsx +196 -0
  49. package/dist/src/components/context-menu.tsx +271 -0
  50. package/dist/src/components/dialog.tsx +158 -0
  51. package/dist/src/components/drawer.tsx +226 -0
  52. package/dist/src/components/dropdown-menu.tsx +268 -0
  53. package/dist/src/components/empty.tsx +123 -0
  54. package/dist/src/components/field.tsx +236 -0
  55. package/dist/src/components/hover-card.tsx +49 -0
  56. package/dist/src/components/input-group.tsx +158 -0
  57. package/dist/src/components/input.tsx +20 -0
  58. package/dist/src/components/item.tsx +201 -0
  59. package/dist/src/components/kbd.tsx +26 -0
  60. package/dist/src/components/label.tsx +20 -0
  61. package/dist/src/components/marker.tsx +71 -0
  62. package/dist/src/components/menubar.tsx +280 -0
  63. package/dist/src/components/message-scroller.tsx +129 -0
  64. package/dist/src/components/message.tsx +92 -0
  65. package/dist/src/components/native-select.tsx +61 -0
  66. package/dist/src/components/navigation-menu.tsx +168 -0
  67. package/dist/src/components/pagination.tsx +135 -0
  68. package/dist/src/components/popover.tsx +88 -0
  69. package/dist/src/components/progress.tsx +83 -0
  70. package/dist/src/components/questionnaire.tsx +329 -0
  71. package/dist/src/components/radio-group.tsx +36 -0
  72. package/dist/src/components/resizable.tsx +50 -0
  73. package/dist/src/components/scroll-area.tsx +52 -0
  74. package/dist/src/components/select.tsx +201 -0
  75. package/dist/src/components/separator.tsx +23 -0
  76. package/dist/src/components/sheet.tsx +136 -0
  77. package/dist/src/components/sidebar.tsx +721 -0
  78. package/dist/src/components/skeleton.tsx +13 -0
  79. package/dist/src/components/slider.tsx +52 -0
  80. package/dist/src/components/spinner.tsx +10 -0
  81. package/dist/src/components/switch.tsx +32 -0
  82. package/dist/src/components/table.tsx +114 -0
  83. package/dist/src/components/tabs.tsx +82 -0
  84. package/dist/src/components/textarea.tsx +18 -0
  85. package/dist/src/components/toast.tsx +234 -0
  86. package/dist/src/components/toggle-group.tsx +89 -0
  87. package/dist/src/components/toggle.tsx +43 -0
  88. package/dist/src/components/tooltip.tsx +66 -0
  89. package/dist/src/composites/autocomplete.tsx +55 -0
  90. package/dist/src/composites/cascader.tsx +46 -0
  91. package/dist/src/composites/color-picker.tsx +19 -0
  92. package/dist/src/composites/confirm-dialog.tsx +56 -0
  93. package/dist/src/composites/copyable.tsx +37 -0
  94. package/dist/src/composites/currency-input.tsx +31 -0
  95. package/dist/src/composites/date-chrome.tsx +157 -0
  96. package/dist/src/composites/date-picker.tsx +91 -0
  97. package/dist/src/composites/date-range-picker.tsx +96 -0
  98. package/dist/src/composites/date-time-picker.tsx +115 -0
  99. package/dist/src/composites/date-time-range-picker.tsx +51 -0
  100. package/dist/src/composites/duration-input.tsx +122 -0
  101. package/dist/src/composites/mini-calendar.tsx +24 -0
  102. package/dist/src/composites/number-field.tsx +53 -0
  103. package/dist/src/composites/password-field.tsx +44 -0
  104. package/dist/src/composites/phone-input.tsx +22 -0
  105. package/dist/src/composites/rating.tsx +39 -0
  106. package/dist/src/composites/relative-date-picker.tsx +62 -0
  107. package/dist/src/composites/search-input.tsx +49 -0
  108. package/dist/src/composites/slider-range.tsx +30 -0
  109. package/dist/src/composites/tag-input.tsx +56 -0
  110. package/dist/src/composites/time-picker.tsx +199 -0
  111. package/dist/src/composites/time-range-picker.tsx +25 -0
  112. package/dist/src/composites/timezone-select.tsx +251 -0
  113. package/dist/src/composites/transfer.tsx +52 -0
  114. package/dist/src/composites/user-picker.tsx +40 -0
  115. package/dist/src/hooks/use-mobile.ts +19 -0
  116. package/dist/src/i18n/context.tsx +72 -0
  117. package/dist/src/i18n/en.ts +168 -0
  118. package/dist/src/i18n/zh.ts +160 -0
  119. package/dist/src/index.ts +134 -0
  120. package/dist/src/lib/icons.tsx +16 -0
  121. package/dist/src/lib/illustrations.tsx +573 -0
  122. package/dist/src/lib/utils.ts +6 -0
  123. package/dist/src/products/cells.tsx +18 -0
  124. package/dist/src/products/code-block.tsx +75 -0
  125. package/dist/src/products/code-editor.tsx +49 -0
  126. package/dist/src/products/column-meta.d.ts +9 -0
  127. package/dist/src/products/data-grid.tsx +689 -0
  128. package/dist/src/products/diff-viewer.tsx +129 -0
  129. package/dist/src/products/event-calendar.tsx +845 -0
  130. package/dist/src/products/export-csv.ts +25 -0
  131. package/dist/src/products/file-dropzone.tsx +41 -0
  132. package/dist/src/products/gantt.tsx +41 -0
  133. package/dist/src/products/jira-wiki-parse.ts +197 -0
  134. package/dist/src/products/jira-wiki.tsx +285 -0
  135. package/dist/src/products/jql-input.tsx +62 -0
  136. package/dist/src/products/jql-language.ts +70 -0
  137. package/dist/src/products/json-viewer.tsx +37 -0
  138. package/dist/src/products/kanban-issue-panel.tsx +98 -0
  139. package/dist/src/products/kanban.tsx +245 -0
  140. package/dist/src/products/log-viewer.tsx +33 -0
  141. package/dist/src/products/markdown-editor.tsx +63 -0
  142. package/dist/src/products/markdown.tsx +26 -0
  143. package/dist/src/products/rich-text-editor.tsx +84 -0
  144. package/dist/src/products/sortable-list.tsx +61 -0
  145. package/dist/src/products/stepper.tsx +89 -0
  146. package/dist/src/products/timeline.tsx +32 -0
  147. package/dist/src/products/tree-view.tsx +56 -0
  148. package/dist/src/styles/globals.css +352 -0
  149. 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
+ }