Skip to content

Commit bf15b65

Browse files
authored
Merge pull request #214 from objectstack-ai/copilot/standardize-forms-and-toasts
2 parents 19edddd + 1e869fe commit bf15b65

File tree

9 files changed

+19
-839
lines changed

9 files changed

+19
-839
lines changed

packages/components/src/hooks/use-toast.ts

Lines changed: 0 additions & 197 deletions
This file was deleted.

packages/components/src/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ import './renderers';
1414
// Export utils
1515
export * from './lib/utils';
1616

17-
// Export hooks
18-
export * from './hooks/use-toast';
19-
2017
// Export raw Shadcn UI components
2118
export * from './ui';
2219

packages/components/src/renderers/feedback/toast.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88

99
import { ComponentRegistry } from '@object-ui/core';
1010
import type { ToastSchema } from '@object-ui/types';
11-
import { useToast } from '../../hooks/use-toast';
11+
import { toast } from 'sonner';
1212
import { Button } from '../../ui';
1313

1414
ComponentRegistry.register('toast',
15-
({ schema, ...props }: { schema: ToastSchema; [key: string]: any }) => {
16-
const { toast } = useToast();
17-
15+
({ schema }: { schema: ToastSchema }) => {
1816
const showToast = () => {
19-
toast({
20-
title: schema.title,
17+
const toastFn = schema.variant === 'success' ? toast.success :
18+
schema.variant === 'error' ? toast.error :
19+
schema.variant === 'warning' ? toast.warning :
20+
schema.variant === 'info' ? toast.info :
21+
toast;
22+
23+
toastFn(schema.title || 'Notification', {
2124
description: schema.description,
22-
variant: schema.variant as any,
25+
duration: schema.duration,
2326
});
2427
};
2528

@@ -37,17 +40,19 @@ ComponentRegistry.register('toast',
3740
{
3841
name: 'variant',
3942
type: 'enum',
40-
enum: ['default', 'destructive'],
43+
enum: ['default', 'success', 'warning', 'error', 'info'],
4144
defaultValue: 'default',
4245
label: 'Variant'
4346
},
47+
{ name: 'duration', type: 'number', label: 'Duration (ms)' },
4448
{ name: 'buttonLabel', type: 'string', label: 'Button Label' },
4549
{ name: 'className', type: 'string', label: 'CSS Class' }
4650
],
4751
defaultProps: {
4852
title: 'Notification',
4953
buttonLabel: 'Show Toast',
50-
variant: 'default'
54+
variant: 'default',
55+
duration: 5000
5156
}
5257
}
5358
);

packages/components/src/renderers/feedback/toaster.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,14 @@
99
import { ComponentRegistry } from '@object-ui/core';
1010
import type { ToasterSchema } from '@object-ui/types';
1111
import { Toaster as SonnerToaster } from '../../ui/sonner';
12-
import { ToastNotifier as DefaultToaster } from '../../ui';
13-
// Note: In shadcn/ui typical setup, Toaster is exported from 'components/ui/toaster' and 'components/ui/sonner'.
14-
// But in @object-ui/ui index.tsx, we need to check if they are exported.
15-
// Assuming they are exported as Toaster and Sonner (or similar).
16-
// Let's assume standard exports.
1712

1813
ComponentRegistry.register('toaster',
19-
({ schema }: { schema: ToasterSchema }) => {
20-
if (schema.provider === 'sonner') {
21-
return <SonnerToaster />;
22-
}
23-
return <DefaultToaster />;
14+
() => {
15+
return <SonnerToaster />;
2416
},
2517
{
2618
label: 'Toaster',
27-
inputs: [
28-
{ name: 'provider', type: 'enum', enum: ['default', 'sonner'], defaultValue: 'default', label: 'Provider' }
29-
],
30-
defaultProps: {
31-
provider: 'default'
32-
}
19+
inputs: [],
20+
defaultProps: {}
3321
}
3422
);

0 commit comments

Comments
 (0)