blixify-ui-web 1.2.198 → 1.2.199
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/data/columnTypes/buttonCell.d.ts +3 -1
- package/lib/components/data/columnTypes/buttonCell.d.ts.map +1 -1
- package/lib/components/data/columnTypes/buttonCell.js +4 -0
- package/lib/components/data/columnTypes/buttonCell.js.map +1 -1
- package/lib/components/data/columnTypes/dateRangeCell.d.ts +20 -0
- package/lib/components/data/columnTypes/dateRangeCell.d.ts.map +1 -0
- package/lib/components/data/columnTypes/dateRangeCell.js +210 -0
- package/lib/components/data/columnTypes/dateRangeCell.js.map +1 -0
- package/lib/components/data/columnTypes/index.d.ts +1 -0
- package/lib/components/data/columnTypes/index.d.ts.map +1 -1
- package/lib/components/data/columnTypes/index.js +1 -0
- package/lib/components/data/columnTypes/index.js.map +1 -1
- package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +121 -10
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/formula/index.d.ts.map +1 -1
- package/lib/components/data/formula/index.js +3 -1
- package/lib/components/data/formula/index.js.map +1 -1
- package/lib/components/data/listModule.d.ts +2 -0
- package/lib/components/data/listModule.d.ts.map +1 -1
- package/lib/components/data/listModule.js +67 -52
- package/lib/components/data/listModule.js.map +1 -1
- package/lib/components/data/updateModule.d.ts.map +1 -1
- package/lib/components/data/updateModule.js +4 -1
- package/lib/components/data/updateModule.js.map +1 -1
- package/lib/components/data/utils.d.ts +1 -0
- package/lib/components/data/utils.d.ts.map +1 -1
- package/lib/components/data/utils.js +19 -12
- package/lib/components/data/utils.js.map +1 -1
- package/lib/components/display/newTable/index.d.ts +8 -0
- package/lib/components/display/newTable/index.d.ts.map +1 -1
- package/lib/components/display/newTable/index.js +323 -109
- package/lib/components/display/newTable/index.js.map +1 -1
- package/lib/tail.css +1 -1
- package/package.json +1 -1
|
@@ -82,7 +82,7 @@ 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.NewTable = exports.handleGetEditableColumnTypes = exports.NEW_TABLE_GROUP_ROW_BATCH = void 0;
|
|
85
|
+
exports.NewTable = exports.handleGetEditableColumnTypes = exports.handleWriteColumnOptions = exports.handleReadColumnOptions = exports.NEW_TABLE_GROUP_ROW_BATCH = void 0;
|
|
86
86
|
var react_1 = require("@headlessui/react");
|
|
87
87
|
var solid_1 = require("@heroicons/react/20/solid");
|
|
88
88
|
var outline_1 = require("@heroicons/react/24/outline");
|
|
@@ -95,6 +95,10 @@ var textButton_1 = require("../../action/textButton");
|
|
|
95
95
|
var collapse_1 = require("../../advanced/collapse");
|
|
96
96
|
var popUp_1 = require("../../advanced/popUp");
|
|
97
97
|
var formula_1 = require("../../data/formula");
|
|
98
|
+
var buttonCell_1 = require("../../data/columnTypes/buttonCell");
|
|
99
|
+
var context_1 = require("../../data/columnTypes/context");
|
|
100
|
+
var dateRangeCell_1 = require("../../data/columnTypes/dateRangeCell");
|
|
101
|
+
var systemColumns_1 = require("../../data/columnTypes/systemColumns");
|
|
98
102
|
var builder_1 = require("../../data/formula/builder");
|
|
99
103
|
var readModule_1 = require("../../data/readModule");
|
|
100
104
|
var updateModule_1 = require("../../data/updateModule");
|
|
@@ -177,7 +181,7 @@ var MIN_COLUMN_WIDTH = 80;
|
|
|
177
181
|
// INFO: every field type the popup can finish. math has its own expression
|
|
178
182
|
// builder, and object/listObject need a nested schema the schema editor builds —
|
|
179
183
|
// creating either here would only ever produce a dead column.
|
|
180
|
-
var
|
|
184
|
+
var ALL_COLUMN_TYPES = [
|
|
181
185
|
{ key: "string", label: "Text" },
|
|
182
186
|
{ key: "textArea", label: "Long text" },
|
|
183
187
|
{ key: "markdown", label: "Markdown" },
|
|
@@ -210,7 +214,16 @@ var ADD_COLUMN_TYPES = [
|
|
|
210
214
|
{ key: "timeTracking", label: "Time tracking" },
|
|
211
215
|
{ key: "button", label: "Button" },
|
|
212
216
|
];
|
|
217
|
+
// INFO: never drawn as a table cell, so a column of these added from the
|
|
218
|
+
// table would be invisible the moment it was made; one that exists can still
|
|
219
|
+
// be renamed
|
|
220
|
+
var NON_ADDABLE_COLUMN_TYPES = ["listAddress", "ganttchart", "canvas"];
|
|
221
|
+
var ADD_COLUMN_TYPES = ALL_COLUMN_TYPES.filter(function (eachType) { return !NON_ADDABLE_COLUMN_TYPES.includes(eachType.key); });
|
|
213
222
|
var REFERENCE_TYPES = ["reference", "listReference", "referenceSelection"];
|
|
223
|
+
var BUTTON_COLOUR_OPTIONS = buttonCell_1.BUTTON_COLOURS.map(function (eachColour) { return ({
|
|
224
|
+
key: eachColour,
|
|
225
|
+
label: eachColour.charAt(0).toUpperCase() + eachColour.slice(1),
|
|
226
|
+
}); });
|
|
214
227
|
var LIST_TYPES = ["list", "multipleList"];
|
|
215
228
|
// INFO: asset columns need a storage path, which the consumer fills in from its
|
|
216
229
|
// own settings — nothing for the user to type
|
|
@@ -245,14 +258,75 @@ var REFERENCE_TARGET_KEYS = [
|
|
|
245
258
|
"referenceSort",
|
|
246
259
|
"referenceDependency",
|
|
247
260
|
];
|
|
248
|
-
|
|
249
|
-
var
|
|
250
|
-
|
|
251
|
-
return
|
|
252
|
-
.split(",")
|
|
253
|
-
.map(function (eachOption) { return eachOption.trim(); })
|
|
254
|
-
.filter(Boolean);
|
|
261
|
+
var columnOptionKey = 0;
|
|
262
|
+
var handleNextOptionKey = function () {
|
|
263
|
+
columnOptionKey += 1;
|
|
264
|
+
return columnOptionKey;
|
|
255
265
|
};
|
|
266
|
+
var OPTION_COLOURS = [
|
|
267
|
+
"primary",
|
|
268
|
+
"red",
|
|
269
|
+
"blue",
|
|
270
|
+
"green",
|
|
271
|
+
"yellow",
|
|
272
|
+
"indigo",
|
|
273
|
+
"purple",
|
|
274
|
+
"lime",
|
|
275
|
+
"sky",
|
|
276
|
+
"pink",
|
|
277
|
+
"orange",
|
|
278
|
+
"dark",
|
|
279
|
+
];
|
|
280
|
+
// INFO: literal classes so Tailwind emits them
|
|
281
|
+
var OPTION_SWATCH_CLASS = {
|
|
282
|
+
"": "bg-white border-gray-300",
|
|
283
|
+
primary: "bg-primary-500 border-primary-500",
|
|
284
|
+
red: "bg-red-500 border-red-500",
|
|
285
|
+
blue: "bg-blue-500 border-blue-500",
|
|
286
|
+
green: "bg-green-500 border-green-500",
|
|
287
|
+
yellow: "bg-yellow-500 border-yellow-500",
|
|
288
|
+
indigo: "bg-indigo-500 border-indigo-500",
|
|
289
|
+
purple: "bg-purple-500 border-purple-500",
|
|
290
|
+
lime: "bg-lime-500 border-lime-500",
|
|
291
|
+
sky: "bg-sky-500 border-sky-500",
|
|
292
|
+
pink: "bg-pink-500 border-pink-500",
|
|
293
|
+
orange: "bg-orange-500 border-orange-500",
|
|
294
|
+
dark: "bg-gray-900 border-gray-900",
|
|
295
|
+
};
|
|
296
|
+
var handleReadColumnOptions = function (column) {
|
|
297
|
+
var _a;
|
|
298
|
+
return ((_a = column === null || column === void 0 ? void 0 : column.listSelection) !== null && _a !== void 0 ? _a : []).map(function (eachOption, index) {
|
|
299
|
+
var _a, _b, _c;
|
|
300
|
+
return ({
|
|
301
|
+
key: handleNextOptionKey(),
|
|
302
|
+
text: eachOption,
|
|
303
|
+
colour: (_b = (_a = column === null || column === void 0 ? void 0 : column.listSelectionColour) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : "",
|
|
304
|
+
label: ((_c = column === null || column === void 0 ? void 0 : column.listSelectionLabel) === null || _c === void 0 ? void 0 : _c[index]) || undefined,
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
exports.handleReadColumnOptions = handleReadColumnOptions;
|
|
309
|
+
// INFO: options, colours and labels saved side by side, index for index; a
|
|
310
|
+
// column with no colour or label set carries no list of them
|
|
311
|
+
var handleWriteColumnOptions = function (column, rows) {
|
|
312
|
+
// INFO: a row left blank is not an option
|
|
313
|
+
var options = rows
|
|
314
|
+
.map(function (eachOption) { return (__assign(__assign({}, eachOption), { text: eachOption.text.trim() })); })
|
|
315
|
+
.filter(function (eachOption) { return eachOption.text; });
|
|
316
|
+
column.listSelection = options.map(function (eachOption) { return eachOption.text; });
|
|
317
|
+
var colours = options.map(function (eachOption) { var _a; return (_a = eachOption.colour) !== null && _a !== void 0 ? _a : ""; });
|
|
318
|
+
if (colours.some(Boolean))
|
|
319
|
+
column.listSelectionColour = colours;
|
|
320
|
+
else
|
|
321
|
+
delete column.listSelectionColour;
|
|
322
|
+
var labels = options.map(function (eachOption) { var _a; return (_a = eachOption.label) !== null && _a !== void 0 ? _a : ""; });
|
|
323
|
+
if (labels.some(Boolean))
|
|
324
|
+
column.listSelectionLabel = labels;
|
|
325
|
+
else
|
|
326
|
+
delete column.listSelectionLabel;
|
|
327
|
+
return column;
|
|
328
|
+
};
|
|
329
|
+
exports.handleWriteColumnOptions = handleWriteColumnOptions;
|
|
256
330
|
// INFO: the column's own type first, then those it may become
|
|
257
331
|
var handleGetEditableColumnTypes = function (type) {
|
|
258
332
|
var _a;
|
|
@@ -377,31 +451,41 @@ var NewTable = function (props) {
|
|
|
377
451
|
//=====================================================================================
|
|
378
452
|
var _4 = (0, react_2.useState)(""), filterModal = _4[0], setFilterModal = _4[1];
|
|
379
453
|
var _5 = (0, react_2.useState)(""), addColumnModal = _5[0], setAddColumnModal = _5[1];
|
|
454
|
+
// INFO: what a DataTemplate around the table lets a cell save
|
|
455
|
+
var columnTypeActions = (0, react_2.useContext)(context_1.ColumnTypeContext);
|
|
380
456
|
var _6 = (0, react_2.useState)(""), newColumnName = _6[0], setNewColumnName = _6[1];
|
|
381
457
|
var _7 = (0, react_2.useState)("string"), newColumnType = _7[0], setNewColumnType = _7[1];
|
|
382
458
|
var _8 = (0, react_2.useState)(""), newColumnRefSpace = _8[0], setNewColumnRefSpace = _8[1];
|
|
383
459
|
var _9 = (0, react_2.useState)(""), newColumnRefLabel = _9[0], setNewColumnRefLabel = _9[1];
|
|
384
|
-
var _10 = (0, react_2.useState)(
|
|
385
|
-
|
|
386
|
-
var
|
|
460
|
+
var _10 = (0, react_2.useState)([]), newColumnOptions = _10[0], setNewColumnOptions = _10[1];
|
|
461
|
+
// INFO: the option row whose colour palette is open
|
|
462
|
+
var _11 = (0, react_2.useState)(null), optionColourKey = _11[0], setOptionColourKey = _11[1];
|
|
463
|
+
var _12 = (0, react_2.useState)(false), newColumnRequired = _12[0], setNewColumnRequired = _12[1];
|
|
464
|
+
var _13 = (0, react_2.useState)(""), newColumnRatingMax = _13[0], setNewColumnRatingMax = _13[1];
|
|
465
|
+
var _14 = (0, react_2.useState)(""), newColumnButtonLabel = _14[0], setNewColumnButtonLabel = _14[1];
|
|
466
|
+
var _15 = (0, react_2.useState)(""), newColumnButtonColour = _15[0], setNewColumnButtonColour = _15[1];
|
|
467
|
+
var _16 = (0, react_2.useState)(""), newColumnButtonConfirm = _16[0], setNewColumnButtonConfirm = _16[1];
|
|
468
|
+
var _17 = (0, react_2.useState)(false), addingColumn = _17[0], setAddingColumn = _17[1];
|
|
387
469
|
// INFO: the formula as shown in the builder — column names, not ids
|
|
388
|
-
var
|
|
470
|
+
var _18 = (0, react_2.useState)(""), newColumnFormula = _18[0], setNewColumnFormula = _18[1];
|
|
389
471
|
var addColumnPopUpRef = (0, react_2.useRef)(null);
|
|
390
472
|
// INFO: the column being changed — empty while the panel adds a new one
|
|
391
|
-
var
|
|
473
|
+
var _19 = (0, react_2.useState)(null), editingColumn = _19[0], setEditingColumn = _19[1];
|
|
392
474
|
//=====================================================================================
|
|
393
475
|
// SECTION: Editable & Addable cells
|
|
394
476
|
//=====================================================================================
|
|
395
|
-
var
|
|
396
|
-
var
|
|
477
|
+
var _20 = (0, react_2.useState)(""), editDataRowId = _20[0], setEditDataRowId = _20[1];
|
|
478
|
+
var _21 = (0, react_2.useState)(""), editDataHeaderKey = _21[0], setEditDataHeaderKey = _21[1];
|
|
397
479
|
// INFO: an editable table used to mount an input in every cell — it read as a
|
|
398
480
|
// form, and a row click always landed on a child input. Only the hovered cell
|
|
399
481
|
// becomes its input now.
|
|
400
|
-
var
|
|
401
|
-
var
|
|
402
|
-
|
|
482
|
+
var _22 = (0, react_2.useState)(null), hoveredCell = _22[0], setHoveredCell = _22[1];
|
|
483
|
+
var _23 = (0, react_2.useState)(false), modalEditVisible = _23[0], setModalEditVisible = _23[1];
|
|
484
|
+
// INFO: whether the modal's signature pad has been drawn on
|
|
485
|
+
var _24 = (0, react_2.useState)(false), signatureSigning = _24[0], setSignatureSigning = _24[1];
|
|
486
|
+
var _25 = (0, react_2.useState)([]), collapsedGroupIds = _25[0], setCollapsedGroupIds = _25[1];
|
|
403
487
|
// INFO: rows shown per section when the sections do not page themselves
|
|
404
|
-
var
|
|
488
|
+
var _26 = (0, react_2.useState)({}), groupVisibleCounts = _26[0], setGroupVisibleCounts = _26[1];
|
|
405
489
|
// INFO: per-group scroll pagination. One sentinel element per band, observed
|
|
406
490
|
// by a single IntersectionObserver that fires props.onGroupLoadMore when a
|
|
407
491
|
// band's sentinel scrolls into view. The debounce guard stops repeat fires
|
|
@@ -417,25 +501,25 @@ var NewTable = function (props) {
|
|
|
417
501
|
var lastSelectedRowRef = (0, react_2.useRef)(null);
|
|
418
502
|
var dragSelectRef = (0, react_2.useRef)(null);
|
|
419
503
|
var suppressNextClickRef = (0, react_2.useRef)(false);
|
|
420
|
-
var
|
|
421
|
-
var
|
|
422
|
-
var
|
|
423
|
-
var
|
|
504
|
+
var _27 = (0, react_2.useState)(false), isDragSelecting = _27[0], setIsDragSelecting = _27[1];
|
|
505
|
+
var _28 = (0, react_2.useState)(0), copiedCount = _28[0], setCopiedCount = _28[1];
|
|
506
|
+
var _29 = (0, react_2.useState)({}), editDataValue = _29[0], setEditDataValue = _29[1];
|
|
507
|
+
var _30 = (0, react_2.useState)(false), editDataIsLoading = _30[0], setEditDataIsLoading = _30[1];
|
|
424
508
|
// INFO: true while the empty bottom row is being filled in; the row itself is
|
|
425
509
|
// always there in an addable table
|
|
426
|
-
var
|
|
427
|
-
var
|
|
510
|
+
var _31 = (0, react_2.useState)(false), addData = _31[0], setAddData = _31[1];
|
|
511
|
+
var _32 = (0, react_2.useState)({}), addDataValue = _32[0], setAddDataValue = _32[1];
|
|
428
512
|
// INFO: bumped after each saved row, so the next one starts with fresh
|
|
429
513
|
// inputs and its first cell takes the focus
|
|
430
|
-
var
|
|
431
|
-
var
|
|
514
|
+
var _33 = (0, react_2.useState)(0), addRowKey = _33[0], setAddRowKey = _33[1];
|
|
515
|
+
var _34 = (0, react_2.useState)({}), referencesOptions = _34[0], setReferencesOptions = _34[1];
|
|
432
516
|
// INFO: seeded options sit under the local map so a cell's own search
|
|
433
517
|
// results still win per key
|
|
434
518
|
var mergedReferencesOptions = __assign(__assign({}, ((_l = props.referencesOptions) !== null && _l !== void 0 ? _l : {})), referencesOptions);
|
|
435
|
-
var
|
|
436
|
-
var
|
|
519
|
+
var _35 = (0, react_2.useState)({}), referencesDetails = _35[0], setReferencesDetails = _35[1];
|
|
520
|
+
var _36 = (0, react_2.useState)(false), referenceLoading = _36[0], setReferenceLoading = _36[1];
|
|
437
521
|
// INFO: measured pixel widths for pinned columns without an explicit width.
|
|
438
|
-
var
|
|
522
|
+
var _37 = (0, react_2.useState)({}), measuredPinWidths = _37[0], setMeasuredPinWidths = _37[1];
|
|
439
523
|
var editDataValueRef = (0, react_2.useRef)({});
|
|
440
524
|
var editDataRowIdRef = (0, react_2.useRef)("");
|
|
441
525
|
var editDataHeaderKeyRef = (0, react_2.useRef)("");
|
|
@@ -807,7 +891,11 @@ var NewTable = function (props) {
|
|
|
807
891
|
commitAddRef.current = handleCommitAdd;
|
|
808
892
|
// INFO: a list column with a palette edits through the ordinary Select, whose
|
|
809
893
|
// options render as the same coloured tags — one dropdown for every cell
|
|
810
|
-
var handleColumnShowsTags = function (col) {
|
|
894
|
+
var handleColumnShowsTags = function (col) {
|
|
895
|
+
var _a;
|
|
896
|
+
return LIST_TYPES.includes((_a = col.type) !== null && _a !== void 0 ? _a : "string") &&
|
|
897
|
+
!!col.listSelectionColour;
|
|
898
|
+
};
|
|
811
899
|
var handleConvertColumnToDataStructure = function (cols) {
|
|
812
900
|
return cols.map(function (col) {
|
|
813
901
|
var _a;
|
|
@@ -927,6 +1015,7 @@ var NewTable = function (props) {
|
|
|
927
1015
|
};
|
|
928
1016
|
var handleModalEditClose = function () {
|
|
929
1017
|
setModalEditVisible(false);
|
|
1018
|
+
setSignatureSigning(false);
|
|
930
1019
|
editDataRowIdRef.current = "";
|
|
931
1020
|
editDataValueRef.current = {};
|
|
932
1021
|
setEditDataRowId("");
|
|
@@ -941,6 +1030,12 @@ var NewTable = function (props) {
|
|
|
941
1030
|
switch (_g.label) {
|
|
942
1031
|
case 0:
|
|
943
1032
|
columnId = editDataHeaderKey;
|
|
1033
|
+
return [4 /*yield*/, handleCheckFormInputRefs("edit")];
|
|
1034
|
+
case 1:
|
|
1035
|
+
// INFO: a signature hands over what was drawn only when its field is
|
|
1036
|
+
// checked, so the fields are checked before the value is read
|
|
1037
|
+
if (!(_g.sent()))
|
|
1038
|
+
return [2 /*return*/];
|
|
944
1039
|
value = editDataValueRef.current[columnId];
|
|
945
1040
|
isUntouchedFilesObj = value &&
|
|
946
1041
|
typeof value === "object" &&
|
|
@@ -950,12 +1045,12 @@ var NewTable = function (props) {
|
|
|
950
1045
|
((_d = (_c = value.remove) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) === 0 &&
|
|
951
1046
|
JSON.stringify(value.data) ===
|
|
952
1047
|
JSON.stringify((_f = (_e = originalDataRef.current) === null || _e === void 0 ? void 0 : _e[columnId]) !== null && _f !== void 0 ? _f : []);
|
|
953
|
-
if (!!isUntouchedFilesObj) return [3 /*break*/,
|
|
1048
|
+
if (!!isUntouchedFilesObj) return [3 /*break*/, 3];
|
|
954
1049
|
return [4 /*yield*/, handleEditDataOnBlur(columnId, editDataValueRef.current)];
|
|
955
|
-
case 1:
|
|
956
|
-
_g.sent();
|
|
957
|
-
_g.label = 2;
|
|
958
1050
|
case 2:
|
|
1051
|
+
_g.sent();
|
|
1052
|
+
_g.label = 3;
|
|
1053
|
+
case 3:
|
|
959
1054
|
handleModalEditClose();
|
|
960
1055
|
return [2 /*return*/];
|
|
961
1056
|
}
|
|
@@ -966,6 +1061,18 @@ var NewTable = function (props) {
|
|
|
966
1061
|
cloned[e.target.id] = e.target.value;
|
|
967
1062
|
handleUpdateChangeData(cloned);
|
|
968
1063
|
};
|
|
1064
|
+
var handleOnChangeMarkdown = function (id, value) {
|
|
1065
|
+
var cloned = handleGenerateClonedData();
|
|
1066
|
+
cloned[id] = value;
|
|
1067
|
+
handleUpdateChangeData(cloned);
|
|
1068
|
+
};
|
|
1069
|
+
// INFO: a drawn signature arrives as a data URL, uploaded by the save
|
|
1070
|
+
var handleSignatureComplete = function (dataURL, id) {
|
|
1071
|
+
var cloned = handleGenerateClonedData();
|
|
1072
|
+
if (dataURL)
|
|
1073
|
+
cloned[id] = dataURL;
|
|
1074
|
+
handleUpdateChangeData(cloned);
|
|
1075
|
+
};
|
|
969
1076
|
var handleOnChangeSelect = function (id, value) {
|
|
970
1077
|
var cloned = handleGenerateClonedData();
|
|
971
1078
|
cloned[id] = value;
|
|
@@ -1060,7 +1167,7 @@ var NewTable = function (props) {
|
|
|
1060
1167
|
// resize is a per-viewer preference and there is no storage for it yet.
|
|
1061
1168
|
// Tailwind cannot emit a runtime w-[Npx], so this drives an inline style and
|
|
1062
1169
|
// wins over the col.width class.
|
|
1063
|
-
var
|
|
1170
|
+
var _38 = (0, react_2.useState)({}), columnWidths = _38[0], setColumnWidths = _38[1];
|
|
1064
1171
|
var resizeRef = (0, react_2.useRef)(null);
|
|
1065
1172
|
// INFO: a consumer may deliberately set a column narrower than the default
|
|
1066
1173
|
// floor (a 40px icon column, say) — never force it wider than it was asked to
|
|
@@ -1126,7 +1233,7 @@ var NewTable = function (props) {
|
|
|
1126
1233
|
});
|
|
1127
1234
|
};
|
|
1128
1235
|
var renderAddColumnPanel = function () {
|
|
1129
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
1236
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1130
1237
|
// INFO: a caller that renders its own form keeps full control; the
|
|
1131
1238
|
// built-in one only appears when it hands over onAddColumn instead
|
|
1132
1239
|
if ((_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.renderAddColumnElements)
|
|
@@ -1147,7 +1254,7 @@ var NewTable = function (props) {
|
|
|
1147
1254
|
react_2.default.createElement("span", { className: "font-mono font-medium" }, derivedId),
|
|
1148
1255
|
taken ? " — already used by another column" : "")) : ("The field id is generated from the name")))),
|
|
1149
1256
|
react_2.default.createElement(select_1.Select, { id: "newColumnType", label: "Type", value: newColumnType, darkMode: props.darkMode, options: editingColumn
|
|
1150
|
-
?
|
|
1257
|
+
? ALL_COLUMN_TYPES.filter(function (eachType) {
|
|
1151
1258
|
return (0, exports.handleGetEditableColumnTypes)(editingColumn.type).includes(eachType.key);
|
|
1152
1259
|
})
|
|
1153
1260
|
: ADD_COLUMN_TYPES, disabled: !!editingColumn &&
|
|
@@ -1170,15 +1277,14 @@ var NewTable = function (props) {
|
|
|
1170
1277
|
setNewColumnRefLabel("");
|
|
1171
1278
|
} }),
|
|
1172
1279
|
react_2.default.createElement(select_1.Select, { id: "newColumnRefLabel", label: "Reference label", value: newColumnRefLabel, darkMode: props.darkMode, portalDropdown: true, disabled: !newColumnRefSpace, options: (_g = (_f = (_e = props.advSettings).renderReferenceLabelOptions) === null || _f === void 0 ? void 0 : _f.call(_e, newColumnRefSpace)) !== null && _g !== void 0 ? _g : [], onChange: function (value) { return setNewColumnRefLabel(value); } }))),
|
|
1173
|
-
LIST_TYPES.includes(newColumnType) && (
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
}), onChange: function (event) { var _a, _b; return setNewColumnOptions((_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ""); } })),
|
|
1280
|
+
LIST_TYPES.includes(newColumnType) && renderColumnOptions(),
|
|
1281
|
+
newColumnType === "number" && (react_2.default.createElement(textInput_1.TextInput, { id: "newColumnRatingMax", type: "number", label: "Rating Stars", placeholder: "1 - ".concat(buttonCell_1.MAX_RATING), value: newColumnRatingMax, darkMode: props.darkMode, onChange: function (event) { var _a, _b; return setNewColumnRatingMax((_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ""); } })),
|
|
1282
|
+
newColumnType === "button" && (react_2.default.createElement(react_2.default.Fragment, null,
|
|
1283
|
+
react_2.default.createElement(textInput_1.TextInput, { id: "newColumnButtonLabel", type: "text", label: "Button Label", placeholder: newColumnName.trim() || "Send", value: newColumnButtonLabel, darkMode: props.darkMode, onChange: function (event) { var _a, _b; return setNewColumnButtonLabel((_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ""); } }),
|
|
1284
|
+
react_2.default.createElement(select_1.Select, { id: "newColumnButtonColour", label: "Button Colour", value: newColumnButtonColour, darkMode: props.darkMode, portalDropdown: true, options: BUTTON_COLOUR_OPTIONS, onChange: function (value) { return setNewColumnButtonColour(value); } }),
|
|
1285
|
+
react_2.default.createElement(textInput_1.TextInput, { id: "newColumnButtonConfirm", type: "text", label: "Confirm Message", placeholder: "Send this to the customer?", value: newColumnButtonConfirm, darkMode: props.darkMode, onChange: function (event) { var _a, _b; return setNewColumnButtonConfirm((_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ""); } }))),
|
|
1180
1286
|
ASSET_TYPES.includes(newColumnType) && (react_2.default.createElement("p", { className: "-mt-2 text-xs text-gray-500" }, "Uploads are stored against this space automatically.")),
|
|
1181
|
-
newColumnType === "formula" && (react_2.default.createElement(builder_1.FormulaBuilder, { value: newColumnFormula, schema: handleGetFormulaSchema(), columnId: editingColumn === null || editingColumn === void 0 ? void 0 : editingColumn.id, previewRow: (
|
|
1287
|
+
newColumnType === "formula" && (react_2.default.createElement(builder_1.FormulaBuilder, { value: newColumnFormula, schema: handleGetFormulaSchema(), columnId: editingColumn === null || editingColumn === void 0 ? void 0 : editingColumn.id, previewRow: (_h = props.data) === null || _h === void 0 ? void 0 : _h[0], previewDisplayRow: (_j = props.spaceData) === null || _j === void 0 ? void 0 : _j[0], darkMode: props.darkMode, onChange: setNewColumnFormula })),
|
|
1182
1288
|
newColumnType !== "formula" && (react_2.default.createElement(checkbox_1.Checkbox, { id: "newColumnRequired",
|
|
1183
1289
|
// INFO: the checkbox itself is not a required field — without this it
|
|
1184
1290
|
// renders "Required *", which reads as a validation error on a toggle
|
|
@@ -1200,8 +1306,54 @@ var NewTable = function (props) {
|
|
|
1200
1306
|
addingColumn ||
|
|
1201
1307
|
!handleIsNewColumnReady(), onClick: handleSubmitNewColumn }))));
|
|
1202
1308
|
};
|
|
1309
|
+
var handleChangeOption = function (key, change) {
|
|
1310
|
+
return setNewColumnOptions(newColumnOptions.map(function (eachOption) {
|
|
1311
|
+
return eachOption.key === key ? __assign(__assign({}, eachOption), change) : eachOption;
|
|
1312
|
+
}));
|
|
1313
|
+
};
|
|
1314
|
+
var handleAddOption = function () {
|
|
1315
|
+
return setNewColumnOptions(__spreadArray(__spreadArray([], newColumnOptions, true), [
|
|
1316
|
+
{ key: handleNextOptionKey(), text: "", colour: "" },
|
|
1317
|
+
], false));
|
|
1318
|
+
};
|
|
1319
|
+
var handleRemoveOption = function (key) {
|
|
1320
|
+
setNewColumnOptions(newColumnOptions.filter(function (eachOption) { return eachOption.key !== key; }));
|
|
1321
|
+
setOptionColourKey(null);
|
|
1322
|
+
};
|
|
1323
|
+
// INFO: two options of one text could not be told apart in a cell
|
|
1324
|
+
var handleHasDuplicateOptions = function () {
|
|
1325
|
+
var texts = newColumnOptions
|
|
1326
|
+
.map(function (eachOption) { return eachOption.text.trim(); })
|
|
1327
|
+
.filter(Boolean);
|
|
1328
|
+
return new Set(texts).size !== texts.length;
|
|
1329
|
+
};
|
|
1330
|
+
var renderOptionColourPalette = function (option, index) { return (react_2.default.createElement("div", { className: "absolute right-0 top-full z-10 mt-1 grid w-44 grid-cols-5 gap-2 rounded-md border border-gray-200 bg-white p-2 shadow-lg", "data-testid": "column-option-palette-".concat(index) }, __spreadArray([""], OPTION_COLOURS, true).map(function (eachColour) { return (react_2.default.createElement("button", { key: eachColour || "none", type: "button", "aria-label": eachColour || "none", "aria-pressed": option.colour === eachColour, "data-testid": "column-option-colour-".concat(index, "-").concat(eachColour || "none"), className: "h-6 w-6 rounded-full border-2 ".concat(OPTION_SWATCH_CLASS[eachColour], " ").concat(option.colour === eachColour
|
|
1331
|
+
? "ring-2 ring-gray-500 ring-offset-1"
|
|
1332
|
+
: ""), onClick: function () {
|
|
1333
|
+
handleChangeOption(option.key, { colour: eachColour });
|
|
1334
|
+
setOptionColourKey(null);
|
|
1335
|
+
} })); }))); };
|
|
1336
|
+
var renderColumnOptions = function () { return (react_2.default.createElement("div", { className: "flex flex-col gap-y-2" },
|
|
1337
|
+
react_2.default.createElement("span", { className: "text-sm font-medium ".concat(props.darkMode ? "text-gray-200" : "text-gray-700") }, "Options"),
|
|
1338
|
+
newColumnOptions.map(function (eachOption, index) {
|
|
1339
|
+
var _a;
|
|
1340
|
+
return (react_2.default.createElement("div", { key: eachOption.key, className: "relative flex flex-row items-center gap-x-2", "data-testid": "column-option-".concat(index) },
|
|
1341
|
+
react_2.default.createElement("input", { id: "newColumnOption-".concat(index), type: "text", value: eachOption.text, placeholder: "Option", className: "block w-full min-w-0 flex-1 rounded-md border px-3 py-1.5 text-sm focus:border-primary-500 focus:outline-none focus:ring-0 ".concat(props.darkMode
|
|
1342
|
+
? "border-gray-600 bg-gray-800 text-white"
|
|
1343
|
+
: "border-gray-300"), onChange: function (event) {
|
|
1344
|
+
return handleChangeOption(eachOption.key, { text: event.target.value });
|
|
1345
|
+
} }),
|
|
1346
|
+
react_2.default.createElement("button", { type: "button", "aria-label": "Colour", "data-testid": "column-option-colour-btn-".concat(index), className: "h-6 w-6 shrink-0 rounded-full border-2 ".concat((_a = OPTION_SWATCH_CLASS[eachOption.colour]) !== null && _a !== void 0 ? _a : OPTION_SWATCH_CLASS[""]), onClick: function () {
|
|
1347
|
+
return setOptionColourKey(optionColourKey === eachOption.key ? null : eachOption.key);
|
|
1348
|
+
} }),
|
|
1349
|
+
react_2.default.createElement("button", { type: "button", "aria-label": "Remove", "data-testid": "column-option-remove-".concat(index), className: "shrink-0 text-gray-400 hover:text-red-600", onClick: function () { return handleRemoveOption(eachOption.key); } },
|
|
1350
|
+
react_2.default.createElement(solid_2.XMarkIcon, { className: "h-4 w-4" })),
|
|
1351
|
+
optionColourKey === eachOption.key &&
|
|
1352
|
+
renderOptionColourPalette(eachOption, index)));
|
|
1353
|
+
}),
|
|
1354
|
+
react_2.default.createElement(textButton_1.TextButton, { text: "Add option", className: "self-start text-sm", onClick: handleAddOption }))); };
|
|
1203
1355
|
var handleEditColumnModal = function (columnId) {
|
|
1204
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1356
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1205
1357
|
var schema = (_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.getColumnSchema) === null || _b === void 0 ? void 0 : _b.call(_a, columnId);
|
|
1206
1358
|
if (!schema)
|
|
1207
1359
|
return;
|
|
@@ -1210,13 +1362,24 @@ var NewTable = function (props) {
|
|
|
1210
1362
|
setNewColumnType((_d = schema.type) !== null && _d !== void 0 ? _d : "string");
|
|
1211
1363
|
setNewColumnRefSpace((_e = schema.referenceSpaceId) !== null && _e !== void 0 ? _e : "");
|
|
1212
1364
|
setNewColumnRefLabel((_f = schema.referenceLabel) !== null && _f !== void 0 ? _f : "");
|
|
1213
|
-
setNewColumnOptions(
|
|
1365
|
+
setNewColumnOptions((0, exports.handleReadColumnOptions)(schema));
|
|
1366
|
+
setOptionColourKey(null);
|
|
1214
1367
|
setNewColumnRequired(!schema.optional);
|
|
1368
|
+
setNewColumnRatingMax(schema.ratingMax ? String(schema.ratingMax) : "");
|
|
1369
|
+
setNewColumnButtonLabel((_g = schema.buttonLabel) !== null && _g !== void 0 ? _g : "");
|
|
1370
|
+
setNewColumnButtonColour((_h = schema.buttonColour) !== null && _h !== void 0 ? _h : "");
|
|
1371
|
+
setNewColumnButtonConfirm((_j = schema.buttonConfirm) !== null && _j !== void 0 ? _j : "");
|
|
1215
1372
|
setNewColumnFormula(schema.type === "formula"
|
|
1216
1373
|
? (0, formula_1.handleGetFormulaDisplay)(schema, handleGetFormulaSchema())
|
|
1217
1374
|
: "");
|
|
1218
1375
|
setAddColumnModal(columnId);
|
|
1219
1376
|
};
|
|
1377
|
+
var handleFitPanelToWindow = function (panel) {
|
|
1378
|
+
if (!panel)
|
|
1379
|
+
return;
|
|
1380
|
+
var top = panel.getBoundingClientRect().top;
|
|
1381
|
+
panel.style.maxHeight = "".concat(Math.max(240, window.innerHeight - top - 16), "px");
|
|
1382
|
+
};
|
|
1220
1383
|
var handleAddColumnModal = function (id) {
|
|
1221
1384
|
setAddColumnModal(id);
|
|
1222
1385
|
if (!id) {
|
|
@@ -1225,9 +1388,14 @@ var NewTable = function (props) {
|
|
|
1225
1388
|
setNewColumnType("string");
|
|
1226
1389
|
setNewColumnRefSpace("");
|
|
1227
1390
|
setNewColumnRefLabel("");
|
|
1228
|
-
setNewColumnOptions(
|
|
1391
|
+
setNewColumnOptions([]);
|
|
1392
|
+
setOptionColourKey(null);
|
|
1229
1393
|
setNewColumnRequired(false);
|
|
1230
1394
|
setNewColumnFormula("");
|
|
1395
|
+
setNewColumnRatingMax("");
|
|
1396
|
+
setNewColumnButtonLabel("");
|
|
1397
|
+
setNewColumnButtonColour("");
|
|
1398
|
+
setNewColumnButtonConfirm("");
|
|
1231
1399
|
}
|
|
1232
1400
|
};
|
|
1233
1401
|
// INFO: the stored field id is derived from what the user types rather than
|
|
@@ -1244,8 +1412,13 @@ var NewTable = function (props) {
|
|
|
1244
1412
|
.map(function (eachWord) { return eachWord.charAt(0).toUpperCase() + eachWord.slice(1); })
|
|
1245
1413
|
.join(""));
|
|
1246
1414
|
};
|
|
1415
|
+
// INFO: the record's key fields and the system columns are on every row
|
|
1416
|
+
// whether or not the table shows them, so a new column cannot claim them
|
|
1247
1417
|
var handleColumnIdTaken = function (id) {
|
|
1248
|
-
return
|
|
1418
|
+
return id === "id" ||
|
|
1419
|
+
id === "_id" ||
|
|
1420
|
+
(0, systemColumns_1.handleIsSystemColumn)(id) ||
|
|
1421
|
+
flatColumns.some(function (eachColumn) { return eachColumn.key === id; });
|
|
1249
1422
|
};
|
|
1250
1423
|
// INFO: every column a formula may read. The full model when the caller
|
|
1251
1424
|
// gives it — hidden columns are still on the row — else the shown columns.
|
|
@@ -1268,6 +1441,12 @@ var NewTable = function (props) {
|
|
|
1268
1441
|
// INFO: a reference with no target resolves nothing, so it cannot be saved
|
|
1269
1442
|
// half-built. Everything else is complete with a name and a type.
|
|
1270
1443
|
var handleIsNewColumnReady = function () {
|
|
1444
|
+
if (LIST_TYPES.includes(newColumnType) && handleHasDuplicateOptions())
|
|
1445
|
+
return false;
|
|
1446
|
+
if (newColumnType === "number" &&
|
|
1447
|
+
newColumnRatingMax.trim() &&
|
|
1448
|
+
handleParseRatingMax(newColumnRatingMax) === undefined)
|
|
1449
|
+
return false;
|
|
1271
1450
|
if (REFERENCE_TYPES.includes(newColumnType))
|
|
1272
1451
|
return !!newColumnRefSpace && !!newColumnRefLabel;
|
|
1273
1452
|
// INFO: an illegal formula would show "Error" in every row
|
|
@@ -1279,25 +1458,60 @@ var NewTable = function (props) {
|
|
|
1279
1458
|
}
|
|
1280
1459
|
return true;
|
|
1281
1460
|
};
|
|
1461
|
+
// INFO: a number column shows as stars only with a whole 1 to 10; blank
|
|
1462
|
+
// leaves it a plain number
|
|
1463
|
+
var handleParseRatingMax = function (value) {
|
|
1464
|
+
var parsed = Number(value);
|
|
1465
|
+
return value.trim() &&
|
|
1466
|
+
Number.isInteger(parsed) &&
|
|
1467
|
+
parsed >= 1 &&
|
|
1468
|
+
parsed <= buttonCell_1.MAX_RATING
|
|
1469
|
+
? parsed
|
|
1470
|
+
: undefined;
|
|
1471
|
+
};
|
|
1472
|
+
// INFO: the panel's rating and button settings on the column — kept only on
|
|
1473
|
+
// the type they belong to, and a blank one is left off rather than saved empty
|
|
1474
|
+
var handleApplyColumnSettings = function (column) {
|
|
1475
|
+
var ratingMax = newColumnType === "number"
|
|
1476
|
+
? handleParseRatingMax(newColumnRatingMax)
|
|
1477
|
+
: undefined;
|
|
1478
|
+
if (ratingMax)
|
|
1479
|
+
column.ratingMax = ratingMax;
|
|
1480
|
+
else
|
|
1481
|
+
delete column.ratingMax;
|
|
1482
|
+
var buttonSettings = [
|
|
1483
|
+
["buttonLabel", newColumnButtonLabel],
|
|
1484
|
+
["buttonColour", newColumnButtonColour],
|
|
1485
|
+
["buttonConfirm", newColumnButtonConfirm],
|
|
1486
|
+
];
|
|
1487
|
+
buttonSettings.forEach(function (_a) {
|
|
1488
|
+
var eachKey = _a[0], eachValue = _a[1];
|
|
1489
|
+
if (newColumnType === "button" && eachValue.trim())
|
|
1490
|
+
column[eachKey] = eachValue.trim();
|
|
1491
|
+
else
|
|
1492
|
+
delete column[eachKey];
|
|
1493
|
+
});
|
|
1494
|
+
return column;
|
|
1495
|
+
};
|
|
1282
1496
|
var handleSubmitNewColumn = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1283
1497
|
var id, column;
|
|
1284
|
-
var _a, _b;
|
|
1285
|
-
return __generator(this, function (
|
|
1286
|
-
switch (
|
|
1498
|
+
var _a, _b, _c;
|
|
1499
|
+
return __generator(this, function (_d) {
|
|
1500
|
+
switch (_d.label) {
|
|
1287
1501
|
case 0:
|
|
1288
1502
|
if (!editingColumn) return [3 /*break*/, 2];
|
|
1289
1503
|
return [4 /*yield*/, handleSubmitEditedColumn(editingColumn)];
|
|
1290
1504
|
case 1:
|
|
1291
|
-
|
|
1505
|
+
_d.sent();
|
|
1292
1506
|
return [2 /*return*/];
|
|
1293
1507
|
case 2:
|
|
1294
1508
|
id = handleDeriveColumnId(newColumnName);
|
|
1295
1509
|
if (!id || handleColumnIdTaken(id) || !handleIsNewColumnReady())
|
|
1296
1510
|
return [2 /*return*/];
|
|
1297
1511
|
setAddingColumn(true);
|
|
1298
|
-
|
|
1512
|
+
_d.label = 3;
|
|
1299
1513
|
case 3:
|
|
1300
|
-
|
|
1514
|
+
_d.trys.push([3, , 5, 6]);
|
|
1301
1515
|
column = {
|
|
1302
1516
|
id: id,
|
|
1303
1517
|
name: newColumnName.trim(),
|
|
@@ -1312,18 +1526,19 @@ var NewTable = function (props) {
|
|
|
1312
1526
|
column.referenceLabel = newColumnRefLabel;
|
|
1313
1527
|
}
|
|
1314
1528
|
if (LIST_TYPES.includes(newColumnType))
|
|
1315
|
-
column
|
|
1316
|
-
.split(",")
|
|
1317
|
-
.map(function (eachOption) { return eachOption.trim(); })
|
|
1318
|
-
.filter(Boolean);
|
|
1529
|
+
(0, exports.handleWriteColumnOptions)(column, newColumnOptions);
|
|
1319
1530
|
if (newColumnType === "formula") {
|
|
1320
1531
|
column.formulaExpression = (0, formula_1.handleFormulaToStorage)(newColumnFormula.trim(), handleGetFormulaSchema());
|
|
1321
1532
|
column.optional = true;
|
|
1322
1533
|
}
|
|
1534
|
+
handleApplyColumnSettings(column);
|
|
1323
1535
|
return [4 /*yield*/, ((_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onAddColumn) === null || _b === void 0 ? void 0 : _b.call(_a, column))];
|
|
1324
1536
|
case 4:
|
|
1325
|
-
|
|
1537
|
+
_d.sent();
|
|
1326
1538
|
handleAddColumnModal("");
|
|
1539
|
+
// INFO: the column is on the table now; the panel left open showed an
|
|
1540
|
+
// empty form that read as the add not having happened
|
|
1541
|
+
(_c = addColumnPopUpRef.current) === null || _c === void 0 ? void 0 : _c.handleOnClose();
|
|
1327
1542
|
return [3 /*break*/, 6];
|
|
1328
1543
|
case 5:
|
|
1329
1544
|
setAddingColumn(false);
|
|
@@ -1335,23 +1550,23 @@ var NewTable = function (props) {
|
|
|
1335
1550
|
// INFO: the column keeps everything the panel does not show; settings that
|
|
1336
1551
|
// belong to a type it no longer has are dropped with it
|
|
1337
1552
|
var handleSubmitEditedColumn = function (original) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1338
|
-
var
|
|
1339
|
-
var _a, _b, _c
|
|
1340
|
-
return __generator(this, function (
|
|
1341
|
-
switch (
|
|
1553
|
+
var source, column_1;
|
|
1554
|
+
var _a, _b, _c;
|
|
1555
|
+
return __generator(this, function (_d) {
|
|
1556
|
+
switch (_d.label) {
|
|
1342
1557
|
case 0:
|
|
1343
1558
|
if (!newColumnName.trim() || !handleIsNewColumnReady())
|
|
1344
1559
|
return [2 /*return*/];
|
|
1345
1560
|
setAddingColumn(true);
|
|
1346
|
-
|
|
1561
|
+
_d.label = 1;
|
|
1347
1562
|
case 1:
|
|
1348
|
-
|
|
1349
|
-
|
|
1563
|
+
_d.trys.push([1, , 3, 4]);
|
|
1564
|
+
source = original;
|
|
1350
1565
|
column_1 = __assign(__assign({}, original), { name: newColumnName.trim(), type: newColumnType, optional: !newColumnRequired });
|
|
1351
1566
|
if (newColumnType !== original.type)
|
|
1352
1567
|
((_a = TYPE_ONLY_KEYS[original.type]) !== null && _a !== void 0 ? _a : []).forEach(function (eachKey) { return delete column_1[eachKey]; });
|
|
1353
1568
|
if (REFERENCE_TYPES.includes(newColumnType)) {
|
|
1354
|
-
if (newColumnRefSpace !==
|
|
1569
|
+
if (newColumnRefSpace !== source.referenceSpaceId)
|
|
1355
1570
|
REFERENCE_TARGET_KEYS.forEach(function (eachKey) { return delete column_1[eachKey]; });
|
|
1356
1571
|
column_1.referenceSpaceId = newColumnRefSpace;
|
|
1357
1572
|
column_1.referenceLabel = newColumnRefLabel;
|
|
@@ -1362,25 +1577,7 @@ var NewTable = function (props) {
|
|
|
1362
1577
|
REFERENCE_TARGET_KEYS.forEach(function (eachKey) { return delete column_1[eachKey]; });
|
|
1363
1578
|
}
|
|
1364
1579
|
if (LIST_TYPES.includes(newColumnType)) {
|
|
1365
|
-
|
|
1366
|
-
// INFO: unchanged text keeps the stored options exactly — an option
|
|
1367
|
-
// holding a comma would otherwise come back split in two
|
|
1368
|
-
if (newColumnOptions !== handleJoinOptions(previous_1)) {
|
|
1369
|
-
next_1 = handleSplitOptions(newColumnOptions);
|
|
1370
|
-
column_1.listSelection = next_1;
|
|
1371
|
-
// INFO: colours and labels line up with the options by position, so
|
|
1372
|
-
// each follows its own option rather than the slot it sat in
|
|
1373
|
-
["listSelectionColour", "listSelectionLabel"].forEach(function (eachKey) {
|
|
1374
|
-
var values = source_1[eachKey];
|
|
1375
|
-
if (!values)
|
|
1376
|
-
return;
|
|
1377
|
-
var rebuilt = next_1.map(function (eachOption) { var _a; return (_a = values[previous_1.indexOf(eachOption)]) !== null && _a !== void 0 ? _a : ""; });
|
|
1378
|
-
if (rebuilt.some(Boolean))
|
|
1379
|
-
column_1[eachKey] = rebuilt;
|
|
1380
|
-
else
|
|
1381
|
-
delete column_1[eachKey];
|
|
1382
|
-
});
|
|
1383
|
-
}
|
|
1580
|
+
(0, exports.handleWriteColumnOptions)(column_1, newColumnOptions);
|
|
1384
1581
|
}
|
|
1385
1582
|
else {
|
|
1386
1583
|
delete column_1.listSelection;
|
|
@@ -1391,9 +1588,10 @@ var NewTable = function (props) {
|
|
|
1391
1588
|
column_1.formulaExpression = (0, formula_1.handleFormulaToStorage)(newColumnFormula.trim(), handleGetFormulaSchema());
|
|
1392
1589
|
column_1.optional = true;
|
|
1393
1590
|
}
|
|
1394
|
-
|
|
1591
|
+
handleApplyColumnSettings(column_1);
|
|
1592
|
+
return [4 /*yield*/, ((_c = (_b = props.advSettings) === null || _b === void 0 ? void 0 : _b.onEditColumn) === null || _c === void 0 ? void 0 : _c.call(_b, column_1))];
|
|
1395
1593
|
case 2:
|
|
1396
|
-
|
|
1594
|
+
_d.sent();
|
|
1397
1595
|
handleAddColumnModal("");
|
|
1398
1596
|
return [3 /*break*/, 4];
|
|
1399
1597
|
case 3:
|
|
@@ -2035,7 +2233,7 @@ var NewTable = function (props) {
|
|
|
2035
2233
|
flatColumns.map(function (col, colIndex) {
|
|
2036
2234
|
var _a, _b, _c;
|
|
2037
2235
|
var renderDataCell = function () {
|
|
2038
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
2236
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
2039
2237
|
// INFO: a coloured list cell is this table's to render, so it takes
|
|
2040
2238
|
// the raw value even when a display row is supplied. The list view
|
|
2041
2239
|
// builds those rows and puts a Tag in for a coloured value — an
|
|
@@ -2043,12 +2241,22 @@ var NewTable = function (props) {
|
|
|
2043
2241
|
// the column came out as a pill that could not be edited in place.
|
|
2044
2242
|
// Only the cell is redirected: the display rows still carry the Tag
|
|
2045
2243
|
// for the read view, the kanban and the grid.
|
|
2046
|
-
var cellValue = spaceRow &&
|
|
2244
|
+
var cellValue = spaceRow &&
|
|
2245
|
+
!(handleColumnShowsTags(col) &&
|
|
2246
|
+
(col.type === "list" || ((_a = props.editable) === null || _a === void 0 ? void 0 : _a.active)))
|
|
2047
2247
|
? spaceRow[col.key]
|
|
2048
2248
|
: resolveValue(row, col.key);
|
|
2049
2249
|
// INFO: first col with type "string" is never made editable
|
|
2050
|
-
var resolvedColType = (
|
|
2250
|
+
var resolvedColType = (_b = col.type) !== null && _b !== void 0 ? _b : "string";
|
|
2051
2251
|
var isActionColumn = col.key === "update" && !col.type;
|
|
2252
|
+
// INFO: a timeline is picked in its cell, as stars and timers are
|
|
2253
|
+
// used there, by whoever may update the record
|
|
2254
|
+
if (resolvedColType === "dateRange" &&
|
|
2255
|
+
columnTypeActions.canUpdate &&
|
|
2256
|
+
columnTypeActions.onUpdateCell &&
|
|
2257
|
+
!col.disabled)
|
|
2258
|
+
return (react_2.default.createElement("td", { key: col.key, "data-cell-key": col.key, className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " whitespace-nowrap ").concat((_d = (_c = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _c === void 0 ? void 0 : _c.className) !== null && _d !== void 0 ? _d : ""), style: (_e = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _e === void 0 ? void 0 : _e.style },
|
|
2259
|
+
react_2.default.createElement(dateRangeCell_1.DateRangeCell, { column: __assign(__assign({}, col), { id: col.key, name: col.title, type: "dateRange" }), rowId: (_f = row.recordId) !== null && _f !== void 0 ? _f : row.id, value: resolveValue(row, col.key) })));
|
|
2052
2260
|
// INFO: a cell whose value is already a React element (row action
|
|
2053
2261
|
// buttons, a custom control) is rendered as-is even in an editable
|
|
2054
2262
|
// table — wrapping it in an inline editor would swallow it
|
|
@@ -2057,12 +2265,13 @@ var NewTable = function (props) {
|
|
|
2057
2265
|
// so it stays read-only in an editable table too — without this an
|
|
2058
2266
|
// admin-locked (often system-filled) column was editable on hover
|
|
2059
2267
|
var isColumnLocked = !!col.disabled;
|
|
2060
|
-
|
|
2268
|
+
// INFO: a thumbnail or a file name is still the cell of a modal
|
|
2269
|
+
// field — the click opens its editor rather than the record
|
|
2270
|
+
var isModalEdit = ((_g = props.editable) === null || _g === void 0 ? void 0 : _g.active) &&
|
|
2061
2271
|
!isColumnLocked &&
|
|
2062
2272
|
!isActionColumn &&
|
|
2063
|
-
!isElementCell &&
|
|
2064
2273
|
utils_1.supportedModalEditList.includes(resolvedColType);
|
|
2065
|
-
var isObjectEdit = ((
|
|
2274
|
+
var isObjectEdit = ((_h = props.editable) === null || _h === void 0 ? void 0 : _h.active) &&
|
|
2066
2275
|
!isColumnLocked &&
|
|
2067
2276
|
!isActionColumn &&
|
|
2068
2277
|
!isElementCell &&
|
|
@@ -2074,12 +2283,12 @@ var NewTable = function (props) {
|
|
|
2074
2283
|
cellValue !== null &&
|
|
2075
2284
|
!(cellValue instanceof Date) &&
|
|
2076
2285
|
utils_1.primitiveInlineEditList.includes(resolvedColType);
|
|
2077
|
-
var isEditable = ((
|
|
2286
|
+
var isEditable = ((_j = props.editable) === null || _j === void 0 ? void 0 : _j.active) &&
|
|
2078
2287
|
!isColumnLocked &&
|
|
2079
2288
|
!isActionColumn &&
|
|
2080
2289
|
!isElementCell &&
|
|
2081
2290
|
!isUneditableShape &&
|
|
2082
|
-
!(((
|
|
2291
|
+
!(((_l = (_k = props.selectedIds) === null || _k === void 0 ? void 0 : _k.length) !== null && _l !== void 0 ? _l : 0) > 0 || props.selectAll) &&
|
|
2083
2292
|
utils_1.supportedInlineEditList.includes(resolvedColType);
|
|
2084
2293
|
var rowData = editDataRowId === row.id ? editDataValue : row;
|
|
2085
2294
|
// INFO: a list column with a palette paints the whole cell —
|
|
@@ -2092,17 +2301,17 @@ var NewTable = function (props) {
|
|
|
2092
2301
|
// INFO: an editable table renders the coloured cell as its Select in
|
|
2093
2302
|
// every row (filled while closed) so the control never swaps in and
|
|
2094
2303
|
// out; the plain block is for read-only tables and locked columns
|
|
2095
|
-
if (fillColour && (!((
|
|
2304
|
+
if (fillColour && (!((_m = props.editable) === null || _m === void 0 ? void 0 : _m.active) || isColumnLocked)) {
|
|
2096
2305
|
// INFO: a read-only table shows the same filled Select as an
|
|
2097
2306
|
// editable one, just disabled — the cell looks identical in both
|
|
2098
2307
|
// modes and the row click still navigates
|
|
2099
|
-
var readOnlyDS = __assign(__assign({}, col), { id: col.key, name: col.title, type: (
|
|
2308
|
+
var readOnlyDS = __assign(__assign({}, col), { id: col.key, name: col.title, type: (_o = col.type) !== null && _o !== void 0 ? _o : "string", showTagSelections: handleColumnShowsTags(col), disabled: true });
|
|
2100
2309
|
// INFO: navigate on click only for a genuinely read-only table. This
|
|
2101
2310
|
// branch is ALSO entered for a locked column inside an EDITABLE
|
|
2102
2311
|
// table (isColumnLocked) — there a click must leave the Select alone,
|
|
2103
2312
|
// not navigate — so the overlay is gated on !editable.active.
|
|
2104
|
-
var shouldNavigateOnClick = !((
|
|
2105
|
-
return (react_2.default.createElement("td", { key: col.key, className: "p-0 align-middle ".concat((
|
|
2313
|
+
var shouldNavigateOnClick = !((_p = props.editable) === null || _p === void 0 ? void 0 : _p.active);
|
|
2314
|
+
return (react_2.default.createElement("td", { key: col.key, className: "p-0 align-middle ".concat((_r = (_q = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _q === void 0 ? void 0 : _q.className) !== null && _r !== void 0 ? _r : ""), style: (_s = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _s === void 0 ? void 0 : _s.style },
|
|
2106
2315
|
react_2.default.createElement("div", { className: "relative w-max whitespace-nowrap p-[1px]" },
|
|
2107
2316
|
renderFormCell(row, readOnlyDS, null, {
|
|
2108
2317
|
active: true,
|
|
@@ -2124,7 +2333,7 @@ var NewTable = function (props) {
|
|
|
2124
2333
|
// INFO: share the column width source with the read-only/edit cell
|
|
2125
2334
|
// variants, otherwise an "Add" placeholder and a filled value in the
|
|
2126
2335
|
// same column resolve to different widths and the column looks ragged
|
|
2127
|
-
className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : getPinProps(col.key, false) ? "" : "whitespace-nowrap", " ").concat((
|
|
2336
|
+
className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : getPinProps(col.key, false) ? "" : "whitespace-nowrap", " ").concat((_u = (_t = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _t === void 0 ? void 0 : _t.className) !== null && _u !== void 0 ? _u : ""), style: (_v = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _v === void 0 ? void 0 : _v.style },
|
|
2128
2337
|
react_2.default.createElement("div", { className: "cursor-pointer group/modaledit flex items-center gap-x-2 min-h-6", "data-testid": "table-object-edit-".concat(col.key), onClick: function (e) {
|
|
2129
2338
|
var _a;
|
|
2130
2339
|
e.stopPropagation();
|
|
@@ -2141,7 +2350,7 @@ var NewTable = function (props) {
|
|
|
2141
2350
|
// INFO: share the column width source with the read-only/edit cell
|
|
2142
2351
|
// variants, otherwise an "Add" placeholder and a filled value in the
|
|
2143
2352
|
// same column resolve to different widths and the column looks ragged
|
|
2144
|
-
className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : getPinProps(col.key, false) ? "" : "whitespace-nowrap", " ").concat((
|
|
2353
|
+
className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : getPinProps(col.key, false) ? "" : "whitespace-nowrap", " ").concat((_x = (_w = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _w === void 0 ? void 0 : _w.className) !== null && _x !== void 0 ? _x : ""), style: (_y = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _y === void 0 ? void 0 : _y.style },
|
|
2145
2354
|
react_2.default.createElement("div", { className: "cursor-pointer group/modaledit flex items-center gap-x-2 min-h-6", "data-testid": "table-modal-edit-".concat(col.key), onClick: function (e) {
|
|
2146
2355
|
e.stopPropagation();
|
|
2147
2356
|
handleModalEditOnClick(row.id, col.key, row);
|
|
@@ -2154,7 +2363,7 @@ var NewTable = function (props) {
|
|
|
2154
2363
|
// filled pill, so there is nothing to swap to.
|
|
2155
2364
|
if (isEditable &&
|
|
2156
2365
|
(handleColumnShowsTags(col) || handleIsCellLive(row.id, col.key))) {
|
|
2157
|
-
var bareOverride = (
|
|
2366
|
+
var bareOverride = (_0 = (_z = props.bareSettings) === null || _z === void 0 ? void 0 : _z.bareListDescription) === null || _0 === void 0 ? void 0 : _0.call(_z, col.key, cellValue);
|
|
2158
2367
|
if (!bareOverride)
|
|
2159
2368
|
return renderEditDataInputs(colIndex, col, rowData, row.id, rowBgClass, isRowHoverable);
|
|
2160
2369
|
}
|
|
@@ -2162,7 +2371,7 @@ var NewTable = function (props) {
|
|
|
2162
2371
|
// INFO: pinned columns use whitespace-normal so text wraps within the fixed width
|
|
2163
2372
|
react_2.default.createElement("td", __assign({ key: col.key }, (isEditable ? handleCellHoverProps(row.id, col.key) : {}), { "data-cell-key": col.key, "data-pin-key": leftPinned.includes(col.key) || rightPinned.includes(col.key)
|
|
2164
2373
|
? col.key
|
|
2165
|
-
: undefined, className: "".concat(cellPadding, " ").concat(isEditable ? "".concat(editCellMinHeight, " align-middle ").concat(handleCellMinWidth(col.type)) : "", " text-sm ").concat(colIndex === 0 && props.onClickRow ? titleFontColor : cellFontColor, " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : getPinProps(col.key, false) ? "" : "whitespace-nowrap", " ").concat((
|
|
2374
|
+
: undefined, className: "".concat(cellPadding, " ").concat(isEditable ? "".concat(editCellMinHeight, " align-middle ").concat(handleCellMinWidth(col.type)) : "", " text-sm ").concat(colIndex === 0 && props.onClickRow ? titleFontColor : cellFontColor, " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : getPinProps(col.key, false) ? "" : "whitespace-nowrap", " ").concat((_2 = (_1 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _1 === void 0 ? void 0 : _1.className) !== null && _2 !== void 0 ? _2 : ""), style: (_3 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _3 === void 0 ? void 0 : _3.style, "data-row-link-cell": props.newTabUrl && props.onClickRow ? "" : undefined }), props.newTabUrl && props.onClickRow ? (react_2.default.createElement(link_1.Link, { href: props.newTabUrl + row.id + ((_4 = props.addNewTabUrl) !== null && _4 !== void 0 ? _4 : ""), className: "w-full block", linkType: props.linkType, custom: props.custom }, (0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord))) : ((0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, cellValue, props.bareSettings, true, props.disableEllipsisOnLongWord))));
|
|
2166
2375
|
};
|
|
2167
2376
|
var cell = renderDataCell();
|
|
2168
2377
|
if (colIndex !== 0 || !props.onRowActivity)
|
|
@@ -2427,7 +2636,10 @@ var NewTable = function (props) {
|
|
|
2427
2636
|
// padding. The button (36px) then fits the 56px pinned width.
|
|
2428
2637
|
className: "!px-2 !py-2 whitespace-nowrap text-left text-xs font-semibold uppercase tracking-wide ".concat(cursorClassname, " ").concat(handleGetAddColumnPin(true).className), style: handleGetAddColumnPin(true).style, rowSpan: hasGroupHeaders ? 2 : undefined },
|
|
2429
2638
|
react_2.default.createElement("div", { className: "hidden flex-row items-center md:flex" },
|
|
2430
|
-
react_2.default.createElement(popUp_1.PopUp, { ref: addColumnPopUpRef, darkMode: props.darkMode, darkModeBg: props.darkModeBg, anchor: "right", portal: true, lib: { Transition: react_1.Transition }, excludePortalIds: ["select-portal"], ctaComp: react_2.default.createElement(iconButton_1.IconButton, { testId: "table-add-column-btn", icon: react_2.default.createElement(solid_1.PlusIcon, { className: "h-5 w-5 text-gray" }) }), renderComp:
|
|
2639
|
+
react_2.default.createElement(popUp_1.PopUp, { ref: addColumnPopUpRef, darkMode: props.darkMode, darkModeBg: props.darkModeBg, anchor: "right", portal: true, lib: { Transition: react_1.Transition }, excludePortalIds: ["select-portal"], ctaComp: react_2.default.createElement(iconButton_1.IconButton, { testId: "table-add-column-btn", icon: react_2.default.createElement(solid_1.PlusIcon, { className: "h-5 w-5 text-gray" }) }), renderComp:
|
|
2640
|
+
// INFO: a button or list column's settings run past a short
|
|
2641
|
+
// screen, so the panel ends at the window's edge and scrolls
|
|
2642
|
+
react_2.default.createElement("div", { ref: handleFitPanelToWindow, className: "w-80 overflow-y-auto p-4 normal-case tracking-normal" }, renderAddColumnPanel()) })),
|
|
2431
2643
|
react_2.default.createElement("div", { className: "flex flex-row items-center md:hidden" },
|
|
2432
2644
|
react_2.default.createElement(iconButton_1.IconButton, { testId: "table-add-column-btn-mobile", icon: react_2.default.createElement(solid_1.PlusIcon, { className: "h-5 w-5 text-gray" }), onClick: function () { return handleAddColumnModal("new"); } }))));
|
|
2433
2645
|
};
|
|
@@ -2694,6 +2906,8 @@ var NewTable = function (props) {
|
|
|
2694
2906
|
handleOnChangeDate: handleOnChangeDate,
|
|
2695
2907
|
handleOnChangeFile: handleOnChangeFile,
|
|
2696
2908
|
handleOnChangeFiles: handleOnChangeFiles,
|
|
2909
|
+
handleOnChangeMarkdown: handleOnChangeMarkdown,
|
|
2910
|
+
handleSignatureComplete: handleSignatureComplete,
|
|
2697
2911
|
}, true, undefined, {
|
|
2698
2912
|
id: editDataRowId,
|
|
2699
2913
|
type: "list",
|
|
@@ -2711,7 +2925,7 @@ var NewTable = function (props) {
|
|
|
2711
2925
|
imageEndpoint: (_b = (_a = props.devSettings) === null || _a === void 0 ? void 0 : _a.imageEndpoint) !== null && _b !== void 0 ? _b : "",
|
|
2712
2926
|
imageBucketName: (_c = props.devSettings) === null || _c === void 0 ? void 0 : _c.bucketName,
|
|
2713
2927
|
maxFileSize: (_d = props.devSettings) === null || _d === void 0 ? void 0 : _d.maxFileSize,
|
|
2714
|
-
}),
|
|
2928
|
+
}, undefined, { signing: signatureSigning, setSigning: setSignatureSigning }),
|
|
2715
2929
|
react_2.default.createElement("div", { className: "flex justify-end gap-3", "data-testid": "table-modal-editor-actions" },
|
|
2716
2930
|
react_2.default.createElement(button_1.Button, { text: "Cancel", type: "light", onClick: handleModalEditClose }),
|
|
2717
2931
|
react_2.default.createElement(button_1.Button, { text: editDataIsLoading ? "Saving" : "Save", type: "normal", disable: editDataIsLoading, onClick: handleModalEditSave }))));
|