@stagewise/ui 0.1.0 → 0.3.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 +9 -3
- package/package.json +9 -15
- package/src/components/ui/accordion.tsx +13 -15
- package/src/components/ui/alert-dialog.tsx +38 -38
- package/src/components/ui/alert.tsx +22 -22
- package/src/components/ui/aspect-ratio.tsx +6 -6
- package/src/components/ui/avatar.tsx +30 -30
- package/src/components/ui/badge.tsx +24 -22
- package/src/components/ui/breadcrumb.tsx +34 -37
- package/src/components/ui/bubble.tsx +48 -48
- package/src/components/ui/button-group.tsx +24 -24
- package/src/components/ui/button.tsx +24 -24
- package/src/components/ui/calendar.tsx +94 -81
- package/src/components/ui/card.tsx +30 -30
- package/src/components/ui/carousel.tsx +95 -92
- package/src/components/ui/chart.tsx +110 -110
- package/src/components/ui/checkbox.tsx +9 -10
- package/src/components/ui/collapsible.tsx +5 -5
- package/src/components/ui/combobox.tsx +51 -44
- package/src/components/ui/command.tsx +173 -190
- package/src/components/ui/context-menu.tsx +60 -50
- package/src/components/ui/dialog.tsx +33 -34
- package/src/components/ui/direction.tsx +1 -1
- package/src/components/ui/drawer.tsx +61 -61
- package/src/components/ui/dropdown-menu.tsx +54 -50
- package/src/components/ui/empty.tsx +30 -30
- package/src/components/ui/field.tsx +64 -64
- package/src/components/ui/hover-card.tsx +12 -12
- package/src/components/ui/input-group.tsx +54 -54
- package/src/components/ui/input-otp.tsx +24 -25
- package/src/components/ui/input.tsx +8 -8
- package/src/components/ui/item.tsx +64 -64
- package/src/components/ui/kbd.tsx +8 -8
- package/src/components/ui/klex-logo-combo.tsx +69 -0
- package/src/components/ui/klex-logo-text.tsx +70 -0
- package/src/components/ui/klex-logo.tsx +146 -0
- package/src/components/ui/label.tsx +8 -8
- package/src/components/ui/marker.tsx +25 -25
- package/src/components/ui/menubar.tsx +54 -50
- package/src/components/ui/message-scroller.tsx +130 -0
- package/src/components/ui/message.tsx +27 -27
- package/src/components/ui/native-select.tsx +22 -18
- package/src/components/ui/navigation-menu.tsx +37 -34
- package/src/components/ui/pagination.tsx +34 -31
- package/src/components/ui/popover.tsx +19 -19
- package/src/components/ui/progress.tsx +16 -16
- package/src/components/ui/questionnaire.tsx +72 -69
- package/src/components/ui/radio-group.tsx +9 -9
- package/src/components/ui/resizable.tsx +19 -12
- package/src/components/ui/scroll-area.tsx +10 -10
- package/src/components/ui/select.tsx +39 -34
- package/src/components/ui/separator.tsx +7 -7
- package/src/components/ui/sheet.tsx +31 -32
- package/src/components/ui/sidebar.tsx +244 -232
- package/src/components/ui/skeleton.tsx +5 -5
- package/src/components/ui/slider.tsx +11 -7
- package/src/components/ui/spinner.tsx +15 -6
- package/src/components/ui/stagewise-logo-combo.tsx +43 -0
- package/src/components/ui/stagewise-logo-text.tsx +30 -0
- package/src/components/ui/stagewise-logo.tsx +42 -0
- package/src/components/ui/switch.tsx +9 -9
- package/src/components/ui/table.tsx +31 -31
- package/src/components/ui/tabs.tsx +37 -26
- package/src/components/ui/textarea.tsx +7 -7
- package/src/components/ui/toast.tsx +70 -70
- package/src/components/ui/toggle-group.tsx +26 -26
- package/src/components/ui/toggle.tsx +15 -15
- package/src/components/ui/tooltip.tsx +13 -13
- package/src/hooks/use-mobile.ts +13 -11
- package/src/icons/custom/ui-outline-18/IconKlexOutline18.tsx +39 -0
- package/src/icons/custom/ui-outline-18/IconLaptop.tsx +35 -0
- package/src/icons/custom/ui-outline-18/IconSignOut.tsx +33 -0
- package/src/icons/custom/ui-outline-18/index.ts +4 -1
- package/src/icons/index.ts +43 -20
- package/src/icons/nucleo/social-media/IconMicrosoftEntraId.tsx +56 -0
- package/src/icons/nucleo/social-media/index.ts +1 -0
- package/src/icons/nucleo/ui-outline-18/IconArrowDownOutline18.tsx +4 -3
- package/src/icons/nucleo/ui-outline-18/IconArrowTurnRightOutline18.tsx +32 -0
- package/src/icons/nucleo/ui-outline-18/IconArrowUpOutline18.tsx +35 -0
- package/src/icons/nucleo/ui-outline-18/IconChartPieOutline18.tsx +4 -3
- package/src/icons/nucleo/ui-outline-18/IconChevronMaximizeDiagonal2Outline18.tsx +33 -0
- package/src/icons/nucleo/ui-outline-18/IconChevronUpOutline18.tsx +4 -3
- package/src/icons/nucleo/ui-outline-18/IconEmptyOutline18.tsx +41 -0
- package/src/icons/nucleo/ui-outline-18/IconEyeOffOutline18.tsx +18 -0
- package/src/icons/nucleo/ui-outline-18/IconLinkBrokenOutline18.tsx +66 -0
- package/src/icons/nucleo/ui-outline-18/IconLock18Outline.tsx +48 -0
- package/src/icons/nucleo/ui-outline-18/IconMinusOutline18.tsx +4 -3
- package/src/icons/nucleo/ui-outline-18/IconMsgs2Outline18.tsx +32 -0
- package/src/icons/nucleo/ui-outline-18/IconPanelLeftOutline18.tsx +4 -3
- package/src/icons/nucleo/ui-outline-18/IconSidebarLeft2HideOutline18.tsx +63 -0
- package/src/icons/nucleo/ui-outline-18/IconSidebarRight2HideOutline18.tsx +63 -0
- package/src/icons/nucleo/ui-outline-18/index.ts +11 -1
- package/src/icons/provider/IconAnthropic.tsx +15 -0
- package/src/icons/provider/IconAttio.tsx +9 -0
- package/src/icons/provider/IconCodex.tsx +18 -0
- package/src/icons/provider/IconDiscord.tsx +17 -0
- package/src/icons/provider/IconGemini.tsx +152 -0
- package/src/icons/provider/IconLinear.tsx +9 -0
- package/src/icons/provider/IconOpenAI.tsx +15 -0
- package/src/icons/provider/IconOpenRouter.tsx +24 -0
- package/src/icons/provider/IconSlack.tsx +24 -0
- package/src/icons/provider/IconTelegram.tsx +29 -0
- package/src/icons/provider/IconWhatsapp.tsx +14 -0
- package/src/icons/provider/LICENSE +21 -0
- package/src/icons/provider/index.ts +11 -0
- package/src/index.ts +68 -61
- package/src/lib/utils.ts +3 -3
- package/src/styles/bridge.css +7 -3
- package/src/styles/derived-utilities.css +129 -50
- package/src/styles/index.css +17 -2
- package/src/styles/palette.css +266 -105
- package/src/styles/scroll-fade.css +116 -0
- package/src/styles/tailwind-tokens.css +3 -0
- package/src/styles/theme.css +57 -43
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import * as RechartsPrimitive from
|
|
3
|
-
import type { TooltipValueType } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as RechartsPrimitive from 'recharts';
|
|
3
|
+
import type { TooltipValueType } from 'recharts';
|
|
4
4
|
|
|
5
|
-
import { cn } from
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
6
|
|
|
7
7
|
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
8
|
-
const THEMES = { light:
|
|
8
|
+
const THEMES = { light: '', dark: '.dark' } as const;
|
|
9
9
|
|
|
10
|
-
const INITIAL_DIMENSION = { width: 320, height: 200 } as const
|
|
11
|
-
type TooltipNameType = number | string
|
|
10
|
+
const INITIAL_DIMENSION = { width: 320, height: 200 } as const;
|
|
11
|
+
type TooltipNameType = number | string;
|
|
12
12
|
|
|
13
13
|
export type ChartConfig = Record<
|
|
14
14
|
string,
|
|
15
15
|
{
|
|
16
|
-
label?: React.ReactNode
|
|
17
|
-
icon?: React.ComponentType
|
|
16
|
+
label?: React.ReactNode;
|
|
17
|
+
icon?: React.ComponentType;
|
|
18
18
|
} & (
|
|
19
19
|
| { color?: string; theme?: never }
|
|
20
20
|
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
21
21
|
)
|
|
22
|
-
|
|
22
|
+
>;
|
|
23
23
|
|
|
24
24
|
type ChartContextProps = {
|
|
25
|
-
config: ChartConfig
|
|
26
|
-
}
|
|
25
|
+
config: ChartConfig;
|
|
26
|
+
};
|
|
27
27
|
|
|
28
|
-
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
28
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
|
29
29
|
|
|
30
30
|
function useChart() {
|
|
31
|
-
const context = React.useContext(ChartContext)
|
|
31
|
+
const context = React.useContext(ChartContext);
|
|
32
32
|
|
|
33
33
|
if (!context) {
|
|
34
|
-
throw new Error(
|
|
34
|
+
throw new Error('useChart must be used within a <ChartContainer />');
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
return context
|
|
37
|
+
return context;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function ChartContainer({
|
|
@@ -44,18 +44,18 @@ function ChartContainer({
|
|
|
44
44
|
config,
|
|
45
45
|
initialDimension = INITIAL_DIMENSION,
|
|
46
46
|
...props
|
|
47
|
-
}: React.ComponentProps<
|
|
48
|
-
config: ChartConfig
|
|
47
|
+
}: React.ComponentProps<'div'> & {
|
|
48
|
+
config: ChartConfig;
|
|
49
49
|
children: React.ComponentProps<
|
|
50
50
|
typeof RechartsPrimitive.ResponsiveContainer
|
|
51
|
-
>[
|
|
51
|
+
>['children'];
|
|
52
52
|
initialDimension?: {
|
|
53
|
-
width: number
|
|
54
|
-
height: number
|
|
55
|
-
}
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
};
|
|
56
56
|
}) {
|
|
57
|
-
const uniqueId = React.useId()
|
|
58
|
-
const chartId = `chart-${id ?? uniqueId.replace(/:/g,
|
|
57
|
+
const uniqueId = React.useId();
|
|
58
|
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, '')}`;
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
61
|
<ChartContext.Provider value={{ config }}>
|
|
@@ -64,7 +64,7 @@ function ChartContainer({
|
|
|
64
64
|
data-chart={chartId}
|
|
65
65
|
className={cn(
|
|
66
66
|
"flex aspect-video justify-center text-xs [&_.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-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.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 [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
67
|
-
className
|
|
67
|
+
className,
|
|
68
68
|
)}
|
|
69
69
|
{...props}
|
|
70
70
|
>
|
|
@@ -76,16 +76,16 @@ function ChartContainer({
|
|
|
76
76
|
</RechartsPrimitive.ResponsiveContainer>
|
|
77
77
|
</div>
|
|
78
78
|
</ChartContext.Provider>
|
|
79
|
-
)
|
|
79
|
+
);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
83
83
|
const colorConfig = Object.entries(config).filter(
|
|
84
|
-
([, config]) => config.theme ?? config.color
|
|
85
|
-
)
|
|
84
|
+
([, config]) => config.theme ?? config.color,
|
|
85
|
+
);
|
|
86
86
|
|
|
87
87
|
if (!colorConfig.length) {
|
|
88
|
-
return null
|
|
88
|
+
return null;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
return (
|
|
@@ -99,26 +99,26 @@ ${colorConfig
|
|
|
99
99
|
.map(([key, itemConfig]) => {
|
|
100
100
|
const color =
|
|
101
101
|
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
|
|
102
|
-
itemConfig.color
|
|
103
|
-
return color ? ` --color-${key}: ${color};` : null
|
|
102
|
+
itemConfig.color;
|
|
103
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
104
104
|
})
|
|
105
|
-
.join(
|
|
105
|
+
.join('\n')}
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
`,
|
|
108
108
|
)
|
|
109
|
-
.join(
|
|
109
|
+
.join('\n'),
|
|
110
110
|
}}
|
|
111
111
|
/>
|
|
112
|
-
)
|
|
113
|
-
}
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
114
|
|
|
115
|
-
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
115
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
116
116
|
|
|
117
117
|
function ChartTooltipContent({
|
|
118
118
|
active,
|
|
119
119
|
payload,
|
|
120
120
|
className,
|
|
121
|
-
indicator =
|
|
121
|
+
indicator = 'dot',
|
|
122
122
|
hideLabel = false,
|
|
123
123
|
hideIndicator = false,
|
|
124
124
|
label,
|
|
@@ -129,47 +129,47 @@ function ChartTooltipContent({
|
|
|
129
129
|
nameKey,
|
|
130
130
|
labelKey,
|
|
131
131
|
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
132
|
-
React.ComponentProps<
|
|
133
|
-
hideLabel?: boolean
|
|
134
|
-
hideIndicator?: boolean
|
|
135
|
-
indicator?:
|
|
136
|
-
nameKey?: string
|
|
137
|
-
labelKey?: string
|
|
132
|
+
React.ComponentProps<'div'> & {
|
|
133
|
+
hideLabel?: boolean;
|
|
134
|
+
hideIndicator?: boolean;
|
|
135
|
+
indicator?: 'line' | 'dot' | 'dashed';
|
|
136
|
+
nameKey?: string;
|
|
137
|
+
labelKey?: string;
|
|
138
138
|
} & Omit<
|
|
139
139
|
RechartsPrimitive.DefaultTooltipContentProps<
|
|
140
140
|
TooltipValueType,
|
|
141
141
|
TooltipNameType
|
|
142
142
|
>,
|
|
143
|
-
|
|
143
|
+
'accessibilityLayer'
|
|
144
144
|
>) {
|
|
145
|
-
const { config } = useChart()
|
|
145
|
+
const { config } = useChart();
|
|
146
146
|
|
|
147
147
|
const tooltipLabel = React.useMemo(() => {
|
|
148
148
|
if (hideLabel || !payload?.length) {
|
|
149
|
-
return null
|
|
149
|
+
return null;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
const [item] = payload
|
|
153
|
-
const key = `${labelKey ?? item?.dataKey ?? item?.name ??
|
|
154
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
152
|
+
const [item] = payload;
|
|
153
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? 'value'}`;
|
|
154
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
155
155
|
const value =
|
|
156
|
-
!labelKey && typeof label ===
|
|
156
|
+
!labelKey && typeof label === 'string'
|
|
157
157
|
? (config[label]?.label ?? label)
|
|
158
|
-
: itemConfig?.label
|
|
158
|
+
: itemConfig?.label;
|
|
159
159
|
|
|
160
160
|
if (labelFormatter) {
|
|
161
161
|
return (
|
|
162
|
-
<div className={cn(
|
|
162
|
+
<div className={cn('font-medium', labelClassName)}>
|
|
163
163
|
{labelFormatter(value, payload)}
|
|
164
164
|
</div>
|
|
165
|
-
)
|
|
165
|
+
);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
if (!value) {
|
|
169
|
-
return null
|
|
169
|
+
return null;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
return <div className={cn(
|
|
172
|
+
return <div className={cn('font-medium', labelClassName)}>{value}</div>;
|
|
173
173
|
}, [
|
|
174
174
|
label,
|
|
175
175
|
labelFormatter,
|
|
@@ -178,36 +178,36 @@ function ChartTooltipContent({
|
|
|
178
178
|
labelClassName,
|
|
179
179
|
config,
|
|
180
180
|
labelKey,
|
|
181
|
-
])
|
|
181
|
+
]);
|
|
182
182
|
|
|
183
183
|
if (!active || !payload?.length) {
|
|
184
|
-
return null
|
|
184
|
+
return null;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
const nestLabel = payload.length === 1 && indicator !==
|
|
187
|
+
const nestLabel = payload.length === 1 && indicator !== 'dot';
|
|
188
188
|
|
|
189
189
|
return (
|
|
190
190
|
<div
|
|
191
191
|
className={cn(
|
|
192
|
-
|
|
193
|
-
className
|
|
192
|
+
'grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl',
|
|
193
|
+
className,
|
|
194
194
|
)}
|
|
195
195
|
>
|
|
196
196
|
{!nestLabel ? tooltipLabel : null}
|
|
197
197
|
<div className="grid gap-1.5">
|
|
198
198
|
{payload
|
|
199
|
-
.filter((item) => item.type !==
|
|
199
|
+
.filter((item) => item.type !== 'none')
|
|
200
200
|
.map((item, index) => {
|
|
201
|
-
const key = `${nameKey ?? item.name ?? item.dataKey ??
|
|
202
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
203
|
-
const indicatorColor = color ?? item.payload?.fill ?? item.color
|
|
201
|
+
const key = `${nameKey ?? item.name ?? item.dataKey ?? 'value'}`;
|
|
202
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
203
|
+
const indicatorColor = color ?? item.payload?.fill ?? item.color;
|
|
204
204
|
|
|
205
205
|
return (
|
|
206
206
|
<div
|
|
207
207
|
key={index}
|
|
208
208
|
className={cn(
|
|
209
|
-
|
|
210
|
-
indicator ===
|
|
209
|
+
'flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground',
|
|
210
|
+
indicator === 'dot' && 'items-center',
|
|
211
211
|
)}
|
|
212
212
|
>
|
|
213
213
|
{formatter && item?.value !== undefined && item.name ? (
|
|
@@ -220,19 +220,19 @@ function ChartTooltipContent({
|
|
|
220
220
|
!hideIndicator && (
|
|
221
221
|
<div
|
|
222
222
|
className={cn(
|
|
223
|
-
|
|
223
|
+
'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',
|
|
224
224
|
{
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
indicator ===
|
|
229
|
-
|
|
230
|
-
}
|
|
225
|
+
'h-2.5 w-2.5': indicator === 'dot',
|
|
226
|
+
'w-1': indicator === 'line',
|
|
227
|
+
'w-0 border-[1.5px] border-dashed bg-transparent':
|
|
228
|
+
indicator === 'dashed',
|
|
229
|
+
'my-0.5': nestLabel && indicator === 'dashed',
|
|
230
|
+
},
|
|
231
231
|
)}
|
|
232
232
|
style={
|
|
233
233
|
{
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
'--color-bg': indicatorColor,
|
|
235
|
+
'--color-border': indicatorColor,
|
|
236
236
|
} as React.CSSProperties
|
|
237
237
|
}
|
|
238
238
|
/>
|
|
@@ -240,8 +240,8 @@ function ChartTooltipContent({
|
|
|
240
240
|
)}
|
|
241
241
|
<div
|
|
242
242
|
className={cn(
|
|
243
|
-
|
|
244
|
-
nestLabel ?
|
|
243
|
+
'flex flex-1 justify-between leading-none',
|
|
244
|
+
nestLabel ? 'items-end' : 'items-center',
|
|
245
245
|
)}
|
|
246
246
|
>
|
|
247
247
|
<div className="grid gap-1.5">
|
|
@@ -252,7 +252,7 @@ function ChartTooltipContent({
|
|
|
252
252
|
</div>
|
|
253
253
|
{item.value != null && (
|
|
254
254
|
<span className="font-mono font-medium text-foreground tabular-nums">
|
|
255
|
-
{typeof item.value ===
|
|
255
|
+
{typeof item.value === 'number'
|
|
256
256
|
? item.value.toLocaleString()
|
|
257
257
|
: String(item.value)}
|
|
258
258
|
</span>
|
|
@@ -261,50 +261,50 @@ function ChartTooltipContent({
|
|
|
261
261
|
</>
|
|
262
262
|
)}
|
|
263
263
|
</div>
|
|
264
|
-
)
|
|
264
|
+
);
|
|
265
265
|
})}
|
|
266
266
|
</div>
|
|
267
267
|
</div>
|
|
268
|
-
)
|
|
268
|
+
);
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
const ChartLegend = RechartsPrimitive.Legend
|
|
271
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
272
272
|
|
|
273
273
|
function ChartLegendContent({
|
|
274
274
|
className,
|
|
275
275
|
hideIcon = false,
|
|
276
276
|
payload,
|
|
277
|
-
verticalAlign =
|
|
277
|
+
verticalAlign = 'bottom',
|
|
278
278
|
nameKey,
|
|
279
|
-
}: React.ComponentProps<
|
|
280
|
-
hideIcon?: boolean
|
|
281
|
-
nameKey?: string
|
|
279
|
+
}: React.ComponentProps<'div'> & {
|
|
280
|
+
hideIcon?: boolean;
|
|
281
|
+
nameKey?: string;
|
|
282
282
|
} & RechartsPrimitive.DefaultLegendContentProps) {
|
|
283
|
-
const { config } = useChart()
|
|
283
|
+
const { config } = useChart();
|
|
284
284
|
|
|
285
285
|
if (!payload?.length) {
|
|
286
|
-
return null
|
|
286
|
+
return null;
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
return (
|
|
290
290
|
<div
|
|
291
291
|
className={cn(
|
|
292
|
-
|
|
293
|
-
verticalAlign ===
|
|
294
|
-
className
|
|
292
|
+
'flex items-center justify-center gap-4',
|
|
293
|
+
verticalAlign === 'top' ? 'pb-3' : 'pt-3',
|
|
294
|
+
className,
|
|
295
295
|
)}
|
|
296
296
|
>
|
|
297
297
|
{payload
|
|
298
|
-
.filter((item) => item.type !==
|
|
298
|
+
.filter((item) => item.type !== 'none')
|
|
299
299
|
.map((item, index) => {
|
|
300
|
-
const key = `${nameKey ?? item.dataKey ??
|
|
301
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
300
|
+
const key = `${nameKey ?? item.dataKey ?? 'value'}`;
|
|
301
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
302
302
|
|
|
303
303
|
return (
|
|
304
304
|
<div
|
|
305
305
|
key={index}
|
|
306
306
|
className={cn(
|
|
307
|
-
|
|
307
|
+
'flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground',
|
|
308
308
|
)}
|
|
309
309
|
>
|
|
310
310
|
{itemConfig?.icon && !hideIcon ? (
|
|
@@ -319,46 +319,46 @@ function ChartLegendContent({
|
|
|
319
319
|
)}
|
|
320
320
|
{itemConfig?.label}
|
|
321
321
|
</div>
|
|
322
|
-
)
|
|
322
|
+
);
|
|
323
323
|
})}
|
|
324
324
|
</div>
|
|
325
|
-
)
|
|
325
|
+
);
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
function getPayloadConfigFromPayload(
|
|
329
329
|
config: ChartConfig,
|
|
330
330
|
payload: unknown,
|
|
331
|
-
key: string
|
|
331
|
+
key: string,
|
|
332
332
|
) {
|
|
333
|
-
if (typeof payload !==
|
|
334
|
-
return undefined
|
|
333
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
334
|
+
return undefined;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
const payloadPayload =
|
|
338
|
-
|
|
339
|
-
typeof payload.payload ===
|
|
338
|
+
'payload' in payload &&
|
|
339
|
+
typeof payload.payload === 'object' &&
|
|
340
340
|
payload.payload !== null
|
|
341
341
|
? payload.payload
|
|
342
|
-
: undefined
|
|
342
|
+
: undefined;
|
|
343
343
|
|
|
344
|
-
let configLabelKey: string = key
|
|
344
|
+
let configLabelKey: string = key;
|
|
345
345
|
|
|
346
346
|
if (
|
|
347
347
|
key in payload &&
|
|
348
|
-
typeof payload[key as keyof typeof payload] ===
|
|
348
|
+
typeof payload[key as keyof typeof payload] === 'string'
|
|
349
349
|
) {
|
|
350
|
-
configLabelKey = payload[key as keyof typeof payload] as string
|
|
350
|
+
configLabelKey = payload[key as keyof typeof payload] as string;
|
|
351
351
|
} else if (
|
|
352
352
|
payloadPayload &&
|
|
353
353
|
key in payloadPayload &&
|
|
354
|
-
typeof payloadPayload[key as keyof typeof payloadPayload] ===
|
|
354
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
|
|
355
355
|
) {
|
|
356
356
|
configLabelKey = payloadPayload[
|
|
357
357
|
key as keyof typeof payloadPayload
|
|
358
|
-
] as string
|
|
358
|
+
] as string;
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
return configLabelKey in config ? config[configLabelKey] : config[key]
|
|
361
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
export {
|
|
@@ -368,4 +368,4 @@ export {
|
|
|
368
368
|
ChartLegend,
|
|
369
369
|
ChartLegendContent,
|
|
370
370
|
ChartStyle,
|
|
371
|
-
}
|
|
371
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
|
|
3
|
-
import { Checkbox as CheckboxPrimitive } from
|
|
3
|
+
import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';
|
|
4
4
|
|
|
5
|
-
import { cn } from
|
|
6
|
-
import { IconCheckOutline18 } from
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
import { IconCheckOutline18 } from '../../icons';
|
|
7
7
|
|
|
8
8
|
function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
|
|
9
9
|
return (
|
|
10
10
|
<CheckboxPrimitive.Root
|
|
11
11
|
data-slot="checkbox"
|
|
12
12
|
className={cn(
|
|
13
|
-
|
|
14
|
-
className
|
|
13
|
+
'peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] text-primary-foreground border border-derived-strong transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary',
|
|
14
|
+
className,
|
|
15
15
|
)}
|
|
16
16
|
{...props}
|
|
17
17
|
>
|
|
@@ -20,11 +20,10 @@ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
|
|
|
20
20
|
className="grid place-content-center transition-transform scale-0 rotate-10 data-checked:scale-100 data-checked:rotate-0"
|
|
21
21
|
keepMounted={true}
|
|
22
22
|
>
|
|
23
|
-
<IconCheckOutline18 className="size-3" strokeWidth={2.5}
|
|
24
|
-
/>
|
|
23
|
+
<IconCheckOutline18 className="size-3" strokeWidth={2.5} />
|
|
25
24
|
</CheckboxPrimitive.Indicator>
|
|
26
25
|
</CheckboxPrimitive.Root>
|
|
27
|
-
)
|
|
26
|
+
);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
export { Checkbox }
|
|
29
|
+
export { Checkbox };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Collapsible as CollapsiblePrimitive } from
|
|
1
|
+
import { Collapsible as CollapsiblePrimitive } from '@base-ui/react/collapsible';
|
|
2
2
|
|
|
3
3
|
function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {
|
|
4
|
-
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props}
|
|
4
|
+
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {
|
|
8
8
|
return (
|
|
9
9
|
<CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />
|
|
10
|
-
)
|
|
10
|
+
);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) {
|
|
14
14
|
return (
|
|
15
15
|
<CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />
|
|
16
|
-
)
|
|
16
|
+
);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
|
19
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|