oolib 2.196.0 → 2.197.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.
@@ -21,7 +21,7 @@ var Typo2_1 = require("../../../../Typo2");
21
21
  var LegendTooltipGlyph_1 = require("../LegendTooltipGlyph");
22
22
  var Legend = function (_a) {
23
23
  var data = _a.data, label = _a.label, _b = _a.orientation, orientation = _b === void 0 ? "vertical" : _b;
24
- return (react_1.default.createElement("div", { style: __assign(__assign({}, (orientation === 'vertical' ? { maxWidth: '200px' } : {})), { padding: "12px", borderRadius: '8px', border: "1px solid ".concat(__1.colors2.grey5), background: "linear-gradient(to bottom, hsla(0, 0%, 96%, 1), hsla(0, 0%, 100%, 0))", maxHeight: orientation === 'vertical' ? '100%' : '150px', overflow: 'scroll' }) },
24
+ return (react_1.default.createElement("div", { style: __assign(__assign({}, (orientation === 'vertical' ? { maxWidth: '200px' } : {})), { padding: "12px", borderRadius: '8px', border: "1px solid ".concat(__1.colors2.grey5), background: "linear-gradient(to bottom, hsla(0, 0%, 96%, 1), hsla(0, 0%, 100%, 0))", maxHeight: orientation === 'vertical' ? '100%' : '150px', overflow: 'auto' }) },
25
25
  label && orientation === 'vertical' && (react_1.default.createElement("div", { style: { paddingBottom: "8px" } },
26
26
  react_1.default.createElement(Typo2_1.UI_CAPTION_BOLD_DF, null, label))),
27
27
  react_1.default.createElement("div", { style: __assign(__assign({ display: "flex", flexDirection: orientation === "vertical" ? "column" : "row" }, (orientation === 'horizontal' ? { flexWrap: 'wrap' } : {})), { gap: "8px" }) },
@@ -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
@@ -327,16 +328,16 @@ var BarChart = function (_a) {
327
328
  // menu options for grouped and stacked
328
329
  if (data.length === 0)
329
330
  return react_1.default.createElement("div", null, "No data available");
330
- return (react_1.default.createElement("div", { ref: vizWrapperRef, style: __assign(__assign({}, style), { width: "100%", background: _debug_controls.chartWrapperBgColor, display: 'flex', gap: '8px', flexDirection: orientation === 'vertical' ? 'row' : 'column', position: 'relative', overflow: 'scroll' }) },
331
+ return (react_1.default.createElement("div", { ref: vizWrapperRef, style: __assign(__assign({}, style), { width: "100%", background: _debug_controls.chartWrapperBgColor, display: 'flex', gap: '8px', flexDirection: orientation === 'vertical' ? 'row' : 'column', position: 'relative', overflow: 'auto' }) },
331
332
  react_1.default.createElement("div", { style: { flexGrow: 1, position: 'relative' } },
332
333
  react_1.default.createElement(BarChartRenderer, { data: data, dataToSummarize: dataToSummarize, isBreakdown: isBreakdown, breakdownDisplayType: breakdownDisplayType, showSumOfBreakdownValues: false, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick, mousePosition: mousePosition, dataMaxValue: dataMaxValue, breakdownCategoryName: breakdownCategoryName }),
333
334
  dataToSummarize && (react_1.default.createElement(BarChartRenderer, { data: dataToSummarize,
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
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { CSSProperties } from "react";
2
2
  export interface HeatMapGridProps {
3
3
  data: any;
4
4
  valuePath: string | string[];
@@ -14,6 +14,7 @@ export interface HeatMapGridProps {
14
14
  breakdownDisplayType?: "grouped" | "stacked";
15
15
  colorIdx?: number;
16
16
  summarizeAfterIdx?: number;
17
+ style?: CSSProperties;
17
18
  }
18
19
  /**
19
20
  * expects exactly the same data structure as barcharts - breakdown version
@@ -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++) {
@@ -54,6 +58,7 @@ var Typo2_1 = require("../../Typo2");
54
58
  var CustomTooltip_1 = __importDefault(require("../BarChart/comps/CustomTooltip"));
55
59
  var usePrepareData_1 = require("../utils/usePrepareData");
56
60
  var __1 = require("../../../..");
61
+ var styled_components_1 = __importDefault(require("styled-components"));
57
62
  /**
58
63
  * Maps a value from an input range to a color
59
64
  * with the base color at the center point of the range
@@ -116,8 +121,8 @@ function hslToHex(h, s, l) {
116
121
  var _configs = {
117
122
  gridGap: 2,
118
123
  cellRoundness: 4,
119
- cellSize: 36,
120
- axisLabelWidth: 62,
124
+ cellSize: 40,
125
+ axisLabelWidth: 150
121
126
  };
122
127
  var HeatMapCell = function (_a) {
123
128
  var value = _a.value, dataMaxValue = _a.dataMaxValue, _b = _a.dataMinValue, dataMinValue = _b === void 0 ? 0 : _b, showPercent = _a.showPercent;
@@ -146,12 +151,17 @@ var HeatMapCell = function (_a) {
146
151
  } },
147
152
  react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: { color: textColor } }, value.labels.count))));
148
153
  };
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));
149
159
  /**
150
160
  * expects exactly the same data structure as barcharts - breakdown version
151
161
  */
152
162
  var HeatMapGrid = function (_a) {
153
- 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;
154
- var _g = (0, usePrepareData_1.usePrepareData)({
163
+ 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
+ var _h = (0, usePrepareData_1.usePrepareData)({
155
165
  _data: _data,
156
166
  labelPath: labelPath,
157
167
  valuePath: valuePath,
@@ -160,12 +170,34 @@ var HeatMapGrid = function (_a) {
160
170
  isBreakdown: true,
161
171
  showPercent: showPercent,
162
172
  summarizeAfterIdx: summarizeAfterIdx,
163
- }), data = _g.data, dataMaxValue = _g.dataMaxValue, dataToSummarize = _g.dataToSummarize;
164
- return (react_1.default.createElement("div", null,
173
+ }), 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) },
165
193
  react_1.default.createElement("div", { style: {
194
+ position: 'relative',
166
195
  display: "grid",
167
196
  gridTemplateColumns: "auto 1fr",
168
197
  gap: _configs.gridGap + 'px',
198
+ overflow: "auto",
199
+ alignItems: "end",
200
+ height: '100%'
169
201
  } },
170
202
  react_1.default.createElement("div", { style: {
171
203
  display: "flex",
@@ -180,16 +212,20 @@ var HeatMapGrid = function (_a) {
180
212
  alignItems: "center",
181
213
  justifyContent: "flex-end",
182
214
  } },
183
- react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: {
184
- width: _configs.axisLabelWidth + "px",
185
- textOverflow: "ellipsis",
186
- overflow: "hidden",
187
- whiteSpace: "nowrap",
188
- } }, d[0].labels.name))); })),
189
- react_1.default.createElement("div", { style: {
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: {
190
224
  display: "flex",
191
225
  flexDirection: "column",
192
226
  gap: _configs.gridGap + "px",
227
+ overflowX: "auto", //horizontal scroll
228
+ position: 'relative'
193
229
  } },
194
230
  react_1.default.createElement("div", { style: {
195
231
  display: "flex",
@@ -202,29 +238,38 @@ var HeatMapGrid = function (_a) {
202
238
  alignItems: "flex-end",
203
239
  textWrap: "nowrap",
204
240
  justifyContent: 'center',
205
- position: "relative", // Add this
206
- overflow: "visible" // Add this to allow content to overflow
241
+ position: "relative",
242
+ overflow: "visible",
243
+ flexShrink: 0,
207
244
  } },
208
- react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: {
245
+ react_1.default.createElement(STYLED_UI_CAPTION_SEMIBOLD_DF, { style: {
209
246
  width: _configs.axisLabelWidth + "px",
210
- textOverflow: "ellipsis",
211
- overflow: "hidden",
212
- whiteSpace: "nowrap",
213
247
  position: "absolute", // Add this
214
- bottom: '-8px', // which is half of the line height of the current text
215
- left: (_configs.cellSize / 2) + 'px', // Center horizontally
216
- transformOrigin: "left center", // Change origin to bottom
217
- transform: "rotate(-90deg)", // Adjust transform
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",
218
260
  } }, dd.labels.tooltipLabel))); })),
219
261
  data.map(function (d) { return (react_1.default.createElement("div", { style: {
220
262
  display: "flex",
221
263
  alignItems: "center",
222
264
  gap: _configs.gridGap + "px",
265
+ // flexShrink: 0,
223
266
  } }, d.map(function (dd) {
224
267
  // console.log({
225
268
  // color: mapValueToColor(dd.labels.count, 0, dataMaxValue),
226
269
  // });
227
270
  return react_1.default.createElement(HeatMapCell, { showPercent: false, dataMaxValue: dataMaxValue, value: dd });
228
- }))); })))));
271
+ }))); }))),
272
+ showFader && react_1.default.createElement(BarChart_1.FadeGradientWhenScroll, { style: { position: 'absolute', bottom: 0, left: 0 } })));
229
273
  };
230
274
  exports.HeatMapGrid = HeatMapGrid;
275
+ var templateObject_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.196.0",
3
+ "version": "2.197.1",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",