@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.
Files changed (109) hide show
  1. package/README.md +1 -1
  2. package/dist/{BlockNoteEditor-4Z6TZBJE.mjs → BlockNoteEditor-6TWTNHNZ.mjs} +2 -2
  3. package/dist/{BlockNoteEditor-34T5CY27.js → BlockNoteEditor-C3WWGGT6.js} +6 -6
  4. package/dist/{BlockNoteEditor-34T5CY27.js.map → BlockNoteEditor-C3WWGGT6.js.map} +1 -1
  5. package/dist/{chunk-D7H7SRWB.js → chunk-6U6QCSJK.js} +4054 -2590
  6. package/dist/chunk-6U6QCSJK.js.map +1 -0
  7. package/dist/{chunk-SXPXC2TY.mjs → chunk-UZDAPWJG.mjs} +5629 -4165
  8. package/dist/chunk-UZDAPWJG.mjs.map +1 -0
  9. package/dist/client/index.js +2 -2
  10. package/dist/client/index.mjs +1 -1
  11. package/dist/components/index.d.mts +298 -385
  12. package/dist/components/index.d.ts +298 -385
  13. package/dist/components/index.js +26 -2
  14. package/dist/components/index.js.map +1 -1
  15. package/dist/components/index.mjs +35 -11
  16. package/dist/contexts/index.js +2 -2
  17. package/dist/contexts/index.mjs +1 -1
  18. package/dist/scripts/generate-web-module/templates/components/editor.template.d.ts.map +1 -1
  19. package/dist/scripts/generate-web-module/templates/components/editor.template.js +20 -6
  20. package/dist/scripts/generate-web-module/templates/components/editor.template.js.map +1 -1
  21. package/dist/scripts/generate-web-module/templates/components/selector.template.d.ts.map +1 -1
  22. package/dist/scripts/generate-web-module/templates/components/selector.template.js +45 -48
  23. package/dist/scripts/generate-web-module/templates/components/selector.template.js.map +1 -1
  24. package/dist/testing/index.js.map +1 -1
  25. package/dist/testing/index.mjs.map +1 -1
  26. package/package.json +6 -25
  27. package/scripts/generate-web-module/templates/components/editor.template.ts +20 -6
  28. package/scripts/generate-web-module/templates/components/selector.template.ts +45 -48
  29. package/src/components/forms/CommonDeleter.tsx +2 -2
  30. package/src/components/forms/CommonEditorTrigger.tsx +3 -3
  31. package/src/components/forms/DatePickerPopover.tsx +3 -1
  32. package/src/components/forms/DateRangeSelector.tsx +1 -1
  33. package/src/components/forms/FormCheckbox.tsx +1 -1
  34. package/src/components/forms/FormDate.tsx +3 -1
  35. package/src/components/forms/FormDateTime.tsx +5 -3
  36. package/src/components/forms/FormSelect.tsx +1 -1
  37. package/src/components/forms/FormSlider.tsx +4 -1
  38. package/src/components/forms/__tests__/FormCheckbox.test.tsx +5 -1
  39. package/src/components/forms/__tests__/FormDate.test.tsx +5 -1
  40. package/src/components/forms/__tests__/FormSelect.test.tsx +5 -1
  41. package/src/components/navigations/RecentPagesNavigator.tsx +2 -2
  42. package/src/components/tables/ContentListTable.tsx +3 -3
  43. package/src/features/billing/stripe-customer/components/details/PaymentMethodCard.tsx +2 -2
  44. package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +2 -2
  45. package/src/features/company/components/forms/CompanyDeleter.tsx +1 -1
  46. package/src/features/content/components/lists/ContentsList.tsx +1 -1
  47. package/src/features/notification/components/lists/NotificationsList.tsx +1 -1
  48. package/src/features/notification/components/modals/NotificationModal.tsx +2 -2
  49. package/src/features/role/components/forms/FormRoles.tsx +1 -1
  50. package/src/features/user/components/forms/UserEditor.tsx +2 -2
  51. package/src/features/user/components/forms/UserReactivator.tsx +1 -1
  52. package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -2
  53. package/src/features/user/components/widgets/UserAvatar.tsx +37 -31
  54. package/src/features/user/components/widgets/UserSearchPopover.tsx +1 -1
  55. package/src/hooks/use-mobile.ts +1 -0
  56. package/src/lib/utils.ts +2 -0
  57. package/src/shadcnui/custom/multi-select.tsx +10 -21
  58. package/src/shadcnui/ui/accordion.tsx +64 -42
  59. package/src/shadcnui/ui/alert-dialog.tsx +142 -108
  60. package/src/shadcnui/ui/alert.tsx +64 -35
  61. package/src/shadcnui/ui/avatar.tsx +106 -50
  62. package/src/shadcnui/ui/badge.tsx +34 -26
  63. package/src/shadcnui/ui/breadcrumb.tsx +103 -92
  64. package/src/shadcnui/ui/button.tsx +30 -30
  65. package/src/shadcnui/ui/calendar.tsx +192 -50
  66. package/src/shadcnui/ui/card.tsx +94 -43
  67. package/src/shadcnui/ui/carousel.tsx +220 -201
  68. package/src/shadcnui/ui/chart.tsx +244 -190
  69. package/src/shadcnui/ui/checkbox.tsx +25 -25
  70. package/src/shadcnui/ui/collapsible.tsx +10 -4
  71. package/src/shadcnui/ui/combobox.tsx +292 -0
  72. package/src/shadcnui/ui/command.tsx +158 -126
  73. package/src/shadcnui/ui/context-menu.tsx +242 -164
  74. package/src/shadcnui/ui/dialog.tsx +125 -70
  75. package/src/shadcnui/ui/drawer.tsx +106 -70
  76. package/src/shadcnui/ui/dropdown-menu.tsx +231 -182
  77. package/src/shadcnui/ui/field.tsx +227 -0
  78. package/src/shadcnui/ui/hover-card.tsx +45 -23
  79. package/src/shadcnui/ui/input-group.tsx +149 -0
  80. package/src/shadcnui/ui/input-otp.tsx +19 -9
  81. package/src/shadcnui/ui/input.tsx +4 -5
  82. package/src/shadcnui/ui/label.tsx +16 -22
  83. package/src/shadcnui/ui/navigation-menu.tsx +44 -49
  84. package/src/shadcnui/ui/popover.tsx +81 -24
  85. package/src/shadcnui/ui/progress.tsx +77 -22
  86. package/src/shadcnui/ui/radio-group.tsx +30 -28
  87. package/src/shadcnui/ui/resizable.tsx +23 -17
  88. package/src/shadcnui/ui/scroll-area.tsx +50 -35
  89. package/src/shadcnui/ui/select.tsx +163 -135
  90. package/src/shadcnui/ui/separator.tsx +5 -8
  91. package/src/shadcnui/ui/sheet.tsx +40 -50
  92. package/src/shadcnui/ui/sidebar.tsx +317 -271
  93. package/src/shadcnui/ui/skeleton.tsx +2 -2
  94. package/src/shadcnui/ui/slider.tsx +60 -21
  95. package/src/shadcnui/ui/sonner.tsx +25 -1
  96. package/src/shadcnui/ui/switch.tsx +31 -24
  97. package/src/shadcnui/ui/table.tsx +84 -103
  98. package/src/shadcnui/ui/tabs.tsx +82 -55
  99. package/src/shadcnui/ui/textarea.tsx +15 -21
  100. package/src/shadcnui/ui/toggle.tsx +26 -21
  101. package/src/shadcnui/ui/tooltip.tsx +33 -24
  102. package/src/testing/factories/createMockApiData.ts +2 -2
  103. package/src/testing/factories/createMockResponse.ts +3 -8
  104. package/src/testing/factories/createMockService.ts +1 -4
  105. package/src/testing/index.ts +4 -18
  106. package/src/testing/matchers/jsonApiMatchers.ts +14 -16
  107. package/dist/chunk-D7H7SRWB.js.map +0 -1
  108. package/dist/chunk-SXPXC2TY.mjs.map +0 -1
  109. /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 "../../utils/cn";
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
- } & ({ color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> });
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<typeof RechartsPrimitive.ResponsiveContainer>["children"];
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>{children}</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(([, config]) => config.theme || config.color);
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
- ${prefix} [data-chart=${id}] {
83
- ${colorConfig
84
- .map(([key, itemConfig]) => {
85
- const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
86
- return color ? ` --color-${key}: ${color};` : null;
87
- })
88
- .join("\n")}
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
- }: CustomTooltipProps) {
137
- const { config } = useChart();
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
- const v =
149
- !labelKey && typeof label === "string"
150
- ? (config[label as keyof typeof config]?.label ?? label)
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 <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
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
- }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
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 grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
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.map((item, index) => {
183
- const key = `${nameKey || item.name || item.dataKey || "value"}`;
184
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
185
- const indicatorColor = color || item.payload.fill || item.color;
186
-
187
- return (
188
- <div
189
- key={item.dataKey}
190
- className={cn(
191
- "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
192
- indicator === "dot" && "items-center",
193
- )}
194
- >
195
- {formatter && item?.value !== undefined && item.name ? (
196
- formatter(item.value, item.name, item, index, item.payload)
197
- ) : (
198
- <>
199
- {itemConfig?.icon ? (
200
- <itemConfig.icon />
201
- ) : (
202
- !hideIndicator && (
203
- <div
204
- className={cn("shrink-0 rounded-[2px] border-[var(--color-border)] bg-[var(--color-bg)]", {
205
- "h-2.5 w-2.5": indicator === "dot",
206
- "w-1": indicator === "line",
207
- "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
208
- "my-0.5": nestLabel && indicator === "dashed",
209
- })}
210
- style={
211
- {
212
- "--color-bg": indicatorColor,
213
- "--color-border": indicatorColor,
214
- } as React.CSSProperties
215
- }
216
- />
217
- )
218
- )}
219
- <div
220
- className={cn("flex flex-1 justify-between leading-none", nestLabel ? "items-end" : "items-center")}
221
- >
222
- <div className="grid gap-1.5">
223
- {nestLabel ? tooltipLabel : null}
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
- </div>
232
- </>
233
- )}
234
- </div>
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
- }: ChartLegendContentProps) {
259
- const { config } = useChart();
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 className={cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className)}>
267
- {payload.map((item) => {
268
- const key = `${nameKey || item.dataKey || "value"}`;
269
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
270
-
271
- return (
272
- <div
273
- key={item.value}
274
- className={cn("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3")}
275
- >
276
- {itemConfig?.icon && !hideIcon ? (
277
- <itemConfig.icon />
278
- ) : (
279
- <div
280
- className="h-2 w-2 shrink-0 rounded-[2px]"
281
- style={{
282
- backgroundColor: item.color,
283
- }}
284
- />
285
- )}
286
- {itemConfig?.label}
287
- </div>
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
- // Helper to extract item config from a payload.
295
- function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
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 && typeof payload.payload === "object" && payload.payload !== null
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 (key in payload && typeof payload[key as keyof typeof payload] === "string") {
308
- configLabelKey = payload[key as keyof typeof payload] as string;
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[key as keyof typeof payloadPayload] as string;
357
+ configLabelKey = payloadPayload[
358
+ key as keyof typeof payloadPayload
359
+ ] as string
315
360
  }
316
361
 
317
- return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
362
+ return configLabelKey in config
363
+ ? config[configLabelKey]
364
+ : config[key as keyof typeof config]
318
365
  }
319
366
 
320
- export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent };
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 { cn } from "../../utils/cn";
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
- const Checkbox = React.forwardRef<
9
- React.ElementRef<typeof CheckboxPrimitive.Root>,
10
- React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
11
- >(({ className, ...props }, ref) => (
12
- <CheckboxPrimitive.Root
13
- ref={ref}
14
- className={cn(
15
- "peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
16
- className,
17
- )}
18
- {...props}
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
- <CheckIcon className="h-4 w-4" />
24
- </CheckboxPrimitive.Indicator>
25
- </CheckboxPrimitive.Root>
26
- ));
27
- Checkbox.displayName = CheckboxPrimitive.Root.displayName;
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 * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
3
+ import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
4
4
 
5
- const Collapsible = CollapsiblePrimitive.Root;
5
+ function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {
6
+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
7
+ }
6
8
 
7
- const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
9
+ function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {
10
+ return <CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />;
11
+ }
8
12
 
9
- const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
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 };