oolib 2.197.1 → 2.197.3

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.
@@ -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>;
@@ -53,71 +53,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.HeatMapGrid = void 0;
55
55
  var react_1 = __importStar(require("react"));
56
- var BarChart_1 = require("../BarChart");
56
+ var styled_components_1 = __importDefault(require("styled-components"));
57
+ var __1 = require("../../../..");
57
58
  var Typo2_1 = require("../../Typo2");
59
+ var BarChart_1 = require("../BarChart");
58
60
  var CustomTooltip_1 = __importDefault(require("../BarChart/comps/CustomTooltip"));
59
61
  var usePrepareData_1 = require("../utils/usePrepareData");
60
- var __1 = require("../../../..");
61
- var styled_components_1 = __importDefault(require("styled-components"));
62
- /**
63
- * Maps a value from an input range to a color
64
- * with the base color at the center point of the range
65
- * @param {number} value - The value to map
66
- * @param {number} minValue - The minimum value in the input range
67
- * @param {number} maxValue - The maximum value in the input range
68
- * @param {Object} hslColor - The base HSL color object
69
- * @param {number} hslColor.h - Hue component (0-360)
70
- * @param {number} hslColor.s - Saturation component (0-100)
71
- * @param {number} hslColor.l - Lightness component (0-100)
72
- * @param {number} minLightness - The minimum lightness (0-100) for darkest shade
73
- * @param {number} maxLightness - The maximum lightness (0-100) for lightest shade
74
- * @return {string} - A hex color code
75
- */
76
- function mapValueToColor(value, minValue, maxValue, hslColor, // Default to #be185d
77
- minLightness, maxLightness) {
78
- if (hslColor === void 0) { hslColor = { h: 336, s: 74, l: 42 }; }
79
- if (minLightness === void 0) { minLightness = 20; }
80
- if (maxLightness === void 0) { maxLightness = 80; }
81
- // Ensure value is within range
82
- value = Math.max(minValue, Math.min(maxValue, value));
83
- // Calculate the center point of the range
84
- var centerPoint = (minValue + maxValue) / 2;
85
- // Extract the hsl components
86
- var h = hslColor.h, s = hslColor.s, baseLightness = hslColor.l;
87
- // Determine lightness based on position relative to center point
88
- var lightness;
89
- if (value < centerPoint) {
90
- // Value is below center (smaller) - scale from maxLightness to baseLightness
91
- var normalizedValue = (value - minValue) / (centerPoint - minValue);
92
- lightness = maxLightness - normalizedValue * (maxLightness - baseLightness);
93
- }
94
- else {
95
- // Value is above center (larger) - scale from baseLightness to minLightness
96
- var normalizedValue = (value - centerPoint) / (maxValue - centerPoint);
97
- lightness = baseLightness - normalizedValue * (baseLightness - minLightness);
98
- }
99
- // Convert HSL back to hex
100
- return "hsl(".concat(h, ", ").concat(s, "%, ").concat(lightness, "%)"); //hslToHex(h, s, lightness);
101
- }
102
- /**
103
- * Convert HSL values to hex color code
104
- * @param {number} h - Hue (0-360)
105
- * @param {number} s - Saturation (0-100)
106
- * @param {number} l - Lightness (0-100)
107
- * @return {string} - Hex color code
108
- */
109
- function hslToHex(h, s, l) {
110
- l /= 100;
111
- var a = (s * Math.min(l, 1 - l)) / 100;
112
- var f = function (n) {
113
- var k = (n + h / 30) % 12;
114
- var color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
115
- return Math.round(255 * color)
116
- .toString(16)
117
- .padStart(2, "0");
118
- };
119
- return "#".concat(f(0)).concat(f(8)).concat(f(4));
120
- }
62
+ var mapValueToColor_1 = require("./utils/mapValueToColor");
63
+ var useAxisMeasure_1 = require("./utils/useAxisMeasure");
64
+ var useFader_1 = require("./utils/useFader");
121
65
  var _configs = {
122
66
  gridGap: 2,
123
67
  cellRoundness: 4,
@@ -128,7 +72,7 @@ var HeatMapCell = function (_a) {
128
72
  var value = _a.value, dataMaxValue = _a.dataMaxValue, _b = _a.dataMinValue, dataMinValue = _b === void 0 ? 0 : _b, showPercent = _a.showPercent;
129
73
  var mousePosition = (0, BarChart_1.useTrackMousePosition)().mousePosition;
130
74
  var _c = (0, react_1.useState)(false), showTooltip = _c[0], setShowTooltip = _c[1];
131
- var cellColor = mapValueToColor(value.labels.count, dataMinValue, dataMaxValue);
75
+ var cellColor = (0, mapValueToColor_1.mapValueToColor)(value.labels.count, dataMinValue, dataMaxValue);
132
76
  var getCellColorLightness = function () {
133
77
  var splitUp = cellColor.trim().replace('hsl(', '');
134
78
  splitUp = splitUp.replace(')', '');
@@ -136,7 +80,9 @@ var HeatMapCell = function (_a) {
136
80
  var toReturn = parseInt(splitUpAry[2].replace('%', ''));
137
81
  return toReturn;
138
82
  };
139
- 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;
140
86
  return (react_1.default.createElement("div", { onMouseOver: function () { return setShowTooltip(true); }, onMouseOut: function () { return setShowTooltip(false); } },
141
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
142
88
  })], showPercent: showPercent, mousePosition: mousePosition })),
@@ -149,16 +95,10 @@ var HeatMapCell = function (_a) {
149
95
  justifyContent: 'center',
150
96
  alignItems: 'center'
151
97
  } },
152
- 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)))));
153
99
  };
154
- 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 ", "\n\n"
155
- /**
156
- * expects exactly the same data structure as barcharts - breakdown version
157
- */
158
- ])), (0, __1.clampText)(2));
159
- /**
160
- * expects exactly the same data structure as barcharts - breakdown version
161
- */
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"])));
162
102
  var HeatMapGrid = function (_a) {
163
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;
164
104
  var _h = (0, usePrepareData_1.usePrepareData)({
@@ -171,105 +111,124 @@ var HeatMapGrid = function (_a) {
171
111
  showPercent: showPercent,
172
112
  summarizeAfterIdx: summarizeAfterIdx,
173
113
  }), data = _h.data, dataMaxValue = _h.dataMaxValue, dataToSummarize = _h.dataToSummarize;
174
- var vizRef = (0, react_1.useRef)(null);
175
- var wrapperRef = (0, react_1.useRef)(null);
176
- var setFader = function () {
177
- var _a, _b, _c, _d;
178
- if (vizRef.current && wrapperRef.current && ((_b = (_a = vizRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.bottom) > ((_d = (_c = wrapperRef.current) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect()) === null || _d === void 0 ? void 0 : _d.bottom)) {
179
- if (!showFader) {
180
- setShowFader(true);
181
- }
182
- }
183
- else {
184
- setShowFader(false);
185
- }
186
- };
187
- var _j = (0, react_1.useState)(false), showFader = _j[0], setShowFader = _j[1];
188
- (0, react_1.useEffect)(function () {
189
- setFader();
190
- }, []);
191
- (0, __1.useScroll)(setFader);
192
- return (react_1.default.createElement("div", { ref: wrapperRef, style: __assign({ position: 'relative' }, style) },
193
- react_1.default.createElement("div", { style: {
194
- position: 'relative',
195
- display: "grid",
196
- gridTemplateColumns: "auto 1fr",
197
- gap: _configs.gridGap + 'px',
198
- overflow: "auto",
199
- alignItems: "end",
200
- height: '100%'
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
+ return (react_1.default.createElement("div", { style: __assign({ display: "grid", gridTemplateColumns: "".concat(yWidth, "px 1fr"), gridTemplateRows: "".concat(xWidth, "px 1fr"), gap: _configs.gridGap + 'px', height: '100%', position: 'relative' }, style) },
119
+ react_1.default.createElement("div", { style: { gridRow: 1, gridColumn: 1 } }),
120
+ react_1.default.createElement(HiddenScrollContainer, { style: {
121
+ gridRow: 1,
122
+ gridColumn: 2,
123
+ overflowX: 'auto',
124
+ overflowY: 'hidden',
125
+ display: 'flex',
126
+ alignItems: 'flex-end',
127
+ }, onScroll: function (e) {
128
+ // Sync horizontal scroll with main content area
129
+ if (scrollableRef.current) {
130
+ scrollableRef.current.scrollLeft = e.target.scrollLeft;
131
+ }
201
132
  } },
202
133
  react_1.default.createElement("div", { style: {
203
134
  display: "flex",
204
- flexDirection: "column",
135
+ alignItems: "center",
205
136
  gap: _configs.gridGap + "px",
137
+ minWidth: 'max-content',
138
+ } }, data[0].map(function (dd, index) { return (react_1.default.createElement("div", { key: dd.labels.tooltipLabel, style: {
139
+ width: _configs.cellSize + "px",
140
+ height: xWidth + "px",
141
+ display: "flex",
142
+ alignItems: "flex-end",
143
+ textWrap: "nowrap",
144
+ justifyContent: 'center',
145
+ position: "relative",
146
+ overflow: "visible",
147
+ flexShrink: 0,
206
148
  } },
207
- react_1.default.createElement("div", { style: { height: _configs.axisLabelWidth + "px" } }),
208
- data.map(function (d) { return (react_1.default.createElement("div", { style: {
209
- height: _configs.cellSize + "px",
210
- textAlign: "right",
211
- display: "flex",
212
- alignItems: "center",
213
- justifyContent: "flex-end",
149
+ react_1.default.createElement("div", { style: {
150
+ width: xWidth + "px",
151
+ position: "absolute",
152
+ bottom: 0,
153
+ left: '50%',
154
+ transformOrigin: "left bottom",
155
+ transform: "rotate(-90deg) translateY(50%)",
156
+ display: 'flex'
214
157
  } },
215
- react_1.default.createElement(STYLED_UI_CAPTION_SEMIBOLD_DF, { style: {
216
- // width: "fit-content",
217
- maxWidth: _configs.axisLabelWidth + "px",
218
- // maxHeight: "2.4em",
219
- // lineHeight: "1.2em",
220
- // overflow: "hidden",
221
- // wordBreak: "break-word",
222
- } }, d[0].labels.name.length > 50 ? d[0].labels.name.substring(0, 50) + "..." : d[0].labels.name))); })),
223
- react_1.default.createElement("div", { ref: vizRef, style: {
158
+ react_1.default.createElement("div", { ref: function (el) { return setHorizontalRef(index, el); } },
159
+ react_1.default.createElement(STYLED_UI_CAPTION_SEMIBOLD_DF, { style: {
160
+ whiteSpace: "normal",
161
+ } }, dd.labels.tooltipLabel))))); }))),
162
+ react_1.default.createElement(HiddenScrollContainer, { style: {
163
+ gridRow: 2,
164
+ gridColumn: 1,
165
+ overflowY: 'auto',
166
+ overflowX: 'hidden',
167
+ display: 'flex',
168
+ flexDirection: 'column',
169
+ gap: _configs.gridGap + "px",
170
+ }, onScroll: function (e) {
171
+ // Sync vertical scroll with main content area
172
+ if (scrollableRef.current) {
173
+ scrollableRef.current.scrollTop = e.target.scrollTop;
174
+ }
175
+ } }, data.map(function (d, idx) { return (react_1.default.createElement("div", { key: idx, style: {
176
+ height: _configs.cellSize + "px",
177
+ textAlign: "right",
178
+ display: "flex",
179
+ alignItems: "center",
180
+ justifyContent: "flex-end",
181
+ flexShrink: 0,
182
+ } },
183
+ react_1.default.createElement("div", { ref: function (el) { return setVerticalRef(idx, el); } },
184
+ react_1.default.createElement(STYLED_UI_CAPTION_SEMIBOLD_DF, { style: {
185
+ maxWidth: yWidth + "px",
186
+ } }, d[0].labels.name.length > 50 ? d[0].labels.name.substring(0, 50) + "..." : d[0].labels.name)))); })),
187
+ react_1.default.createElement("div", { ref: scrollableRef, style: {
188
+ gridRow: 2,
189
+ gridColumn: 2,
190
+ overflow: 'auto',
191
+ position: 'relative',
192
+ }, onScroll: function (e) {
193
+ // Sync scrolling with headers
194
+ var topHeader = e.target.parentElement.children[1]; // Top-right header
195
+ var leftHeader = e.target.parentElement.children[2]; // Bottom-left header
196
+ if (topHeader)
197
+ topHeader.scrollLeft = e.target.scrollLeft;
198
+ if (leftHeader)
199
+ leftHeader.scrollTop = e.target.scrollTop;
200
+ // Update fader visibility on scroll
201
+ setFader();
202
+ } },
203
+ react_1.default.createElement("div", { style: {
224
204
  display: "flex",
225
205
  flexDirection: "column",
226
206
  gap: _configs.gridGap + "px",
227
- overflowX: "auto", //horizontal scroll
228
- position: 'relative'
229
- } },
230
- react_1.default.createElement("div", { style: {
231
- display: "flex",
232
- alignItems: "center",
233
- gap: _configs.gridGap + "px",
234
- } }, data[0].map(function (dd) { return (react_1.default.createElement("div", { style: {
235
- width: _configs.cellSize + "px",
236
- height: _configs.axisLabelWidth + "px",
237
- display: "flex",
238
- alignItems: "flex-end",
239
- textWrap: "nowrap",
240
- justifyContent: 'center',
241
- position: "relative",
242
- overflow: "visible",
243
- flexShrink: 0,
244
- } },
245
- react_1.default.createElement(STYLED_UI_CAPTION_SEMIBOLD_DF, { style: {
246
- width: _configs.axisLabelWidth + "px",
247
- position: "absolute", // Add this
248
- bottom: 0, // which is half of the line height of the current text
249
- left: '50%', // Center horizontally
250
- transformOrigin: "left bottom", // Change origin to bottom
251
- transform: "rotate(-90deg) translateY(50%)", // Adjust transform
252
- // Multi-line
253
- whiteSpace: "normal",
254
- // overflow: "hidden",
255
- // display: "-webkit-box",
256
- // WebkitBoxOrient: "vertical",
257
- // WebkitLineClamp: 2,
258
- // textOverflow: "ellipsis",
259
- // lineHeight: "16px",
260
- } }, dd.labels.tooltipLabel))); })),
261
- data.map(function (d) { return (react_1.default.createElement("div", { style: {
262
- display: "flex",
263
- alignItems: "center",
264
- gap: _configs.gridGap + "px",
265
- // flexShrink: 0,
266
- } }, d.map(function (dd) {
267
- // console.log({
268
- // color: mapValueToColor(dd.labels.count, 0, dataMaxValue),
269
- // });
270
- return react_1.default.createElement(HeatMapCell, { showPercent: false, dataMaxValue: dataMaxValue, value: dd });
271
- }))); }))),
272
- showFader && react_1.default.createElement(BarChart_1.FadeGradientWhenScroll, { style: { position: 'absolute', bottom: 0, left: 0 } })));
207
+ minWidth: 'max-content',
208
+ } }, data.map(function (d, rowIdx) { return (react_1.default.createElement("div", { key: rowIdx, style: {
209
+ display: "flex",
210
+ alignItems: "center",
211
+ gap: _configs.gridGap + "px",
212
+ flexShrink: 0,
213
+ } }, d.map(function (dd, colIdx) {
214
+ return react_1.default.createElement(HeatMapCell, { key: "".concat(rowIdx, "-").concat(colIdx), showPercent: false, dataMaxValue: dataMaxValue, value: dd });
215
+ }))); }))),
216
+ showFader && react_1.default.createElement("div", { style: {
217
+ background: "linear-gradient(to top, ".concat(__1.colors2.white, ", hsla(0, 0%, 100%, 0))"),
218
+ position: 'absolute',
219
+ bottom: 0,
220
+ left: 0,
221
+ width: '100%',
222
+ height: '40px'
223
+ } }),
224
+ showHorizontalFader && react_1.default.createElement("div", { style: {
225
+ background: "linear-gradient(to left, ".concat(__1.colors2.white, ", hsla(0, 0%, 100%, 0))"),
226
+ position: 'absolute',
227
+ top: 0,
228
+ right: 0,
229
+ height: '100%',
230
+ width: '40px'
231
+ } })));
273
232
  };
274
233
  exports.HeatMapGrid = HeatMapGrid;
275
- var templateObject_1;
234
+ 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.1",
3
+ "version": "2.197.3",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",