oolib 2.197.0 → 2.197.2

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.
@@ -29,5 +29,8 @@ export interface BarChartProps {
29
29
  summarizeAfterIdx?: number;
30
30
  style?: React.CSSProperties;
31
31
  }
32
+ export declare const FadeGradientWhenScroll: ({ style }: {
33
+ style?: {};
34
+ }) => React.JSX.Element;
32
35
  export declare const BarChart: React.FC<BarChartProps>;
33
36
  export {};
@@ -47,7 +47,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
47
47
  return (mod && mod.__esModule) ? mod : { "default": mod };
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.BarChart = exports.useTrackMousePosition = void 0;
50
+ exports.BarChart = exports.FadeGradientWhenScroll = exports.useTrackMousePosition = void 0;
51
51
  var react_1 = __importStar(require("react"));
52
52
  var recharts_1 = require("recharts");
53
53
  var CustomizedLabel_1 = require("./comps/CustomizedLabel");
@@ -303,6 +303,7 @@ var FadeGradientWhenScroll = function (_a) {
303
303
  var _b = _a.style, style = _b === void 0 ? {} : _b;
304
304
  return (react_1.default.createElement("div", { style: __assign({ width: '100%', height: '40px', position: 'sticky', left: 0, bottom: 0, background: "linear-gradient(to top, ".concat(__1.colors2.white, ", hsla(0, 0%, 100%, 0))") }, style) }));
305
305
  };
306
+ exports.FadeGradientWhenScroll = FadeGradientWhenScroll;
306
307
  var BarChart = function (_a) {
307
308
  var _data = _a.data, valuePath = _a.valuePath, _b = _a.style, style = _b === void 0 ? {} : _b, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, breakdownCategoryName = _a.breakdownCategoryName, // basically, if lets say tagCat1 is broken down by tagCat2. then tagCat2's display would be this property
308
309
  _c = _a.labelPath, // basically, if lets say tagCat1 is broken down by tagCat2. then tagCat2's display would be this property
@@ -334,9 +335,9 @@ var BarChart = function (_a) {
334
335
  isBreakdown: true,
335
336
  breakdownDisplayType: "stacked",
336
337
  showSumOfBreakdownValues: true, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick, mousePosition: mousePosition, dataMaxValue: dataMaxValue, breakdownCategoryName: breakdownCategoryName })),
337
- orientation === 'vertical' && react_1.default.createElement(FadeGradientWhenScroll, null)),
338
+ orientation === 'vertical' && react_1.default.createElement(exports.FadeGradientWhenScroll, null)),
338
339
  isBreakdown && react_1.default.createElement("div", { style: __assign({ position: 'sticky' }, (orientation === 'vertical' ? { top: 0 } : { bottom: 0, background: __1.colors2.white })) },
339
- orientation === 'horizontal' && react_1.default.createElement(FadeGradientWhenScroll, { style: { transform: 'translateY(-100%)', top: 0, bottom: 'unset', position: 'absolute', } }),
340
+ orientation === 'horizontal' && react_1.default.createElement(exports.FadeGradientWhenScroll, { style: { transform: 'translateY(-100%)', top: 0, bottom: 'unset', position: 'absolute', } }),
340
341
  react_1.default.createElement(Legend_1.Legend, { orientation: orientation, label: breakdownCategoryName, data: data[0].map(function (d) { return ({
341
342
  text: d.labels.tooltipLabel,
342
343
  color: d.labels.barColor
@@ -16,7 +16,4 @@ export interface HeatMapGridProps {
16
16
  summarizeAfterIdx?: number;
17
17
  style?: CSSProperties;
18
18
  }
19
- /**
20
- * expects exactly the same data structure as barcharts - breakdown version
21
- */
22
19
  export declare const HeatMapGrid: React.FC<HeatMapGridProps>;
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
2
6
  var __assign = (this && this.__assign) || function () {
3
7
  __assign = Object.assign || function(t) {
4
8
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -49,81 +53,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
49
53
  Object.defineProperty(exports, "__esModule", { value: true });
50
54
  exports.HeatMapGrid = void 0;
51
55
  var react_1 = __importStar(require("react"));
52
- var BarChart_1 = require("../BarChart");
56
+ var styled_components_1 = __importDefault(require("styled-components"));
57
+ var __1 = require("../../../..");
53
58
  var Typo2_1 = require("../../Typo2");
59
+ var BarChart_1 = require("../BarChart");
54
60
  var CustomTooltip_1 = __importDefault(require("../BarChart/comps/CustomTooltip"));
55
61
  var usePrepareData_1 = require("../utils/usePrepareData");
56
- var __1 = require("../../../..");
57
- /**
58
- * Maps a value from an input range to a color
59
- * with the base color at the center point of the range
60
- * @param {number} value - The value to map
61
- * @param {number} minValue - The minimum value in the input range
62
- * @param {number} maxValue - The maximum value in the input range
63
- * @param {Object} hslColor - The base HSL color object
64
- * @param {number} hslColor.h - Hue component (0-360)
65
- * @param {number} hslColor.s - Saturation component (0-100)
66
- * @param {number} hslColor.l - Lightness component (0-100)
67
- * @param {number} minLightness - The minimum lightness (0-100) for darkest shade
68
- * @param {number} maxLightness - The maximum lightness (0-100) for lightest shade
69
- * @return {string} - A hex color code
70
- */
71
- function mapValueToColor(value, minValue, maxValue, hslColor, // Default to #be185d
72
- minLightness, maxLightness) {
73
- if (hslColor === void 0) { hslColor = { h: 336, s: 74, l: 42 }; }
74
- if (minLightness === void 0) { minLightness = 20; }
75
- if (maxLightness === void 0) { maxLightness = 80; }
76
- // Ensure value is within range
77
- value = Math.max(minValue, Math.min(maxValue, value));
78
- // Calculate the center point of the range
79
- var centerPoint = (minValue + maxValue) / 2;
80
- // Extract the hsl components
81
- var h = hslColor.h, s = hslColor.s, baseLightness = hslColor.l;
82
- // Determine lightness based on position relative to center point
83
- var lightness;
84
- if (value < centerPoint) {
85
- // Value is below center (smaller) - scale from maxLightness to baseLightness
86
- var normalizedValue = (value - minValue) / (centerPoint - minValue);
87
- lightness = maxLightness - normalizedValue * (maxLightness - baseLightness);
88
- }
89
- else {
90
- // Value is above center (larger) - scale from baseLightness to minLightness
91
- var normalizedValue = (value - centerPoint) / (maxValue - centerPoint);
92
- lightness = baseLightness - normalizedValue * (baseLightness - minLightness);
93
- }
94
- // Convert HSL back to hex
95
- return "hsl(".concat(h, ", ").concat(s, "%, ").concat(lightness, "%)"); //hslToHex(h, s, lightness);
96
- }
97
- /**
98
- * Convert HSL values to hex color code
99
- * @param {number} h - Hue (0-360)
100
- * @param {number} s - Saturation (0-100)
101
- * @param {number} l - Lightness (0-100)
102
- * @return {string} - Hex color code
103
- */
104
- function hslToHex(h, s, l) {
105
- l /= 100;
106
- var a = (s * Math.min(l, 1 - l)) / 100;
107
- var f = function (n) {
108
- var k = (n + h / 30) % 12;
109
- var color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
110
- return Math.round(255 * color)
111
- .toString(16)
112
- .padStart(2, "0");
113
- };
114
- return "#".concat(f(0)).concat(f(8)).concat(f(4));
115
- }
62
+ var mapValueToColor_1 = require("./utils/mapValueToColor");
63
+ var useAxisMeasure_1 = require("./utils/useAxisMeasure");
64
+ var useFader_1 = require("./utils/useFader");
116
65
  var _configs = {
117
66
  gridGap: 2,
118
67
  cellRoundness: 4,
119
- cellSize: 36,
120
- axisLabelWidth: 200
68
+ cellSize: 40,
69
+ axisLabelWidth: 150
121
70
  };
122
71
  var HeatMapCell = function (_a) {
123
72
  var value = _a.value, dataMaxValue = _a.dataMaxValue, _b = _a.dataMinValue, dataMinValue = _b === void 0 ? 0 : _b, showPercent = _a.showPercent;
124
73
  var mousePosition = (0, BarChart_1.useTrackMousePosition)().mousePosition;
125
74
  var _c = (0, react_1.useState)(false), showTooltip = _c[0], setShowTooltip = _c[1];
126
- var cellColor = mapValueToColor(value.labels.count, dataMinValue, dataMaxValue);
75
+ var cellColor = (0, mapValueToColor_1.mapValueToColor)(value.labels.count, dataMinValue, dataMaxValue);
127
76
  var getCellColorLightness = function () {
128
77
  var splitUp = cellColor.trim().replace('hsl(', '');
129
78
  splitUp = splitUp.replace(')', '');
@@ -131,7 +80,9 @@ var HeatMapCell = function (_a) {
131
80
  var toReturn = parseInt(splitUpAry[2].replace('%', ''));
132
81
  return toReturn;
133
82
  };
134
- var textColor = getCellColorLightness() > 60 ? __1.colors2.black : __1.colors2.white;
83
+ var textColor = value.labels.count === 0
84
+ ? __1.colors2.black
85
+ : getCellColorLightness() > 60 ? __1.colors2.black : __1.colors2.white;
135
86
  return (react_1.default.createElement("div", { onMouseOver: function () { return setShowTooltip(true); }, onMouseOut: function () { return setShowTooltip(false); } },
136
87
  showTooltip && (react_1.default.createElement(CustomTooltip_1.default, { active: true, value: [__assign(__assign({}, value.labels), { tooltipLabel: value.labels.name + ' | ' + value.labels.tooltipLabel //bit of a hack but will sort later
137
88
  })], showPercent: showPercent, mousePosition: mousePosition })),
@@ -144,11 +95,10 @@ var HeatMapCell = function (_a) {
144
95
  justifyContent: 'center',
145
96
  alignItems: 'center'
146
97
  } },
147
- react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: { color: textColor } }, value.labels.count))));
98
+ react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: { color: textColor } }, "".concat(value.labels.count)))));
148
99
  };
149
- /**
150
- * expects exactly the same data structure as barcharts - breakdown version
151
- */
100
+ var STYLED_UI_CAPTION_SEMIBOLD_DF = (0, styled_components_1.default)(Typo2_1.UI_CAPTION_SEMIBOLD_DF)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), (0, __1.clampText)(2));
101
+ var HiddenScrollContainer = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE and Edge */\n \n &::-webkit-scrollbar {\n display: none; /* Webkit browsers */\n }\n"], ["\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE and Edge */\n \n &::-webkit-scrollbar {\n display: none; /* Webkit browsers */\n }\n"])));
152
102
  var HeatMapGrid = function (_a) {
153
103
  var _data = _a.data, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, _b = _a.labelPath, labelPath = _b === void 0 ? "name" : _b, onClick = _a.onClick, _c = _a.showCount, showCount = _c === void 0 ? true : _c, _d = _a.showPercent, showPercent = _d === void 0 ? true : _d, _e = _a.colorIdx, colorIdx = _e === void 0 ? 0 : _e, _f = _a.summarizeAfterIdx, summarizeAfterIdx = _f === void 0 ? 5 : _f, _g = _a.style, style = _g === void 0 ? {} : _g;
154
104
  var _h = (0, usePrepareData_1.usePrepareData)({
@@ -161,76 +111,132 @@ var HeatMapGrid = function (_a) {
161
111
  showPercent: showPercent,
162
112
  summarizeAfterIdx: summarizeAfterIdx,
163
113
  }), data = _h.data, dataMaxValue = _h.dataMaxValue, dataToSummarize = _h.dataToSummarize;
164
- return (react_1.default.createElement("div", { style: __assign({ display: "grid", gridTemplateColumns: "auto 1fr", gap: _configs.gridGap + 'px', overflow: "auto", alignItems: "end" }, style) },
114
+ var scrollableRef = (0, react_1.useRef)(null);
115
+ var _j = (0, useFader_1.useFader)(scrollableRef), setFader = _j.setFader, showFader = _j.showFader, showHorizontalFader = _j.showHorizontalFader;
116
+ // Replace: const { xAxisWidth, yAxisWidth, measurementRef } = useAxisDimensions(data, _configs.axisLabelWidth);
117
+ var _k = (0, useAxisMeasure_1.useAxisMeasure)(_configs.axisLabelWidth), xWidth = _k.xWidth, yWidth = _k.yWidth, setHorizontalRef = _k.setHorizontalRef, setVerticalRef = _k.setVerticalRef;
118
+ console.log({ xWidth: xWidth, yWidth: yWidth });
119
+ return (react_1.default.createElement("div", { style: __assign({ position: 'relative' }, style) },
165
120
  react_1.default.createElement("div", { style: {
166
- display: "flex",
167
- flexDirection: "column",
168
- gap: _configs.gridGap + "px",
121
+ display: "grid",
122
+ gridTemplateColumns: "".concat(yWidth, "px 1fr"),
123
+ gridTemplateRows: "".concat(xWidth, "px 1fr"),
124
+ gap: _configs.gridGap + 'px',
125
+ height: '100%',
169
126
  } },
170
- react_1.default.createElement("div", { style: { height: _configs.axisLabelWidth + "px" } }),
171
- data.map(function (d) { return (react_1.default.createElement("div", { style: {
127
+ react_1.default.createElement("div", { style: { gridRow: 1, gridColumn: 1 } }),
128
+ react_1.default.createElement(HiddenScrollContainer, { style: {
129
+ gridRow: 1,
130
+ gridColumn: 2,
131
+ overflowX: 'auto',
132
+ overflowY: 'hidden',
133
+ display: 'flex',
134
+ alignItems: 'flex-end',
135
+ }, onScroll: function (e) {
136
+ // Sync horizontal scroll with main content area
137
+ if (scrollableRef.current) {
138
+ scrollableRef.current.scrollLeft = e.target.scrollLeft;
139
+ }
140
+ } },
141
+ react_1.default.createElement("div", { style: {
142
+ display: "flex",
143
+ alignItems: "center",
144
+ gap: _configs.gridGap + "px",
145
+ minWidth: 'max-content',
146
+ } }, data[0].map(function (dd, index) { return (react_1.default.createElement("div", { key: dd.labels.tooltipLabel, style: {
147
+ width: _configs.cellSize + "px",
148
+ height: xWidth + "px",
149
+ display: "flex",
150
+ alignItems: "flex-end",
151
+ textWrap: "nowrap",
152
+ justifyContent: 'center',
153
+ position: "relative",
154
+ overflow: "visible",
155
+ flexShrink: 0,
156
+ } },
157
+ react_1.default.createElement("div", { style: {
158
+ width: xWidth + "px",
159
+ position: "absolute",
160
+ bottom: 0,
161
+ left: '50%',
162
+ transformOrigin: "left bottom",
163
+ transform: "rotate(-90deg) translateY(50%)",
164
+ display: 'flex'
165
+ } },
166
+ react_1.default.createElement("div", { ref: function (el) { return setHorizontalRef(index, el); } },
167
+ react_1.default.createElement(STYLED_UI_CAPTION_SEMIBOLD_DF, { style: {
168
+ whiteSpace: "normal",
169
+ } }, dd.labels.tooltipLabel))))); }))),
170
+ react_1.default.createElement(HiddenScrollContainer, { style: {
171
+ gridRow: 2,
172
+ gridColumn: 1,
173
+ overflowY: 'auto',
174
+ overflowX: 'hidden',
175
+ display: 'flex',
176
+ flexDirection: 'column',
177
+ gap: _configs.gridGap + "px",
178
+ }, onScroll: function (e) {
179
+ // Sync vertical scroll with main content area
180
+ if (scrollableRef.current) {
181
+ scrollableRef.current.scrollTop = e.target.scrollTop;
182
+ }
183
+ } }, data.map(function (d, idx) { return (react_1.default.createElement("div", { key: idx, style: {
172
184
  height: _configs.cellSize + "px",
173
185
  textAlign: "right",
174
186
  display: "flex",
175
187
  alignItems: "center",
176
188
  justifyContent: "flex-end",
177
- } },
178
- react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: {
179
- width: "fit-content",
180
- maxWidth: _configs.axisLabelWidth + "px",
181
- height: "2.4em",
182
- lineHeight: "1.2em",
183
- overflow: "hidden",
184
- wordBreak: "break-word",
185
- } }, d[0].labels.name.length > 50 ? d[0].labels.name.substring(0, 50) + "..." : d[0].labels.name))); })),
186
- react_1.default.createElement("div", { style: {
187
- display: "flex",
188
- flexDirection: "column",
189
- gap: _configs.gridGap + "px",
190
- overflowX: "auto",
191
- } },
192
- react_1.default.createElement("div", { style: {
193
- display: "flex",
194
- alignItems: "center",
195
- gap: _configs.gridGap + "px",
196
- } }, data[0].map(function (dd) { return (react_1.default.createElement("div", { style: {
197
- width: _configs.cellSize + "px",
198
- height: _configs.axisLabelWidth + "px",
199
- display: "flex",
200
- alignItems: "flex-end",
201
- textWrap: "nowrap",
202
- justifyContent: 'center',
203
- position: "relative",
204
- overflow: "visible",
205
189
  flexShrink: 0,
206
190
  } },
207
- react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: {
208
- width: _configs.axisLabelWidth + "px",
209
- height: "32px",
210
- position: "absolute",
211
- bottom: '-16px',
212
- left: (_configs.cellSize / 2) + 'px',
213
- transformOrigin: "left center",
214
- transform: "rotate(-90deg)",
215
- // Multi-line
216
- whiteSpace: "normal",
217
- overflow: "hidden",
218
- display: "-webkit-box",
219
- WebkitBoxOrient: "vertical",
220
- WebkitLineClamp: 2,
221
- textOverflow: "ellipsis",
222
- lineHeight: "16px",
223
- } }, dd.labels.tooltipLabel))); })),
224
- data.map(function (d) { return (react_1.default.createElement("div", { style: {
225
- display: "flex",
226
- alignItems: "center",
227
- gap: _configs.gridGap + "px",
228
- // flexShrink: 0,
229
- } }, d.map(function (dd) {
230
- // console.log({
231
- // color: mapValueToColor(dd.labels.count, 0, dataMaxValue),
232
- // });
233
- return react_1.default.createElement(HeatMapCell, { showPercent: false, dataMaxValue: dataMaxValue, value: dd });
234
- }))); }))));
191
+ react_1.default.createElement("div", { ref: function (el) { return setVerticalRef(idx, el); } },
192
+ react_1.default.createElement(STYLED_UI_CAPTION_SEMIBOLD_DF, { style: {
193
+ maxWidth: yWidth + "px",
194
+ } }, d[0].labels.name.length > 50 ? d[0].labels.name.substring(0, 50) + "..." : d[0].labels.name)))); })),
195
+ react_1.default.createElement("div", { ref: scrollableRef, style: {
196
+ gridRow: 2,
197
+ gridColumn: 2,
198
+ overflow: 'auto',
199
+ position: 'relative',
200
+ }, onScroll: function (e) {
201
+ // Sync scrolling with headers
202
+ var topHeader = e.target.parentElement.children[1]; // Top-right header
203
+ var leftHeader = e.target.parentElement.children[2]; // Bottom-left header
204
+ if (topHeader)
205
+ topHeader.scrollLeft = e.target.scrollLeft;
206
+ if (leftHeader)
207
+ leftHeader.scrollTop = e.target.scrollTop;
208
+ // Update fader visibility on scroll
209
+ setFader();
210
+ } },
211
+ react_1.default.createElement("div", { style: {
212
+ display: "flex",
213
+ flexDirection: "column",
214
+ gap: _configs.gridGap + "px",
215
+ minWidth: 'max-content',
216
+ } }, data.map(function (d, rowIdx) { return (react_1.default.createElement("div", { key: rowIdx, style: {
217
+ display: "flex",
218
+ alignItems: "center",
219
+ gap: _configs.gridGap + "px",
220
+ flexShrink: 0,
221
+ } }, d.map(function (dd, colIdx) {
222
+ return react_1.default.createElement(HeatMapCell, { key: "".concat(rowIdx, "-").concat(colIdx), showPercent: false, dataMaxValue: dataMaxValue, value: dd });
223
+ }))); })))),
224
+ showFader && react_1.default.createElement("div", { style: {
225
+ background: "linear-gradient(to top, ".concat(__1.colors2.white, ", hsla(0, 0%, 100%, 0))"),
226
+ position: 'absolute',
227
+ bottom: 0,
228
+ left: 0,
229
+ width: '100%',
230
+ height: '40px'
231
+ } }),
232
+ showHorizontalFader && react_1.default.createElement("div", { style: {
233
+ background: "linear-gradient(to left, ".concat(__1.colors2.white, ", hsla(0, 0%, 100%, 0))"),
234
+ position: 'absolute',
235
+ top: 0,
236
+ right: 0,
237
+ height: '100%',
238
+ width: '40px'
239
+ } })));
235
240
  };
236
241
  exports.HeatMapGrid = HeatMapGrid;
242
+ var templateObject_1, templateObject_2;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Maps a value from an input range to a color
3
+ * with the base color at the center point of the range
4
+ * @param {number} value - The value to map
5
+ * @param {number} minValue - The minimum value in the input range
6
+ * @param {number} maxValue - The maximum value in the input range
7
+ * @param {Object} hslColor - The base HSL color object
8
+ * @param {number} hslColor.h - Hue component (0-360)
9
+ * @param {number} hslColor.s - Saturation component (0-100)
10
+ * @param {number} hslColor.l - Lightness component (0-100)
11
+ * @param {number} minLightness - The minimum lightness (0-100) for darkest shade
12
+ * @param {number} maxLightness - The maximum lightness (0-100) for lightest shade
13
+ * @return {string} - A hex color code
14
+ */
15
+ export declare function mapValueToColor(value: any, minValue: any, maxValue: any, hslColor?: {
16
+ h: number;
17
+ s: number;
18
+ l: number;
19
+ }, // Default to #be185d
20
+ minLightness?: number, maxLightness?: number): string;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapValueToColor = mapValueToColor;
4
+ var __1 = require("../../../../..");
5
+ /**
6
+ * Maps a value from an input range to a color
7
+ * with the base color at the center point of the range
8
+ * @param {number} value - The value to map
9
+ * @param {number} minValue - The minimum value in the input range
10
+ * @param {number} maxValue - The maximum value in the input range
11
+ * @param {Object} hslColor - The base HSL color object
12
+ * @param {number} hslColor.h - Hue component (0-360)
13
+ * @param {number} hslColor.s - Saturation component (0-100)
14
+ * @param {number} hslColor.l - Lightness component (0-100)
15
+ * @param {number} minLightness - The minimum lightness (0-100) for darkest shade
16
+ * @param {number} maxLightness - The maximum lightness (0-100) for lightest shade
17
+ * @return {string} - A hex color code
18
+ */
19
+ function mapValueToColor(value, minValue, maxValue, hslColor, // Default to #be185d
20
+ minLightness, maxLightness) {
21
+ if (hslColor === void 0) { hslColor = { h: 336, s: 74, l: 42 }; }
22
+ if (minLightness === void 0) { minLightness = 20; }
23
+ if (maxLightness === void 0) { maxLightness = 80; }
24
+ // Ensure value is within range
25
+ value = Math.max(minValue, Math.min(maxValue, value));
26
+ if (value === 0)
27
+ return __1.colors2.grey10;
28
+ // Calculate the center point of the range
29
+ var centerPoint = (minValue + maxValue) / 2;
30
+ // Extract the hsl components
31
+ var h = hslColor.h, s = hslColor.s, baseLightness = hslColor.l;
32
+ // Determine lightness based on position relative to center point
33
+ var lightness;
34
+ if (value < centerPoint) {
35
+ // Value is below center (smaller) - scale from maxLightness to baseLightness
36
+ var normalizedValue = (value - minValue) / (centerPoint - minValue);
37
+ lightness = maxLightness - normalizedValue * (maxLightness - baseLightness);
38
+ }
39
+ else {
40
+ // Value is above center (larger) - scale from baseLightness to minLightness
41
+ var normalizedValue = (value - centerPoint) / (maxValue - centerPoint);
42
+ lightness = baseLightness - normalizedValue * (baseLightness - minLightness);
43
+ }
44
+ return "hsl(".concat(h, ", ").concat(s, "%, ").concat(lightness, "%)");
45
+ }
@@ -0,0 +1,6 @@
1
+ export declare const useAxisMeasure: (defaultAxisLabelWidth: number) => {
2
+ xWidth: number;
3
+ yWidth: number;
4
+ setHorizontalRef: (index: number, el: HTMLDivElement | null) => void;
5
+ setVerticalRef: (index: number, el: HTMLDivElement | null) => void;
6
+ };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAxisMeasure = void 0;
4
+ var react_1 = require("react");
5
+ var useAxisMeasure = function (defaultAxisLabelWidth) {
6
+ var _a = (0, react_1.useState)(defaultAxisLabelWidth), xWidth = _a[0], setXWidth = _a[1];
7
+ var _b = (0, react_1.useState)(defaultAxisLabelWidth), yWidth = _b[0], setYWidth = _b[1];
8
+ var horizontalRefs = (0, react_1.useRef)([]);
9
+ var verticalRefs = (0, react_1.useRef)([]);
10
+ // Functions to set refs
11
+ var setHorizontalRef = function (index, el) {
12
+ console.log({ horEL: el });
13
+ horizontalRefs.current[index] = el;
14
+ };
15
+ var setVerticalRef = function (index, el) {
16
+ console.log({ verEL: el });
17
+ verticalRefs.current[index] = el;
18
+ };
19
+ console.log({ horizontalRefs: horizontalRefs, verticalRefs: verticalRefs });
20
+ (0, react_1.useEffect)(function () {
21
+ // Measure horizontal labels
22
+ var maxHorizontalWidth = 0;
23
+ horizontalRefs.current.forEach(function (ref) {
24
+ console.log({ ref: ref });
25
+ if (ref) {
26
+ var width = ref.offsetWidth;
27
+ maxHorizontalWidth = Math.max(maxHorizontalWidth, width);
28
+ }
29
+ });
30
+ // Measure vertical labels
31
+ var maxVerticalWidth = 0;
32
+ verticalRefs.current.forEach(function (ref) {
33
+ if (ref) {
34
+ var width = ref.offsetWidth;
35
+ maxVerticalWidth = Math.max(maxVerticalWidth, width);
36
+ }
37
+ });
38
+ // Update state if measured width is less than config
39
+ if (maxHorizontalWidth > 0 && maxHorizontalWidth < defaultAxisLabelWidth) {
40
+ setXWidth(maxHorizontalWidth + 10); // +10 for padding
41
+ }
42
+ if (maxVerticalWidth > 0 && maxVerticalWidth < defaultAxisLabelWidth) {
43
+ setYWidth(maxVerticalWidth + 10); // +10 for padding
44
+ }
45
+ }, []);
46
+ return {
47
+ xWidth: xWidth,
48
+ yWidth: yWidth,
49
+ setHorizontalRef: setHorizontalRef,
50
+ setVerticalRef: setVerticalRef
51
+ };
52
+ };
53
+ exports.useAxisMeasure = useAxisMeasure;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ export declare const useFader: (scrollableRef: React.RefObject<HTMLDivElement>) => {
3
+ showFader: boolean;
4
+ showHorizontalFader: boolean;
5
+ setFader: () => void;
6
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFader = void 0;
4
+ var react_1 = require("react");
5
+ var __1 = require("../../../../..");
6
+ var useFader = function (scrollableRef) {
7
+ var _a = (0, react_1.useState)(false), showFader = _a[0], setShowFader = _a[1];
8
+ var _b = (0, react_1.useState)(false), showHorizontalFader = _b[0], setShowHorizontalFader = _b[1];
9
+ var setFader = function () {
10
+ if (scrollableRef.current) {
11
+ var _a = scrollableRef.current, scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight, scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
12
+ // Vertical fader logic
13
+ var hasMoreContentToScrollDown = scrollTop + clientHeight < scrollHeight - 5;
14
+ if (hasMoreContentToScrollDown && !showFader) {
15
+ setShowFader(true);
16
+ }
17
+ else if (!hasMoreContentToScrollDown && showFader) {
18
+ setShowFader(false);
19
+ }
20
+ // Horizontal fader logic
21
+ var hasMoreContentToScrollRight = scrollLeft + clientWidth < scrollWidth - 5;
22
+ if (hasMoreContentToScrollRight && !showHorizontalFader) {
23
+ setShowHorizontalFader(true);
24
+ }
25
+ else if (!hasMoreContentToScrollRight && showHorizontalFader) {
26
+ setShowHorizontalFader(false);
27
+ }
28
+ }
29
+ };
30
+ (0, react_1.useEffect)(function () {
31
+ setFader();
32
+ }, []);
33
+ (0, __1.useScroll)(setFader);
34
+ return { showFader: showFader, showHorizontalFader: showHorizontalFader, setFader: setFader };
35
+ };
36
+ exports.useFader = useFader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.197.0",
3
+ "version": "2.197.2",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",