@mui/x-charts 8.9.0 → 8.10.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 (128) hide show
  1. package/BarChart/BarChart.js +110 -1
  2. package/BarChart/BarClipPath.d.ts +17 -12
  3. package/BarChart/BarClipPath.js +70 -57
  4. package/BarChart/BarPlot.js +4 -0
  5. package/BarChart/seriesConfig/extremums.js +2 -3
  6. package/BarChart/useBarChartProps.d.ts +1 -1
  7. package/CHANGELOG.md +245 -6
  8. package/ChartContainer/ChartContainer.js +165 -0
  9. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +1 -3
  10. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +1 -3
  11. package/ChartsTooltip/ChartsTooltip.d.ts +2 -1
  12. package/ChartsTooltip/ChartsTooltip.js +3 -3
  13. package/ChartsTooltip/ChartsTooltipContainer.d.ts +5 -5
  14. package/ChartsTooltip/ChartsTooltipContainer.js +3 -3
  15. package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
  16. package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +33 -7
  17. package/ChartsXAxis/ChartsGroupedXAxis.d.ts +7 -0
  18. package/ChartsXAxis/ChartsGroupedXAxis.js +142 -0
  19. package/ChartsXAxis/ChartsSingleXAxis.d.ts +7 -0
  20. package/ChartsXAxis/ChartsSingleXAxis.js +144 -0
  21. package/ChartsXAxis/ChartsXAxis.d.ts +1 -1
  22. package/ChartsXAxis/ChartsXAxis.js +8 -210
  23. package/ChartsXAxis/getVisibleLabels.d.ts +2 -2
  24. package/ChartsXAxis/useAxisProps.d.ts +4526 -0
  25. package/ChartsXAxis/useAxisProps.js +105 -0
  26. package/ChartsXAxis/utilities.d.ts +11 -0
  27. package/ChartsXAxis/utilities.js +43 -0
  28. package/LineChart/LineChart.js +110 -1
  29. package/LineChart/seriesConfig/extremums.js +2 -3
  30. package/LineChart/useLineChartProps.d.ts +1 -1
  31. package/PieChart/PieChart.js +1 -1
  32. package/RadarChart/RadarChart.d.ts +1 -1
  33. package/RadarChart/RadarChart.js +1 -1
  34. package/RadarChart/index.d.ts +9 -2
  35. package/RadarChart/index.js +13 -14
  36. package/RadarChart/useRadarChartProps.d.ts +1 -1
  37. package/ScatterChart/ScatterChart.d.ts +8 -1
  38. package/ScatterChart/ScatterChart.js +110 -1
  39. package/ScatterChart/seriesConfig/extremums.js +50 -23
  40. package/ScatterChart/useScatterChartProps.d.ts +1 -1
  41. package/SparkLineChart/SparkLineChart.js +109 -0
  42. package/esm/BarChart/BarChart.js +110 -1
  43. package/esm/BarChart/BarClipPath.d.ts +17 -12
  44. package/esm/BarChart/BarClipPath.js +69 -55
  45. package/esm/BarChart/BarPlot.js +4 -0
  46. package/esm/BarChart/seriesConfig/extremums.js +2 -3
  47. package/esm/BarChart/useBarChartProps.d.ts +1 -1
  48. package/esm/ChartContainer/ChartContainer.js +165 -0
  49. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +1 -3
  50. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +1 -3
  51. package/esm/ChartsTooltip/ChartsTooltip.d.ts +2 -1
  52. package/esm/ChartsTooltip/ChartsTooltip.js +3 -3
  53. package/esm/ChartsTooltip/ChartsTooltipContainer.d.ts +5 -5
  54. package/esm/ChartsTooltip/ChartsTooltipContainer.js +3 -3
  55. package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
  56. package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +31 -6
  57. package/esm/ChartsXAxis/ChartsGroupedXAxis.d.ts +7 -0
  58. package/esm/ChartsXAxis/ChartsGroupedXAxis.js +136 -0
  59. package/esm/ChartsXAxis/ChartsSingleXAxis.d.ts +7 -0
  60. package/esm/ChartsXAxis/ChartsSingleXAxis.js +140 -0
  61. package/esm/ChartsXAxis/ChartsXAxis.d.ts +1 -1
  62. package/esm/ChartsXAxis/ChartsXAxis.js +7 -207
  63. package/esm/ChartsXAxis/getVisibleLabels.d.ts +2 -2
  64. package/esm/ChartsXAxis/useAxisProps.d.ts +4526 -0
  65. package/esm/ChartsXAxis/useAxisProps.js +98 -0
  66. package/esm/ChartsXAxis/utilities.d.ts +11 -0
  67. package/esm/ChartsXAxis/utilities.js +35 -0
  68. package/esm/LineChart/LineChart.js +110 -1
  69. package/esm/LineChart/seriesConfig/extremums.js +2 -3
  70. package/esm/LineChart/useLineChartProps.d.ts +1 -1
  71. package/esm/PieChart/PieChart.js +1 -1
  72. package/esm/RadarChart/RadarChart.d.ts +1 -1
  73. package/esm/RadarChart/RadarChart.js +1 -1
  74. package/esm/RadarChart/index.d.ts +9 -2
  75. package/esm/RadarChart/index.js +12 -2
  76. package/esm/RadarChart/useRadarChartProps.d.ts +1 -1
  77. package/esm/ScatterChart/ScatterChart.d.ts +8 -1
  78. package/esm/ScatterChart/ScatterChart.js +110 -1
  79. package/esm/ScatterChart/seriesConfig/extremums.js +50 -23
  80. package/esm/ScatterChart/useScatterChartProps.d.ts +1 -1
  81. package/esm/SparkLineChart/SparkLineChart.js +109 -0
  82. package/esm/hooks/useTicksGrouped.d.ts +28 -0
  83. package/esm/hooks/useTicksGrouped.js +98 -0
  84. package/esm/index.d.ts +2 -1
  85. package/esm/index.js +6 -2
  86. package/esm/internals/findMinMax.d.ts +1 -0
  87. package/esm/internals/findMinMax.js +13 -0
  88. package/esm/internals/getScale.d.ts +1 -1
  89. package/esm/internals/getScale.js +3 -0
  90. package/esm/internals/index.d.ts +1 -1
  91. package/esm/internals/index.js +1 -1
  92. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -1
  93. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -1
  94. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +32 -23
  95. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts +1 -1
  96. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
  97. package/esm/internals/symlogScale.d.ts +2 -0
  98. package/esm/internals/symlogScale.js +94 -0
  99. package/esm/models/axis.d.ts +81 -4
  100. package/esm/models/axis.js +3 -0
  101. package/hooks/useTicksGrouped.d.ts +28 -0
  102. package/hooks/useTicksGrouped.js +104 -0
  103. package/index.d.ts +2 -1
  104. package/index.js +13 -1
  105. package/internals/findMinMax.d.ts +1 -0
  106. package/internals/findMinMax.js +19 -0
  107. package/internals/getScale.d.ts +1 -1
  108. package/internals/getScale.js +3 -0
  109. package/internals/index.d.ts +1 -1
  110. package/internals/index.js +12 -12
  111. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +3 -0
  112. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -1
  113. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +34 -23
  114. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts +1 -1
  115. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
  116. package/internals/symlogScale.d.ts +2 -0
  117. package/internals/symlogScale.js +100 -0
  118. package/models/axis.d.ts +81 -4
  119. package/models/axis.js +4 -0
  120. package/package.json +5 -7
  121. package/BarChart/getRadius.d.ts +0 -20
  122. package/BarChart/getRadius.js +0 -37
  123. package/esm/BarChart/getRadius.d.ts +0 -20
  124. package/esm/BarChart/getRadius.js +0 -30
  125. /package/{esm/internals/components/ChartsWrapper → ChartsWrapper}/index.d.ts +0 -0
  126. /package/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
  127. /package/{internals/components → esm}/ChartsWrapper/index.d.ts +0 -0
  128. /package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.scaleSymlog = scaleSymlog;
7
+ var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
8
+ function scaleSymlog(_domain, _range) {
9
+ const scale = (0, _d3Scale.scaleSymlog)(_domain, _range);
10
+ const originalTicks = scale.ticks;
11
+ const {
12
+ negativeScale,
13
+ linearScale,
14
+ positiveScale
15
+ } = generateScales(scale);
16
+
17
+ // Workaround for https://github.com/d3/d3-scale/issues/162
18
+ scale.ticks = count => {
19
+ const ticks = originalTicks(count);
20
+ const constant = scale.constant();
21
+ let negativeLogTickCount = 0;
22
+ let linearTickCount = 0;
23
+ let positiveLogTickCount = 0;
24
+ ticks.forEach(tick => {
25
+ if (tick > -constant && tick < constant) {
26
+ linearTickCount += 1;
27
+ }
28
+ if (tick <= -constant) {
29
+ negativeLogTickCount += 1;
30
+ }
31
+ if (tick >= constant) {
32
+ positiveLogTickCount += 1;
33
+ }
34
+ });
35
+ const finalTicks = [];
36
+ if (negativeLogTickCount > 0) {
37
+ finalTicks.push(...negativeScale.ticks(negativeLogTickCount));
38
+ }
39
+ if (linearTickCount > 0) {
40
+ const linearTicks = linearScale.ticks(linearTickCount);
41
+ if (finalTicks.at(-1) === linearTicks[0]) {
42
+ finalTicks.push(...linearTicks.slice(1));
43
+ } else {
44
+ finalTicks.push(...linearTicks);
45
+ }
46
+ }
47
+ if (positiveLogTickCount > 0) {
48
+ const positiveTicks = positiveScale.ticks(positiveLogTickCount);
49
+ if (finalTicks.at(-1) === positiveTicks[0]) {
50
+ finalTicks.push(...positiveTicks.slice(1));
51
+ } else {
52
+ finalTicks.push(...positiveTicks);
53
+ }
54
+ }
55
+ return finalTicks;
56
+ };
57
+ scale.tickFormat = (count = 10, specifier) => {
58
+ // Calculates the proportion of the domain that each scale occupies, and use that ratio to determine the number of ticks for each scale.
59
+ const constant = scale.constant();
60
+ const [start, end] = scale.domain();
61
+ const extent = end - start;
62
+ const negativeScaleDomain = negativeScale.domain();
63
+ const negativeScaleExtent = negativeScaleDomain[1] - negativeScaleDomain[0];
64
+ const negativeScaleRatio = extent === 0 ? 0 : negativeScaleExtent / extent;
65
+ const negativeScaleTickCount = negativeScaleRatio * count;
66
+ const linearScaleDomain = linearScale.domain();
67
+ const linearScaleExtent = linearScaleDomain[1] - linearScaleDomain[0];
68
+ const linearScaleRatio = extent === 0 ? 0 : linearScaleExtent / extent;
69
+ const linearScaleTickCount = linearScaleRatio * count;
70
+ const positiveScaleDomain = positiveScale.domain();
71
+ const positiveScaleExtent = positiveScaleDomain[1] - positiveScaleDomain[0];
72
+ const positiveScaleRatio = extent === 0 ? 0 : positiveScaleExtent / extent;
73
+ const positiveScaleTickCount = positiveScaleRatio * count;
74
+ const negativeTickFormat = negativeScale.tickFormat(negativeScaleTickCount, specifier);
75
+ const linearTickFormat = linearScale.tickFormat(linearScaleTickCount, specifier);
76
+ const positiveTickFormat = positiveScale.tickFormat(positiveScaleTickCount, specifier);
77
+ return tick => {
78
+ const tickFormat =
79
+ // eslint-disable-next-line no-nested-ternary
80
+ tick.valueOf() <= -constant ? negativeTickFormat : tick.valueOf() >= constant ? positiveTickFormat : linearTickFormat;
81
+ return tickFormat(tick);
82
+ };
83
+ };
84
+ return scale;
85
+ }
86
+ function generateScales(scale) {
87
+ const constant = scale.constant();
88
+ const domain = scale.domain();
89
+ const negativeDomain = [domain[0], Math.min(domain[1], -constant)];
90
+ const negativeLogScale = (0, _d3Scale.scaleLog)(negativeDomain, scale.range());
91
+ const linearDomain = [Math.max(domain[0], -constant), Math.min(domain[1], constant)];
92
+ const linearScale = (0, _d3Scale.scaleLinear)(linearDomain, scale.range());
93
+ const positiveDomain = [Math.max(domain[0], constant), domain[1]];
94
+ const positiveLogScale = (0, _d3Scale.scaleLog)(positiveDomain, scale.range());
95
+ return {
96
+ negativeScale: negativeLogScale,
97
+ linearScale,
98
+ positiveScale: positiveLogScale
99
+ };
100
+ }
package/models/axis.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ScaleBand, ScaleLinear, ScaleLogarithmic, ScaleOrdinal, ScalePoint, ScalePower, ScaleSequential, ScaleThreshold, ScaleTime } from '@mui/x-charts-vendor/d3-scale';
1
+ import type { ScaleBand, ScaleLinear, ScaleLogarithmic, ScaleOrdinal, ScalePoint, ScalePower, ScaleSequential, ScaleThreshold, ScaleTime, ScaleSymLog } from '@mui/x-charts-vendor/d3-scale';
2
2
  import { SxProps } from '@mui/system/styleFunctionSx';
3
3
  import { type MakeOptional, MakeRequired } from '@mui/x-internals/types';
4
4
  import type { DefaultizedZoomOptions } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
@@ -9,8 +9,8 @@ import { ContinuousColorConfig, OrdinalColorConfig, PiecewiseColorConfig } from
9
9
  export type AxisId = string | number;
10
10
  export type D3Scale<Domain extends {
11
11
  toString(): string;
12
- } = number | Date | string, Range = number, Output = number> = ScaleBand<Domain> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
13
- export type D3ContinuousScale<Range = number, Output = number> = ScaleLogarithmic<Range, Output> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
12
+ } = number | Date | string, Range = number, Output = number> = ScaleBand<Domain> | ScaleSymLog<Range, Output> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
13
+ export type D3ContinuousScale<Range = number, Output = number> = ScaleSymLog<Range, Output> | ScaleLogarithmic<Range, Output> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
14
14
  export interface ChartsAxisSlots {
15
15
  /**
16
16
  * Custom component for the axis main line.
@@ -179,7 +179,22 @@ export interface ChartsRadiusAxisProps extends ChartsAxisProps {
179
179
  maxRadius?: number;
180
180
  }
181
181
  export type ScaleName = keyof AxisScaleConfig;
182
- export type ContinuousScaleName = 'linear' | 'log' | 'pow' | 'sqrt' | 'time' | 'utc';
182
+ export type ContinuousScaleName = 'linear' | 'log' | 'symlog' | 'pow' | 'sqrt' | 'time' | 'utc';
183
+ export type AxisGroup = {
184
+ /**
185
+ * The function used to return the value for this group.
186
+ *
187
+ * @param {any} value The value of the axis item.
188
+ * @param {number} dataIndex The index of the data item.
189
+ * @returns {string | number | Date} The value that will be used to group the axis items.
190
+ */
191
+ getValue: (value: any, dataIndex: number) => string | number | Date;
192
+ /**
193
+ * The size of the tick in pixels.
194
+ * @default 6
195
+ */
196
+ tickSize?: number;
197
+ };
183
198
  export interface AxisScaleConfig {
184
199
  band: {
185
200
  scaleType: 'band';
@@ -197,17 +212,73 @@ export interface AxisScaleConfig {
197
212
  */
198
213
  barGapRatio: number;
199
214
  colorMap?: OrdinalColorConfig | ContinuousColorConfig | PiecewiseColorConfig;
215
+ /**
216
+ * Each group will have a label that is the stringified value of the group.
217
+ *
218
+ * @example
219
+ * If the axis is grouped by day, month and year.
220
+ *
221
+ * ```tsx
222
+ * [
223
+ * { getValue: getDate },
224
+ * { getValue: getMonth },
225
+ * { getValue: getFullYear }
226
+ * ]
227
+ * ```
228
+ *
229
+ * Then the axis will have three rows, one for each group.
230
+ *
231
+ * ```bash
232
+ * | 31 | 1 | 2 |
233
+ * | Jan | Feb |
234
+ * | 2021 |
235
+ * ```
236
+ */
237
+ groups?: AxisGroup[];
200
238
  } & Pick<TickParams, 'tickPlacement' | 'tickLabelPlacement'>;
201
239
  point: {
202
240
  scaleType: 'point';
203
241
  scale: ScalePoint<number | Date | string>;
204
242
  colorMap?: OrdinalColorConfig | ContinuousColorConfig | PiecewiseColorConfig;
243
+ /**
244
+ * Each group will have a label that is the stringified value of the group.
245
+ *
246
+ * @example
247
+ * If the axis is grouped by day, month and year.
248
+ *
249
+ * ```tsx
250
+ * [
251
+ * { getValue: getDate },
252
+ * { getValue: getMonth },
253
+ * { getValue: getFullYear }
254
+ * ]
255
+ * ```
256
+ *
257
+ * Then the axis will have three rows, one for each group.
258
+ *
259
+ * ```bash
260
+ * | 31 | 1 | 2 |
261
+ * | Jan | Feb |
262
+ * | 2021 |
263
+ * ```
264
+ */
265
+ groups?: AxisGroup[];
205
266
  };
206
267
  log: {
207
268
  scaleType: 'log';
208
269
  scale: ScaleLogarithmic<number, number>;
209
270
  colorMap?: ContinuousColorConfig | PiecewiseColorConfig;
210
271
  };
272
+ symlog: {
273
+ scaleType: 'symlog';
274
+ scale: ScaleSymLog<number, number>;
275
+ colorMap?: ContinuousColorConfig | PiecewiseColorConfig;
276
+ /**
277
+ * The constant used to define the zero point of the symlog scale.
278
+ * @default 1
279
+ */
280
+ constant?: number;
281
+ };
211
282
  pow: {
212
283
  scaleType: 'pow';
213
284
  scale: ScalePower<number, number>;
@@ -248,6 +319,9 @@ export interface AxisScaleComputedConfig {
248
319
  log: {
249
320
  colorScale?: ScaleSequential<string, string | null> | ScaleThreshold<number, string | null>;
250
321
  };
322
+ symlog: {
323
+ colorScale?: ScaleSequential<string, string | null> | ScaleThreshold<number, string | null>;
324
+ };
251
325
  pow: {
252
326
  colorScale?: ScaleSequential<string, string | null> | ScaleThreshold<number, string | null>;
253
327
  };
@@ -417,6 +491,9 @@ export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): s
417
491
  export declare function isPointScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'point'> & {
418
492
  scaleType: 'point';
419
493
  };
494
+ export declare function isSymlogScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'symlog'> & {
495
+ scaleType: 'symlog';
496
+ };
420
497
  /**
421
498
  * The data format returned by onAxisClick.
422
499
  */
package/models/axis.js CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isBandScaleConfig = isBandScaleConfig;
7
7
  exports.isPointScaleConfig = isPointScaleConfig;
8
+ exports.isSymlogScaleConfig = isSymlogScaleConfig;
8
9
  /**
9
10
  * Use this type instead of `AxisScaleConfig` when the values
10
11
  * shouldn't be provided by the user.
@@ -24,6 +25,9 @@ function isBandScaleConfig(scaleConfig) {
24
25
  function isPointScaleConfig(scaleConfig) {
25
26
  return scaleConfig.scaleType === 'point';
26
27
  }
28
+ function isSymlogScaleConfig(scaleConfig) {
29
+ return scaleConfig.scaleType === 'symlog';
30
+ }
27
31
 
28
32
  /**
29
33
  * The data format returned by onAxisClick.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "8.9.0",
3
+ "version": "8.10.0",
4
4
  "author": "MUI Team",
5
5
  "description": "The community edition of MUI X Charts components.",
6
6
  "main": "./index.js",
@@ -11,8 +11,7 @@
11
11
  "homepage": "https://mui.com/x/react-charts/",
12
12
  "sideEffects": false,
13
13
  "publishConfig": {
14
- "access": "public",
15
- "directory": "build"
14
+ "access": "public"
16
15
  },
17
16
  "keywords": [
18
17
  "react",
@@ -29,7 +28,7 @@
29
28
  "directory": "packages/x-charts"
30
29
  },
31
30
  "dependencies": {
32
- "@babel/runtime": "^7.27.6",
31
+ "@babel/runtime": "^7.28.2",
33
32
  "@mui/utils": "^7.2.0",
34
33
  "bezier-easing": "^2.1.0",
35
34
  "clsx": "^2.1.1",
@@ -37,8 +36,8 @@
37
36
  "reselect": "^5.1.1",
38
37
  "use-sync-external-store": "^1.5.0",
39
38
  "@mui/x-charts-vendor": "8.6.0",
40
- "@mui/x-internal-gestures": "0.2.1",
41
- "@mui/x-internals": "8.8.0"
39
+ "@mui/x-internal-gestures": "0.2.3",
40
+ "@mui/x-internals": "8.10.0"
42
41
  },
43
42
  "peerDependencies": {
44
43
  "@emotion/react": "^11.9.0",
@@ -60,7 +59,6 @@
60
59
  "node": ">=14.0.0"
61
60
  },
62
61
  "private": false,
63
- "module": "./esm/index.js",
64
62
  "exports": {
65
63
  "./package.json": "./package.json",
66
64
  ".": {
@@ -1,20 +0,0 @@
1
- export type GetRadiusData = {
2
- hasNegative: boolean;
3
- hasPositive: boolean;
4
- borderRadius?: number;
5
- layout?: 'vertical' | 'horizontal';
6
- };
7
- type GetRadiusCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
8
- /**
9
- * Returns if the corner should have a radius or not based on the layout and the data.
10
- * @param {GetRadiusCorner} corner The corner to check.
11
- * @param {GetRadiusData} cornerData The data for the corner.
12
- * @returns {number} The radius for the corner.
13
- */
14
- export declare const getRadius: (corner: GetRadiusCorner, {
15
- hasNegative,
16
- hasPositive,
17
- borderRadius,
18
- layout
19
- }: GetRadiusData) => number;
20
- export {};
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getRadius = void 0;
7
- /**
8
- * Returns if the corner should have a radius or not based on the layout and the data.
9
- * @param {GetRadiusCorner} corner The corner to check.
10
- * @param {GetRadiusData} cornerData The data for the corner.
11
- * @returns {number} The radius for the corner.
12
- */
13
- const getRadius = (corner, {
14
- hasNegative,
15
- hasPositive,
16
- borderRadius,
17
- layout
18
- }) => {
19
- if (!borderRadius) {
20
- return 0;
21
- }
22
- const isVertical = layout === 'vertical';
23
- if (corner === 'top-left' && (isVertical && hasPositive || !isVertical && hasNegative)) {
24
- return borderRadius;
25
- }
26
- if (corner === 'top-right' && (isVertical && hasPositive || !isVertical && hasPositive)) {
27
- return borderRadius;
28
- }
29
- if (corner === 'bottom-right' && (isVertical && hasNegative || !isVertical && hasPositive)) {
30
- return borderRadius;
31
- }
32
- if (corner === 'bottom-left' && (isVertical && hasNegative || !isVertical && hasNegative)) {
33
- return borderRadius;
34
- }
35
- return 0;
36
- };
37
- exports.getRadius = getRadius;
@@ -1,20 +0,0 @@
1
- export type GetRadiusData = {
2
- hasNegative: boolean;
3
- hasPositive: boolean;
4
- borderRadius?: number;
5
- layout?: 'vertical' | 'horizontal';
6
- };
7
- type GetRadiusCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
8
- /**
9
- * Returns if the corner should have a radius or not based on the layout and the data.
10
- * @param {GetRadiusCorner} corner The corner to check.
11
- * @param {GetRadiusData} cornerData The data for the corner.
12
- * @returns {number} The radius for the corner.
13
- */
14
- export declare const getRadius: (corner: GetRadiusCorner, {
15
- hasNegative,
16
- hasPositive,
17
- borderRadius,
18
- layout
19
- }: GetRadiusData) => number;
20
- export {};
@@ -1,30 +0,0 @@
1
- /**
2
- * Returns if the corner should have a radius or not based on the layout and the data.
3
- * @param {GetRadiusCorner} corner The corner to check.
4
- * @param {GetRadiusData} cornerData The data for the corner.
5
- * @returns {number} The radius for the corner.
6
- */
7
- export const getRadius = (corner, {
8
- hasNegative,
9
- hasPositive,
10
- borderRadius,
11
- layout
12
- }) => {
13
- if (!borderRadius) {
14
- return 0;
15
- }
16
- const isVertical = layout === 'vertical';
17
- if (corner === 'top-left' && (isVertical && hasPositive || !isVertical && hasNegative)) {
18
- return borderRadius;
19
- }
20
- if (corner === 'top-right' && (isVertical && hasPositive || !isVertical && hasPositive)) {
21
- return borderRadius;
22
- }
23
- if (corner === 'bottom-right' && (isVertical && hasNegative || !isVertical && hasPositive)) {
24
- return borderRadius;
25
- }
26
- if (corner === 'bottom-left' && (isVertical && hasNegative || !isVertical && hasNegative)) {
27
- return borderRadius;
28
- }
29
- return 0;
30
- };