@monolith-forensics/monolith-ui 1.8.0 → 1.8.1-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/dist/BarChart/BarChart.d.ts +3 -0
  2. package/dist/BarChart/BarChart.js +511 -0
  3. package/dist/BarChart/BarChart.lib.d.ts +31 -0
  4. package/dist/BarChart/BarChart.lib.js +136 -0
  5. package/dist/BarChart/BarChart.styled.d.ts +49 -0
  6. package/dist/BarChart/BarChart.styled.js +111 -0
  7. package/dist/BarChart/BarChart.types.d.ts +170 -0
  8. package/dist/BarChart/BarChart.types.js +1 -0
  9. package/dist/BarChart/index.d.ts +3 -0
  10. package/dist/BarChart/index.js +2 -0
  11. package/dist/Button/Button.js +9 -58
  12. package/dist/Calendar/Calendar.d.ts +3 -1
  13. package/dist/Calendar/Calendar.js +134 -33
  14. package/dist/Calendar/CalendarStyles.d.ts +3 -0
  15. package/dist/Calendar/CalendarStyles.js +92 -14
  16. package/dist/Calendar/calendarHelpers.d.ts +5 -1
  17. package/dist/Calendar/calendarHelpers.js +13 -5
  18. package/dist/ChartPrimitives/chartLegend.styled.d.ts +12 -0
  19. package/dist/ChartPrimitives/chartLegend.styled.js +52 -0
  20. package/dist/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
  21. package/dist/ChartPrimitives/chartTooltip.styled.js +61 -0
  22. package/dist/ChartPrimitives/index.d.ts +2 -0
  23. package/dist/ChartPrimitives/index.js +2 -0
  24. package/dist/ChartUtils/chartColors.d.ts +8 -0
  25. package/dist/ChartUtils/chartColors.js +65 -0
  26. package/dist/ChartUtils/chartMath.d.ts +3 -0
  27. package/dist/ChartUtils/chartMath.js +3 -0
  28. package/dist/ChartUtils/index.d.ts +2 -0
  29. package/dist/ChartUtils/index.js +2 -0
  30. package/dist/Charts/BarChart/BarChart.d.ts +5 -0
  31. package/dist/Charts/BarChart/BarChart.js +549 -0
  32. package/dist/Charts/BarChart/BarChart.lib.d.ts +31 -0
  33. package/dist/Charts/BarChart/BarChart.lib.js +136 -0
  34. package/dist/Charts/BarChart/BarChart.styled.d.ts +51 -0
  35. package/dist/Charts/BarChart/BarChart.styled.js +115 -0
  36. package/dist/Charts/BarChart/BarChart.types.d.ts +171 -0
  37. package/dist/Charts/BarChart/BarChart.types.js +1 -0
  38. package/dist/Charts/BarChart/index.d.ts +3 -0
  39. package/dist/Charts/BarChart/index.js +2 -0
  40. package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +11 -0
  41. package/dist/Charts/ChartPrimitives/ChartExportControl.js +29 -0
  42. package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +1 -0
  43. package/dist/Charts/ChartPrimitives/chartActions.styled.js +8 -0
  44. package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +12 -0
  45. package/dist/Charts/ChartPrimitives/chartLegend.styled.js +52 -0
  46. package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
  47. package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +61 -0
  48. package/dist/Charts/ChartPrimitives/index.d.ts +4 -0
  49. package/dist/Charts/ChartPrimitives/index.js +4 -0
  50. package/dist/Charts/ChartUtils/chartColors.d.ts +8 -0
  51. package/dist/Charts/ChartUtils/chartColors.js +65 -0
  52. package/dist/Charts/ChartUtils/chartExport.d.ts +47 -0
  53. package/dist/Charts/ChartUtils/chartExport.js +311 -0
  54. package/dist/Charts/ChartUtils/chartMath.d.ts +3 -0
  55. package/dist/Charts/ChartUtils/chartMath.js +3 -0
  56. package/dist/Charts/ChartUtils/index.d.ts +3 -0
  57. package/dist/Charts/ChartUtils/index.js +3 -0
  58. package/dist/Charts/HeatMap/HeatMap.d.ts +5 -0
  59. package/dist/Charts/HeatMap/HeatMap.js +212 -0
  60. package/dist/Charts/HeatMap/HeatMap.lib.d.ts +30 -0
  61. package/dist/Charts/HeatMap/HeatMap.lib.js +115 -0
  62. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +37 -0
  63. package/dist/Charts/HeatMap/HeatMap.styled.js +91 -0
  64. package/dist/Charts/HeatMap/HeatMap.types.d.ts +80 -0
  65. package/dist/Charts/HeatMap/HeatMap.types.js +1 -0
  66. package/dist/Charts/HeatMap/index.d.ts +3 -0
  67. package/dist/Charts/HeatMap/index.js +2 -0
  68. package/dist/Charts/LineChart/LineChart.d.ts +5 -0
  69. package/dist/Charts/LineChart/LineChart.js +529 -0
  70. package/dist/Charts/LineChart/LineChart.lib.d.ts +24 -0
  71. package/dist/Charts/LineChart/LineChart.lib.js +132 -0
  72. package/dist/Charts/LineChart/LineChart.styled.d.ts +59 -0
  73. package/dist/Charts/LineChart/LineChart.styled.js +147 -0
  74. package/dist/Charts/LineChart/LineChart.types.d.ts +193 -0
  75. package/dist/Charts/LineChart/LineChart.types.js +1 -0
  76. package/dist/Charts/LineChart/index.d.ts +3 -0
  77. package/dist/Charts/LineChart/index.js +2 -0
  78. package/dist/Charts/PieChart/PieChart.d.ts +4 -0
  79. package/dist/Charts/PieChart/PieChart.js +199 -0
  80. package/dist/Charts/PieChart/PieChart.lib.d.ts +5 -0
  81. package/dist/Charts/PieChart/PieChart.lib.js +19 -0
  82. package/dist/Charts/PieChart/PieChart.styled.d.ts +51 -0
  83. package/dist/Charts/PieChart/PieChart.styled.js +163 -0
  84. package/dist/Charts/PieChart/PieChart.types.d.ts +100 -0
  85. package/dist/Charts/PieChart/PieChart.types.js +1 -0
  86. package/dist/Charts/PieChart/index.d.ts +2 -0
  87. package/dist/Charts/PieChart/index.js +1 -0
  88. package/dist/Charts/index.d.ts +5 -0
  89. package/dist/Charts/index.js +4 -0
  90. package/dist/CheckBox/CheckBox.js +2 -16
  91. package/dist/DateInput/DateInput.js +198 -143
  92. package/dist/DropDownMenu/components/MenuComponent.js +2 -1
  93. package/dist/DropDownMenu/components/MenuItem.js +5 -14
  94. package/dist/DropDownMenu/components/MenuItemList.js +7 -24
  95. package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
  96. package/dist/FieldLabel/FieldLabel.js +4 -12
  97. package/dist/FileInputField/FileInputField.js +4 -23
  98. package/dist/FormSection/FormSection.js +5 -25
  99. package/dist/HeatMap/HeatMap.d.ts +3 -0
  100. package/dist/HeatMap/HeatMap.js +174 -0
  101. package/dist/HeatMap/HeatMap.lib.d.ts +30 -0
  102. package/dist/HeatMap/HeatMap.lib.js +115 -0
  103. package/dist/HeatMap/HeatMap.styled.d.ts +34 -0
  104. package/dist/HeatMap/HeatMap.styled.js +83 -0
  105. package/dist/HeatMap/HeatMap.types.d.ts +79 -0
  106. package/dist/HeatMap/HeatMap.types.js +1 -0
  107. package/dist/HeatMap/index.d.ts +3 -0
  108. package/dist/HeatMap/index.js +2 -0
  109. package/dist/IconButton/IconButton.js +2 -16
  110. package/dist/Input/Input.js +7 -56
  111. package/dist/LineChart/LineChart.d.ts +3 -0
  112. package/dist/LineChart/LineChart.js +491 -0
  113. package/dist/LineChart/LineChart.lib.d.ts +24 -0
  114. package/dist/LineChart/LineChart.lib.js +132 -0
  115. package/dist/LineChart/LineChart.styled.d.ts +57 -0
  116. package/dist/LineChart/LineChart.styled.js +150 -0
  117. package/dist/LineChart/LineChart.types.d.ts +192 -0
  118. package/dist/LineChart/LineChart.types.js +1 -0
  119. package/dist/LineChart/index.d.ts +3 -0
  120. package/dist/LineChart/index.js +2 -0
  121. package/dist/PieChart/PieChart.d.ts +2 -0
  122. package/dist/PieChart/PieChart.js +161 -0
  123. package/dist/PieChart/PieChart.lib.d.ts +5 -0
  124. package/dist/PieChart/PieChart.lib.js +19 -0
  125. package/dist/PieChart/PieChart.styled.d.ts +49 -0
  126. package/dist/PieChart/PieChart.styled.js +161 -0
  127. package/dist/PieChart/PieChart.types.d.ts +99 -0
  128. package/dist/PieChart/PieChart.types.js +1 -0
  129. package/dist/PieChart/index.d.ts +2 -0
  130. package/dist/PieChart/index.js +1 -0
  131. package/dist/Pill/Pill.js +8 -79
  132. package/dist/Popover/Popover.context.d.ts +2 -1
  133. package/dist/Popover/Popover.js +5 -2
  134. package/dist/Popover/Popover.styles.d.ts +1 -6
  135. package/dist/Popover/Popover.styles.js +11 -28
  136. package/dist/Popover/Popover.transitions.d.ts +4 -2
  137. package/dist/Popover/Popover.transitions.js +23 -49
  138. package/dist/Popover/PopoverDropdown.js +6 -8
  139. package/dist/Popover/PopoverTarget.js +6 -3
  140. package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
  141. package/dist/SegmentedControl/SegmentedControl.utils.js +3 -30
  142. package/dist/SelectBox/SelectBox.js +3 -3
  143. package/dist/SelectBox/select-box.styled-components.d.ts +3 -1
  144. package/dist/SelectBox/select-box.styled-components.js +10 -48
  145. package/dist/SuperDatePicker/SuperDatePicker.d.ts +74 -0
  146. package/dist/SuperDatePicker/SuperDatePicker.js +557 -0
  147. package/dist/SuperDatePicker/index.d.ts +2 -0
  148. package/dist/SuperDatePicker/index.js +2 -0
  149. package/dist/Switch/Switch.d.ts +2 -2
  150. package/dist/Switch/Switch.js +18 -83
  151. package/dist/Table/StateStorage.d.ts +4 -0
  152. package/dist/Table/StateStorage.js +13 -0
  153. package/dist/Table/Table.js +160 -12
  154. package/dist/Table/TableComponents.d.ts +10 -0
  155. package/dist/Table/TableComponents.js +57 -0
  156. package/dist/Table/TableDefaults.d.ts +7 -0
  157. package/dist/Table/TableDefaults.js +7 -0
  158. package/dist/Table/TableProvider.js +263 -71
  159. package/dist/Table/TableRow.js +15 -10
  160. package/dist/Table/types.d.ts +64 -0
  161. package/dist/TagBox/TagBox.js +18 -76
  162. package/dist/TextArea/TextArea.js +4 -23
  163. package/dist/TextInput/TextInput.js +12 -6
  164. package/dist/Utilities/parseTimestamp.js +11 -6
  165. package/dist/core/ArrowButton.d.ts +2 -0
  166. package/dist/core/ArrowButton.js +7 -3
  167. package/dist/core/ClearButton.d.ts +2 -0
  168. package/dist/core/ClearButton.js +7 -3
  169. package/dist/core/controlSizes.d.ts +34 -0
  170. package/dist/core/controlSizes.js +190 -0
  171. package/dist/core/index.d.ts +1 -0
  172. package/dist/core/index.js +1 -0
  173. package/dist/index.d.ts +1 -0
  174. package/dist/index.js +1 -0
  175. package/package.json +5 -1
@@ -0,0 +1,161 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { useEffect, useId, useMemo, useRef, useState } from "react";
14
+ import { arc, pie } from "d3-shape";
15
+ import { useTheme } from "styled-components";
16
+ import { clamp, easeOutCubic, formatDefaultValue, getGradientColor, getSliceKey, useThemeColors, } from "./PieChart.lib";
17
+ import { StyledCenter, StyledCenterLabel, StyledCenterPanel, StyledCenterValue, StyledChartWrap, StyledContainer, StyledEmptyState, StyledLabel, StyledLegend, StyledLegendItem, StyledLegendLabel, StyledLegendMeta, StyledLegendPercent, StyledLegendValue, StyledSlice, StyledSvg, StyledSwatch, StyledTooltip, StyledTooltipHeader, StyledTooltipLabel, StyledTooltipMeta, StyledTooltipSwatch, } from "./PieChart.styled";
18
+ export const PieChart = (_a) => {
19
+ var _b, _c;
20
+ var { data, size = 220, innerRadius = 58, outerRadius, cornerRadius = 1, padAngle = 0.004, colors, colorGradient, sliceOpacity = 1, sliceBorderColor, sliceBorderWidth = 1, sliceBorderOpacity = 1, sliceBorderLineJoin = "round", showLegend = true, showLegendSwatches = true, showLegendLabels = true, showLegendValues = true, showLegendPercentages = true, showLabels = false, centerLabel, centerValue, emptyLabel = "No data", ariaLabel = "Pie chart", animateOnRender = false, animationDuration = 520, animationStagger = 35, showTooltips = false, valueFormatter, labelFormatter, tooltipFormatter, onSliceClick, onLegendItemClick, className } = _a, props = __rest(_a, ["data", "size", "innerRadius", "outerRadius", "cornerRadius", "padAngle", "colors", "colorGradient", "sliceOpacity", "sliceBorderColor", "sliceBorderWidth", "sliceBorderOpacity", "sliceBorderLineJoin", "showLegend", "showLegendSwatches", "showLegendLabels", "showLegendValues", "showLegendPercentages", "showLabels", "centerLabel", "centerValue", "emptyLabel", "ariaLabel", "animateOnRender", "animationDuration", "animationStagger", "showTooltips", "valueFormatter", "labelFormatter", "tooltipFormatter", "onSliceClick", "onLegendItemClick", "className"]);
21
+ const descriptionId = useId();
22
+ const theme = useTheme();
23
+ const containerRef = useRef(null);
24
+ const [activeSliceKey, setActiveSliceKey] = useState(null);
25
+ const [activeTooltip, setActiveTooltip] = useState(null);
26
+ const [animationElapsed, setAnimationElapsed] = useState(animateOnRender ? 0 : Number.POSITIVE_INFINITY);
27
+ const themeColors = useThemeColors(colors);
28
+ const validData = useMemo(() => data.filter((datum) => Number.isFinite(datum.value) && datum.value > 0), [data]);
29
+ const total = useMemo(() => validData.reduce((sum, datum) => sum + datum.value, 0), [validData]);
30
+ const radius = outerRadius !== null && outerRadius !== void 0 ? outerRadius : Math.max(size / 2 - 6, 0);
31
+ const resolvedSliceOpacity = clamp(sliceOpacity, 0, 1);
32
+ const resolvedSliceBorderWidth = Math.max(sliceBorderWidth, 0);
33
+ const resolvedSliceBorderOpacity = clamp(sliceBorderOpacity, 0, 1);
34
+ const resolvedSliceBorderColor = sliceBorderColor !== null && sliceBorderColor !== void 0 ? sliceBorderColor : theme.palette.background.paper;
35
+ const resolvedInnerRadius = Math.min(innerRadius, radius - 1);
36
+ const centerPanelDiameter = Math.max(resolvedInnerRadius * 1.62, 52);
37
+ const labelRadius = resolvedInnerRadius > 0
38
+ ? resolvedInnerRadius + (radius - resolvedInnerRadius) / 2
39
+ : radius * 0.68;
40
+ const slices = useMemo(() => {
41
+ const pieGenerator = pie()
42
+ .value((datum) => datum.value)
43
+ .sort(null)
44
+ .padAngle(padAngle);
45
+ return pieGenerator(validData).map((slice, index) => {
46
+ var _a, _b;
47
+ return (Object.assign(Object.assign({}, slice), { color: (_b = (_a = slice.data.color) !== null && _a !== void 0 ? _a : getGradientColor(colorGradient, index, validData.length)) !== null && _b !== void 0 ? _b : themeColors[index % themeColors.length], percent: total > 0 ? slice.data.value / total : 0 }));
48
+ });
49
+ }, [colorGradient, padAngle, themeColors, total, validData]);
50
+ const safeAnimationDuration = Math.max(animationDuration, 0);
51
+ const safeAnimationStagger = Math.max(animationStagger, 0);
52
+ const totalAnimationDuration = safeAnimationDuration +
53
+ Math.max(slices.length - 1, 0) * safeAnimationStagger;
54
+ useEffect(() => {
55
+ var _a;
56
+ if (!animateOnRender || slices.length === 0) {
57
+ setAnimationElapsed(Number.POSITIVE_INFINITY);
58
+ return;
59
+ }
60
+ const prefersReducedMotion = typeof window !== "undefined" &&
61
+ ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, "(prefers-reduced-motion: reduce)").matches);
62
+ if (prefersReducedMotion) {
63
+ setAnimationElapsed(Number.POSITIVE_INFINITY);
64
+ return;
65
+ }
66
+ let animationFrame = 0;
67
+ let startTime = null;
68
+ setAnimationElapsed(0);
69
+ const runAnimation = (timestamp) => {
70
+ if (startTime == null)
71
+ startTime = timestamp;
72
+ const elapsed = timestamp - startTime;
73
+ setAnimationElapsed(elapsed);
74
+ if (elapsed < totalAnimationDuration) {
75
+ animationFrame = window.requestAnimationFrame(runAnimation);
76
+ }
77
+ };
78
+ animationFrame = window.requestAnimationFrame(runAnimation);
79
+ return () => {
80
+ window.cancelAnimationFrame(animationFrame);
81
+ };
82
+ }, [
83
+ animateOnRender,
84
+ animationDuration,
85
+ animationStagger,
86
+ slices.length,
87
+ totalAnimationDuration,
88
+ ]);
89
+ const arcGenerator = useMemo(() => arc()
90
+ .innerRadius(Math.max(resolvedInnerRadius, 0))
91
+ .outerRadius(radius)
92
+ .cornerRadius(cornerRadius), [cornerRadius, radius, resolvedInnerRadius]);
93
+ const labelArcGenerator = useMemo(() => arc()
94
+ .innerRadius(labelRadius)
95
+ .outerRadius(labelRadius), [labelRadius]);
96
+ const formatValue = (datum) => { var _a; return (_a = valueFormatter === null || valueFormatter === void 0 ? void 0 : valueFormatter(datum.value, datum)) !== null && _a !== void 0 ? _a : formatDefaultValue(datum.value); };
97
+ const updateTooltipPosition = (event, sliceKey) => {
98
+ if (!showTooltips || !containerRef.current)
99
+ return;
100
+ const containerRect = containerRef.current.getBoundingClientRect();
101
+ setActiveTooltip({
102
+ sliceKey,
103
+ x: event.clientX - containerRect.left,
104
+ y: event.clientY - containerRect.top,
105
+ });
106
+ };
107
+ const showLegendMeta = showLegendValues || showLegendPercentages;
108
+ const shouldShowLegend = showLegend &&
109
+ slices.length > 0 &&
110
+ (showLegendSwatches || showLegendLabels || showLegendMeta);
111
+ const animationStartAngle = (_c = (_b = slices[0]) === null || _b === void 0 ? void 0 : _b.startAngle) !== null && _c !== void 0 ? _c : 0;
112
+ const getSliceAnimationProgress = (index) => {
113
+ if (!animateOnRender || safeAnimationDuration === 0)
114
+ return 1;
115
+ const elapsed = animationElapsed - index * safeAnimationStagger;
116
+ return easeOutCubic(clamp(elapsed / safeAnimationDuration, 0, 1));
117
+ };
118
+ const activeTooltipSlice = showTooltips && activeTooltip
119
+ ? slices.find((slice, index) => getSliceKey(slice.data, index) === activeTooltip.sliceKey)
120
+ : null;
121
+ return (_jsxs(StyledContainer, Object.assign({ ref: containerRef, className: className }, props, { children: [slices.length === 0 ? (_jsx(StyledEmptyState, { "$size": size, children: emptyLabel })) : (_jsxs(StyledChartWrap, { children: [_jsxs(StyledSvg, { width: size, height: size, viewBox: `0 0 ${size} ${size}`, role: "img", "aria-label": ariaLabel, "aria-describedby": descriptionId, children: [_jsx("desc", { id: descriptionId, children: slices
122
+ .map((slice) => `${slice.data.label}: ${formatDefaultValue(slice.data.value)}`)
123
+ .join(", ") }), _jsx("g", { transform: `translate(${size / 2}, ${size / 2})`, children: slices.map((slice, index) => {
124
+ var _a;
125
+ const sliceKey = getSliceKey(slice.data, index);
126
+ const sliceAnimationProgress = getSliceAnimationProgress(index);
127
+ const animatedSlice = Object.assign(Object.assign({}, slice), { startAngle: animationStartAngle +
128
+ (slice.startAngle - animationStartAngle) *
129
+ sliceAnimationProgress, endAngle: animationStartAngle +
130
+ (slice.endAngle - animationStartAngle) *
131
+ sliceAnimationProgress });
132
+ const path = arcGenerator(animatedSlice);
133
+ const labelPosition = labelArcGenerator.centroid(slice);
134
+ const percent = Math.round(slice.percent * 100);
135
+ return (_jsxs("g", { children: [_jsx(StyledSlice, { "$active": activeSliceKey === sliceKey, d: path !== null && path !== void 0 ? path : undefined, fill: slice.color, fillOpacity: resolvedSliceOpacity, stroke: resolvedSliceBorderColor, strokeWidth: resolvedSliceBorderWidth, strokeOpacity: resolvedSliceBorderOpacity, strokeLinejoin: sliceBorderLineJoin, tabIndex: 0, onFocus: () => setActiveSliceKey(sliceKey), onBlur: () => setActiveSliceKey(null), onMouseEnter: (event) => {
136
+ setActiveSliceKey(sliceKey);
137
+ updateTooltipPosition(event, sliceKey);
138
+ }, onMouseMove: (event) => updateTooltipPosition(event, sliceKey), onMouseLeave: () => {
139
+ setActiveSliceKey(null);
140
+ setActiveTooltip(null);
141
+ }, onClick: (event) => onSliceClick === null || onSliceClick === void 0 ? void 0 : onSliceClick(event, slice.data), onKeyDown: (event) => {
142
+ if (event.key !== "Enter" && event.key !== " ")
143
+ return;
144
+ event.preventDefault();
145
+ onSliceClick === null || onSliceClick === void 0 ? void 0 : onSliceClick(event, slice.data);
146
+ }, "aria-label": `${slice.data.label}: ${formatDefaultValue(slice.data.value)}, ${percent}%` }), showLabels &&
147
+ slice.percent >= 0.05 &&
148
+ sliceAnimationProgress >= 0.92 && (_jsx(StyledLabel, { x: labelPosition[0], y: labelPosition[1], textAnchor: "middle", dominantBaseline: "central", children: (_a = labelFormatter === null || labelFormatter === void 0 ? void 0 : labelFormatter(slice.data, slice.percent)) !== null && _a !== void 0 ? _a : `${percent}%` }))] }, sliceKey));
149
+ }) })] }), (centerLabel != null || centerValue != null) && (_jsx(StyledCenter, { children: _jsxs(StyledCenterPanel, { "$diameter": centerPanelDiameter, children: [centerValue != null && (_jsx(StyledCenterValue, { children: centerValue })), centerLabel != null && (_jsx(StyledCenterLabel, { children: centerLabel }))] }) }))] })), shouldShowLegend && (_jsx(StyledLegend, { children: slices.map((slice, index) => {
150
+ const sliceKey = getSliceKey(slice.data, index);
151
+ return (_jsxs(StyledLegendItem, { "$active": activeSliceKey === sliceKey, "$showSwatch": showLegendSwatches, "$showLabel": showLegendLabels, "$showMeta": showLegendMeta, tabIndex: 0, onMouseEnter: () => setActiveSliceKey(sliceKey), onMouseLeave: () => setActiveSliceKey(null), onFocus: () => setActiveSliceKey(sliceKey), onBlur: () => setActiveSliceKey(null), onClick: (event) => onLegendItemClick === null || onLegendItemClick === void 0 ? void 0 : onLegendItemClick(event, slice.data), onKeyDown: (event) => {
152
+ if (event.key !== "Enter" && event.key !== " ")
153
+ return;
154
+ event.preventDefault();
155
+ onLegendItemClick === null || onLegendItemClick === void 0 ? void 0 : onLegendItemClick(event, slice.data);
156
+ }, children: [showLegendSwatches && _jsx(StyledSwatch, { "$color": slice.color }), showLegendLabels && (_jsx(StyledLegendLabel, { title: slice.data.label, children: slice.data.label })), showLegendMeta && (_jsxs(StyledLegendMeta, { children: [showLegendValues && (_jsx(StyledLegendValue, { children: formatValue(slice.data) })), showLegendPercentages && (_jsxs(StyledLegendPercent, { children: [Math.round(slice.percent * 100), "%"] }))] }))] }, sliceKey));
157
+ }) })), activeTooltip && activeTooltipSlice && (_jsx(StyledTooltip, { style: {
158
+ left: activeTooltip.x,
159
+ top: activeTooltip.y,
160
+ }, children: tooltipFormatter ? (tooltipFormatter(activeTooltipSlice.data, activeTooltipSlice.percent)) : (_jsxs(_Fragment, { children: [_jsxs(StyledTooltipHeader, { children: [_jsx(StyledTooltipSwatch, { "$color": activeTooltipSlice.color }), _jsx(StyledTooltipLabel, { children: activeTooltipSlice.data.label })] }), _jsxs(StyledTooltipMeta, { children: [_jsx("span", { children: formatValue(activeTooltipSlice.data) }), _jsxs("span", { children: [Math.round(activeTooltipSlice.percent * 100), "%"] })] })] })) }))] })));
161
+ };
@@ -0,0 +1,5 @@
1
+ import { clamp, easeOutCubic, formatDefaultValue, getGradientColor, getGradientStops, mixColors } from "../ChartUtils";
2
+ import { PieChartDatum } from "./PieChart.types";
3
+ export { clamp, easeOutCubic, formatDefaultValue, getGradientColor, getGradientStops, mixColors };
4
+ export declare const getSliceKey: (datum: PieChartDatum<unknown>, index: number) => string | number;
5
+ export declare const useThemeColors: (colors?: string[]) => string[];
@@ -0,0 +1,19 @@
1
+ import { useMemo } from "react";
2
+ import { useTheme } from "styled-components";
3
+ import { clamp, easeOutCubic, formatDefaultValue, getGradientColor, getGradientStops, mixColors, } from "../ChartUtils";
4
+ export { clamp, easeOutCubic, formatDefaultValue, getGradientColor, getGradientStops, mixColors };
5
+ export const getSliceKey = (datum, index) => { var _a; return (_a = datum.id) !== null && _a !== void 0 ? _a : `${datum.label}-${index}`; };
6
+ export const useThemeColors = (colors) => {
7
+ const theme = useTheme();
8
+ return useMemo(() => (colors === null || colors === void 0 ? void 0 : colors.length)
9
+ ? colors
10
+ : [
11
+ theme.palette.primary.main,
12
+ theme.alert.success.color,
13
+ theme.alert.warning.color,
14
+ theme.alert.error.color,
15
+ theme.alert.info.color,
16
+ theme.palette.fourth.main,
17
+ theme.button.text.secondary,
18
+ ], [colors, theme]);
19
+ };
@@ -0,0 +1,49 @@
1
+ export declare const StyledContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
+ export declare const StyledChartWrap: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
+ export declare const StyledSvg: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").SVGProps<SVGSVGElement>, never>> & string;
4
+ export declare const StyledSlice: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").SVGProps<SVGPathElement>, {
5
+ $active: boolean;
6
+ }>> & string;
7
+ export declare const StyledLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").SVGTextElementAttributes<SVGTextElement>, never>> & string;
8
+ export declare const StyledCenter: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
9
+ export declare const StyledCenterPanel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
10
+ $diameter: number;
11
+ }>> & string;
12
+ export declare const StyledCenterValue: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
13
+ export declare const StyledCenterLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
14
+ export declare const StyledLegend: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>, never>> & string;
15
+ export declare const StyledLegendItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
16
+ $active: boolean;
17
+ $showSwatch: boolean;
18
+ $showLabel: boolean;
19
+ $showMeta: boolean;
20
+ }>> & string;
21
+ export declare const StyledSwatch: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
22
+ $color: string;
23
+ $width?: number;
24
+ $height?: number;
25
+ $radius?: number;
26
+ }>> & string;
27
+ export declare const StyledLegendLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
28
+ export declare const StyledLegendValue: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
29
+ export declare const StyledLegendMeta: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
30
+ export declare const StyledLegendPercent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
31
+ export declare const StyledEmptyState: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
32
+ $size: number;
33
+ }>> & string;
34
+ export declare const StyledTooltip: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
35
+ $minWidth?: number;
36
+ $maxWidth?: number;
37
+ $transform?: string;
38
+ }>> & string;
39
+ export declare const StyledTooltipHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
40
+ export declare const StyledTooltipSwatch: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
41
+ $color: string;
42
+ $radius?: string;
43
+ }>> & string;
44
+ export declare const StyledTooltipLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
45
+ export declare const StyledTooltipMeta: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
46
+ $marginTop?: number;
47
+ $direction?: "row" | "column";
48
+ $gap?: number;
49
+ }>> & string;
@@ -0,0 +1,161 @@
1
+ import styled from "styled-components";
2
+ import { StyledChartLegend, StyledChartLegendLabel, StyledChartLegendSwatch, StyledChartLegendValue, StyledChartTooltip, StyledChartTooltipHeader, StyledChartTooltipLabel, StyledChartTooltipMeta, StyledChartTooltipSwatch, sharedLegendItemStyles, } from "../ChartPrimitives";
3
+ const activeSliceStyles = `
4
+ opacity: 0.96;
5
+ filter: brightness(1.12) saturate(1.08);
6
+ transform: scale(1.018);
7
+ `;
8
+ export const StyledContainer = styled.div `
9
+ position: relative;
10
+ display: flex;
11
+ align-items: center;
12
+ flex-wrap: wrap;
13
+ gap: 20px;
14
+ width: fit-content;
15
+ max-width: 100%;
16
+ color: ${({ theme }) => theme.palette.text.primary};
17
+ box-sizing: border-box;
18
+ overflow: visible;
19
+ `;
20
+ export const StyledChartWrap = styled.div `
21
+ position: relative;
22
+ display: flex;
23
+ align-items: center;
24
+ justify-content: center;
25
+ flex: 0 0 auto;
26
+ `;
27
+ export const StyledSvg = styled.svg `
28
+ display: block;
29
+ overflow: visible;
30
+ `;
31
+ export const StyledSlice = styled.path `
32
+ cursor: pointer;
33
+ outline: none;
34
+ transform-box: fill-box;
35
+ transform-origin: center;
36
+ transition:
37
+ opacity 0.18s ease,
38
+ filter 0.18s ease,
39
+ transform 0.18s ease;
40
+
41
+ &:hover,
42
+ &:focus-visible {
43
+ ${activeSliceStyles}
44
+ }
45
+
46
+ ${({ $active }) => $active && activeSliceStyles}
47
+ `;
48
+ export const StyledLabel = styled.text `
49
+ fill: #fff;
50
+ font-size: 11px;
51
+ font-weight: 600;
52
+ paint-order: stroke;
53
+ stroke: rgba(0, 0, 0, 0.28);
54
+ stroke-width: 3px;
55
+ stroke-linejoin: round;
56
+ pointer-events: none;
57
+ `;
58
+ export const StyledCenter = styled.div `
59
+ position: absolute;
60
+ inset: 0;
61
+ display: flex;
62
+ align-items: center;
63
+ justify-content: center;
64
+ flex-direction: column;
65
+ gap: 2px;
66
+ text-align: center;
67
+ pointer-events: none;
68
+ `;
69
+ export const StyledCenterPanel = styled.div `
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: center;
73
+ flex-direction: column;
74
+ gap: 2px;
75
+ width: ${({ $diameter }) => $diameter}px;
76
+ height: ${({ $diameter }) => $diameter}px;
77
+ max-width: 74%;
78
+ max-height: 74%;
79
+ border: 1px solid ${({ theme }) => theme.palette.divider};
80
+ border-radius: 50%;
81
+ background: linear-gradient(
82
+ 180deg,
83
+ ${({ theme }) => theme.palette.background.paper} 0%,
84
+ ${({ theme }) => theme.palette.background.secondary} 100%
85
+ );
86
+ `;
87
+ export const StyledCenterValue = styled.div `
88
+ max-width: 78%;
89
+ overflow: hidden;
90
+ text-overflow: ellipsis;
91
+ white-space: nowrap;
92
+ font-size: 20px;
93
+ font-weight: 700;
94
+ line-height: 1.15;
95
+ color: ${({ theme }) => theme.palette.text.primary};
96
+ `;
97
+ export const StyledCenterLabel = styled.div `
98
+ max-width: 78%;
99
+ overflow: hidden;
100
+ text-overflow: ellipsis;
101
+ white-space: nowrap;
102
+ font-size: 11px;
103
+ line-height: 1.2;
104
+ color: ${({ theme }) => theme.palette.text.secondary};
105
+ `;
106
+ export const StyledLegend = styled(StyledChartLegend) `
107
+ min-width: 164px;
108
+ max-width: 260px;
109
+ `;
110
+ export const StyledLegendItem = styled.div `
111
+ display: grid;
112
+ grid-template-columns: ${({ $showSwatch, $showLabel, $showMeta }) => [
113
+ $showSwatch ? "4px" : null,
114
+ $showLabel ? "minmax(0, 1fr)" : null,
115
+ $showMeta ? "auto" : null,
116
+ ]
117
+ .filter(Boolean)
118
+ .join(" ")};
119
+ ${sharedLegendItemStyles}
120
+ `;
121
+ export const StyledSwatch = StyledChartLegendSwatch;
122
+ export const StyledLegendLabel = StyledChartLegendLabel;
123
+ export const StyledLegendValue = StyledChartLegendValue;
124
+ export const StyledLegendMeta = styled.span `
125
+ display: flex;
126
+ align-items: center;
127
+ gap: 7px;
128
+ white-space: nowrap;
129
+ `;
130
+ export const StyledLegendPercent = styled.span `
131
+ min-width: 34px;
132
+ padding: 2px 5px;
133
+ border: 1px solid ${({ theme }) => theme.palette.divider};
134
+ border-radius: 4px;
135
+ background-color: ${({ theme }) => theme.palette.background.paper};
136
+ color: ${({ theme }) => theme.palette.text.primary};
137
+ font-size: 11px;
138
+ font-variant-numeric: tabular-nums;
139
+ text-align: center;
140
+ `;
141
+ export const StyledEmptyState = styled.div `
142
+ display: flex;
143
+ align-items: center;
144
+ justify-content: center;
145
+ width: ${({ $size }) => $size}px;
146
+ height: ${({ $size }) => $size}px;
147
+ border: 1px dashed ${({ theme }) => theme.palette.divider};
148
+ border-radius: 50%;
149
+ background: radial-gradient(
150
+ circle,
151
+ ${({ theme }) => theme.palette.background.paper} 0%,
152
+ ${({ theme }) => theme.palette.background.secondary} 70%
153
+ );
154
+ font-size: 12px;
155
+ color: ${({ theme }) => theme.palette.text.secondary};
156
+ `;
157
+ export const StyledTooltip = StyledChartTooltip;
158
+ export const StyledTooltipHeader = StyledChartTooltipHeader;
159
+ export const StyledTooltipSwatch = StyledChartTooltipSwatch;
160
+ export const StyledTooltipLabel = StyledChartTooltipLabel;
161
+ export const StyledTooltipMeta = StyledChartTooltipMeta;
@@ -0,0 +1,99 @@
1
+ import React, { HTMLAttributes } from "react";
2
+ import { PieArcDatum } from "d3-shape";
3
+ export type PieChartDatum<TData = unknown> = {
4
+ /** Stable identifier for the slice. Falls back to label and index when omitted. */
5
+ id?: string | number;
6
+ /** Display label used for legends, labels, tooltips, and accessibility text. */
7
+ label: string;
8
+ /** Numeric value used to calculate the slice size. Values must be positive to render. */
9
+ value: number;
10
+ /** Optional per-slice color. Takes precedence over colorGradient, colors, and theme colors. */
11
+ color?: string;
12
+ /** Optional contextual payload returned in click callbacks and formatter functions. */
13
+ data?: TData;
14
+ };
15
+ export type PieChartColorGradient =
16
+ /** Ordered color stops used to generate slice colors across a gradient scale. */
17
+ string[]
18
+ /** Two-color gradient range used to generate slice colors from start to end. */
19
+ | {
20
+ /** Starting color for generated slice colors. */
21
+ from: string;
22
+ /** Ending color for generated slice colors. */
23
+ to: string;
24
+ };
25
+ export type PieChartProps<TData = unknown> = HTMLAttributes<HTMLDivElement> & {
26
+ /** Slice data rendered by the chart. Only positive finite values are displayed. */
27
+ data: PieChartDatum<TData>[];
28
+ /** SVG width and height in pixels. Defaults to 220. */
29
+ size?: number;
30
+ /** Inner radius in pixels. Set to 0 for a solid pie. Defaults to 58. */
31
+ innerRadius?: number;
32
+ /** Outer radius in pixels. Defaults to half the size minus chart padding. */
33
+ outerRadius?: number;
34
+ /** Corner radius for slice edges in pixels. Defaults to 1. */
35
+ cornerRadius?: number;
36
+ /** Angular spacing between slices in radians. Defaults to 0.004. */
37
+ padAngle?: number;
38
+ /** Categorical color palette for slices. Used after per-slice colors and colorGradient. */
39
+ colors?: string[];
40
+ /** Generates slice colors along a gradient scale. Per-slice color values still take precedence. */
41
+ colorGradient?: PieChartColorGradient;
42
+ /** Opacity applied to slice fills. Clamped between 0 and 1. Defaults to 1. */
43
+ sliceOpacity?: number;
44
+ /** Stroke color around each slice. Defaults to the theme paper background. */
45
+ sliceBorderColor?: string;
46
+ /** Stroke width around each slice in pixels. Defaults to 1. */
47
+ sliceBorderWidth?: number;
48
+ /** Stroke opacity around each slice. Clamped between 0 and 1. Defaults to 1. */
49
+ sliceBorderOpacity?: number;
50
+ /** SVG stroke line join used by each slice border. Defaults to "round". */
51
+ sliceBorderLineJoin?: React.SVGAttributes<SVGPathElement>["strokeLinejoin"];
52
+ /** Shows or hides the entire legend. Defaults to true. */
53
+ showLegend?: boolean;
54
+ /** Shows or hides legend color swatches. Defaults to true. */
55
+ showLegendSwatches?: boolean;
56
+ /** Shows or hides legend labels. Defaults to true. */
57
+ showLegendLabels?: boolean;
58
+ /** Shows or hides legend formatted values. Defaults to true. */
59
+ showLegendValues?: boolean;
60
+ /** Shows or hides legend percentage badges. Defaults to true. */
61
+ showLegendPercentages?: boolean;
62
+ /** Shows percentage labels inside sufficiently large slices. Defaults to false. */
63
+ showLabels?: boolean;
64
+ /** Label displayed in the center of donut charts. */
65
+ centerLabel?: React.ReactNode;
66
+ /** Value displayed above centerLabel in donut charts. */
67
+ centerValue?: React.ReactNode;
68
+ /** Content shown when no valid positive data values are available. Defaults to "No data". */
69
+ emptyLabel?: React.ReactNode;
70
+ /** Accessible label for the SVG chart image. Defaults to "Pie chart". */
71
+ ariaLabel?: string;
72
+ /** Animates slices on initial render with a fan-out sweep. Defaults to false. */
73
+ animateOnRender?: boolean;
74
+ /** Duration in milliseconds for each slice animation. Defaults to 520. */
75
+ animationDuration?: number;
76
+ /** Delay in milliseconds between each slice animation. Defaults to 35. */
77
+ animationStagger?: number;
78
+ /** Shows a custom themed tooltip when hovering over slices. Defaults to false. */
79
+ showTooltips?: boolean;
80
+ /** Formats values shown in the legend and default tooltip. */
81
+ valueFormatter?: (value: number, datum: PieChartDatum<TData>) => React.ReactNode;
82
+ /** Formats labels rendered inside slices. Receives the original datum and percentage as 0-1. */
83
+ labelFormatter?: (datum: PieChartDatum<TData>, percent: number) => React.ReactNode;
84
+ /** Custom tooltip renderer. Receives the original datum and percentage as 0-1. */
85
+ tooltipFormatter?: (datum: PieChartDatum<TData>, percent: number) => React.ReactNode;
86
+ /** Called when a slice is clicked or activated with Enter/Space. */
87
+ onSliceClick?: (event: React.MouseEvent<SVGPathElement> | React.KeyboardEvent<SVGPathElement>, datum: PieChartDatum<TData>) => void;
88
+ /** Called when a legend item is clicked or activated with Enter/Space. */
89
+ onLegendItemClick?: (event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>, datum: PieChartDatum<TData>) => void;
90
+ };
91
+ export type ResolvedSlice<TData = unknown> = PieArcDatum<PieChartDatum<TData>> & {
92
+ color: string;
93
+ percent: number;
94
+ };
95
+ export type ActiveTooltip = {
96
+ sliceKey: string | number;
97
+ x: number;
98
+ y: number;
99
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./PieChart";
2
+ export type { PieChartColorGradient, PieChartDatum, PieChartProps, } from "./PieChart.types";
@@ -0,0 +1 @@
1
+ export * from "./PieChart";
package/dist/Pill/Pill.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled from "styled-components";
3
3
  import { X } from "lucide-react";
4
+ import { getControlSizeTokens } from "../core";
4
5
  const StyledButton = styled.button `
5
6
  background-color: transparent;
6
7
  border: none;
@@ -35,7 +36,7 @@ const Pill = styled(({ className, children, title, size = "md", showRemoveIcon =
35
36
  flex-direction: row;
36
37
  width: fit-content;
37
38
  max-width: 250px;
38
- gap: 5px;
39
+ gap: ${({ size }) => `${getControlSizeTokens(size).pillGap}px`};
39
40
  flex: 0;
40
41
 
41
42
  font-weight: 500;
@@ -45,55 +46,12 @@ const Pill = styled(({ className, children, title, size = "md", showRemoveIcon =
45
46
  if (showRemoveIcon !== false) {
46
47
  return "0px";
47
48
  }
48
- switch (size) {
49
- case "xs":
50
- return "8px";
51
- case "sm":
52
- return "10px";
53
- case "md":
54
- return "12px";
55
- case "lg":
56
- return "14px";
57
- case "xl":
58
- return "16px";
59
- default:
60
- return "10px";
61
- }
49
+ return `${getControlSizeTokens(size).pillPaddingX}px`;
62
50
  }};
63
51
 
64
- padding-inline-start: ${({ size }) => {
65
- switch (size) {
66
- case "xs":
67
- return "8px";
68
- case "sm":
69
- return "10px";
70
- case "md":
71
- return "12px";
72
- case "lg":
73
- return "14px";
74
- case "xl":
75
- return "16px";
76
- default:
77
- return "10px";
78
- }
79
- }};
52
+ padding-inline-start: ${({ size }) => `${getControlSizeTokens(size).pillPaddingX}px`};
80
53
 
81
- height: ${({ size }) => {
82
- switch (size) {
83
- case "xs":
84
- return "20px";
85
- case "sm":
86
- return "22px";
87
- case "md":
88
- return "24px";
89
- case "lg":
90
- return "26px";
91
- case "xl":
92
- return "28px";
93
- default:
94
- return "22px";
95
- }
96
- }};
54
+ height: ${({ size }) => `${getControlSizeTokens(size).pillHeight}px`};
97
55
 
98
56
  border: 1px solid ${({ theme }) => theme.palette.divider};
99
57
  border-radius: 1000px;
@@ -105,43 +63,14 @@ const Pill = styled(({ className, children, title, size = "md", showRemoveIcon =
105
63
  overflow: hidden;
106
64
  text-overflow: ellipsis;
107
65
 
108
- font-size: ${({ size }) => {
109
- switch (size) {
110
- case "xs":
111
- return "10px";
112
- case "sm":
113
- return "12px";
114
- case "md":
115
- return "14px";
116
- case "lg":
117
- return "16px";
118
- case "xl":
119
- return "18px";
120
- default:
121
- return "12px";
122
- }
123
- }};
66
+ font-size: ${({ size }) => `${getControlSizeTokens(size).pillFontSize}px`};
124
67
  }
125
68
 
126
69
  svg {
127
70
  color: ${({ theme }) => theme.palette.text.primary};
128
71
 
129
- width: ${({ size }) => {
130
- switch (size) {
131
- case "xs":
132
- return "12px";
133
- case "sm":
134
- return "14px";
135
- case "md":
136
- return "16px";
137
- case "lg":
138
- return "18px";
139
- case "xl":
140
- return "20px";
141
- default:
142
- return "14px";
143
- }
144
- }};
72
+ width: ${({ size }) => `${getControlSizeTokens(size).pillIconSize}px`};
73
+ height: ${({ size }) => `${getControlSizeTokens(size).pillIconSize}px`};
145
74
  }
146
75
  `;
147
76
  export default Pill;
@@ -10,12 +10,13 @@ export interface PopoverContextValue {
10
10
  withArrow: boolean;
11
11
  arrowSize: number;
12
12
  arrowRadius: number;
13
- arrowRef: React.MutableRefObject<HTMLDivElement | null>;
13
+ arrowRef: React.MutableRefObject<SVGSVGElement | null>;
14
14
  withinPortal: boolean;
15
15
  trapFocus: boolean;
16
16
  returnFocus: boolean;
17
17
  keepMounted: boolean;
18
18
  zIndex: number;
19
+ role: "dialog" | "menu" | "tooltip";
19
20
  dropdownId: string;
20
21
  transitionProps: PopoverTransitionProps;
21
22
  }