@object-ui/components 0.3.1 → 2.0.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 (326) hide show
  1. package/.turbo/turbo-build.log +34 -0
  2. package/CHANGELOG.md +13 -0
  3. package/README.md +13 -0
  4. package/dist/index.css +1 -1
  5. package/dist/index.js +36430 -25529
  6. package/dist/index.umd.cjs +53 -32
  7. package/dist/src/SchemaRenderer.d.ts +3 -0
  8. package/dist/src/custom/action-param-dialog.d.ts +21 -0
  9. package/dist/src/{ui → custom}/button-group.d.ts +1 -1
  10. package/dist/src/custom/field.d.ts +19 -0
  11. package/dist/src/custom/index.d.ts +14 -0
  12. package/dist/src/custom/input-group.d.ts +14 -0
  13. package/dist/src/{ui → custom}/item.d.ts +1 -1
  14. package/dist/src/custom/native-select.d.ts +12 -0
  15. package/dist/src/custom/navigation-overlay.d.ts +50 -0
  16. package/dist/src/custom/sort-builder.d.ts +22 -0
  17. package/dist/src/index.d.ts +2 -0
  18. package/dist/src/renderers/action/action-button.d.ts +11 -0
  19. package/dist/src/renderers/action/action-group.d.ts +25 -0
  20. package/dist/src/renderers/action/action-icon.d.ts +10 -0
  21. package/dist/src/renderers/action/action-menu.d.ts +19 -0
  22. package/dist/src/renderers/action/index.d.ts +0 -0
  23. package/dist/src/renderers/action/resolve-icon.d.ts +6 -0
  24. package/dist/src/renderers/data-display/table.d.ts +1 -1
  25. package/dist/src/renderers/layout/page.d.ts +1 -1
  26. package/dist/src/renderers/placeholders.d.ts +1 -1
  27. package/dist/src/ui/accordion.d.ts +4 -4
  28. package/dist/src/ui/alert-dialog.d.ts +17 -11
  29. package/dist/src/ui/alert.d.ts +4 -5
  30. package/dist/src/ui/aspect-ratio.d.ts +1 -1
  31. package/dist/src/ui/avatar.d.ts +3 -3
  32. package/dist/src/ui/badge.d.ts +3 -3
  33. package/dist/src/ui/breadcrumb.d.ts +16 -8
  34. package/dist/src/ui/calendar.d.ts +7 -7
  35. package/dist/src/ui/card.d.ts +7 -8
  36. package/dist/src/ui/carousel.d.ts +5 -6
  37. package/dist/src/ui/chart.d.ts +62 -0
  38. package/dist/src/ui/checkbox.d.ts +1 -1
  39. package/dist/src/ui/collapsible.d.ts +3 -3
  40. package/dist/src/ui/command.d.ts +78 -16
  41. package/dist/src/ui/context-menu.d.ts +14 -12
  42. package/dist/src/ui/dialog.d.ts +17 -13
  43. package/dist/src/ui/drawer.d.ts +19 -10
  44. package/dist/src/ui/dropdown-menu.d.ts +20 -18
  45. package/dist/src/ui/form.d.ts +6 -7
  46. package/dist/src/ui/hover-card.d.ts +3 -3
  47. package/dist/src/ui/index.d.ts +2 -8
  48. package/dist/src/ui/input-otp.d.ts +30 -7
  49. package/dist/src/ui/label.d.ts +2 -1
  50. package/dist/src/ui/menubar.d.ts +19 -17
  51. package/dist/src/ui/navigation-menu.d.ts +9 -11
  52. package/dist/src/ui/pagination.d.ts +25 -10
  53. package/dist/src/ui/popover.d.ts +4 -5
  54. package/dist/src/ui/progress.d.ts +1 -1
  55. package/dist/src/ui/radio-group.d.ts +2 -2
  56. package/dist/src/ui/resizable.d.ts +5 -8
  57. package/dist/src/ui/scroll-area.d.ts +2 -2
  58. package/dist/src/ui/select.d.ts +11 -13
  59. package/dist/src/ui/sheet.d.ts +23 -11
  60. package/dist/src/ui/sidebar.d.ts +27 -29
  61. package/dist/src/ui/skeleton.d.ts +1 -1
  62. package/dist/src/ui/slider.d.ts +1 -1
  63. package/dist/src/ui/sonner.d.ts +2 -1
  64. package/dist/src/ui/switch.d.ts +2 -2
  65. package/dist/src/ui/tabs.d.ts +1 -1
  66. package/dist/src/ui/textarea.d.ts +1 -1
  67. package/dist/src/ui/toast.d.ts +22 -0
  68. package/dist/src/ui/toggle-group.d.ts +8 -3
  69. package/dist/src/ui/toggle.d.ts +4 -1
  70. package/dist/src/ui/tooltip.d.ts +4 -4
  71. package/dist/src/ui/typography.d.ts +21 -0
  72. package/package.json +20 -9
  73. package/shadcn-components.json +52 -47
  74. package/src/SchemaRenderer.tsx +28 -0
  75. package/src/__tests__/PageRendererRegions.test.tsx +668 -0
  76. package/src/__tests__/Registry.test.ts +21 -0
  77. package/src/__tests__/basic-renderers.test.tsx +1 -1
  78. package/src/__tests__/complex-disclosure-renderers.test.tsx +3 -2
  79. package/src/__tests__/compliance.test.tsx +72 -0
  80. package/src/__tests__/feedback-overlay-renderers.test.tsx +1 -1
  81. package/src/__tests__/form-renderers.test.tsx +1 -1
  82. package/src/__tests__/layout-data-renderers.test.tsx +1 -1
  83. package/src/__tests__/navigation-overlay.test.tsx +273 -0
  84. package/src/__tests__/view-compliance.test.tsx +153 -0
  85. package/src/custom/action-param-dialog.tsx +264 -0
  86. package/src/{ui → custom}/button-group.tsx +1 -1
  87. package/src/{ui → custom}/combobox.tsx +3 -3
  88. package/src/{ui → custom}/date-picker.tsx +3 -3
  89. package/src/custom/field.tsx +81 -0
  90. package/src/{ui → custom}/filter-builder.tsx +3 -3
  91. package/src/custom/index.ts +14 -0
  92. package/src/custom/input-group.tsx +53 -0
  93. package/src/{ui → custom}/item.tsx +1 -1
  94. package/src/custom/native-select.tsx +33 -0
  95. package/src/custom/navigation-overlay.tsx +296 -0
  96. package/src/custom/sort-builder.tsx +129 -0
  97. package/src/index.css +20 -1
  98. package/src/index.ts +2 -0
  99. package/src/renderers/action/action-button.tsx +147 -0
  100. package/src/renderers/action/action-group.tsx +270 -0
  101. package/src/renderers/action/action-icon.tsx +150 -0
  102. package/src/renderers/action/action-menu.tsx +203 -0
  103. package/src/renderers/action/index.ts +18 -0
  104. package/src/renderers/action/resolve-icon.ts +35 -0
  105. package/src/renderers/basic/button-group.tsx +1 -0
  106. package/src/renderers/basic/div.tsx +12 -1
  107. package/src/renderers/basic/html.tsx +1 -0
  108. package/src/renderers/basic/icon.tsx +1 -0
  109. package/src/renderers/basic/image.tsx +1 -0
  110. package/src/renderers/basic/navigation-menu.tsx +1 -0
  111. package/src/renderers/basic/pagination.tsx +31 -4
  112. package/src/renderers/basic/separator.tsx +1 -0
  113. package/src/renderers/basic/span.tsx +12 -1
  114. package/src/renderers/basic/text.tsx +4 -2
  115. package/src/renderers/complex/__tests__/data-table-batch-editing.test.tsx +275 -0
  116. package/src/renderers/complex/__tests__/data-table-cell-renderer.test.tsx +120 -0
  117. package/src/renderers/complex/__tests__/data-table-editing.test.tsx +221 -0
  118. package/src/renderers/complex/carousel.tsx +1 -0
  119. package/src/renderers/complex/data-table.tsx +355 -95
  120. package/src/renderers/complex/filter-builder.tsx +2 -1
  121. package/src/renderers/complex/resizable.tsx +2 -1
  122. package/src/renderers/complex/scroll-area.tsx +25 -7
  123. package/src/renderers/complex/table.tsx +1 -0
  124. package/src/renderers/data-display/alert.tsx +1 -0
  125. package/src/renderers/data-display/avatar.tsx +1 -0
  126. package/src/renderers/data-display/badge.tsx +1 -0
  127. package/src/renderers/data-display/breadcrumb.tsx +1 -0
  128. package/src/renderers/data-display/kbd.tsx +1 -0
  129. package/src/renderers/data-display/list.tsx +21 -49
  130. package/src/renderers/data-display/statistic.tsx +21 -5
  131. package/src/renderers/data-display/table.tsx +21 -11
  132. package/src/renderers/data-display/tree-view.tsx +7 -1
  133. package/src/renderers/disclosure/accordion.tsx +1 -0
  134. package/src/renderers/disclosure/collapsible.tsx +1 -0
  135. package/src/renderers/disclosure/toggle-group.tsx +2 -0
  136. package/src/renderers/feedback/empty.tsx +1 -0
  137. package/src/renderers/feedback/loading.tsx +2 -1
  138. package/src/renderers/feedback/progress.tsx +1 -0
  139. package/src/renderers/feedback/skeleton.tsx +1 -0
  140. package/src/renderers/feedback/sonner.tsx +1 -0
  141. package/src/renderers/feedback/spinner.tsx +1 -0
  142. package/src/renderers/feedback/toast.tsx +1 -0
  143. package/src/renderers/feedback/toaster.tsx +1 -0
  144. package/src/renderers/form/button.tsx +35 -1
  145. package/src/renderers/form/calendar.tsx +1 -0
  146. package/src/renderers/form/checkbox.tsx +38 -16
  147. package/src/renderers/form/combobox.tsx +2 -1
  148. package/src/renderers/form/command.tsx +1 -0
  149. package/src/renderers/form/date-picker.tsx +1 -0
  150. package/src/renderers/form/file-upload.tsx +1 -0
  151. package/src/renderers/form/form.tsx +115 -19
  152. package/src/renderers/form/input-otp.tsx +1 -0
  153. package/src/renderers/form/input.tsx +3 -0
  154. package/src/renderers/form/label.tsx +1 -0
  155. package/src/renderers/form/radio-group.tsx +1 -0
  156. package/src/renderers/form/select.tsx +35 -15
  157. package/src/renderers/form/slider.tsx +1 -0
  158. package/src/renderers/form/switch.tsx +1 -0
  159. package/src/renderers/form/textarea.tsx +50 -27
  160. package/src/renderers/form/toggle.tsx +3 -45
  161. package/src/renderers/index.ts +1 -0
  162. package/src/renderers/layout/aspect-ratio.tsx +2 -1
  163. package/src/renderers/layout/card.tsx +10 -2
  164. package/src/renderers/layout/container.tsx +1 -0
  165. package/src/renderers/layout/flex.tsx +1 -0
  166. package/src/renderers/layout/grid.tsx +23 -8
  167. package/src/renderers/layout/page.tsx +433 -57
  168. package/src/renderers/layout/semantic.tsx +1 -0
  169. package/src/renderers/layout/stack.tsx +2 -1
  170. package/src/renderers/layout/tabs.tsx +43 -17
  171. package/src/renderers/navigation/header-bar.tsx +1 -0
  172. package/src/renderers/navigation/sidebar.tsx +11 -0
  173. package/src/renderers/overlay/alert-dialog.tsx +1 -0
  174. package/src/renderers/overlay/context-menu.tsx +1 -0
  175. package/src/renderers/overlay/dialog.tsx +1 -0
  176. package/src/renderers/overlay/drawer.tsx +1 -0
  177. package/src/renderers/overlay/dropdown-menu.tsx +1 -0
  178. package/src/renderers/overlay/hover-card.tsx +1 -0
  179. package/src/renderers/overlay/menubar.tsx +1 -0
  180. package/src/renderers/overlay/popover.tsx +1 -0
  181. package/src/renderers/overlay/sheet.tsx +1 -0
  182. package/src/renderers/overlay/tooltip.tsx +1 -0
  183. package/src/renderers/placeholders.tsx +4 -4
  184. package/src/stories/CRMApp.stories.tsx +706 -0
  185. package/src/stories/Guide.mdx +55 -0
  186. package/src/stories/Introduction.mdx +61 -0
  187. package/src/stories/MockedData.stories.tsx +121 -0
  188. package/src/stories/assets/accessibility.png +0 -0
  189. package/src/stories/assets/accessibility.svg +1 -0
  190. package/src/stories/assets/addon-library.png +0 -0
  191. package/src/stories/assets/assets.png +0 -0
  192. package/src/stories/assets/avif-test-image.avif +0 -0
  193. package/src/stories/assets/context.png +0 -0
  194. package/src/stories/assets/discord.svg +1 -0
  195. package/src/stories/assets/docs.png +0 -0
  196. package/src/stories/assets/figma-plugin.png +0 -0
  197. package/src/stories/assets/github.svg +1 -0
  198. package/src/stories/assets/share.png +0 -0
  199. package/src/stories/assets/styling.png +0 -0
  200. package/src/stories/assets/testing.png +0 -0
  201. package/src/stories/assets/theming.png +0 -0
  202. package/src/stories/assets/tutorials.svg +1 -0
  203. package/src/stories/assets/youtube.svg +1 -0
  204. package/src/stories/button.css +30 -0
  205. package/src/stories/header.css +32 -0
  206. package/src/stories/page.css +68 -0
  207. package/src/stories-json/accordion.stories.tsx +43 -0
  208. package/src/stories-json/aggrid.stories.tsx +103 -0
  209. package/src/stories-json/alert.stories.tsx +39 -0
  210. package/src/stories-json/aspect-ratio.stories.tsx +34 -0
  211. package/src/stories-json/avatar.stories.tsx +38 -0
  212. package/src/stories-json/badge.stories.tsx +53 -0
  213. package/src/stories-json/breadcrumb.stories.tsx +30 -0
  214. package/src/stories-json/button-group.stories.tsx +43 -0
  215. package/src/stories-json/button.stories.tsx +73 -0
  216. package/src/stories-json/calendar.stories.tsx +85 -0
  217. package/src/stories-json/card.stories.tsx +48 -0
  218. package/src/stories-json/carousel.stories.tsx +33 -0
  219. package/src/stories-json/charts.stories.tsx +195 -0
  220. package/src/stories-json/chatbot.stories.tsx +248 -0
  221. package/src/stories-json/code-editor.stories.tsx +92 -0
  222. package/src/stories-json/collapsible.stories.tsx +40 -0
  223. package/src/stories-json/controls.stories.tsx +36 -0
  224. package/src/stories-json/crm-live-data.stories.tsx +154 -0
  225. package/src/stories-json/dashboard.stories.tsx +318 -0
  226. package/src/stories-json/data-table.stories.tsx +136 -0
  227. package/src/stories-json/data_display_extras.stories.tsx +102 -0
  228. package/src/stories-json/date-picker.stories.tsx +28 -0
  229. package/src/stories-json/detail-view.stories.tsx +258 -0
  230. package/src/stories-json/dialog.stories.tsx +43 -0
  231. package/src/stories-json/feedback_extras.stories.tsx +40 -0
  232. package/src/stories-json/feedback_others.stories.tsx +46 -0
  233. package/src/stories-json/form-variants.stories.tsx +210 -0
  234. package/src/stories-json/form_advanced.stories.tsx +117 -0
  235. package/src/stories-json/form_extras.stories.tsx +123 -0
  236. package/src/stories-json/grid.stories.tsx +56 -0
  237. package/src/stories-json/icon.stories.tsx +36 -0
  238. package/src/stories-json/input.stories.tsx +52 -0
  239. package/src/stories-json/kanban.stories.tsx +295 -0
  240. package/src/stories-json/layout_extended.stories.tsx +76 -0
  241. package/src/stories-json/layout_flex.stories.tsx +107 -0
  242. package/src/stories-json/list-view.stories.tsx +97 -0
  243. package/src/stories-json/markdown.stories.tsx +129 -0
  244. package/src/stories-json/menus.stories.tsx +63 -0
  245. package/src/stories-json/metric-card.stories.tsx +143 -0
  246. package/src/stories-json/navigation-menu.stories.tsx +37 -0
  247. package/src/stories-json/object-aggrid-advanced.stories.tsx +389 -0
  248. package/src/stories-json/object-aggrid.stories.tsx +252 -0
  249. package/src/stories-json/object-form.stories.tsx +130 -0
  250. package/src/stories-json/object-gantt.stories.tsx +114 -0
  251. package/src/stories-json/object-grid.stories.tsx +315 -0
  252. package/src/stories-json/object-map.stories.tsx +116 -0
  253. package/src/stories-json/object-view.stories.tsx +118 -0
  254. package/src/stories-json/overlay_extras.stories.tsx +113 -0
  255. package/src/stories-json/overlay_others.stories.tsx +76 -0
  256. package/src/stories-json/page.stories.tsx +55 -0
  257. package/src/stories-json/reports.stories.tsx +163 -0
  258. package/src/stories-json/resizable.stories.tsx +44 -0
  259. package/src/stories-json/select.stories.tsx +34 -0
  260. package/src/stories-json/separator.stories.tsx +41 -0
  261. package/src/stories-json/sidebar.stories.tsx +147 -0
  262. package/src/stories-json/statistic.stories.tsx +44 -0
  263. package/src/stories-json/tabs.stories.tsx +51 -0
  264. package/src/stories-json/timeline.stories.tsx +188 -0
  265. package/src/stories-json/typography.stories.tsx +45 -0
  266. package/src/ui/accordion.tsx +47 -53
  267. package/src/ui/alert-dialog.tsx +103 -117
  268. package/src/ui/alert.tsx +35 -36
  269. package/src/ui/aspect-ratio.tsx +1 -5
  270. package/src/ui/avatar.tsx +41 -42
  271. package/src/ui/badge.tsx +6 -15
  272. package/src/ui/breadcrumb.tsx +81 -75
  273. package/src/ui/button.tsx +10 -11
  274. package/src/ui/calendar.tsx +178 -51
  275. package/src/ui/card.tsx +51 -110
  276. package/src/ui/carousel.tsx +136 -113
  277. package/src/ui/chart.tsx +367 -0
  278. package/src/ui/checkbox.tsx +20 -22
  279. package/src/ui/collapsible.tsx +5 -25
  280. package/src/ui/command.tsx +106 -135
  281. package/src/ui/context-menu.tsx +69 -116
  282. package/src/ui/dialog.tsx +94 -113
  283. package/src/ui/drawer.tsx +82 -99
  284. package/src/ui/dropdown-menu.tsx +134 -188
  285. package/src/ui/form.tsx +51 -40
  286. package/src/ui/hover-card.tsx +18 -33
  287. package/src/ui/index.ts +2 -8
  288. package/src/ui/input-otp.tsx +42 -52
  289. package/src/ui/input.tsx +13 -15
  290. package/src/ui/label.tsx +17 -15
  291. package/src/ui/menubar.tsx +188 -206
  292. package/src/ui/navigation-menu.tsx +96 -136
  293. package/src/ui/pagination.tsx +86 -96
  294. package/src/ui/popover.tsx +24 -41
  295. package/src/ui/progress.tsx +21 -22
  296. package/src/ui/radio-group.tsx +19 -20
  297. package/src/ui/resizable.tsx +32 -42
  298. package/src/ui/scroll-area.tsx +38 -48
  299. package/src/ui/select.tsx +129 -157
  300. package/src/ui/separator.tsx +2 -2
  301. package/src/ui/sheet.tsx +110 -107
  302. package/src/ui/sidebar.tsx +442 -408
  303. package/src/ui/skeleton.tsx +6 -11
  304. package/src/ui/slider.tsx +19 -54
  305. package/src/ui/sonner.tsx +19 -1
  306. package/src/ui/switch.tsx +19 -21
  307. package/src/ui/tabs.tsx +6 -37
  308. package/src/ui/textarea.tsx +8 -4
  309. package/src/ui/toast.tsx +137 -0
  310. package/src/ui/toggle-group.tsx +28 -37
  311. package/src/ui/toggle.tsx +19 -19
  312. package/src/ui/tooltip.tsx +21 -52
  313. package/src/ui/typography.tsx +85 -0
  314. package/tsconfig.json +1 -1
  315. package/vite.config.ts +9 -1
  316. package/vitest.config.ts +5 -0
  317. package/ISSUES_FOUND.md +0 -128
  318. /package/dist/src/{ui → custom}/combobox.d.ts +0 -0
  319. /package/dist/src/{ui → custom}/date-picker.d.ts +0 -0
  320. /package/dist/src/{ui → custom}/empty.d.ts +0 -0
  321. /package/dist/src/{ui → custom}/filter-builder.d.ts +0 -0
  322. /package/dist/src/{ui → custom}/kbd.d.ts +0 -0
  323. /package/dist/src/{ui → custom}/spinner.d.ts +0 -0
  324. /package/src/{ui → custom}/empty.tsx +0 -0
  325. /package/src/{ui → custom}/kbd.tsx +0 -0
  326. /package/src/{ui → custom}/spinner.tsx +0 -0
@@ -0,0 +1,270 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * action:group — Toolbar or button group for organizing related actions.
11
+ *
12
+ * Supports two display modes:
13
+ * - 'inline': Renders all actions as a horizontal button row
14
+ * - 'dropdown': Renders a primary button + dropdown for overflow
15
+ *
16
+ * Filters actions by location when `location` prop is provided.
17
+ */
18
+
19
+ import React, { forwardRef, useCallback, useState } from 'react';
20
+ import { ComponentRegistry } from '@object-ui/core';
21
+ import type { ActionSchema, ActionGroup, ActionLocation } from '@object-ui/types';
22
+ import { useAction } from '@object-ui/react';
23
+ import { useCondition } from '@object-ui/react';
24
+ import { Button } from '../../ui';
25
+ import {
26
+ DropdownMenu,
27
+ DropdownMenuContent,
28
+ DropdownMenuItem,
29
+ DropdownMenuSeparator,
30
+ DropdownMenuTrigger,
31
+ } from '../../ui';
32
+ import { cn } from '../../lib/utils';
33
+ import { Loader2, ChevronDown } from 'lucide-react';
34
+ import { resolveIcon } from './resolve-icon';
35
+
36
+ export interface ActionGroupSchema {
37
+ type: 'action:group';
38
+ /** Group name */
39
+ name?: string;
40
+ /** Group label */
41
+ label?: string;
42
+ /** Group icon */
43
+ icon?: string;
44
+ /** Actions in this group */
45
+ actions?: ActionSchema[];
46
+ /** Display mode: inline button row or dropdown */
47
+ display?: 'dropdown' | 'inline';
48
+ /** Filter actions by location */
49
+ location?: ActionLocation;
50
+ /** Group visibility condition */
51
+ visible?: string;
52
+ /** Button variant for inline actions */
53
+ variant?: string;
54
+ /** Button size for inline actions */
55
+ size?: string;
56
+ /** Custom CSS class */
57
+ className?: string;
58
+ [key: string]: any;
59
+ }
60
+
61
+ /**
62
+ * Inline action button within a group.
63
+ */
64
+ const InlineActionButton: React.FC<{
65
+ action: ActionSchema;
66
+ variant?: string;
67
+ size?: string;
68
+ onExecute: (action: ActionSchema) => Promise<void>;
69
+ }> = ({ action, variant, size, onExecute }) => {
70
+ const [loading, setLoading] = useState(false);
71
+ const isVisible = useCondition(action.visible ? `\${${action.visible}}` : undefined);
72
+ const isEnabled = useCondition(action.enabled ? `\${${action.enabled}}` : undefined);
73
+
74
+ const Icon = resolveIcon(action.icon);
75
+ const btnVariant = (action.variant as string) === 'primary' ? 'default' : (action.variant || variant || 'outline');
76
+ const btnSize = action.size === 'md' ? 'default' : (action.size || size || 'sm');
77
+
78
+ const handleClick = useCallback(async () => {
79
+ if (loading) return;
80
+ setLoading(true);
81
+ try {
82
+ await onExecute(action);
83
+ } finally {
84
+ setLoading(false);
85
+ }
86
+ }, [action, onExecute, loading]);
87
+
88
+ if (action.visible && !isVisible) return null;
89
+
90
+ return (
91
+ <Button
92
+ type="button"
93
+ variant={btnVariant as any}
94
+ size={btnSize as any}
95
+ className={action.className}
96
+ disabled={(action.enabled ? !isEnabled : false) || loading}
97
+ onClick={handleClick}
98
+ >
99
+ {loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
100
+ {!loading && Icon && <Icon className={cn('h-4 w-4', action.label && 'mr-2')} />}
101
+ {action.label}
102
+ </Button>
103
+ );
104
+ };
105
+
106
+ InlineActionButton.displayName = 'InlineActionButton';
107
+
108
+ const ActionGroupRenderer = forwardRef<HTMLDivElement, { schema: ActionGroupSchema; [key: string]: any }>(
109
+ ({ schema, className, ...props }, ref) => {
110
+ const {
111
+ 'data-obj-id': dataObjId,
112
+ 'data-obj-type': dataObjType,
113
+ style,
114
+ ...rest
115
+ } = props;
116
+
117
+ const { execute } = useAction();
118
+ const [dropdownLoading, setDropdownLoading] = useState(false);
119
+
120
+ const isVisible = useCondition(schema.visible ? `\${${schema.visible}}` : undefined);
121
+
122
+ // Filter actions by location if specified
123
+ let actions = schema.actions || [];
124
+ if (schema.location) {
125
+ actions = actions.filter(
126
+ a => !a.locations || a.locations.includes(schema.location!),
127
+ );
128
+ }
129
+
130
+ const handleExecute = useCallback(
131
+ async (action: ActionSchema) => {
132
+ await execute({
133
+ type: action.type,
134
+ name: action.name,
135
+ target: action.target,
136
+ execute: action.execute,
137
+ endpoint: action.endpoint,
138
+ method: action.method,
139
+ params: action.params as Record<string, any> | undefined,
140
+ confirmText: action.confirmText,
141
+ successMessage: action.successMessage,
142
+ errorMessage: action.errorMessage,
143
+ refreshAfter: action.refreshAfter,
144
+ toast: action.toast,
145
+ });
146
+ },
147
+ [execute],
148
+ );
149
+
150
+ if (schema.visible && !isVisible) return null;
151
+ if (actions.length === 0) return null;
152
+
153
+ const display = schema.display || 'inline';
154
+
155
+ // --- DROPDOWN MODE ---
156
+ if (display === 'dropdown') {
157
+ const TriggerIcon = resolveIcon(schema.icon);
158
+ return (
159
+ <DropdownMenu>
160
+ <DropdownMenuTrigger asChild>
161
+ <Button
162
+ type="button"
163
+ variant={(schema.variant || 'outline') as any}
164
+ size={(schema.size === 'md' ? 'default' : (schema.size || 'default')) as any}
165
+ className={cn(schema.className, className)}
166
+ disabled={dropdownLoading}
167
+ {...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
168
+ >
169
+ {dropdownLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
170
+ {!dropdownLoading && TriggerIcon && <TriggerIcon className="mr-2 h-4 w-4" />}
171
+ {schema.label || 'Actions'}
172
+ <ChevronDown className="ml-2 h-3 w-3 opacity-50" />
173
+ </Button>
174
+ </DropdownMenuTrigger>
175
+
176
+ <DropdownMenuContent align="end">
177
+ {actions.map((action, index) => {
178
+ const Icon = resolveIcon(action.icon);
179
+ const showSeparator = action.tags?.includes('separator-before') && index > 0;
180
+ return (
181
+ <React.Fragment key={action.name || index}>
182
+ {showSeparator && <DropdownMenuSeparator />}
183
+ <DropdownMenuItem
184
+ onSelect={async (e) => {
185
+ e.preventDefault();
186
+ setDropdownLoading(true);
187
+ try {
188
+ await handleExecute(action);
189
+ } finally {
190
+ setDropdownLoading(false);
191
+ }
192
+ }}
193
+ className={cn(
194
+ action.variant === 'destructive' && 'text-destructive focus:text-destructive',
195
+ action.className,
196
+ )}
197
+ >
198
+ {Icon && <Icon className="mr-2 h-4 w-4" />}
199
+ <span>{action.label || action.name}</span>
200
+ </DropdownMenuItem>
201
+ </React.Fragment>
202
+ );
203
+ })}
204
+ </DropdownMenuContent>
205
+ </DropdownMenu>
206
+ );
207
+ }
208
+
209
+ // --- INLINE MODE (default) ---
210
+ return (
211
+ <div
212
+ ref={ref}
213
+ className={cn('flex items-center gap-2', schema.className, className)}
214
+ {...rest}
215
+ {...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
216
+ >
217
+ {actions.map((action) => (
218
+ <InlineActionButton
219
+ key={action.name}
220
+ action={action}
221
+ variant={schema.variant}
222
+ size={schema.size}
223
+ onExecute={handleExecute}
224
+ />
225
+ ))}
226
+ </div>
227
+ );
228
+ },
229
+ );
230
+
231
+ ActionGroupRenderer.displayName = 'ActionGroupRenderer';
232
+
233
+ ComponentRegistry.register('action:group', ActionGroupRenderer, {
234
+ namespace: 'action',
235
+ label: 'Action Group',
236
+ inputs: [
237
+ { name: 'name', type: 'string', label: 'Group Name' },
238
+ { name: 'label', type: 'string', label: 'Label' },
239
+ { name: 'icon', type: 'string', label: 'Icon' },
240
+ { name: 'actions', type: 'object', label: 'Actions' },
241
+ {
242
+ name: 'display',
243
+ type: 'enum',
244
+ label: 'Display Mode',
245
+ enum: ['inline', 'dropdown'],
246
+ defaultValue: 'inline',
247
+ },
248
+ {
249
+ name: 'variant',
250
+ type: 'enum',
251
+ label: 'Variant',
252
+ enum: ['default', 'secondary', 'outline', 'ghost'],
253
+ defaultValue: 'outline',
254
+ },
255
+ {
256
+ name: 'size',
257
+ type: 'enum',
258
+ label: 'Size',
259
+ enum: ['sm', 'md', 'lg'],
260
+ defaultValue: 'sm',
261
+ },
262
+ { name: 'className', type: 'string', label: 'CSS Class', advanced: true },
263
+ ],
264
+ defaultProps: {
265
+ display: 'inline',
266
+ variant: 'outline',
267
+ size: 'sm',
268
+ actions: [],
269
+ },
270
+ });
@@ -0,0 +1,150 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * action:icon — Icon-only action button for dense layouts.
11
+ *
12
+ * Renders a Shadcn Button (size="icon") with tooltip and ActionRunner integration.
13
+ */
14
+
15
+ import React, { forwardRef, useCallback, useState } from 'react';
16
+ import { ComponentRegistry } from '@object-ui/core';
17
+ import type { ActionSchema } from '@object-ui/types';
18
+ import { useAction } from '@object-ui/react';
19
+ import { useCondition } from '@object-ui/react';
20
+ import { Button } from '../../ui';
21
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui';
22
+ import { cn } from '../../lib/utils';
23
+ import { Loader2 } from 'lucide-react';
24
+ import { resolveIcon } from './resolve-icon';
25
+
26
+ export interface ActionIconProps {
27
+ schema: ActionSchema & { type: string; className?: string };
28
+ className?: string;
29
+ context?: Record<string, any>;
30
+ [key: string]: any;
31
+ }
32
+
33
+ const ActionIconRenderer = forwardRef<HTMLButtonElement, ActionIconProps>(
34
+ ({ schema, className, context: localContext, ...props }, ref) => {
35
+ const {
36
+ 'data-obj-id': dataObjId,
37
+ 'data-obj-type': dataObjType,
38
+ style,
39
+ ...rest
40
+ } = props;
41
+
42
+ const { execute } = useAction();
43
+ const [loading, setLoading] = useState(false);
44
+
45
+ const isVisible = useCondition(schema.visible ? `\${${schema.visible}}` : undefined);
46
+ const isEnabled = useCondition(schema.enabled ? `\${${schema.enabled}}` : undefined);
47
+
48
+ const Icon = resolveIcon(schema.icon);
49
+ const variant = schema.variant === 'primary' ? 'default' : (schema.variant || 'ghost');
50
+ const size = 'icon';
51
+
52
+ const handleClick = useCallback(async () => {
53
+ if (loading) return;
54
+ setLoading(true);
55
+ try {
56
+ await execute({
57
+ type: schema.type,
58
+ name: schema.name,
59
+ target: schema.target,
60
+ execute: schema.execute,
61
+ endpoint: schema.endpoint,
62
+ method: schema.method,
63
+ params: schema.params as Record<string, any> | undefined,
64
+ confirmText: schema.confirmText,
65
+ successMessage: schema.successMessage,
66
+ errorMessage: schema.errorMessage,
67
+ refreshAfter: schema.refreshAfter,
68
+ toast: schema.toast,
69
+ ...localContext,
70
+ });
71
+ } finally {
72
+ setLoading(false);
73
+ }
74
+ }, [schema, execute, loading, localContext]);
75
+
76
+ if (schema.visible && !isVisible) return null;
77
+
78
+ const button = (
79
+ <Button
80
+ ref={ref}
81
+ type="button"
82
+ variant={variant as any}
83
+ size={size}
84
+ className={cn('h-8 w-8', schema.className, className)}
85
+ disabled={(schema.enabled ? !isEnabled : false) || loading}
86
+ onClick={handleClick}
87
+ aria-label={schema.label || schema.name}
88
+ {...rest}
89
+ {...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
90
+ >
91
+ {loading ? (
92
+ <Loader2 className="h-4 w-4 animate-spin" />
93
+ ) : Icon ? (
94
+ <Icon className="h-4 w-4" />
95
+ ) : (
96
+ <span className="text-xs">{schema.label?.charAt(0) || '?'}</span>
97
+ )}
98
+ </Button>
99
+ );
100
+
101
+ // Wrap with tooltip if label is provided
102
+ if (schema.label || schema.description) {
103
+ return (
104
+ <TooltipProvider delayDuration={300}>
105
+ <Tooltip>
106
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
107
+ <TooltipContent>
108
+ <p>{schema.label || schema.description}</p>
109
+ </TooltipContent>
110
+ </Tooltip>
111
+ </TooltipProvider>
112
+ );
113
+ }
114
+
115
+ return button;
116
+ },
117
+ );
118
+
119
+ ActionIconRenderer.displayName = 'ActionIconRenderer';
120
+
121
+ ComponentRegistry.register('action:icon', ActionIconRenderer, {
122
+ namespace: 'action',
123
+ label: 'Action Icon',
124
+ inputs: [
125
+ { name: 'name', type: 'string', label: 'Action Name' },
126
+ { name: 'label', type: 'string', label: 'Tooltip Label' },
127
+ { name: 'icon', type: 'string', label: 'Icon' },
128
+ {
129
+ name: 'type',
130
+ type: 'enum',
131
+ label: 'Action Type',
132
+ enum: ['script', 'url', 'modal', 'flow', 'api'],
133
+ defaultValue: 'script',
134
+ },
135
+ { name: 'target', type: 'string', label: 'Target' },
136
+ {
137
+ name: 'variant',
138
+ type: 'enum',
139
+ label: 'Variant',
140
+ enum: ['default', 'secondary', 'destructive', 'outline', 'ghost'],
141
+ defaultValue: 'ghost',
142
+ },
143
+ { name: 'className', type: 'string', label: 'CSS Class', advanced: true },
144
+ ],
145
+ defaultProps: {
146
+ icon: 'play',
147
+ type: 'script',
148
+ variant: 'ghost',
149
+ },
150
+ });
@@ -0,0 +1,203 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * action:menu — Dropdown menu for overflow actions.
11
+ *
12
+ * Renders a Shadcn DropdownMenu populated from ActionSchema[].
13
+ * Each menu item triggers the corresponding action via ActionRunner.
14
+ */
15
+
16
+ import React, { forwardRef, useCallback, useMemo, useState } from 'react';
17
+ import { ComponentRegistry } from '@object-ui/core';
18
+ import type { ActionSchema } from '@object-ui/types';
19
+ import { useAction } from '@object-ui/react';
20
+ import { useCondition } from '@object-ui/react';
21
+ import { Button } from '../../ui';
22
+ import {
23
+ DropdownMenu,
24
+ DropdownMenuContent,
25
+ DropdownMenuItem,
26
+ DropdownMenuSeparator,
27
+ DropdownMenuTrigger,
28
+ } from '../../ui';
29
+ import { cn } from '../../lib/utils';
30
+ import { Loader2, MoreHorizontal } from 'lucide-react';
31
+ import { resolveIcon } from './resolve-icon';
32
+
33
+ export interface ActionMenuSchema {
34
+ type: 'action:menu';
35
+ /** Menu trigger label (defaults to icon-only) */
36
+ label?: string;
37
+ /** Menu trigger icon (defaults to more-horizontal) */
38
+ icon?: string;
39
+ /** Actions to render as menu items */
40
+ actions?: ActionSchema[];
41
+ /** Trigger variant */
42
+ variant?: string;
43
+ /** Trigger size */
44
+ size?: string;
45
+ /** Visibility condition */
46
+ visible?: string;
47
+ /** Custom CSS class */
48
+ className?: string;
49
+ [key: string]: any;
50
+ }
51
+
52
+ const ActionMenuItem: React.FC<{
53
+ action: ActionSchema;
54
+ onExecute: (action: ActionSchema) => Promise<void>;
55
+ }> = ({ action, onExecute }) => {
56
+ const isVisible = useCondition(action.visible ? `\${${action.visible}}` : undefined);
57
+ const isEnabled = useCondition(action.enabled ? `\${${action.enabled}}` : undefined);
58
+
59
+ const iconElement = useMemo(() => {
60
+ const Icon = resolveIcon(action.icon);
61
+ // eslint-disable-next-line react-hooks/static-components -- Icon is resolved from a stable icon registry
62
+ return Icon ? <Icon className="mr-2 h-4 w-4" /> : null;
63
+ }, [action.icon]);
64
+
65
+ if (action.visible && !isVisible) return null;
66
+
67
+ return (
68
+ <DropdownMenuItem
69
+ disabled={action.enabled ? !isEnabled : false}
70
+ onSelect={(e) => {
71
+ e.preventDefault();
72
+ onExecute(action);
73
+ }}
74
+ className={cn(
75
+ (action.variant as string) === 'destructive' && 'text-destructive focus:text-destructive',
76
+ action.className,
77
+ )}
78
+ >
79
+ {iconElement}
80
+ <span>{action.label || action.name}</span>
81
+ </DropdownMenuItem>
82
+ );
83
+ };
84
+
85
+ ActionMenuItem.displayName = 'ActionMenuItem';
86
+
87
+ const ActionMenuRenderer = forwardRef<HTMLButtonElement, { schema: ActionMenuSchema; [key: string]: any }>(
88
+ ({ schema, className, ...props }, ref) => {
89
+ const {
90
+ 'data-obj-id': dataObjId,
91
+ 'data-obj-type': dataObjType,
92
+ style,
93
+ ...rest
94
+ } = props;
95
+
96
+ const { execute } = useAction();
97
+ const [loading, setLoading] = useState(false);
98
+
99
+ const isVisible = useCondition(schema.visible ? `\${${schema.visible}}` : undefined);
100
+
101
+ const TriggerIcon = resolveIcon(schema.icon) || MoreHorizontal;
102
+ const variant = schema.variant || 'ghost';
103
+ const size = schema.size || 'icon';
104
+
105
+ const handleExecute = useCallback(
106
+ async (action: ActionSchema) => {
107
+ setLoading(true);
108
+ try {
109
+ await execute({
110
+ type: action.type,
111
+ name: action.name,
112
+ target: action.target,
113
+ execute: action.execute,
114
+ endpoint: action.endpoint,
115
+ method: action.method,
116
+ params: action.params as Record<string, any> | undefined,
117
+ confirmText: action.confirmText,
118
+ successMessage: action.successMessage,
119
+ errorMessage: action.errorMessage,
120
+ refreshAfter: action.refreshAfter,
121
+ toast: action.toast,
122
+ });
123
+ } finally {
124
+ setLoading(false);
125
+ }
126
+ },
127
+ [execute],
128
+ );
129
+
130
+ if (schema.visible && !isVisible) return null;
131
+
132
+ const actions = schema.actions || [];
133
+ if (actions.length === 0) return null;
134
+
135
+ return (
136
+ <DropdownMenu>
137
+ <DropdownMenuTrigger asChild>
138
+ <Button
139
+ ref={ref}
140
+ type="button"
141
+ variant={variant as any}
142
+ size={size as any}
143
+ className={cn(
144
+ size === 'icon' && 'h-8 w-8',
145
+ schema.className,
146
+ className,
147
+ )}
148
+ disabled={loading}
149
+ aria-label={schema.label || 'More actions'}
150
+ {...rest}
151
+ {...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
152
+ >
153
+ {loading ? (
154
+ <Loader2 className="h-4 w-4 animate-spin" />
155
+ ) : (
156
+ <>
157
+ <TriggerIcon className={cn('h-4 w-4', schema.label && 'mr-2')} />
158
+ {schema.label && <span>{schema.label}</span>}
159
+ </>
160
+ )}
161
+ </Button>
162
+ </DropdownMenuTrigger>
163
+
164
+ <DropdownMenuContent align="end">
165
+ {actions.map((action, index) => {
166
+ // Render separator for actions tagged with 'separator-before'
167
+ const showSeparator = action.tags?.includes('separator-before') && index > 0;
168
+ return (
169
+ <React.Fragment key={action.name || index}>
170
+ {showSeparator && <DropdownMenuSeparator />}
171
+ <ActionMenuItem action={action} onExecute={handleExecute} />
172
+ </React.Fragment>
173
+ );
174
+ })}
175
+ </DropdownMenuContent>
176
+ </DropdownMenu>
177
+ );
178
+ },
179
+ );
180
+
181
+ ActionMenuRenderer.displayName = 'ActionMenuRenderer';
182
+
183
+ ComponentRegistry.register('action:menu', ActionMenuRenderer, {
184
+ namespace: 'action',
185
+ label: 'Action Menu',
186
+ inputs: [
187
+ { name: 'label', type: 'string', label: 'Trigger Label' },
188
+ { name: 'icon', type: 'string', label: 'Trigger Icon' },
189
+ { name: 'actions', type: 'object', label: 'Actions' },
190
+ {
191
+ name: 'variant',
192
+ type: 'enum',
193
+ label: 'Trigger Variant',
194
+ enum: ['default', 'secondary', 'outline', 'ghost'],
195
+ defaultValue: 'ghost',
196
+ },
197
+ { name: 'className', type: 'string', label: 'CSS Class', advanced: true },
198
+ ],
199
+ defaultProps: {
200
+ variant: 'ghost',
201
+ actions: [],
202
+ },
203
+ });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * Action renderers — Smart action components driven by ActionSchema.
11
+ *
12
+ * Registers: action:button, action:icon, action:menu, action:group
13
+ */
14
+
15
+ import './action-button';
16
+ import './action-icon';
17
+ import './action-menu';
18
+ import './action-group';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ import { icons, type LucideIcon } from 'lucide-react';
10
+
11
+ /**
12
+ * Convert a kebab-case icon name to PascalCase (e.g., "arrow-right" -> "ArrowRight").
13
+ */
14
+ function toPascalCase(str: string): string {
15
+ return str
16
+ .split('-')
17
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1))
18
+ .join('');
19
+ }
20
+
21
+ /** Map of renamed icons in lucide-react */
22
+ const iconNameMap: Record<string, string> = {
23
+ Home: 'House',
24
+ };
25
+
26
+ /**
27
+ * Resolve a Lucide icon by its kebab-case name.
28
+ * Returns null if not found.
29
+ */
30
+ export function resolveIcon(name: string | undefined): LucideIcon | null {
31
+ if (!name) return null;
32
+ const pascalName = toPascalCase(name);
33
+ const mapped = iconNameMap[pascalName] || pascalName;
34
+ return (icons as Record<string, LucideIcon>)[mapped] ?? null;
35
+ }
@@ -47,6 +47,7 @@ ComponentRegistry.register('button-group',
47
47
  );
48
48
  },
49
49
  {
50
+ namespace: 'ui',
50
51
  label: 'Button Group',
51
52
  inputs: [
52
53
  {