flikkui 0.2.0-beta.1 → 0.2.0-beta.4
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 +12 -539
- package/dist/components/ai/PromptInput/PromptInput.js +94 -4
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.d.ts +27 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.js +62 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.theme.d.ts +10 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.theme.js +12 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.types.d.ts +53 -0
- package/dist/components/ai/PromptSuggestions/index.d.ts +4 -2
- package/dist/components/ai/index.d.ts +2 -12
- package/dist/components/charts/ActivityRings/ActivityRings.js +70 -58
- package/dist/components/charts/ActivityRings/ActivityRings.theme.js +0 -1
- package/dist/components/charts/ActivityRings/ActivityRings.types.d.ts +17 -0
- package/dist/components/charts/BarChart/BarChart.js +8 -4
- package/dist/components/charts/BarChart/BarChart.types.d.ts +14 -0
- package/dist/components/charts/DonutChart/DonutChart.js +11 -8
- package/dist/components/charts/DonutChart/DonutChart.theme.d.ts +3 -0
- package/dist/components/charts/DonutChart/DonutChart.theme.js +5 -4
- package/dist/components/charts/DonutChart/donut-utils.d.ts +5 -0
- package/dist/components/charts/DonutChart/donut-utils.js +26 -1
- package/dist/components/charts/Heatmap/Heatmap.theme.js +2 -2
- package/dist/components/charts/shared/ChartAxis/XAxis.d.ts +2 -2
- package/dist/components/charts/shared/ChartAxis/XAxis.js +4 -4
- package/dist/components/charts/shared/ChartAxis/YAxis.d.ts +2 -2
- package/dist/components/charts/shared/ChartAxis/YAxis.js +8 -7
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.d.ts +1 -1
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.js +2 -2
- package/dist/components/charts/theme/chart.theme.d.ts +1 -1
- package/dist/components/charts/theme/chart.theme.js +39 -39
- package/dist/components/core/Accordion/Accordion.d.ts +1 -1
- package/dist/components/core/Accordion/Accordion.js +2 -2
- package/dist/components/core/Accordion/Accordion.types.d.ts +8 -0
- package/dist/components/core/Badge/Badge.js +11 -15
- package/dist/components/core/Badge/Badge.theme.js +7 -21
- package/dist/components/core/Badge/Badge.types.d.ts +9 -1
- package/dist/components/core/Button/Button.js +2 -2
- package/dist/components/core/Button/Button.theme.js +1 -1
- package/dist/components/core/Button/Button.types.d.ts +8 -0
- package/dist/components/core/Card/Card.js +8 -2
- package/dist/components/core/Card/Card.theme.js +1 -1
- package/dist/components/core/Card/Card.types.d.ts +24 -1
- package/dist/components/core/Drawer/Drawer.d.ts +1 -1
- package/dist/components/core/Drawer/Drawer.js +10 -40
- package/dist/components/core/Drawer/Drawer.theme.js +2 -1
- package/dist/components/core/Drawer/Drawer.types.d.ts +8 -0
- package/dist/components/core/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/core/Dropdown/Dropdown.js +2 -2
- package/dist/components/core/Dropdown/Dropdown.types.d.ts +8 -0
- package/dist/components/core/Metric/Metric.d.ts +1 -1
- package/dist/components/core/Metric/Metric.js +9 -5
- package/dist/components/core/Metric/Metric.theme.d.ts +1 -1
- package/dist/components/core/Metric/Metric.theme.js +38 -28
- package/dist/components/core/Metric/Metric.types.d.ts +27 -8
- package/dist/components/core/Modal/Modal.d.ts +1 -1
- package/dist/components/core/Modal/Modal.js +17 -40
- package/dist/components/core/Modal/Modal.theme.js +8 -3
- package/dist/components/core/Modal/Modal.types.d.ts +18 -0
- package/dist/components/core/Modal/index.d.ts +1 -1
- package/dist/components/core/Notification/Notification.js +67 -0
- package/dist/components/core/Pill/Pill.d.ts +6 -11
- package/dist/components/core/Pill/Pill.theme.d.ts +2 -2
- package/dist/components/core/Pill/Pill.types.d.ts +9 -22
- package/dist/components/core/Pill/index.d.ts +1 -1
- package/dist/components/core/Popover/Popover.d.ts +1 -1
- package/dist/components/core/Popover/Popover.js +2 -2
- package/dist/components/core/Popover/Popover.types.d.ts +8 -0
- package/dist/components/core/Progress/Progress.d.ts +28 -0
- package/dist/components/core/Progress/Progress.js +114 -0
- package/dist/components/core/Progress/Progress.theme.d.ts +5 -0
- package/dist/components/core/Progress/Progress.theme.js +33 -0
- package/dist/components/core/Progress/Progress.types.d.ts +92 -0
- package/dist/components/core/Progress/index.d.ts +2 -0
- package/dist/components/core/Tabs/Tabs.js +2 -2
- package/dist/components/core/Tabs/Tabs.types.d.ts +8 -0
- package/dist/components/core/Tag/Tag.animations.d.ts +3 -0
- package/dist/components/core/Tag/Tag.animations.js +31 -0
- package/dist/components/core/Tag/Tag.d.ts +14 -0
- package/dist/components/core/Tag/Tag.js +45 -0
- package/dist/components/core/Tag/Tag.theme.d.ts +2 -0
- package/dist/components/core/Tag/Tag.theme.js +21 -0
- package/dist/components/core/Tag/Tag.types.d.ts +40 -0
- package/dist/components/core/Tag/index.d.ts +3 -0
- package/dist/components/core/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/core/Tooltip/Tooltip.js +3 -3
- package/dist/components/core/Tooltip/Tooltip.theme.js +1 -1
- package/dist/components/core/Tooltip/Tooltip.types.d.ts +17 -0
- package/dist/components/core/index.d.ts +2 -1
- package/dist/components/core/index.js +3 -2
- package/dist/components/effects/CustomCursor/CustomCursor.d.ts +0 -13
- package/dist/components/effects/CustomCursor/CustomCursor.js +26 -2
- package/dist/components/effects/CustomCursor/CustomCursor.theme.js +12 -1
- package/dist/components/effects/CustomCursor/CustomCursor.types.d.ts +14 -1
- package/dist/components/forms/Combobox/Combobox.d.ts +25 -0
- package/dist/components/forms/Combobox/Combobox.js +412 -0
- package/dist/components/forms/Combobox/Combobox.theme.d.ts +6 -0
- package/dist/components/forms/Combobox/Combobox.theme.js +60 -0
- package/dist/components/forms/Combobox/Combobox.types.d.ts +111 -0
- package/dist/components/forms/Combobox/index.d.ts +3 -0
- package/dist/components/forms/FileUpload/FileUpload.js +68 -0
- package/dist/components/forms/Input/Input.js +25 -28
- package/dist/components/forms/Input/inputMasks.d.ts +15 -0
- package/dist/components/forms/Input/inputMasks.js +72 -1
- package/dist/components/forms/InputTag/InputTag.d.ts +40 -0
- package/dist/components/forms/InputTag/InputTag.js +491 -0
- package/dist/components/forms/InputTag/InputTag.theme.d.ts +2 -0
- package/dist/components/forms/InputTag/InputTag.theme.js +16 -0
- package/dist/components/forms/InputTag/InputTag.types.d.ts +107 -0
- package/dist/components/forms/InputTag/index.d.ts +3 -0
- package/dist/components/forms/Select/Select.d.ts +101 -2
- package/dist/components/forms/Select/Select.js +128 -132
- package/dist/components/forms/Select/Select.theme.js +10 -14
- package/dist/components/forms/Select/Select.types.d.ts +6 -2
- package/dist/components/forms/Select/index.d.ts +7 -4
- package/dist/components/forms/Select/useSelectState.d.ts +66 -0
- package/dist/components/forms/Select/useSelectState.js +134 -0
- package/dist/components/forms/SelectExpand/SelectExpand.animations.d.ts +20 -0
- package/dist/components/forms/SelectExpand/SelectExpand.animations.js +74 -0
- package/dist/components/forms/SelectExpand/SelectExpand.d.ts +9 -0
- package/dist/components/forms/SelectExpand/SelectExpand.js +223 -0
- package/dist/components/forms/SelectExpand/SelectExpand.theme.d.ts +5 -0
- package/dist/components/forms/SelectExpand/SelectExpand.theme.js +74 -0
- package/dist/components/forms/SelectExpand/SelectExpand.types.d.ts +126 -0
- package/dist/components/forms/SelectExpand/index.d.ts +4 -0
- package/dist/components/forms/Switch/Switch.js +3 -3
- package/dist/components/forms/Switch/Switch.theme.d.ts +1 -1
- package/dist/components/forms/Switch/Switch.theme.js +2 -2
- package/dist/components/forms/TimePicker/TimePicker.animations.d.ts +0 -46
- package/dist/components/forms/TimePicker/TimePicker.d.ts +15 -6
- package/dist/components/forms/TimePicker/TimePicker.js +285 -124
- package/dist/components/forms/TimePicker/TimePicker.theme.d.ts +1 -1
- package/dist/components/forms/TimePicker/TimePicker.theme.js +39 -22
- package/dist/components/forms/TimePicker/TimePicker.types.d.ts +88 -34
- package/dist/components/forms/TimePicker/TimePickerContent.d.ts +7 -10
- package/dist/components/forms/TimePicker/TimePickerContent.js +149 -16
- package/dist/components/forms/TimePicker/TimePickerTrigger.d.ts +3 -3
- package/dist/components/forms/TimePicker/TimePickerTrigger.js +22 -19
- package/dist/components/forms/TimePicker/WheelColumn.d.ts +14 -0
- package/dist/components/forms/TimePicker/WheelColumn.js +90 -0
- package/dist/components/forms/TimePicker/index.d.ts +4 -1
- package/dist/components/forms/TimePicker/useWheelPicker.d.ts +37 -0
- package/dist/components/forms/TimePicker/useWheelPicker.js +138 -0
- package/dist/components/forms/forms.theme.d.ts +14 -0
- package/dist/components/forms/forms.theme.js +31 -0
- package/dist/components/forms/index.d.ts +9 -3
- package/dist/components/forms/index.js +73 -2
- package/dist/hooks/index.d.ts +0 -4
- package/dist/icons/Icon.d.ts +7 -0
- package/dist/icons/Icon.js +6 -2
- package/dist/index.js +62 -63
- package/dist/styles.css +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/optimisticErrors.js +1 -70
- package/package.json +1 -1
- package/dist/components/ai/EditingIndicator/EditingIndicator.animations.d.ts +0 -31
- package/dist/components/ai/EditingIndicator/EditingIndicator.animations.js +0 -115
- package/dist/components/ai/EditingIndicator/EditingIndicator.d.ts +0 -35
- package/dist/components/ai/EditingIndicator/EditingIndicator.js +0 -94
- package/dist/components/ai/EditingIndicator/EditingIndicator.theme.d.ts +0 -2
- package/dist/components/ai/EditingIndicator/EditingIndicator.theme.js +0 -13
- package/dist/components/ai/EditingIndicator/EditingIndicator.types.d.ts +0 -54
- package/dist/components/ai/EditingIndicator/index.d.ts +0 -9
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.d.ts +0 -3
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.js +0 -126
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.theme.d.ts +0 -2
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.theme.js +0 -8
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.types.d.ts +0 -45
- package/dist/components/ai/GenerativeRenderer/index.d.ts +0 -3
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.animations.d.ts +0 -17
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.animations.js +0 -56
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.d.ts +0 -38
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.js +0 -110
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.theme.d.ts +0 -2
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.theme.js +0 -13
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.types.d.ts +0 -53
- package/dist/components/ai/PresenceIndicator/index.d.ts +0 -8
- package/dist/components/ai/PresenceProvider/PresenceContext.d.ts +0 -24
- package/dist/components/ai/PresenceProvider/PresenceContext.js +0 -34
- package/dist/components/ai/PresenceProvider/PresenceProvider.d.ts +0 -32
- package/dist/components/ai/PresenceProvider/PresenceProvider.js +0 -321
- package/dist/components/ai/PresenceProvider/PresenceProvider.types.d.ts +0 -140
- package/dist/components/ai/PresenceProvider/adapters/MockAdapter.d.ts +0 -102
- package/dist/components/ai/PresenceProvider/adapters/MockAdapter.js +0 -331
- package/dist/components/ai/PresenceProvider/adapters/PresenceAdapter.d.ts +0 -93
- package/dist/components/ai/PresenceProvider/adapters/SupabaseAdapter.d.ts +0 -134
- package/dist/components/ai/PresenceProvider/adapters/WebSocketAdapter.d.ts +0 -149
- package/dist/components/ai/PresenceProvider/adapters/index.d.ts +0 -11
- package/dist/components/ai/PresenceProvider/index.d.ts +0 -10
- package/dist/components/ai/PromptSuggestions/PromptSuggestions.d.ts +0 -27
- package/dist/components/ai/PromptSuggestions/PromptSuggestions.js +0 -61
- package/dist/components/ai/PromptSuggestions/PromptSuggestions.types.d.ts +0 -65
- package/dist/components/ai/VersionSlider/VersionSlider.d.ts +0 -3
- package/dist/components/ai/VersionSlider/VersionSlider.js +0 -97
- package/dist/components/ai/VersionSlider/VersionSlider.theme.d.ts +0 -2
- package/dist/components/ai/VersionSlider/VersionSlider.theme.js +0 -18
- package/dist/components/ai/VersionSlider/VersionSlider.types.d.ts +0 -77
- package/dist/components/ai/VersionSlider/index.d.ts +0 -3
- package/dist/components/core/Pill/Pill.animations.js +0 -25
- package/dist/components/core/Pill/Pill.js +0 -145
- package/dist/components/core/Pill/Pill.theme.js +0 -65
- package/dist/components/core/RetryBoundary/RetryBoundary.d.ts +0 -35
- package/dist/components/core/RetryBoundary/RetryBoundary.js +0 -154
- package/dist/components/core/RetryBoundary/RetryBoundary.theme.d.ts +0 -2
- package/dist/components/core/RetryBoundary/RetryBoundary.theme.js +0 -7
- package/dist/components/core/RetryBoundary/RetryBoundary.types.d.ts +0 -51
- package/dist/components/core/RetryBoundary/index.d.ts +0 -3
- package/dist/components/forms/OptimisticForm/OptimisticForm.d.ts +0 -33
- package/dist/components/forms/OptimisticForm/OptimisticForm.js +0 -87
- package/dist/components/forms/OptimisticForm/OptimisticForm.theme.d.ts +0 -2
- package/dist/components/forms/OptimisticForm/OptimisticForm.theme.js +0 -8
- package/dist/components/forms/OptimisticForm/OptimisticForm.types.d.ts +0 -74
- package/dist/components/forms/OptimisticForm/index.d.ts +0 -3
- package/dist/hooks/useOptimisticMutation.d.ts +0 -109
- package/dist/hooks/useOptimisticMutation.js +0 -171
- package/dist/hooks/usePresence.d.ts +0 -88
- package/dist/utils/presenceUtils.d.ts +0 -66
- package/dist/utils/presenceUtils.js +0 -107
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PromptSuggestionProps } from "./PromptSuggestion.types";
|
|
3
|
+
/**
|
|
4
|
+
* PromptSuggestion - Individual clickable suggestion chip
|
|
5
|
+
*
|
|
6
|
+
* Simple, focused component for AI prompt interfaces.
|
|
7
|
+
* White background with border styling, fully customizable via className.
|
|
8
|
+
*
|
|
9
|
+
* @example Basic usage
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <div className="flex gap-2">
|
|
12
|
+
* <PromptSuggestion onSelect={handleSelect}>Write a poem</PromptSuggestion>
|
|
13
|
+
* <PromptSuggestion onSelect={handleSelect}>Summarize document</PromptSuggestion>
|
|
14
|
+
* </div>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @example With icons
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <PromptSuggestion
|
|
20
|
+
* icon={<CodeBracketIcon className="size-4" />}
|
|
21
|
+
* onSelect={handleSelect}
|
|
22
|
+
* >
|
|
23
|
+
* Explain code
|
|
24
|
+
* </PromptSuggestion>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const PromptSuggestion: React.ForwardRefExoticComponent<PromptSuggestionProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React__default, { useCallback } from 'react';
|
|
2
|
+
import { promptSuggestionTheme } from './PromptSuggestion.theme.js';
|
|
3
|
+
import { cn } from '../../../utils/cn.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* PromptSuggestion - Individual clickable suggestion chip
|
|
7
|
+
*
|
|
8
|
+
* Simple, focused component for AI prompt interfaces.
|
|
9
|
+
* White background with border styling, fully customizable via className.
|
|
10
|
+
*
|
|
11
|
+
* @example Basic usage
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <div className="flex gap-2">
|
|
14
|
+
* <PromptSuggestion onSelect={handleSelect}>Write a poem</PromptSuggestion>
|
|
15
|
+
* <PromptSuggestion onSelect={handleSelect}>Summarize document</PromptSuggestion>
|
|
16
|
+
* </div>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example With icons
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <PromptSuggestion
|
|
22
|
+
* icon={<CodeBracketIcon className="size-4" />}
|
|
23
|
+
* onSelect={handleSelect}
|
|
24
|
+
* >
|
|
25
|
+
* Explain code
|
|
26
|
+
* </PromptSuggestion>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const PromptSuggestion = React__default.forwardRef(({ children, onSelect, icon, className, onClick, ...props }, ref) => {
|
|
30
|
+
const theme = promptSuggestionTheme;
|
|
31
|
+
// Extract text content from children for onSelect callback
|
|
32
|
+
const getTextContent = useCallback(() => {
|
|
33
|
+
if (typeof children === "string") {
|
|
34
|
+
return children;
|
|
35
|
+
}
|
|
36
|
+
if (typeof children === "number") {
|
|
37
|
+
return String(children);
|
|
38
|
+
}
|
|
39
|
+
return "";
|
|
40
|
+
}, [children]);
|
|
41
|
+
// Handle click with onSelect callback
|
|
42
|
+
const handleClick = useCallback((event) => {
|
|
43
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
44
|
+
if (onSelect) {
|
|
45
|
+
const text = getTextContent();
|
|
46
|
+
if (text) {
|
|
47
|
+
onSelect(text);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, [onClick, onSelect, getTextContent]);
|
|
51
|
+
return (React__default.createElement("span", { ref: ref, role: "button", tabIndex: 0, onClick: handleClick, onKeyDown: (e) => {
|
|
52
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
handleClick(e);
|
|
55
|
+
}
|
|
56
|
+
}, className: cn(theme.baseStyle, className), "aria-label": typeof children === "string" ? `Use suggestion: ${children}` : undefined, ...props },
|
|
57
|
+
icon && React__default.createElement("span", { className: theme.iconStyle }, icon),
|
|
58
|
+
children));
|
|
59
|
+
});
|
|
60
|
+
PromptSuggestion.displayName = "PromptSuggestion";
|
|
61
|
+
|
|
62
|
+
export { PromptSuggestion };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PromptSuggestion theme configuration
|
|
3
|
+
*/
|
|
4
|
+
export interface PromptSuggestionTheme {
|
|
5
|
+
/** Base styles for the suggestion chip */
|
|
6
|
+
baseStyle: string;
|
|
7
|
+
/** Icon container styles */
|
|
8
|
+
iconStyle: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const promptSuggestionTheme: PromptSuggestionTheme;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const promptSuggestionTheme = {
|
|
2
|
+
baseStyle: "inline-flex items-center gap-2 py-2 px-3.5 rounded-full " +
|
|
3
|
+
"bg-white dark:bg-[var(--color-background)] " +
|
|
4
|
+
"border border-[var(--color-border)] " +
|
|
5
|
+
"text-sm font-medium text-[var(--color-text-primary)] " +
|
|
6
|
+
"cursor-pointer transition-all duration-300 " +
|
|
7
|
+
"hover:bg-[var(--color-background-secondary)] dark:hover:bg-[var(--color-background-secondary)] " +
|
|
8
|
+
"focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-primary)]",
|
|
9
|
+
iconStyle: "size-4 flex-shrink-0",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { promptSuggestionTheme };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* PromptSuggestion component props
|
|
4
|
+
*
|
|
5
|
+
* Individual clickable suggestion chip for AI prompt interfaces.
|
|
6
|
+
* Simple, focused component with white background and border styling.
|
|
7
|
+
*
|
|
8
|
+
* @example Basic usage
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <PromptSuggestion onSelect={handleSelect}>
|
|
11
|
+
* Write a poem
|
|
12
|
+
* </PromptSuggestion>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example With icon
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <PromptSuggestion
|
|
18
|
+
* icon={<CodeBracketIcon className="size-4" />}
|
|
19
|
+
* onSelect={handleSelect}
|
|
20
|
+
* >
|
|
21
|
+
* Explain this code
|
|
22
|
+
* </PromptSuggestion>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example Custom styling (shadcn approach)
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <PromptSuggestion
|
|
28
|
+
* className="bg-purple-100 border-purple-300"
|
|
29
|
+
* onSelect={handleSelect}
|
|
30
|
+
* >
|
|
31
|
+
* Custom styled
|
|
32
|
+
* </PromptSuggestion>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export interface PromptSuggestionProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "onSelect"> {
|
|
36
|
+
/**
|
|
37
|
+
* Suggestion text content
|
|
38
|
+
*/
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Callback when suggestion is clicked
|
|
42
|
+
* Receives the text content as a string
|
|
43
|
+
*/
|
|
44
|
+
onSelect?: (text: string) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Optional icon displayed before the text
|
|
47
|
+
*/
|
|
48
|
+
icon?: React.ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Additional className for full customization (highest priority)
|
|
51
|
+
*/
|
|
52
|
+
className?: string;
|
|
53
|
+
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
1
|
+
export { PromptSuggestion } from "./PromptSuggestion";
|
|
2
|
+
export { promptSuggestionTheme } from "./PromptSuggestion.theme";
|
|
3
|
+
export type { PromptSuggestionProps } from "./PromptSuggestion.types";
|
|
4
|
+
export type { PromptSuggestionTheme } from "./PromptSuggestion.theme";
|
|
@@ -10,8 +10,8 @@ export { ThinkingIndicator, thinkingIndicatorTheme } from "./ThinkingIndicator";
|
|
|
10
10
|
export type { ThinkingIndicatorProps, ThinkingIndicatorSize, ThinkingIndicatorTheme, ThinkingIndicatorThemeOverrides, } from "./ThinkingIndicator";
|
|
11
11
|
export { TokenCounter, tokenCounterTheme, estimateTokens, calculateCost, formatCost, formatTokenCount, MODEL_CONFIGS, } from "./TokenCounter";
|
|
12
12
|
export type { TokenCounterProps, TokenCounterModel, TokenCounterSize, TokenCounterTheme, TokenCounterThemeOverrides, ModelConfig, } from "./TokenCounter";
|
|
13
|
-
export {
|
|
14
|
-
export type {
|
|
13
|
+
export { PromptSuggestion, promptSuggestionTheme } from "./PromptSuggestions";
|
|
14
|
+
export type { PromptSuggestionProps, PromptSuggestionTheme, } from "./PromptSuggestions";
|
|
15
15
|
export { StreamingResponse, ErrorDisplay, MarkdownRenderer, streamingResponseTheme, } from "./StreamingResponse";
|
|
16
16
|
export type { StreamingResponseProps, StreamingResponseTheme, MarkdownOptions, } from "./StreamingResponse";
|
|
17
17
|
export { CodeBlock, codeBlockTheme } from "./CodeBlock";
|
|
@@ -19,15 +19,5 @@ export type { CodeBlockProps, CodeBlockLanguage, CodeBlockTheme, CodeBlockThemeO
|
|
|
19
19
|
export { ApprovalCard } from "./ApprovalCard";
|
|
20
20
|
export type { ApprovalCardProps, ApprovalRiskLevel, ApprovalMode, } from "./ApprovalCard";
|
|
21
21
|
export { approvalCardTheme } from "./ApprovalCard/ApprovalCard.theme";
|
|
22
|
-
export { EditingIndicator, editingIndicatorTheme } from "./EditingIndicator";
|
|
23
|
-
export type { EditingIndicatorProps, EditingIndicatorTheme, } from "./EditingIndicator";
|
|
24
|
-
export { PresenceIndicator, presenceIndicatorTheme } from "./PresenceIndicator";
|
|
25
|
-
export type { PresenceIndicatorProps, PresenceIndicatorTheme, PresenceSort, } from "./PresenceIndicator";
|
|
26
|
-
export { PresenceProvider, usePresenceContext, PresenceContext, MockPresenceAdapter, } from "./PresenceProvider";
|
|
27
|
-
export type { PresenceProviderProps, PresenceUser, TypingUser, ConnectionStatus, PresenceEvent, PresenceAdapter, PresenceAdapterConfig, PresenceContextValue, PresenceProviderTheme, } from "./PresenceProvider";
|
|
28
22
|
export { ArtifactContainer, artifactContainerTheme, handleSizes, } from "./ArtifactContainer";
|
|
29
23
|
export type { ArtifactContainerProps, ArtifactContainerChatProps, ArtifactContainerCanvasProps, ArtifactContainerTheme, SplitDirection, } from "./ArtifactContainer";
|
|
30
|
-
export { GenerativeRenderer, generativeRendererTheme, } from "./GenerativeRenderer";
|
|
31
|
-
export type { GenerativeRendererProps, GenerativeRendererTheme, RendererType, } from "./GenerativeRenderer";
|
|
32
|
-
export { VersionSlider, versionSliderTheme } from "./VersionSlider";
|
|
33
|
-
export type { VersionSliderProps, VersionSliderTheme, Version, } from "./VersionSlider";
|
|
@@ -14,8 +14,8 @@ import { getSpringAnimation, CIRCULAR_CHART_ANIMATIONS, getStaggerDelay } from '
|
|
|
14
14
|
* Multiple concentric circular progress rings, inspired by Apple Activity.
|
|
15
15
|
* Features smooth animations, accessibility support, and production-ready CSS variables.
|
|
16
16
|
*/
|
|
17
|
-
const ActivityRings = ({ rings, centerLabel, centerSuffix, size = ACTIVITY_RINGS_DEFAULTS.size, strokeWidth: propStrokeWidth, gap: propGap, showAnimation = ACTIVITY_RINGS_DEFAULTS.showAnimation, theme: themeOverrides, className, title, description, showValidationWarnings = process.env.NODE_ENV === "development", ...props }) => {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f
|
|
17
|
+
const ActivityRings = ({ rings, centerLabel, centerSuffix, size = ACTIVITY_RINGS_DEFAULTS.size, strokeWidth: propStrokeWidth, gap: propGap, showAnimation = ACTIVITY_RINGS_DEFAULTS.showAnimation, colors, theme: themeOverrides, className, title, description, darkMode = false, showValidationWarnings = process.env.NODE_ENV === "development", ...props }) => {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
19
|
const theme = { ...activityRingsTheme, ...(themeOverrides || {}) };
|
|
20
20
|
const shouldReduceMotion = useReducedMotion();
|
|
21
21
|
const containerRef = useRef(null);
|
|
@@ -81,8 +81,25 @@ const ActivityRings = ({ rings, centerLabel, centerSuffix, size = ACTIVITY_RINGS
|
|
|
81
81
|
return maxRadius - index * (strokeWidth + gap);
|
|
82
82
|
});
|
|
83
83
|
}, [normalizedRings.length, strokeWidth, gap, center]);
|
|
84
|
-
// Get
|
|
85
|
-
|
|
84
|
+
// Get color for a ring by index
|
|
85
|
+
// Priority: ring.color > colors prop > theme colors > fallback
|
|
86
|
+
const getRingColor = (ring, index) => {
|
|
87
|
+
var _a;
|
|
88
|
+
// 1. Individual ring color override (highest priority)
|
|
89
|
+
if (ring.color)
|
|
90
|
+
return ring.color;
|
|
91
|
+
// 2. Component-level colors prop (overrides theme defaults)
|
|
92
|
+
if (colors && colors.length > 0) {
|
|
93
|
+
return colors[index % colors.length];
|
|
94
|
+
}
|
|
95
|
+
// 3. Theme colors
|
|
96
|
+
const themeColors = ((_a = theme.ringDefaults) === null || _a === void 0 ? void 0 : _a.colors) || [];
|
|
97
|
+
if (themeColors.length > 0) {
|
|
98
|
+
return themeColors[index % themeColors.length];
|
|
99
|
+
}
|
|
100
|
+
// 4. Fallback
|
|
101
|
+
return "var(--color-primary)";
|
|
102
|
+
};
|
|
86
103
|
// Container size
|
|
87
104
|
const containerSize = typeof size === "number" ? `${size}px` : size;
|
|
88
105
|
// Calculate average progress for ARIA
|
|
@@ -90,72 +107,67 @@ const ActivityRings = ({ rings, centerLabel, centerSuffix, size = ACTIVITY_RINGS
|
|
|
90
107
|
const sum = normalizedRings.reduce((acc, ring) => acc + ring.value, 0);
|
|
91
108
|
return Math.round(sum / normalizedRings.length);
|
|
92
109
|
}, [normalizedRings]);
|
|
93
|
-
return (React__default.createElement("div", { ref: containerRef, className: cn(theme.baseStyle, className), style: { width: containerSize, height: containerSize }, role: "progressbar", "aria-valuenow": averageProgress, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": title ||
|
|
110
|
+
return (React__default.createElement("div", { ref: containerRef, className: cn(theme.baseStyle, darkMode && "dark", className), style: { width: containerSize, height: containerSize }, role: "progressbar", "aria-valuenow": averageProgress, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": title ||
|
|
94
111
|
`Activity rings: ${normalizedRings
|
|
95
112
|
.map((r, i) => `${r.label || `Ring ${i + 1}`} ${r.value}%`)
|
|
96
113
|
.join(", ")}`, "aria-describedby": description ? "rings-description" : undefined, tabIndex: 0, ...props },
|
|
97
114
|
description && (React__default.createElement("span", { id: "rings-description", className: "sr-only" }, description)),
|
|
98
|
-
React__default.createElement("svg", { className: cn(theme.svgStyle), viewBox: `0 0 ${svgSize} ${svgSize}`, width: containerSize, height: containerSize, preserveAspectRatio: "xMidYMid meet", role: "presentation", "aria-hidden": "true" },
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const animationDelay = getStaggerDelay(index, CIRCULAR_CHART_ANIMATIONS.activityRings.staggerDelay);
|
|
109
|
-
// Check if radius is valid (prevent negative or zero radius)
|
|
110
|
-
if (radius <= 0) {
|
|
111
|
-
if (process.env.NODE_ENV !== "production") {
|
|
112
|
-
console.warn(`[ActivityRings]: Ring ${index} has invalid radius (${radius}). Too many rings or strokeWidth/gap too large.`);
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
+
React__default.createElement("svg", { className: cn(theme.svgStyle), viewBox: `0 0 ${svgSize} ${svgSize}`, width: containerSize, height: containerSize, preserveAspectRatio: "xMidYMid meet", role: "presentation", "aria-hidden": "true" }, normalizedRings.map((ring, index) => {
|
|
116
|
+
const radius = ringRadii[index];
|
|
117
|
+
const circumference = 2 * Math.PI * radius;
|
|
118
|
+
const offset = circumference - (ring.value / 100) * circumference;
|
|
119
|
+
const ringColor = getRingColor(ring, index);
|
|
120
|
+
const animationDelay = getStaggerDelay(index, CIRCULAR_CHART_ANIMATIONS.activityRings.staggerDelay);
|
|
121
|
+
// Check if radius is valid (prevent negative or zero radius)
|
|
122
|
+
if (radius <= 0) {
|
|
123
|
+
if (process.env.NODE_ENV !== "production") {
|
|
124
|
+
console.warn(`[ActivityRings]: Ring ${index} has invalid radius (${radius}). Too many rings or strokeWidth/gap too large.`);
|
|
115
125
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
const svgCoordinates = {
|
|
131
|
-
x: center,
|
|
132
|
-
y: center - radius,
|
|
133
|
-
dimensions: {
|
|
134
|
-
width: svgSize,
|
|
135
|
-
height: svgSize,
|
|
136
|
-
left: 0,
|
|
137
|
-
top: 0,
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
// Create shared hover handlers
|
|
129
|
+
const createHoverHandlers = () => ({
|
|
130
|
+
onMouseEnter: (e) => {
|
|
131
|
+
const content = {
|
|
132
|
+
category: "", // Empty to avoid duplicate text in tooltip
|
|
133
|
+
series: [
|
|
134
|
+
{
|
|
135
|
+
key: `ring-${index}`,
|
|
136
|
+
label: ring.label || `Ring ${index + 1}`,
|
|
137
|
+
value: ring.value,
|
|
138
|
+
color: ringColor,
|
|
138
139
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
],
|
|
141
|
+
};
|
|
142
|
+
const svgCoordinates = {
|
|
143
|
+
x: center,
|
|
144
|
+
y: center - radius,
|
|
145
|
+
dimensions: {
|
|
146
|
+
width: svgSize,
|
|
147
|
+
height: svgSize,
|
|
148
|
+
left: 0,
|
|
149
|
+
top: 0,
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
handleMouseEnter(e, content, svgCoordinates);
|
|
153
|
+
},
|
|
154
|
+
onMouseMove: (e) => handleMouseMove(e),
|
|
155
|
+
onMouseLeave: () => handleMouseLeave(),
|
|
156
|
+
});
|
|
157
|
+
return (React__default.createElement("g", { key: index },
|
|
158
|
+
React__default.createElement("circle", { cx: center, cy: center, r: radius, fill: "none", stroke: "var(--color-chart-track)", strokeWidth: strokeWidth, strokeLinecap: "round", className: "cursor-pointer", transform: `rotate(-90 ${center} ${center})`, ...createHoverHandlers() }),
|
|
159
|
+
React__default.createElement(motion.circle, { cx: center, cy: center, r: radius, fill: "none", stroke: ringColor, strokeWidth: strokeWidth, strokeLinecap: "round", strokeDasharray: circumference, className: "cursor-pointer transition-opacity duration-200", initial: { strokeDashoffset: circumference }, animate: hasAnimated ? { strokeDashoffset: offset } : {}, transition: showAnimation && !shouldReduceMotion
|
|
160
|
+
? getSpringAnimation(CIRCULAR_CHART_ANIMATIONS.activityRings.preset, shouldReduceMotion, animationDelay)
|
|
161
|
+
: { duration: 0 }, transform: `rotate(-90 ${center} ${center})`, ...createHoverHandlers() })));
|
|
162
|
+
})),
|
|
151
163
|
(centerLabel || centerSuffix) && (React__default.createElement(motion.div, { className: "absolute inset-0 flex flex-col items-center justify-center pointer-events-none", initial: { opacity: 0, scale: 0.8 }, animate: hasAnimated ? { opacity: 1, scale: 1 } : {}, transition: showAnimation && !shouldReduceMotion
|
|
152
164
|
? {
|
|
153
165
|
delay: CIRCULAR_CHART_ANIMATIONS.activityRings.centerLabelDelay,
|
|
154
166
|
duration: 0.4,
|
|
155
167
|
}
|
|
156
|
-
: { duration: 0 } }, centerLabel && (React__default.createElement("div", { className: cn((
|
|
168
|
+
: { duration: 0 } }, centerLabel && (React__default.createElement("div", { className: cn((_e = theme.centerText) === null || _e === void 0 ? void 0 : _e.label, "flex flex-col items-center") },
|
|
157
169
|
React__default.createElement("span", null, centerLabel),
|
|
158
|
-
centerSuffix && (React__default.createElement("span", { className: (
|
|
170
|
+
centerSuffix && (React__default.createElement("span", { className: (_f = theme.centerText) === null || _f === void 0 ? void 0 : _f.suffix }, centerSuffix)))))),
|
|
159
171
|
React__default.createElement(ChartTooltip, { tooltipRef: tooltipRef, content: tooltipData === null || tooltipData === void 0 ? void 0 : tooltipData.content, active: !!tooltipData, position: tooltipData ? { x: tooltipData.x, y: tooltipData.y } : { x: 0, y: 0 } })));
|
|
160
172
|
};
|
|
161
173
|
ActivityRings.displayName = "ActivityRings";
|
|
@@ -22,6 +22,7 @@ export interface ActivityRingsThemeOverrides {
|
|
|
22
22
|
ringDefaults?: {
|
|
23
23
|
strokeWidth?: number;
|
|
24
24
|
gap?: number;
|
|
25
|
+
/** Default colors */
|
|
25
26
|
colors?: string[];
|
|
26
27
|
};
|
|
27
28
|
/** Center text styles */
|
|
@@ -48,8 +49,24 @@ export interface ActivityRingsProps extends Pick<BaseChartProps, 'className' | '
|
|
|
48
49
|
gap?: number;
|
|
49
50
|
/** Whether to show animations (default: true) */
|
|
50
51
|
showAnimation?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Custom color palette for rings. Colors are applied in order from outer to inner ring.
|
|
54
|
+
* If fewer colors than rings, colors will cycle. Individual ring.color takes precedence.
|
|
55
|
+
* When provided, overrides both light and dark theme defaults - choose colors appropriate
|
|
56
|
+
* for your background.
|
|
57
|
+
* @example ['#3b82f6', '#10b981', '#f59e0b']
|
|
58
|
+
* @example ['var(--color-primary)', 'var(--color-success)', 'var(--color-warning)']
|
|
59
|
+
*/
|
|
60
|
+
colors?: string[];
|
|
51
61
|
/** Theme overrides */
|
|
52
62
|
theme?: ActivityRingsThemeOverrides;
|
|
63
|
+
/**
|
|
64
|
+
* Force dark mode styling for the chart. Use when placing the chart on a dark background
|
|
65
|
+
* while the page is in light mode. This applies the 'dark' class to the chart container,
|
|
66
|
+
* making text, borders, and other elements use light colors for visibility.
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
darkMode?: boolean;
|
|
53
70
|
/** Development and debugging props */
|
|
54
71
|
showValidationWarnings?: boolean;
|
|
55
72
|
}
|
|
@@ -24,8 +24,10 @@ orientation = BAR_CHART_DEFAULTS.orientation,
|
|
|
24
24
|
showAnimation = BAR_CHART_DEFAULTS.showAnimation,
|
|
25
25
|
// Placeholder bar props
|
|
26
26
|
showPlaceholderBars = BAR_CHART_DEFAULTS.showPlaceholderBars, placeholderData,
|
|
27
|
+
// Color customization
|
|
28
|
+
colors,
|
|
27
29
|
// Base props
|
|
28
|
-
className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.enableKeyboardNavigation, showValidationWarnings = process.env.NODE_ENV === "development", children, ...props }) => {
|
|
30
|
+
className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.enableKeyboardNavigation, showValidationWarnings = process.env.NODE_ENV === "development", darkMode = false, children, ...props }) => {
|
|
29
31
|
var _a, _b;
|
|
30
32
|
// Resolve barRadius with backward compatibility
|
|
31
33
|
const resolvedBarRadius = (_a = barRadius !== null && barRadius !== void 0 ? barRadius : radius) !== null && _a !== void 0 ? _a : BAR_CHART_DEFAULTS.barRadius;
|
|
@@ -75,13 +77,15 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
75
77
|
}
|
|
76
78
|
// Simple color functions based on direct CSS variables (following guidelines)
|
|
77
79
|
const getSeriesFillColor = (index) => {
|
|
78
|
-
const
|
|
80
|
+
const defaultColors = [
|
|
79
81
|
"var(--color-primary)",
|
|
80
82
|
"var(--color-warning)",
|
|
81
83
|
"var(--color-success)",
|
|
82
84
|
"var(--color-danger)",
|
|
83
85
|
];
|
|
84
|
-
|
|
86
|
+
// Use custom colors if provided, otherwise fall back to defaults
|
|
87
|
+
const palette = colors && colors.length > 0 ? colors : defaultColors;
|
|
88
|
+
return palette[index % palette.length];
|
|
85
89
|
};
|
|
86
90
|
const containerRef = useRef(null);
|
|
87
91
|
const [dimensions, setDimensions] = useState({ width: 600, height: 400 });
|
|
@@ -408,7 +412,7 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
408
412
|
: undefined }));
|
|
409
413
|
};
|
|
410
414
|
return (React__default.createElement(ChartErrorBoundary, { className: className, showErrorDetails: process.env.NODE_ENV === "development" },
|
|
411
|
-
React__default.createElement("div", { ref: containerRef, className: cn("chart-container w-full h-full", className), ...chartAccessibilityProps, onMouseEnter: handleMouseInteraction, onMouseMove: handleMouseInteraction, ...props },
|
|
415
|
+
React__default.createElement("div", { ref: containerRef, className: cn("chart-container w-full h-full", darkMode && "dark", className), ...chartAccessibilityProps, onMouseEnter: handleMouseInteraction, onMouseMove: handleMouseInteraction, ...props },
|
|
412
416
|
descriptionProps && React__default.createElement("div", { ...descriptionProps }),
|
|
413
417
|
showValidationWarnings && hasWarnings && (React__default.createElement("div", { className: "absolute top-2 left-2 right-2 z-10 p-2 bg-[var(--color-warning-50)] border border-[var(--color-warning-200)] rounded text-xs text-[var(--color-warning)] shadow-sm" },
|
|
414
418
|
React__default.createElement("strong", null, "Chart Warnings:"),
|
|
@@ -4,10 +4,24 @@ export interface BarChartProps extends BaseChartProps, StandardChartDisplayProps
|
|
|
4
4
|
radius?: number;
|
|
5
5
|
gap?: number;
|
|
6
6
|
categoryGap?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Custom color palette for bar series. Colors are applied in order to each data series.
|
|
9
|
+
* If fewer colors than series, colors will cycle. Supports any valid CSS color value
|
|
10
|
+
* including hex, rgb, hsl, and CSS variables like `var(--color-primary)`.
|
|
11
|
+
* @example ['#3b82f6', '#10b981', '#f59e0b']
|
|
12
|
+
* @example ['var(--color-primary)', 'var(--color-success)']
|
|
13
|
+
*/
|
|
14
|
+
colors?: string[];
|
|
7
15
|
showAnimation?: boolean;
|
|
8
16
|
showPlaceholderBars?: boolean;
|
|
9
17
|
placeholderData?: BaseChartProps["data"];
|
|
10
18
|
showValidationWarnings?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Force dark mode styling for the chart. Use when placing the chart on a dark background
|
|
21
|
+
* while the page is in light mode. This applies the 'dark' class to the chart container,
|
|
22
|
+
* making axis labels, grid lines, and text use light colors for visibility.
|
|
23
|
+
*/
|
|
24
|
+
darkMode?: boolean;
|
|
11
25
|
}
|
|
12
26
|
export declare const BAR_CHART_DEFAULTS: {
|
|
13
27
|
readonly barRadius: 32;
|
|
@@ -3,7 +3,7 @@ import { useReducedMotion, motion } from 'motion/react';
|
|
|
3
3
|
import { cn } from '../../../utils/cn.js';
|
|
4
4
|
import { donutChartTheme } from './DonutChart.theme.js';
|
|
5
5
|
import { getSpringAnimation, CIRCULAR_CHART_ANIMATIONS, getStaggerDelay } from '../utils/animation-utils.js';
|
|
6
|
-
import { describeRingSegmentPath, interpolateHexColor, clamp } from './donut-utils.js';
|
|
6
|
+
import { resolveCssVariable, describeRingSegmentPath, interpolateHexColor, clamp } from './donut-utils.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* DonutChart component for displaying a percentage value with a circular progress indicator
|
|
@@ -36,28 +36,31 @@ const DonutChart = ({ variant = "solid", percentage, label, subtitle, size = 200
|
|
|
36
36
|
// Generate stable gradient ID based on component instance
|
|
37
37
|
const gradientId = useMemo(() => `donut-gradient-${Math.random().toString(36).substr(2, 9)}`, []);
|
|
38
38
|
// Determine colors based on props or theme - simplified logic
|
|
39
|
+
// Resolves CSS variables to computed values for SVG attribute compatibility
|
|
39
40
|
const getColors = useMemo(() => {
|
|
40
41
|
var _a, _b;
|
|
41
42
|
// If colors prop has both from and to, use gradient
|
|
42
43
|
if ((colors === null || colors === void 0 ? void 0 : colors.from) && (colors === null || colors === void 0 ? void 0 : colors.to)) {
|
|
43
44
|
return {
|
|
44
45
|
type: "gradient",
|
|
45
|
-
from: colors.from,
|
|
46
|
-
to: colors.to,
|
|
46
|
+
from: resolveCssVariable(colors.from),
|
|
47
|
+
to: resolveCssVariable(colors.to),
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
// If colors prop has primary, use solid color
|
|
50
51
|
if (colors === null || colors === void 0 ? void 0 : colors.primary) {
|
|
51
52
|
return {
|
|
52
53
|
type: "solid",
|
|
53
|
-
color: colors.primary,
|
|
54
|
+
color: resolveCssVariable(colors.primary),
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
|
-
// Use theme defaults (gradient)
|
|
57
|
+
// Use theme defaults (gradient) - resolve CSS variables
|
|
58
|
+
const primaryColor = resolveCssVariable(((_a = theme.colors) === null || _a === void 0 ? void 0 : _a.primary) || "", "#3b82f6");
|
|
59
|
+
const secondaryColor = resolveCssVariable(((_b = theme.colors) === null || _b === void 0 ? void 0 : _b.secondary) || "", "#10b981");
|
|
57
60
|
return {
|
|
58
61
|
type: "gradient",
|
|
59
|
-
from:
|
|
60
|
-
to:
|
|
62
|
+
from: primaryColor,
|
|
63
|
+
to: secondaryColor,
|
|
61
64
|
};
|
|
62
65
|
}, [colors, theme.colors]);
|
|
63
66
|
const segmentDefinitions = useMemo(() => {
|
|
@@ -148,7 +151,7 @@ const DonutChart = ({ variant = "solid", percentage, label, subtitle, size = 200
|
|
|
148
151
|
isSegmentedVariant ? (React__default.createElement("g", null,
|
|
149
152
|
segmentDefinitions.map((segment, index) => {
|
|
150
153
|
var _a;
|
|
151
|
-
return (React__default.createElement("path", { key: `donut-track-${index}`, d: segment.trackPath, fill: ((_a = theme.colors) === null || _a === void 0 ? void 0 : _a.track) || "#e5e7eb", opacity: 0.25 }));
|
|
154
|
+
return (React__default.createElement("path", { key: `donut-track-${index}`, d: segment.trackPath, fill: resolveCssVariable(((_a = theme.colors) === null || _a === void 0 ? void 0 : _a.track) || "", "#e5e7eb"), opacity: 0.25 }));
|
|
152
155
|
}),
|
|
153
156
|
segmentDefinitions.map((segment, index) => segment.activePath ? (React__default.createElement(motion.path, { key: `donut-active-${index}`, d: segment.activePath, fill: resolveSegmentFill(segment.colorFactor), initial: { opacity: 0, scale: 0.95 }, animate: hasAnimated ? { opacity: 1, scale: 1 } : {}, transition: showAnimation && !shouldReduceMotion
|
|
154
157
|
? {
|
|
@@ -5,6 +5,9 @@ import { DonutChartThemeOverrides } from "./DonutChart.types";
|
|
|
5
5
|
export declare const donutChartTheme: DonutChartThemeOverrides;
|
|
6
6
|
/**
|
|
7
7
|
* Pre-defined color schemes for quick customization
|
|
8
|
+
* Note: These use hex values as they're required for gradient interpolation
|
|
9
|
+
* via the interpolateHexColor function. Users can also pass CSS variables
|
|
10
|
+
* which will be resolved at runtime.
|
|
8
11
|
*/
|
|
9
12
|
export declare const donutChartColorSchemes: {
|
|
10
13
|
readonly default: {
|
|
@@ -13,11 +13,12 @@ const donutChartTheme = {
|
|
|
13
13
|
label: "text-2xl font-bold text-[var(--color-text-primary)] transition-colors duration-300 tracking-tight",
|
|
14
14
|
subtitle: "text-sm text-[var(--color-text-secondary)] mt-1 transition-colors duration-300",
|
|
15
15
|
},
|
|
16
|
-
// Default color palette
|
|
16
|
+
// Default color palette (CSS variables for dark mode support)
|
|
17
|
+
// Note: These are resolved at runtime via getComputedStyle
|
|
17
18
|
colors: {
|
|
18
|
-
primary: "
|
|
19
|
-
secondary: "
|
|
20
|
-
track: "
|
|
19
|
+
primary: "var(--color-primary)",
|
|
20
|
+
secondary: "var(--color-success)",
|
|
21
|
+
track: "var(--color-border)",
|
|
21
22
|
},
|
|
22
23
|
};
|
|
23
24
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared utility functions for DonutChart components
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Resolves a CSS variable to its computed value
|
|
6
|
+
* Falls back to the provided value if not a CSS variable or resolution fails
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolveCssVariable: (value: string, fallback?: string) => string;
|
|
4
9
|
/**
|
|
5
10
|
* Clamps a value between a minimum and maximum
|
|
6
11
|
*/
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared utility functions for DonutChart components
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Resolves a CSS variable to its computed value
|
|
6
|
+
* Falls back to the provided value if not a CSS variable or resolution fails
|
|
7
|
+
*/
|
|
8
|
+
const resolveCssVariable = (value, fallback) => {
|
|
9
|
+
var _a;
|
|
10
|
+
// If not a CSS variable, return as-is
|
|
11
|
+
if (!value.startsWith("var(")) {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
// Check if we're in a browser environment
|
|
15
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
16
|
+
return fallback || value;
|
|
17
|
+
}
|
|
18
|
+
// Extract variable name from var(--name) or var(--name, fallback)
|
|
19
|
+
const match = value.match(/var\(([^,)]+)(?:,\s*([^)]+))?\)/);
|
|
20
|
+
if (!match) {
|
|
21
|
+
return fallback || value;
|
|
22
|
+
}
|
|
23
|
+
const varName = match[1].trim();
|
|
24
|
+
const cssDefault = (_a = match[2]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
25
|
+
// Get computed value from document root
|
|
26
|
+
const computed = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
27
|
+
return computed || cssDefault || fallback || value;
|
|
28
|
+
};
|
|
4
29
|
/**
|
|
5
30
|
* Clamps a value between a minimum and maximum
|
|
6
31
|
*/
|
|
@@ -112,4 +137,4 @@ const interpolateHexColor = (from, to, factor) => {
|
|
|
112
137
|
return `rgb(${r}, ${g}, ${b})`;
|
|
113
138
|
};
|
|
114
139
|
|
|
115
|
-
export { clamp, describeArcPathClockwise, describeRingSegmentPath, hexToRgb, interpolateHexColor, polarToCartesian };
|
|
140
|
+
export { clamp, describeArcPathClockwise, describeRingSegmentPath, hexToRgb, interpolateHexColor, polarToCartesian, resolveCssVariable };
|
|
@@ -9,8 +9,8 @@ const heatmapTheme = {
|
|
|
9
9
|
gridStyle: "absolute inset-0",
|
|
10
10
|
// Base cell styles (individual cells add opacity via inline styles)
|
|
11
11
|
cellBaseStyle: "relative w-full h-full cursor-pointer border border-transparent transition-all duration-500 animate-[flicker_0.6s_ease-out_forwards]",
|
|
12
|
-
// Axis labels using
|
|
13
|
-
axisLabelStyle: "text-xs text-
|
|
12
|
+
// Axis labels using CSS variables for dark mode support
|
|
13
|
+
axisLabelStyle: "text-xs text-[var(--color-text-secondary)] font-medium select-none",
|
|
14
14
|
// Legend using correct CSS variables
|
|
15
15
|
legendStyle: "w-full space-y-1.5 mt-3",
|
|
16
16
|
};
|