@object-ui/components 3.3.0 → 3.3.1
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/CHANGELOG.md +20 -0
- package/README.md +21 -1
- package/dist/index.css +6339 -2
- package/dist/index.js +17600 -17481
- package/dist/index.umd.cjs +36 -36
- package/dist/packages/components/src/custom/empty.d.ts +12 -1
- package/dist/packages/components/src/renderers/action/action-bar.d.ts +12 -1
- package/dist/packages/components/src/ui/chart.d.ts +10 -29
- package/package.json +65 -44
- package/.turbo/turbo-build.log +0 -84
- package/README_SHADCN_SYNC.md +0 -281
- package/TESTING.md +0 -335
- package/docs/FilterBuilder.md +0 -268
- package/metadata/Chart.component.yml +0 -30
- package/metadata/FilterBuilder.component.yml +0 -39
- package/metadata/GridLayout.component.yml +0 -27
- package/metadata/Menu.component.yml +0 -31
- package/metadata/ObjectForm.component.yml +0 -34
- package/metadata/ObjectGrid.component.yml +0 -72
- package/metadata/Page.component.yml +0 -24
- package/postcss.config.js +0 -14
- package/shadcn-components.json +0 -440
- package/src/SchemaRenderer.tsx +0 -28
- package/src/__tests__/PageRendererRegions.test.tsx +0 -668
- package/src/__tests__/README.md +0 -124
- package/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap +0 -811
- package/src/__tests__/__snapshots__/snapshot.test.tsx.snap +0 -327
- package/src/__tests__/accessibility.test.tsx +0 -137
- package/src/__tests__/action-bar.test.tsx +0 -206
- package/src/__tests__/api-consistency.test.tsx +0 -596
- package/src/__tests__/basic-renderers.test.tsx +0 -255
- package/src/__tests__/color-contrast.test.tsx +0 -212
- package/src/__tests__/complex-disclosure-renderers.test.tsx +0 -302
- package/src/__tests__/compliance.test.tsx +0 -72
- package/src/__tests__/config-field-renderer.test.tsx +0 -307
- package/src/__tests__/config-panel-renderer.test.tsx +0 -580
- package/src/__tests__/config-primitives.test.tsx +0 -106
- package/src/__tests__/edge-cases.test.tsx +0 -285
- package/src/__tests__/feedback-overlay-renderers.test.tsx +0 -349
- package/src/__tests__/filter-builder.test.tsx +0 -409
- package/src/__tests__/form-renderers.test.tsx +0 -364
- package/src/__tests__/layout-data-renderers.test.tsx +0 -340
- package/src/__tests__/mobile-accessibility.test.tsx +0 -120
- package/src/__tests__/navigation-overlay.test.tsx +0 -370
- package/src/__tests__/snapshot-critical.test.tsx +0 -317
- package/src/__tests__/snapshot.test.tsx +0 -205
- package/src/__tests__/test-utils.tsx +0 -190
- package/src/__tests__/use-config-draft.test.tsx +0 -295
- package/src/__tests__/view-compliance.test.tsx +0 -153
- package/src/__tests__/wcag-audit.test.tsx +0 -493
- package/src/custom/action-param-dialog.tsx +0 -264
- package/src/custom/button-group.tsx +0 -91
- package/src/custom/combobox.tsx +0 -104
- package/src/custom/config-field-renderer.tsx +0 -276
- package/src/custom/config-panel-renderer.tsx +0 -306
- package/src/custom/config-row.tsx +0 -50
- package/src/custom/date-picker.tsx +0 -61
- package/src/custom/empty.tsx +0 -112
- package/src/custom/field.tsx +0 -81
- package/src/custom/filter-builder.tsx +0 -418
- package/src/custom/index.ts +0 -21
- package/src/custom/input-group.tsx +0 -53
- package/src/custom/item.tsx +0 -201
- package/src/custom/kbd.tsx +0 -36
- package/src/custom/mobile-dialog-content.tsx +0 -67
- package/src/custom/native-select.tsx +0 -33
- package/src/custom/navigation-overlay.tsx +0 -334
- package/src/custom/section-header.tsx +0 -68
- package/src/custom/sort-builder.tsx +0 -129
- package/src/custom/spinner.tsx +0 -26
- package/src/custom/view-skeleton.tsx +0 -243
- package/src/custom/view-states.tsx +0 -153
- package/src/debug/DebugPanel.tsx +0 -313
- package/src/debug/__tests__/DebugPanel.test.tsx +0 -134
- package/src/debug/index.ts +0 -10
- package/src/hooks/use-config-draft.ts +0 -127
- package/src/hooks/use-mobile.tsx +0 -27
- package/src/index.css +0 -245
- package/src/index.ts +0 -47
- package/src/lib/use-sync-external-store-shim.ts +0 -10
- package/src/lib/use-sync-external-store-with-selector-shim.ts +0 -90
- package/src/lib/utils.tsx +0 -35
- package/src/new-components.test.ts +0 -73
- package/src/renderers/action/action-bar.tsx +0 -221
- package/src/renderers/action/action-button.tsx +0 -158
- package/src/renderers/action/action-group.tsx +0 -270
- package/src/renderers/action/action-icon.tsx +0 -150
- package/src/renderers/action/action-menu.tsx +0 -203
- package/src/renderers/action/index.ts +0 -19
- package/src/renderers/action/resolve-icon.ts +0 -35
- package/src/renderers/basic/button-group.tsx +0 -79
- package/src/renderers/basic/div.tsx +0 -60
- package/src/renderers/basic/html.tsx +0 -43
- package/src/renderers/basic/icon.tsx +0 -89
- package/src/renderers/basic/image.tsx +0 -49
- package/src/renderers/basic/index.ts +0 -18
- package/src/renderers/basic/navigation-menu.tsx +0 -81
- package/src/renderers/basic/pagination.tsx +0 -109
- package/src/renderers/basic/separator.tsx +0 -57
- package/src/renderers/basic/span.tsx +0 -63
- package/src/renderers/basic/text.tsx +0 -52
- package/src/renderers/complex/README-KANBAN.md +0 -208
- package/src/renderers/complex/TIMELINE.md +0 -353
- package/src/renderers/complex/__tests__/data-table-airtable-ux.test.tsx +0 -239
- package/src/renderers/complex/__tests__/data-table-batch-editing.test.tsx +0 -275
- package/src/renderers/complex/__tests__/data-table-cell-renderer.test.tsx +0 -120
- package/src/renderers/complex/__tests__/data-table-editing.test.tsx +0 -221
- package/src/renderers/complex/__tests__/data-table.test.ts +0 -76
- package/src/renderers/complex/carousel.tsx +0 -69
- package/src/renderers/complex/data-table.tsx +0 -1243
- package/src/renderers/complex/filter-builder.tsx +0 -77
- package/src/renderers/complex/index.ts +0 -16
- package/src/renderers/complex/resizable.tsx +0 -66
- package/src/renderers/complex/scroll-area.tsx +0 -58
- package/src/renderers/complex/table.tsx +0 -95
- package/src/renderers/data-display/alert.tsx +0 -46
- package/src/renderers/data-display/avatar.tsx +0 -38
- package/src/renderers/data-display/badge.tsx +0 -55
- package/src/renderers/data-display/breadcrumb.tsx +0 -61
- package/src/renderers/data-display/index.ts +0 -18
- package/src/renderers/data-display/kbd.tsx +0 -50
- package/src/renderers/data-display/list.tsx +0 -75
- package/src/renderers/data-display/statistic.tsx +0 -95
- package/src/renderers/data-display/table.tsx +0 -78
- package/src/renderers/data-display/tree-view.tsx +0 -176
- package/src/renderers/disclosure/accordion.tsx +0 -69
- package/src/renderers/disclosure/collapsible.tsx +0 -53
- package/src/renderers/disclosure/index.ts +0 -11
- package/src/renderers/disclosure/toggle-group.tsx +0 -79
- package/src/renderers/feedback/empty.tsx +0 -49
- package/src/renderers/feedback/index.ts +0 -16
- package/src/renderers/feedback/loading.tsx +0 -78
- package/src/renderers/feedback/progress.tsx +0 -29
- package/src/renderers/feedback/skeleton.tsx +0 -31
- package/src/renderers/feedback/sonner.tsx +0 -56
- package/src/renderers/feedback/spinner.tsx +0 -55
- package/src/renderers/feedback/toast.tsx +0 -59
- package/src/renderers/feedback/toaster.tsx +0 -23
- package/src/renderers/form/button.tsx +0 -103
- package/src/renderers/form/calendar.tsx +0 -34
- package/src/renderers/form/checkbox.tsx +0 -71
- package/src/renderers/form/combobox.tsx +0 -48
- package/src/renderers/form/command.tsx +0 -58
- package/src/renderers/form/date-picker.tsx +0 -84
- package/src/renderers/form/file-upload.tsx +0 -184
- package/src/renderers/form/form.tsx +0 -540
- package/src/renderers/form/index.ts +0 -26
- package/src/renderers/form/input-otp.tsx +0 -51
- package/src/renderers/form/input.tsx +0 -121
- package/src/renderers/form/label.tsx +0 -45
- package/src/renderers/form/radio-group.tsx +0 -63
- package/src/renderers/form/select.tsx +0 -94
- package/src/renderers/form/slider.tsx +0 -61
- package/src/renderers/form/switch.tsx +0 -48
- package/src/renderers/form/textarea.tsx +0 -76
- package/src/renderers/form/toggle.tsx +0 -42
- package/src/renderers/index.ts +0 -18
- package/src/renderers/layout/aspect-ratio.tsx +0 -51
- package/src/renderers/layout/card.tsx +0 -85
- package/src/renderers/layout/container.tsx +0 -122
- package/src/renderers/layout/flex.tsx +0 -132
- package/src/renderers/layout/grid.tsx +0 -178
- package/src/renderers/layout/index.ts +0 -19
- package/src/renderers/layout/page.tsx +0 -466
- package/src/renderers/layout/semantic.tsx +0 -48
- package/src/renderers/layout/stack.tsx +0 -132
- package/src/renderers/layout/tabs.tsx +0 -97
- package/src/renderers/navigation/header-bar.tsx +0 -118
- package/src/renderers/navigation/index.ts +0 -10
- package/src/renderers/navigation/sidebar.tsx +0 -208
- package/src/renderers/overlay/alert-dialog.tsx +0 -72
- package/src/renderers/overlay/context-menu.tsx +0 -100
- package/src/renderers/overlay/dialog.tsx +0 -77
- package/src/renderers/overlay/drawer.tsx +0 -77
- package/src/renderers/overlay/dropdown-menu.tsx +0 -99
- package/src/renderers/overlay/hover-card.tsx +0 -55
- package/src/renderers/overlay/index.ts +0 -18
- package/src/renderers/overlay/menubar.tsx +0 -76
- package/src/renderers/overlay/popover.tsx +0 -56
- package/src/renderers/overlay/sheet.tsx +0 -77
- package/src/renderers/overlay/tooltip.tsx +0 -67
- package/src/renderers/placeholders.tsx +0 -107
- package/src/stories/CRMApp.stories.tsx +0 -706
- package/src/stories/ConfigPanel.stories.tsx +0 -232
- package/src/stories/Guide.mdx +0 -55
- package/src/stories/MockedData.stories.tsx +0 -121
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +0 -1
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +0 -1
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +0 -1
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +0 -1
- package/src/stories/assets/youtube.svg +0 -1
- package/src/stories/button.css +0 -30
- package/src/stories/header.css +0 -32
- package/src/stories/page.css +0 -68
- package/src/stories-json/Accessibility.mdx +0 -297
- package/src/stories-json/EdgeCases.stories.tsx +0 -160
- package/src/stories-json/GettingStarted.mdx +0 -89
- package/src/stories-json/Introduction.mdx +0 -127
- package/src/stories-json/accordion.stories.tsx +0 -43
- package/src/stories-json/aggrid.stories.tsx +0 -103
- package/src/stories-json/alert.stories.tsx +0 -39
- package/src/stories-json/aspect-ratio.stories.tsx +0 -34
- package/src/stories-json/avatar.stories.tsx +0 -38
- package/src/stories-json/badge.stories.tsx +0 -53
- package/src/stories-json/breadcrumb.stories.tsx +0 -30
- package/src/stories-json/button-group.stories.tsx +0 -43
- package/src/stories-json/button.stories.tsx +0 -73
- package/src/stories-json/calendar.stories.tsx +0 -85
- package/src/stories-json/card.stories.tsx +0 -48
- package/src/stories-json/carousel.stories.tsx +0 -33
- package/src/stories-json/charts.stories.tsx +0 -195
- package/src/stories-json/chatbot.stories.tsx +0 -349
- package/src/stories-json/code-editor.stories.tsx +0 -92
- package/src/stories-json/collapsible.stories.tsx +0 -40
- package/src/stories-json/controls.stories.tsx +0 -36
- package/src/stories-json/crm-live-data.stories.tsx +0 -154
- package/src/stories-json/dashboard.stories.tsx +0 -318
- package/src/stories-json/data-table.stories.tsx +0 -136
- package/src/stories-json/data_display_extras.stories.tsx +0 -102
- package/src/stories-json/date-picker.stories.tsx +0 -28
- package/src/stories-json/detail-view.stories.tsx +0 -258
- package/src/stories-json/dialog.stories.tsx +0 -43
- package/src/stories-json/feedback_extras.stories.tsx +0 -40
- package/src/stories-json/feedback_others.stories.tsx +0 -46
- package/src/stories-json/form-variants.stories.tsx +0 -210
- package/src/stories-json/form_advanced.stories.tsx +0 -117
- package/src/stories-json/form_extras.stories.tsx +0 -123
- package/src/stories-json/grid.stories.tsx +0 -56
- package/src/stories-json/icon.stories.tsx +0 -36
- package/src/stories-json/input.stories.tsx +0 -52
- package/src/stories-json/kanban.stories.tsx +0 -295
- package/src/stories-json/layout_extended.stories.tsx +0 -76
- package/src/stories-json/layout_flex.stories.tsx +0 -107
- package/src/stories-json/list-view.stories.tsx +0 -97
- package/src/stories-json/markdown.stories.tsx +0 -129
- package/src/stories-json/menus.stories.tsx +0 -63
- package/src/stories-json/metric-card.stories.tsx +0 -143
- package/src/stories-json/navigation-menu.stories.tsx +0 -37
- package/src/stories-json/object-aggrid-advanced.stories.tsx +0 -389
- package/src/stories-json/object-aggrid.stories.tsx +0 -252
- package/src/stories-json/object-form.stories.tsx +0 -130
- package/src/stories-json/object-gantt.stories.tsx +0 -114
- package/src/stories-json/object-grid.stories.tsx +0 -315
- package/src/stories-json/object-map.stories.tsx +0 -116
- package/src/stories-json/object-view.stories.tsx +0 -118
- package/src/stories-json/overlay_extras.stories.tsx +0 -113
- package/src/stories-json/overlay_others.stories.tsx +0 -76
- package/src/stories-json/page.stories.tsx +0 -55
- package/src/stories-json/reports.stories.tsx +0 -163
- package/src/stories-json/resizable.stories.tsx +0 -44
- package/src/stories-json/select.stories.tsx +0 -34
- package/src/stories-json/separator.stories.tsx +0 -41
- package/src/stories-json/sidebar.stories.tsx +0 -147
- package/src/stories-json/statistic.stories.tsx +0 -44
- package/src/stories-json/tabs.stories.tsx +0 -51
- package/src/stories-json/timeline.stories.tsx +0 -188
- package/src/stories-json/typography.stories.tsx +0 -45
- package/src/types/config-panel.ts +0 -101
- package/src/ui/accordion.tsx +0 -66
- package/src/ui/alert-dialog.tsx +0 -149
- package/src/ui/alert.tsx +0 -67
- package/src/ui/aspect-ratio.tsx +0 -15
- package/src/ui/avatar.tsx +0 -58
- package/src/ui/badge.tsx +0 -44
- package/src/ui/breadcrumb.tsx +0 -123
- package/src/ui/button.tsx +0 -64
- package/src/ui/calendar.tsx +0 -221
- package/src/ui/card.tsx +0 -87
- package/src/ui/carousel.tsx +0 -270
- package/src/ui/chart.tsx +0 -377
- package/src/ui/checkbox.tsx +0 -38
- package/src/ui/collapsible.tsx +0 -19
- package/src/ui/command.tsx +0 -161
- package/src/ui/context-menu.tsx +0 -208
- package/src/ui/dialog.tsx +0 -130
- package/src/ui/drawer.tsx +0 -126
- package/src/ui/dropdown-menu.tsx +0 -208
- package/src/ui/form.tsx +0 -186
- package/src/ui/hover-card.tsx +0 -37
- package/src/ui/index.ts +0 -56
- package/src/ui/input-otp.tsx +0 -79
- package/src/ui/input.tsx +0 -30
- package/src/ui/label.tsx +0 -34
- package/src/ui/menubar.tsx +0 -264
- package/src/ui/navigation-menu.tsx +0 -136
- package/src/ui/pagination.tsx +0 -125
- package/src/ui/popover.tsx +0 -39
- package/src/ui/progress.tsx +0 -36
- package/src/ui/radio-group.tsx +0 -52
- package/src/ui/resizable.tsx +0 -53
- package/src/ui/scroll-area.tsx +0 -56
- package/src/ui/select.tsx +0 -168
- package/src/ui/separator.tsx +0 -39
- package/src/ui/sheet.tsx +0 -150
- package/src/ui/sidebar.tsx +0 -781
- package/src/ui/skeleton.tsx +0 -23
- package/src/ui/slider.tsx +0 -39
- package/src/ui/sonner.tsx +0 -53
- package/src/ui/switch.tsx +0 -37
- package/src/ui/table.tsx +0 -125
- package/src/ui/tabs.tsx +0 -63
- package/src/ui/textarea.tsx +0 -30
- package/src/ui/toast.tsx +0 -137
- package/src/ui/toggle-group.tsx +0 -69
- package/src/ui/toggle.tsx +0 -53
- package/src/ui/tooltip.tsx +0 -38
- package/src/ui/typography.tsx +0 -85
- package/tsconfig.json +0 -19
- package/vite.config.ts +0 -71
- package/vitest.config.ts +0 -5
|
@@ -1,221 +0,0 @@
|
|
|
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:bar — Location-aware action toolbar.
|
|
11
|
-
*
|
|
12
|
-
* Renders a set of ActionSchema items filtered by a given location.
|
|
13
|
-
* Each action is rendered using its `component` type (action:button, action:icon,
|
|
14
|
-
* action:menu, action:group) via the ComponentRegistry. Actions beyond the
|
|
15
|
-
* `maxVisible` threshold are grouped into an overflow "More" dropdown.
|
|
16
|
-
*
|
|
17
|
-
* This is the "bridge" component that connects ActionSchema metadata to the UI,
|
|
18
|
-
* enabling server-driven action rendering at list_toolbar, record_header,
|
|
19
|
-
* list_item, record_more, record_related, and global_nav locations.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* <SchemaRenderer schema={{
|
|
24
|
-
* type: 'action:bar',
|
|
25
|
-
* location: 'record_header',
|
|
26
|
-
* actions: [
|
|
27
|
-
* { name: 'mark_complete', label: 'Mark Complete', type: 'script', icon: 'check', component: 'action:button' },
|
|
28
|
-
* { name: 'delete', label: 'Delete', type: 'api', icon: 'trash-2', variant: 'destructive', component: 'action:button' },
|
|
29
|
-
* ],
|
|
30
|
-
* }} />
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
35
|
-
import { ComponentRegistry } from '@object-ui/core';
|
|
36
|
-
import type { ActionSchema, ActionLocation, ActionComponent } from '@object-ui/types';
|
|
37
|
-
import { useCondition } from '@object-ui/react';
|
|
38
|
-
import { cn } from '../../lib/utils';
|
|
39
|
-
import { useIsMobile } from '../../hooks/use-mobile';
|
|
40
|
-
|
|
41
|
-
export interface ActionBarSchema {
|
|
42
|
-
type: 'action:bar';
|
|
43
|
-
/** Actions to render */
|
|
44
|
-
actions?: ActionSchema[];
|
|
45
|
-
/** Filter actions by this location */
|
|
46
|
-
location?: ActionLocation;
|
|
47
|
-
/** Maximum visible inline actions before overflow into "More" menu (default: 3) */
|
|
48
|
-
maxVisible?: number;
|
|
49
|
-
/** Maximum visible inline actions on mobile devices (default: 1). Desktop uses maxVisible instead. */
|
|
50
|
-
mobileMaxVisible?: number;
|
|
51
|
-
/** Visibility condition expression */
|
|
52
|
-
visible?: string;
|
|
53
|
-
/** Layout direction */
|
|
54
|
-
direction?: 'horizontal' | 'vertical';
|
|
55
|
-
/** Gap between items (Tailwind gap class, default: 'gap-2') */
|
|
56
|
-
gap?: string;
|
|
57
|
-
/** Button variant for all actions (can be overridden per-action) */
|
|
58
|
-
variant?: string;
|
|
59
|
-
/** Button size for all actions (can be overridden per-action) */
|
|
60
|
-
size?: string;
|
|
61
|
-
/** Custom CSS class */
|
|
62
|
-
className?: string;
|
|
63
|
-
[key: string]: any;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const ActionBarRenderer = forwardRef<HTMLDivElement, { schema: ActionBarSchema; [key: string]: any }>(
|
|
67
|
-
({ schema, className, ...props }, ref) => {
|
|
68
|
-
const {
|
|
69
|
-
'data-obj-id': dataObjId,
|
|
70
|
-
'data-obj-type': dataObjType,
|
|
71
|
-
style,
|
|
72
|
-
data,
|
|
73
|
-
...rest
|
|
74
|
-
} = props;
|
|
75
|
-
|
|
76
|
-
const isVisible = useCondition(schema.visible ? `\${${schema.visible}}` : undefined);
|
|
77
|
-
const isMobile = useIsMobile();
|
|
78
|
-
|
|
79
|
-
// Filter actions by location and deduplicate by name
|
|
80
|
-
const filteredActions = useMemo(() => {
|
|
81
|
-
const actions = schema.actions || [];
|
|
82
|
-
const located = !schema.location
|
|
83
|
-
? actions
|
|
84
|
-
: actions.filter(
|
|
85
|
-
a => !a.locations || a.locations.length === 0 || a.locations.includes(schema.location!),
|
|
86
|
-
);
|
|
87
|
-
// Deduplicate by action name — keep first occurrence
|
|
88
|
-
const seen = new Set<string>();
|
|
89
|
-
return located.filter(a => {
|
|
90
|
-
if (!a.name) return true;
|
|
91
|
-
if (seen.has(a.name)) return false;
|
|
92
|
-
seen.add(a.name);
|
|
93
|
-
return true;
|
|
94
|
-
});
|
|
95
|
-
}, [schema.actions, schema.location]);
|
|
96
|
-
|
|
97
|
-
// Split into visible inline actions and overflow
|
|
98
|
-
// On mobile, show fewer actions inline (default: 1)
|
|
99
|
-
const maxVisible = isMobile
|
|
100
|
-
? (schema.mobileMaxVisible ?? 1)
|
|
101
|
-
: (schema.maxVisible ?? 3);
|
|
102
|
-
const { inlineActions, overflowActions } = useMemo(() => {
|
|
103
|
-
if (filteredActions.length <= maxVisible) {
|
|
104
|
-
return { inlineActions: filteredActions, overflowActions: [] as ActionSchema[] };
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
inlineActions: filteredActions.slice(0, maxVisible),
|
|
108
|
-
overflowActions: filteredActions.slice(maxVisible),
|
|
109
|
-
};
|
|
110
|
-
}, [filteredActions, maxVisible]);
|
|
111
|
-
|
|
112
|
-
if (schema.visible && !isVisible) return null;
|
|
113
|
-
if (filteredActions.length === 0) return null;
|
|
114
|
-
|
|
115
|
-
const direction = schema.direction || 'horizontal';
|
|
116
|
-
const gap = schema.gap || 'gap-2';
|
|
117
|
-
|
|
118
|
-
// Render overflow menu for excess actions
|
|
119
|
-
const MenuRenderer = overflowActions.length > 0 ? ComponentRegistry.get('action:menu') : null;
|
|
120
|
-
const overflowMenu = MenuRenderer ? (
|
|
121
|
-
<MenuRenderer
|
|
122
|
-
schema={{
|
|
123
|
-
type: 'action:menu' as const,
|
|
124
|
-
actions: overflowActions,
|
|
125
|
-
variant: schema.variant || 'ghost',
|
|
126
|
-
size: schema.size || 'sm',
|
|
127
|
-
}}
|
|
128
|
-
/>
|
|
129
|
-
) : null;
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<div
|
|
133
|
-
ref={ref}
|
|
134
|
-
className={cn(
|
|
135
|
-
'flex items-center',
|
|
136
|
-
direction === 'vertical' ? 'flex-col items-stretch' : 'flex-row flex-wrap',
|
|
137
|
-
gap,
|
|
138
|
-
schema.className,
|
|
139
|
-
className,
|
|
140
|
-
)}
|
|
141
|
-
role="toolbar"
|
|
142
|
-
aria-label="Actions"
|
|
143
|
-
{...rest}
|
|
144
|
-
{...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
|
|
145
|
-
>
|
|
146
|
-
{inlineActions.map((action) => {
|
|
147
|
-
const componentType: ActionComponent = action.component || 'action:button';
|
|
148
|
-
const Renderer = ComponentRegistry.get(componentType);
|
|
149
|
-
if (!Renderer) return null;
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<Renderer
|
|
153
|
-
key={action.name}
|
|
154
|
-
schema={{
|
|
155
|
-
...action,
|
|
156
|
-
type: componentType,
|
|
157
|
-
actionType: action.type,
|
|
158
|
-
variant: action.variant || schema.variant,
|
|
159
|
-
size: action.size || schema.size,
|
|
160
|
-
}}
|
|
161
|
-
data={data}
|
|
162
|
-
/>
|
|
163
|
-
);
|
|
164
|
-
})}
|
|
165
|
-
|
|
166
|
-
{overflowActions.length > 0 && overflowMenu}
|
|
167
|
-
</div>
|
|
168
|
-
);
|
|
169
|
-
},
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
ActionBarRenderer.displayName = 'ActionBarRenderer';
|
|
173
|
-
|
|
174
|
-
ComponentRegistry.register('action:bar', ActionBarRenderer, {
|
|
175
|
-
namespace: 'action',
|
|
176
|
-
label: 'Action Bar',
|
|
177
|
-
inputs: [
|
|
178
|
-
{ name: 'actions', type: 'object', label: 'Actions' },
|
|
179
|
-
{
|
|
180
|
-
name: 'location',
|
|
181
|
-
type: 'enum',
|
|
182
|
-
label: 'Location',
|
|
183
|
-
enum: ['list_toolbar', 'list_item', 'record_header', 'record_more', 'record_related', 'global_nav'],
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: 'maxVisible',
|
|
187
|
-
type: 'number',
|
|
188
|
-
label: 'Max Visible Actions',
|
|
189
|
-
defaultValue: 3,
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
name: 'direction',
|
|
193
|
-
type: 'enum',
|
|
194
|
-
label: 'Direction',
|
|
195
|
-
enum: ['horizontal', 'vertical'],
|
|
196
|
-
defaultValue: 'horizontal',
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
name: 'variant',
|
|
200
|
-
type: 'enum',
|
|
201
|
-
label: 'Default Variant',
|
|
202
|
-
enum: ['default', 'secondary', 'outline', 'ghost'],
|
|
203
|
-
defaultValue: 'outline',
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
name: 'size',
|
|
207
|
-
type: 'enum',
|
|
208
|
-
label: 'Default Size',
|
|
209
|
-
enum: ['sm', 'md', 'lg'],
|
|
210
|
-
defaultValue: 'sm',
|
|
211
|
-
},
|
|
212
|
-
{ name: 'className', type: 'string', label: 'CSS Class', advanced: true },
|
|
213
|
-
],
|
|
214
|
-
defaultProps: {
|
|
215
|
-
maxVisible: 3,
|
|
216
|
-
direction: 'horizontal',
|
|
217
|
-
variant: 'outline',
|
|
218
|
-
size: 'sm',
|
|
219
|
-
actions: [],
|
|
220
|
-
},
|
|
221
|
-
});
|
|
@@ -1,158 +0,0 @@
|
|
|
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:button — Smart action button driven by ActionSchema.
|
|
11
|
-
*
|
|
12
|
-
* Renders a Shadcn Button wired to the ActionRunner. Supports:
|
|
13
|
-
* - All 5 spec action types (script, url, modal, flow, api)
|
|
14
|
-
* - Conditional visibility & enabled state
|
|
15
|
-
* - Loading indicator during async execution
|
|
16
|
-
* - Icon rendering via Lucide
|
|
17
|
-
* - Variant / size / className overrides from schema
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import React, { forwardRef, useCallback, useState } from 'react';
|
|
21
|
-
import { ComponentRegistry } from '@object-ui/core';
|
|
22
|
-
import type { ActionSchema } from '@object-ui/types';
|
|
23
|
-
import { useAction } from '@object-ui/react';
|
|
24
|
-
import { useCondition } from '@object-ui/react';
|
|
25
|
-
import { Button } from '../../ui';
|
|
26
|
-
import { cn } from '../../lib/utils';
|
|
27
|
-
import { Loader2 } from 'lucide-react';
|
|
28
|
-
import { resolveIcon } from './resolve-icon';
|
|
29
|
-
|
|
30
|
-
export interface ActionButtonProps {
|
|
31
|
-
schema: ActionSchema & { type: string; className?: string; actionType?: string };
|
|
32
|
-
className?: string;
|
|
33
|
-
/** Override context for this specific action */
|
|
34
|
-
context?: Record<string, any>;
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const ActionButtonRenderer = forwardRef<HTMLButtonElement, ActionButtonProps>(
|
|
39
|
-
({ schema, className, context: localContext, ...props }, ref) => {
|
|
40
|
-
const {
|
|
41
|
-
'data-obj-id': dataObjId,
|
|
42
|
-
'data-obj-type': dataObjType,
|
|
43
|
-
style,
|
|
44
|
-
data,
|
|
45
|
-
...rest
|
|
46
|
-
} = props;
|
|
47
|
-
|
|
48
|
-
const { execute } = useAction();
|
|
49
|
-
const [loading, setLoading] = useState(false);
|
|
50
|
-
|
|
51
|
-
// Record data may be passed from SchemaRenderer (e.g. DetailView passes record data)
|
|
52
|
-
const recordData = data != null && typeof data === 'object' ? data as Record<string, any> : {};
|
|
53
|
-
|
|
54
|
-
// Evaluate visibility and enabled conditions with record data context
|
|
55
|
-
const isVisible = useCondition(schema.visible ? `\${${schema.visible}}` : undefined, recordData);
|
|
56
|
-
const isEnabled = useCondition(schema.enabled ? `\${${schema.enabled}}` : undefined, recordData);
|
|
57
|
-
|
|
58
|
-
// Resolve icon
|
|
59
|
-
const Icon = resolveIcon(schema.icon);
|
|
60
|
-
|
|
61
|
-
// Map schema variant to Shadcn button variant
|
|
62
|
-
const variant = schema.variant === 'primary' ? 'default' : (schema.variant || 'default');
|
|
63
|
-
const size = schema.size === 'md' ? 'default' : (schema.size || 'default');
|
|
64
|
-
|
|
65
|
-
const handleClick = useCallback(async () => {
|
|
66
|
-
if (loading) return;
|
|
67
|
-
setLoading(true);
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
// Route params correctly:
|
|
71
|
-
// - Array of objects with name+type → ActionParamDef[] → pass as actionParams for collection
|
|
72
|
-
// - Otherwise → pass as actual param values
|
|
73
|
-
const paramsPayload = Array.isArray(schema.params)
|
|
74
|
-
? { actionParams: schema.params as any }
|
|
75
|
-
: { params: schema.params as Record<string, any> | undefined };
|
|
76
|
-
|
|
77
|
-
await execute({
|
|
78
|
-
type: schema.actionType || schema.type,
|
|
79
|
-
name: schema.name,
|
|
80
|
-
target: schema.target,
|
|
81
|
-
execute: schema.execute,
|
|
82
|
-
endpoint: schema.endpoint,
|
|
83
|
-
method: schema.method,
|
|
84
|
-
...paramsPayload,
|
|
85
|
-
confirmText: schema.confirmText,
|
|
86
|
-
successMessage: schema.successMessage,
|
|
87
|
-
errorMessage: schema.errorMessage,
|
|
88
|
-
refreshAfter: schema.refreshAfter,
|
|
89
|
-
toast: schema.toast,
|
|
90
|
-
...localContext,
|
|
91
|
-
});
|
|
92
|
-
} finally {
|
|
93
|
-
setLoading(false);
|
|
94
|
-
}
|
|
95
|
-
}, [schema, execute, loading, localContext]);
|
|
96
|
-
|
|
97
|
-
if (schema.visible && !isVisible) return null;
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<Button
|
|
101
|
-
ref={ref}
|
|
102
|
-
type="button"
|
|
103
|
-
variant={variant as any}
|
|
104
|
-
size={size as any}
|
|
105
|
-
className={cn(schema.className, className)}
|
|
106
|
-
disabled={(schema.enabled ? !isEnabled : false) || loading}
|
|
107
|
-
onClick={handleClick}
|
|
108
|
-
{...rest}
|
|
109
|
-
{...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
|
|
110
|
-
>
|
|
111
|
-
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
112
|
-
{!loading && Icon && <Icon className={cn('h-4 w-4', schema.label && 'mr-2')} />}
|
|
113
|
-
{schema.label}
|
|
114
|
-
</Button>
|
|
115
|
-
);
|
|
116
|
-
},
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
ActionButtonRenderer.displayName = 'ActionButtonRenderer';
|
|
120
|
-
|
|
121
|
-
ComponentRegistry.register('action:button', ActionButtonRenderer, {
|
|
122
|
-
namespace: 'action',
|
|
123
|
-
label: 'Action Button',
|
|
124
|
-
inputs: [
|
|
125
|
-
{ name: 'name', type: 'string', label: 'Action Name' },
|
|
126
|
-
{ name: 'label', type: 'string', label: 'Label', defaultValue: 'Action' },
|
|
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', 'primary', 'secondary', 'destructive', 'outline', 'ghost'],
|
|
141
|
-
defaultValue: 'default',
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: 'size',
|
|
145
|
-
type: 'enum',
|
|
146
|
-
label: 'Size',
|
|
147
|
-
enum: ['sm', 'md', 'lg'],
|
|
148
|
-
defaultValue: 'md',
|
|
149
|
-
},
|
|
150
|
-
{ name: 'className', type: 'string', label: 'CSS Class', advanced: true },
|
|
151
|
-
],
|
|
152
|
-
defaultProps: {
|
|
153
|
-
label: 'Action',
|
|
154
|
-
type: 'script',
|
|
155
|
-
variant: 'default',
|
|
156
|
-
size: 'md',
|
|
157
|
-
},
|
|
158
|
-
});
|
|
@@ -1,270 +0,0 @@
|
|
|
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
|
-
});
|