@object-ui/plugin-timeline 3.0.2 → 3.1.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 +5 -5
- package/CHANGELOG.md +10 -0
- package/dist/index.js +1252 -1214
- package/dist/index.umd.cjs +21 -21
- package/dist/src/ObjectTimeline.d.ts +15 -1
- package/dist/src/ObjectTimeline.d.ts.map +1 -1
- package/dist/src/index.d.ts +13 -3
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/ObjectTimeline.test.tsx +57 -1
- package/src/ObjectTimeline.tsx +71 -22
- package/src/__tests__/ObjectTimeline.spec-config.test.tsx +232 -0
- package/src/__tests__/timeline-variants.test.tsx +150 -0
- package/src/index.tsx +42 -19
package/src/index.tsx
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as React from "react"
|
|
10
|
-
import { cn } from "@object-ui/components"
|
|
10
|
+
import { cn, cva } from "@object-ui/components"
|
|
11
|
+
import type { VariantProps } from "class-variance-authority"
|
|
11
12
|
|
|
12
13
|
const Timeline = React.forwardRef<
|
|
13
14
|
HTMLOListElement,
|
|
@@ -21,40 +22,60 @@ const Timeline = React.forwardRef<
|
|
|
21
22
|
))
|
|
22
23
|
Timeline.displayName = "Timeline"
|
|
23
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
|
+
|
|
24
36
|
const TimelineItem = React.forwardRef<
|
|
25
37
|
HTMLLIElement,
|
|
26
|
-
React.HTMLAttributes<HTMLLIElement>
|
|
27
|
-
>(({ className, ...props }, ref) => (
|
|
38
|
+
React.HTMLAttributes<HTMLLIElement> & VariantProps<typeof timelineItemVariants>
|
|
39
|
+
>(({ className, density, ...props }, ref) => (
|
|
28
40
|
<li
|
|
29
41
|
ref={ref}
|
|
30
|
-
className={cn(
|
|
42
|
+
className={cn(timelineItemVariants({ density }), className)}
|
|
31
43
|
{...props}
|
|
32
44
|
/>
|
|
33
45
|
))
|
|
34
46
|
TimelineItem.displayName = "TimelineItem"
|
|
35
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
|
+
|
|
36
69
|
const TimelineMarker = React.forwardRef<
|
|
37
70
|
HTMLDivElement,
|
|
38
71
|
React.HTMLAttributes<HTMLDivElement> & {
|
|
39
|
-
variant?:
|
|
72
|
+
variant?: TimelineMarkerVariant
|
|
40
73
|
}
|
|
41
74
|
>(({ className, variant = "default", ...props }, ref) => {
|
|
42
|
-
const variantClasses = {
|
|
43
|
-
default: "bg-gray-200 border-gray-300",
|
|
44
|
-
success: "bg-green-200 border-green-500",
|
|
45
|
-
warning: "bg-yellow-200 border-yellow-500",
|
|
46
|
-
danger: "bg-red-200 border-red-500",
|
|
47
|
-
info: "bg-blue-200 border-blue-500",
|
|
48
|
-
}
|
|
49
|
-
|
|
50
75
|
return (
|
|
51
76
|
<div
|
|
52
77
|
ref={ref}
|
|
53
|
-
className={cn(
|
|
54
|
-
"absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center",
|
|
55
|
-
variantClasses[variant],
|
|
56
|
-
className
|
|
57
|
-
)}
|
|
78
|
+
className={cn(timelineMarkerVariants({ variant }), className)}
|
|
58
79
|
{...props}
|
|
59
80
|
/>
|
|
60
81
|
)
|
|
@@ -256,7 +277,9 @@ TimelineGanttBarContent.displayName = "TimelineGanttBarContent"
|
|
|
256
277
|
export {
|
|
257
278
|
Timeline,
|
|
258
279
|
TimelineItem,
|
|
280
|
+
timelineItemVariants,
|
|
259
281
|
TimelineMarker,
|
|
282
|
+
timelineMarkerVariants,
|
|
260
283
|
TimelineContent,
|
|
261
284
|
TimelineTitle,
|
|
262
285
|
TimelineTime,
|
|
@@ -286,7 +309,7 @@ import { useSchemaContext } from '@object-ui/react';
|
|
|
286
309
|
|
|
287
310
|
// Register object-timeline component
|
|
288
311
|
export const ObjectTimelineRenderer: React.FC<any> = ({ schema, ...props }) => {
|
|
289
|
-
const { dataSource } = useSchemaContext();
|
|
312
|
+
const { dataSource } = useSchemaContext() || {};
|
|
290
313
|
return <ObjectTimeline schema={schema} dataSource={dataSource} {...props} />;
|
|
291
314
|
};
|
|
292
315
|
|