@cognite/aura 0.1.7 → 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/DESIGN.md +34 -92
- package/README.md +33 -0
- package/dist/colors.css +471 -214
- package/dist/components/index.d.ts +17 -33
- package/dist/components/index.js +315 -281
- package/dist/components/ui/core/accordion/accordion.d.ts +7 -7
- package/dist/components/ui/core/accordion/accordion.js +64 -62
- package/dist/components/ui/core/action-toolbar/action-toolbar.d.ts +41 -0
- package/dist/components/ui/core/action-toolbar/action-toolbar.js +176 -0
- package/dist/components/ui/core/alert/alert.d.ts +23 -12
- package/dist/components/ui/core/alert/alert.js +123 -120
- package/dist/components/ui/core/avatar/avatar.d.ts +12 -8
- package/dist/components/ui/core/avatar/avatar.js +10 -10
- package/dist/components/ui/core/badge/badge.d.ts +11 -8
- package/dist/components/ui/core/badge/badge.js +13 -13
- package/dist/components/ui/core/banner/banner.d.ts +18 -28
- package/dist/components/ui/core/banner/banner.js +6 -6
- package/dist/components/ui/core/breadcrumb/breadcrumb.d.ts +12 -0
- package/dist/components/ui/core/breadcrumb/breadcrumb.js +200 -0
- package/dist/components/ui/core/button/button.d.ts +8 -5
- package/dist/components/ui/core/button/button.js +22 -19
- package/dist/components/ui/core/button-group/button-group.d.ts +7 -6
- package/dist/components/ui/core/card/card.d.ts +18 -14
- package/dist/components/ui/core/card/card.js +131 -87
- package/dist/components/ui/core/chart/chart.d.ts +69 -0
- package/dist/components/ui/core/chart/chart.js +215 -0
- package/dist/components/ui/core/chart/index.d.ts +2 -0
- package/dist/components/ui/core/chart/index.js +8 -0
- package/dist/components/ui/core/checkbox/checkbox.d.ts +17 -0
- package/dist/components/ui/core/checkbox/checkbox.js +133 -0
- package/dist/components/ui/core/{badge/badge.metadata.d.ts → checkbox/checkbox.metadata.d.ts} +1 -1
- package/dist/components/ui/core/checkbox/checkbox.metadata.js +8 -0
- package/dist/components/ui/core/code-block/code-block.d.ts +6 -9
- package/dist/components/ui/core/code-block/code-block.js +52 -48
- package/dist/components/ui/core/collapsible/collapsible.d.ts +5 -3
- package/dist/components/ui/core/combobox/combobox.d.ts +2 -2
- package/dist/components/ui/core/command/command.d.ts +11 -78
- package/dist/components/ui/core/command/command.js +53 -52
- package/dist/components/ui/core/count/count.d.ts +9 -0
- package/dist/components/ui/core/count/count.js +32 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.d.ts +15 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +99 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +25 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.d.ts +4 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +82 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.d.ts +17 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +190 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +42 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +161 -0
- package/dist/components/ui/core/date-time-pickers/index.d.ts +6 -0
- package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.d.ts +7 -0
- package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +57 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.d.ts +13 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +119 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.d.ts +10 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.js +93 -0
- package/dist/components/ui/core/date-time-pickers/shared/constants.d.ts +20 -0
- package/dist/components/ui/core/date-time-pickers/shared/constants.js +14 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.d.ts +19 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +99 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.d.ts +12 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +68 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.d.ts +12 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +40 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.d.ts +29 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +63 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.d.ts +8 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +19 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.d.ts +17 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +34 -0
- package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.d.ts +8 -0
- package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +7 -0
- package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.d.ts +13 -0
- package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +31 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.d.ts +10 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +52 -0
- package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.d.ts +48 -0
- package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +52 -0
- package/dist/components/ui/core/date-time-pickers/utils/date-range-utils.d.ts +26 -0
- package/dist/components/ui/core/date-time-pickers/utils/format-utils.d.ts +37 -0
- package/dist/components/ui/core/date-time-pickers/utils/segment-utils.d.ts +34 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.d.ts +43 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +15 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-validation.d.ts +23 -0
- package/dist/components/ui/core/dialog/dialog.d.ts +10 -10
- package/dist/components/ui/core/dialog/dialog.js +12 -3
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +24 -47
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +125 -123
- package/dist/components/ui/core/empty-state/empty-state.context.d.ts +10 -0
- package/dist/components/ui/core/empty-state/empty-state.context.js +8 -0
- package/dist/components/ui/core/empty-state/empty-state.d.ts +18 -0
- package/dist/components/ui/core/empty-state/empty-state.js +139 -0
- package/dist/components/ui/core/helper-text/helper-text.d.ts +7 -5
- package/dist/components/ui/core/hover-card/hover-card.d.ts +5 -7
- package/dist/components/ui/core/hover-card/hover-card.js +26 -25
- package/dist/components/ui/core/inline-citation/inline-citation.d.ts +10 -10
- package/dist/components/ui/core/inline-citation/inline-citation.js +65 -57
- package/dist/components/ui/core/input/input.d.ts +2 -1
- package/dist/components/ui/core/input-group/input-group.d.ts +17 -13
- package/dist/components/ui/core/input-group/input-group.js +35 -36
- package/dist/components/ui/core/kbd/kbd.d.ts +4 -0
- package/dist/components/ui/core/kbd/kbd.js +36 -0
- package/dist/components/ui/core/label/label.d.ts +3 -2
- package/dist/components/ui/core/loader/loader.d.ts +11 -3
- package/dist/components/ui/core/loader/loader.js +106 -107
- package/dist/components/ui/core/message/message.d.ts +18 -17
- package/dist/components/ui/core/message/message.js +15 -13
- package/dist/components/ui/core/pagination/pagination-size-context.d.ts +5 -0
- package/dist/components/ui/core/pagination/pagination-size-context.js +6 -0
- package/dist/components/ui/core/pagination/pagination-teleport.d.ts +11 -0
- package/dist/components/ui/core/pagination/pagination-teleport.js +108 -0
- package/dist/components/ui/core/pagination/pagination-teleport.utils.d.ts +1 -0
- package/dist/components/ui/core/pagination/pagination-teleport.utils.js +7 -0
- package/dist/components/ui/core/pagination/pagination.d.ts +41 -0
- package/dist/components/ui/core/pagination/pagination.js +335 -0
- package/dist/components/ui/core/popover/popover.d.ts +12 -16
- package/dist/components/ui/core/popover/popover.js +52 -51
- package/dist/components/ui/core/progress/progress.d.ts +7 -4
- package/dist/components/ui/core/prompt-input/prompt-input.d.ts +36 -103
- package/dist/components/ui/core/prompt-input/prompt-input.js +193 -180
- package/dist/components/ui/core/radio-group/radio-group.d.ts +20 -0
- package/dist/components/ui/core/radio-group/radio-group.js +113 -0
- package/dist/components/ui/core/reasoning/reasoning.d.ts +5 -5
- package/dist/components/ui/core/reasoning/reasoning.js +1 -1
- package/dist/components/ui/core/scroll-area/scroll-area.d.ts +4 -2
- package/dist/components/ui/core/search/search.d.ts +10 -0
- package/dist/components/ui/core/search/search.js +99 -0
- package/dist/components/ui/core/segmented-control/segmented-control.d.ts +20 -0
- package/dist/components/ui/core/segmented-control/segmented-control.js +172 -0
- package/dist/components/ui/core/select/select.d.ts +13 -13
- package/dist/components/ui/core/select/select.js +13 -10
- package/dist/components/ui/core/separator/separator.d.ts +2 -4
- package/dist/components/ui/core/separator/separator.js +4 -5
- package/dist/components/ui/core/shimmer/shimmer.d.ts +3 -5
- package/dist/components/ui/core/shimmer/shimmer.js +25 -26
- package/dist/components/ui/core/skeleton/skeleton.d.ts +2 -1
- package/dist/components/ui/core/sonner-toast/sonner-toast.d.ts +4 -0
- package/dist/components/ui/core/sonner-toast/sonner-toast.js +48 -0
- package/dist/components/ui/core/sources/sources.d.ts +3 -3
- package/dist/components/ui/core/sources/sources.js +6 -1
- package/dist/components/ui/core/switch/switch.d.ts +11 -0
- package/dist/components/ui/core/{button/button.metadata.d.ts → switch/switch.metadata.d.ts} +1 -1
- package/dist/components/ui/core/tabs/tabs.d.ts +27 -0
- package/dist/components/ui/core/tabs/tabs.js +224 -0
- package/dist/components/ui/core/tabs/tabs.utils.d.ts +2 -0
- package/dist/components/ui/core/tabs/tabs.utils.js +9 -0
- package/dist/components/ui/core/textarea/textarea.d.ts +2 -1
- package/dist/components/ui/core/textarea/textarea.js +20 -18
- package/dist/components/ui/core/tool/tool.d.ts +7 -6
- package/dist/components/ui/core/tool/tool.js +48 -44
- package/dist/components/ui/core/tooltip/tooltip.d.ts +6 -5
- package/dist/components/ui/core/tooltip/tooltip.js +10 -8
- package/dist/components/ui/core/topbar/topbar.d.ts +28 -0
- package/dist/components/ui/core/topbar/topbar.js +190 -0
- package/dist/eslint/index.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +298 -273
- package/dist/lib/portal-container-context.d.ts +2 -1
- package/dist/lib/portal-container-context.js +1 -3
- package/dist/lib/utils.d.ts +11 -0
- package/dist/lib/utils.js +40 -29
- package/dist/styles.css +1 -1
- package/dist/styles.source.css +75 -8
- package/package.json +26 -5
- package/dist/components/ui/core/accordion/accordion.metadata.d.ts +0 -2
- package/dist/components/ui/core/accordion/accordion.metadata.js +0 -9
- package/dist/components/ui/core/alert/alert.metadata.d.ts +0 -2
- package/dist/components/ui/core/alert/alert.metadata.js +0 -9
- package/dist/components/ui/core/avatar/avatar.metadata.d.ts +0 -8
- package/dist/components/ui/core/avatar/avatar.metadata.js +0 -9
- package/dist/components/ui/core/badge/badge.metadata.js +0 -8
- package/dist/components/ui/core/banner/banner.metadata.d.ts +0 -2
- package/dist/components/ui/core/banner/banner.metadata.js +0 -9
- package/dist/components/ui/core/button/button.metadata.js +0 -9
- package/dist/components/ui/core/button-group/button-group.metadata.d.ts +0 -2
- package/dist/components/ui/core/button-group/button-group.metadata.js +0 -8
- package/dist/components/ui/core/card/card.metadata.d.ts +0 -8
- package/dist/components/ui/core/card/card.metadata.js +0 -9
- package/dist/components/ui/core/code-block/code-block.metadata.d.ts +0 -2
- package/dist/components/ui/core/code-block/code-block.metadata.js +0 -8
- package/dist/components/ui/core/collapsible/collapsible.metadata.d.ts +0 -2
- package/dist/components/ui/core/collapsible/collapsible.metadata.js +0 -9
- package/dist/components/ui/core/combobox/combobox.metadata.d.ts +0 -2
- package/dist/components/ui/core/command/command.metadata.d.ts +0 -2
- package/dist/components/ui/core/command/command.metadata.js +0 -9
- package/dist/components/ui/core/dialog/dialog.metadata.d.ts +0 -2
- package/dist/components/ui/core/dialog/dialog.metadata.js +0 -9
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.metadata.d.ts +0 -2
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.metadata.js +0 -9
- package/dist/components/ui/core/helper-text/helper-text.metadata.d.ts +0 -2
- package/dist/components/ui/core/helper-text/helper-text.metadata.js +0 -9
- package/dist/components/ui/core/hover-card/hover-card.metadata.d.ts +0 -2
- package/dist/components/ui/core/hover-card/hover-card.metadata.js +0 -8
- package/dist/components/ui/core/inline-citation/inline-citation.metadata.d.ts +0 -2
- package/dist/components/ui/core/inline-citation/inline-citation.metadata.js +0 -8
- package/dist/components/ui/core/input/input.metadata.d.ts +0 -2
- package/dist/components/ui/core/input/input.metadata.js +0 -9
- package/dist/components/ui/core/input-group/input-group.metadata.d.ts +0 -2
- package/dist/components/ui/core/input-group/input-group.metadata.js +0 -9
- package/dist/components/ui/core/label/label.metadata.d.ts +0 -2
- package/dist/components/ui/core/label/label.metadata.js +0 -9
- package/dist/components/ui/core/loader/loader.metadata.d.ts +0 -2
- package/dist/components/ui/core/loader/loader.metadata.js +0 -9
- package/dist/components/ui/core/message/message.metadata.d.ts +0 -2
- package/dist/components/ui/core/popover/popover.metadata.d.ts +0 -2
- package/dist/components/ui/core/popover/popover.metadata.js +0 -9
- package/dist/components/ui/core/progress/progress.metadata.d.ts +0 -2
- package/dist/components/ui/core/progress/progress.metadata.js +0 -9
- package/dist/components/ui/core/prompt-input/prompt-input.metadata.d.ts +0 -2
- package/dist/components/ui/core/prompt-input/prompt-input.metadata.js +0 -9
- package/dist/components/ui/core/reasoning/reasoning.metadata.d.ts +0 -2
- package/dist/components/ui/core/reasoning/reasoning.metadata.js +0 -8
- package/dist/components/ui/core/scroll-area/scroll-area.metadata.d.ts +0 -2
- package/dist/components/ui/core/scroll-area/scroll-area.metadata.js +0 -9
- package/dist/components/ui/core/select/select.metadata.d.ts +0 -2
- package/dist/components/ui/core/select/select.metadata.js +0 -9
- package/dist/components/ui/core/separator/separator.metadata.d.ts +0 -2
- package/dist/components/ui/core/separator/separator.metadata.js +0 -8
- package/dist/components/ui/core/shimmer/shimmer.metadata.d.ts +0 -2
- package/dist/components/ui/core/shimmer/shimmer.metadata.js +0 -9
- package/dist/components/ui/core/skeleton/skeleton.metadata.d.ts +0 -2
- package/dist/components/ui/core/skeleton/skeleton.metadata.js +0 -9
- package/dist/components/ui/core/sources/sources.metadata.d.ts +0 -2
- package/dist/components/ui/core/textarea/textarea.metadata.d.ts +0 -2
- package/dist/components/ui/core/textarea/textarea.metadata.js +0 -9
- package/dist/components/ui/core/tool/tool.metadata.d.ts +0 -2
- package/dist/components/ui/core/tool/tool.metadata.js +0 -8
- package/dist/components/ui/core/tooltip/tooltip.metadata.d.ts +0 -8
- package/dist/components/ui/core/tooltip/tooltip.metadata.js +0 -9
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ComponentProps, CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { ResponsiveContainer, Tooltip, Legend } from 'recharts';
|
|
3
|
+
export type ChartConfig = {
|
|
4
|
+
[k in string]: {
|
|
5
|
+
label?: ReactNode;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
/** A CSS color or `var(--token)`. Use a token for light/dark theming. */
|
|
8
|
+
color?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
declare function colorVarsFromConfig(config: ChartConfig): CSSProperties;
|
|
12
|
+
type ChartA11yProps = {
|
|
13
|
+
'aria-label': string;
|
|
14
|
+
'aria-labelledby'?: never;
|
|
15
|
+
} | {
|
|
16
|
+
'aria-labelledby': string;
|
|
17
|
+
'aria-label'?: never;
|
|
18
|
+
};
|
|
19
|
+
type ChartContainerProps = Omit<ComponentProps<'div'>, 'aria-label' | 'aria-labelledby'> & ChartA11yProps & {
|
|
20
|
+
config: ChartConfig;
|
|
21
|
+
children: ComponentProps<typeof ResponsiveContainer>['children'];
|
|
22
|
+
};
|
|
23
|
+
declare function ChartContainer({ id, className, children, config, style, role, ...props }: ChartContainerProps): ReactNode;
|
|
24
|
+
declare const ChartTooltip: typeof Tooltip;
|
|
25
|
+
type TooltipPayloadItem = {
|
|
26
|
+
type?: string;
|
|
27
|
+
name?: string | number;
|
|
28
|
+
dataKey?: string | number;
|
|
29
|
+
value?: string | number;
|
|
30
|
+
color?: string;
|
|
31
|
+
payload?: Record<string, unknown>;
|
|
32
|
+
fill?: string;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
};
|
|
35
|
+
type ChartTooltipContentProps = Omit<ComponentProps<typeof Tooltip>, 'content' | 'formatter' | 'labelFormatter'> & {
|
|
36
|
+
className?: string;
|
|
37
|
+
labelClassName?: string;
|
|
38
|
+
hideLabel?: boolean;
|
|
39
|
+
hideIndicator?: boolean;
|
|
40
|
+
indicator?: 'line' | 'dot' | 'dashed';
|
|
41
|
+
nameKey?: string;
|
|
42
|
+
labelKey?: string;
|
|
43
|
+
payload?: TooltipPayloadItem[];
|
|
44
|
+
label?: string | number;
|
|
45
|
+
color?: string;
|
|
46
|
+
formatter?: (value: string | number, name: string | number, item: TooltipPayloadItem, index: number, payload: Record<string, unknown> | undefined) => ReactNode;
|
|
47
|
+
labelFormatter?: (value: ReactNode, payload: TooltipPayloadItem[]) => ReactNode;
|
|
48
|
+
/** Pass an i18n-aware formatter from your app's locale; defaults to the environment locale. */
|
|
49
|
+
valueFormatter?: (value: string | number) => string;
|
|
50
|
+
};
|
|
51
|
+
declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, valueFormatter, }: ChartTooltipContentProps): ReactNode;
|
|
52
|
+
declare const ChartLegend: typeof Legend;
|
|
53
|
+
type LegendPayloadItem = {
|
|
54
|
+
type?: string;
|
|
55
|
+
value?: string;
|
|
56
|
+
dataKey?: string | number;
|
|
57
|
+
color?: string;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
type ChartLegendContentProps = {
|
|
61
|
+
className?: string;
|
|
62
|
+
hideIcon?: boolean;
|
|
63
|
+
nameKey?: string;
|
|
64
|
+
payload?: LegendPayloadItem[];
|
|
65
|
+
verticalAlign?: 'top' | 'bottom' | 'middle';
|
|
66
|
+
};
|
|
67
|
+
declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, nameKey, }: ChartLegendContentProps): ReactNode;
|
|
68
|
+
declare function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string): ChartConfig[string] | undefined;
|
|
69
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, colorVarsFromConfig, getPayloadConfigFromPayload, };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { jsx as a, jsxs as g, Fragment as L } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as O, createContext as K, useContext as Y } from "react";
|
|
3
|
+
import { Legend as $, Tooltip as D, ResponsiveContainer as M } from "recharts";
|
|
4
|
+
import { cn as i } from "../../../../lib/utils.js";
|
|
5
|
+
function S(e) {
|
|
6
|
+
if (!e)
|
|
7
|
+
return;
|
|
8
|
+
const r = e.trim();
|
|
9
|
+
return { backgroundColor: r, borderColor: r };
|
|
10
|
+
}
|
|
11
|
+
const V = K(null);
|
|
12
|
+
function j() {
|
|
13
|
+
const e = Y(V);
|
|
14
|
+
if (!e)
|
|
15
|
+
throw new Error("useChart must be used within a <ChartContainer>");
|
|
16
|
+
return e;
|
|
17
|
+
}
|
|
18
|
+
function R(e) {
|
|
19
|
+
const r = {};
|
|
20
|
+
for (const [s, n] of Object.entries(e))
|
|
21
|
+
n.color && (r[`--color-${s}`] = n.color);
|
|
22
|
+
return r;
|
|
23
|
+
}
|
|
24
|
+
function Q({
|
|
25
|
+
id: e,
|
|
26
|
+
className: r,
|
|
27
|
+
children: s,
|
|
28
|
+
config: n,
|
|
29
|
+
style: d,
|
|
30
|
+
role: c = "img",
|
|
31
|
+
...o
|
|
32
|
+
}) {
|
|
33
|
+
const l = O(() => ({ config: n }), [n]), f = R(n);
|
|
34
|
+
return /* @__PURE__ */ a(V.Provider, { value: l, children: /* @__PURE__ */ a(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
role: c,
|
|
38
|
+
"data-slot": "chart",
|
|
39
|
+
"data-chart-id": e,
|
|
40
|
+
className: i(
|
|
41
|
+
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-chart-gridlines [&_.recharts-curve.recharts-tooltip-cursor]:stroke-chart-gridlines [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-chart-gridlines [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-chart-gridlines 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",
|
|
42
|
+
r
|
|
43
|
+
),
|
|
44
|
+
style: { ...f, ...d },
|
|
45
|
+
...o,
|
|
46
|
+
children: /* @__PURE__ */ a(M, { children: s })
|
|
47
|
+
}
|
|
48
|
+
) });
|
|
49
|
+
}
|
|
50
|
+
const U = D, G = [], H = (e) => typeof e == "number" ? e.toLocaleString() : String(e);
|
|
51
|
+
function W({
|
|
52
|
+
active: e,
|
|
53
|
+
payload: r = G,
|
|
54
|
+
className: s,
|
|
55
|
+
indicator: n = "dot",
|
|
56
|
+
hideLabel: d = !1,
|
|
57
|
+
hideIndicator: c = !1,
|
|
58
|
+
label: o,
|
|
59
|
+
labelFormatter: l,
|
|
60
|
+
labelClassName: f,
|
|
61
|
+
formatter: h,
|
|
62
|
+
color: y,
|
|
63
|
+
nameKey: T,
|
|
64
|
+
labelKey: _,
|
|
65
|
+
valueFormatter: A = H
|
|
66
|
+
}) {
|
|
67
|
+
const { config: x } = j(), k = (() => {
|
|
68
|
+
if (d || !r?.length)
|
|
69
|
+
return null;
|
|
70
|
+
const [t] = r, v = `${_ ?? t?.dataKey ?? t?.name ?? "value"}`, C = b(x, t, v), u = !_ && typeof o == "string" ? x[o]?.label ?? o : C?.label;
|
|
71
|
+
return l ? /* @__PURE__ */ a("div", { className: i("font-medium", f), children: l(u, r) }) : u ? /* @__PURE__ */ a("div", { className: i("font-medium", f), children: u }) : null;
|
|
72
|
+
})(), w = !e || !r.length, p = r.length === 1 && n !== "dot";
|
|
73
|
+
return /* @__PURE__ */ a(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
className: i(
|
|
77
|
+
"bg-popover-background grid min-w-32 items-start gap-1 rounded-md p-2 text-sm shadow-md",
|
|
78
|
+
w && "invisible",
|
|
79
|
+
s
|
|
80
|
+
),
|
|
81
|
+
children: w ? null : /* @__PURE__ */ g(L, { children: [
|
|
82
|
+
p ? null : k,
|
|
83
|
+
/* @__PURE__ */ a("div", { className: "grid gap-1.5", children: r.filter((t) => t.type !== "none").map((t, v) => {
|
|
84
|
+
const C = `${T ?? t.name ?? t.dataKey ?? "value"}`, u = b(
|
|
85
|
+
x,
|
|
86
|
+
t,
|
|
87
|
+
C
|
|
88
|
+
), E = m(t.payload) && typeof t.payload.fill == "string" ? t.payload.fill : void 0, N = y ?? E ?? t.color, F = S(
|
|
89
|
+
typeof N == "string" ? N : void 0
|
|
90
|
+
);
|
|
91
|
+
return /* @__PURE__ */ a(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
className: i(
|
|
95
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
96
|
+
n === "dot" && "items-center"
|
|
97
|
+
),
|
|
98
|
+
children: h && t.value != null && t.name != null ? h(
|
|
99
|
+
t.value,
|
|
100
|
+
t.name,
|
|
101
|
+
t,
|
|
102
|
+
v,
|
|
103
|
+
m(t.payload) ? t.payload : void 0
|
|
104
|
+
) : /* @__PURE__ */ g(L, { children: [
|
|
105
|
+
u?.icon ? u.icon : !c && /* @__PURE__ */ a(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
className: i("shrink-0 rounded-xs", {
|
|
109
|
+
"h-2 w-2": n === "dot",
|
|
110
|
+
"w-1": n === "line",
|
|
111
|
+
"w-0 border border-dashed bg-transparent": n === "dashed",
|
|
112
|
+
"my-0.5": p && n === "dashed"
|
|
113
|
+
}),
|
|
114
|
+
style: F
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ g(
|
|
118
|
+
"div",
|
|
119
|
+
{
|
|
120
|
+
className: i(
|
|
121
|
+
"flex flex-1 justify-between gap-4 leading-none",
|
|
122
|
+
p ? "items-end" : "items-center"
|
|
123
|
+
),
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ g("div", { className: "grid gap-1", children: [
|
|
126
|
+
p ? k : null,
|
|
127
|
+
/* @__PURE__ */ a("span", { className: "text-muted-foreground", children: u?.label ?? t.name })
|
|
128
|
+
] }),
|
|
129
|
+
t.value !== void 0 && t.value !== null && /* @__PURE__ */ a("span", { className: "text-foreground tabular-nums", children: A(t.value) })
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
] })
|
|
134
|
+
},
|
|
135
|
+
t.dataKey ?? v
|
|
136
|
+
);
|
|
137
|
+
}) })
|
|
138
|
+
] })
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
const X = $, I = [];
|
|
143
|
+
function Z({
|
|
144
|
+
className: e,
|
|
145
|
+
hideIcon: r = !1,
|
|
146
|
+
payload: s = I,
|
|
147
|
+
verticalAlign: n = "bottom",
|
|
148
|
+
nameKey: d
|
|
149
|
+
}) {
|
|
150
|
+
const { config: c } = j();
|
|
151
|
+
return s?.length ? /* @__PURE__ */ a(
|
|
152
|
+
"div",
|
|
153
|
+
{
|
|
154
|
+
className: i(
|
|
155
|
+
"flex items-center justify-center gap-4",
|
|
156
|
+
n === "top" ? "pb-3" : "pt-3",
|
|
157
|
+
e
|
|
158
|
+
),
|
|
159
|
+
children: s.filter((o) => o.type !== "none").map((o, l) => {
|
|
160
|
+
const f = `${d ?? o.dataKey ?? "value"}`, h = b(c, o, f), y = S(
|
|
161
|
+
typeof o.color == "string" ? o.color : void 0
|
|
162
|
+
);
|
|
163
|
+
return /* @__PURE__ */ g(
|
|
164
|
+
"div",
|
|
165
|
+
{
|
|
166
|
+
className: i(
|
|
167
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
|
|
168
|
+
),
|
|
169
|
+
children: [
|
|
170
|
+
h?.icon && !r ? h.icon : /* @__PURE__ */ a(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
className: "h-2 w-2 shrink-0 rounded-xs",
|
|
174
|
+
style: y
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
h?.label ?? o.value
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
o.value ?? l
|
|
181
|
+
);
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
) : null;
|
|
185
|
+
}
|
|
186
|
+
function b(e, r, s) {
|
|
187
|
+
if (!m(r))
|
|
188
|
+
return;
|
|
189
|
+
const n = r, d = m(n.payload) ? n.payload : void 0;
|
|
190
|
+
let c = s;
|
|
191
|
+
const o = P(n, s);
|
|
192
|
+
if (o)
|
|
193
|
+
c = o;
|
|
194
|
+
else {
|
|
195
|
+
const l = d ? P(d, s) : void 0;
|
|
196
|
+
l && (c = l);
|
|
197
|
+
}
|
|
198
|
+
return e[c] ?? e[s];
|
|
199
|
+
}
|
|
200
|
+
function m(e) {
|
|
201
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
202
|
+
}
|
|
203
|
+
function P(e, r) {
|
|
204
|
+
const s = e[r];
|
|
205
|
+
return typeof s == "string" ? s : void 0;
|
|
206
|
+
}
|
|
207
|
+
export {
|
|
208
|
+
Q as ChartContainer,
|
|
209
|
+
X as ChartLegend,
|
|
210
|
+
Z as ChartLegendContent,
|
|
211
|
+
U as ChartTooltip,
|
|
212
|
+
W as ChartTooltipContent,
|
|
213
|
+
R as colorVarsFromConfig,
|
|
214
|
+
b as getPayloadConfigFromPayload
|
|
215
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChartContainer as e, ChartLegend as n, ChartLegendContent as r, ChartTooltip as C, ChartTooltipContent as a } from "./chart.js";
|
|
2
|
+
export {
|
|
3
|
+
e as ChartContainer,
|
|
4
|
+
n as ChartLegend,
|
|
5
|
+
r as ChartLegendContent,
|
|
6
|
+
C as ChartTooltip,
|
|
7
|
+
a as ChartTooltipContent
|
|
8
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes, HTMLAttributes } from 'react';
|
|
2
|
+
import { CheckboxRootProps } from '@base-ui/react/checkbox';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
import { ClassProp } from 'class-variance-authority/types';
|
|
5
|
+
type Orientation = 'horizontal' | 'vertical';
|
|
6
|
+
declare const CheckboxGroup: ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
7
|
+
orientation?: Orientation;
|
|
8
|
+
} & RefAttributes<HTMLDivElement>>;
|
|
9
|
+
interface CheckboxItemVariantProps {
|
|
10
|
+
variant?: 'default' | 'card' | null;
|
|
11
|
+
}
|
|
12
|
+
declare const checkboxItemVariants: (props?: (CheckboxItemVariantProps & ClassProp) | undefined) => string;
|
|
13
|
+
declare const CheckboxItem: ForwardRefExoticComponent<HTMLAttributes<HTMLLabelElement> & VariantProps<typeof checkboxItemVariants> & RefAttributes<HTMLLabelElement>>;
|
|
14
|
+
declare const CheckboxItemControl: ForwardRefExoticComponent<Omit<CheckboxRootProps, 'ref'> & RefAttributes<HTMLElement>>;
|
|
15
|
+
declare const CheckboxItemLabel: ForwardRefExoticComponent<HTMLAttributes<HTMLSpanElement> & RefAttributes<HTMLSpanElement>>;
|
|
16
|
+
declare const CheckboxItemDescription: ForwardRefExoticComponent<HTMLAttributes<HTMLSpanElement> & RefAttributes<HTMLSpanElement>>;
|
|
17
|
+
export { CheckboxGroup, CheckboxItem, CheckboxItemControl, CheckboxItemDescription, CheckboxItemLabel, };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as r } from "react";
|
|
3
|
+
import { Checkbox as i } from "@base-ui/react/checkbox";
|
|
4
|
+
import { IconCheck as l, IconMinus as b } from "@tabler/icons-react";
|
|
5
|
+
import { cva as m } from "class-variance-authority";
|
|
6
|
+
import { cn as d, invalidState as h, focusState as k, selectionItemDescription as u, selectionItemLabel as x, selectionItemBase as p, selectionItemCard as g, selectionItemDefault as f } from "../../../../lib/utils.js";
|
|
7
|
+
const I = r(
|
|
8
|
+
({ className: a, orientation: e = "vertical", role: t = "group", ...c }, n) => /* @__PURE__ */ o(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
ref: n,
|
|
12
|
+
role: t,
|
|
13
|
+
"data-slot": "checkbox-group",
|
|
14
|
+
"data-orientation": e,
|
|
15
|
+
className: d(
|
|
16
|
+
e === "horizontal" ? "flex items-center gap-2" : "grid has-[[data-variant=card]]:gap-2",
|
|
17
|
+
a
|
|
18
|
+
),
|
|
19
|
+
...c
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
I.displayName = "CheckboxGroup";
|
|
24
|
+
const C = m(d("group/checkbox-item", p), {
|
|
25
|
+
variants: {
|
|
26
|
+
variant: {
|
|
27
|
+
default: f,
|
|
28
|
+
card: g
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
variant: "default"
|
|
33
|
+
}
|
|
34
|
+
}), v = r(
|
|
35
|
+
({ className: a, variant: e, ...t }, c) => /* @__PURE__ */ o(
|
|
36
|
+
"label",
|
|
37
|
+
{
|
|
38
|
+
ref: c,
|
|
39
|
+
"data-slot": "checkbox-item",
|
|
40
|
+
"data-variant": e ?? "default",
|
|
41
|
+
className: d(C({ variant: e }), a),
|
|
42
|
+
...t
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
v.displayName = "CheckboxItem";
|
|
47
|
+
const N = r(({ className: a, ...e }, t) => /* @__PURE__ */ o(
|
|
48
|
+
i.Root,
|
|
49
|
+
{
|
|
50
|
+
ref: t,
|
|
51
|
+
"data-slot": "checkbox-item-control",
|
|
52
|
+
className: d(
|
|
53
|
+
"peer relative size-4 shrink-0 rounded-sm border-[1.5px] border-inactive-foreground bg-transparent text-foreground-on-primary outline-none transition-colors",
|
|
54
|
+
"[&:is([data-checked],[data-indeterminate]):not([data-disabled])]:border-transparent [&:is([data-checked],[data-indeterminate]):not([data-disabled])]:bg-primary-background",
|
|
55
|
+
"data-unchecked:not-data-disabled:hover:border-secondary-foreground group-hover/checkbox-item:data-unchecked:not-data-disabled:border-secondary-foreground",
|
|
56
|
+
"data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:border-transparent data-disabled:bg-disabled-background data-disabled:text-disabled-foreground data-disabled:data-unchecked:border-border",
|
|
57
|
+
"[&[data-checked]_[data-slot=checkbox-check]]:block [&[data-indeterminate]_[data-slot=checkbox-dash]]:block",
|
|
58
|
+
k,
|
|
59
|
+
h,
|
|
60
|
+
a
|
|
61
|
+
),
|
|
62
|
+
...e,
|
|
63
|
+
children: /* @__PURE__ */ s(
|
|
64
|
+
i.Indicator,
|
|
65
|
+
{
|
|
66
|
+
"data-slot": "checkbox-indicator",
|
|
67
|
+
className: "grid size-full place-content-center text-current transition-none",
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ o(
|
|
70
|
+
l,
|
|
71
|
+
{
|
|
72
|
+
"aria-hidden": "true",
|
|
73
|
+
"data-slot": "checkbox-check",
|
|
74
|
+
className: "hidden size-3",
|
|
75
|
+
stroke: 3
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ o(
|
|
79
|
+
b,
|
|
80
|
+
{
|
|
81
|
+
"aria-hidden": "true",
|
|
82
|
+
"data-slot": "checkbox-dash",
|
|
83
|
+
className: "hidden size-3",
|
|
84
|
+
stroke: 3.5
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
));
|
|
92
|
+
N.displayName = "CheckboxItemControl";
|
|
93
|
+
const y = r(
|
|
94
|
+
({ className: a, ...e }, t) => /* @__PURE__ */ o(
|
|
95
|
+
"span",
|
|
96
|
+
{
|
|
97
|
+
ref: t,
|
|
98
|
+
"data-slot": "checkbox-item-label",
|
|
99
|
+
className: d(
|
|
100
|
+
x,
|
|
101
|
+
"group-has-[[data-checked]]/checkbox-item:text-foreground",
|
|
102
|
+
"group-has-[[data-indeterminate]]/checkbox-item:text-foreground",
|
|
103
|
+
"group-has-[[data-disabled]]/checkbox-item:text-disabled-foreground",
|
|
104
|
+
a
|
|
105
|
+
),
|
|
106
|
+
...e
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
y.displayName = "CheckboxItemLabel";
|
|
111
|
+
const z = r(
|
|
112
|
+
({ className: a, ...e }, t) => /* @__PURE__ */ o(
|
|
113
|
+
"span",
|
|
114
|
+
{
|
|
115
|
+
ref: t,
|
|
116
|
+
"data-slot": "checkbox-item-description",
|
|
117
|
+
className: d(
|
|
118
|
+
u,
|
|
119
|
+
"group-has-[[data-disabled]]/checkbox-item:text-disabled-foreground",
|
|
120
|
+
a
|
|
121
|
+
),
|
|
122
|
+
...e
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
z.displayName = "CheckboxItemDescription";
|
|
127
|
+
export {
|
|
128
|
+
I as CheckboxGroup,
|
|
129
|
+
v as CheckboxItem,
|
|
130
|
+
N as CheckboxItemControl,
|
|
131
|
+
z as CheckboxItemDescription,
|
|
132
|
+
y as CheckboxItemLabel
|
|
133
|
+
};
|
package/dist/components/ui/core/{badge/badge.metadata.d.ts → checkbox/checkbox.metadata.d.ts}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ComponentMeta } from '../../../../lib/types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const CheckboxMetadata: ComponentMeta;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
name: "Checkbox",
|
|
3
|
+
description: "A composable checkbox group with optional label and description slots, including a card-style item variant and support for checked, unchecked, and indeterminate states.",
|
|
4
|
+
llmUsage: 'Use `<CheckboxGroup>` with `<CheckboxItem>` wrapping `<CheckboxItemControl />`, plus optional `<CheckboxItemLabel>` and `<CheckboxItemDescription>`. Always pass an accessible name on `<CheckboxItemControl>` via `aria-label` (or `aria-labelledby` pointing to the label\'s id) — the wrapping `<label>` element names the underlying hidden form input, but does not name the visible `role="checkbox"` element that screen readers focus on. `<CheckboxItemDescription>` is a visual slot at this primitive layer; if you need it announced by screen readers, give it an `id` and pass `aria-describedby` to `<CheckboxItemControl>`. Use `variant="card"` on `<CheckboxItem>` for card-style options. `<CheckboxItemControl>` supports `checked`, `defaultChecked`, `indeterminate`, `onCheckedChange`, `disabled`, and `required` for form integration.'
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
e as CheckboxMetadata
|
|
8
|
+
};
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import { ComponentProps, HTMLAttributes } from 'react';
|
|
1
|
+
import { ComponentProps, ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from 'react';
|
|
2
2
|
import { BundledLanguage } from 'shiki';
|
|
3
3
|
import { Button } from '../button/button';
|
|
4
4
|
export declare function getCollapsedPreviewDisplay(code: string): string;
|
|
5
5
|
export declare function isContentLargerThanPreview(code: string): boolean;
|
|
6
6
|
export declare function shouldUsePlainTextInsteadOfShiki(code: string, lineCount: number): boolean;
|
|
7
7
|
export declare function plainPreMarkup(code: string): string;
|
|
8
|
-
declare const CodeBlock:
|
|
8
|
+
declare const CodeBlock: ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
9
9
|
code: string;
|
|
10
10
|
copyText?: string;
|
|
11
11
|
collapsed?: boolean;
|
|
12
12
|
language: BundledLanguage;
|
|
13
13
|
showLineNumbers?: boolean;
|
|
14
|
-
} &
|
|
14
|
+
} & RefAttributes<HTMLDivElement>>;
|
|
15
15
|
type CodeBlockCopyButtonProps = ComponentProps<typeof Button> & {
|
|
16
16
|
onCopy?: () => void;
|
|
17
17
|
onError?: (error: Error) => void;
|
|
18
18
|
timeout?: number;
|
|
19
19
|
};
|
|
20
|
-
declare const CodeBlockCopyButton:
|
|
21
|
-
declare const CodeBlockCollapseButton:
|
|
22
|
-
variant?: "default" | "secondary" | "outline" | "ghost" | "destructive" | null | undefined;
|
|
23
|
-
size?: "icon" | "default" | "sm" | "lg" | "icon-sm" | "icon-lg" | null | undefined;
|
|
24
|
-
} & import('class-variance-authority/types').ClassProp) | undefined) => string>, "ref"> & import('react').RefAttributes<HTMLElement>, "ref"> & import('react').RefAttributes<HTMLElement>>;
|
|
20
|
+
declare const CodeBlockCopyButton: ForwardRefExoticComponent<Omit<CodeBlockCopyButtonProps, 'ref'> & RefAttributes<HTMLElement>>;
|
|
21
|
+
declare const CodeBlockCollapseButton: ForwardRefExoticComponent<Omit<ComponentProps<typeof Button>, 'ref'> & RefAttributes<HTMLElement>>;
|
|
25
22
|
type CodeBlockDownloadButtonProps = ComponentProps<typeof Button> & {
|
|
26
23
|
fileName?: string;
|
|
27
24
|
mimeType?: string;
|
|
28
25
|
onDownload?: () => void;
|
|
29
26
|
onError?: (error: Error) => void;
|
|
30
27
|
};
|
|
31
|
-
declare const CodeBlockDownloadButton:
|
|
28
|
+
declare const CodeBlockDownloadButton: ForwardRefExoticComponent<Omit<CodeBlockDownloadButtonProps, 'ref'> & RefAttributes<HTMLElement>>;
|
|
32
29
|
export { CodeBlock, CodeBlockCollapseButton, CodeBlockCopyButton, CodeBlockDownloadButton, };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as L, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { forwardRef as w, useState as x, useMemo as D, useEffect as F, useContext as H, createContext as O } from "react";
|
|
3
|
+
import { IconSelector as K, IconCheck as V, IconCopy as $, IconDownload as q } from "@tabler/icons-react";
|
|
4
4
|
import { isStorybookTestEnv as v, highlightCode as M, cn as f } from "../../../../lib/utils.js";
|
|
5
5
|
import { Button as S } from "../button/button.js";
|
|
6
|
-
const I =
|
|
6
|
+
const I = O({
|
|
7
7
|
code: "",
|
|
8
8
|
copyText: "",
|
|
9
9
|
isCollapsed: !1,
|
|
@@ -48,7 +48,7 @@ const ee = "min(60vh, 32rem)", oe = "dark:hidden [&>pre]:m-0 [&>pre]:min-h-10 [&
|
|
|
48
48
|
() => v ? `<pre><code>${P(s)}</code></pre>` : "",
|
|
49
49
|
[s]
|
|
50
50
|
);
|
|
51
|
-
|
|
51
|
+
F(() => {
|
|
52
52
|
if (v) return;
|
|
53
53
|
let g = !1;
|
|
54
54
|
const B = (u) => {
|
|
@@ -169,51 +169,55 @@ const ee = "min(60vh, 32rem)", oe = "dark:hidden [&>pre]:m-0 [&>pre]:min-h-10 [&
|
|
|
169
169
|
}
|
|
170
170
|
);
|
|
171
171
|
ne.displayName = "CodeBlock";
|
|
172
|
-
const re = w(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
172
|
+
const re = w(
|
|
173
|
+
({ onCopy: e, onError: t, timeout: n = 2e3, children: o, className: a, ...h }, i) => {
|
|
174
|
+
const [C, k] = x(!1), { copyText: b } = H(I), d = async () => {
|
|
175
|
+
if (typeof window > "u" || !navigator?.clipboard?.writeText) {
|
|
176
|
+
t?.(new Error("Clipboard API not available"));
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
await navigator.clipboard.writeText(b), k(!0), e?.(), setTimeout(() => k(!1), n);
|
|
181
|
+
} catch (c) {
|
|
182
|
+
console.warn("Clipboard write failed:", c), t?.(
|
|
183
|
+
c instanceof Error ? c : new Error("Clipboard write failed")
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}, p = C ? V : $;
|
|
187
|
+
return /* @__PURE__ */ r(
|
|
188
|
+
S,
|
|
189
|
+
{
|
|
190
|
+
ref: i,
|
|
191
|
+
"data-slot": "code-block-copy-button",
|
|
192
|
+
className: f("shrink-0", a),
|
|
193
|
+
onClick: d,
|
|
194
|
+
size: "icon-sm",
|
|
195
|
+
variant: "secondary",
|
|
196
|
+
...h,
|
|
197
|
+
children: o ?? /* @__PURE__ */ r(p, { size: 14 })
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
);
|
|
200
202
|
re.displayName = "CodeBlockCopyButton";
|
|
201
|
-
const le = w(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
203
|
+
const le = w(
|
|
204
|
+
({ children: e, className: t, ...n }, o) => {
|
|
205
|
+
const { isCollapsed: a, setIsCollapsed: h, lineCount: i } = H(I);
|
|
206
|
+
return i <= 1 ? null : /* @__PURE__ */ r(
|
|
207
|
+
S,
|
|
208
|
+
{
|
|
209
|
+
ref: o,
|
|
210
|
+
"data-slot": "code-block-collapse-button",
|
|
211
|
+
className: f("shrink-0", t),
|
|
212
|
+
onClick: () => h(!a),
|
|
213
|
+
size: "icon-sm",
|
|
214
|
+
variant: "secondary",
|
|
215
|
+
...n,
|
|
216
|
+
children: e ?? /* @__PURE__ */ r(K, { size: 14 })
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
);
|
|
217
221
|
le.displayName = "CodeBlockCollapseButton";
|
|
218
222
|
const ae = w(
|
|
219
223
|
({
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
import { CollapsiblePanelProps, CollapsibleRootProps, CollapsibleTriggerProps } from '@base-ui/react/collapsible';
|
|
3
|
+
declare const Collapsible: ForwardRefExoticComponent<Omit<CollapsibleRootProps, 'ref'> & RefAttributes<HTMLDivElement>>;
|
|
4
|
+
declare const CollapsibleTrigger: ForwardRefExoticComponent<Omit<CollapsibleTriggerProps, 'ref'> & RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
declare const CollapsibleContent: ForwardRefExoticComponent<Omit<CollapsiblePanelProps, 'ref'> & RefAttributes<HTMLDivElement>>;
|
|
4
6
|
export { Collapsible, CollapsibleContent, CollapsibleTrigger };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes, ComponentProps } from 'react';
|
|
2
2
|
import { Button } from '../button/button';
|
|
3
3
|
type ComboboxProps = Omit<ComponentProps<typeof Button>, 'value' | 'onChange'> & {
|
|
4
4
|
options: Array<{
|
|
@@ -11,5 +11,5 @@ type ComboboxProps = Omit<ComponentProps<typeof Button>, 'value' | 'onChange'> &
|
|
|
11
11
|
searchPlaceholder?: string;
|
|
12
12
|
emptyText?: string;
|
|
13
13
|
};
|
|
14
|
-
declare const Combobox:
|
|
14
|
+
declare const Combobox: ForwardRefExoticComponent<Omit<ComboboxProps, 'ref'> & RefAttributes<HTMLElement>>;
|
|
15
15
|
export { Combobox };
|