@carlonicora/nextjs-jsonapi 1.17.0 → 1.18.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/README.md +1 -1
- package/dist/{BlockNoteEditor-4Z6TZBJE.mjs → BlockNoteEditor-6TWTNHNZ.mjs} +2 -2
- package/dist/{BlockNoteEditor-34T5CY27.js → BlockNoteEditor-C3WWGGT6.js} +6 -6
- package/dist/{BlockNoteEditor-34T5CY27.js.map → BlockNoteEditor-C3WWGGT6.js.map} +1 -1
- package/dist/{chunk-D7H7SRWB.js → chunk-6U6QCSJK.js} +4054 -2590
- package/dist/chunk-6U6QCSJK.js.map +1 -0
- package/dist/{chunk-SXPXC2TY.mjs → chunk-UZDAPWJG.mjs} +5629 -4165
- package/dist/chunk-UZDAPWJG.mjs.map +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/components/index.d.mts +298 -385
- package/dist/components/index.d.ts +298 -385
- package/dist/components/index.js +26 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +35 -11
- package/dist/contexts/index.js +2 -2
- package/dist/contexts/index.mjs +1 -1
- package/dist/scripts/generate-web-module/templates/components/editor.template.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/templates/components/editor.template.js +20 -6
- package/dist/scripts/generate-web-module/templates/components/editor.template.js.map +1 -1
- package/dist/scripts/generate-web-module/templates/components/selector.template.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/templates/components/selector.template.js +45 -48
- package/dist/scripts/generate-web-module/templates/components/selector.template.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/index.mjs.map +1 -1
- package/package.json +6 -25
- package/scripts/generate-web-module/templates/components/editor.template.ts +20 -6
- package/scripts/generate-web-module/templates/components/selector.template.ts +45 -48
- package/src/components/forms/CommonDeleter.tsx +2 -2
- package/src/components/forms/CommonEditorTrigger.tsx +3 -3
- package/src/components/forms/DatePickerPopover.tsx +3 -1
- package/src/components/forms/DateRangeSelector.tsx +1 -1
- package/src/components/forms/FormCheckbox.tsx +1 -1
- package/src/components/forms/FormDate.tsx +3 -1
- package/src/components/forms/FormDateTime.tsx +5 -3
- package/src/components/forms/FormSelect.tsx +1 -1
- package/src/components/forms/FormSlider.tsx +4 -1
- package/src/components/forms/__tests__/FormCheckbox.test.tsx +5 -1
- package/src/components/forms/__tests__/FormDate.test.tsx +5 -1
- package/src/components/forms/__tests__/FormSelect.test.tsx +5 -1
- package/src/components/navigations/RecentPagesNavigator.tsx +2 -2
- package/src/components/tables/ContentListTable.tsx +3 -3
- package/src/features/billing/stripe-customer/components/details/PaymentMethodCard.tsx +2 -2
- package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +2 -2
- package/src/features/company/components/forms/CompanyDeleter.tsx +1 -1
- package/src/features/content/components/lists/ContentsList.tsx +1 -1
- package/src/features/notification/components/lists/NotificationsList.tsx +1 -1
- package/src/features/notification/components/modals/NotificationModal.tsx +2 -2
- package/src/features/role/components/forms/FormRoles.tsx +1 -1
- package/src/features/user/components/forms/UserEditor.tsx +2 -2
- package/src/features/user/components/forms/UserReactivator.tsx +1 -1
- package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -2
- package/src/features/user/components/widgets/UserAvatar.tsx +37 -31
- package/src/features/user/components/widgets/UserSearchPopover.tsx +1 -1
- package/src/hooks/use-mobile.ts +1 -0
- package/src/lib/utils.ts +2 -0
- package/src/shadcnui/custom/multi-select.tsx +10 -21
- package/src/shadcnui/ui/accordion.tsx +64 -42
- package/src/shadcnui/ui/alert-dialog.tsx +142 -108
- package/src/shadcnui/ui/alert.tsx +64 -35
- package/src/shadcnui/ui/avatar.tsx +106 -50
- package/src/shadcnui/ui/badge.tsx +34 -26
- package/src/shadcnui/ui/breadcrumb.tsx +103 -92
- package/src/shadcnui/ui/button.tsx +30 -30
- package/src/shadcnui/ui/calendar.tsx +192 -50
- package/src/shadcnui/ui/card.tsx +94 -43
- package/src/shadcnui/ui/carousel.tsx +220 -201
- package/src/shadcnui/ui/chart.tsx +244 -190
- package/src/shadcnui/ui/checkbox.tsx +25 -25
- package/src/shadcnui/ui/collapsible.tsx +10 -4
- package/src/shadcnui/ui/combobox.tsx +292 -0
- package/src/shadcnui/ui/command.tsx +158 -126
- package/src/shadcnui/ui/context-menu.tsx +242 -164
- package/src/shadcnui/ui/dialog.tsx +125 -70
- package/src/shadcnui/ui/drawer.tsx +106 -70
- package/src/shadcnui/ui/dropdown-menu.tsx +231 -182
- package/src/shadcnui/ui/field.tsx +227 -0
- package/src/shadcnui/ui/hover-card.tsx +45 -23
- package/src/shadcnui/ui/input-group.tsx +149 -0
- package/src/shadcnui/ui/input-otp.tsx +19 -9
- package/src/shadcnui/ui/input.tsx +4 -5
- package/src/shadcnui/ui/label.tsx +16 -22
- package/src/shadcnui/ui/navigation-menu.tsx +44 -49
- package/src/shadcnui/ui/popover.tsx +81 -24
- package/src/shadcnui/ui/progress.tsx +77 -22
- package/src/shadcnui/ui/radio-group.tsx +30 -28
- package/src/shadcnui/ui/resizable.tsx +23 -17
- package/src/shadcnui/ui/scroll-area.tsx +50 -35
- package/src/shadcnui/ui/select.tsx +163 -135
- package/src/shadcnui/ui/separator.tsx +5 -8
- package/src/shadcnui/ui/sheet.tsx +40 -50
- package/src/shadcnui/ui/sidebar.tsx +317 -271
- package/src/shadcnui/ui/skeleton.tsx +2 -2
- package/src/shadcnui/ui/slider.tsx +60 -21
- package/src/shadcnui/ui/sonner.tsx +25 -1
- package/src/shadcnui/ui/switch.tsx +31 -24
- package/src/shadcnui/ui/table.tsx +84 -103
- package/src/shadcnui/ui/tabs.tsx +82 -55
- package/src/shadcnui/ui/textarea.tsx +15 -21
- package/src/shadcnui/ui/toggle.tsx +26 -21
- package/src/shadcnui/ui/tooltip.tsx +33 -24
- package/src/testing/factories/createMockApiData.ts +2 -2
- package/src/testing/factories/createMockResponse.ts +3 -8
- package/src/testing/factories/createMockService.ts +1 -4
- package/src/testing/index.ts +4 -18
- package/src/testing/matchers/jsonApiMatchers.ts +14 -16
- package/dist/chunk-D7H7SRWB.js.map +0 -1
- package/dist/chunk-SXPXC2TY.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-4Z6TZBJE.mjs.map → BlockNoteEditor-6TWTNHNZ.mjs.map} +0 -0
|
@@ -1,38 +1,48 @@
|
|
|
1
|
-
"use client"
|
|
1
|
+
"use client"
|
|
2
2
|
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as RechartsPrimitive from "recharts"
|
|
5
|
-
import type { LegendPayload } from "recharts/types/component/DefaultLegendContent";
|
|
6
|
-
import { NameType, Payload, ValueType } from "recharts/types/component/DefaultTooltipContent";
|
|
7
|
-
import type { Props as LegendProps } from "recharts/types/component/Legend";
|
|
8
|
-
import { TooltipContentProps } from "recharts/types/component/Tooltip";
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as RechartsPrimitive from "recharts"
|
|
9
5
|
|
|
10
|
-
import { cn } from "
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
11
7
|
|
|
12
8
|
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
13
|
-
const THEMES = { light: "", dark: ".dark" } as const
|
|
9
|
+
const THEMES = { light: "", dark: ".dark" } as const
|
|
10
|
+
|
|
11
|
+
// Custom type for tooltip/legend payload items
|
|
12
|
+
type PayloadItem = {
|
|
13
|
+
dataKey?: string | number
|
|
14
|
+
name?: string
|
|
15
|
+
value?: string | number
|
|
16
|
+
type?: string
|
|
17
|
+
color?: string
|
|
18
|
+
payload?: Record<string, unknown> & { fill?: string }
|
|
19
|
+
fill?: string
|
|
20
|
+
}
|
|
14
21
|
|
|
15
22
|
export type ChartConfig = {
|
|
16
23
|
[k in string]: {
|
|
17
|
-
label?: React.ReactNode
|
|
18
|
-
icon?: React.ComponentType
|
|
19
|
-
} & (
|
|
20
|
-
}
|
|
24
|
+
label?: React.ReactNode
|
|
25
|
+
icon?: React.ComponentType
|
|
26
|
+
} & (
|
|
27
|
+
| { color?: string; theme?: never }
|
|
28
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
29
|
+
)
|
|
30
|
+
}
|
|
21
31
|
|
|
22
32
|
type ChartContextProps = {
|
|
23
|
-
config: ChartConfig
|
|
24
|
-
}
|
|
33
|
+
config: ChartConfig
|
|
34
|
+
}
|
|
25
35
|
|
|
26
|
-
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
36
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
27
37
|
|
|
28
38
|
function useChart() {
|
|
29
|
-
const context = React.useContext(ChartContext)
|
|
39
|
+
const context = React.useContext(ChartContext)
|
|
30
40
|
|
|
31
41
|
if (!context) {
|
|
32
|
-
throw new Error("useChart must be used within a <ChartContainer />")
|
|
42
|
+
throw new Error("useChart must be used within a <ChartContainer />")
|
|
33
43
|
}
|
|
34
44
|
|
|
35
|
-
return context
|
|
45
|
+
return context
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
function ChartContainer({
|
|
@@ -42,11 +52,13 @@ function ChartContainer({
|
|
|
42
52
|
config,
|
|
43
53
|
...props
|
|
44
54
|
}: React.ComponentProps<"div"> & {
|
|
45
|
-
config: ChartConfig
|
|
46
|
-
children: React.ComponentProps<
|
|
55
|
+
config: ChartConfig
|
|
56
|
+
children: React.ComponentProps<
|
|
57
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
58
|
+
>["children"]
|
|
47
59
|
}) {
|
|
48
|
-
const uniqueId = React.useId()
|
|
49
|
-
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}
|
|
60
|
+
const uniqueId = React.useId()
|
|
61
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
|
|
50
62
|
|
|
51
63
|
return (
|
|
52
64
|
<ChartContext.Provider value={{ config }}>
|
|
@@ -55,22 +67,26 @@ function ChartContainer({
|
|
|
55
67
|
data-chart={chartId}
|
|
56
68
|
className={cn(
|
|
57
69
|
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
58
|
-
className
|
|
70
|
+
className
|
|
59
71
|
)}
|
|
60
72
|
{...props}
|
|
61
73
|
>
|
|
62
74
|
<ChartStyle id={chartId} config={config} />
|
|
63
|
-
<RechartsPrimitive.ResponsiveContainer>
|
|
75
|
+
<RechartsPrimitive.ResponsiveContainer>
|
|
76
|
+
{children}
|
|
77
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
64
78
|
</div>
|
|
65
79
|
</ChartContext.Provider>
|
|
66
|
-
)
|
|
80
|
+
)
|
|
67
81
|
}
|
|
68
82
|
|
|
69
83
|
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
70
|
-
const colorConfig = Object.entries(config).filter(
|
|
84
|
+
const colorConfig = Object.entries(config).filter(
|
|
85
|
+
([, config]) => config.theme || config.color
|
|
86
|
+
)
|
|
71
87
|
|
|
72
88
|
if (!colorConfig.length) {
|
|
73
|
-
return null
|
|
89
|
+
return null
|
|
74
90
|
}
|
|
75
91
|
|
|
76
92
|
return (
|
|
@@ -79,175 +95,179 @@ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
|
79
95
|
__html: Object.entries(THEMES)
|
|
80
96
|
.map(
|
|
81
97
|
([theme, prefix]) => `
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
${prefix} [data-chart=${id}] {
|
|
99
|
+
${colorConfig
|
|
100
|
+
.map(([key, itemConfig]) => {
|
|
101
|
+
const color =
|
|
102
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
|
103
|
+
itemConfig.color
|
|
104
|
+
return color ? ` --color-${key}: ${color};` : null
|
|
105
|
+
})
|
|
106
|
+
.join("\n")}
|
|
107
|
+
}
|
|
108
|
+
`
|
|
91
109
|
)
|
|
92
110
|
.join("\n"),
|
|
93
111
|
}}
|
|
94
112
|
/>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
99
|
-
|
|
100
|
-
type CustomTooltipProps = TooltipContentProps<ValueType, NameType> & {
|
|
101
|
-
className?: string;
|
|
102
|
-
hideLabel?: boolean;
|
|
103
|
-
hideIndicator?: boolean;
|
|
104
|
-
indicator?: "line" | "dot" | "dashed";
|
|
105
|
-
nameKey?: string;
|
|
106
|
-
labelKey?: string;
|
|
107
|
-
labelFormatter?: (
|
|
108
|
-
label: TooltipContentProps<number, string>["label"],
|
|
109
|
-
payload: TooltipContentProps<number, string>["payload"],
|
|
110
|
-
) => React.ReactNode;
|
|
111
|
-
formatter?: (
|
|
112
|
-
value: number | string,
|
|
113
|
-
name: string,
|
|
114
|
-
item: Payload<number | string, string>,
|
|
115
|
-
index: number,
|
|
116
|
-
payload: ReadonlyArray<Payload<number | string, string>>,
|
|
117
|
-
) => React.ReactNode;
|
|
118
|
-
labelClassName?: string;
|
|
119
|
-
color?: string;
|
|
120
|
-
};
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
121
117
|
|
|
122
118
|
function ChartTooltipContent({
|
|
123
119
|
active,
|
|
124
120
|
payload,
|
|
125
|
-
label,
|
|
126
121
|
className,
|
|
127
122
|
indicator = "dot",
|
|
128
123
|
hideLabel = false,
|
|
129
124
|
hideIndicator = false,
|
|
125
|
+
label,
|
|
130
126
|
labelFormatter,
|
|
131
|
-
formatter,
|
|
132
127
|
labelClassName,
|
|
128
|
+
formatter,
|
|
133
129
|
color,
|
|
134
130
|
nameKey,
|
|
135
131
|
labelKey,
|
|
136
|
-
}:
|
|
137
|
-
|
|
132
|
+
}: React.ComponentProps<"div"> & {
|
|
133
|
+
active?: boolean
|
|
134
|
+
payload?: PayloadItem[]
|
|
135
|
+
label?: string | number
|
|
136
|
+
labelFormatter?: (label: unknown, payload: PayloadItem[]) => React.ReactNode
|
|
137
|
+
formatter?: (value: unknown, name: string, item: PayloadItem, index: number, payload: unknown) => React.ReactNode
|
|
138
|
+
hideLabel?: boolean
|
|
139
|
+
hideIndicator?: boolean
|
|
140
|
+
indicator?: "line" | "dot" | "dashed"
|
|
141
|
+
nameKey?: string
|
|
142
|
+
labelKey?: string
|
|
143
|
+
labelClassName?: string
|
|
144
|
+
color?: string
|
|
145
|
+
}) {
|
|
146
|
+
const { config } = useChart()
|
|
138
147
|
|
|
139
148
|
const tooltipLabel = React.useMemo(() => {
|
|
140
149
|
if (hideLabel || !payload?.length) {
|
|
141
|
-
return null
|
|
150
|
+
return null
|
|
142
151
|
}
|
|
143
152
|
|
|
144
|
-
const [item] = payload
|
|
145
|
-
const key = `${labelKey || item?.dataKey || item?.name || "value"}
|
|
146
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
147
|
-
const value =
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
: itemConfig?.label;
|
|
152
|
-
|
|
153
|
-
return typeof v === "string" || typeof v === "number" ? v : undefined;
|
|
154
|
-
})();
|
|
153
|
+
const [item] = payload
|
|
154
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`
|
|
155
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
156
|
+
const value =
|
|
157
|
+
!labelKey && typeof label === "string"
|
|
158
|
+
? config[label as keyof typeof config]?.label || label
|
|
159
|
+
: itemConfig?.label
|
|
155
160
|
|
|
156
161
|
if (labelFormatter) {
|
|
157
|
-
return
|
|
162
|
+
return (
|
|
163
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
164
|
+
{labelFormatter(value, payload)}
|
|
165
|
+
</div>
|
|
166
|
+
)
|
|
158
167
|
}
|
|
159
168
|
|
|
160
169
|
if (!value) {
|
|
161
|
-
return null
|
|
170
|
+
return null
|
|
162
171
|
}
|
|
163
172
|
|
|
164
|
-
return <div className={cn("font-medium", labelClassName)}>{value}</div
|
|
165
|
-
}, [
|
|
173
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>
|
|
174
|
+
}, [
|
|
175
|
+
label,
|
|
176
|
+
labelFormatter,
|
|
177
|
+
payload,
|
|
178
|
+
hideLabel,
|
|
179
|
+
labelClassName,
|
|
180
|
+
config,
|
|
181
|
+
labelKey,
|
|
182
|
+
])
|
|
166
183
|
|
|
167
184
|
if (!active || !payload?.length) {
|
|
168
|
-
return null
|
|
185
|
+
return null
|
|
169
186
|
}
|
|
170
187
|
|
|
171
|
-
const nestLabel = payload.length === 1 && indicator !== "dot"
|
|
188
|
+
const nestLabel = payload.length === 1 && indicator !== "dot"
|
|
172
189
|
|
|
173
190
|
return (
|
|
174
191
|
<div
|
|
175
192
|
className={cn(
|
|
176
|
-
"border-border/50 bg-background
|
|
177
|
-
className
|
|
193
|
+
"border-border/50 bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs/relaxed shadow-xl grid min-w-[8rem] items-start",
|
|
194
|
+
className
|
|
178
195
|
)}
|
|
179
196
|
>
|
|
180
197
|
{!nestLabel ? tooltipLabel : null}
|
|
181
198
|
<div className="grid gap-1.5">
|
|
182
|
-
{payload
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
<span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
|
|
225
|
-
</div>
|
|
226
|
-
{item.value && (
|
|
227
|
-
<span className="text-foreground font-mono font-medium tabular-nums">
|
|
228
|
-
{item.value.toLocaleString()}
|
|
229
|
-
</span>
|
|
199
|
+
{payload
|
|
200
|
+
.filter((item) => item.type !== "none")
|
|
201
|
+
.map((item, index) => {
|
|
202
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`
|
|
203
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
204
|
+
const indicatorColor = color || item.payload?.fill || item.color
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<div
|
|
208
|
+
key={item.dataKey}
|
|
209
|
+
className={cn(
|
|
210
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
211
|
+
indicator === "dot" && "items-center"
|
|
212
|
+
)}
|
|
213
|
+
>
|
|
214
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
215
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
216
|
+
) : (
|
|
217
|
+
<>
|
|
218
|
+
{itemConfig?.icon ? (
|
|
219
|
+
<itemConfig.icon />
|
|
220
|
+
) : (
|
|
221
|
+
!hideIndicator && (
|
|
222
|
+
<div
|
|
223
|
+
className={cn(
|
|
224
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
225
|
+
{
|
|
226
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
227
|
+
"w-1": indicator === "line",
|
|
228
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
229
|
+
indicator === "dashed",
|
|
230
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
231
|
+
}
|
|
232
|
+
)}
|
|
233
|
+
style={
|
|
234
|
+
{
|
|
235
|
+
"--color-bg": indicatorColor,
|
|
236
|
+
"--color-border": indicatorColor,
|
|
237
|
+
} as React.CSSProperties
|
|
238
|
+
}
|
|
239
|
+
/>
|
|
240
|
+
)
|
|
230
241
|
)}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
242
|
+
<div
|
|
243
|
+
className={cn(
|
|
244
|
+
"flex flex-1 justify-between leading-none",
|
|
245
|
+
nestLabel ? "items-end" : "items-center"
|
|
246
|
+
)}
|
|
247
|
+
>
|
|
248
|
+
<div className="grid gap-1.5">
|
|
249
|
+
{nestLabel ? tooltipLabel : null}
|
|
250
|
+
<span className="text-muted-foreground">
|
|
251
|
+
{itemConfig?.label || item.name}
|
|
252
|
+
</span>
|
|
253
|
+
</div>
|
|
254
|
+
{item.value && (
|
|
255
|
+
<span className="text-foreground font-mono font-medium tabular-nums">
|
|
256
|
+
{item.value.toLocaleString()}
|
|
257
|
+
</span>
|
|
258
|
+
)}
|
|
259
|
+
</div>
|
|
260
|
+
</>
|
|
261
|
+
)}
|
|
262
|
+
</div>
|
|
263
|
+
)
|
|
264
|
+
})}
|
|
237
265
|
</div>
|
|
238
266
|
</div>
|
|
239
|
-
)
|
|
267
|
+
)
|
|
240
268
|
}
|
|
241
269
|
|
|
242
|
-
const ChartLegend = RechartsPrimitive.Legend
|
|
243
|
-
|
|
244
|
-
type ChartLegendContentProps = {
|
|
245
|
-
className?: string;
|
|
246
|
-
hideIcon?: boolean;
|
|
247
|
-
verticalAlign?: LegendProps["verticalAlign"];
|
|
248
|
-
payload?: LegendPayload[];
|
|
249
|
-
nameKey?: string;
|
|
250
|
-
};
|
|
270
|
+
const ChartLegend = RechartsPrimitive.Legend
|
|
251
271
|
|
|
252
272
|
function ChartLegendContent({
|
|
253
273
|
className,
|
|
@@ -255,66 +275,100 @@ function ChartLegendContent({
|
|
|
255
275
|
payload,
|
|
256
276
|
verticalAlign = "bottom",
|
|
257
277
|
nameKey,
|
|
258
|
-
}:
|
|
259
|
-
|
|
278
|
+
}: React.ComponentProps<"div"> & {
|
|
279
|
+
payload?: PayloadItem[]
|
|
280
|
+
verticalAlign?: "top" | "bottom" | "middle"
|
|
281
|
+
hideIcon?: boolean
|
|
282
|
+
nameKey?: string
|
|
283
|
+
}) {
|
|
284
|
+
const { config } = useChart()
|
|
260
285
|
|
|
261
286
|
if (!payload?.length) {
|
|
262
|
-
return null
|
|
287
|
+
return null
|
|
263
288
|
}
|
|
264
289
|
|
|
265
290
|
return (
|
|
266
|
-
<div
|
|
267
|
-
{
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
291
|
+
<div
|
|
292
|
+
className={cn(
|
|
293
|
+
"flex items-center justify-center gap-4",
|
|
294
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
295
|
+
className
|
|
296
|
+
)}
|
|
297
|
+
>
|
|
298
|
+
{payload
|
|
299
|
+
.filter((item) => item.type !== "none")
|
|
300
|
+
.map((item) => {
|
|
301
|
+
const key = `${nameKey || item.dataKey || "value"}`
|
|
302
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<div
|
|
306
|
+
key={item.value}
|
|
307
|
+
className={cn(
|
|
308
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
|
|
309
|
+
)}
|
|
310
|
+
>
|
|
311
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
312
|
+
<itemConfig.icon />
|
|
313
|
+
) : (
|
|
314
|
+
<div
|
|
315
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
316
|
+
style={{
|
|
317
|
+
backgroundColor: item.color,
|
|
318
|
+
}}
|
|
319
|
+
/>
|
|
320
|
+
)}
|
|
321
|
+
{itemConfig?.label}
|
|
322
|
+
</div>
|
|
323
|
+
)
|
|
324
|
+
})}
|
|
290
325
|
</div>
|
|
291
|
-
)
|
|
326
|
+
)
|
|
292
327
|
}
|
|
293
328
|
|
|
294
|
-
|
|
295
|
-
|
|
329
|
+
function getPayloadConfigFromPayload(
|
|
330
|
+
config: ChartConfig,
|
|
331
|
+
payload: unknown,
|
|
332
|
+
key: string
|
|
333
|
+
) {
|
|
296
334
|
if (typeof payload !== "object" || payload === null) {
|
|
297
|
-
return undefined
|
|
335
|
+
return undefined
|
|
298
336
|
}
|
|
299
337
|
|
|
300
338
|
const payloadPayload =
|
|
301
|
-
"payload" in payload &&
|
|
339
|
+
"payload" in payload &&
|
|
340
|
+
typeof payload.payload === "object" &&
|
|
341
|
+
payload.payload !== null
|
|
302
342
|
? payload.payload
|
|
303
|
-
: undefined
|
|
343
|
+
: undefined
|
|
304
344
|
|
|
305
|
-
let configLabelKey: string = key
|
|
345
|
+
let configLabelKey: string = key
|
|
306
346
|
|
|
307
|
-
if (
|
|
308
|
-
|
|
347
|
+
if (
|
|
348
|
+
key in payload &&
|
|
349
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
350
|
+
) {
|
|
351
|
+
configLabelKey = payload[key as keyof typeof payload] as string
|
|
309
352
|
} else if (
|
|
310
353
|
payloadPayload &&
|
|
311
354
|
key in payloadPayload &&
|
|
312
355
|
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
313
356
|
) {
|
|
314
|
-
configLabelKey = payloadPayload[
|
|
357
|
+
configLabelKey = payloadPayload[
|
|
358
|
+
key as keyof typeof payloadPayload
|
|
359
|
+
] as string
|
|
315
360
|
}
|
|
316
361
|
|
|
317
|
-
return configLabelKey in config
|
|
362
|
+
return configLabelKey in config
|
|
363
|
+
? config[configLabelKey]
|
|
364
|
+
: config[key as keyof typeof config]
|
|
318
365
|
}
|
|
319
366
|
|
|
320
|
-
export {
|
|
367
|
+
export {
|
|
368
|
+
ChartContainer,
|
|
369
|
+
ChartTooltip,
|
|
370
|
+
ChartTooltipContent,
|
|
371
|
+
ChartLegend,
|
|
372
|
+
ChartLegendContent,
|
|
373
|
+
ChartStyle,
|
|
374
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use client"
|
|
1
|
+
"use client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
5
|
-
import { CheckIcon } from "@radix-ui/react-icons";
|
|
6
|
-
import * as React from "react";
|
|
3
|
+
import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox"
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<CheckboxPrimitive.Indicator
|
|
21
|
-
className={cn("flex items-center justify-center text-current")}
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
import { CheckIcon } from "lucide-react"
|
|
7
|
+
|
|
8
|
+
function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
|
|
9
|
+
return (
|
|
10
|
+
<CheckboxPrimitive.Root
|
|
11
|
+
data-slot="checkbox"
|
|
12
|
+
className={cn(
|
|
13
|
+
"border-input dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 flex size-4 items-center justify-center rounded-[4px] border transition-shadow group-has-disabled/field:opacity-50 focus-visible:ring-[2px] aria-invalid:ring-[2px] peer relative shrink-0 outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
14
|
+
className
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
22
17
|
>
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
<CheckboxPrimitive.Indicator
|
|
19
|
+
data-slot="checkbox-indicator"
|
|
20
|
+
className="[&>svg]:size-3.5 grid place-content-center text-current transition-none"
|
|
21
|
+
>
|
|
22
|
+
<CheckIcon
|
|
23
|
+
/>
|
|
24
|
+
</CheckboxPrimitive.Indicator>
|
|
25
|
+
</CheckboxPrimitive.Root>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
28
|
|
|
29
|
-
export { Checkbox }
|
|
29
|
+
export { Checkbox }
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {
|
|
6
|
+
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
|
|
7
|
+
}
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {
|
|
10
|
+
return <CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />;
|
|
11
|
+
}
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
function CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) {
|
|
14
|
+
return <CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />;
|
|
15
|
+
}
|
|
10
16
|
|
|
11
17
|
export { Collapsible, CollapsibleContent, CollapsibleTrigger };
|