@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.
- package/.turbo/turbo-build.log +34 -0
- package/CHANGELOG.md +13 -0
- package/README.md +13 -0
- package/dist/index.css +1 -1
- package/dist/index.js +36430 -25529
- package/dist/index.umd.cjs +53 -32
- package/dist/src/SchemaRenderer.d.ts +3 -0
- package/dist/src/custom/action-param-dialog.d.ts +21 -0
- package/dist/src/{ui → custom}/button-group.d.ts +1 -1
- package/dist/src/custom/field.d.ts +19 -0
- package/dist/src/custom/index.d.ts +14 -0
- package/dist/src/custom/input-group.d.ts +14 -0
- package/dist/src/{ui → custom}/item.d.ts +1 -1
- package/dist/src/custom/native-select.d.ts +12 -0
- package/dist/src/custom/navigation-overlay.d.ts +50 -0
- package/dist/src/custom/sort-builder.d.ts +22 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/renderers/action/action-button.d.ts +11 -0
- package/dist/src/renderers/action/action-group.d.ts +25 -0
- package/dist/src/renderers/action/action-icon.d.ts +10 -0
- package/dist/src/renderers/action/action-menu.d.ts +19 -0
- package/dist/src/renderers/action/index.d.ts +0 -0
- package/dist/src/renderers/action/resolve-icon.d.ts +6 -0
- package/dist/src/renderers/data-display/table.d.ts +1 -1
- package/dist/src/renderers/layout/page.d.ts +1 -1
- package/dist/src/renderers/placeholders.d.ts +1 -1
- package/dist/src/ui/accordion.d.ts +4 -4
- package/dist/src/ui/alert-dialog.d.ts +17 -11
- package/dist/src/ui/alert.d.ts +4 -5
- package/dist/src/ui/aspect-ratio.d.ts +1 -1
- package/dist/src/ui/avatar.d.ts +3 -3
- package/dist/src/ui/badge.d.ts +3 -3
- package/dist/src/ui/breadcrumb.d.ts +16 -8
- package/dist/src/ui/calendar.d.ts +7 -7
- package/dist/src/ui/card.d.ts +7 -8
- package/dist/src/ui/carousel.d.ts +5 -6
- package/dist/src/ui/chart.d.ts +62 -0
- package/dist/src/ui/checkbox.d.ts +1 -1
- package/dist/src/ui/collapsible.d.ts +3 -3
- package/dist/src/ui/command.d.ts +78 -16
- package/dist/src/ui/context-menu.d.ts +14 -12
- package/dist/src/ui/dialog.d.ts +17 -13
- package/dist/src/ui/drawer.d.ts +19 -10
- package/dist/src/ui/dropdown-menu.d.ts +20 -18
- package/dist/src/ui/form.d.ts +6 -7
- package/dist/src/ui/hover-card.d.ts +3 -3
- package/dist/src/ui/index.d.ts +2 -8
- package/dist/src/ui/input-otp.d.ts +30 -7
- package/dist/src/ui/label.d.ts +2 -1
- package/dist/src/ui/menubar.d.ts +19 -17
- package/dist/src/ui/navigation-menu.d.ts +9 -11
- package/dist/src/ui/pagination.d.ts +25 -10
- package/dist/src/ui/popover.d.ts +4 -5
- package/dist/src/ui/progress.d.ts +1 -1
- package/dist/src/ui/radio-group.d.ts +2 -2
- package/dist/src/ui/resizable.d.ts +5 -8
- package/dist/src/ui/scroll-area.d.ts +2 -2
- package/dist/src/ui/select.d.ts +11 -13
- package/dist/src/ui/sheet.d.ts +23 -11
- package/dist/src/ui/sidebar.d.ts +27 -29
- package/dist/src/ui/skeleton.d.ts +1 -1
- package/dist/src/ui/slider.d.ts +1 -1
- package/dist/src/ui/sonner.d.ts +2 -1
- package/dist/src/ui/switch.d.ts +2 -2
- package/dist/src/ui/tabs.d.ts +1 -1
- package/dist/src/ui/textarea.d.ts +1 -1
- package/dist/src/ui/toast.d.ts +22 -0
- package/dist/src/ui/toggle-group.d.ts +8 -3
- package/dist/src/ui/toggle.d.ts +4 -1
- package/dist/src/ui/tooltip.d.ts +4 -4
- package/dist/src/ui/typography.d.ts +21 -0
- package/package.json +20 -9
- package/shadcn-components.json +52 -47
- package/src/SchemaRenderer.tsx +28 -0
- package/src/__tests__/PageRendererRegions.test.tsx +668 -0
- package/src/__tests__/Registry.test.ts +21 -0
- package/src/__tests__/basic-renderers.test.tsx +1 -1
- package/src/__tests__/complex-disclosure-renderers.test.tsx +3 -2
- package/src/__tests__/compliance.test.tsx +72 -0
- package/src/__tests__/feedback-overlay-renderers.test.tsx +1 -1
- package/src/__tests__/form-renderers.test.tsx +1 -1
- package/src/__tests__/layout-data-renderers.test.tsx +1 -1
- package/src/__tests__/navigation-overlay.test.tsx +273 -0
- package/src/__tests__/view-compliance.test.tsx +153 -0
- package/src/custom/action-param-dialog.tsx +264 -0
- package/src/{ui → custom}/button-group.tsx +1 -1
- package/src/{ui → custom}/combobox.tsx +3 -3
- package/src/{ui → custom}/date-picker.tsx +3 -3
- package/src/custom/field.tsx +81 -0
- package/src/{ui → custom}/filter-builder.tsx +3 -3
- package/src/custom/index.ts +14 -0
- package/src/custom/input-group.tsx +53 -0
- package/src/{ui → custom}/item.tsx +1 -1
- package/src/custom/native-select.tsx +33 -0
- package/src/custom/navigation-overlay.tsx +296 -0
- package/src/custom/sort-builder.tsx +129 -0
- package/src/index.css +20 -1
- package/src/index.ts +2 -0
- package/src/renderers/action/action-button.tsx +147 -0
- package/src/renderers/action/action-group.tsx +270 -0
- package/src/renderers/action/action-icon.tsx +150 -0
- package/src/renderers/action/action-menu.tsx +203 -0
- package/src/renderers/action/index.ts +18 -0
- package/src/renderers/action/resolve-icon.ts +35 -0
- package/src/renderers/basic/button-group.tsx +1 -0
- package/src/renderers/basic/div.tsx +12 -1
- package/src/renderers/basic/html.tsx +1 -0
- package/src/renderers/basic/icon.tsx +1 -0
- package/src/renderers/basic/image.tsx +1 -0
- package/src/renderers/basic/navigation-menu.tsx +1 -0
- package/src/renderers/basic/pagination.tsx +31 -4
- package/src/renderers/basic/separator.tsx +1 -0
- package/src/renderers/basic/span.tsx +12 -1
- package/src/renderers/basic/text.tsx +4 -2
- package/src/renderers/complex/__tests__/data-table-batch-editing.test.tsx +275 -0
- package/src/renderers/complex/__tests__/data-table-cell-renderer.test.tsx +120 -0
- package/src/renderers/complex/__tests__/data-table-editing.test.tsx +221 -0
- package/src/renderers/complex/carousel.tsx +1 -0
- package/src/renderers/complex/data-table.tsx +355 -95
- package/src/renderers/complex/filter-builder.tsx +2 -1
- package/src/renderers/complex/resizable.tsx +2 -1
- package/src/renderers/complex/scroll-area.tsx +25 -7
- package/src/renderers/complex/table.tsx +1 -0
- package/src/renderers/data-display/alert.tsx +1 -0
- package/src/renderers/data-display/avatar.tsx +1 -0
- package/src/renderers/data-display/badge.tsx +1 -0
- package/src/renderers/data-display/breadcrumb.tsx +1 -0
- package/src/renderers/data-display/kbd.tsx +1 -0
- package/src/renderers/data-display/list.tsx +21 -49
- package/src/renderers/data-display/statistic.tsx +21 -5
- package/src/renderers/data-display/table.tsx +21 -11
- package/src/renderers/data-display/tree-view.tsx +7 -1
- package/src/renderers/disclosure/accordion.tsx +1 -0
- package/src/renderers/disclosure/collapsible.tsx +1 -0
- package/src/renderers/disclosure/toggle-group.tsx +2 -0
- package/src/renderers/feedback/empty.tsx +1 -0
- package/src/renderers/feedback/loading.tsx +2 -1
- package/src/renderers/feedback/progress.tsx +1 -0
- package/src/renderers/feedback/skeleton.tsx +1 -0
- package/src/renderers/feedback/sonner.tsx +1 -0
- package/src/renderers/feedback/spinner.tsx +1 -0
- package/src/renderers/feedback/toast.tsx +1 -0
- package/src/renderers/feedback/toaster.tsx +1 -0
- package/src/renderers/form/button.tsx +35 -1
- package/src/renderers/form/calendar.tsx +1 -0
- package/src/renderers/form/checkbox.tsx +38 -16
- package/src/renderers/form/combobox.tsx +2 -1
- package/src/renderers/form/command.tsx +1 -0
- package/src/renderers/form/date-picker.tsx +1 -0
- package/src/renderers/form/file-upload.tsx +1 -0
- package/src/renderers/form/form.tsx +115 -19
- package/src/renderers/form/input-otp.tsx +1 -0
- package/src/renderers/form/input.tsx +3 -0
- package/src/renderers/form/label.tsx +1 -0
- package/src/renderers/form/radio-group.tsx +1 -0
- package/src/renderers/form/select.tsx +35 -15
- package/src/renderers/form/slider.tsx +1 -0
- package/src/renderers/form/switch.tsx +1 -0
- package/src/renderers/form/textarea.tsx +50 -27
- package/src/renderers/form/toggle.tsx +3 -45
- package/src/renderers/index.ts +1 -0
- package/src/renderers/layout/aspect-ratio.tsx +2 -1
- package/src/renderers/layout/card.tsx +10 -2
- package/src/renderers/layout/container.tsx +1 -0
- package/src/renderers/layout/flex.tsx +1 -0
- package/src/renderers/layout/grid.tsx +23 -8
- package/src/renderers/layout/page.tsx +433 -57
- package/src/renderers/layout/semantic.tsx +1 -0
- package/src/renderers/layout/stack.tsx +2 -1
- package/src/renderers/layout/tabs.tsx +43 -17
- package/src/renderers/navigation/header-bar.tsx +1 -0
- package/src/renderers/navigation/sidebar.tsx +11 -0
- package/src/renderers/overlay/alert-dialog.tsx +1 -0
- package/src/renderers/overlay/context-menu.tsx +1 -0
- package/src/renderers/overlay/dialog.tsx +1 -0
- package/src/renderers/overlay/drawer.tsx +1 -0
- package/src/renderers/overlay/dropdown-menu.tsx +1 -0
- package/src/renderers/overlay/hover-card.tsx +1 -0
- package/src/renderers/overlay/menubar.tsx +1 -0
- package/src/renderers/overlay/popover.tsx +1 -0
- package/src/renderers/overlay/sheet.tsx +1 -0
- package/src/renderers/overlay/tooltip.tsx +1 -0
- package/src/renderers/placeholders.tsx +4 -4
- package/src/stories/CRMApp.stories.tsx +706 -0
- package/src/stories/Guide.mdx +55 -0
- package/src/stories/Introduction.mdx +61 -0
- package/src/stories/MockedData.stories.tsx +121 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- 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 +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +1 -0
- 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 +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +68 -0
- package/src/stories-json/accordion.stories.tsx +43 -0
- package/src/stories-json/aggrid.stories.tsx +103 -0
- package/src/stories-json/alert.stories.tsx +39 -0
- package/src/stories-json/aspect-ratio.stories.tsx +34 -0
- package/src/stories-json/avatar.stories.tsx +38 -0
- package/src/stories-json/badge.stories.tsx +53 -0
- package/src/stories-json/breadcrumb.stories.tsx +30 -0
- package/src/stories-json/button-group.stories.tsx +43 -0
- package/src/stories-json/button.stories.tsx +73 -0
- package/src/stories-json/calendar.stories.tsx +85 -0
- package/src/stories-json/card.stories.tsx +48 -0
- package/src/stories-json/carousel.stories.tsx +33 -0
- package/src/stories-json/charts.stories.tsx +195 -0
- package/src/stories-json/chatbot.stories.tsx +248 -0
- package/src/stories-json/code-editor.stories.tsx +92 -0
- package/src/stories-json/collapsible.stories.tsx +40 -0
- package/src/stories-json/controls.stories.tsx +36 -0
- package/src/stories-json/crm-live-data.stories.tsx +154 -0
- package/src/stories-json/dashboard.stories.tsx +318 -0
- package/src/stories-json/data-table.stories.tsx +136 -0
- package/src/stories-json/data_display_extras.stories.tsx +102 -0
- package/src/stories-json/date-picker.stories.tsx +28 -0
- package/src/stories-json/detail-view.stories.tsx +258 -0
- package/src/stories-json/dialog.stories.tsx +43 -0
- package/src/stories-json/feedback_extras.stories.tsx +40 -0
- package/src/stories-json/feedback_others.stories.tsx +46 -0
- package/src/stories-json/form-variants.stories.tsx +210 -0
- package/src/stories-json/form_advanced.stories.tsx +117 -0
- package/src/stories-json/form_extras.stories.tsx +123 -0
- package/src/stories-json/grid.stories.tsx +56 -0
- package/src/stories-json/icon.stories.tsx +36 -0
- package/src/stories-json/input.stories.tsx +52 -0
- package/src/stories-json/kanban.stories.tsx +295 -0
- package/src/stories-json/layout_extended.stories.tsx +76 -0
- package/src/stories-json/layout_flex.stories.tsx +107 -0
- package/src/stories-json/list-view.stories.tsx +97 -0
- package/src/stories-json/markdown.stories.tsx +129 -0
- package/src/stories-json/menus.stories.tsx +63 -0
- package/src/stories-json/metric-card.stories.tsx +143 -0
- package/src/stories-json/navigation-menu.stories.tsx +37 -0
- package/src/stories-json/object-aggrid-advanced.stories.tsx +389 -0
- package/src/stories-json/object-aggrid.stories.tsx +252 -0
- package/src/stories-json/object-form.stories.tsx +130 -0
- package/src/stories-json/object-gantt.stories.tsx +114 -0
- package/src/stories-json/object-grid.stories.tsx +315 -0
- package/src/stories-json/object-map.stories.tsx +116 -0
- package/src/stories-json/object-view.stories.tsx +118 -0
- package/src/stories-json/overlay_extras.stories.tsx +113 -0
- package/src/stories-json/overlay_others.stories.tsx +76 -0
- package/src/stories-json/page.stories.tsx +55 -0
- package/src/stories-json/reports.stories.tsx +163 -0
- package/src/stories-json/resizable.stories.tsx +44 -0
- package/src/stories-json/select.stories.tsx +34 -0
- package/src/stories-json/separator.stories.tsx +41 -0
- package/src/stories-json/sidebar.stories.tsx +147 -0
- package/src/stories-json/statistic.stories.tsx +44 -0
- package/src/stories-json/tabs.stories.tsx +51 -0
- package/src/stories-json/timeline.stories.tsx +188 -0
- package/src/stories-json/typography.stories.tsx +45 -0
- package/src/ui/accordion.tsx +47 -53
- package/src/ui/alert-dialog.tsx +103 -117
- package/src/ui/alert.tsx +35 -36
- package/src/ui/aspect-ratio.tsx +1 -5
- package/src/ui/avatar.tsx +41 -42
- package/src/ui/badge.tsx +6 -15
- package/src/ui/breadcrumb.tsx +81 -75
- package/src/ui/button.tsx +10 -11
- package/src/ui/calendar.tsx +178 -51
- package/src/ui/card.tsx +51 -110
- package/src/ui/carousel.tsx +136 -113
- package/src/ui/chart.tsx +367 -0
- package/src/ui/checkbox.tsx +20 -22
- package/src/ui/collapsible.tsx +5 -25
- package/src/ui/command.tsx +106 -135
- package/src/ui/context-menu.tsx +69 -116
- package/src/ui/dialog.tsx +94 -113
- package/src/ui/drawer.tsx +82 -99
- package/src/ui/dropdown-menu.tsx +134 -188
- package/src/ui/form.tsx +51 -40
- package/src/ui/hover-card.tsx +18 -33
- package/src/ui/index.ts +2 -8
- package/src/ui/input-otp.tsx +42 -52
- package/src/ui/input.tsx +13 -15
- package/src/ui/label.tsx +17 -15
- package/src/ui/menubar.tsx +188 -206
- package/src/ui/navigation-menu.tsx +96 -136
- package/src/ui/pagination.tsx +86 -96
- package/src/ui/popover.tsx +24 -41
- package/src/ui/progress.tsx +21 -22
- package/src/ui/radio-group.tsx +19 -20
- package/src/ui/resizable.tsx +32 -42
- package/src/ui/scroll-area.tsx +38 -48
- package/src/ui/select.tsx +129 -157
- package/src/ui/separator.tsx +2 -2
- package/src/ui/sheet.tsx +110 -107
- package/src/ui/sidebar.tsx +442 -408
- package/src/ui/skeleton.tsx +6 -11
- package/src/ui/slider.tsx +19 -54
- package/src/ui/sonner.tsx +19 -1
- package/src/ui/switch.tsx +19 -21
- package/src/ui/tabs.tsx +6 -37
- package/src/ui/textarea.tsx +8 -4
- package/src/ui/toast.tsx +137 -0
- package/src/ui/toggle-group.tsx +28 -37
- package/src/ui/toggle.tsx +19 -19
- package/src/ui/tooltip.tsx +21 -52
- package/src/ui/typography.tsx +85 -0
- package/tsconfig.json +1 -1
- package/vite.config.ts +9 -1
- package/vitest.config.ts +5 -0
- package/ISSUES_FOUND.md +0 -128
- /package/dist/src/{ui → custom}/combobox.d.ts +0 -0
- /package/dist/src/{ui → custom}/date-picker.d.ts +0 -0
- /package/dist/src/{ui → custom}/empty.d.ts +0 -0
- /package/dist/src/{ui → custom}/filter-builder.d.ts +0 -0
- /package/dist/src/{ui → custom}/kbd.d.ts +0 -0
- /package/dist/src/{ui → custom}/spinner.d.ts +0 -0
- /package/src/{ui → custom}/empty.tsx +0 -0
- /package/src/{ui → custom}/kbd.tsx +0 -0
- /package/src/{ui → custom}/spinner.tsx +0 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { SchemaRenderer } from '../SchemaRenderer';
|
|
3
|
+
import type { BaseSchema } from '@object-ui/types';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Plugins/Rich Content/Chatbot',
|
|
7
|
+
component: SchemaRenderer,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'centered',
|
|
10
|
+
},
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
argTypes: {
|
|
13
|
+
schema: { table: { disable: true } },
|
|
14
|
+
},
|
|
15
|
+
} satisfies Meta<any>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
const renderStory = (args: any) => <SchemaRenderer schema={args as unknown as BaseSchema} />;
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
render: renderStory,
|
|
24
|
+
args: {
|
|
25
|
+
type: 'chatbot',
|
|
26
|
+
messages: [
|
|
27
|
+
{
|
|
28
|
+
id: 'welcome',
|
|
29
|
+
role: 'assistant',
|
|
30
|
+
content: 'Hello! How can I help you today?',
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
placeholder: 'Type your message...',
|
|
34
|
+
showTimestamp: false,
|
|
35
|
+
disabled: false,
|
|
36
|
+
userAvatarFallback: 'You',
|
|
37
|
+
assistantAvatarFallback: 'AI',
|
|
38
|
+
maxHeight: '500px',
|
|
39
|
+
autoResponse: true,
|
|
40
|
+
autoResponseText: 'Thank you for your message! This is an automated response.',
|
|
41
|
+
autoResponseDelay: 1000,
|
|
42
|
+
className: 'w-full max-w-2xl'
|
|
43
|
+
} as any,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const WithTimestamps: Story = {
|
|
47
|
+
render: renderStory,
|
|
48
|
+
args: {
|
|
49
|
+
type: 'chatbot',
|
|
50
|
+
messages: [
|
|
51
|
+
{
|
|
52
|
+
id: '1',
|
|
53
|
+
role: 'assistant',
|
|
54
|
+
content: 'Hello! I\'m here to assist you.',
|
|
55
|
+
timestamp: '10:00 AM'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: '2',
|
|
59
|
+
role: 'user',
|
|
60
|
+
content: 'Hi! I need help with my account.',
|
|
61
|
+
timestamp: '10:01 AM'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: '3',
|
|
65
|
+
role: 'assistant',
|
|
66
|
+
content: 'I\'d be happy to help! What specific issue are you experiencing?',
|
|
67
|
+
timestamp: '10:01 AM'
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
placeholder: 'Type your message...',
|
|
71
|
+
showTimestamp: true,
|
|
72
|
+
autoResponse: true,
|
|
73
|
+
autoResponseText: 'I understand your concern. Let me help you with that.',
|
|
74
|
+
className: 'w-full max-w-2xl'
|
|
75
|
+
} as any,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const CustomerSupport: Story = {
|
|
79
|
+
render: renderStory,
|
|
80
|
+
args: {
|
|
81
|
+
type: 'chatbot',
|
|
82
|
+
messages: [
|
|
83
|
+
{
|
|
84
|
+
id: '1',
|
|
85
|
+
role: 'system',
|
|
86
|
+
content: 'Support session started'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: '2',
|
|
90
|
+
role: 'assistant',
|
|
91
|
+
content: 'Welcome to customer support! How may I assist you today?',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: '3',
|
|
95
|
+
role: 'user',
|
|
96
|
+
content: 'I\'m having trouble accessing my dashboard.',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: '4',
|
|
100
|
+
role: 'assistant',
|
|
101
|
+
content: 'I\'m sorry to hear that. Let me help you troubleshoot. First, can you tell me what error message you\'re seeing?',
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
placeholder: 'Describe your issue...',
|
|
105
|
+
assistantAvatarFallback: 'CS',
|
|
106
|
+
autoResponse: true,
|
|
107
|
+
autoResponseText: 'Thank you for that information. Let me check our system.',
|
|
108
|
+
autoResponseDelay: 1500,
|
|
109
|
+
className: 'w-full max-w-2xl'
|
|
110
|
+
} as any,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const WithMarkdown: Story = {
|
|
114
|
+
render: renderStory,
|
|
115
|
+
args: {
|
|
116
|
+
type: 'chatbot',
|
|
117
|
+
messages: [
|
|
118
|
+
{
|
|
119
|
+
id: '1',
|
|
120
|
+
role: 'user',
|
|
121
|
+
content: 'Can you show me how to use markdown?',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: '2',
|
|
125
|
+
role: 'assistant',
|
|
126
|
+
content: `Sure! Here are some markdown examples:
|
|
127
|
+
|
|
128
|
+
**Bold text** and *italic text*
|
|
129
|
+
|
|
130
|
+
# Heading 1
|
|
131
|
+
## Heading 2
|
|
132
|
+
|
|
133
|
+
- List item 1
|
|
134
|
+
- List item 2
|
|
135
|
+
- List item 3
|
|
136
|
+
|
|
137
|
+
\`inline code\` and code blocks:
|
|
138
|
+
|
|
139
|
+
\`\`\`javascript
|
|
140
|
+
const greeting = "Hello, World!";
|
|
141
|
+
console.log(greeting);
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
> This is a blockquote
|
|
145
|
+
`,
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
placeholder: 'Type your message...',
|
|
149
|
+
enableMarkdown: true,
|
|
150
|
+
showTimestamp: false,
|
|
151
|
+
autoResponse: true,
|
|
152
|
+
autoResponseText: 'Markdown is great for formatting!',
|
|
153
|
+
className: 'w-full max-w-2xl'
|
|
154
|
+
} as any,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export const WithCodeHighlighting: Story = {
|
|
158
|
+
render: renderStory,
|
|
159
|
+
args: {
|
|
160
|
+
type: 'chatbot',
|
|
161
|
+
messages: [
|
|
162
|
+
{
|
|
163
|
+
id: '1',
|
|
164
|
+
role: 'user',
|
|
165
|
+
content: 'Can you help me with a React component?',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: '2',
|
|
169
|
+
role: 'assistant',
|
|
170
|
+
content: `Of course! Here's a simple React component example:
|
|
171
|
+
|
|
172
|
+
\`\`\`tsx
|
|
173
|
+
import React from 'react';
|
|
174
|
+
|
|
175
|
+
interface ButtonProps {
|
|
176
|
+
label: string;
|
|
177
|
+
onClick: () => void;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export const Button: React.FC<ButtonProps> = ({ label, onClick }) => {
|
|
181
|
+
return (
|
|
182
|
+
<button
|
|
183
|
+
onClick={onClick}
|
|
184
|
+
className="px-4 py-2 bg-blue-500 text-white rounded"
|
|
185
|
+
>
|
|
186
|
+
{label}
|
|
187
|
+
</button>
|
|
188
|
+
);
|
|
189
|
+
};
|
|
190
|
+
\`\`\`
|
|
191
|
+
|
|
192
|
+
This component accepts a \`label\` and \`onClick\` handler as props.`,
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
placeholder: 'Ask me anything...',
|
|
196
|
+
enableMarkdown: true,
|
|
197
|
+
showTimestamp: false,
|
|
198
|
+
autoResponse: true,
|
|
199
|
+
autoResponseText: 'I can help with code examples!',
|
|
200
|
+
className: 'w-full max-w-2xl'
|
|
201
|
+
} as any,
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export const WithFileUpload: Story = {
|
|
205
|
+
render: renderStory,
|
|
206
|
+
args: {
|
|
207
|
+
type: 'chatbot',
|
|
208
|
+
messages: [
|
|
209
|
+
{
|
|
210
|
+
id: '1',
|
|
211
|
+
role: 'assistant',
|
|
212
|
+
content: 'You can upload files by clicking the attachment button below.',
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
placeholder: 'Type your message or upload a file...',
|
|
216
|
+
enableFileUpload: true,
|
|
217
|
+
acceptedFileTypes: 'image/*,.pdf,.doc,.docx',
|
|
218
|
+
maxFileSize: 5242880, // 5MB
|
|
219
|
+
showTimestamp: false,
|
|
220
|
+
autoResponse: true,
|
|
221
|
+
autoResponseText: 'File received! Processing...',
|
|
222
|
+
className: 'w-full max-w-2xl'
|
|
223
|
+
} as any,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export const StreamingResponse: Story = {
|
|
227
|
+
render: renderStory,
|
|
228
|
+
args: {
|
|
229
|
+
type: 'chatbot',
|
|
230
|
+
messages: [
|
|
231
|
+
{
|
|
232
|
+
id: '1',
|
|
233
|
+
role: 'user',
|
|
234
|
+
content: 'Tell me a story',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
id: '2',
|
|
238
|
+
role: 'assistant',
|
|
239
|
+
content: 'Once upon a time in a digital world...',
|
|
240
|
+
streaming: true,
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
placeholder: 'Type your message...',
|
|
244
|
+
enableMarkdown: true,
|
|
245
|
+
showTimestamp: false,
|
|
246
|
+
className: 'w-full max-w-2xl'
|
|
247
|
+
} as any,
|
|
248
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { SchemaRenderer } from '../SchemaRenderer';
|
|
3
|
+
import type { BaseSchema } from '@object-ui/types';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Plugins/Rich Content/Code Editor',
|
|
7
|
+
component: SchemaRenderer,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'padded',
|
|
10
|
+
},
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
argTypes: {
|
|
13
|
+
schema: { table: { disable: true } },
|
|
14
|
+
},
|
|
15
|
+
} satisfies Meta<any>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
const renderStory = (args: any) => <SchemaRenderer schema={args as unknown as BaseSchema} />;
|
|
21
|
+
|
|
22
|
+
export const JavaScript: Story = {
|
|
23
|
+
render: renderStory,
|
|
24
|
+
args: {
|
|
25
|
+
type: 'code-editor',
|
|
26
|
+
value: '// Write your code here\nconsole.log("Hello, World!");',
|
|
27
|
+
language: 'javascript',
|
|
28
|
+
theme: 'vs-dark',
|
|
29
|
+
height: '400px',
|
|
30
|
+
readOnly: false
|
|
31
|
+
} as any,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const TypeScript: Story = {
|
|
35
|
+
render: renderStory,
|
|
36
|
+
args: {
|
|
37
|
+
type: 'code-editor',
|
|
38
|
+
value: 'interface User {\n id: number;\n name: string;\n email: string;\n}\n\nconst user: User = {\n id: 1,\n name: "John Doe",\n email: "john@example.com"\n};',
|
|
39
|
+
language: 'typescript',
|
|
40
|
+
theme: 'vs-dark',
|
|
41
|
+
height: '400px',
|
|
42
|
+
readOnly: false
|
|
43
|
+
} as any,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const Python: Story = {
|
|
47
|
+
render: renderStory,
|
|
48
|
+
args: {
|
|
49
|
+
type: 'code-editor',
|
|
50
|
+
value: 'def greet(name):\n """Greet a person by name."""\n return f"Hello, {name}!"\n\nif __name__ == "__main__":\n print(greet("World"))',
|
|
51
|
+
language: 'python',
|
|
52
|
+
theme: 'vs-dark',
|
|
53
|
+
height: '400px',
|
|
54
|
+
readOnly: false
|
|
55
|
+
} as any,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const JSON: Story = {
|
|
59
|
+
render: renderStory,
|
|
60
|
+
args: {
|
|
61
|
+
type: 'code-editor',
|
|
62
|
+
value: '{\n "name": "ObjectUI",\n "version": "1.0.0",\n "description": "Server-Driven UI Engine",\n "features": [\n "JSON-based components",\n "React integration",\n "Tailwind styling"\n ]\n}',
|
|
63
|
+
language: 'json',
|
|
64
|
+
theme: 'vs-dark',
|
|
65
|
+
height: '400px',
|
|
66
|
+
readOnly: false
|
|
67
|
+
} as any,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const ReadOnly: Story = {
|
|
71
|
+
render: renderStory,
|
|
72
|
+
args: {
|
|
73
|
+
type: 'code-editor',
|
|
74
|
+
value: '// This editor is read-only\nconst message = "You cannot edit this code";\nconsole.log(message);',
|
|
75
|
+
language: 'javascript',
|
|
76
|
+
theme: 'vs-dark',
|
|
77
|
+
height: '300px',
|
|
78
|
+
readOnly: true
|
|
79
|
+
} as any,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const LightTheme: Story = {
|
|
83
|
+
render: renderStory,
|
|
84
|
+
args: {
|
|
85
|
+
type: 'code-editor',
|
|
86
|
+
value: 'function fibonacci(n) {\n if (n <= 1) return n;\n return fibonacci(n - 1) + fibonacci(n - 2);\n}\n\nconsole.log(fibonacci(10));',
|
|
87
|
+
language: 'javascript',
|
|
88
|
+
theme: 'light',
|
|
89
|
+
height: '400px',
|
|
90
|
+
readOnly: false
|
|
91
|
+
} as any,
|
|
92
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { SchemaRenderer } from '../SchemaRenderer';
|
|
3
|
+
import type { BaseSchema } from '@object-ui/types';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Primitives/Data Display/Collapsible',
|
|
7
|
+
component: SchemaRenderer,
|
|
8
|
+
parameters: { layout: 'centered' },
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
schema: { table: { disable: true } }
|
|
12
|
+
}
|
|
13
|
+
} satisfies Meta<typeof SchemaRenderer>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const renderStory = (args: any) => <SchemaRenderer schema={args as unknown as BaseSchema} />;
|
|
19
|
+
|
|
20
|
+
export const Collapsible: Story = {
|
|
21
|
+
render: renderStory,
|
|
22
|
+
args: {
|
|
23
|
+
type: 'collapsible',
|
|
24
|
+
className: 'w-[350px] space-y-2',
|
|
25
|
+
trigger: [
|
|
26
|
+
{
|
|
27
|
+
type: 'div',
|
|
28
|
+
className: 'flex items-center justify-between space-x-4 px-4 py-2 hover:bg-muted/50 rounded-md cursor-pointer',
|
|
29
|
+
children: [
|
|
30
|
+
{ type: 'text', content: '@peduarte starred 3 repositories' },
|
|
31
|
+
{ type: 'icon', name: 'chevrons-up-down', className: 'h-4 w-4' }
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
content: [
|
|
36
|
+
{ type: 'div', className: 'rounded-md border p-2 mb-2', children: [{type:'text', content: '@radix-ui/primitives'}] },
|
|
37
|
+
{ type: 'div', className: 'rounded-md border p-2', children: [{type:'text', content: '@radix-ui/react'}] }
|
|
38
|
+
]
|
|
39
|
+
} as any,
|
|
40
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { SchemaRenderer } from '../SchemaRenderer';
|
|
3
|
+
import type { BaseSchema } from '@object-ui/types';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Primitives/Data Entry/Controls',
|
|
7
|
+
component: SchemaRenderer,
|
|
8
|
+
parameters: { layout: 'centered' },
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
schema: { table: { disable: true } }
|
|
12
|
+
}
|
|
13
|
+
} satisfies Meta<typeof SchemaRenderer>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const renderStory = (args: any) => <SchemaRenderer schema={args as unknown as BaseSchema} />;
|
|
19
|
+
|
|
20
|
+
export const Checkbox: Story = {
|
|
21
|
+
render: renderStory,
|
|
22
|
+
args: {
|
|
23
|
+
type: 'checkbox',
|
|
24
|
+
label: 'Accept terms and conditions',
|
|
25
|
+
id: 'terms1'
|
|
26
|
+
} as any,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Switch: Story = {
|
|
30
|
+
render: renderStory,
|
|
31
|
+
args: {
|
|
32
|
+
type: 'switch',
|
|
33
|
+
label: 'Airplane Mode',
|
|
34
|
+
id: 'airplane-mode'
|
|
35
|
+
} as any,
|
|
36
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import React, { useEffect, useState, useCallback } from 'react';
|
|
3
|
+
import { SchemaRenderer, SchemaRendererProvider } from '@object-ui/react';
|
|
4
|
+
import type { BaseSchema } from '@object-ui/types';
|
|
5
|
+
import { createStorybookDataSource } from '@storybook-config/datasource';
|
|
6
|
+
|
|
7
|
+
const meta: Meta = {
|
|
8
|
+
title: 'Plugins/Data Views/CRM Live Data',
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'padded',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
const dataSource = createStorybookDataSource();
|
|
17
|
+
|
|
18
|
+
// ==========================================
|
|
19
|
+
// Helper: Fetches data from MSW and renders a schema
|
|
20
|
+
// ==========================================
|
|
21
|
+
const LiveDataView = ({
|
|
22
|
+
objectName,
|
|
23
|
+
schema,
|
|
24
|
+
title
|
|
25
|
+
}: {
|
|
26
|
+
objectName: string;
|
|
27
|
+
schema: (data: any[]) => BaseSchema;
|
|
28
|
+
title: string;
|
|
29
|
+
}) => {
|
|
30
|
+
const [data, setData] = useState<any[]>([]);
|
|
31
|
+
const [loading, setLoading] = useState(true);
|
|
32
|
+
const [error, setError] = useState<string | null>(null);
|
|
33
|
+
|
|
34
|
+
const fetchData = useCallback(async () => {
|
|
35
|
+
setLoading(true);
|
|
36
|
+
setError(null);
|
|
37
|
+
try {
|
|
38
|
+
const result = await dataSource.find(objectName, { $top: 50 });
|
|
39
|
+
setData(result.data as any[]);
|
|
40
|
+
} catch (err: any) {
|
|
41
|
+
console.error(`[CRM Live] Failed to fetch ${objectName}:`, err);
|
|
42
|
+
setError(err?.message || `Failed to fetch ${objectName}`);
|
|
43
|
+
} finally {
|
|
44
|
+
setLoading(false);
|
|
45
|
+
}
|
|
46
|
+
}, [objectName]);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
fetchData();
|
|
50
|
+
}, [fetchData]);
|
|
51
|
+
|
|
52
|
+
if (loading) return <div className="p-8 text-muted-foreground">Loading {title} from MSW API...</div>;
|
|
53
|
+
if (error) return (
|
|
54
|
+
<div className="p-8 space-y-2">
|
|
55
|
+
<div className="text-destructive font-medium">API Error: {error}</div>
|
|
56
|
+
<div className="text-sm text-muted-foreground">
|
|
57
|
+
Ensure the ObjectStack MSW runtime is running. Check browser console for logs.
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<SchemaRendererProvider dataSource={dataSource}>
|
|
64
|
+
<div className="space-y-4">
|
|
65
|
+
<h2 className="text-lg font-semibold">{title} ({data.length} records)</h2>
|
|
66
|
+
<SchemaRenderer schema={schema(data)} />
|
|
67
|
+
</div>
|
|
68
|
+
</SchemaRendererProvider>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// ==========================================
|
|
73
|
+
// Contact Grid from MSW
|
|
74
|
+
// ==========================================
|
|
75
|
+
export const ContactGrid: StoryObj = {
|
|
76
|
+
name: 'Contact Grid (Live)',
|
|
77
|
+
render: () => (
|
|
78
|
+
<LiveDataView
|
|
79
|
+
objectName="contact"
|
|
80
|
+
title="Contacts"
|
|
81
|
+
schema={(data) => ({
|
|
82
|
+
type: 'object-grid',
|
|
83
|
+
objectName: 'contact',
|
|
84
|
+
columns: [
|
|
85
|
+
{ field: 'name', header: 'Name', sortable: true, filterable: true },
|
|
86
|
+
{ field: 'email', header: 'Email', sortable: true },
|
|
87
|
+
{ field: 'title', header: 'Title' },
|
|
88
|
+
{ field: 'department', header: 'Department' },
|
|
89
|
+
{ field: 'status', header: 'Status', sortable: true },
|
|
90
|
+
],
|
|
91
|
+
data,
|
|
92
|
+
pagination: true,
|
|
93
|
+
pageSize: 10,
|
|
94
|
+
className: 'w-full',
|
|
95
|
+
} as any)}
|
|
96
|
+
/>
|
|
97
|
+
),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// ==========================================
|
|
101
|
+
// Account Grid from MSW
|
|
102
|
+
// ==========================================
|
|
103
|
+
export const AccountGrid: StoryObj = {
|
|
104
|
+
name: 'Account Grid (Live)',
|
|
105
|
+
render: () => (
|
|
106
|
+
<LiveDataView
|
|
107
|
+
objectName="account"
|
|
108
|
+
title="Accounts"
|
|
109
|
+
schema={(data) => ({
|
|
110
|
+
type: 'object-grid',
|
|
111
|
+
objectName: 'account',
|
|
112
|
+
columns: [
|
|
113
|
+
{ field: 'name', header: 'Company', sortable: true, filterable: true },
|
|
114
|
+
{ field: 'industry', header: 'Industry', sortable: true },
|
|
115
|
+
{ field: 'type', header: 'Type' },
|
|
116
|
+
{ field: 'employees', header: 'Employees', type: 'number' },
|
|
117
|
+
{ field: 'phone', header: 'Phone' },
|
|
118
|
+
],
|
|
119
|
+
data,
|
|
120
|
+
pagination: true,
|
|
121
|
+
pageSize: 10,
|
|
122
|
+
className: 'w-full',
|
|
123
|
+
} as any)}
|
|
124
|
+
/>
|
|
125
|
+
),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// ==========================================
|
|
129
|
+
// Opportunity Grid from MSW
|
|
130
|
+
// ==========================================
|
|
131
|
+
export const OpportunityGrid: StoryObj = {
|
|
132
|
+
name: 'Opportunity Grid (Live)',
|
|
133
|
+
render: () => (
|
|
134
|
+
<LiveDataView
|
|
135
|
+
objectName="opportunity"
|
|
136
|
+
title="Opportunities"
|
|
137
|
+
schema={(data) => ({
|
|
138
|
+
type: 'object-grid',
|
|
139
|
+
objectName: 'opportunity',
|
|
140
|
+
columns: [
|
|
141
|
+
{ field: 'name', header: 'Opportunity', sortable: true },
|
|
142
|
+
{ field: 'amount', header: 'Amount', type: 'currency', sortable: true },
|
|
143
|
+
{ field: 'stage', header: 'Stage', sortable: true },
|
|
144
|
+
{ field: 'probability', header: 'Probability' },
|
|
145
|
+
{ field: 'close_date', header: 'Close Date', type: 'date' },
|
|
146
|
+
],
|
|
147
|
+
data,
|
|
148
|
+
pagination: true,
|
|
149
|
+
pageSize: 10,
|
|
150
|
+
className: 'w-full',
|
|
151
|
+
} as any)}
|
|
152
|
+
/>
|
|
153
|
+
),
|
|
154
|
+
};
|