@monkey-mini-app/ui 0.1.0 → 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.
Files changed (203) hide show
  1. package/README.md +58 -0
  2. package/dist/globals.css +1 -1
  3. package/dist/index.js +12 -2
  4. package/dist/manifest.json +6 -6
  5. package/dist/runtime.js +9 -0
  6. package/dist/sdk.js +158 -0
  7. package/dist/src/blocks/activity-feed.tsx +7 -0
  8. package/dist/src/blocks/app-shell.tsx +1 -0
  9. package/dist/src/blocks/attachment-gallery.tsx +7 -0
  10. package/dist/src/blocks/bar-chart.tsx +15 -1
  11. package/dist/src/blocks/comment-thread.tsx +7 -0
  12. package/dist/src/blocks/dashboard-shell.tsx +109 -0
  13. package/dist/src/blocks/description-list.tsx +7 -0
  14. package/dist/src/blocks/detail-panel.tsx +1 -0
  15. package/dist/src/blocks/donut-chart.tsx +19 -2
  16. package/dist/src/blocks/env-badge.tsx +7 -0
  17. package/dist/src/blocks/env-table.tsx +316 -0
  18. package/dist/src/blocks/file-tree.tsx +7 -0
  19. package/dist/src/blocks/filter-bar.tsx +1 -0
  20. package/dist/src/blocks/form-sheet.tsx +160 -0
  21. package/dist/src/blocks/gauge.tsx +29 -6
  22. package/dist/src/blocks/list-detail.tsx +121 -0
  23. package/dist/src/blocks/notification-center.tsx +7 -0
  24. package/dist/src/blocks/page-header.tsx +1 -0
  25. package/dist/src/blocks/progress-ring.tsx +20 -2
  26. package/dist/src/blocks/radar-chart.tsx +18 -1
  27. package/dist/src/blocks/request-inspector.tsx +7 -0
  28. package/dist/src/blocks/reveal.tsx +56 -0
  29. package/dist/src/blocks/run-timeline.tsx +7 -0
  30. package/dist/src/blocks/scrollspy.tsx +7 -0
  31. package/dist/src/blocks/settings-split.tsx +154 -0
  32. package/dist/src/blocks/severity-chip.tsx +7 -0
  33. package/dist/src/blocks/sparkline.tsx +12 -3
  34. package/dist/src/blocks/stat-card.tsx +1 -0
  35. package/dist/src/blocks/status-badge.tsx +1 -0
  36. package/dist/src/blocks/table-page.tsx +83 -0
  37. package/dist/src/blocks/terminal.tsx +21 -3
  38. package/dist/src/blocks/test-step-list.tsx +7 -0
  39. package/dist/src/blocks/trend-card.tsx +7 -0
  40. package/dist/src/blocks/wizard-shell.tsx +132 -0
  41. package/dist/src/cdn-modules.d.ts +5 -0
  42. package/dist/src/components/accordion.tsx +7 -0
  43. package/dist/src/components/alert-dialog.tsx +7 -0
  44. package/dist/src/components/alert.tsx +7 -0
  45. package/dist/src/components/aspect-ratio.tsx +4 -0
  46. package/dist/src/components/attachment.tsx +4 -0
  47. package/dist/src/components/avatar.tsx +4 -0
  48. package/dist/src/components/badge.tsx +7 -0
  49. package/dist/src/components/breadcrumb.tsx +4 -0
  50. package/dist/src/components/bubble.tsx +4 -0
  51. package/dist/src/components/button-group.tsx +6 -0
  52. package/dist/src/components/button.tsx +7 -0
  53. package/dist/src/components/calendar.tsx +4 -0
  54. package/dist/src/components/card.tsx +8 -1
  55. package/dist/src/components/chart.tsx +7 -0
  56. package/dist/src/components/checkbox.tsx +5 -0
  57. package/dist/src/components/collapsible.tsx +4 -0
  58. package/dist/src/components/combobox.tsx +4 -0
  59. package/dist/src/components/command.tsx +6 -0
  60. package/dist/src/components/context-menu.tsx +4 -0
  61. package/dist/src/components/dialog.tsx +21 -0
  62. package/dist/src/components/drawer.tsx +4 -0
  63. package/dist/src/components/dropdown-menu.tsx +7 -0
  64. package/dist/src/components/empty.tsx +7 -0
  65. package/dist/src/components/field.tsx +6 -0
  66. package/dist/src/components/hover-card.tsx +4 -0
  67. package/dist/src/components/input-group.tsx +4 -0
  68. package/dist/src/components/input.tsx +7 -0
  69. package/dist/src/components/item.tsx +4 -0
  70. package/dist/src/components/kbd.tsx +4 -0
  71. package/dist/src/components/label.tsx +7 -0
  72. package/dist/src/components/marker.tsx +4 -0
  73. package/dist/src/components/menubar.tsx +4 -0
  74. package/dist/src/components/message-scroller.tsx +4 -0
  75. package/dist/src/components/message.tsx +4 -0
  76. package/dist/src/components/native-select.tsx +4 -0
  77. package/dist/src/components/navigation-menu.tsx +4 -0
  78. package/dist/src/components/pagination.tsx +4 -0
  79. package/dist/src/components/popover.tsx +7 -0
  80. package/dist/src/components/progress.tsx +7 -0
  81. package/dist/src/components/questionnaire.tsx +4 -0
  82. package/dist/src/components/radio-group.tsx +4 -0
  83. package/dist/src/components/resizable.tsx +7 -0
  84. package/dist/src/components/scroll-area.tsx +4 -0
  85. package/dist/src/components/select.tsx +7 -0
  86. package/dist/src/components/separator.tsx +5 -0
  87. package/dist/src/components/sheet.tsx +22 -0
  88. package/dist/src/components/sidebar.tsx +4 -0
  89. package/dist/src/components/skeleton.tsx +7 -0
  90. package/dist/src/components/slider.tsx +4 -0
  91. package/dist/src/components/spinner.tsx +6 -0
  92. package/dist/src/components/switch.tsx +7 -0
  93. package/dist/src/components/table.tsx +7 -0
  94. package/dist/src/components/tabs.tsx +7 -0
  95. package/dist/src/components/textarea.tsx +7 -0
  96. package/dist/src/components/toast.tsx +7 -0
  97. package/dist/src/components/toggle-group.tsx +4 -0
  98. package/dist/src/components/toggle.tsx +4 -0
  99. package/dist/src/components/tooltip.tsx +7 -0
  100. package/dist/src/composites/autocomplete.tsx +7 -0
  101. package/dist/src/composites/cascader.tsx +7 -0
  102. package/dist/src/composites/color-picker.tsx +7 -0
  103. package/dist/src/composites/confirm-dialog.tsx +7 -0
  104. package/dist/src/composites/copyable.tsx +9 -1
  105. package/dist/src/composites/currency-input.tsx +7 -0
  106. package/dist/src/composites/date-picker.tsx +7 -0
  107. package/dist/src/composites/date-range-picker.tsx +4 -0
  108. package/dist/src/composites/date-time-picker.tsx +7 -0
  109. package/dist/src/composites/date-time-range-picker.tsx +7 -0
  110. package/dist/src/composites/duration-input.tsx +7 -0
  111. package/dist/src/composites/mini-calendar.tsx +7 -0
  112. package/dist/src/composites/number-field.tsx +7 -0
  113. package/dist/src/composites/password-field.tsx +7 -0
  114. package/dist/src/composites/phone-input.tsx +7 -0
  115. package/dist/src/composites/rating.tsx +7 -0
  116. package/dist/src/composites/relative-date-picker.tsx +7 -0
  117. package/dist/src/composites/search-input.tsx +7 -0
  118. package/dist/src/composites/slider-range.tsx +7 -0
  119. package/dist/src/composites/tag-input.tsx +7 -0
  120. package/dist/src/composites/time-picker.tsx +11 -1
  121. package/dist/src/composites/time-range-picker.tsx +7 -0
  122. package/dist/src/composites/timezone-select.tsx +7 -0
  123. package/dist/src/composites/transfer.tsx +7 -0
  124. package/dist/src/composites/user-picker.tsx +7 -0
  125. package/dist/src/hooks/use-html-dark.ts +37 -0
  126. package/dist/src/hooks/use-mobile.ts +3 -0
  127. package/dist/src/i18n/en.ts +109 -2
  128. package/dist/src/i18n/zh.ts +99 -2
  129. package/dist/src/index.ts +147 -134
  130. package/dist/src/lib/clipboard.ts +10 -0
  131. package/dist/src/lib/illustrations.tsx +2 -2
  132. package/dist/src/products/code-block.tsx +35 -18
  133. package/dist/src/products/code-editor.tsx +156 -24
  134. package/dist/src/products/commit-graph.tsx +644 -0
  135. package/dist/src/products/data-grid.tsx +2 -1
  136. package/dist/src/products/diff-viewer.tsx +104 -8
  137. package/dist/src/products/event-calendar.tsx +28 -823
  138. package/dist/src/products/file-dropzone.tsx +7 -0
  139. package/dist/src/products/full-calendar/animations.ts +38 -0
  140. package/dist/src/products/full-calendar/calendar-body.tsx +77 -0
  141. package/dist/src/products/full-calendar/constants.ts +10 -0
  142. package/dist/src/products/full-calendar/contexts/calendar-context.tsx +255 -0
  143. package/dist/src/products/full-calendar/contexts/dnd-context.tsx +157 -0
  144. package/dist/src/products/full-calendar/dialogs/add-edit-event-dialog.tsx +187 -0
  145. package/dist/src/products/full-calendar/dialogs/delete-event-dialog.tsx +39 -0
  146. package/dist/src/products/full-calendar/dialogs/event-details-dialog.tsx +100 -0
  147. package/dist/src/products/full-calendar/dialogs/events-list-dialog.tsx +87 -0
  148. package/dist/src/products/full-calendar/dnd/draggable-event.tsx +45 -0
  149. package/dist/src/products/full-calendar/dnd/droppable-area.tsx +45 -0
  150. package/dist/src/products/full-calendar/dnd/resizable-event.tsx +179 -0
  151. package/dist/src/products/full-calendar/header/calendar-header.tsx +65 -0
  152. package/dist/src/products/full-calendar/header/date-navigator.tsx +110 -0
  153. package/dist/src/products/full-calendar/header/filter.tsx +58 -0
  154. package/dist/src/products/full-calendar/header/today-button.tsx +45 -0
  155. package/dist/src/products/full-calendar/header/user-select.tsx +64 -0
  156. package/dist/src/products/full-calendar/header/view-tabs.tsx +36 -0
  157. package/dist/src/products/full-calendar/helpers.ts +453 -0
  158. package/dist/src/products/full-calendar/hooks/use-time-range-create.ts +152 -0
  159. package/dist/src/products/full-calendar/hooks.ts +70 -0
  160. package/dist/src/products/full-calendar/interfaces.ts +23 -0
  161. package/dist/src/products/full-calendar/settings/settings.tsx +80 -0
  162. package/dist/src/products/full-calendar/shims/avatar-group.tsx +16 -0
  163. package/dist/src/products/full-calendar/shims/day-picker.tsx +1 -0
  164. package/dist/src/products/full-calendar/shims/motion.tsx +97 -0
  165. package/dist/src/products/full-calendar/shims/next-themes.ts +6 -0
  166. package/dist/src/products/full-calendar/shims/re-resizable.tsx +25 -0
  167. package/dist/src/products/full-calendar/shims/sonner.ts +4 -0
  168. package/dist/src/products/full-calendar/types.ts +8 -0
  169. package/dist/src/products/full-calendar/views/agenda-view/agenda-events.tsx +140 -0
  170. package/dist/src/products/full-calendar/views/month-view/calendar-month-view.tsx +69 -0
  171. package/dist/src/products/full-calendar/views/month-view/day-cell.tsx +201 -0
  172. package/dist/src/products/full-calendar/views/month-view/event-bullet.tsx +40 -0
  173. package/dist/src/products/full-calendar/views/month-view/month-event-badge.tsx +143 -0
  174. package/dist/src/products/full-calendar/views/week-and-day-view/calendar-day-view.tsx +295 -0
  175. package/dist/src/products/full-calendar/views/week-and-day-view/calendar-time-line.tsx +35 -0
  176. package/dist/src/products/full-calendar/views/week-and-day-view/calendar-week-view.tsx +253 -0
  177. package/dist/src/products/full-calendar/views/week-and-day-view/day-view-multi-day-events-row.tsx +73 -0
  178. package/dist/src/products/full-calendar/views/week-and-day-view/event-block.tsx +114 -0
  179. package/dist/src/products/full-calendar/views/week-and-day-view/render-grouped-events.tsx +49 -0
  180. package/dist/src/products/full-calendar/views/week-and-day-view/week-view-multi-day-events-row.tsx +143 -0
  181. package/dist/src/products/full-calendar/views/year-view/calendar-year-view.tsx +161 -0
  182. package/dist/src/products/gantt.tsx +7 -0
  183. package/dist/src/products/jira-wiki.tsx +1 -0
  184. package/dist/src/products/jql-input.tsx +340 -37
  185. package/dist/src/products/json-viewer.tsx +7 -0
  186. package/dist/src/products/kanban-issue-panel.tsx +7 -0
  187. package/dist/src/products/kanban.tsx +1 -0
  188. package/dist/src/products/log-viewer.tsx +390 -18
  189. package/dist/src/products/markdown-editor.tsx +21 -6
  190. package/dist/src/products/markdown.tsx +7 -0
  191. package/dist/src/products/rich-text-editor.tsx +65 -59
  192. package/dist/src/products/sortable-list.tsx +7 -0
  193. package/dist/src/products/stepper.tsx +219 -70
  194. package/dist/src/products/timeline.tsx +7 -0
  195. package/dist/src/products/tree-view.tsx +7 -0
  196. package/dist/src/sdk/app-error-boundary.tsx +240 -0
  197. package/dist/src/sdk/app-id.ts +7 -0
  198. package/dist/src/sdk/use-app.ts +126 -0
  199. package/dist/src/styles/globals.css +7 -7
  200. package/dist/vendors/lodash.js +20 -0
  201. package/dist/vendors/motion.js +12 -0
  202. package/package.json +23 -19
  203. package/dist/src/products/jql-language.ts +0 -70
@@ -6,6 +6,13 @@ import { Menu as MenuPrimitive } from "@base-ui/react/menu"
6
6
  import { cn } from "@monkey-mini-app/ui/lib/utils"
7
7
  import { ChevronRightIcon, CheckIcon } from "lucide-react"
8
8
 
9
+ /**
10
+ * Command menu on a trigger.
11
+ * @when Row `MoreHorizontal` actions. Free-form panel content → `Popover`.
12
+ * @example
13
+ * <DropdownMenu><DropdownMenuTrigger asChild><Button><Icon.MoreHorizontal /></Button></DropdownMenuTrigger><DropdownMenuContent><DropdownMenuItem onClick={edit}>编辑</DropdownMenuItem></DropdownMenuContent></DropdownMenu>
14
+ * @family Navigation
15
+ */
9
16
  function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {
10
17
  return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />
11
18
  }
@@ -2,6 +2,13 @@ import { cva, type VariantProps } from "class-variance-authority"
2
2
 
3
3
  import { cn } from "@monkey-mini-app/ui/lib/utils"
4
4
 
5
+ /**
6
+ * Empty-state block: media + title + description + action.
7
+ * @when Any list/panel with no rows — pair media with an `Illu*`.
8
+ * @example
9
+ * <Empty><EmptyHeader><EmptyMedia variant="icon"><IlluEmpty /></EmptyMedia><EmptyTitle>还没有数据</EmptyTitle><EmptyDescription>点右上角添加</EmptyDescription></EmptyHeader></Empty>
10
+ * @family Feedback & status
11
+ */
5
12
  function Empty({
6
13
  className,
7
14
  title,
@@ -67,6 +67,12 @@ const fieldVariants = cva(
67
67
  }
68
68
  )
69
69
 
70
+ /**
71
+ * @family Form
72
+ * @when Any form row that must read well and stay accessible.
73
+ * @example
74
+ * <Field><FieldLabel htmlFor="n">名称</FieldLabel><Input id="n" /><FieldDescription>显示在列表里</FieldDescription></Field>
75
+ */
70
76
  function Field({
71
77
  className,
72
78
  orientation = "vertical",
@@ -2,6 +2,10 @@ import { PreviewCard as PreviewCardPrimitive } from "@base-ui/react/preview-card
2
2
 
3
3
  import { cn } from "@monkey-mini-app/ui/lib/utils"
4
4
 
5
+ /**
6
+ * @family Surface
7
+ * @when Peek a user/issue without navigating. Needs a decision → `Dialog`.
8
+ */
5
9
  function HoverCard({ ...props }: PreviewCardPrimitive.Root.Props) {
6
10
  return <PreviewCardPrimitive.Root data-slot="hover-card" {...props} />
7
11
  }
@@ -8,6 +8,10 @@ import { Button } from "@monkey-mini-app/ui/components/button"
8
8
  import { Input } from "@monkey-mini-app/ui/components/input"
9
9
  import { Textarea } from "@monkey-mini-app/ui/components/textarea"
10
10
 
11
+ /**
12
+ * @family Form
13
+ * @when Search/url/amount fields with adornments; keep validation in `NumberField` etc.
14
+ */
11
15
  function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
12
16
  return (
13
17
  <div
@@ -3,6 +3,13 @@ import { Input as InputPrimitive } from "@base-ui/react/input"
3
3
 
4
4
  import { cn } from "@monkey-mini-app/ui/lib/utils"
5
5
 
6
+ /**
7
+ * Single-line text input.
8
+ * @when Plain text. Numbers → `NumberField`; secrets → `PasswordField`; search → `SearchInput`.
9
+ * @example
10
+ * <Input value={v} onChange={(e) => set(e.target.value)} placeholder="名称" />
11
+ * @family Form
12
+ */
6
13
  function Input({ className, type, ...props }: React.ComponentProps<"input">) {
7
14
  return (
8
15
  <InputPrimitive
@@ -56,6 +56,10 @@ const itemVariants = cva(
56
56
  }
57
57
  )
58
58
 
59
+ /**
60
+ * @family Layout & structure
61
+ * @when A uniform list row when `DataGrid` is too heavy.
62
+ */
59
63
  function Item({
60
64
  className,
61
65
  variant = "default",
@@ -1,5 +1,9 @@
1
1
  import { cn } from "@monkey-mini-app/ui/lib/utils"
2
2
 
3
+ /**
4
+ * @family Layout & structure
5
+ * @when Documenting ⌘K-style shortcuts in help panels.
6
+ */
3
7
  function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
4
8
  return (
5
9
  <kbd
@@ -4,6 +4,13 @@ import * as React from "react"
4
4
 
5
5
  import { cn } from "@monkey-mini-app/ui/lib/utils"
6
6
 
7
+ /**
8
+ * Accessible field label.
9
+ * @when Always bind `htmlFor` — bare text labels are not accessible.
10
+ * @example
11
+ * <Label htmlFor="name">名称</Label>
12
+ * @family Form
13
+ */
7
14
  function Label({ className, ...props }: React.ComponentProps<"label">) {
8
15
  return (
9
16
  <label
@@ -19,6 +19,10 @@ const markerVariants = cva(
19
19
  }
20
20
  )
21
21
 
22
+ /**
23
+ * @family Layout & structure
24
+ * @when Small state markers inside a sentence or legend.
25
+ */
22
26
  function Marker({
23
27
  className,
24
28
  variant = "default",
@@ -22,6 +22,10 @@ import {
22
22
  } from "@monkey-mini-app/ui/components/dropdown-menu"
23
23
  import { CheckIcon } from "lucide-react"
24
24
 
25
+ /**
26
+ * @family Navigation
27
+ * @when Rarely right for a panel-width mini-app — prefer `Tabs` / `DropdownMenu`.
28
+ */
25
29
  function Menubar({ className, ...props }: MenubarPrimitive.Props) {
26
30
  return (
27
31
  <MenubarPrimitive
@@ -16,6 +16,10 @@ function MessageScrollerProvider(
16
16
  return <MessageScrollerPrimitive.Provider {...props} />
17
17
  }
18
18
 
19
+ /**
20
+ * @family Realtime
21
+ * @when Streaming chat output. Logs by timestamp → `LogViewer`.
22
+ */
19
23
  function MessageScroller({
20
24
  className,
21
25
  ...props
@@ -12,6 +12,10 @@ function MessageGroup({ className, ...props }: React.ComponentProps<"div">) {
12
12
  )
13
13
  }
14
14
 
15
+ /**
16
+ * @family Surface
17
+ * @when Assistant/user turns. Timestamped log rows → `LogViewer`.
18
+ */
15
19
  function Message({
16
20
  className,
17
21
  align = "start",
@@ -7,6 +7,10 @@ type NativeSelectProps = Omit<React.ComponentProps<"select">, "size"> & {
7
7
  size?: "sm" | "default"
8
8
  }
9
9
 
10
+ /**
11
+ * @family Form
12
+ * @when Short option lists where a plain select is enough and `Select` is overkill.
13
+ */
10
14
  function NativeSelect({
11
15
  className,
12
16
  size = "default",
@@ -4,6 +4,10 @@ import { cva } from "class-variance-authority"
4
4
  import { cn } from "@monkey-mini-app/ui/lib/utils"
5
5
  import { ChevronDownIcon } from "lucide-react"
6
6
 
7
+ /**
8
+ * @family Navigation
9
+ * @when Not for mini-apps with one screen — use `Tabs` or `AppShell` sidebar.
10
+ */
7
11
  function NavigationMenu({
8
12
  align = "start",
9
13
  className,
@@ -7,6 +7,10 @@ import { useLabels } from "@monkey-mini-app/ui/i18n/context"
7
7
  import { Button } from "@monkey-mini-app/ui/components/button"
8
8
  import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
9
9
 
10
+ /**
11
+ * @family Navigation
12
+ * @when Only when you page by hand; `DataGrid` does this itself.
13
+ */
10
14
  function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
11
15
  return (
12
16
  <nav
@@ -3,6 +3,13 @@ import { Popover as PopoverPrimitive } from "@base-ui/react/popover"
3
3
 
4
4
  import { cn } from "@monkey-mini-app/ui/lib/utils"
5
5
 
6
+ /**
7
+ * Anchored floating panel.
8
+ * @when Small editor/filter anchored to a control. Menus of commands → `DropdownMenu`.
9
+ * @example
10
+ * <Popover><PopoverTrigger asChild><Button>筛选</Button></PopoverTrigger><PopoverContent>…</PopoverContent></Popover>
11
+ * @family Surface
12
+ */
6
13
  function Popover({ ...props }: PopoverPrimitive.Root.Props) {
7
14
  return <PopoverPrimitive.Root data-slot="popover" {...props} />
8
15
  }
@@ -4,6 +4,13 @@ import { Progress as ProgressPrimitive } from "@base-ui/react/progress"
4
4
 
5
5
  import { cn } from "@monkey-mini-app/ui/lib/utils"
6
6
 
7
+ /**
8
+ * Linear determinate progress bar.
9
+ * @when Full-width scan/import progress. Compact circle → `ProgressRing`.
10
+ * @example
11
+ * <Progress value={scan.progress} />
12
+ * @family Feedback & status
13
+ */
7
14
  function Progress({
8
15
  className,
9
16
  children,
@@ -8,6 +8,10 @@ import { useLabels } from "@monkey-mini-app/ui/i18n/context"
8
8
  import { buttonVariants, type Button } from "@monkey-mini-app/ui/components/button"
9
9
  import { CheckIcon } from "lucide-react"
10
10
 
11
+ /**
12
+ * @family Form
13
+ * @when Structured ask-the-user blocks; you persist the answers.
14
+ */
11
15
  function Questionnaire({
12
16
  className,
13
17
  ...props
@@ -3,6 +3,10 @@ import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group"
3
3
 
4
4
  import { cn } from "@monkey-mini-app/ui/lib/utils"
5
5
 
6
+ /**
7
+ * @family Form
8
+ * @when 2–5 mutually exclusive options. Many options → `Select`.
9
+ */
6
10
  function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
7
11
  return (
8
12
  <RadioGroupPrimitive
@@ -4,6 +4,13 @@ import * as ResizablePrimitive from "react-resizable-panels"
4
4
 
5
5
  import { cn } from "@monkey-mini-app/ui/lib/utils"
6
6
 
7
+ /**
8
+ * Draggable split panes.
9
+ * @family Layout & structure
10
+ * @when Master-detail or editor + preview inside the app body.
11
+ * @example
12
+ * <ResizablePanelGroup orientation="horizontal"><ResizablePanel>list</ResizablePanel><ResizableHandle /><ResizablePanel>detail</ResizablePanel></ResizablePanelGroup>
13
+ */
7
14
  function ResizablePanelGroup({
8
15
  className,
9
16
  ...props
@@ -2,6 +2,10 @@ import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"
2
2
 
3
3
  import { cn } from "@monkey-mini-app/ui/lib/utils"
4
4
 
5
+ /**
6
+ * @family Layout & structure
7
+ * @when A bounded panel (list in a card). Whole-page scroll → plain div.
8
+ */
5
9
  function ScrollArea({
6
10
  className,
7
11
  children,
@@ -6,6 +6,13 @@ import { Select as SelectPrimitive } from "@base-ui/react/select"
6
6
  import { cn } from "@monkey-mini-app/ui/lib/utils"
7
7
  import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react"
8
8
 
9
+ /**
10
+ * Dropdown single-choice from a fixed list.
11
+ * @when Closed set of options (searchable/large → `Autocomplete` or `DataGrid` filter).
12
+ * @example
13
+ * <Select value={v} onValueChange={set}><SelectTrigger><SelectValue placeholder="选择" /></SelectTrigger><SelectContent><SelectItem value="a">A</SelectItem></SelectContent></Select>
14
+ * @family Form
15
+ */
9
16
  const Select = SelectPrimitive.Root
10
17
 
11
18
  function SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {
@@ -2,6 +2,11 @@ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
2
2
 
3
3
  import { cn } from "@monkey-mini-app/ui/lib/utils"
4
4
 
5
+ /**
6
+ * Horizontal/vertical rule.
7
+ * @when Grouping inside panels.
8
+ * @family Layout & structure
9
+ */
5
10
  function Separator({
6
11
  className,
7
12
  orientation = "horizontal",
@@ -5,6 +5,13 @@ import { cn } from "@monkey-mini-app/ui/lib/utils"
5
5
  import { Button } from "@monkey-mini-app/ui/components/button"
6
6
  import { XIcon } from "lucide-react"
7
7
 
8
+ /**
9
+ * Slide-in side panel.
10
+ * @when Detail/edit panel that keeps the list visible — the usual master-detail pattern. Size it with `width` on `SheetContent`: the panel carries its own `data-[side=right]:sm:max-w-sm` / `data-[side=left]:sm:max-w-sm`, so a `max-w-*` in `className` loses at ≥sm (inline style or `!max-w-*` also work).
11
+ * @example
12
+ * <Sheet open={open} onOpenChange={setOpen}><SheetContent side="right"><SheetHeader><SheetTitle>详情</SheetTitle></SheetHeader>…</SheetContent></Sheet>
13
+ * @family Surface
14
+ */
8
15
  function Sheet({ ...props }: SheetPrimitive.Root.Props) {
9
16
  return <SheetPrimitive.Root data-slot="sheet" {...props} />
10
17
  }
@@ -39,17 +46,32 @@ function SheetContent({
39
46
  children,
40
47
  side = "right",
41
48
  showCloseButton = true,
49
+ width,
50
+ style,
42
51
  ...props
43
52
  }: SheetPrimitive.Popup.Props & {
44
53
  side?: "top" | "right" | "bottom" | "left"
45
54
  showCloseButton?: boolean
55
+ /**
56
+ * Panel width — a number is px. Applied as inline `maxWidth` on purpose: the base class
57
+ * already caps the sheet at `sm:max-w-sm` through a variant selector, which outranks a
58
+ * `max-w-*` utility the caller passes in `className`, so a prop is the only honest door.
59
+ */
60
+ width?: string | number
46
61
  }) {
62
+ const maxWidth =
63
+ width == null
64
+ ? undefined
65
+ : typeof width === "number"
66
+ ? `${width}px`
67
+ : width
47
68
  return (
48
69
  <SheetPortal>
49
70
  <SheetOverlay />
50
71
  <SheetPrimitive.Popup
51
72
  data-slot="sheet-content"
52
73
  data-side={side}
74
+ style={maxWidth == null ? style : { ...style, maxWidth }}
53
75
  className={cn(
54
76
  "fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
55
77
  className
@@ -147,6 +147,10 @@ function SidebarProvider({
147
147
  )
148
148
  }
149
149
 
150
+ /**
151
+ * @family Navigation
152
+ * @when Many sections in one app; `AppShell` already wires one for you.
153
+ */
150
154
  function Sidebar({
151
155
  side = "left",
152
156
  variant = "sidebar",
@@ -1,5 +1,12 @@
1
1
  import { cn } from "@monkey-mini-app/ui/lib/utils"
2
2
 
3
+ /**
4
+ * Pulse placeholder block.
5
+ * @when First paint while `call()` is pending — match the real layout's size.
6
+ * @example
7
+ * <div className="flex flex-col gap-2">{[0,1,2].map((i) => <Skeleton key={i} className="h-16 w-full" />)}</div>
8
+ * @family Feedback & status
9
+ */
3
10
  function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
4
11
  return (
5
12
  <div
@@ -2,6 +2,10 @@ import { Slider as SliderPrimitive } from "@base-ui/react/slider"
2
2
 
3
3
  import { cn } from "@monkey-mini-app/ui/lib/utils"
4
4
 
5
+ /**
6
+ * @family Form
7
+ * @when One numeric value. Range → `SliderRange`.
8
+ */
5
9
  function Slider({
6
10
  className,
7
11
  defaultValue,
@@ -1,6 +1,12 @@
1
1
  import { cn } from "@monkey-mini-app/ui/lib/utils"
2
2
  import { Loader2Icon } from "lucide-react"
3
3
 
4
+ /**
5
+ * @family Feedback & status
6
+ * @when Inside a button while `call()` is pending. Known % → `Progress`.
7
+ * @example
8
+ * <Button disabled><Spinner /> 保存中</Button>
9
+ */
4
10
  function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
5
11
  return (
6
12
  <Loader2Icon data-slot="spinner" role="status" aria-label="Loading" className={cn("size-4 animate-spin", className)} {...props} />
@@ -4,6 +4,13 @@ import { Switch as SwitchPrimitive } from "@base-ui/react/switch"
4
4
 
5
5
  import { cn } from "@monkey-mini-app/ui/lib/utils"
6
6
 
7
+ /**
8
+ * Boolean toggle.
9
+ * @when Immediate on/off settings (submit-on-toggle).
10
+ * @example
11
+ * <Switch checked={on} onCheckedChange={set} />
12
+ * @family Form
13
+ */
7
14
  function Switch({
8
15
  className,
9
16
  size = "default",
@@ -2,6 +2,13 @@ import * as React from "react"
2
2
 
3
3
  import { cn } from "@monkey-mini-app/ui/lib/utils"
4
4
 
5
+ /**
6
+ * Raw HTML table primitives.
7
+ * @when Only when you need full control of cells. Otherwise use `DataGrid` (sorting/filter/paging/CSV built in).
8
+ * @example
9
+ * <Table><TableHeader><TableRow><TableHead>列</TableHead></TableRow></TableHeader><TableBody><TableRow><TableCell>v</TableCell></TableRow></TableBody></Table>
10
+ * @family Data & tables
11
+ */
5
12
  function Table({ className, ...props }: React.ComponentProps<"table">) {
6
13
  return (
7
14
  <div
@@ -5,6 +5,13 @@ import { cva, type VariantProps } from "class-variance-authority"
5
5
 
6
6
  import { cn } from "@monkey-mini-app/ui/lib/utils"
7
7
 
8
+ /**
9
+ * Switch between views in one page.
10
+ * @when Board vs table, or settings sections. Navigation between routes/pages → keep it in your own state.
11
+ * @example
12
+ * <Tabs value={v} onValueChange={set}><TabsList><TabsTrigger value="a">A</TabsTrigger></TabsList><TabsContent value="a">…</TabsContent></Tabs>
13
+ * @family Navigation
14
+ */
8
15
  function Tabs({
9
16
  className,
10
17
  orientation = "horizontal",
@@ -2,6 +2,13 @@ import * as React from "react"
2
2
 
3
3
  import { cn } from "@monkey-mini-app/ui/lib/utils"
4
4
 
5
+ /**
6
+ * Multi-line text input.
7
+ * @when Notes/prompts. Code → `CodeEditor`; markdown → `MarkdownEditor`.
8
+ * @example
9
+ * <Textarea rows={4} value={v} onChange={(e) => set(e.target.value)} />
10
+ * @family Form
11
+ */
5
12
  function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
6
13
  return (
7
14
  <textarea
@@ -30,6 +30,13 @@ function ToastViewport({ className, ...props }: ToastPrimitive.Viewport.Props) {
30
30
  )
31
31
  }
32
32
 
33
+ /**
34
+ * Transient notification (provider + viewport + `toast()`).
35
+ * @when Confirm/save failures. The host already mounts the provider — call `toast(...)`.
36
+ * @example
37
+ * toast({ title: "已保存", description: "2 条更新" })
38
+ * @family Feedback & status
39
+ */
33
40
  function Toast({ className, ...props }: ToastPrimitive.Root.Props) {
34
41
  return (
35
42
  <ToastPrimitive.Root
@@ -20,6 +20,10 @@ const ToggleGroupContext = React.createContext<
20
20
  orientation: "horizontal",
21
21
  })
22
22
 
23
+ /**
24
+ * @family Form
25
+ * @when Multiple independent on/off buttons; exclusive selection → `Tabs`/`ButtonGroup`.
26
+ */
23
27
  function ToggleGroup({
24
28
  className,
25
29
  variant,
@@ -25,6 +25,10 @@ const toggleVariants = cva(
25
25
  }
26
26
  )
27
27
 
28
+ /**
29
+ * @family Form
30
+ * @when Binary formatting switch (bold, filters on).
31
+ */
28
32
  function Toggle({
29
33
  className,
30
34
  variant = "default",
@@ -17,6 +17,13 @@ function TooltipProvider({
17
17
  )
18
18
  }
19
19
 
20
+ /**
21
+ * Hover/focus hint on an icon or truncated label.
22
+ * @when Explaining an icon-only button. Never put an action in it.
23
+ * @example
24
+ * <Tooltip><TooltipTrigger asChild><Button size="icon" aria-label="刷新"><Icon.RefreshCw /></Button></TooltipTrigger><TooltipContent>刷新</TooltipContent></Tooltip>
25
+ * @family Surface
26
+ */
20
27
  function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {
21
28
  return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
22
29
  }
@@ -4,6 +4,13 @@ import * as React from "react"
4
4
 
5
5
  import { Input } from "@monkey-mini-app/ui/components/input"
6
6
 
7
+ /**
8
+ * Text input with filtered suggestions.
9
+ * @when Free text allowed but known values should be suggested. Strict pick-list → `Select`.
10
+ * @example
11
+ * <Autocomplete options={["main", "develop"]} onChange={(v) => set(v)} />
12
+ * @family Form
13
+ */
7
14
  export function Autocomplete({
8
15
  value,
9
16
  onChange,
@@ -4,6 +4,13 @@ import { NativeSelect, NativeSelectOption } from "@monkey-mini-app/ui/components
4
4
 
5
5
  export type CascaderNode = { value: string; label: string; children?: CascaderNode[] }
6
6
 
7
+ /**
8
+ * Multi-level drill-down picker.
9
+ * @when Hierarchical codes (region → site → line). Flat tree → `TreeView`.
10
+ * @example
11
+ * <Cascader options={[{ label: "华东", value: "cn", children: [{ label: "上海", value: "sha" }] }]} onChange={(v) => set(v)} />
12
+ * @family Form
13
+ */
7
14
  export function Cascader({
8
15
  options,
9
16
  value = [],
@@ -1,5 +1,12 @@
1
1
  "use client"
2
2
 
3
+ /**
4
+ * Swatch + hex colour input.
5
+ * @when Theme/label colour config. Never for secrets.
6
+ * @example
7
+ * <ColorPicker value={c} onChange={(v) => set(v)} />
8
+ * @family Form
9
+ */
3
10
  export function ColorPicker({
4
11
  value = "#111111",
5
12
  onChange,
@@ -12,6 +12,13 @@ import {
12
12
  } from "@monkey-mini-app/ui/components/alert-dialog"
13
13
  import { useLabels } from "@monkey-mini-app/ui/i18n/context"
14
14
 
15
+ /**
16
+ * Controlled yes/no dialog with loading-safe confirm.
17
+ * @when Any destructive action. Needs a form inside → compose `Dialog` yourself.
18
+ * @example
19
+ * <ConfirmDialog open={open} title="删除这条?" onConfirm={remove} onOpenChange={setOpen} />
20
+ * @family Surface
21
+ */
15
22
  export function ConfirmDialog({
16
23
  open,
17
24
  onOpenChange,
@@ -10,7 +10,15 @@ import {
10
10
  InputGroupInput,
11
11
  } from "@monkey-mini-app/ui/components/input-group"
12
12
  import { useLabels } from "@monkey-mini-app/ui/i18n/context"
13
+ import { writeClipboard } from "@monkey-mini-app/ui/lib/clipboard"
13
14
 
15
+ /**
16
+ * Inline text with a copy button.
17
+ * @when IDs, hashes, URLs, tokens the user pastes elsewhere.
18
+ * @example
19
+ * <Copyable value="i_1724918400" />
20
+ * @family Discovery & inspect
21
+ */
14
22
  export function Copyable({ value }: { value: string }) {
15
23
  const t = useLabels("copyable")
16
24
  const [copied, setCopied] = React.useState(false)
@@ -24,7 +32,7 @@ export function Copyable({ value }: { value: string }) {
24
32
  type="button"
25
33
  aria-label={t.copy}
26
34
  onClick={async () => {
27
- await navigator.clipboard.writeText(value)
35
+ if (!(await writeClipboard(value))) return
28
36
  setCopied(true)
29
37
  window.setTimeout(() => setCopied(false), 1200)
30
38
  }}
@@ -7,6 +7,13 @@ import {
7
7
  InputGroupText,
8
8
  } from "@monkey-mini-app/ui/components/input-group"
9
9
 
10
+ /**
11
+ * Amount input with grouping + currency prefix.
12
+ * @when Money fields; keeps the raw string out of your state.
13
+ * @example
14
+ * <CurrencyInput currency="CNY" onChange={(v) => set(v)} />
15
+ * @family Form
16
+ */
10
17
  export function CurrencyInput({
11
18
  value,
12
19
  onChange,
@@ -23,6 +23,13 @@ export type DatePickerProps = {
23
23
  className?: string
24
24
  }
25
25
 
26
+ /**
27
+ * Single calendar date (day precision).
28
+ * @when Filtering or storing one day. With a clock → `DateTimePicker`.
29
+ * @example
30
+ * <DatePicker value={d} onChange={(v) => set(v)} />
31
+ * @family Calendar & date
32
+ */
26
33
  export function DatePicker({
27
34
  value,
28
35
  onChange,