@object-ui/plugin-timeline 3.1.5 → 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.
Files changed (33) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +20 -0
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.js +1041 -751
  5. package/dist/index.umd.cjs +31 -6
  6. package/dist/packages/plugin-timeline/src/ObjectTimeline.d.ts.map +1 -0
  7. package/dist/packages/plugin-timeline/src/ObjectTimeline.stories.d.ts.map +1 -0
  8. package/dist/packages/plugin-timeline/src/index.d.ts.map +1 -0
  9. package/dist/packages/plugin-timeline/src/renderer.d.ts.map +1 -0
  10. package/package.json +36 -13
  11. package/.turbo/turbo-build.log +0 -22
  12. package/dist/src/ObjectTimeline.d.ts.map +0 -1
  13. package/dist/src/ObjectTimeline.stories.d.ts.map +0 -1
  14. package/dist/src/index.d.ts.map +0 -1
  15. package/dist/src/renderer.d.ts.map +0 -1
  16. package/src/ObjectTimeline.msw.test.tsx +0 -80
  17. package/src/ObjectTimeline.stories.tsx +0 -113
  18. package/src/ObjectTimeline.test.tsx +0 -138
  19. package/src/ObjectTimeline.tsx +0 -241
  20. package/src/__tests__/ObjectTimeline.spec-config.test.tsx +0 -232
  21. package/src/__tests__/renderer.test.tsx +0 -295
  22. package/src/__tests__/timeline-variants.test.tsx +0 -150
  23. package/src/index.test.tsx +0 -24
  24. package/src/index.tsx +0 -334
  25. package/src/renderer.tsx +0 -477
  26. package/tsconfig.json +0 -18
  27. package/vite.config.ts +0 -63
  28. package/vitest.config.ts +0 -13
  29. package/vitest.setup.ts +0 -1
  30. /package/dist/{src → packages/plugin-timeline/src}/ObjectTimeline.d.ts +0 -0
  31. /package/dist/{src → packages/plugin-timeline/src}/ObjectTimeline.stories.d.ts +0 -0
  32. /package/dist/{src → packages/plugin-timeline/src}/index.d.ts +0 -0
  33. /package/dist/{src → packages/plugin-timeline/src}/renderer.d.ts +0 -0
@@ -1,24 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { render, screen } from '@testing-library/react';
3
- import React from 'react';
4
- import { ObjectTimelineRenderer } from './index';
5
-
6
- // Mock dependencies
7
- vi.mock('@object-ui/react', () => ({
8
- useSchemaContext: vi.fn(() => ({ dataSource: { type: 'mock-datasource' } })),
9
- }));
10
-
11
- vi.mock('./ObjectTimeline', () => ({
12
- ObjectTimeline: ({ dataSource }: any) => (
13
- <div data-testid="timeline-mock">
14
- {dataSource ? `DataSource: ${dataSource.type}` : 'No DataSource'}
15
- </div>
16
- )
17
- }));
18
-
19
- describe('Plugin Timeline Registration', () => {
20
- it('renderer passes dataSource from context', () => {
21
- render(<ObjectTimelineRenderer schema={{ type: 'object-timeline' }} />);
22
- expect(screen.getByTestId('timeline-mock')).toHaveTextContent('DataSource: mock-datasource');
23
- });
24
- });
package/src/index.tsx DELETED
@@ -1,334 +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
- import * as React from "react"
10
- import { cn, cva } from "@object-ui/components"
11
- import type { VariantProps } from "class-variance-authority"
12
-
13
- const Timeline = React.forwardRef<
14
- HTMLOListElement,
15
- React.HTMLAttributes<HTMLOListElement>
16
- >(({ className, ...props }, ref) => (
17
- <ol
18
- ref={ref}
19
- className={cn("relative border-l border-gray-200", className)}
20
- {...props}
21
- />
22
- ))
23
- Timeline.displayName = "Timeline"
24
-
25
- const timelineItemVariants = cva("ml-6", {
26
- variants: {
27
- density: {
28
- default: "mb-10",
29
- compact: "mb-3",
30
- comfortable: "mb-6",
31
- },
32
- },
33
- defaultVariants: { density: "default" },
34
- })
35
-
36
- const TimelineItem = React.forwardRef<
37
- HTMLLIElement,
38
- React.HTMLAttributes<HTMLLIElement> & VariantProps<typeof timelineItemVariants>
39
- >(({ className, density, ...props }, ref) => (
40
- <li
41
- ref={ref}
42
- className={cn(timelineItemVariants({ density }), className)}
43
- {...props}
44
- />
45
- ))
46
- TimelineItem.displayName = "TimelineItem"
47
-
48
- const timelineMarkerVariants = cva(
49
- "absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center",
50
- {
51
- variants: {
52
- variant: {
53
- default: "bg-blue-200 border-blue-400",
54
- success: "bg-emerald-200 border-emerald-500",
55
- warning: "bg-amber-200 border-amber-500",
56
- danger: "bg-red-200 border-red-500",
57
- info: "bg-purple-200 border-purple-500",
58
- todo: "bg-slate-200 border-slate-400",
59
- "in-progress": "bg-blue-200 border-blue-500",
60
- done: "bg-emerald-200 border-emerald-500",
61
- },
62
- },
63
- defaultVariants: { variant: "default" },
64
- }
65
- )
66
-
67
- type TimelineMarkerVariant = VariantProps<typeof timelineMarkerVariants>["variant"]
68
-
69
- const TimelineMarker = React.forwardRef<
70
- HTMLDivElement,
71
- React.HTMLAttributes<HTMLDivElement> & {
72
- variant?: TimelineMarkerVariant
73
- }
74
- >(({ className, variant = "default", ...props }, ref) => {
75
- return (
76
- <div
77
- ref={ref}
78
- className={cn(timelineMarkerVariants({ variant }), className)}
79
- {...props}
80
- />
81
- )
82
- })
83
- TimelineMarker.displayName = "TimelineMarker"
84
-
85
- const TimelineContent = React.forwardRef<
86
- HTMLDivElement,
87
- React.HTMLAttributes<HTMLDivElement>
88
- >(({ className, ...props }, ref) => (
89
- <div
90
- ref={ref}
91
- className={className}
92
- {...props}
93
- />
94
- ))
95
- TimelineContent.displayName = "TimelineContent"
96
-
97
- const TimelineTitle = React.forwardRef<
98
- HTMLHeadingElement,
99
- React.HTMLAttributes<HTMLHeadingElement>
100
- >(({ className, ...props }, ref) => (
101
- <h3
102
- ref={ref}
103
- className={cn("font-semibold text-lg mb-1", className)}
104
- {...props}
105
- />
106
- ))
107
- TimelineTitle.displayName = "TimelineTitle"
108
-
109
- const TimelineTime = React.forwardRef<
110
- HTMLTimeElement,
111
- React.TimeHTMLAttributes<HTMLTimeElement>
112
- >(({ className, ...props }, ref) => (
113
- <time
114
- ref={ref}
115
- className={cn("text-sm font-normal text-gray-500 mb-2 block", className)}
116
- {...props}
117
- />
118
- ))
119
- TimelineTime.displayName = "TimelineTime"
120
-
121
- const TimelineDescription = React.forwardRef<
122
- HTMLParagraphElement,
123
- React.HTMLAttributes<HTMLParagraphElement>
124
- >(({ className, ...props }, ref) => (
125
- <p
126
- ref={ref}
127
- className={cn("text-base text-gray-700", className)}
128
- {...props}
129
- />
130
- ))
131
- TimelineDescription.displayName = "TimelineDescription"
132
-
133
- // Horizontal Timeline Components
134
- const TimelineHorizontal = React.forwardRef<
135
- HTMLDivElement,
136
- React.HTMLAttributes<HTMLDivElement>
137
- >(({ className, ...props }, ref) => (
138
- <div
139
- ref={ref}
140
- className={cn("relative flex overflow-x-auto py-8", className)}
141
- {...props}
142
- />
143
- ))
144
- TimelineHorizontal.displayName = "TimelineHorizontal"
145
-
146
- const TimelineHorizontalItem = React.forwardRef<
147
- HTMLDivElement,
148
- React.HTMLAttributes<HTMLDivElement>
149
- >(({ className, ...props }, ref) => (
150
- <div
151
- ref={ref}
152
- className={cn("flex-shrink-0 w-64 relative", className)}
153
- {...props}
154
- />
155
- ))
156
- TimelineHorizontalItem.displayName = "TimelineHorizontalItem"
157
-
158
- // Gantt-style Timeline Components (Airtable-like)
159
- const TimelineGantt = React.forwardRef<
160
- HTMLDivElement,
161
- React.HTMLAttributes<HTMLDivElement>
162
- >(({ className, ...props }, ref) => (
163
- <div
164
- ref={ref}
165
- className={cn("relative w-full border rounded-lg overflow-hidden", className)}
166
- {...props}
167
- />
168
- ))
169
- TimelineGantt.displayName = "TimelineGantt"
170
-
171
- const TimelineGanttHeader = React.forwardRef<
172
- HTMLDivElement,
173
- React.HTMLAttributes<HTMLDivElement>
174
- >(({ className, ...props }, ref) => (
175
- <div
176
- ref={ref}
177
- className={cn("flex border-b bg-gray-50", className)}
178
- {...props}
179
- />
180
- ))
181
- TimelineGanttHeader.displayName = "TimelineGanttHeader"
182
-
183
- const TimelineGanttRowLabels = React.forwardRef<
184
- HTMLDivElement,
185
- React.HTMLAttributes<HTMLDivElement>
186
- >(({ className, ...props }, ref) => (
187
- <div
188
- ref={ref}
189
- className={cn("w-48 border-r bg-white", className)}
190
- {...props}
191
- />
192
- ))
193
- TimelineGanttRowLabels.displayName = "TimelineGanttRowLabels"
194
-
195
- const TimelineGanttGrid = React.forwardRef<
196
- HTMLDivElement,
197
- React.HTMLAttributes<HTMLDivElement>
198
- >(({ className, ...props }, ref) => (
199
- <div
200
- ref={ref}
201
- className={cn("flex-1 overflow-x-auto", className)}
202
- {...props}
203
- />
204
- ))
205
- TimelineGanttGrid.displayName = "TimelineGanttGrid"
206
-
207
- const TimelineGanttRow = React.forwardRef<
208
- HTMLDivElement,
209
- React.HTMLAttributes<HTMLDivElement>
210
- >(({ className, ...props }, ref) => (
211
- <div
212
- ref={ref}
213
- className={cn("flex items-center border-b min-h-12", className)}
214
- {...props}
215
- />
216
- ))
217
- TimelineGanttRow.displayName = "TimelineGanttRow"
218
-
219
- const TimelineGanttLabel = React.forwardRef<
220
- HTMLDivElement,
221
- React.HTMLAttributes<HTMLDivElement>
222
- >(({ className, ...props }, ref) => (
223
- <div
224
- ref={ref}
225
- className={cn("px-4 py-2 font-medium text-sm truncate", className)}
226
- {...props}
227
- />
228
- ))
229
- TimelineGanttLabel.displayName = "TimelineGanttLabel"
230
-
231
- const TimelineGanttBar = React.forwardRef<
232
- HTMLDivElement,
233
- React.HTMLAttributes<HTMLDivElement> & {
234
- start?: number
235
- width?: number
236
- variant?: "default" | "success" | "warning" | "danger" | "info"
237
- }
238
- >(({ className, start = 0, width = 100, variant = "default", ...props }, ref) => {
239
- const variantClasses = {
240
- default: "bg-blue-500 hover:bg-blue-600",
241
- success: "bg-green-500 hover:bg-green-600",
242
- warning: "bg-yellow-500 hover:bg-yellow-600",
243
- danger: "bg-red-500 hover:bg-red-600",
244
- info: "bg-purple-500 hover:bg-purple-600",
245
- }
246
-
247
- return (
248
- <div
249
- ref={ref}
250
- className={cn(
251
- "absolute h-8 rounded-md transition-colors cursor-pointer",
252
- variantClasses[variant],
253
- className
254
- )}
255
- style={{
256
- left: `${start}%`,
257
- width: `${width}%`,
258
- }}
259
- {...props}
260
- />
261
- )
262
- })
263
- TimelineGanttBar.displayName = "TimelineGanttBar"
264
-
265
- const TimelineGanttBarContent = React.forwardRef<
266
- HTMLDivElement,
267
- React.HTMLAttributes<HTMLDivElement>
268
- >(({ className, ...props }, ref) => (
269
- <div
270
- ref={ref}
271
- className={cn("px-2 py-1 text-white text-xs font-medium truncate", className)}
272
- {...props}
273
- />
274
- ))
275
- TimelineGanttBarContent.displayName = "TimelineGanttBarContent"
276
-
277
- export {
278
- Timeline,
279
- TimelineItem,
280
- timelineItemVariants,
281
- TimelineMarker,
282
- timelineMarkerVariants,
283
- TimelineContent,
284
- TimelineTitle,
285
- TimelineTime,
286
- TimelineDescription,
287
- TimelineHorizontal,
288
- TimelineHorizontalItem,
289
- TimelineGantt,
290
- TimelineGanttHeader,
291
- TimelineGanttRowLabels,
292
- TimelineGanttGrid,
293
- TimelineGanttRow,
294
- TimelineGanttLabel,
295
- TimelineGanttBar,
296
- TimelineGanttBarContent,
297
- }
298
-
299
- // Export renderer to register the component with ObjectUI
300
- export * from './renderer';
301
-
302
- // Export ObjectTimeline
303
- export { ObjectTimeline } from './ObjectTimeline';
304
- export type { ObjectTimelineProps } from './ObjectTimeline';
305
-
306
- import { ComponentRegistry } from '@object-ui/core';
307
- import { ObjectTimeline } from './ObjectTimeline';
308
- import { useSchemaContext } from '@object-ui/react';
309
-
310
- // Register object-timeline component
311
- export const ObjectTimelineRenderer: React.FC<any> = ({ schema, ...props }) => {
312
- const { dataSource } = useSchemaContext() || {};
313
- return <ObjectTimeline schema={schema} dataSource={dataSource} {...props} />;
314
- };
315
-
316
- ComponentRegistry.register('object-timeline', ObjectTimelineRenderer, {
317
- namespace: 'plugin-timeline',
318
- label: 'Object Timeline',
319
- category: 'view',
320
- inputs: [
321
- { name: 'objectName', type: 'string', label: 'Object Name', required: true },
322
- { name: 'variant', type: 'enum', enum: ['vertical', 'horizontal', 'gantt'], defaultValue: 'vertical' },
323
- ]
324
- });
325
-
326
- ComponentRegistry.register('timeline', ObjectTimelineRenderer, {
327
- namespace: 'view',
328
- label: 'Timeline View',
329
- category: 'view',
330
- inputs: [
331
- { name: 'objectName', type: 'string', label: 'Object Name', required: true },
332
- { name: 'variant', type: 'enum', enum: ['vertical', 'horizontal', 'gantt'], defaultValue: 'vertical' },
333
- ]
334
- });