flikkui 0.1.0-beta.3 → 0.1.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +155 -0
  2. package/dist/components/charts/AreaChart/AreaChart.js +434 -0
  3. package/dist/components/charts/AreaChart/AreaChart.types.js +7 -0
  4. package/dist/components/charts/BarChart/BarChart.js +402 -0
  5. package/dist/components/charts/BarChart/BarChart.types.js +7 -0
  6. package/dist/components/charts/ChartContainer.js +38 -0
  7. package/dist/components/charts/Heatmap/Heatmap.js +153 -0
  8. package/dist/components/charts/Heatmap/HeatmapCell.js +100 -0
  9. package/dist/components/charts/Heatmap/HeatmapLegend.js +20 -0
  10. package/dist/components/charts/Heatmap/utils/heatmapUtils.js +174 -0
  11. package/dist/components/charts/LineChart/LineChart.js +396 -0
  12. package/dist/components/charts/LineChart/LineChart.types.js +7 -0
  13. package/dist/components/charts/hooks/useChartAccessibility.js +127 -0
  14. package/dist/components/charts/hooks/useChartTheme.js +86 -0
  15. package/dist/components/charts/hooks/useChartValidation.js +59 -0
  16. package/dist/components/charts/hooks/useTooltipPosition.js +292 -0
  17. package/dist/components/charts/shared/ChartAxis/XAxis.js +30 -0
  18. package/dist/components/charts/shared/ChartAxis/YAxis.js +97 -0
  19. package/dist/components/charts/shared/ChartCrosshair/ChartCrosshair.js +35 -0
  20. package/dist/components/charts/shared/ChartCrosshair/ChartCrosshair.theme.js +11 -0
  21. package/dist/components/charts/shared/ChartErrorBoundary/ChartErrorBoundary.js +66 -0
  22. package/dist/components/charts/shared/ChartGrid/HorizontalGrid.js +22 -0
  23. package/dist/components/charts/shared/ChartLegend/ChartLegend.js +30 -0
  24. package/dist/components/charts/shared/ChartLegend/ChartLegendContent.js +22 -0
  25. package/dist/components/charts/shared/ChartMarker/ChartMarker.js +25 -0
  26. package/dist/components/charts/shared/ChartMarker/ChartMarker.theme.js +9 -0
  27. package/dist/components/charts/shared/ChartText/ChartText.js +33 -0
  28. package/dist/components/charts/shared/ChartText/ChartText.theme.js +9 -0
  29. package/dist/components/charts/shared/ChartTooltip/ChartTooltip.js +62 -0
  30. package/dist/components/charts/theme/chart.theme.js +73 -0
  31. package/dist/components/charts/types/chart.types.js +29 -0
  32. package/dist/components/charts/utils/chart-validation.js +292 -0
  33. package/dist/components/charts/utils/color-utils.js +175 -0
  34. package/dist/components/core/Accordion/Accordion.animations.js +45 -0
  35. package/dist/components/core/Accordion/Accordion.js +52 -0
  36. package/dist/components/core/Accordion/Accordion.theme.js +8 -0
  37. package/dist/components/core/Accordion/AccordionContent.js +25 -0
  38. package/dist/components/core/Accordion/AccordionItem.js +56 -0
  39. package/dist/components/core/Accordion/AccordionTrigger.js +32 -0
  40. package/dist/components/core/Accordion/index.js +5 -0
  41. package/dist/components/core/Avatar/Avatar.js +94 -0
  42. package/dist/components/core/Avatar/Avatar.theme.js +25 -0
  43. package/dist/components/core/AvatarGroup/AvatarGroup.animations.js +79 -0
  44. package/dist/components/core/AvatarGroup/AvatarGroup.js +67 -0
  45. package/dist/components/core/AvatarGroup/AvatarGroup.theme.js +23 -0
  46. package/dist/components/core/Badge/Badge.animations.js +109 -0
  47. package/dist/components/core/Badge/Badge.js +101 -0
  48. package/dist/components/core/Badge/Badge.theme.js +41 -0
  49. package/dist/components/core/Breadcrumbs/Breadcrumbs.theme.js +8 -8
  50. package/dist/components/core/Button/Button.theme.js +5 -5
  51. package/dist/components/core/Card/Card.js +46 -0
  52. package/dist/components/core/Card/Card.theme.js +5 -0
  53. package/dist/components/core/Divider/Divider.js +21 -0
  54. package/dist/components/core/Divider/Divider.theme.js +19 -0
  55. package/dist/components/core/Pagination/Pagination.js +113 -0
  56. package/dist/components/core/Pagination/Pagination.theme.js +27 -0
  57. package/dist/components/core/Segmented/Segmented.js +69 -0
  58. package/dist/components/core/Segmented/Segmented.theme.js +40 -0
  59. package/dist/components/core/Segmented/SegmentedContext.js +8 -0
  60. package/dist/components/core/Segmented/SegmentedItem.js +30 -0
  61. package/dist/components/core/Stepper/Stepper.js +57 -0
  62. package/dist/components/core/Stepper/Stepper.theme.js +9 -0
  63. package/dist/components/core/Stepper/components/ConnectorLine.js +42 -0
  64. package/dist/components/core/Stepper/components/IconCircle.js +44 -0
  65. package/dist/components/core/Stepper/components/ProgressIndicator.js +12 -0
  66. package/dist/components/core/Stepper/components/StepContent.js +36 -0
  67. package/dist/components/core/Stepper/components/StepperItem.js +22 -0
  68. package/dist/components/core/Tabs/Tabs.theme.js +2 -2
  69. package/dist/components/core/Tooltip/Tooltip.animations.js +46 -0
  70. package/dist/components/core/Tooltip/Tooltip.js +85 -0
  71. package/dist/components/core/Tooltip/Tooltip.theme.js +11 -0
  72. package/dist/components/core/Tooltip/useTooltipPositioning.js +59 -0
  73. package/dist/components/core/Tree/Tree.animations.js +38 -0
  74. package/dist/components/core/Tree/Tree.js +177 -0
  75. package/dist/components/core/Tree/Tree.theme.js +11 -0
  76. package/dist/components/data-display/Table/Table.js +177 -0
  77. package/dist/components/data-display/Table/Table.theme.js +28 -0
  78. package/dist/components/data-display/Table/Table.utils.js +28 -0
  79. package/dist/components/data-display/Table/components/DeclarativeComponents.js +123 -0
  80. package/dist/components/data-display/Table/components/TableActions/TableActions.js +56 -0
  81. package/dist/components/data-display/Table/components/TableActions/TableActionsMenu.js +29 -0
  82. package/dist/components/data-display/Table/components/TableColumnManager/TableColumnManager.js +85 -0
  83. package/dist/components/data-display/Table/components/TableColumnManager/TableColumnManager.theme.js +21 -0
  84. package/dist/components/data-display/Table/components/TablePagination/TablePagination.js +51 -0
  85. package/dist/components/data-display/Table/components/TableSelectionHeader/TableSelectionHeader.js +29 -0
  86. package/dist/components/data-display/Table/components/core/TableBody.js +32 -0
  87. package/dist/components/data-display/Table/components/core/TableCell.js +47 -0
  88. package/dist/components/data-display/Table/components/core/TableHeader.js +77 -0
  89. package/dist/components/data-display/Table/components/core/TableRow.js +46 -0
  90. package/dist/components/data-display/Table/index.js +20 -0
  91. package/dist/components/feedback/Alert/Alert.js +36 -0
  92. package/dist/components/feedback/Alert/Alert.theme.js +17 -0
  93. package/dist/components/feedback/ChatMessage/ChatMessage.js +26 -0
  94. package/dist/components/feedback/ChatMessage/ChatMessage.theme.js +16 -0
  95. package/dist/components/feedback/Empty/Empty.js +26 -0
  96. package/dist/components/feedback/Empty/Empty.theme.js +13 -0
  97. package/dist/components/feedback/Notification/Notification.js +41 -0
  98. package/dist/components/feedback/Notification/Notification.theme.js +49 -0
  99. package/dist/components/feedback/Spinner/Spinner.theme.js +3 -3
  100. package/dist/components/feedback/Toast/Toast.animations.js +58 -0
  101. package/dist/components/feedback/Toast/Toast.js +67 -0
  102. package/dist/components/feedback/Toast/Toast.theme.js +18 -0
  103. package/dist/components/feedback/Toast/ToastProvider.js +73 -0
  104. package/dist/components/feedback/Toast/useToast.js +91 -0
  105. package/dist/components/forms/Checkbox/Checkbox.theme.js +1 -1
  106. package/dist/components/forms/FormLabel/FormLabel.theme.js +2 -2
  107. package/dist/components/forms/Input/Input.theme.js +4 -4
  108. package/dist/components/forms/Radio/Radio.theme.js +2 -2
  109. package/dist/components/forms/Select/Select.js +1 -1
  110. package/dist/components/forms/Select/Select.theme.js +5 -5
  111. package/dist/components/forms/Switch/Switch.theme.js +1 -1
  112. package/dist/components/forms/TimePicker/TimePicker.theme.js +19 -19
  113. package/dist/components/forms/forms.theme.js +8 -8
  114. package/dist/components/navigation/NavItem/NavItem.js +93 -0
  115. package/dist/components/navigation/NavItem/NavItem.theme.js +27 -0
  116. package/dist/components/navigation/Sidebar/Sidebar.js +28 -0
  117. package/dist/components/navigation/Sidebar/Sidebar.theme.js +16 -0
  118. package/dist/components/navigation/Sidebar/SidebarContent.js +12 -0
  119. package/dist/components/navigation/Sidebar/SidebarContext.js +38 -0
  120. package/dist/components/navigation/Sidebar/SidebarFooter.js +11 -0
  121. package/dist/components/navigation/Sidebar/SidebarHeader.js +22 -0
  122. package/dist/components/navigation/Sidebar/SidebarNav.js +11 -0
  123. package/dist/components/navigation/Sidebar/SidebarNavGroup.js +19 -0
  124. package/dist/components/navigation/Sidebar/SidebarToggle.js +26 -0
  125. package/dist/icons/core/TickIcon.js +3 -1
  126. package/dist/index.d.ts +29 -4
  127. package/dist/index.js +64 -4
  128. package/dist/node_modules/@heroicons/react/20/solid/esm/ChevronDownIcon.js +26 -0
  129. package/dist/node_modules/@heroicons/react/24/outline/esm/ChevronDoubleLeftIcon.js +28 -0
  130. package/dist/node_modules/@heroicons/react/24/outline/esm/ChevronDoubleRightIcon.js +28 -0
  131. package/dist/node_modules/@heroicons/react/24/outline/esm/ChevronLeftIcon.js +28 -0
  132. package/dist/node_modules/@heroicons/react/24/outline/esm/Cog6ToothIcon.js +32 -0
  133. package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentIcon.js +28 -0
  134. package/dist/node_modules/@heroicons/react/24/outline/esm/EllipsisVerticalIcon.js +28 -0
  135. package/dist/node_modules/@heroicons/react/24/outline/esm/PlusIcon.js +28 -0
  136. package/dist/node_modules/@heroicons/react/24/solid/esm/ArrowPathIcon.js +26 -0
  137. package/dist/node_modules/@heroicons/react/24/solid/esm/BellIcon.js +26 -0
  138. package/dist/node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js +26 -0
  139. package/dist/node_modules/@heroicons/react/24/solid/esm/ExclamationTriangleIcon.js +26 -0
  140. package/dist/node_modules/@heroicons/react/24/solid/esm/InformationCircleIcon.js +26 -0
  141. package/dist/node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js +26 -0
  142. package/dist/node_modules/@heroicons/react/24/solid/esm/XMarkIcon.js +26 -0
  143. package/dist/node_modules/tslib/tslib.es6.js +15 -1
  144. package/dist/utils/dateUtils.js +32 -0
  145. package/dist/utils/debounce.js +21 -0
  146. package/package.json +3 -4
  147. package/dist/styles.css +0 -2
@@ -0,0 +1,22 @@
1
+ import { __rest, __assign } from '../../../../node_modules/tslib/tslib.es6.js';
2
+ import React__default from 'react';
3
+
4
+ /**
5
+ * Basic ChartLegendContent component - minimal implementation
6
+ * TODO: Enhance with full legend content functionality when needed
7
+ */
8
+ var ChartLegendContent = function (_a) {
9
+ var _b = _a.payload, payload = _b === void 0 ? [] : _b, _c = _a.nameKey, nameKey = _c === void 0 ? 'name' : _c, className = _a.className, props = __rest(_a, ["payload", "nameKey", "className"]);
10
+ if (!payload || payload.length === 0) {
11
+ return null;
12
+ }
13
+ return (React__default.createElement("div", __assign({ className: "flex flex-wrap gap-4 ".concat(className || '') }, props), payload.map(function (entry, index) {
14
+ var name = entry[nameKey] || entry.dataKey || "Series ".concat(index + 1);
15
+ var color = entry.color || '#8884d8';
16
+ return (React__default.createElement("div", { key: index, className: "flex items-center gap-2" },
17
+ React__default.createElement("div", { className: "w-3 h-3 rounded", style: { backgroundColor: color } }),
18
+ React__default.createElement("span", { className: "text-sm text-gray-600" }, name)));
19
+ })));
20
+ };
21
+
22
+ export { ChartLegendContent };
@@ -0,0 +1,25 @@
1
+ import React__default, { useState } from 'react';
2
+ import { cn } from '../../../../utils/cn.js';
3
+ import { chartMarkerTheme } from './ChartMarker.theme.js';
4
+
5
+ /**
6
+ * ChartMarker component for rendering circular data point markers in charts
7
+ * Supports hover scaling with React state for reliable SVG interactions
8
+ */
9
+ var ChartMarker = function (_a) {
10
+ var cx = _a.cx, cy = _a.cy, radius = _a.radius, colorClass = _a.colorClass, className = _a.className, _b = _a.strokeWidth, strokeWidth = _b === void 0 ? 2 : _b, fillColor = _a.fillColor, strokeColor = _a.strokeColor;
11
+ var theme = chartMarkerTheme;
12
+ var _c = useState(false), isHovered = _c[0], setIsHovered = _c[1];
13
+ // Extract stroke color from colorClass if not provided
14
+ var extractedStrokeColor = strokeColor || colorClass;
15
+ var baseClasses = cn(theme.baseStyle, extractedStrokeColor, className);
16
+ // Calculate hover radius
17
+ var currentRadius = isHovered ? radius * 1.1 : radius;
18
+ return (React__default.createElement("g", { className: "chart-marker" },
19
+ React__default.createElement("circle", { cx: cx, cy: cy, r: currentRadius, className: baseClasses, fill: fillColor || "white", strokeWidth: strokeWidth, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, style: {
20
+ transition: 'linear 0.2s ease-out',
21
+ cursor: 'pointer'
22
+ } })));
23
+ };
24
+
25
+ export { ChartMarker };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Default theme for ChartMarker component
3
+ * Provides consistent styling for chart data point markers
4
+ */
5
+ var chartMarkerTheme = {
6
+ baseStyle: "fill-white stroke-2",
7
+ };
8
+
9
+ export { chartMarkerTheme };
@@ -0,0 +1,33 @@
1
+ import { __rest, __assign } from '../../../../node_modules/tslib/tslib.es6.js';
2
+ import React__default from 'react';
3
+ import { cn } from '../../../../utils/cn.js';
4
+ import { chartTextTheme } from './ChartText.theme.js';
5
+
6
+ /**
7
+ * ChartText component for consistent typography in charts
8
+ * Uses fixed Tailwind styling for consistency
9
+ */
10
+ var ChartText = function (_a) {
11
+ var children = _a.children, _b = _a.textAnchor, textAnchor = _b === void 0 ? "start" : _b, _c = _a.dominantBaseline, dominantBaseline = _c === void 0 ? "auto" : _c, maxWidth = _a.maxWidth, _d = _a.truncate, truncate = _d === void 0 ? false : _d, _e = _a.rotation, rotation = _e === void 0 ? 0 : _e, className = _a.className, props = __rest(_a, ["children", "textAnchor", "dominantBaseline", "maxWidth", "truncate", "rotation", "className"]);
12
+ var theme = chartTextTheme;
13
+ // Truncate text if needed
14
+ var truncateText = function (text, maxWidth) {
15
+ // Rough estimate: 6px per character for text-sm
16
+ if (!maxWidth || text.length <= maxWidth / 6) {
17
+ return text;
18
+ }
19
+ var maxChars = Math.floor(maxWidth / 6) - 3;
20
+ return text.substring(0, maxChars) + "...";
21
+ };
22
+ // Process children to handle truncation
23
+ var processedChildren = React__default.useMemo(function () {
24
+ if (!truncate || !maxWidth || typeof children !== "string") {
25
+ return children;
26
+ }
27
+ return truncateText(children, maxWidth);
28
+ }, [children, truncate, maxWidth]);
29
+ var x = props.x, y = props.y;
30
+ return (React__default.createElement("text", __assign({ textAnchor: textAnchor, dominantBaseline: dominantBaseline, className: cn(theme.baseStyle, className), transform: rotation !== 0 && x !== undefined && y !== undefined ? "rotate(".concat(rotation, ", ").concat(x, ", ").concat(y, ")") : undefined }, props), processedChildren));
31
+ };
32
+
33
+ export { ChartText };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Default theme for ChartText component
3
+ * Uses fixed Tailwind styling for consistency across charts
4
+ */
5
+ var chartTextTheme = {
6
+ baseStyle: "transition-all duration-200 text-xs text-text-secondary/80 fill-text-secondary/80 font-medium select-none",
7
+ };
8
+
9
+ export { chartTextTheme };
@@ -0,0 +1,62 @@
1
+ import { __rest, __assign } from '../../../../node_modules/tslib/tslib.es6.js';
2
+ import React__default from 'react';
3
+ import { cn } from '../../../../utils/cn.js';
4
+ import { AnimatePresence } from '../../../../node_modules/framer-motion/dist/es/components/AnimatePresence/index.js';
5
+ import { motion } from '../../../../node_modules/framer-motion/dist/es/render/components/motion/proxy.js';
6
+
7
+ // Helper function to check if content is MultiSeriesData
8
+ var isMultiSeriesData = function (content) {
9
+ return content && typeof content === 'object' && 'category' in content && 'series' in content;
10
+ };
11
+ // Component to render multi-series tooltip content
12
+ var MultiSeriesContent = function (_a) {
13
+ var data = _a.data, containerClassName = _a.containerClassName, categoryClassName = _a.categoryClassName, seriesContainerClassName = _a.seriesContainerClassName, seriesRowClassName = _a.seriesRowClassName, dotClassName = _a.dotClassName, labelClassName = _a.labelClassName, valueClassName = _a.valueClassName;
14
+ return (React__default.createElement("div", { className: cn("text-left", containerClassName) },
15
+ React__default.createElement("div", { className: cn("font-medium mb-1", categoryClassName) }, data.category),
16
+ React__default.createElement("div", { className: cn("space-y-0.5", seriesContainerClassName) }, data.series.map(function (item, index) { return (React__default.createElement("div", { key: index, className: cn("flex items-center justify-between gap-3", seriesRowClassName) },
17
+ React__default.createElement("div", { className: "flex items-center gap-1" },
18
+ item.color && (React__default.createElement("div", { className: cn("w-2 h-2 rounded-[2px]", dotClassName), style: { backgroundColor: item.color } })),
19
+ React__default.createElement("span", { className: cn("text-sm opacity-90", labelClassName) }, item.label || item.key)),
20
+ React__default.createElement("span", { className: cn("text-sm font-semibold", valueClassName) }, item.value))); }))));
21
+ };
22
+ function ChartTooltip(_a) {
23
+ var content = _a.content, className = _a.className, _b = _a.active, active = _b === void 0 ? false : _b, _c = _a.position, position = _c === void 0 ? { x: 0, y: 0 } : _c, children = _a.children; _a.chartType; var containerClassName = _a.containerClassName, categoryClassName = _a.categoryClassName, seriesContainerClassName = _a.seriesContainerClassName, seriesRowClassName = _a.seriesRowClassName, dotClassName = _a.dotClassName, labelClassName = _a.labelClassName, valueClassName = _a.valueClassName, tooltipRef = _a.tooltipRef, props = __rest(_a, ["content", "className", "active", "position", "children", "chartType", "containerClassName", "categoryClassName", "seriesContainerClassName", "seriesRowClassName", "dotClassName", "labelClassName", "valueClassName", "tooltipRef"]);
24
+ return (React__default.createElement(React__default.Fragment, null,
25
+ children,
26
+ React__default.createElement(AnimatePresence, null, active && content && (React__default.createElement(motion.div, __assign({ ref: tooltipRef, initial: {
27
+ opacity: 0,
28
+ scale: 0.95,
29
+ x: position.x,
30
+ y: position.y
31
+ }, animate: {
32
+ opacity: 1,
33
+ scale: 1,
34
+ x: position.x,
35
+ y: position.y - 30,
36
+ transition: {
37
+ type: "spring",
38
+ stiffness: 400,
39
+ damping: 30,
40
+ opacity: { duration: 0.15 },
41
+ scale: { duration: 0.15 }
42
+ },
43
+ }, exit: {
44
+ opacity: 0,
45
+ scale: 0.95,
46
+ x: position.x,
47
+ y: position.y - 10,
48
+ transition: {
49
+ type: "spring",
50
+ stiffness: 300,
51
+ damping: 25,
52
+ duration: 0.15,
53
+ },
54
+ }, className: cn("fixed z-50 bg-black/80 backdrop-blur-sm text-white rounded-lg px-3 py-2 shadow-xl shadow-neutral-900/30 pointer-events-none border-white/50 border-t-[1px]", className), style: {
55
+ left: 0,
56
+ top: 0,
57
+ transform: "translate(-50%, -100%)",
58
+ } }, props),
59
+ React__default.createElement("div", { className: cn("whitespace-nowrap text-sm", isMultiSeriesData(content) ? "text-left" : "text-center") }, isMultiSeriesData(content) ? (React__default.createElement(MultiSeriesContent, { data: content, containerClassName: containerClassName, categoryClassName: categoryClassName, seriesContainerClassName: seriesContainerClassName, seriesRowClassName: seriesRowClassName, dotClassName: dotClassName, labelClassName: labelClassName, valueClassName: valueClassName })) : (content)))))));
60
+ }
61
+
62
+ export { ChartTooltip };
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Default theme for Chart components
3
+ * Uses Tailwind classes with CSS variables for consistency with the design system
4
+ */
5
+ var chartTheme = {
6
+ baseStyle: {
7
+ colors: {
8
+ // Default series colors using your design system colors
9
+ series: [
10
+ 'fill-[var(--color-primary)] stroke-[var(--color-primary)]', // Primary
11
+ 'fill-[var(--color-warning)] stroke-[var(--color-warning)]', // Warning/Orange
12
+ 'fill-[var(--color-success)] stroke-[var(--color-success)]', // Success/Green
13
+ 'fill-[var(--color-danger)] stroke-[var(--color-danger)]', // Danger/Red
14
+ 'fill-[var(--color-primary-400)] stroke-[var(--color-primary-400)]', // Primary lighter
15
+ 'fill-[var(--color-warning-400)] stroke-[var(--color-warning-400)]', // Warning lighter
16
+ 'fill-[var(--color-success-400)] stroke-[var(--color-success-400)]', // Success lighter
17
+ 'fill-[var(--color-danger-400)] stroke-[var(--color-danger-400)]', // Danger lighter
18
+ ],
19
+ // Chart infrastructure colors
20
+ grid: 'stroke-neutral-200',
21
+ axis: 'stroke-neutral-300',
22
+ text: 'fill-text-secondary',
23
+ background: 'fill-white',
24
+ hover: 'fill-neutral-100',
25
+ disabled: 'fill-neutral-200',
26
+ },
27
+ opacity: {
28
+ default: 'opacity-100',
29
+ hover: 'opacity-80',
30
+ disabled: 'opacity-50',
31
+ },
32
+ transitions: {
33
+ default: 'transition-all duration-200',
34
+ hover: 'transition-all duration-150',
35
+ },
36
+ },
37
+ variants: {
38
+ default: {
39
+ colors: [
40
+ 'fill-[var(--color-primary)] stroke-[var(--color-primary)]',
41
+ 'fill-[var(--color-warning)] stroke-[var(--color-warning)]',
42
+ 'fill-[var(--color-success)] stroke-[var(--color-success)]',
43
+ 'fill-[var(--color-danger)] stroke-[var(--color-danger)]',
44
+ 'fill-[var(--color-primary-400)] stroke-[var(--color-primary-400)]',
45
+ 'fill-[var(--color-warning-400)] stroke-[var(--color-warning-400)]',
46
+ 'fill-[var(--color-success-400)] stroke-[var(--color-success-400)]',
47
+ 'fill-[var(--color-danger-400)] stroke-[var(--color-danger-400)]',
48
+ ],
49
+ },
50
+ minimal: {
51
+ colors: [
52
+ 'fill-neutral-600 stroke-neutral-600',
53
+ 'fill-neutral-500 stroke-neutral-500',
54
+ 'fill-neutral-400 stroke-neutral-400',
55
+ 'fill-neutral-300 stroke-neutral-300',
56
+ 'fill-neutral-700 stroke-neutral-700',
57
+ 'fill-neutral-800 stroke-neutral-800',
58
+ ],
59
+ },
60
+ gradient: {
61
+ colors: [
62
+ 'fill-[var(--color-primary)] stroke-[var(--color-primary)]',
63
+ 'fill-[var(--color-primary-400)] stroke-[var(--color-primary-400)]',
64
+ 'fill-[var(--color-primary-500)] stroke-[var(--color-primary-500)]',
65
+ 'fill-[var(--color-primary-600)] stroke-[var(--color-primary-600)]',
66
+ 'fill-[var(--color-primary-700)] stroke-[var(--color-primary-700)]',
67
+ 'fill-[var(--color-primary-800)] stroke-[var(--color-primary-800)]',
68
+ ],
69
+ },
70
+ },
71
+ };
72
+
73
+ export { chartTheme };
@@ -0,0 +1,29 @@
1
+ // Standardized Chart Defaults
2
+ var CHART_DEFAULTS = {
3
+ // Display options
4
+ showGrid: true,
5
+ showXAxis: true,
6
+ showYAxis: true,
7
+ showNullValues: true,
8
+ // Visual properties
9
+ radius: 4, // For dots, bars, cells
10
+ strokeWidth: 2,
11
+ gap: 4, // For bars, cells
12
+ categoryGap: 16, // For bar categories
13
+ // Line/Area specific
14
+ curved: true,
15
+ curveType: 'monotone',
16
+ fillOpacity: 0.3,
17
+ showStroke: true,
18
+ showDots: true,
19
+ // Bar specific
20
+ orientation: 'vertical',
21
+ // Layout
22
+ stacked: false,
23
+ // Theme
24
+ variant: 'default',
25
+ // Accessibility
26
+ enableKeyboardNavigation: true,
27
+ };
28
+
29
+ export { CHART_DEFAULTS };
@@ -0,0 +1,292 @@
1
+ /**
2
+ * Safe math operations to prevent division by zero and other edge cases
3
+ */
4
+ var SafeMath = /** @class */ (function () {
5
+ function SafeMath() {
6
+ }
7
+ /**
8
+ * Safe division that returns 0 when dividing by zero
9
+ */
10
+ SafeMath.divide = function (numerator, denominator, fallback) {
11
+ if (fallback === void 0) { fallback = 0; }
12
+ if (denominator === 0 || !isFinite(denominator)) {
13
+ return fallback;
14
+ }
15
+ var result = numerator / denominator;
16
+ return isFinite(result) ? result : fallback;
17
+ };
18
+ /**
19
+ * Safe percentage calculation
20
+ */
21
+ SafeMath.percentage = function (value, total, fallback) {
22
+ if (fallback === void 0) { fallback = 0; }
23
+ return this.divide(value * 100, total, fallback);
24
+ };
25
+ /**
26
+ * Safe Math.max that handles empty arrays
27
+ */
28
+ SafeMath.max = function (values, fallback) {
29
+ if (fallback === void 0) { fallback = 0; }
30
+ if (!Array.isArray(values) || values.length === 0) {
31
+ return fallback;
32
+ }
33
+ var filtered = values.filter(function (v) { return isFinite(v); });
34
+ return filtered.length > 0 ? Math.max.apply(Math, filtered) : fallback;
35
+ };
36
+ /**
37
+ * Safe Math.min that handles empty arrays
38
+ */
39
+ SafeMath.min = function (values, fallback) {
40
+ if (fallback === void 0) { fallback = 0; }
41
+ if (!Array.isArray(values) || values.length === 0) {
42
+ return fallback;
43
+ }
44
+ var filtered = values.filter(function (v) { return isFinite(v); });
45
+ return filtered.length > 0 ? Math.min.apply(Math, filtered) : fallback;
46
+ };
47
+ /**
48
+ * Safe scale calculation for chart positioning
49
+ */
50
+ SafeMath.scale = function (value, min, max, targetMin, targetMax) {
51
+ if (targetMin === void 0) { targetMin = 0; }
52
+ if (targetMax === void 0) { targetMax = 1; }
53
+ var range = max - min;
54
+ if (range === 0) {
55
+ return targetMin + (targetMax - targetMin) / 2; // Return middle of target range
56
+ }
57
+ var ratio = this.divide(value - min, range);
58
+ return targetMin + ratio * (targetMax - targetMin);
59
+ };
60
+ /**
61
+ * Clamp a value between min and max
62
+ */
63
+ SafeMath.clamp = function (value, min, max) {
64
+ return Math.min(Math.max(value, min), max);
65
+ };
66
+ return SafeMath;
67
+ }());
68
+ /**
69
+ * Validates chart data array
70
+ */
71
+ function validateChartData(data) {
72
+ var errors = [];
73
+ var warnings = [];
74
+ // Check if data exists
75
+ if (!data) {
76
+ errors.push({
77
+ type: 'data',
78
+ message: 'Chart data is required but was not provided',
79
+ field: 'data'
80
+ });
81
+ return { isValid: false, errors: errors, warnings: warnings };
82
+ }
83
+ // Check if data is an array
84
+ if (!Array.isArray(data)) {
85
+ errors.push({
86
+ type: 'data',
87
+ message: 'Chart data must be an array',
88
+ field: 'data'
89
+ });
90
+ return { isValid: false, errors: errors, warnings: warnings };
91
+ }
92
+ // Check if data is empty
93
+ if (data.length === 0) {
94
+ warnings.push({
95
+ type: 'data',
96
+ message: 'Chart data array is empty',
97
+ field: 'data'
98
+ });
99
+ }
100
+ // Validate each data item
101
+ data.forEach(function (item, index) {
102
+ if (!item || typeof item !== 'object') {
103
+ errors.push({
104
+ type: 'data',
105
+ message: "Data item at index ".concat(index, " must be an object"),
106
+ field: "data[".concat(index, "]")
107
+ });
108
+ return;
109
+ }
110
+ // Check for at least one numeric value
111
+ var hasNumericValue = Object.values(item).some(function (value) {
112
+ return typeof value === 'number' && isFinite(value);
113
+ });
114
+ if (!hasNumericValue) {
115
+ warnings.push({
116
+ type: 'data',
117
+ message: "Data item at index ".concat(index, " has no valid numeric values"),
118
+ field: "data[".concat(index, "]")
119
+ });
120
+ }
121
+ });
122
+ return { isValid: errors.length === 0, errors: errors, warnings: warnings };
123
+ }
124
+ /**
125
+ * Validates chart configuration
126
+ */
127
+ function validateChartConfig(config) {
128
+ var errors = [];
129
+ var warnings = [];
130
+ // Check if config exists
131
+ if (!config) {
132
+ errors.push({
133
+ type: 'config',
134
+ message: 'Chart config is required but was not provided',
135
+ field: 'config'
136
+ });
137
+ return { isValid: false, errors: errors, warnings: warnings };
138
+ }
139
+ // Check if config is an object
140
+ if (typeof config !== 'object') {
141
+ errors.push({
142
+ type: 'config',
143
+ message: 'Chart config must be an object',
144
+ field: 'config'
145
+ });
146
+ return { isValid: false, errors: errors, warnings: warnings };
147
+ }
148
+ // Check if config has any keys
149
+ var configKeys = Object.keys(config);
150
+ if (configKeys.length === 0) {
151
+ warnings.push({
152
+ type: 'config',
153
+ message: 'Chart config is empty - no data series will be displayed',
154
+ field: 'config'
155
+ });
156
+ }
157
+ return { isValid: errors.length === 0, errors: errors, warnings: warnings };
158
+ }
159
+ /**
160
+ * Validates that data and config are compatible
161
+ */
162
+ function validateDataConfigCompatibility(data, config) {
163
+ var errors = [];
164
+ var warnings = [];
165
+ var configKeys = Object.keys(config);
166
+ var dataKeys = data.length > 0 ? Object.keys(data[0]) : [];
167
+ // Check if any config keys exist in data
168
+ var validKeys = configKeys.filter(function (key) {
169
+ return dataKeys.includes(key) &&
170
+ data.some(function (item) { return typeof item[key] === 'number' && isFinite(item[key]); });
171
+ });
172
+ if (validKeys.length === 0) {
173
+ errors.push({
174
+ type: 'config',
175
+ message: 'No config keys match valid numeric data fields',
176
+ field: 'config'
177
+ });
178
+ }
179
+ // Warn about config keys that don't exist in data
180
+ var missingKeys = configKeys.filter(function (key) { return !dataKeys.includes(key); });
181
+ missingKeys.forEach(function (key) {
182
+ warnings.push({
183
+ type: 'config',
184
+ message: "Config key \"".concat(key, "\" not found in data"),
185
+ field: "config.".concat(key)
186
+ });
187
+ });
188
+ return { isValid: errors.length === 0, errors: errors, warnings: warnings };
189
+ }
190
+ /**
191
+ * Sanitizes chart data by removing invalid entries and normalizing values
192
+ */
193
+ function sanitizeChartData(data) {
194
+ if (!Array.isArray(data)) {
195
+ return [];
196
+ }
197
+ return data
198
+ .filter(function (item) { return item && typeof item === 'object'; })
199
+ .map(function (item) {
200
+ var sanitized = {};
201
+ Object.entries(item).forEach(function (_a) {
202
+ var key = _a[0], value = _a[1];
203
+ if (typeof value === 'number') {
204
+ // Replace NaN and Infinity with null
205
+ sanitized[key] = isFinite(value) ? value : null;
206
+ }
207
+ else if (typeof value === 'string') {
208
+ // Keep string values (like names, categories)
209
+ sanitized[key] = value;
210
+ }
211
+ else if (value === null || value === undefined) {
212
+ // Keep explicit null/undefined
213
+ sanitized[key] = null;
214
+ }
215
+ // Skip other types (objects, arrays, etc.)
216
+ });
217
+ return sanitized;
218
+ });
219
+ }
220
+ /**
221
+ * Calculates safe min/max values for chart scales
222
+ */
223
+ function calculateSafeScaleRange(data, config, options) {
224
+ if (options === void 0) { options = {}; }
225
+ var propMin = options.minValue, propMax = options.maxValue, _a = options.includeZero, includeZero = _a === void 0 ? true : _a, _b = options.padding, padding = _b === void 0 ? 0.1 : _b;
226
+ // If both min and max are provided, use them
227
+ if (propMin !== undefined && propMax !== undefined) {
228
+ return {
229
+ min: propMin,
230
+ max: propMax,
231
+ hasValidData: true
232
+ };
233
+ }
234
+ var configKeys = Object.keys(config);
235
+ var allValues = [];
236
+ // Extract all numeric values
237
+ data.forEach(function (item) {
238
+ configKeys.forEach(function (key) {
239
+ var value = item[key];
240
+ if (typeof value === 'number' && isFinite(value)) {
241
+ allValues.push(value);
242
+ }
243
+ });
244
+ });
245
+ // No valid data found
246
+ if (allValues.length === 0) {
247
+ return {
248
+ min: propMin !== null && propMin !== void 0 ? propMin : 0,
249
+ max: propMax !== null && propMax !== void 0 ? propMax : 100,
250
+ hasValidData: false
251
+ };
252
+ }
253
+ var min = propMin !== null && propMin !== void 0 ? propMin : SafeMath.min(allValues);
254
+ var max = propMax !== null && propMax !== void 0 ? propMax : SafeMath.max(allValues);
255
+ // Include zero if requested
256
+ if (includeZero) {
257
+ min = Math.min(min, 0);
258
+ max = Math.max(max, 0);
259
+ }
260
+ // Add padding if min and max are the same
261
+ if (min === max) {
262
+ var absValue = Math.abs(min);
263
+ var paddingValue = absValue > 0 ? absValue * padding : 1;
264
+ min -= paddingValue;
265
+ max += paddingValue;
266
+ }
267
+ return { min: min, max: max, hasValidData: true };
268
+ }
269
+ /**
270
+ * Comprehensive chart validation that combines all checks
271
+ */
272
+ function validateChart(data, config) {
273
+ var errors = [];
274
+ var warnings = [];
275
+ // Validate data
276
+ var dataValidation = validateChartData(data);
277
+ errors.push.apply(errors, dataValidation.errors);
278
+ warnings.push.apply(warnings, dataValidation.warnings);
279
+ // Validate config
280
+ var configValidation = validateChartConfig(config);
281
+ errors.push.apply(errors, configValidation.errors);
282
+ warnings.push.apply(warnings, configValidation.warnings);
283
+ // If basic validation passes, check compatibility
284
+ if (dataValidation.isValid && configValidation.isValid) {
285
+ var compatibilityValidation = validateDataConfigCompatibility(data, config);
286
+ errors.push.apply(errors, compatibilityValidation.errors);
287
+ warnings.push.apply(warnings, compatibilityValidation.warnings);
288
+ }
289
+ return { isValid: errors.length === 0, errors: errors, warnings: warnings };
290
+ }
291
+
292
+ export { SafeMath, calculateSafeScaleRange, sanitizeChartData, validateChart, validateChartConfig, validateChartData, validateDataConfigCompatibility };