@redsift/charts 11.5.0 → 11.6.0-muiv5-alpha.1

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 (223) hide show
  1. package/_virtual/_rollupPluginBabelHelpers.js +93 -0
  2. package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  3. package/components/Arc/Arc.d.ts +6 -0
  4. package/components/Arc/Arc.js +74 -0
  5. package/components/Arc/Arc.js.map +1 -0
  6. package/components/Arc/styles.d.ts +17 -0
  7. package/components/Arc/styles.js +49 -0
  8. package/components/Arc/styles.js.map +1 -0
  9. package/components/Arc/types.d.ts +20 -0
  10. package/components/Arcs/Arcs.d.ts +6 -0
  11. package/components/Arcs/Arcs.js +90 -0
  12. package/components/Arcs/Arcs.js.map +1 -0
  13. package/components/Arcs/styles.d.ts +9 -0
  14. package/components/Arcs/styles.js +9 -0
  15. package/components/Arcs/styles.js.map +1 -0
  16. package/components/Arcs/types.d.ts +17 -0
  17. package/components/Axis/Axis.d.ts +7 -0
  18. package/components/Axis/Axis.js +211 -0
  19. package/components/Axis/Axis.js.map +1 -0
  20. package/components/Axis/computeTicks.js +117 -0
  21. package/components/Axis/computeTicks.js.map +1 -0
  22. package/components/Axis/styles.d.ts +14 -0
  23. package/components/Axis/styles.js +51 -0
  24. package/components/Axis/styles.js.map +1 -0
  25. package/components/Axis/types.d.ts +89 -0
  26. package/components/Axis/types.js +24 -0
  27. package/components/Axis/types.js.map +1 -0
  28. package/components/Bar/Bar.d.ts +6 -0
  29. package/components/Bar/Bar.js +95 -0
  30. package/components/Bar/Bar.js.map +1 -0
  31. package/components/Bar/styles.d.ts +16 -0
  32. package/components/Bar/styles.js +66 -0
  33. package/components/Bar/styles.js.map +1 -0
  34. package/components/Bar/types.d.ts +46 -0
  35. package/components/Bar/types.js +18 -0
  36. package/components/Bar/types.js.map +1 -0
  37. package/components/BarChart/BarChart.d.ts +29 -0
  38. package/components/BarChart/BarChart.js +141 -0
  39. package/components/BarChart/BarChart.js.map +1 -0
  40. package/components/BarChart/BarChartBars.js +168 -0
  41. package/components/BarChart/BarChartBars.js.map +1 -0
  42. package/components/BarChart/BarChartSection.js +139 -0
  43. package/components/BarChart/BarChartSection.js.map +1 -0
  44. package/components/BarChart/EmptyBarChart.js +57 -0
  45. package/components/BarChart/EmptyBarChart.js.map +1 -0
  46. package/components/BarChart/LoadingBarChart.js +18 -0
  47. package/components/BarChart/LoadingBarChart.js.map +1 -0
  48. package/components/BarChart/RenderedLinearBarChart.js +549 -0
  49. package/components/BarChart/RenderedLinearBarChart.js.map +1 -0
  50. package/components/BarChart/RenderedOrdinalBarChart.js +236 -0
  51. package/components/BarChart/RenderedOrdinalBarChart.js.map +1 -0
  52. package/components/BarChart/context.js +13 -0
  53. package/components/BarChart/context.js.map +1 -0
  54. package/components/BarChart/intl/en-US.json.js +17 -0
  55. package/components/BarChart/intl/en-US.json.js.map +1 -0
  56. package/components/BarChart/intl/fr-FR.json.js +17 -0
  57. package/components/BarChart/intl/fr-FR.json.js.map +1 -0
  58. package/components/BarChart/intl/index.js +10 -0
  59. package/components/BarChart/intl/index.js.map +1 -0
  60. package/components/BarChart/styles.d.ts +19 -0
  61. package/components/BarChart/styles.js +71 -0
  62. package/components/BarChart/styles.js.map +1 -0
  63. package/components/BarChart/types.d.ts +177 -0
  64. package/components/BarChart/types.js +17 -0
  65. package/components/BarChart/types.js.map +1 -0
  66. package/components/BarChart/utils.js +69 -0
  67. package/components/BarChart/utils.js.map +1 -0
  68. package/components/ChartContainer/ChartContainer.d.ts +9 -0
  69. package/components/ChartContainer/ChartContainer.js +167 -0
  70. package/components/ChartContainer/ChartContainer.js.map +1 -0
  71. package/components/ChartContainer/context.js +6 -0
  72. package/components/ChartContainer/context.js.map +1 -0
  73. package/components/ChartContainer/intl/en-US.json.js +14 -0
  74. package/components/ChartContainer/intl/en-US.json.js.map +1 -0
  75. package/components/ChartContainer/intl/fr-FR.json.js +14 -0
  76. package/components/ChartContainer/intl/fr-FR.json.js.map +1 -0
  77. package/components/ChartContainer/intl/index.js +10 -0
  78. package/components/ChartContainer/intl/index.js.map +1 -0
  79. package/components/ChartContainer/styles.d.ts +17 -0
  80. package/components/ChartContainer/styles.js +76 -0
  81. package/components/ChartContainer/styles.js.map +1 -0
  82. package/components/ChartContainer/types.d.ts +48 -0
  83. package/components/DataPoint/DataPoint.d.ts +6 -0
  84. package/components/DataPoint/DataPoint.js +104 -0
  85. package/components/DataPoint/DataPoint.js.map +1 -0
  86. package/components/DataPoint/styles.d.ts +12 -0
  87. package/components/DataPoint/styles.js +10 -0
  88. package/components/DataPoint/styles.js.map +1 -0
  89. package/components/DataPoint/types.d.ts +60 -0
  90. package/components/Dot/Dot.d.ts +6 -0
  91. package/components/Dot/Dot.js +55 -0
  92. package/components/Dot/Dot.js.map +1 -0
  93. package/components/Dot/styles.d.ts +16 -0
  94. package/components/Dot/styles.js +49 -0
  95. package/components/Dot/styles.js.map +1 -0
  96. package/components/Dot/types.d.ts +30 -0
  97. package/components/Dot/types.js +14 -0
  98. package/components/Dot/types.js.map +1 -0
  99. package/components/Legend/Legend.d.ts +6 -0
  100. package/components/Legend/Legend.js +73 -0
  101. package/components/Legend/Legend.js.map +1 -0
  102. package/components/Legend/styles.d.ts +11 -0
  103. package/components/Legend/styles.js +15 -0
  104. package/components/Legend/styles.js.map +1 -0
  105. package/components/Legend/types.d.ts +44 -0
  106. package/components/LegendItem/LegendItem.js +96 -0
  107. package/components/LegendItem/LegendItem.js.map +1 -0
  108. package/components/LegendItem/styles.js +63 -0
  109. package/components/LegendItem/styles.js.map +1 -0
  110. package/components/LegendItem/types.d.ts +20 -0
  111. package/components/Line/Line.d.ts +6 -0
  112. package/components/Line/Line.js +55 -0
  113. package/components/Line/Line.js.map +1 -0
  114. package/components/Line/styles.d.ts +9 -0
  115. package/components/Line/styles.js +9 -0
  116. package/components/Line/styles.js.map +1 -0
  117. package/components/Line/types.d.ts +21 -0
  118. package/components/LineChart/EmptyLineChart.js +58 -0
  119. package/components/LineChart/EmptyLineChart.js.map +1 -0
  120. package/components/LineChart/LineChart.d.ts +6 -0
  121. package/components/LineChart/LineChart.js +96 -0
  122. package/components/LineChart/LineChart.js.map +1 -0
  123. package/components/LineChart/LoadingLineChart.js +18 -0
  124. package/components/LineChart/LoadingLineChart.js.map +1 -0
  125. package/components/LineChart/RenderedLineChart.js +372 -0
  126. package/components/LineChart/RenderedLineChart.js.map +1 -0
  127. package/components/LineChart/intl/en-US.json.js +17 -0
  128. package/components/LineChart/intl/en-US.json.js.map +1 -0
  129. package/components/LineChart/intl/fr-FR.json.js +17 -0
  130. package/components/LineChart/intl/fr-FR.json.js.map +1 -0
  131. package/components/LineChart/intl/index.js +10 -0
  132. package/components/LineChart/intl/index.js.map +1 -0
  133. package/components/LineChart/styles.d.ts +17 -0
  134. package/components/LineChart/styles.js +53 -0
  135. package/components/LineChart/styles.js.map +1 -0
  136. package/components/LineChart/types.d.ts +90 -0
  137. package/components/LineChart/types.js +17 -0
  138. package/components/LineChart/types.js.map +1 -0
  139. package/components/LineChart/utils.js +67 -0
  140. package/components/LineChart/utils.js.map +1 -0
  141. package/components/PieChart/EmptyPieChart.js +85 -0
  142. package/components/PieChart/EmptyPieChart.js.map +1 -0
  143. package/components/PieChart/LoadingPieChart.js +18 -0
  144. package/components/PieChart/LoadingPieChart.js.map +1 -0
  145. package/components/PieChart/PieChart.d.ts +6 -0
  146. package/components/PieChart/PieChart.js +98 -0
  147. package/components/PieChart/PieChart.js.map +1 -0
  148. package/components/PieChart/RenderedPieChart.js +198 -0
  149. package/components/PieChart/RenderedPieChart.js.map +1 -0
  150. package/components/PieChart/intl/en-US.json.js +9 -0
  151. package/components/PieChart/intl/en-US.json.js.map +1 -0
  152. package/components/PieChart/intl/fr-FR.json.js +9 -0
  153. package/components/PieChart/intl/fr-FR.json.js.map +1 -0
  154. package/components/PieChart/intl/index.js +10 -0
  155. package/components/PieChart/intl/index.js.map +1 -0
  156. package/components/PieChart/styles.d.ts +24 -0
  157. package/components/PieChart/styles.js +168 -0
  158. package/components/PieChart/styles.js.map +1 -0
  159. package/components/PieChart/types.d.ts +115 -0
  160. package/components/PieChart/types.js +27 -0
  161. package/components/PieChart/types.js.map +1 -0
  162. package/components/PieChart/utils.js +37 -0
  163. package/components/PieChart/utils.js.map +1 -0
  164. package/components/ScatterPlot/EmptyScatterPlot.js +58 -0
  165. package/components/ScatterPlot/EmptyScatterPlot.js.map +1 -0
  166. package/components/ScatterPlot/LoadingScatterPlot.js +18 -0
  167. package/components/ScatterPlot/LoadingScatterPlot.js.map +1 -0
  168. package/components/ScatterPlot/RenderedScatterPlot.js +352 -0
  169. package/components/ScatterPlot/RenderedScatterPlot.js.map +1 -0
  170. package/components/ScatterPlot/ScatterPlot.d.ts +6 -0
  171. package/components/ScatterPlot/ScatterPlot.js +105 -0
  172. package/components/ScatterPlot/ScatterPlot.js.map +1 -0
  173. package/components/ScatterPlot/intl/en-US.json.js +12 -0
  174. package/components/ScatterPlot/intl/en-US.json.js.map +1 -0
  175. package/components/ScatterPlot/intl/fr-FR.json.js +17 -0
  176. package/components/ScatterPlot/intl/fr-FR.json.js.map +1 -0
  177. package/components/ScatterPlot/intl/index.js +10 -0
  178. package/components/ScatterPlot/intl/index.js.map +1 -0
  179. package/components/ScatterPlot/styles.d.ts +17 -0
  180. package/components/ScatterPlot/styles.js +53 -0
  181. package/components/ScatterPlot/styles.js.map +1 -0
  182. package/components/ScatterPlot/types.d.ts +109 -0
  183. package/components/ScatterPlot/types.js +24 -0
  184. package/components/ScatterPlot/types.js.map +1 -0
  185. package/components/ScatterPlot/utils.js +70 -0
  186. package/components/ScatterPlot/utils.js.map +1 -0
  187. package/config.js +15 -0
  188. package/config.js.map +1 -0
  189. package/design-system/src/react-aria/react-aria/i18n/useMessageFormatter.d.ts +5 -0
  190. package/hooks/useBrush.d.ts +17 -0
  191. package/hooks/useBrush.js +48 -0
  192. package/hooks/useBrush.js.map +1 -0
  193. package/hooks/useColor.d.ts +18 -0
  194. package/hooks/useColor.js +20 -0
  195. package/hooks/useColor.js.map +1 -0
  196. package/hooks/useFormatCategoricalData.d.ts +26 -0
  197. package/hooks/useFormatCategoricalData.js +57 -0
  198. package/hooks/useFormatCategoricalData.js.map +1 -0
  199. package/hooks/useZoom.d.ts +26 -0
  200. package/hooks/useZoom.js +39 -0
  201. package/hooks/useZoom.js.map +1 -0
  202. package/index.d.ts +51 -1277
  203. package/index.js +42 -5118
  204. package/index.js.map +1 -1
  205. package/package.json +4 -4
  206. package/scheme.d.ts +32 -0
  207. package/scheme.js +47 -0
  208. package/scheme.js.map +1 -0
  209. package/types/axis.d.ts +48 -0
  210. package/types/data.d.ts +72 -0
  211. package/types/legend.d.ts +30 -0
  212. package/types/legend.js +21 -0
  213. package/types/legend.js.map +1 -0
  214. package/types/scale.d.ts +48 -0
  215. package/types/size.d.ts +20 -0
  216. package/types/size.js +8 -0
  217. package/types/size.js.map +1 -0
  218. package/types/theme.d.ts +23 -0
  219. package/types/theme.js +13 -0
  220. package/types/theme.js.map +1 -0
  221. package/utils/index.d.ts +11 -0
  222. package/utils/index.js +44 -0
  223. package/utils/index.js.map +1 -0
@@ -0,0 +1,211 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef, useRef } from 'react';
3
+ import classNames from 'classnames';
4
+ import { useTheme } from '@redsift/design-system';
5
+ import { AxisPosition, AxisVariant } from './types.js';
6
+ import { StyledAxis } from './styles.js';
7
+ import { a as it } from '../../node_modules/@react-spring/web/dist/esm/index.js';
8
+ import { computeTicks } from './computeTicks.js';
9
+ import { config } from '../../config.js';
10
+ import { useSpring as J, useTransition as Gt } from '../../node_modules/@react-spring/core/dist/esm/index.js';
11
+
12
+ const _excluded = ["className", "disableAnimations", "grid", "length", "legend", "legendOffset", "legendPosition", "legendX", "legendY", "legendRotation", "legendStyle", "position", "scale", "tickPadding", "tickRotation", "tickSize", "tickValues", "tickFormat", "tickRemodelling", "variant", "x", "y", "chartWidth", "chartHeight", "sectionHeight", "textColor", "tickToColor"],
13
+ _excluded2 = ["length"];
14
+ const COMPONENT_NAME = 'Axis';
15
+ const CLASSNAME = 'redsift-axis';
16
+ const getAxisType = position => [AxisPosition.top, AxisPosition.bottom].includes(position) ? 'x' : 'y';
17
+ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
18
+ const {
19
+ className,
20
+ disableAnimations,
21
+ grid,
22
+ length,
23
+ legend,
24
+ legendOffset = -32,
25
+ legendPosition = 'end',
26
+ legendX: propsLegendX,
27
+ legendY: propsLegendY,
28
+ legendRotation: propsLegendRotation,
29
+ legendStyle,
30
+ position = AxisPosition.bottom,
31
+ scale,
32
+ tickPadding = 5,
33
+ tickRotation = 0,
34
+ tickSize = 5,
35
+ tickValues,
36
+ tickFormat,
37
+ tickRemodelling,
38
+ variant = AxisVariant.default,
39
+ x = 0,
40
+ y = 0,
41
+ chartWidth,
42
+ chartHeight,
43
+ sectionHeight,
44
+ textColor,
45
+ tickToColor = () => true
46
+ } = props,
47
+ forwardedProps = _objectWithoutProperties(props, _excluded);
48
+ const theme = useTheme();
49
+ const axis = getAxisType(position);
50
+ const _ref = typeof grid === 'object' ? _objectSpread2({
51
+ length: axis === 'x' ? sectionHeight !== null && sectionHeight !== void 0 ? sectionHeight : chartHeight : chartWidth
52
+ }, grid) : grid === true ? {
53
+ length: axis === 'x' ? sectionHeight !== null && sectionHeight !== void 0 ? sectionHeight : chartHeight : chartWidth
54
+ } : {
55
+ length: 0
56
+ },
57
+ {
58
+ length: gridLength
59
+ } = _ref,
60
+ gridStyle = _objectWithoutProperties(_ref, _excluded2);
61
+ const axisRef = ref || useRef();
62
+ const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
63
+ to: async next => {
64
+ await next({
65
+ lineX2: axis === 'x' ? length : 0,
66
+ lineY2: axis === 'x' ? 0 : length
67
+ });
68
+ },
69
+ from: {
70
+ lineX2: 0,
71
+ lineY2: 0
72
+ },
73
+ reset: false
74
+ }));
75
+ let legendNode = null;
76
+ if (legend !== undefined) {
77
+ let legendX = 0;
78
+ let legendY = 0;
79
+ let legendRotation = 0;
80
+ let textAnchor;
81
+ if (axis === 'y') {
82
+ legendRotation = propsLegendRotation !== null && propsLegendRotation !== void 0 ? propsLegendRotation : 90;
83
+ legendX = propsLegendX !== null && propsLegendX !== void 0 ? propsLegendX : legendOffset;
84
+ if (legendPosition === 'start') {
85
+ textAnchor = 'start';
86
+ legendY = propsLegendY !== null && propsLegendY !== void 0 ? propsLegendY : length;
87
+ } else if (legendPosition === 'middle') {
88
+ textAnchor = 'middle';
89
+ legendY = propsLegendY !== null && propsLegendY !== void 0 ? propsLegendY : length / 2;
90
+ } else if (legendPosition === 'end') {
91
+ textAnchor = 'end';
92
+ legendY = propsLegendY !== null && propsLegendY !== void 0 ? propsLegendY : legendY;
93
+ }
94
+ } else {
95
+ legendY = propsLegendY !== null && propsLegendY !== void 0 ? propsLegendY : legendOffset;
96
+ if (legendPosition === 'start') {
97
+ textAnchor = 'start';
98
+ legendX = propsLegendX !== null && propsLegendX !== void 0 ? propsLegendX : legendX;
99
+ } else if (legendPosition === 'middle') {
100
+ textAnchor = 'middle';
101
+ legendX = propsLegendX !== null && propsLegendX !== void 0 ? propsLegendX : length / 2;
102
+ } else if (legendPosition === 'end') {
103
+ textAnchor = 'end';
104
+ legendX = propsLegendX !== null && propsLegendX !== void 0 ? propsLegendX : length;
105
+ }
106
+ }
107
+ legendNode = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("text", {
108
+ transform: `translate(${legendX}, ${legendY}) rotate(${legendRotation})`,
109
+ textAnchor: textAnchor,
110
+ style: _objectSpread2({
111
+ dominantBaseline: 'central'
112
+ }, legendStyle)
113
+ }, legend));
114
+ }
115
+ const {
116
+ ticks,
117
+ textAlign,
118
+ textBaseline
119
+ } = computeTicks({
120
+ axis,
121
+ scale: scale,
122
+ ticksPosition: [AxisPosition.top, AxisPosition.left].includes(position) ? 'before' : 'after',
123
+ tickValues,
124
+ tickSize: tickSize,
125
+ tickPadding: tickPadding,
126
+ tickRotation: tickRotation,
127
+ tickRemodelling
128
+ });
129
+ const transition = Gt(ticks, _objectSpread2(_objectSpread2({}, config), {}, {
130
+ keys: tick => tick.key,
131
+ initial: tick => ({
132
+ opacity: 1,
133
+ transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${axis === 'x' ? 0 : 180})`,
134
+ textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`
135
+ }),
136
+ from: tick => ({
137
+ opacity: 0,
138
+ transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${axis === 'x' ? 0 : 180})`,
139
+ textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`
140
+ }),
141
+ enter: tick => ({
142
+ opacity: 1,
143
+ transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${axis === 'x' ? 0 : 180})`,
144
+ textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`
145
+ }),
146
+ update: tick => ({
147
+ opacity: 1,
148
+ transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${axis === 'x' ? 0 : 180})`,
149
+ textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`
150
+ }),
151
+ leave: {
152
+ opacity: 0
153
+ }
154
+ }));
155
+ return /*#__PURE__*/React__default.createElement(StyledAxis, _extends({
156
+ "aria-hidden": "true",
157
+ className: classNames(Axis.className, className),
158
+ $theme: theme
159
+ }, forwardedProps, {
160
+ transform: `translate(${x},${y})${axis === 'x' ? '' : ',rotate(180)'}`,
161
+ ref: axisRef,
162
+ $color: textColor
163
+ }), gridLength ? /*#__PURE__*/React__default.createElement("g", {
164
+ className: `${Axis.className}__grid`
165
+ }, ticks.map((tick, i) => /*#__PURE__*/React__default.createElement("line", {
166
+ key: `grid-${tick.key}-${i}`,
167
+ className: `${Axis.className}-grid__line`,
168
+ x1: axis === 'x' ? tick.x : 0,
169
+ x2: axis === 'x' ? tick.x : gridLength * -1,
170
+ y1: axis === 'x' ? 0 : tick.y,
171
+ y2: axis === 'x' ? gridLength * -1 : tick.y,
172
+ style: _objectSpread2(_objectSpread2({
173
+ strokeDasharray: '4,4',
174
+ opacity: 0.2,
175
+ strokeWidth: 0.5
176
+ }, gridStyle), {}, {
177
+ stroke: 'currentColor'
178
+ })
179
+ }))) : null, variant === AxisVariant.default || variant === AxisVariant.tick || variant === AxisVariant.lineTick || variant === AxisVariant.tickValue ? transition((transitionProps, tick, _state, tickIndex) => {
180
+ return /*#__PURE__*/React__default.createElement(it.g, {
181
+ className: `${Axis.className}__tick`,
182
+ key: tickIndex,
183
+ transform: transitionProps.transform,
184
+ style: {
185
+ opacity: transitionProps.opacity
186
+ }
187
+ }, /*#__PURE__*/React__default.createElement("line", {
188
+ className: `${Axis.className}-tick__line`,
189
+ x1: 0,
190
+ x2: tick.lineX,
191
+ y1: 0,
192
+ y2: tick.lineY
193
+ }), variant === AxisVariant.default || variant === AxisVariant.tickValue ? /*#__PURE__*/React__default.createElement(it.text, {
194
+ dominantBaseline: textBaseline,
195
+ textAnchor: textAlign,
196
+ transform: transitionProps.textTransform,
197
+ className: !textColor ? '' : tickToColor(tick, tickIndex) ? 'colored' : ''
198
+ }, `${tickFormat ? tickFormat(tick.value) : tick.value}`) : null);
199
+ }) : null, variant === AxisVariant.default || variant === AxisVariant.line || variant === AxisVariant.lineTick ? /*#__PURE__*/React__default.createElement(it.line, {
200
+ className: `${Axis.className}__line`,
201
+ x1: 0,
202
+ x2: config.immediate || disableAnimations ? axis === 'x' ? length : 0 : animatedProps.lineX2,
203
+ y1: 0,
204
+ y2: config.immediate || disableAnimations ? axis === 'x' ? 0 : length : animatedProps.lineY2
205
+ }) : null, legendNode);
206
+ });
207
+ Axis.className = CLASSNAME;
208
+ Axis.displayName = COMPONENT_NAME;
209
+
210
+ export { Axis, getAxisType };
211
+ //# sourceMappingURL=Axis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Axis.js","sources":["../../../src/components/Axis/Axis.tsx"],"sourcesContent":["import React, { forwardRef, RefObject, useRef } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp, useTheme } from '@redsift/design-system';\n\nimport { AxisProps, AxisPosition, AxisVariant } from './types';\nimport { StyledAxis } from './styles';\nimport { animated, useSpring, useTransition } from '@react-spring/web';\nimport { computeTicks } from './computeTicks';\nimport { config } from '../../config';\nimport { AnyScale } from '@redsift/charts/types';\n\nconst COMPONENT_NAME = 'Axis';\nconst CLASSNAME = 'redsift-axis';\n\nexport const getAxisType = (position: AxisPosition) =>\n [AxisPosition.top, AxisPosition.bottom].includes(position) ? 'x' : 'y';\n\nexport const Axis: Comp<AxisProps, SVGGElement> = forwardRef((props, ref) => {\n const {\n className,\n disableAnimations,\n grid,\n length,\n legend,\n legendOffset = -32,\n legendPosition = 'end',\n legendX: propsLegendX,\n legendY: propsLegendY,\n legendRotation: propsLegendRotation,\n legendStyle,\n position = AxisPosition.bottom,\n scale,\n tickPadding = 5,\n tickRotation = 0,\n tickSize = 5,\n tickValues,\n tickFormat,\n tickRemodelling,\n variant = AxisVariant.default,\n x = 0,\n y = 0,\n chartWidth,\n chartHeight,\n sectionHeight,\n textColor,\n tickToColor = () => true,\n ...forwardedProps\n } = props;\n const theme = useTheme();\n const axis = getAxisType(position!);\n const { length: gridLength, ...gridStyle } =\n typeof grid === 'object'\n ? { length: axis === 'x' ? sectionHeight ?? chartHeight : chartWidth, ...grid }\n : grid === true\n ? {\n length: axis === 'x' ? sectionHeight ?? chartHeight : chartWidth,\n }\n : { length: 0 };\n\n const axisRef = (ref || useRef<SVGGElement>()) as RefObject<SVGGElement>;\n\n const animatedProps = useSpring({\n ...config,\n to: async (next: (props?: object) => Promise<void>) => {\n await next({\n lineX2: axis === 'x' ? length : 0,\n lineY2: axis === 'x' ? 0 : length,\n });\n },\n from: { lineX2: 0, lineY2: 0 },\n reset: false,\n });\n\n let legendNode = null;\n if (legend !== undefined) {\n let legendX = 0;\n let legendY = 0;\n let legendRotation = 0;\n let textAnchor;\n\n if (axis === 'y') {\n legendRotation = propsLegendRotation ?? 90;\n legendX = propsLegendX ?? legendOffset!;\n if (legendPosition === 'start') {\n textAnchor = 'start';\n legendY = propsLegendY ?? length!;\n } else if (legendPosition === 'middle') {\n textAnchor = 'middle';\n legendY = propsLegendY ?? length! / 2;\n } else if (legendPosition === 'end') {\n textAnchor = 'end';\n legendY = propsLegendY ?? legendY;\n }\n } else {\n legendY = propsLegendY ?? legendOffset!;\n if (legendPosition === 'start') {\n textAnchor = 'start';\n legendX = propsLegendX ?? legendX;\n } else if (legendPosition === 'middle') {\n textAnchor = 'middle';\n legendX = propsLegendX ?? length! / 2;\n } else if (legendPosition === 'end') {\n textAnchor = 'end';\n legendX = propsLegendX ?? length!;\n }\n }\n\n legendNode = (\n <>\n <text\n transform={`translate(${legendX}, ${legendY}) rotate(${legendRotation})`}\n textAnchor={textAnchor}\n style={{\n dominantBaseline: 'central',\n ...legendStyle,\n }}\n >\n {legend}\n </text>\n </>\n );\n }\n\n const { ticks, textAlign, textBaseline } = computeTicks({\n axis,\n scale: scale as AnyScale,\n ticksPosition: [AxisPosition.top, AxisPosition.left].includes(position!) ? 'before' : 'after',\n tickValues,\n tickSize: tickSize!,\n tickPadding: tickPadding!,\n tickRotation: tickRotation!,\n tickRemodelling,\n });\n\n const transition = useTransition<(typeof ticks)[0], { opacity: number; transform: string; textTransform: string }>(\n ticks,\n {\n ...config,\n keys: (tick) => tick.key,\n initial: (tick) => ({\n opacity: 1,\n transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${\n axis === 'x' ? 0 : 180\n })`,\n textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`,\n }),\n from: (tick) => ({\n opacity: 0,\n transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${\n axis === 'x' ? 0 : 180\n })`,\n textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`,\n }),\n enter: (tick) => ({\n opacity: 1,\n transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${\n axis === 'x' ? 0 : 180\n })`,\n textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`,\n }),\n update: (tick) => ({\n opacity: 1,\n transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${\n axis === 'x' ? 0 : 180\n })`,\n textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`,\n }),\n leave: {\n opacity: 0,\n },\n }\n );\n\n return (\n <StyledAxis\n aria-hidden=\"true\"\n className={classNames(Axis.className, className)}\n $theme={theme}\n {...forwardedProps}\n transform={`translate(${x},${y})${axis === 'x' ? '' : ',rotate(180)'}`}\n ref={axisRef}\n $color={textColor}\n >\n {gridLength ? (\n <g className={`${Axis.className}__grid`}>\n {ticks.map((tick, i) => (\n <line\n key={`grid-${tick.key}-${i}`}\n className={`${Axis.className}-grid__line`}\n x1={axis === 'x' ? tick.x : 0}\n x2={axis === 'x' ? tick.x : gridLength! * -1}\n y1={axis === 'x' ? 0 : tick.y}\n y2={axis === 'x' ? gridLength! * -1 : tick.y}\n style={{\n strokeDasharray: '4,4',\n opacity: 0.2,\n strokeWidth: 0.5,\n ...gridStyle,\n stroke: 'currentColor',\n }}\n />\n ))}\n </g>\n ) : null}\n\n {variant === AxisVariant.default ||\n variant === AxisVariant.tick ||\n variant === AxisVariant.lineTick ||\n variant === AxisVariant.tickValue\n ? transition((transitionProps, tick, _state, tickIndex) => {\n return (\n <animated.g\n className={`${Axis.className}__tick`}\n key={tickIndex}\n transform={transitionProps.transform}\n style={{ opacity: transitionProps.opacity }}\n >\n <line className={`${Axis.className}-tick__line`} x1={0} x2={tick.lineX} y1={0} y2={tick.lineY} />\n {variant === AxisVariant.default || variant === AxisVariant.tickValue ? (\n <animated.text\n dominantBaseline={textBaseline}\n textAnchor={textAlign}\n transform={transitionProps.textTransform}\n className={!textColor ? '' : tickToColor(tick, tickIndex) ? 'colored' : ''}\n >\n {`${tickFormat ? tickFormat(tick.value as any) : tick.value}`}\n </animated.text>\n ) : null}\n </animated.g>\n );\n })\n : null}\n\n {variant === AxisVariant.default || variant === AxisVariant.line || variant === AxisVariant.lineTick ? (\n <animated.line\n className={`${Axis.className}__line`}\n x1={0}\n x2={config.immediate || disableAnimations ? (axis === 'x' ? length : 0) : animatedProps.lineX2}\n y1={0}\n y2={config.immediate || disableAnimations ? (axis === 'x' ? 0 : length) : animatedProps.lineY2}\n />\n ) : null}\n {legendNode}\n </StyledAxis>\n );\n});\nAxis.className = CLASSNAME;\nAxis.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getAxisType","position","AxisPosition","top","bottom","includes","Axis","forwardRef","props","ref","className","disableAnimations","grid","length","legend","legendOffset","legendPosition","legendX","propsLegendX","legendY","propsLegendY","legendRotation","propsLegendRotation","legendStyle","scale","tickPadding","tickRotation","tickSize","tickValues","tickFormat","tickRemodelling","variant","AxisVariant","default","x","y","chartWidth","chartHeight","sectionHeight","textColor","tickToColor","forwardedProps","_objectWithoutProperties","_excluded","theme","useTheme","axis","_ref","_objectSpread","gridLength","gridStyle","_excluded2","axisRef","useRef","animatedProps","useSpring","config","to","next","lineX2","lineY2","from","reset","legendNode","undefined","textAnchor","React","createElement","Fragment","transform","style","dominantBaseline","ticks","textAlign","textBaseline","computeTicks","ticksPosition","left","transition","useTransition","keys","tick","key","initial","opacity","textTransform","textX","textY","enter","update","leave","StyledAxis","_extends","classNames","$theme","$color","map","i","x1","x2","y1","y2","strokeDasharray","strokeWidth","stroke","lineTick","tickValue","transitionProps","_state","tickIndex","animated","g","lineX","lineY","text","value","line","immediate","displayName"],"mappings":";;;;;;;;;;;;;AAYA,MAAMA,cAAc,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../_virtual/_rollupPluginBabelHelpers.js';
2
+
3
+ const getScaleTicks = (scale, spec) => {
4
+ // specific values
5
+ if (Array.isArray(spec)) {
6
+ return spec;
7
+ }
8
+
9
+ // continuous scales
10
+ if ('ticks' in scale) {
11
+ // default behaviour
12
+ if (spec === undefined) {
13
+ return scale.ticks();
14
+ }
15
+
16
+ // specific tick count
17
+ if (typeof spec === 'number' && isFinite(spec) && Math.floor(spec) === spec) {
18
+ return scale.ticks(spec);
19
+ }
20
+ if (typeof spec === 'function') {
21
+ return scale.ticks();
22
+ }
23
+ }
24
+
25
+ // non linear scale default
26
+ return scale.domain();
27
+ };
28
+ const centerScale = scale => {
29
+ const bandwidth = scale.bandwidth();
30
+ if (bandwidth === 0) return scale;
31
+ let offset = bandwidth / 2;
32
+ if (scale.round()) {
33
+ offset = Math.round(offset);
34
+ }
35
+ return d => {
36
+ var _scale;
37
+ return ((_scale = scale(d)) !== null && _scale !== void 0 ? _scale : 0) + offset;
38
+ };
39
+ };
40
+ const computeTicks = _ref => {
41
+ let {
42
+ axis,
43
+ scale,
44
+ ticksPosition,
45
+ tickValues,
46
+ tickSize,
47
+ tickPadding,
48
+ tickRotation,
49
+ tickRemodelling
50
+ } = _ref;
51
+ const values = tickRemodelling ? tickRemodelling(getScaleTicks(scale, tickValues)) : getScaleTicks(scale, tickValues);
52
+ const position = 'bandwidth' in scale ? centerScale(scale) : scale;
53
+ const line = {
54
+ lineX: 0,
55
+ lineY: 0
56
+ };
57
+ const text = {
58
+ textX: 0,
59
+ textY: 0
60
+ };
61
+ const isRTL = typeof document === 'object' ? document.dir === 'rtl' : false;
62
+ let translate;
63
+ let textAlign = 'middle';
64
+ let textBaseline = 'central';
65
+ if (axis === 'x') {
66
+ translate = d => {
67
+ var _position;
68
+ return {
69
+ x: (_position = position(d)) !== null && _position !== void 0 ? _position : 0,
70
+ y: 0
71
+ };
72
+ };
73
+ line.lineY = tickSize * (ticksPosition === 'after' ? 1 : -1);
74
+ text.textY = (tickSize + tickPadding) * (ticksPosition === 'after' ? 1 : -1);
75
+ if (ticksPosition === 'after') {
76
+ textBaseline = 'text-before-edge';
77
+ } else {
78
+ textBaseline = 'alphabetic';
79
+ }
80
+ if (tickRotation === 0) {
81
+ textAlign = 'middle';
82
+ } else if (ticksPosition === 'after' && tickRotation < 0 || ticksPosition === 'before' && tickRotation > 0) {
83
+ textAlign = isRTL ? 'start' : 'end';
84
+ textBaseline = 'middle';
85
+ } else if (ticksPosition === 'after' && tickRotation > 0 || ticksPosition === 'before' && tickRotation < 0) {
86
+ textAlign = isRTL ? 'end' : 'start';
87
+ textBaseline = 'middle';
88
+ }
89
+ } else {
90
+ translate = d => {
91
+ var _position2;
92
+ return {
93
+ x: 0,
94
+ y: (_position2 = position(d)) !== null && _position2 !== void 0 ? _position2 : 0
95
+ };
96
+ };
97
+ line.lineX = tickSize * (ticksPosition === 'after' ? 1 : -1);
98
+ text.textX = (tickSize + tickPadding) * (ticksPosition === 'after' ? 1 : -1);
99
+ if (ticksPosition === 'after') {
100
+ textAlign = 'start';
101
+ } else {
102
+ textAlign = 'end';
103
+ }
104
+ }
105
+ const ticks = values.map(value => _objectSpread2(_objectSpread2(_objectSpread2({
106
+ key: value instanceof Date ? `${value.valueOf()}` : `${value}`,
107
+ value
108
+ }, translate(value)), line), text));
109
+ return {
110
+ ticks,
111
+ textAlign,
112
+ textBaseline
113
+ };
114
+ };
115
+
116
+ export { centerScale, computeTicks };
117
+ //# sourceMappingURL=computeTicks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeTicks.js","sources":["../../../src/components/Axis/computeTicks.ts"],"sourcesContent":["import { AnyScale, Coordinates, ScaleValue, ScaleWithBandwidth, TicksSpec } from '../../types';\n\nconst getScaleTicks = (scale: AnyScale, spec?: TicksSpec) => {\n // specific values\n if (Array.isArray(spec)) {\n return spec;\n }\n\n // continuous scales\n if ('ticks' in scale) {\n // default behaviour\n if (spec === undefined) {\n return scale.ticks();\n }\n\n // specific tick count\n if (typeof spec === 'number' && isFinite(spec) && Math.floor(spec) === spec) {\n return scale.ticks(spec);\n }\n\n if (typeof spec === 'function') {\n return scale.ticks();\n }\n }\n\n // non linear scale default\n return scale.domain();\n};\n\nexport const centerScale = (scale: ScaleWithBandwidth) => {\n const bandwidth = scale.bandwidth();\n\n if (bandwidth === 0) return scale;\n\n let offset = bandwidth / 2;\n if (scale.round()) {\n offset = Math.round(offset);\n }\n\n return <T extends ScaleValue>(d: T) => (scale(d) ?? 0) + offset;\n};\n\nexport const computeTicks = ({\n axis,\n scale,\n ticksPosition,\n tickValues,\n tickSize,\n tickPadding,\n tickRotation,\n tickRemodelling,\n}: {\n axis: 'x' | 'y';\n scale: AnyScale;\n ticksPosition?: 'after' | 'before';\n tickValues?: TicksSpec;\n tickSize: number;\n tickPadding: number;\n tickRotation: number;\n tickRemodelling?: (tickValues: any[]) => any[];\n}) => {\n const values = tickRemodelling ? tickRemodelling(getScaleTicks(scale, tickValues)) : getScaleTicks(scale, tickValues);\n\n const position = 'bandwidth' in scale ? centerScale(scale) : scale;\n const line = { lineX: 0, lineY: 0 };\n const text = { textX: 0, textY: 0 };\n\n const isRTL = typeof document === 'object' ? document.dir === 'rtl' : false;\n let translate: (value: ScaleValue) => Coordinates;\n let textAlign = 'middle';\n let textBaseline = 'central';\n\n if (axis === 'x') {\n translate = (d) => ({ x: position(d) ?? 0, y: 0 });\n\n line.lineY = tickSize * (ticksPosition === 'after' ? 1 : -1);\n text.textY = (tickSize + tickPadding) * (ticksPosition === 'after' ? 1 : -1);\n\n if (ticksPosition === 'after') {\n textBaseline = 'text-before-edge';\n } else {\n textBaseline = 'alphabetic';\n }\n\n if (tickRotation === 0) {\n textAlign = 'middle';\n } else if ((ticksPosition === 'after' && tickRotation < 0) || (ticksPosition === 'before' && tickRotation > 0)) {\n textAlign = isRTL ? 'start' : 'end';\n textBaseline = 'middle';\n } else if ((ticksPosition === 'after' && tickRotation > 0) || (ticksPosition === 'before' && tickRotation < 0)) {\n textAlign = isRTL ? 'end' : 'start';\n textBaseline = 'middle';\n }\n } else {\n translate = (d) => ({ x: 0, y: position(d) ?? 0 });\n\n line.lineX = tickSize * (ticksPosition === 'after' ? 1 : -1);\n text.textX = (tickSize + tickPadding) * (ticksPosition === 'after' ? 1 : -1);\n\n if (ticksPosition === 'after') {\n textAlign = 'start';\n } else {\n textAlign = 'end';\n }\n }\n\n const ticks = values.map((value: ScaleValue) => ({\n key: value instanceof Date ? `${value.valueOf()}` : `${value}`,\n value,\n ...translate(value),\n ...line,\n ...text,\n }));\n\n return {\n ticks,\n textAlign,\n textBaseline,\n };\n};\n"],"names":["getScaleTicks","scale","spec","Array","isArray","undefined","ticks","isFinite","Math","floor","domain","centerScale","bandwidth","offset","round","d","_scale","computeTicks","_ref","axis","ticksPosition","tickValues","tickSize","tickPadding","tickRotation","tickRemodelling","values","position","line","lineX","lineY","text","textX","textY","isRTL","document","dir","translate","textAlign","textBaseline","_position","x","y","_position2","map","value","_objectSpread","key","Date","valueOf"],"mappings":";;AAEA,MAAMA,aAAa,GAAGA,CAACC,KAAe,EAAEC,IAAgB,KAAK;AAC3D;AACA,EAAA,IAAIC,KAAK,CAACC,OAAO,CAACF,IAAI,CAAC,EAAE;AACvB,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;;AAEA;EACA,IAAI,OAAO,IAAID,KAAK,EAAE;AACpB;IACA,IAAIC,IAAI,KAAKG,SAAS,EAAE;AACtB,MAAA,OAAOJ,KAAK,CAACK,KAAK,EAAE,CAAA;AACtB,KAAA;;AAEA;AACA,IAAA,IAAI,OAAOJ,IAAI,KAAK,QAAQ,IAAIK,QAAQ,CAACL,IAAI,CAAC,IAAIM,IAAI,CAACC,KAAK,CAACP,IAAI,CAAC,KAAKA,IAAI,EAAE;AAC3E,MAAA,OAAOD,KAAK,CAACK,KAAK,CAACJ,IAAI,CAAC,CAAA;AAC1B,KAAA;AAEA,IAAA,IAAI,OAAOA,IAAI,KAAK,UAAU,EAAE;AAC9B,MAAA,OAAOD,K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,cAAA,CAAAA,cAAA,CAAAA,cAAA,CAAA;AACzCC,IAAAA,GAAG,EAAEF,KAAK,YAAYG,IAAI,GAAI,CAAEH,EAAAA,KAAK,CAACI,OAAO,EAAG,CAAA,CAAC,GAAI,CAAA,EAAEJ,KAAM,CAAC,CAAA;AAC9DA,IAAAA,KAAAA;GACGR,EAAAA,SAAS,CAACQ,KAAK,CAAC,GAChBjB,IAAI,CAAA,EACJG,IAAI,CACP,CAAC,CAAA;EAEH,OAAO;IACLzB,KAAK;IACLgC,SAAS;AACTC,IAAAA,YAAAA;GACD,CAAA;AACH;;;;"}
@@ -0,0 +1,14 @@
1
+ import * as styled_components from 'styled-components';
2
+ import { AxisProps } from './types.js';
3
+ import * as _react_spring_web from '@react-spring/web';
4
+ import { Theme } from '@redsift/design-system';
5
+
6
+ /**
7
+ * Component style.
8
+ */
9
+ declare const StyledAxis: styled_components.StyledComponent<_react_spring_web.AnimatedComponent<"g">, any, Omit<AxisProps, "size" | "scale" | "areXLabelsRotated"> & {
10
+ $theme: Theme;
11
+ $color?: string | undefined;
12
+ }, never>;
13
+
14
+ export { StyledAxis };
@@ -0,0 +1,51 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { a as it } from '../../node_modules/@react-spring/web/dist/esm/index.js';
3
+ import { Theme } from '@redsift/design-system';
4
+
5
+ /**
6
+ * Component style.
7
+ */
8
+ const StyledAxis = styled(it.g)`
9
+ .redsift-axis__line,
10
+ .redsift-axis-tick__line {
11
+ fill: none;
12
+ ${_ref => {
13
+ let {
14
+ $theme
15
+ } = _ref;
16
+ return css`
17
+ stroke: var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'});
18
+ `;
19
+ }}
20
+ shape-rendering: crispEdges;
21
+ }
22
+
23
+ text {
24
+ font-family: var(--redsift-typography-font-family-poppins);
25
+ ${_ref2 => {
26
+ let {
27
+ $theme
28
+ } = _ref2;
29
+ return css`
30
+ fill: var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'});
31
+ `;
32
+ }}
33
+ font-size: 10px;
34
+ user-select: none;
35
+ }
36
+
37
+ text.colored {
38
+ ${_ref3 => {
39
+ let {
40
+ $theme,
41
+ $color
42
+ } = _ref3;
43
+ return css`
44
+ fill: ${$color === 'green' ? '#029B57' : $color === 'red' ? '#CB0E0E' : `var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'})`};
45
+ `;
46
+ }}
47
+ }
48
+ `;
49
+
50
+ export { StyledAxis };
51
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sources":["../../../src/components/Axis/styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { StyledAxisProps } from './types';\nimport { animated } from '@react-spring/web';\nimport { Theme } from '@redsift/design-system';\n\n/**\n * Component style.\n */\nexport const StyledAxis = styled(animated.g)<StyledAxisProps>`\n .redsift-axis__line,\n .redsift-axis-tick__line {\n fill: none;\n ${({ $theme }) => css`\n stroke: var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'});\n `}\n shape-rendering: crispEdges;\n }\n\n text {\n font-family: var(--redsift-typography-font-family-poppins);\n ${({ $theme }) => css`\n fill: var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'});\n `}\n font-size: 10px;\n user-select: none;\n }\n\n text.colored {\n ${({ $theme, $color }) => css`\n fill: ${$color === 'green'\n ? '#029B57'\n : $color === 'red'\n ? '#CB0E0E'\n : `var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'})`};\n `}\n }\n`;\n"],"names":["StyledAxis","styled","animated","g","_ref","$theme","css","Theme","dark","_ref2","_ref3","$color"],"mappings":";;;;AAKA;AACA;AACA;AACO,MAAMA,UAAU,GAAGC,MAAM,CAACC,EAAQ,CAACC,CAAC,CAAmB,CAAA;AAC9D;AACA;AACA;AACA,IAAA,EAAMC,IAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,MAAAA;AAAO,GAAC,GAAAD,IAAA,CAAA;AAAA,EAAA,OAAKE,GAAI,CAAA;AAC1B,0CAA4CD,EAAAA,MAAM,KAAKE,KAAK,CAACC,IAAI,GAAG,OAAO,GAAG,aAAc,CAAA;AAC5F,IAAK,CAAA,CAAA;AAAA,CAAC,CAAA;AACN;AACA;AACA;AACA;AACA;AACA,IAAA,EAAMC,KAAA,IAAA;EAAA,IAAC;AAAEJ,IAAAA,MAAAA;AAAO,GAAC,GAAAI,KAAA,CAAA;AAAA,EAAA,OAAKH,GAAI,CAAA;AAC1B,wCAA0CD,EAAAA,MAAM,KAAKE,KAAK,CAACC,IAAI,GAAG,OAAO,GAAG,aAAc,CAAA;AAC1F,IAAK,CAAA,CAAA;AAAA,CAAC,CAAA;AACN;AACA;AACA;AACA;AACA;AACA,IAAA,EAAME,KAAA,IAAA;EAAA,IAAC;IAAEL,MAAM;AAAEM,IAAAA,MAAAA;AAAO,GAAC,GAAAD,KAAA,CAAA;AAAA,EAAA,OAAKJ,GAAI,CAAA;AAClC,YAAcK,EAAAA,MAAM,KAAK,OAAO,GACtB,SAAS,GACTA,MAAM,KAAK,KAAK,GAChB,SAAS,GACR,CAA8BN,4BAAAA,EAAAA,MAAM,KAAKE,KAAK,CAACC,IAAI,GAAG,OAAO,GAAG,aAAc,CAAG,CAAA,CAAA,CAAA;AAC5F,IAAK,CAAA,CAAA;AAAA,CAAC,CAAA;AACN;AACA;;;;"}
@@ -0,0 +1,89 @@
1
+ import { ComponentProps } from 'react';
2
+ import { ValueOf, Theme } from '@redsift/design-system';
3
+ import { AnyScale, NumericValue, StringValue, ScaleValue, TicksSpec } from '../../types/scale.js';
4
+
5
+ /**
6
+ * Component variant.
7
+ */
8
+ declare const AxisVariant: {
9
+ readonly none: "none";
10
+ readonly line: "line";
11
+ readonly lineTick: "lineTick";
12
+ readonly tick: "tick";
13
+ readonly tickValue: "tickValue";
14
+ readonly default: "default";
15
+ };
16
+ type AxisVariant = ValueOf<typeof AxisVariant>;
17
+ declare const AxisPosition: {
18
+ top: string;
19
+ right: string;
20
+ bottom: string;
21
+ left: string;
22
+ };
23
+ type AxisPosition = ValueOf<typeof AxisPosition>;
24
+ /**
25
+ * Component props.
26
+ */
27
+ interface AxisProps extends Omit<ComponentProps<'g'>, 'scale'> {
28
+ /** Disable animations. */
29
+ disableAnimations?: boolean;
30
+ format?: string;
31
+ /** Whether to display grid or not. The length is mandatory and should usually be the length of the other axis. */
32
+ grid?: boolean | {
33
+ length?: number;
34
+ stroke?: string;
35
+ strokeWidth?: number;
36
+ strokeDasharray?: string;
37
+ opacity?: number;
38
+ };
39
+ legend?: string;
40
+ legendOffset?: number;
41
+ legendPosition?: 'start' | 'middle' | 'end';
42
+ legendX?: number;
43
+ legendY?: number;
44
+ legendRotation?: number;
45
+ legendStyle?: React.CSSProperties;
46
+ /** Length of the axis. */
47
+ length?: number;
48
+ /** Position of axis. top|bottom means this is an x axis, right|left means this is an y axis. */
49
+ position?: AxisPosition;
50
+ /** Scale (d3.js) used to generate the axis. */
51
+ scale?: AnyScale;
52
+ tickFormat?: ((d: NumericValue) => string) | ((d: StringValue) => string) | ((d: Date) => string) | ((d: ScaleValue) => string);
53
+ tickPadding?: number;
54
+ tickRotation?: number;
55
+ tickSize?: number;
56
+ tickValues?: TicksSpec;
57
+ tickRemodelling?: (tickValues: any[]) => any[];
58
+ /** Variant. */
59
+ variant?: AxisVariant;
60
+ /** X position. */
61
+ x?: number;
62
+ /** Y position. */
63
+ y?: number;
64
+ /** Chart width, used for horizontal grid. */
65
+ chartWidth?: number;
66
+ /** Chart height, used for horizontal grid. */
67
+ chartHeight?: number;
68
+ /** Section height, used for horizontal grid within a section. */
69
+ sectionHeight?: number;
70
+ /** Color used for tick values. */
71
+ textColor?: string;
72
+ /** Custom method to choose which tick value to color if not all. */
73
+ tickToColor?: (tick?: {
74
+ textX: number;
75
+ textY: number;
76
+ lineX: number;
77
+ lineY: number;
78
+ x: number;
79
+ y: number;
80
+ key: string;
81
+ value: ScaleValue;
82
+ }, index?: number) => boolean;
83
+ }
84
+ type StyledAxisProps = Omit<AxisProps, 'areXLabelsRotated' | 'size' | 'scale'> & {
85
+ $theme: Theme;
86
+ $color?: string;
87
+ };
88
+
89
+ export { AxisPosition, AxisProps, AxisVariant, StyledAxisProps };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Component variant.
3
+ */
4
+ const AxisVariant = {
5
+ none: 'none',
6
+ line: 'line',
7
+ lineTick: 'lineTick',
8
+ tick: 'tick',
9
+ tickValue: 'tickValue',
10
+ default: 'default'
11
+ };
12
+ const AxisPosition = {
13
+ top: 'top',
14
+ right: 'right',
15
+ bottom: 'bottom',
16
+ left: 'left'
17
+ };
18
+
19
+ /**
20
+ * Component props.
21
+ */
22
+
23
+ export { AxisPosition, AxisVariant };
24
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../src/components/Axis/types.ts"],"sourcesContent":["import { ComponentProps } from 'react';\nimport { ValueOf, Theme } from '@redsift/design-system';\nimport { AnyScale, NumericValue, ScaleValue, StringValue, TicksSpec } from '../../types';\n\n/**\n * Component variant.\n */\nexport const AxisVariant = {\n none: 'none',\n line: 'line',\n lineTick: 'lineTick',\n tick: 'tick',\n tickValue: 'tickValue',\n default: 'default',\n} as const;\nexport type AxisVariant = ValueOf<typeof AxisVariant>;\n\nexport const AxisPosition = {\n top: 'top',\n right: 'right',\n bottom: 'bottom',\n left: 'left',\n};\nexport type AxisPosition = ValueOf<typeof AxisPosition>;\n\n/**\n * Component props.\n */\nexport interface AxisProps extends Omit<ComponentProps<'g'>, 'scale'> {\n /** Disable animations. */\n disableAnimations?: boolean;\n format?: string;\n /** Whether to display grid or not. The length is mandatory and should usually be the length of the other axis. */\n grid?:\n | boolean\n | {\n length?: number;\n stroke?: string;\n strokeWidth?: number;\n strokeDasharray?: string;\n opacity?: number;\n };\n legend?: string;\n legendOffset?: number;\n legendPosition?: 'start' | 'middle' | 'end';\n legendX?: number;\n legendY?: number;\n legendRotation?: number;\n legendStyle?: React.CSSProperties;\n /** Length of the axis. */\n length?: number;\n /** Position of axis. top|bottom means this is an x axis, right|left means this is an y axis. */\n position?: AxisPosition;\n /** Scale (d3.js) used to generate the axis. */\n scale?: AnyScale;\n tickFormat?:\n | ((d: NumericValue) => string)\n | ((d: StringValue) => string)\n | ((d: Date) => string)\n | ((d: ScaleValue) => string);\n tickPadding?: number;\n tickRotation?: number;\n tickSize?: number;\n tickValues?: TicksSpec;\n tickRemodelling?: (tickValues: any[]) => any[];\n /** Variant. */\n variant?: AxisVariant;\n /** X position. */\n x?: number;\n /** Y position. */\n y?: number;\n /** Chart width, used for horizontal grid. */\n chartWidth?: number;\n /** Chart height, used for horizontal grid. */\n chartHeight?: number;\n /** Section height, used for horizontal grid within a section. */\n sectionHeight?: number;\n /** Color used for tick values. */\n textColor?: string;\n /** Custom method to choose which tick value to color if not all. */\n tickToColor?: (\n tick?: {\n textX: number;\n textY: number;\n lineX: number;\n lineY: number;\n x: number;\n y: number;\n key: string;\n value: ScaleValue;\n },\n index?: number\n ) => boolean;\n}\n\nexport type StyledAxisProps = Omit<AxisProps, 'areXLabelsRotated' | 'size' | 'scale'> & {\n $theme: Theme;\n $color?: string;\n};\n"],"names":["AxisVariant","none","line","lineTick","tick","tickValue","default","AxisPosition","top","right","bottom","left"],"mappings":"AAIA;AACA;AACA;AACO,MAAMA,WAAW,GAAG;AACzBC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,QAAQ,EAAE,UAAU;AACpBC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,SAAS,EAAE,WAAW;AACtBC,EAAAA,OAAO,EAAE,SAAA;AACX,EAAU;AAGH,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,IAAI,EAAE,MAAA;AACR,EAAC;;AAGD;AACA;AACA;;;;"}
@@ -0,0 +1,6 @@
1
+ import { Comp } from '@redsift/design-system';
2
+ import { BarProps } from './types.js';
3
+
4
+ declare const Bar: Comp<BarProps, SVGGElement>;
5
+
6
+ export { Bar };