blixify-ui-web 1.2.246 → 1.2.250
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.
- package/lib/components/advanced/collapse/index.d.ts.map +1 -1
- package/lib/components/advanced/collapse/index.js +11 -1
- package/lib/components/advanced/collapse/index.js.map +1 -1
- package/lib/components/chart/DateRange.js +10 -11
- package/lib/components/chart/DateRange.js.map +1 -1
- package/lib/components/chart/areaChart/index.js +1 -1
- package/lib/components/chart/areaChart/index.js.map +1 -1
- package/lib/components/chart/barChart/index.d.ts +139 -0
- package/lib/components/chart/barChart/index.d.ts.map +1 -1
- package/lib/components/chart/barChart/index.js +520 -106
- package/lib/components/chart/barChart/index.js.map +1 -1
- package/lib/components/chart/boxPlotChart/index.js +1 -1
- package/lib/components/chart/boxPlotChart/index.js.map +1 -1
- package/lib/components/chart/bubbleChart/index.js +1 -1
- package/lib/components/chart/bubbleChart/index.js.map +1 -1
- package/lib/components/chart/card/index.js +1 -1
- package/lib/components/chart/card/index.js.map +1 -1
- package/lib/components/chart/heatmapChart/index.js +1 -1
- package/lib/components/chart/heatmapChart/index.js.map +1 -1
- package/lib/components/chart/lineChart/index.js +1 -1
- package/lib/components/chart/lineChart/index.js.map +1 -1
- package/lib/components/chart/pieChart/index.d.ts +40 -0
- package/lib/components/chart/pieChart/index.d.ts.map +1 -1
- package/lib/components/chart/pieChart/index.js +184 -44
- package/lib/components/chart/pieChart/index.js.map +1 -1
- package/lib/components/chart/polarAreaChart/index.js +1 -1
- package/lib/components/chart/polarAreaChart/index.js.map +1 -1
- package/lib/components/chart/radarChart/index.js +1 -1
- package/lib/components/chart/radarChart/index.js.map +1 -1
- package/lib/components/chart/radialBar/index.js +1 -1
- package/lib/components/chart/radialBar/index.js.map +1 -1
- package/lib/components/chart/rangeBarChart/index.js +1 -1
- package/lib/components/chart/rangeBarChart/index.js.map +1 -1
- package/lib/components/chart/treemapChart/index.js +1 -1
- package/lib/components/chart/treemapChart/index.js.map +1 -1
- package/lib/components/data/dataGraph/chartResults.d.ts +41 -0
- package/lib/components/data/dataGraph/chartResults.d.ts.map +1 -1
- package/lib/components/data/dataGraph/chartResults.js +72 -2
- package/lib/components/data/dataGraph/chartResults.js.map +1 -1
- package/lib/components/data/dataGraph/index.d.ts.map +1 -1
- package/lib/components/data/dataGraph/index.js +54 -21
- package/lib/components/data/dataGraph/index.js.map +1 -1
- package/lib/components/data/dataTemplate/chartBuilder.d.ts +6 -0
- package/lib/components/data/dataTemplate/chartBuilder.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/chartBuilder.js +19 -10
- package/lib/components/data/dataTemplate/chartBuilder.js.map +1 -1
- package/lib/components/data/dataTemplate/chartView.d.ts +7 -1
- package/lib/components/data/dataTemplate/chartView.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/chartView.js +291 -32
- package/lib/components/data/dataTemplate/chartView.js.map +1 -1
- package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +14 -4
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/spaceModel.d.ts +15 -0
- package/lib/components/data/dataTemplate/spaceModel.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/spaceModel.js +10 -1
- package/lib/components/data/dataTemplate/spaceModel.js.map +1 -1
- package/lib/components/display/newTable/index.d.ts +2 -1
- package/lib/components/display/newTable/index.d.ts.map +1 -1
- package/lib/components/display/newTable/index.js +396 -108
- package/lib/components/display/newTable/index.js.map +1 -1
- package/lib/components/display/newTable/rowRendering.d.ts +66 -0
- package/lib/components/display/newTable/rowRendering.d.ts.map +1 -0
- package/lib/components/display/newTable/rowRendering.js +219 -0
- package/lib/components/display/newTable/rowRendering.js.map +1 -0
- package/lib/components/display/recordActions/index.d.ts +2 -0
- package/lib/components/display/recordActions/index.d.ts.map +1 -1
- package/lib/components/display/recordActions/index.js +8 -2
- package/lib/components/display/recordActions/index.js.map +1 -1
- package/lib/tail.css +2 -2
- package/package.json +1 -1
|
@@ -82,13 +82,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
82
82
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
83
83
|
};
|
|
84
84
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
85
|
-
exports.handleChartWorkspace = exports.handleCreateDefaultChart = void 0;
|
|
85
|
+
exports.handleChartWorkspace = exports.handleCreateDefaultChart = exports.handleCleanBenchmarks = void 0;
|
|
86
86
|
exports.ChartBuilder = ChartBuilder;
|
|
87
87
|
exports.ChartView = ChartView;
|
|
88
88
|
var outline_1 = require("@heroicons/react/24/outline");
|
|
89
89
|
var axios_1 = __importDefault(require("axios"));
|
|
90
90
|
var react_1 = __importStar(require("react"));
|
|
91
91
|
var button_1 = require("../../action/button");
|
|
92
|
+
var collapse_1 = require("../../advanced/collapse");
|
|
92
93
|
var textButton_1 = require("../../action/textButton");
|
|
93
94
|
var toggle_1 = require("../../action/toggle");
|
|
94
95
|
var dayjs_1 = __importDefault(require("../../dayjs"));
|
|
@@ -104,6 +105,7 @@ var readQuery_1 = require("../readQuery");
|
|
|
104
105
|
var chartBuilder_1 = require("./chartBuilder");
|
|
105
106
|
var chartEmoji_1 = require("./chartEmoji");
|
|
106
107
|
var chartEmojiPicker_1 = require("./chartEmojiPicker");
|
|
108
|
+
var spaceModel_1 = require("./spaceModel");
|
|
107
109
|
var CHART_TYPES = [
|
|
108
110
|
{ key: "card", label: "Card", icon: react_1.default.createElement(outline_1.HashtagIcon, { className: "h-6 w-6" }) },
|
|
109
111
|
{ key: "bar", label: "Bar", icon: react_1.default.createElement(outline_1.ChartBarIcon, { className: "h-6 w-6" }) },
|
|
@@ -135,6 +137,42 @@ var STYLE_OPTIONS = {
|
|
|
135
137
|
{ key: "pie", label: "Pie" },
|
|
136
138
|
],
|
|
137
139
|
};
|
|
140
|
+
// INFO: where a pie chart's legend sits; Top is the default and saves nothing
|
|
141
|
+
var LEGEND_OPTIONS = [
|
|
142
|
+
{ key: "top", label: "Top" },
|
|
143
|
+
{ key: "bottom", label: "Bottom" },
|
|
144
|
+
{ key: "left", label: "Left" },
|
|
145
|
+
{ key: "right", label: "Right" },
|
|
146
|
+
];
|
|
147
|
+
// INFO: enough for a few months of goals on two series without crowding
|
|
148
|
+
var MAX_CHART_BENCHMARKS = 10;
|
|
149
|
+
var BENCHMARK_COLOUR_LABELS = {
|
|
150
|
+
purple: "Purple",
|
|
151
|
+
red: "Red",
|
|
152
|
+
amber: "Amber",
|
|
153
|
+
green: "Green",
|
|
154
|
+
blue: "Blue",
|
|
155
|
+
};
|
|
156
|
+
/** The benchmarks worth saving: a row needs a number to draw anything. */
|
|
157
|
+
var handleCleanBenchmarks = function (benchmarks) {
|
|
158
|
+
var kept = (benchmarks !== null && benchmarks !== void 0 ? benchmarks : [])
|
|
159
|
+
.filter(function (each) { return typeof each.value === "number" && isFinite(each.value); })
|
|
160
|
+
.map(function (each) {
|
|
161
|
+
var _a;
|
|
162
|
+
return (__assign(__assign({ value: each.value }, (((_a = each.label) === null || _a === void 0 ? void 0 : _a.trim()) ? { label: each.label.trim() } : {})), (each.colour ? { colour: each.colour } : {})));
|
|
163
|
+
});
|
|
164
|
+
return kept.length ? kept : undefined;
|
|
165
|
+
};
|
|
166
|
+
exports.handleCleanBenchmarks = handleCleanBenchmarks;
|
|
167
|
+
var BAR_VALUE_OPTIONS = [
|
|
168
|
+
{ key: "inside", label: "Inside the bars" },
|
|
169
|
+
{ key: "outside", label: "Outside the bars" },
|
|
170
|
+
{ key: "hidden", label: "Hidden" },
|
|
171
|
+
];
|
|
172
|
+
var YES_NO_OPTIONS = [
|
|
173
|
+
{ key: "yes", label: "Yes" },
|
|
174
|
+
{ key: "no", label: "No" },
|
|
175
|
+
];
|
|
138
176
|
// INFO: written out in full so Tailwind finds every class in the source; a
|
|
139
177
|
// class built from a template string is dropped from a consumer's CSS build
|
|
140
178
|
var CHART_WIDTH_CLASS = {
|
|
@@ -193,6 +231,28 @@ function ChartBuilder(props) {
|
|
|
193
231
|
// — one read per pause instead of one per keystroke
|
|
194
232
|
var _d = (0, react_1.useState)(props.chart), previewDraft = _d[0], setPreviewDraft = _d[1];
|
|
195
233
|
var _e = (0, react_1.useState)(false), emojiPickerOpen = _e[0], setEmojiPickerOpen = _e[1];
|
|
234
|
+
// INFO: side by side the form scrolls in its own column, which hides how
|
|
235
|
+
// much is left below, so a fade marks it until the end is reached
|
|
236
|
+
var formScrollRef = (0, react_1.useRef)(null);
|
|
237
|
+
var _f = (0, react_1.useState)(false), formHasMore = _f[0], setFormHasMore = _f[1];
|
|
238
|
+
var handleCheckFormMore = function () {
|
|
239
|
+
var element = formScrollRef.current;
|
|
240
|
+
if (!element)
|
|
241
|
+
return;
|
|
242
|
+
setFormHasMore(element.scrollHeight - element.scrollTop - element.clientHeight > 4);
|
|
243
|
+
};
|
|
244
|
+
(0, react_1.useEffect)(function () {
|
|
245
|
+
var element = formScrollRef.current;
|
|
246
|
+
if (!element || typeof ResizeObserver === "undefined")
|
|
247
|
+
return;
|
|
248
|
+
// INFO: fields come and go with the chart type, and the column only
|
|
249
|
+
// scrolls once the screen is wide enough, so both are watched
|
|
250
|
+
var observer = new ResizeObserver(handleCheckFormMore);
|
|
251
|
+
observer.observe(element);
|
|
252
|
+
if (element.firstElementChild)
|
|
253
|
+
observer.observe(element.firstElementChild);
|
|
254
|
+
return function () { return observer.disconnect(); };
|
|
255
|
+
}, []);
|
|
196
256
|
(0, react_1.useEffect)(function () {
|
|
197
257
|
var timer = setTimeout(function () { return setPreviewDraft(draft); }, PREVIEW_DEBOUNCE_MS);
|
|
198
258
|
return function () { return clearTimeout(timer); };
|
|
@@ -262,8 +322,14 @@ function ChartBuilder(props) {
|
|
|
262
322
|
}
|
|
263
323
|
if (!chartBuilder_1.SEGMENTED_CHART_TYPES.includes(type))
|
|
264
324
|
update.segmentBy = undefined;
|
|
265
|
-
if (type !== "bar")
|
|
325
|
+
if (type !== "bar") {
|
|
266
326
|
update.colors = undefined;
|
|
327
|
+
update.valuePosition = undefined;
|
|
328
|
+
update.benchmarks = undefined;
|
|
329
|
+
}
|
|
330
|
+
// INFO: a pie already draws every slice as a share, so it has no Show as %
|
|
331
|
+
if (type === "pie")
|
|
332
|
+
update.showPercent = undefined;
|
|
267
333
|
if (type !== "table") {
|
|
268
334
|
update.datesAcross = undefined;
|
|
269
335
|
update.higherIsBetter = undefined;
|
|
@@ -338,25 +404,118 @@ function ChartBuilder(props) {
|
|
|
338
404
|
eachType.label));
|
|
339
405
|
})));
|
|
340
406
|
};
|
|
341
|
-
var
|
|
342
|
-
var _a
|
|
343
|
-
var
|
|
344
|
-
|
|
407
|
+
var handleUpdateBenchmark = function (index, update) {
|
|
408
|
+
var _a;
|
|
409
|
+
var benchmarks = __spreadArray([], ((_a = draft.benchmarks) !== null && _a !== void 0 ? _a : []), true);
|
|
410
|
+
benchmarks[index] = __assign(__assign({}, benchmarks[index]), update);
|
|
411
|
+
handleUpdateDraft({ benchmarks: benchmarks });
|
|
412
|
+
};
|
|
413
|
+
var handleRemoveBenchmark = function (index) {
|
|
414
|
+
var _a;
|
|
415
|
+
var benchmarks = ((_a = draft.benchmarks) !== null && _a !== void 0 ? _a : []).filter(function (_, eachIndex) { return eachIndex !== index; });
|
|
416
|
+
handleUpdateDraft({
|
|
417
|
+
benchmarks: benchmarks.length ? benchmarks : undefined,
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
// INFO: goals drawn as dashed lines across a bar chart, each a label, a
|
|
421
|
+
// number and a colour; a row without a number draws nothing and isn't saved
|
|
422
|
+
// INFO: the body of its own section; goals are parted by a rule, each with
|
|
423
|
+
// its label and value side by side and its colour beneath
|
|
424
|
+
var renderBenchmarks = function () {
|
|
425
|
+
var _a;
|
|
426
|
+
var benchmarks = (_a = draft.benchmarks) !== null && _a !== void 0 ? _a : [];
|
|
427
|
+
return (react_1.default.createElement("div", { className: "flex flex-col gap-3", "data-testid": "chart-benchmarks" },
|
|
428
|
+
react_1.default.createElement("p", { className: "text-sm text-gray-500" }, "Goals drawn as dashed lines across the chart, such as a monthly target."),
|
|
429
|
+
benchmarks.map(function (eachBenchmark, index) {
|
|
430
|
+
var _a;
|
|
431
|
+
return (react_1.default.createElement("div", { key: index, className: "flex flex-col gap-2 border-t border-gray-200 pt-3" },
|
|
432
|
+
react_1.default.createElement("div", { className: "flex items-center justify-between" },
|
|
433
|
+
react_1.default.createElement("p", { className: "text-xs font-medium text-gray-500" },
|
|
434
|
+
"Benchmark ",
|
|
435
|
+
index + 1),
|
|
436
|
+
react_1.default.createElement(outline_1.TrashIcon, { role: "button", "aria-label": "Remove benchmark line", "data-testid": "chartBenchmarkRemove-".concat(index), className: "h-5 w-5 cursor-pointer text-red-600 hover:text-red-400", onClick: function () { return handleRemoveBenchmark(index); } })),
|
|
437
|
+
react_1.default.createElement("div", { className: "grid grid-cols-2 gap-3" },
|
|
438
|
+
react_1.default.createElement(textInput_1.TextInput, { id: "chartBenchmarkLabel-".concat(index), type: "text", label: "Label", placeholder: "June Target", value: (_a = eachBenchmark.label) !== null && _a !== void 0 ? _a : "", onChange: function (e) {
|
|
439
|
+
return handleUpdateBenchmark(index, { label: e.target.value });
|
|
440
|
+
} }),
|
|
441
|
+
react_1.default.createElement(textInput_1.TextInput, { id: "chartBenchmarkValue-".concat(index), type: "number", label: "Value", placeholder: "0", value: isFinite(eachBenchmark.value) ? "".concat(eachBenchmark.value) : "", onChange: function (e) {
|
|
442
|
+
return handleUpdateBenchmark(index, {
|
|
443
|
+
value: e.target.value === ""
|
|
444
|
+
? Number.NaN
|
|
445
|
+
: Number(e.target.value),
|
|
446
|
+
});
|
|
447
|
+
} })),
|
|
448
|
+
react_1.default.createElement("div", { role: "radiogroup", "aria-label": "Colour", "data-testid": "chartBenchmarkColour-".concat(index), className: "flex flex-wrap items-center gap-2" }, spaceModel_1.CHART_BENCHMARK_COLOURS.map(function (eachColour) {
|
|
449
|
+
var _a;
|
|
450
|
+
var isSelected = ((_a = eachBenchmark.colour) !== null && _a !== void 0 ? _a : "purple") === eachColour;
|
|
451
|
+
return (react_1.default.createElement("button", { key: eachColour, type: "button", role: "radio", "aria-checked": isSelected, "aria-label": BENCHMARK_COLOUR_LABELS[eachColour], title: BENCHMARK_COLOUR_LABELS[eachColour], "data-testid": "chartBenchmarkColour-".concat(index, "-").concat(eachColour), className: "h-6 w-6 rounded-full ".concat(isSelected
|
|
452
|
+
? "ring-2 ring-gray-900 ring-offset-2"
|
|
453
|
+
: "hover:scale-110"), style: {
|
|
454
|
+
backgroundColor: chartResults_1.CHART_BENCHMARK_HEX[eachColour].light,
|
|
455
|
+
}, onClick: function () {
|
|
456
|
+
return handleUpdateBenchmark(index, { colour: eachColour });
|
|
457
|
+
} }));
|
|
458
|
+
}))));
|
|
459
|
+
}),
|
|
460
|
+
benchmarks.length < MAX_CHART_BENCHMARKS && (react_1.default.createElement("div", null,
|
|
461
|
+
react_1.default.createElement(textButton_1.TextButton, { text: "+ Add benchmark line", className: "text-sm", onClick: function () {
|
|
462
|
+
return handleUpdateDraft({
|
|
463
|
+
benchmarks: __spreadArray(__spreadArray([], benchmarks, true), [{ value: Number.NaN }], false),
|
|
464
|
+
});
|
|
465
|
+
} })))));
|
|
466
|
+
};
|
|
467
|
+
// INFO: where a bar chart prints its values. With benchmark lines they're
|
|
468
|
+
// outside the bars or hidden, so no benchmark label covers one; only the
|
|
469
|
+
// choice that differs from the default is saved
|
|
470
|
+
var renderBarValues = function () {
|
|
471
|
+
var hasBenchmarks = !!(0, chartResults_1.handleChartBenchmarkLines)(draft);
|
|
472
|
+
var isStacked = (0, chartResults_1.handleIsStackedBar)(draft);
|
|
473
|
+
var fallback = hasBenchmarks ? "outside" : "inside";
|
|
474
|
+
// INFO: a stacked chart's values stay inside its segments or are hidden;
|
|
475
|
+
// with benchmarks they're outside or hidden
|
|
476
|
+
var options = BAR_VALUE_OPTIONS.filter(function (each) {
|
|
477
|
+
return isStacked
|
|
478
|
+
? each.key !== "outside"
|
|
479
|
+
: hasBenchmarks
|
|
480
|
+
? each.key !== "inside"
|
|
481
|
+
: true;
|
|
482
|
+
});
|
|
483
|
+
return (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartValuePosition", label: "Values position", options: options, value: (0, chartResults_1.handleBarValuePosition)(draft), onChange: function (value) {
|
|
484
|
+
return handleUpdateDraft({
|
|
485
|
+
valuePosition: !value || value === fallback
|
|
486
|
+
? undefined
|
|
487
|
+
: value,
|
|
488
|
+
});
|
|
489
|
+
}, staticDropdown: true }));
|
|
490
|
+
};
|
|
491
|
+
var renderChartSection = function () {
|
|
492
|
+
var _a, _b;
|
|
493
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
345
494
|
props.sourceName && (react_1.default.createElement(textInput_1.TextInput, { id: "chartSource", type: "text", label: "Datasheet", placeholder: "", value: props.sourceName, disabled: true, onChange: function () { } })),
|
|
346
495
|
react_1.default.createElement(textInput_1.TextInput, { id: "chartTitle", type: "text", label: "Title", placeholder: "eg. Orders By Status", value: draft.title, onChange: function (e) { return handleUpdateDraft({ title: e.target.value }); } }),
|
|
347
496
|
renderTypePicker(),
|
|
348
497
|
draft.type === "card" && renderEmojiInput(),
|
|
349
|
-
STYLE_OPTIONS[draft.type] && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartStyle",
|
|
498
|
+
STYLE_OPTIONS[draft.type] && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartStyle",
|
|
499
|
+
// INFO: a bar's style is its orientation; a pie's is pie or donut
|
|
500
|
+
label: draft.type === "bar" ? "Orientation" : "Style", options: STYLE_OPTIONS[draft.type], value: (_a = (draft.type === "bar" ? draft.orientation : draft.pieType)) !== null && _a !== void 0 ? _a : STYLE_OPTIONS[draft.type][0].key, onChange: function (value) {
|
|
350
501
|
return handleUpdateDraft(draft.type === "bar"
|
|
351
502
|
? { orientation: value }
|
|
352
503
|
: { pieType: value });
|
|
353
504
|
}, staticDropdown: true })),
|
|
354
|
-
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "
|
|
505
|
+
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartWidth", label: "Width", options: WIDTH_OPTIONS, value: "".concat((_b = draft.gridSize) !== null && _b !== void 0 ? _b : 1), onChange: function (value) {
|
|
506
|
+
return handleUpdateDraft({ gridSize: Number(value) });
|
|
507
|
+
}, staticDropdown: true })));
|
|
508
|
+
};
|
|
509
|
+
var renderDataSection = function () {
|
|
510
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
511
|
+
var isMeasured = draft.queryBaseType === "sum" || draft.queryBaseType === "avg";
|
|
512
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
513
|
+
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartMetric", label: "Measure", options: renderMetricOptions(), value: (_a = draft.queryBaseType) !== null && _a !== void 0 ? _a : "count", onChange: function (value) {
|
|
355
514
|
return handleSelectMetric(value);
|
|
356
515
|
}, staticDropdown: true }),
|
|
357
|
-
isMeasured && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartAttribute", label: "Of", options: numberOptions, value: draft.type === "radar"
|
|
358
|
-
? ((
|
|
359
|
-
: ((
|
|
516
|
+
isMeasured && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartAttribute", label: "Of column", options: numberOptions, value: draft.type === "radar"
|
|
517
|
+
? ((_b = draft.queryAttributeId) !== null && _b !== void 0 ? _b : [])
|
|
518
|
+
: ((_d = (_c = draft.queryAttributeId) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : ""), onChange: function (value) {
|
|
360
519
|
return handleUpdateDraft({
|
|
361
520
|
queryAttributeId: Array.isArray(value) ? value : [value],
|
|
362
521
|
});
|
|
@@ -366,25 +525,54 @@ function ChartBuilder(props) {
|
|
|
366
525
|
}, staticDropdown: true })),
|
|
367
526
|
(draft.type === "line" || !isDateGrouped) && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartDate", label: draft.type === "line" ? "Over Time" : "Date Range On", options: draft.type === "line"
|
|
368
527
|
? dateOptions
|
|
369
|
-
: __spreadArray([{ key: "", label: "None" }], dateOptions, true), value: (
|
|
528
|
+
: __spreadArray([{ key: "", label: "None" }], dateOptions, true), value: (_e = draft.queryBaseDateId) !== null && _e !== void 0 ? _e : "", onChange: function (value) {
|
|
370
529
|
return handleUpdateDraft({ queryBaseDateId: value || undefined });
|
|
371
530
|
}, staticDropdown: true })),
|
|
372
531
|
(isDateGrouped || draft.type === "line") && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartInterval", label: "Interval", options: draft.type === "line"
|
|
373
|
-
? __spreadArray([{ key: "", label: "Auto" }], chartBuilder_1.INTERVAL_OPTIONS, true) : chartBuilder_1.INTERVAL_OPTIONS, value: (
|
|
532
|
+
? __spreadArray([{ key: "", label: "Auto" }], chartBuilder_1.INTERVAL_OPTIONS, true) : chartBuilder_1.INTERVAL_OPTIONS, value: (_f = draft.queryDateInterval) !== null && _f !== void 0 ? _f : "", onChange: function (value) {
|
|
374
533
|
return handleUpdateDraft({
|
|
375
534
|
queryDateInterval: value || undefined,
|
|
376
535
|
cumulative: value ? draft.cumulative : undefined,
|
|
377
536
|
});
|
|
378
537
|
}, staticDropdown: true })),
|
|
379
|
-
chartBuilder_1.SEGMENTED_CHART_TYPES.includes(draft.type) && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartSegmentBy", label: "Split By", options: (0, chartBuilder_1.handleGetSegmentOptions)(props.structure, (
|
|
538
|
+
chartBuilder_1.SEGMENTED_CHART_TYPES.includes(draft.type) && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartSegmentBy", label: "Split By", options: (0, chartBuilder_1.handleGetSegmentOptions)(props.structure, (_g = draft.groupBy) !== null && _g !== void 0 ? _g : (_j = (_h = draft.query) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.queryId), value: (_k = draft.segmentBy) !== null && _k !== void 0 ? _k : "", onChange: function (value) {
|
|
380
539
|
return handleUpdateDraft({
|
|
381
540
|
segmentBy: value || undefined,
|
|
382
541
|
showPercent: value ? undefined : draft.showPercent,
|
|
383
542
|
});
|
|
543
|
+
}, staticDropdown: true }))));
|
|
544
|
+
};
|
|
545
|
+
var renderCustomizeSection = function () {
|
|
546
|
+
var _a, _b, _c, _d;
|
|
547
|
+
var canShowTotal = ((_a = draft.pieType) !== null && _a !== void 0 ? _a : "donut") === "donut" && draft.queryBaseType !== "avg";
|
|
548
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
549
|
+
draft.type === "bar" && renderBarValues(),
|
|
550
|
+
draft.type === "pie" && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartLegend", label: "Legend", options: LEGEND_OPTIONS, value: (_b = draft.legendPosition) !== null && _b !== void 0 ? _b : "top", onChange: function (value) {
|
|
551
|
+
return handleUpdateDraft({
|
|
552
|
+
legendPosition: value === "top"
|
|
553
|
+
? undefined
|
|
554
|
+
: value,
|
|
555
|
+
});
|
|
384
556
|
}, staticDropdown: true })),
|
|
557
|
+
draft.type === "pie" && (react_1.default.createElement("div", { className: "grid grid-cols-2 gap-4" },
|
|
558
|
+
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartDataLabel", label: "Show values on chart", options: YES_NO_OPTIONS, value: draft.showDataLabel === false ? "no" : "yes", onChange: function (value) {
|
|
559
|
+
return handleUpdateDraft({
|
|
560
|
+
// INFO: shown is the default, so only hiding is saved
|
|
561
|
+
showDataLabel: value === "no" ? false : undefined,
|
|
562
|
+
});
|
|
563
|
+
}, staticDropdown: true }),
|
|
564
|
+
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartTotal", label: "Show total", options: YES_NO_OPTIONS,
|
|
565
|
+
// INFO: stays beside Show values so the row keeps its shape; a
|
|
566
|
+
// solid pie has no centre, and a sum of averages means nothing
|
|
567
|
+
value: canShowTotal && draft.showTotal ? "yes" : "no", disabled: !canShowTotal, onChange: function (value) {
|
|
568
|
+
return handleUpdateDraft({
|
|
569
|
+
// INFO: hidden is the default, so only showing is saved
|
|
570
|
+
showTotal: value === "yes" ? true : undefined,
|
|
571
|
+
});
|
|
572
|
+
}, staticDropdown: true }))),
|
|
385
573
|
isGrouped && draft.type !== "radar" && !isDateGrouped && (react_1.default.createElement("div", { className: "grid grid-cols-2 gap-4" },
|
|
386
574
|
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartSort", label: "Sort", options: chartBuilder_1.SORT_OPTIONS, value: draft.sortBy
|
|
387
|
-
? "".concat(draft.sortBy, ":").concat((
|
|
575
|
+
? "".concat(draft.sortBy, ":").concat((_c = draft.sortDirection) !== null && _c !== void 0 ? _c : "desc")
|
|
388
576
|
: "", onChange: function (value) {
|
|
389
577
|
var _a = value.split(":"), sortBy = _a[0], sortDirection = _a[1];
|
|
390
578
|
handleUpdateDraft({
|
|
@@ -402,6 +590,7 @@ function ChartBuilder(props) {
|
|
|
402
590
|
}, staticDropdown: true }))),
|
|
403
591
|
isGrouped &&
|
|
404
592
|
draft.type !== "radar" &&
|
|
593
|
+
draft.type !== "pie" &&
|
|
405
594
|
draft.queryBaseType !== "avg" &&
|
|
406
595
|
!draft.segmentBy && (react_1.default.createElement(toggle_1.Toggle, { id: "chartPercent", text: "Show as %", direction: "right", value: !!draft.showPercent, onClick: function () {
|
|
407
596
|
return handleUpdateDraft({ showPercent: !draft.showPercent });
|
|
@@ -424,7 +613,7 @@ function ChartBuilder(props) {
|
|
|
424
613
|
isDateGrouped &&
|
|
425
614
|
draft.type === "table" &&
|
|
426
615
|
draft.datesAcross &&
|
|
427
|
-
!!draft.segmentBy && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartValueDisplay", label: "Show values as", options: VALUE_DISPLAY_OPTIONS, value: draft.valueDisplay === "count" ? "" : (
|
|
616
|
+
!!draft.segmentBy && (react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartValueDisplay", label: "Show values as", options: VALUE_DISPLAY_OPTIONS, value: draft.valueDisplay === "count" ? "" : ((_d = draft.valueDisplay) !== null && _d !== void 0 ? _d : ""), onChange: function (value) {
|
|
428
617
|
return handleUpdateDraft({
|
|
429
618
|
valueDisplay: value === "percent" || value === "both" ? value : undefined,
|
|
430
619
|
});
|
|
@@ -439,18 +628,23 @@ function ChartBuilder(props) {
|
|
|
439
628
|
});
|
|
440
629
|
}, staticDropdown: true })),
|
|
441
630
|
(isDateGrouped ||
|
|
442
|
-
(draft.type === "line" && !!draft.queryDateInterval)) && (react_1.default.createElement(toggle_1.Toggle, { id: "chartCumulative", text: "Running total", direction: "right", value: !!draft.cumulative, onClick: function () { return handleUpdateDraft({ cumulative: !draft.cumulative }); } }))
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
631
|
+
(draft.type === "line" && !!draft.queryDateInterval)) && (react_1.default.createElement(toggle_1.Toggle, { id: "chartCumulative", text: "Running total", direction: "right", value: !!draft.cumulative, onClick: function () { return handleUpdateDraft({ cumulative: !draft.cumulative }); } }))));
|
|
632
|
+
};
|
|
633
|
+
var renderBenchmarkSection = function () { return (react_1.default.createElement(react_1.default.Fragment, null, (0, chartResults_1.handleIsStackedBar)(draft) ? (
|
|
634
|
+
// INFO: a split chart's bars are stacks of segments, each its own
|
|
635
|
+
// number, so a goal against one number per bar doesn't apply
|
|
636
|
+
react_1.default.createElement("p", { className: "text-sm text-gray-500" }, "Not available on a chart split by a column, since each bar is a stack of several values.")) : (renderBenchmarks()))); };
|
|
637
|
+
var renderRecordsSection = function () {
|
|
638
|
+
var _a, _b, _c, _d, _e, _f;
|
|
639
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
640
|
+
react_1.default.createElement("p", { className: "text-sm text-gray-500" }, "Opens when someone clicks a bar, slice or row, showing the records behind it."),
|
|
641
|
+
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartRecordColumns", label: "Columns", options: recordColumnOptions, value: (_a = draft.recordColumns) !== null && _a !== void 0 ? _a : [], onChange: function (value) {
|
|
448
642
|
return handleUpdateDraft({
|
|
449
643
|
recordColumns: (value === null || value === void 0 ? void 0 : value.length) ? value : undefined,
|
|
450
644
|
});
|
|
451
645
|
}, staticDropdown: true }),
|
|
452
646
|
react_1.default.createElement("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-2" },
|
|
453
|
-
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartRecordSort", label: "Sort by", options: __spreadArray([{ key: "", label: "Default" }], recordColumnOptions, true), value: (
|
|
647
|
+
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartRecordSort", label: "Sort by", options: __spreadArray([{ key: "", label: "Default" }], recordColumnOptions, true), value: (_c = (_b = draft.recordSort) === null || _b === void 0 ? void 0 : _b.sortId) !== null && _c !== void 0 ? _c : "", onChange: function (value) {
|
|
454
648
|
var _a, _b;
|
|
455
649
|
return handleUpdateDraft({
|
|
456
650
|
recordSort: value
|
|
@@ -458,30 +652,92 @@ function ChartBuilder(props) {
|
|
|
458
652
|
: undefined,
|
|
459
653
|
});
|
|
460
654
|
}, staticDropdown: true }),
|
|
461
|
-
|
|
655
|
+
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartRecordSortType", label: "Order", options: RECORD_SORT_DIRECTIONS,
|
|
656
|
+
// INFO: stays in place beside Sort by, so the row keeps its shape;
|
|
657
|
+
// there is nothing to order until a column is picked
|
|
658
|
+
value: (_e = (_d = draft.recordSort) === null || _d === void 0 ? void 0 : _d.type) !== null && _e !== void 0 ? _e : "desc", disabled: !draft.recordSort, onChange: function (value) {
|
|
462
659
|
return draft.recordSort &&
|
|
463
660
|
handleUpdateDraft({
|
|
464
661
|
recordSort: __assign(__assign({}, draft.recordSort), { type: value === "asc" ? "asc" : "desc" }),
|
|
465
662
|
});
|
|
466
|
-
}, staticDropdown: true }))
|
|
467
|
-
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartRecordPageSize", label: "Rows per page", options: RECORD_PAGE_SIZES, value: "".concat((
|
|
663
|
+
}, staticDropdown: true })),
|
|
664
|
+
react_1.default.createElement(select_1.Select, { portalDropdown: true, id: "chartRecordPageSize", label: "Rows per page", options: RECORD_PAGE_SIZES, value: "".concat((_f = draft.recordPageSize) !== null && _f !== void 0 ? _f : RECORD_LIMIT), onChange: function (value) {
|
|
468
665
|
return handleUpdateDraft({
|
|
469
666
|
recordPageSize: Number(value) === RECORD_LIMIT ? undefined : Number(value),
|
|
470
667
|
});
|
|
471
668
|
}, staticDropdown: true })));
|
|
472
669
|
};
|
|
670
|
+
// INFO: Monday-style stack of bordered sections, each opened or closed from
|
|
671
|
+
// its header; a closed section keeps its fields in the page, only hidden,
|
|
672
|
+
// and says in a line what's set inside so the form reads without opening it
|
|
673
|
+
var renderSection = function (key, title, content, defaultOpen, summary, summaryClassName) { return (react_1.default.createElement("div", { "data-testid": "chart-section-".concat(key) },
|
|
674
|
+
react_1.default.createElement(collapse_1.Collapse, { title: title, icon: react_1.default.createElement(react_1.default.Fragment, null), summary: summary, summaryClassName: summaryClassName, defaultOpen: defaultOpen, containerClassName: "border border-gray-200", titleClassName: "text-sm font-semibold leading-tight text-gray-900", contentClassName: "flex flex-col gap-4 px-3 py-4", content: content }))); };
|
|
675
|
+
var renderForm = function () {
|
|
676
|
+
var _a, _b, _c, _d, _e, _f;
|
|
677
|
+
var typeLabel = (_a = CHART_TYPES.find(function (eachType) { return eachType.key === draft.type; })) === null || _a === void 0 ? void 0 : _a.label;
|
|
678
|
+
var groupLabel = isGrouped
|
|
679
|
+
? (_b = groupOptions.find(function (eachOption) { return eachOption.key === groupValue; })) === null || _b === void 0 ? void 0 : _b.label
|
|
680
|
+
: undefined;
|
|
681
|
+
var measureColumn = (_c = numberOptions.find(function (eachOption) { var _a; return eachOption.key === ((_a = draft.queryAttributeId) === null || _a === void 0 ? void 0 : _a[0]); })) === null || _c === void 0 ? void 0 : _c.label;
|
|
682
|
+
var measureLabel = draft.queryBaseType === "sum" || draft.queryBaseType === "avg"
|
|
683
|
+
? "".concat(draft.queryBaseType === "sum" ? "Sum" : "Average").concat(measureColumn ? " of ".concat(measureColumn) : "")
|
|
684
|
+
: "Count";
|
|
685
|
+
// INFO: a card, a radar or a line without an interval has nothing to
|
|
686
|
+
// customise, so the section only shows when it holds a field
|
|
687
|
+
var hasCustomize = ["bar", "pie", "table"].includes(draft.type) ||
|
|
688
|
+
isDateGrouped ||
|
|
689
|
+
(draft.type === "line" && !!draft.queryDateInterval);
|
|
690
|
+
var benchmarkCount = (0, chartResults_1.handleIsStackedBar)(draft)
|
|
691
|
+
? 0
|
|
692
|
+
: ((_d = draft.benchmarks) !== null && _d !== void 0 ? _d : []).length;
|
|
693
|
+
// INFO: what the data settings still need; Data then opens with the form
|
|
694
|
+
// and names it while closed, so a disabled Save has its reason in view
|
|
695
|
+
var dataProblem = (0, chartBuilder_1.handleGetChartDataProblem)(draft);
|
|
696
|
+
var recordSortLabel = draft.recordSort
|
|
697
|
+
? (_e = recordColumnOptions.find(function (eachOption) { var _a; return eachOption.key === ((_a = draft.recordSort) === null || _a === void 0 ? void 0 : _a.sortId); })) === null || _e === void 0 ? void 0 : _e.label
|
|
698
|
+
: undefined;
|
|
699
|
+
return (react_1.default.createElement("div", { className: "flex flex-col gap-3" },
|
|
700
|
+
renderSection("chart", "Chart", renderChartSection(), true, typeLabel),
|
|
701
|
+
renderSection("data", "Data", renderDataSection(), !!dataProblem, dataProblem !== null && dataProblem !== void 0 ? dataProblem : "".concat(measureLabel).concat(groupLabel ? " by ".concat(groupLabel) : ""), dataProblem ? "text-red-600" : undefined),
|
|
702
|
+
hasCustomize &&
|
|
703
|
+
renderSection("customize", "Customize", renderCustomizeSection(), false),
|
|
704
|
+
draft.type === "bar" &&
|
|
705
|
+
renderSection("benchmarks", "Benchmark lines", renderBenchmarkSection(), false, (0, chartResults_1.handleIsStackedBar)(draft)
|
|
706
|
+
? "Not available on a split chart"
|
|
707
|
+
: benchmarkCount
|
|
708
|
+
? "".concat(benchmarkCount, " ").concat(benchmarkCount === 1 ? "line" : "lines")
|
|
709
|
+
: "None"),
|
|
710
|
+
renderSection("records", "Records list", renderRecordsSection(), false, "".concat((_f = draft.recordPageSize) !== null && _f !== void 0 ? _f : RECORD_LIMIT, " rows per page").concat(recordSortLabel ? ", sorted by ".concat(recordSortLabel) : ""))));
|
|
711
|
+
};
|
|
473
712
|
var renderPreview = function () {
|
|
474
713
|
if (!(0, chartBuilder_1.handleCheckChartValid)(previewDraft))
|
|
475
714
|
return react_1.default.createElement("div", { className: "h-full min-h-[16rem]" });
|
|
476
715
|
return (react_1.default.createElement(dataGraph_1.DataGraph, { charts: [previewChart], workspace: props.workspace, structure: props.structure, personOptions: props.personOptions, multicolourDefault: props.multicolourDefault, renderSettings: function (element) { return element; } }));
|
|
477
716
|
};
|
|
478
717
|
return (react_1.default.createElement("div", { className: "flex flex-col gap-6" },
|
|
479
|
-
react_1.default.createElement("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2" },
|
|
480
|
-
|
|
481
|
-
|
|
718
|
+
react_1.default.createElement("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-5" },
|
|
719
|
+
react_1.default.createElement("div", { ref: formScrollRef, onScroll: handleCheckFormMore, className: "md:max-h-[70vh] md:overflow-y-auto md:pr-2 lg:col-span-2" },
|
|
720
|
+
renderForm(),
|
|
721
|
+
formHasMore && (react_1.default.createElement("div", { "data-testid": "chart-form-more", className: "pointer-events-none sticky bottom-0 -mt-12 hidden h-12 bg-gradient-to-t from-white to-transparent md:block" }))),
|
|
722
|
+
react_1.default.createElement("div", { "data-testid": "chart-preview", className: "lg:col-span-3" }, renderPreview())),
|
|
482
723
|
react_1.default.createElement("div", { className: "flex justify-end gap-2" },
|
|
483
724
|
react_1.default.createElement(button_1.Button, { type: "light", text: "Cancel", onClick: props.onClose }),
|
|
484
|
-
react_1.default.createElement(button_1.Button, { type: "normal", text: "Save", id: "chartSave", disable: !isValid, onClick: function () {
|
|
725
|
+
react_1.default.createElement(button_1.Button, { type: "normal", text: "Save", id: "chartSave", disable: !isValid, onClick: function () {
|
|
726
|
+
return props.onSave(__assign(__assign({}, draft), { title: draft.title.trim(),
|
|
727
|
+
// INFO: a split chart has no benchmark lines, so none are kept
|
|
728
|
+
benchmarks: (0, chartResults_1.handleIsStackedBar)(draft)
|
|
729
|
+
? undefined
|
|
730
|
+
: (0, exports.handleCleanBenchmarks)(draft.benchmarks),
|
|
731
|
+
// INFO: a chart with benchmarks never prints its values inside
|
|
732
|
+
// INFO: only a position that applies is kept: never inside
|
|
733
|
+
// with benchmarks, never outside on a stacked chart
|
|
734
|
+
valuePosition: (0, chartResults_1.handleBarValuePosition)(draft) === "hidden"
|
|
735
|
+
? "hidden"
|
|
736
|
+
: draft.valuePosition === "outside" &&
|
|
737
|
+
!(0, chartResults_1.handleIsStackedBar)(draft)
|
|
738
|
+
? "outside"
|
|
739
|
+
: undefined }));
|
|
740
|
+
} })),
|
|
485
741
|
react_1.default.createElement(modal_1.Modal, { open: emojiPickerOpen, title: "Choose Emoji", maxWidth: "lg", onClose: function () { return setEmojiPickerOpen(false); }, renderContent: function () { return (emojiPickerOpen ? renderEmojiPicker() : null); } })));
|
|
486
742
|
}
|
|
487
743
|
// INFO: a column a short records table can show as plain text
|
|
@@ -682,7 +938,10 @@ function ChartView(props) {
|
|
|
682
938
|
var renderCharts = function () {
|
|
683
939
|
return (react_1.default.createElement("div", { className: "grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-4" }, props.charts.map(function (eachChart, index) {
|
|
684
940
|
var _a;
|
|
685
|
-
return (react_1.default.createElement("div", { key: "".concat(index, "-").concat(eachChart.title), "data-testid": "chart-".concat(index),
|
|
941
|
+
return (react_1.default.createElement("div", { key: "".concat(index, "-").concat(eachChart.title), "data-testid": "chart-".concat(index),
|
|
942
|
+
// INFO: a column, so the chart under its actions fills the rest of
|
|
943
|
+
// the row's height
|
|
944
|
+
className: "flex flex-col ".concat((_a = CHART_WIDTH_CLASS[eachChart.gridSize]) !== null && _a !== void 0 ? _a : "col-span-1") },
|
|
686
945
|
canEdit && renderChartActions(index),
|
|
687
946
|
react_1.default.createElement(dataGraph_1.DataGraph, { charts: [handleResolveChart(eachChart)], workspace: workspace, structure: props.structure, personOptions: props.devSettings.organisationMembers, multicolourDefault: props.multicolourDefault, onDrillDown: setDrillDown, onHighlightRow: canEdit
|
|
688
947
|
? function (_chart, row, highlight) {
|
|
@@ -693,7 +952,7 @@ function ChartView(props) {
|
|
|
693
952
|
};
|
|
694
953
|
return (react_1.default.createElement("div", { className: "mt-4 flex flex-col gap-2" },
|
|
695
954
|
props.charts.length === 0 ? renderEmpty() : renderCharts(),
|
|
696
|
-
react_1.default.createElement(modal_1.Modal, { open: !!editingChart, title: (editing === null || editing === void 0 ? void 0 : editing.isNew) ? "Add Chart" : "Edit Chart", maxWidth: "
|
|
955
|
+
react_1.default.createElement(modal_1.Modal, { open: !!editingChart, title: (editing === null || editing === void 0 ? void 0 : editing.isNew) ? "Add Chart" : "Edit Chart", maxWidth: "6xl", darkMode: props.darkMode, darkModeBg: props.darkModeBg, onClose: function () { return setEditing(null); }, renderContent: function () {
|
|
697
956
|
return editingChart ? (react_1.default.createElement(ChartBuilder, { key: "".concat(editing === null || editing === void 0 ? void 0 : editing.index, "-").concat(editing === null || editing === void 0 ? void 0 : editing.isNew), chart: editingChart, structure: props.structure, workspace: workspace, filterQuery: props.filterQuery, rangeOverride: props.rangeOverride, personOptions: props.devSettings.organisationMembers, sourceName: props.collectionName, multicolourDefault: props.multicolourDefault, onSave: handleSaveChart, onClose: function () { return setEditing(null); } })) : null;
|
|
698
957
|
} }),
|
|
699
958
|
react_1.default.createElement(modal_1.Modal, { open: !!drillDown, title: drillDown ? "".concat(drillDown.chart.title, " \u2014 ").concat(drillDown.label) : "",
|