blixify-ui-web 1.2.260 → 1.2.262
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/dataTemplate/dataStateModel.d.ts +1 -0
- package/lib/components/data/dataTemplate/dataStateModel.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/dataStateModel.js.map +1 -1
- package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +95 -47
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/model.d.ts +2 -0
- package/lib/components/data/dataTemplate/model.d.ts.map +1 -1
- package/lib/components/data/dataWrapper/index.d.ts +1 -0
- package/lib/components/data/dataWrapper/index.d.ts.map +1 -1
- package/lib/components/data/dataWrapper/index.js +2 -2
- package/lib/components/data/dataWrapper/index.js.map +1 -1
- package/lib/components/data/updateModule.d.ts +20 -2
- package/lib/components/data/updateModule.d.ts.map +1 -1
- package/lib/components/data/updateModule.js +155 -58
- package/lib/components/data/updateModule.js.map +1 -1
- package/lib/components/display/drawer/index.d.ts +25 -0
- package/lib/components/display/drawer/index.d.ts.map +1 -1
- package/lib/components/display/drawer/index.js +223 -4
- package/lib/components/display/drawer/index.js.map +1 -1
- package/lib/components/display/newTable/columnMenu.d.ts +28 -0
- package/lib/components/display/newTable/columnMenu.d.ts.map +1 -0
- package/lib/components/display/newTable/columnMenu.js +197 -0
- package/lib/components/display/newTable/columnMenu.js.map +1 -0
- package/lib/components/display/newTable/columnWidth.d.ts +7 -0
- package/lib/components/display/newTable/columnWidth.d.ts.map +1 -1
- package/lib/components/display/newTable/columnWidth.js +12 -1
- package/lib/components/display/newTable/columnWidth.js.map +1 -1
- package/lib/components/display/newTable/columnWindow.d.ts +42 -0
- package/lib/components/display/newTable/columnWindow.d.ts.map +1 -0
- package/lib/components/display/newTable/columnWindow.js +84 -0
- package/lib/components/display/newTable/columnWindow.js.map +1 -0
- package/lib/components/display/newTable/index.d.ts +2 -0
- package/lib/components/display/newTable/index.d.ts.map +1 -1
- package/lib/components/display/newTable/index.js +717 -218
- package/lib/components/display/newTable/index.js.map +1 -1
- package/lib/components/display/newTable/rowRendering.d.ts +13 -0
- package/lib/components/display/newTable/rowRendering.d.ts.map +1 -1
- package/lib/components/display/newTable/rowRendering.js +28 -1
- package/lib/components/display/newTable/rowRendering.js.map +1 -1
- package/lib/components/display/recordActions/index.d.ts.map +1 -1
- package/lib/components/display/recordActions/index.js +25 -21
- package/lib/components/display/recordActions/index.js.map +1 -1
- package/lib/components/input/select/index.d.ts +1 -0
- package/lib/components/input/select/index.d.ts.map +1 -1
- package/lib/components/input/select/index.js +24 -4
- package/lib/components/input/select/index.js.map +1 -1
- package/lib/tail.css +2 -2
- package/package.json +1 -1
|
@@ -128,7 +128,9 @@ var modal_1 = require("../modal");
|
|
|
128
128
|
var newPagination_1 = require("../newPagination");
|
|
129
129
|
var recordActions_1 = require("../recordActions");
|
|
130
130
|
var scrollShadow_1 = require("../scrollShadow");
|
|
131
|
+
var columnMenu_1 = require("./columnMenu");
|
|
131
132
|
var columnWidth_1 = require("./columnWidth");
|
|
133
|
+
var columnWindow_1 = require("./columnWindow");
|
|
132
134
|
var labelPicker_1 = require("./labelPicker");
|
|
133
135
|
var tagLine_1 = require("./tagLine");
|
|
134
136
|
var tag_1 = require("../tag");
|
|
@@ -389,30 +391,22 @@ exports.handleGetEditableColumnTypes = handleGetEditableColumnTypes;
|
|
|
389
391
|
// padding, so the room for the title's actions is an !important class too —
|
|
390
392
|
// without it a squeezed title (a pinned column on a phone) runs under them
|
|
391
393
|
var TITLE_ACTIONS_PADDING_CLASS = {
|
|
392
|
-
8: "!pr-[8px]",
|
|
393
394
|
48: "!pr-[48px]",
|
|
394
395
|
52: "!pr-[52px]",
|
|
395
396
|
92: "!pr-[92px]",
|
|
396
397
|
96: "!pr-[96px]",
|
|
397
398
|
136: "!pr-[136px]",
|
|
398
399
|
};
|
|
399
|
-
// INFO:
|
|
400
|
-
|
|
401
|
-
// editor make room for it instead of running under it
|
|
402
|
-
var TITLE_CHEVRON_PADDING_CLASS = {
|
|
403
|
-
48: "group-hover:!pr-[48px] focus-within:!pr-[48px] [@media(hover:none)]:!pr-[48px]",
|
|
404
|
-
92: "group-hover:!pr-[92px] focus-within:!pr-[92px] [@media(hover:none)]:!pr-[92px]",
|
|
405
|
-
136: "group-hover:!pr-[136px] focus-within:!pr-[136px] [@media(hover:none)]:!pr-[136px]",
|
|
406
|
-
};
|
|
407
|
-
// INFO: the chevron's width plus its gap from the strips
|
|
408
|
-
var CHEVRON_ROOM = 40;
|
|
400
|
+
// INFO: the eye's width plus its gap from the strips
|
|
401
|
+
var EYE_ROOM = 40;
|
|
409
402
|
// INFO: the title text a narrowed title column always keeps beside its actions
|
|
410
403
|
var MIN_TITLE_TEXT_WIDTH = 48;
|
|
411
404
|
// INFO: the cell padding's left side (!px-6)
|
|
412
405
|
var TITLE_LEFT_PADDING = 24;
|
|
413
406
|
// INFO: the pencil and the comment bubble each sit in their own full-height
|
|
414
407
|
// strip at the title cell's right edge, split by dividers like columns of
|
|
415
|
-
// their own — pencil, then bubble at the edge
|
|
408
|
+
// their own — pencil, then bubble at the edge. The eye sits just left of them
|
|
409
|
+
// with no divider of its own.
|
|
416
410
|
var ACTION_STRIP_WIDTH = 44;
|
|
417
411
|
var ACCENT_CLASS = {
|
|
418
412
|
default: "border-primary-500",
|
|
@@ -464,6 +458,42 @@ var FILL_INPUT_TYPES = [
|
|
|
464
458
|
"listPerson",
|
|
465
459
|
"referenceSelection",
|
|
466
460
|
];
|
|
461
|
+
// INFO: what each column type a cell's "x" can clear saves once cleared. A
|
|
462
|
+
// yes/no is left out — an emptied one reads as a third state beside yes and
|
|
463
|
+
// no — and so is a rating, which is cleared from its stars. A coloured list
|
|
464
|
+
// has its blank block, and pictures, files, signatures and the parts of an
|
|
465
|
+
// address or object are each removed on their own. A column's default only
|
|
466
|
+
// prefills a new record, so a cleared cell stays empty whatever its default.
|
|
467
|
+
var CLEAR_CELL_VALUES = {
|
|
468
|
+
string: function () { return ""; },
|
|
469
|
+
email: function () { return ""; },
|
|
470
|
+
textArea: function () { return ""; },
|
|
471
|
+
contact: function () { return ""; },
|
|
472
|
+
list: function () { return ""; },
|
|
473
|
+
person: function () { return ""; },
|
|
474
|
+
number: function () { return null; },
|
|
475
|
+
date: function () { return null; },
|
|
476
|
+
reference: function () { return null; },
|
|
477
|
+
referenceSelection: function () { return null; },
|
|
478
|
+
multipleList: function () { return []; },
|
|
479
|
+
listReference: function () { return []; },
|
|
480
|
+
listPerson: function () { return []; },
|
|
481
|
+
roles: function () { return []; },
|
|
482
|
+
};
|
|
483
|
+
var CLEAR_OPEN_EDITOR_TYPES = [
|
|
484
|
+
"string",
|
|
485
|
+
"email",
|
|
486
|
+
"textArea",
|
|
487
|
+
"contact",
|
|
488
|
+
"number",
|
|
489
|
+
"date",
|
|
490
|
+
];
|
|
491
|
+
var handleIsEmptyCellValue = function (value) {
|
|
492
|
+
return value === undefined ||
|
|
493
|
+
value === null ||
|
|
494
|
+
value === "" ||
|
|
495
|
+
(Array.isArray(value) && value.length === 0);
|
|
496
|
+
};
|
|
467
497
|
// INFO: drops the field's own box — background, rounded corners and the
|
|
468
498
|
// hover / focus border — so the text is typed straight into the cell; an
|
|
469
499
|
// errored field keeps its red border. The cell's ring shows which one is open.
|
|
@@ -517,7 +547,7 @@ var handleGetListColour = function (col, value) {
|
|
|
517
547
|
return column.listSelectionColour[index] || undefined;
|
|
518
548
|
};
|
|
519
549
|
var NewTable = function (rawProps) {
|
|
520
|
-
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;
|
|
550
|
+
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;
|
|
521
551
|
// INFO: props are read through the latest render. A row that was not drawn
|
|
522
552
|
// again keeps the handlers of the render that drew it, and those read
|
|
523
553
|
// props.onClickRow, props.data and the rest at the time they run — so a
|
|
@@ -618,57 +648,56 @@ var NewTable = function (rawProps) {
|
|
|
618
648
|
flatColumns.length = 0;
|
|
619
649
|
flatColumns.push.apply(flatColumns, __spreadArray(__spreadArray(__spreadArray([], leftCols, false), middleCols, false), rightCols, false));
|
|
620
650
|
}
|
|
621
|
-
var
|
|
651
|
+
var _4 = (0, react_2.useState)(props.fixedPagination ? true : false), isFixed = _4[0], setIsFixed = _4[1];
|
|
622
652
|
// INFO: the actions sit over the title cell's right padding: the pencil and
|
|
623
|
-
// the bubble in divided strips at the edge,
|
|
624
|
-
// clear so they never cover the title, and added to
|
|
625
|
-
// width so the title keeps its own width instead of
|
|
626
|
-
//
|
|
627
|
-
//
|
|
628
|
-
// the column is sized and floored for that wider padding.
|
|
653
|
+
// the bubble in divided strips at the edge, the eye just left of them, then
|
|
654
|
+
// 8px from the text — kept clear so they never cover the title, and added to
|
|
655
|
+
// the cell's measured width so the title keeps its own width instead of
|
|
656
|
+
// wrapping. All of them always show: users missed an eye that showed only on
|
|
657
|
+
// hover and reached for the pencil to view a record.
|
|
629
658
|
var hasRowActions = !!props.onRowEdit || !!props.onRowOpen || !!props.onRowActivity;
|
|
630
659
|
var canDragRows = !!props.onMoveRowToGroup && !!((_g = props.groups) === null || _g === void 0 ? void 0 : _g.length);
|
|
631
660
|
var activityStripWidth = props.onRowActivity ? ACTION_STRIP_WIDTH : 0;
|
|
632
661
|
var editStripWidth = props.onRowEdit ? ACTION_STRIP_WIDTH : 0;
|
|
662
|
+
var titleStripsWidth = activityStripWidth + editStripWidth;
|
|
633
663
|
var titleActionsWidth = hasRowActions
|
|
634
|
-
?
|
|
664
|
+
? titleStripsWidth + 8 + (props.onRowOpen ? EYE_ROOM : 0)
|
|
635
665
|
: 0;
|
|
636
|
-
var titleChevronActionsWidth = titleActionsWidth + (props.onRowOpen ? CHEVRON_ROOM : 0);
|
|
637
666
|
//=====================================================================================
|
|
638
667
|
// SECTION: Advanced Settings
|
|
639
668
|
//=====================================================================================
|
|
640
|
-
var
|
|
641
|
-
var
|
|
669
|
+
var _5 = (0, react_2.useState)(""), filterModal = _5[0], setFilterModal = _5[1];
|
|
670
|
+
var _6 = (0, react_2.useState)(""), addColumnModal = _6[0], setAddColumnModal = _6[1];
|
|
642
671
|
// INFO: what a DataTemplate around the table lets a cell save
|
|
643
672
|
var columnTypeActions = (0, react_2.useContext)(context_1.ColumnTypeContext);
|
|
644
|
-
var
|
|
645
|
-
var
|
|
646
|
-
var
|
|
647
|
-
var
|
|
648
|
-
var
|
|
649
|
-
var
|
|
650
|
-
var
|
|
673
|
+
var _7 = (0, react_2.useState)(""), newColumnName = _7[0], setNewColumnName = _7[1];
|
|
674
|
+
var _8 = (0, react_2.useState)("string"), newColumnType = _8[0], setNewColumnType = _8[1];
|
|
675
|
+
var _9 = (0, react_2.useState)(""), newColumnRefSpace = _9[0], setNewColumnRefSpace = _9[1];
|
|
676
|
+
var _10 = (0, react_2.useState)(""), newColumnRefLabel = _10[0], setNewColumnRefLabel = _10[1];
|
|
677
|
+
var _11 = (0, react_2.useState)(""), newColumnLookupReference = _11[0], setNewColumnLookupReference = _11[1];
|
|
678
|
+
var _12 = (0, react_2.useState)(""), newColumnLookupField = _12[0], setNewColumnLookupField = _12[1];
|
|
679
|
+
var _13 = (0, react_2.useState)([]), newColumnOptions = _13[0], setNewColumnOptions = _13[1];
|
|
651
680
|
// INFO: the option row whose colour palette is open
|
|
652
|
-
var
|
|
653
|
-
var
|
|
654
|
-
var
|
|
655
|
-
var
|
|
656
|
-
var
|
|
657
|
-
var
|
|
658
|
-
var
|
|
659
|
-
var
|
|
660
|
-
var
|
|
661
|
-
var
|
|
681
|
+
var _14 = (0, react_2.useState)(null), optionColourKey = _14[0], setOptionColourKey = _14[1];
|
|
682
|
+
var _15 = (0, react_2.useState)(false), newColumnRequired = _15[0], setNewColumnRequired = _15[1];
|
|
683
|
+
var _16 = (0, react_2.useState)(false), newColumnUnique = _16[0], setNewColumnUnique = _16[1];
|
|
684
|
+
var _17 = (0, react_2.useState)(false), newColumnReadOnly = _17[0], setNewColumnReadOnly = _17[1];
|
|
685
|
+
var _18 = (0, react_2.useState)(""), newColumnRatingMax = _18[0], setNewColumnRatingMax = _18[1];
|
|
686
|
+
var _19 = (0, react_2.useState)(""), newColumnButtonLabel = _19[0], setNewColumnButtonLabel = _19[1];
|
|
687
|
+
var _20 = (0, react_2.useState)(""), newColumnButtonColour = _20[0], setNewColumnButtonColour = _20[1];
|
|
688
|
+
var _21 = (0, react_2.useState)(""), newColumnButtonConfirm = _21[0], setNewColumnButtonConfirm = _21[1];
|
|
689
|
+
var _22 = (0, react_2.useState)(false), addingColumn = _22[0], setAddingColumn = _22[1];
|
|
690
|
+
var _23 = (0, react_2.useState)(false), confirmDeleteColumn = _23[0], setConfirmDeleteColumn = _23[1];
|
|
662
691
|
// INFO: the formula as shown in the builder — column names, not ids
|
|
663
|
-
var
|
|
692
|
+
var _24 = (0, react_2.useState)(""), newColumnFormula = _24[0], setNewColumnFormula = _24[1];
|
|
664
693
|
var addColumnPopUpRef = (0, react_2.useRef)(null);
|
|
665
694
|
// INFO: the column being changed — empty while the panel adds a new one
|
|
666
|
-
var
|
|
695
|
+
var _25 = (0, react_2.useState)(null), editingColumn = _25[0], setEditingColumn = _25[1];
|
|
667
696
|
//=====================================================================================
|
|
668
697
|
// SECTION: Editable & Addable cells
|
|
669
698
|
//=====================================================================================
|
|
670
|
-
var
|
|
671
|
-
var
|
|
699
|
+
var _26 = (0, react_2.useState)(""), editDataRowId = _26[0], setEditDataRowId = _26[1];
|
|
700
|
+
var _27 = (0, react_2.useState)(""), editDataHeaderKey = _27[0], setEditDataHeaderKey = _27[1];
|
|
672
701
|
// INFO: an editable table used to mount an input in every cell — it read as a
|
|
673
702
|
// form, and a row click always landed on a child input. Only the hovered cell
|
|
674
703
|
// becomes its input now; NewTableHoverCell keeps that hover to itself.
|
|
@@ -677,13 +706,13 @@ var NewTable = function (rawProps) {
|
|
|
677
706
|
var pendingFocusRef = (0, react_2.useRef)("");
|
|
678
707
|
// INFO: the cell a gridLines="all" multiple list is being picked in — its
|
|
679
708
|
// popover hangs from this element
|
|
680
|
-
var
|
|
681
|
-
var
|
|
709
|
+
var _28 = (0, react_2.useState)(null), labelPickerAnchor = _28[0], setLabelPickerAnchor = _28[1];
|
|
710
|
+
var _29 = (0, react_2.useState)(false), modalEditVisible = _29[0], setModalEditVisible = _29[1];
|
|
682
711
|
// INFO: whether the modal's signature pad has been drawn on
|
|
683
|
-
var
|
|
684
|
-
var
|
|
712
|
+
var _30 = (0, react_2.useState)(false), signatureSigning = _30[0], setSignatureSigning = _30[1];
|
|
713
|
+
var _31 = (0, react_2.useState)([]), collapsedGroupIds = _31[0], setCollapsedGroupIds = _31[1];
|
|
685
714
|
// INFO: rows shown per section when the sections do not page themselves
|
|
686
|
-
var
|
|
715
|
+
var _32 = (0, react_2.useState)({}), groupVisibleCounts = _32[0], setGroupVisibleCounts = _32[1];
|
|
687
716
|
// INFO: per-group scroll pagination. One sentinel element per band, observed
|
|
688
717
|
// by a single IntersectionObserver that fires props.onGroupLoadMore when a
|
|
689
718
|
// band's sentinel scrolls into view. The debounce guard stops repeat fires
|
|
@@ -701,36 +730,36 @@ var NewTable = function (rawProps) {
|
|
|
701
730
|
var lastSelectedRowRef = (0, react_2.useRef)(null);
|
|
702
731
|
var dragSelectRef = (0, react_2.useRef)(null);
|
|
703
732
|
var suppressNextClickRef = (0, react_2.useRef)(false);
|
|
704
|
-
var
|
|
705
|
-
var
|
|
706
|
-
var
|
|
707
|
-
var
|
|
733
|
+
var _33 = (0, react_2.useState)(false), isDragSelecting = _33[0], setIsDragSelecting = _33[1];
|
|
734
|
+
var _34 = (0, react_2.useState)(0), copiedCount = _34[0], setCopiedCount = _34[1];
|
|
735
|
+
var _35 = (0, react_2.useState)({}), editDataValue = _35[0], setEditDataValue = _35[1];
|
|
736
|
+
var _36 = (0, react_2.useState)(false), editDataIsLoading = _36[0], setEditDataIsLoading = _36[1];
|
|
708
737
|
// INFO: true while the empty bottom row is being filled in; the row itself is
|
|
709
738
|
// always there in an addable table
|
|
710
|
-
var
|
|
739
|
+
var _37 = (0, react_2.useState)(false), addData = _37[0], setAddData = _37[1];
|
|
711
740
|
var isAddRowPinned = props.paginationType === "scroll";
|
|
712
|
-
var
|
|
741
|
+
var _38 = (0, react_2.useState)({}), addDataValue = _38[0], setAddDataValue = _38[1];
|
|
713
742
|
// INFO: bumped after each saved row, so the next one starts with fresh
|
|
714
743
|
// inputs and its first cell takes the focus
|
|
715
|
-
var
|
|
744
|
+
var _39 = (0, react_2.useState)(0), addRowKey = _39[0], setAddRowKey = _39[1];
|
|
716
745
|
// INFO: the add row's coloured multiple list being picked under
|
|
717
746
|
// gridLines="all" — its label picker hangs from this cell
|
|
718
747
|
// INFO: the new row's required tag columns left empty on a save — their
|
|
719
748
|
// cells are ringed red until a label is picked
|
|
720
|
-
var
|
|
721
|
-
var
|
|
749
|
+
var _40 = (0, react_2.useState)([]), addTagErrors = _40[0], setAddTagErrors = _40[1];
|
|
750
|
+
var _41 = (0, react_2.useState)(null), addLabelPicker = _41[0], setAddLabelPicker = _41[1];
|
|
722
751
|
// INFO: the group whose own add row is being filled in; "" = the bottom row
|
|
723
|
-
var
|
|
752
|
+
var _42 = (0, react_2.useState)(""), addGroupId = _42[0], setAddGroupId = _42[1];
|
|
724
753
|
// INFO: the row armed by a press on its handle, so only the handle — never
|
|
725
754
|
// a click or a text selection in a cell — starts a drag
|
|
726
|
-
var
|
|
727
|
-
var
|
|
728
|
-
var
|
|
729
|
-
var
|
|
755
|
+
var _43 = (0, react_2.useState)(""), dragArmedRowId = _43[0], setDragArmedRowId = _43[1];
|
|
756
|
+
var _44 = (0, react_2.useState)(""), draggingRowId = _44[0], setDraggingRowId = _44[1];
|
|
757
|
+
var _45 = (0, react_2.useState)(""), dropGroupId = _45[0], setDropGroupId = _45[1];
|
|
758
|
+
var _46 = (0, react_2.useState)({}), referencesOptions = _46[0], setReferencesOptions = _46[1];
|
|
730
759
|
// INFO: seeded options sit under the local map so a cell's own search
|
|
731
760
|
// results still win per key
|
|
732
761
|
var mergedReferencesOptions = __assign(__assign({}, ((_h = props.referencesOptions) !== null && _h !== void 0 ? _h : {})), referencesOptions);
|
|
733
|
-
var
|
|
762
|
+
var _47 = (0, react_2.useState)({}), referencesDetails = _47[0], setReferencesDetails = _47[1];
|
|
734
763
|
// INFO: per column, the records a search found and the records the parent
|
|
735
764
|
// passes in, matched by id — a search copies the parent's records into the
|
|
736
765
|
// local map, so the parent's copy wins and a reload of the list reaches the
|
|
@@ -740,13 +769,13 @@ var NewTable = function (rawProps) {
|
|
|
740
769
|
var mergedReferencesDetails = (0, react_2.useMemo)(function () {
|
|
741
770
|
return handleMergeReferencesDetails(referencesDetails, props.referencesDetails);
|
|
742
771
|
}, [referencesDetails, props.referencesDetails]);
|
|
743
|
-
var
|
|
772
|
+
var _48 = (0, react_2.useState)(false), referenceLoading = _48[0], setReferenceLoading = _48[1];
|
|
744
773
|
// INFO: measured pixel widths for pinned columns without an explicit width.
|
|
745
|
-
var
|
|
774
|
+
var _49 = (0, react_2.useState)({}), measuredPinWidths = _49[0], setMeasuredPinWidths = _49[1];
|
|
746
775
|
// INFO: the scrolling view's width, which caps how much the left pins take
|
|
747
|
-
var
|
|
776
|
+
var _50 = (0, react_2.useState)(0), pinViewWidth = _50[0], setPinViewWidth = _50[1];
|
|
748
777
|
// INFO: per large group, the rows [start, end) drawn; the rest are spacers
|
|
749
|
-
var
|
|
778
|
+
var _51 = (0, react_2.useState)({}), virtualRanges = _51[0], setVirtualRanges = _51[1];
|
|
750
779
|
// INFO: each drawn row's measured height, kept so a spacer is as tall as the
|
|
751
780
|
// rows it stands in for
|
|
752
781
|
var rowHeightsRef = (0, react_2.useRef)(new Map());
|
|
@@ -754,10 +783,28 @@ var NewTable = function (rawProps) {
|
|
|
754
783
|
var virtualGroupsRef = (0, react_2.useRef)([]);
|
|
755
784
|
var virtualFrameRef = (0, react_2.useRef)(0);
|
|
756
785
|
var rowEstimateRef = (0, react_2.useRef)(rowRendering_1.VIRTUAL_DEFAULT_ROW_HEIGHT);
|
|
786
|
+
// INFO: on a wide table, where the scroller shows the unpinned columns —
|
|
787
|
+
// its left edge as an offset from the first of them, and its width. Set only
|
|
788
|
+
// when the drawn columns no longer cover it, so scrolling inside them draws
|
|
789
|
+
// nothing
|
|
790
|
+
var _52 = (0, react_2.useState)(null), columnView = _52[0], setColumnView = _52[1];
|
|
791
|
+
// INFO: each drawn unpinned column's measured width, so a spacer is as wide
|
|
792
|
+
// as the columns it stands in for
|
|
793
|
+
var columnWidthsMeasuredRef = (0, react_2.useRef)({});
|
|
794
|
+
var columnFrameRef = (0, react_2.useRef)(0);
|
|
795
|
+
// INFO: set each draw — the scroll listener is set up once and reads these
|
|
796
|
+
var isColumnVirtualRef = (0, react_2.useRef)(false);
|
|
797
|
+
var columnWindowForRef = (0, react_2.useRef)(function () { return null; });
|
|
757
798
|
var tableVersionRef = (0, react_2.useRef)({
|
|
758
799
|
key: "",
|
|
759
800
|
version: 0,
|
|
760
801
|
});
|
|
802
|
+
// INFO: the table version without the column window — a body cell compares
|
|
803
|
+
// it, so moving the window redraws rows but not the cells they keep
|
|
804
|
+
var cellVersionRef = (0, react_2.useRef)({
|
|
805
|
+
key: "",
|
|
806
|
+
version: 0,
|
|
807
|
+
});
|
|
761
808
|
var editDataValueRef = (0, react_2.useRef)({});
|
|
762
809
|
// INFO: the check a cell's blur is running — under gridLines="all" the next
|
|
763
810
|
// cell opens only once it is done, while the field it checks still exists
|
|
@@ -821,6 +868,36 @@ var NewTable = function (rawProps) {
|
|
|
821
868
|
handleUpdateVirtualRanges();
|
|
822
869
|
});
|
|
823
870
|
};
|
|
871
|
+
// INFO: which unpinned columns a wide table draws, from where its scroller
|
|
872
|
+
// sits. The pinned columns before them may stick over its left edge or
|
|
873
|
+
// scroll away, so the view is widened by their width to cover either case
|
|
874
|
+
var handleUpdateColumnWindow = function () {
|
|
875
|
+
var table = tableRef.current;
|
|
876
|
+
if (!table || !isColumnVirtualRef.current)
|
|
877
|
+
return;
|
|
878
|
+
var scroller = table.parentElement;
|
|
879
|
+
var spacer = table.querySelector('thead th[data-column-spacer="before"]');
|
|
880
|
+
if (!scroller || !spacer)
|
|
881
|
+
return;
|
|
882
|
+
var next = {
|
|
883
|
+
start: scroller.scrollLeft - spacer.offsetLeft,
|
|
884
|
+
width: scroller.clientWidth + spacer.offsetLeft,
|
|
885
|
+
};
|
|
886
|
+
setColumnView(function (previous) {
|
|
887
|
+
if (!previous)
|
|
888
|
+
return next;
|
|
889
|
+
var drawn = columnWindowForRef.current(previous);
|
|
890
|
+
return drawn && (0, columnWindow_1.handleIsViewCovered)(drawn, next) ? previous : next;
|
|
891
|
+
});
|
|
892
|
+
};
|
|
893
|
+
var handleScheduleColumnWindow = function () {
|
|
894
|
+
if (columnFrameRef.current)
|
|
895
|
+
return;
|
|
896
|
+
columnFrameRef.current = requestAnimationFrame(function () {
|
|
897
|
+
columnFrameRef.current = 0;
|
|
898
|
+
handleUpdateColumnWindow();
|
|
899
|
+
});
|
|
900
|
+
};
|
|
824
901
|
// INFO: after each draw, the drawn rows of large groups are measured, so the
|
|
825
902
|
// spacers match them, and the ranges are checked against the new layout
|
|
826
903
|
(0, react_2.useLayoutEffect)(function () {
|
|
@@ -845,20 +922,44 @@ var NewTable = function (rawProps) {
|
|
|
845
922
|
}
|
|
846
923
|
handleScheduleVirtualRanges();
|
|
847
924
|
});
|
|
925
|
+
// INFO: after each draw of a wide table, its drawn columns are measured, so
|
|
926
|
+
// the spacers match them, and the window is checked against the new layout
|
|
927
|
+
(0, react_2.useLayoutEffect)(function () {
|
|
928
|
+
if (!isColumnVirtualRef.current)
|
|
929
|
+
return;
|
|
930
|
+
var table = tableRef.current;
|
|
931
|
+
if (!table)
|
|
932
|
+
return;
|
|
933
|
+
table
|
|
934
|
+
.querySelectorAll("thead th[data-column-key]")
|
|
935
|
+
.forEach(function (element) {
|
|
936
|
+
var key = element.getAttribute("data-column-key");
|
|
937
|
+
var width = element.getBoundingClientRect().width;
|
|
938
|
+
if (key && width > 0)
|
|
939
|
+
columnWidthsMeasuredRef.current[key] = width;
|
|
940
|
+
});
|
|
941
|
+
handleScheduleColumnWindow();
|
|
942
|
+
});
|
|
848
943
|
// INFO: capture catches the scroll of whichever element scrolls the table
|
|
849
944
|
(0, react_2.useEffect)(function () {
|
|
850
|
-
|
|
945
|
+
var handleScroll = function () {
|
|
946
|
+
handleScheduleVirtualRanges();
|
|
947
|
+
handleScheduleColumnWindow();
|
|
948
|
+
};
|
|
949
|
+
window.addEventListener("scroll", handleScroll, {
|
|
851
950
|
capture: true,
|
|
852
951
|
passive: true,
|
|
853
952
|
});
|
|
854
|
-
window.addEventListener("resize",
|
|
953
|
+
window.addEventListener("resize", handleScroll);
|
|
855
954
|
return function () {
|
|
856
|
-
window.removeEventListener("scroll",
|
|
955
|
+
window.removeEventListener("scroll", handleScroll, {
|
|
857
956
|
capture: true,
|
|
858
957
|
});
|
|
859
|
-
window.removeEventListener("resize",
|
|
958
|
+
window.removeEventListener("resize", handleScroll);
|
|
860
959
|
if (virtualFrameRef.current)
|
|
861
960
|
cancelAnimationFrame(virtualFrameRef.current);
|
|
961
|
+
if (columnFrameRef.current)
|
|
962
|
+
cancelAnimationFrame(columnFrameRef.current);
|
|
862
963
|
};
|
|
863
964
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
864
965
|
}, []);
|
|
@@ -1199,14 +1300,12 @@ var NewTable = function (rawProps) {
|
|
|
1199
1300
|
? Math.max(textWidth, inner.offsetWidth, truncatedWidth)
|
|
1200
1301
|
: td.scrollWidth;
|
|
1201
1302
|
// INFO: + cell padding (px-4 = 16px × 2), or the title cell's left
|
|
1202
|
-
// padding and the actions' room
|
|
1203
|
-
// still fits when a hovered row makes room for the chevron
|
|
1303
|
+
// padding and the actions' room
|
|
1204
1304
|
var leftPadding = parseFloat(window.getComputedStyle(td).paddingLeft) || 16;
|
|
1205
|
-
var rightPadding = titleChevronActionsWidth;
|
|
1206
1305
|
if (w > 0)
|
|
1207
1306
|
widths[key] =
|
|
1208
1307
|
key === ((_c = flatColumns[0]) === null || _c === void 0 ? void 0 : _c.key) && titleActionsWidth
|
|
1209
|
-
? w + leftPadding +
|
|
1308
|
+
? w + leftPadding + titleActionsWidth
|
|
1210
1309
|
: w + 32;
|
|
1211
1310
|
}
|
|
1212
1311
|
});
|
|
@@ -1439,9 +1538,11 @@ var NewTable = function (rawProps) {
|
|
|
1439
1538
|
}
|
|
1440
1539
|
});
|
|
1441
1540
|
}); };
|
|
1541
|
+
// INFO: an edited row is saved — its emptied fields are not prefilled with
|
|
1542
|
+
// defaults again; the add row is a new record and keeps them
|
|
1442
1543
|
var handleGenerateClonedData = function () {
|
|
1443
1544
|
var _a, _b;
|
|
1444
|
-
return (0, updateModule_1.handleClonedDataAttribute)(addData ? addDataValueRef.current : editDataValueRef.current, handleConvertColumnToDataStructure(flatColumns), (_b = (_a = props.devSettings) === null || _a === void 0 ? void 0 : _a.server) !== null && _b !== void 0 ? _b : "mongoServer");
|
|
1545
|
+
return (0, updateModule_1.handleClonedDataAttribute)(addData ? addDataValueRef.current : editDataValueRef.current, handleConvertColumnToDataStructure(flatColumns), (_b = (_a = props.devSettings) === null || _a === void 0 ? void 0 : _a.server) !== null && _b !== void 0 ? _b : "mongoServer", false, false, !addData);
|
|
1445
1546
|
};
|
|
1446
1547
|
var handleUpdateChangeData = function (data) {
|
|
1447
1548
|
if (addData) {
|
|
@@ -1664,18 +1765,45 @@ var NewTable = function (rawProps) {
|
|
|
1664
1765
|
}
|
|
1665
1766
|
});
|
|
1666
1767
|
}); };
|
|
1768
|
+
// INFO: a cell's "x" — opens the cell as a click would, empties its value and
|
|
1769
|
+
// saves it the way leaving the field does, which closes the cell
|
|
1770
|
+
var handleClearCell = function (rowId, col, rowData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1771
|
+
var handleEmpty, cleared;
|
|
1772
|
+
var _a;
|
|
1773
|
+
var _b;
|
|
1774
|
+
return __generator(this, function (_c) {
|
|
1775
|
+
switch (_c.label) {
|
|
1776
|
+
case 0:
|
|
1777
|
+
handleEmpty = CLEAR_CELL_VALUES[(_b = col.type) !== null && _b !== void 0 ? _b : "string"];
|
|
1778
|
+
if (!handleEmpty)
|
|
1779
|
+
return [2 /*return*/];
|
|
1780
|
+
handleEditDataOnClick(rowId, col.key, rowData);
|
|
1781
|
+
cleared = __assign(__assign({}, editDataValueRef.current), (_a = {}, _a[col.key] = handleEmpty(), _a));
|
|
1782
|
+
editDataValueRef.current = cleared;
|
|
1783
|
+
setEditDataValue(cleared);
|
|
1784
|
+
return [4 /*yield*/, handleEditDataOnBlur(col.key, cleared)];
|
|
1785
|
+
case 1:
|
|
1786
|
+
_c.sent();
|
|
1787
|
+
return [2 /*return*/];
|
|
1788
|
+
}
|
|
1789
|
+
});
|
|
1790
|
+
}); };
|
|
1667
1791
|
// INFO: the width of a column being dragged, keyed by column key, until the
|
|
1668
1792
|
// drag is released — then a caller with onResizeColumn keeps it, otherwise
|
|
1669
1793
|
// it stays here until the table unmounts. Tailwind cannot emit a runtime
|
|
1670
1794
|
// w-[Npx], so a width drives an inline style and wins over the col.width
|
|
1671
1795
|
// class.
|
|
1672
|
-
var
|
|
1796
|
+
var _53 = (0, react_2.useState)({}), columnWidths = _53[0], setColumnWidths = _53[1];
|
|
1797
|
+
// INFO: caps measured for content-sized columns — see handleMeasureCaps
|
|
1798
|
+
var _54 = (0, react_2.useState)({}), cappedWidths = _54[0], setCappedWidths = _54[1];
|
|
1673
1799
|
var resizeRef = (0, react_2.useRef)(null);
|
|
1674
1800
|
// INFO: a dragged width first, else the column's own fixed width in pixels
|
|
1675
1801
|
// whatever form it is stored in ("180px", "w-[180px]", "w-48")
|
|
1676
1802
|
var getColumnWidth = function (key) {
|
|
1677
1803
|
var col = flatColumns.find(function (eachCol) { return eachCol.key === key; });
|
|
1678
|
-
var width = columnWidths[key] ||
|
|
1804
|
+
var width = columnWidths[key] ||
|
|
1805
|
+
(0, columnWidth_1.handleParseColumnWidth)(col === null || col === void 0 ? void 0 : col.width) ||
|
|
1806
|
+
cappedWidths[key];
|
|
1679
1807
|
// INFO: a title carrying its row's actions never narrows past its floor,
|
|
1680
1808
|
// even from a width saved before the actions took their room
|
|
1681
1809
|
var titleMin = getTitleMinWidth(key);
|
|
@@ -1686,24 +1814,12 @@ var NewTable = function (rawProps) {
|
|
|
1686
1814
|
var getTitleMinWidth = function (key) {
|
|
1687
1815
|
var _a;
|
|
1688
1816
|
return key === ((_a = flatColumns[0]) === null || _a === void 0 ? void 0 : _a.key) && hasRowActions
|
|
1689
|
-
? TITLE_LEFT_PADDING +
|
|
1817
|
+
? TITLE_LEFT_PADDING + titleActionsWidth + MIN_TITLE_TEXT_WIDTH
|
|
1690
1818
|
: undefined;
|
|
1691
1819
|
};
|
|
1692
1820
|
// INFO: a consumer may deliberately set a column narrower than the default
|
|
1693
1821
|
// floor (a 40px icon column, say) — never force it wider than it was asked to
|
|
1694
1822
|
// be, so the floor drops to the configured width when that is smaller
|
|
1695
|
-
// INFO: the title cell can only grow its padding on hover while its column
|
|
1696
|
-
// has a set width — a pinned title, or one dragged or configured. A title
|
|
1697
|
-
// sized by its content would widen and shift the table on every hover, so
|
|
1698
|
-
// it keeps the chevron's room all the time instead.
|
|
1699
|
-
var titleKey = (_o = flatColumns[0]) === null || _o === void 0 ? void 0 : _o.key;
|
|
1700
|
-
var isTitleWidthFixed = !!titleKey &&
|
|
1701
|
-
(leftPinned.includes(titleKey) ||
|
|
1702
|
-
rightPinned.includes(titleKey) ||
|
|
1703
|
-
!!getColumnWidth(titleKey));
|
|
1704
|
-
var titleRestPadding = isTitleWidthFixed
|
|
1705
|
-
? titleActionsWidth
|
|
1706
|
-
: titleChevronActionsWidth;
|
|
1707
1823
|
var getColumnMinWidth = function (key) {
|
|
1708
1824
|
var titleMin = getTitleMinWidth(key);
|
|
1709
1825
|
if (titleMin)
|
|
@@ -1714,6 +1830,126 @@ var NewTable = function (rawProps) {
|
|
|
1714
1830
|
? MIN_COLUMN_WIDTH
|
|
1715
1831
|
: Math.min(MIN_COLUMN_WIDTH, configured);
|
|
1716
1832
|
};
|
|
1833
|
+
// INFO: determines whether any column uses groupData — if so, a two-row
|
|
1834
|
+
// thead with colSpan/rowSpan is rendered for proper visual grouping.
|
|
1835
|
+
var hasGroupHeaders = columns.some(function (col) {
|
|
1836
|
+
return !col.hide &&
|
|
1837
|
+
col.groupData &&
|
|
1838
|
+
col.groupData.length > 0;
|
|
1839
|
+
});
|
|
1840
|
+
//=====================================================================================
|
|
1841
|
+
// SECTION: Column window
|
|
1842
|
+
//=====================================================================================
|
|
1843
|
+
// INFO: pinned columns come first and last in flatColumns, so the unpinned
|
|
1844
|
+
// ones are the run [middleStart, middleEnd)
|
|
1845
|
+
var middleStart = flatColumns.filter(function (col) {
|
|
1846
|
+
return leftPinned.includes(col.key);
|
|
1847
|
+
}).length;
|
|
1848
|
+
var middleEnd = flatColumns.length -
|
|
1849
|
+
flatColumns.filter(function (col) { return rightPinned.includes(col.key); }).length;
|
|
1850
|
+
// INFO: a row being added is typed across every column, and a two-row
|
|
1851
|
+
// header spans groups of columns, so either draws all of them
|
|
1852
|
+
var isColumnVirtual = !props.mobileView &&
|
|
1853
|
+
!hasGroupHeaders &&
|
|
1854
|
+
!addData &&
|
|
1855
|
+
middleEnd - middleStart >= columnWindow_1.COLUMN_VIRTUAL_MIN;
|
|
1856
|
+
// INFO: a column not drawn yet is assumed as wide as the average of those
|
|
1857
|
+
// measured, so the scroller's width barely moves as each one is drawn
|
|
1858
|
+
var handleGetMiddleWidths = function () {
|
|
1859
|
+
var measured = Object.values(columnWidthsMeasuredRef.current);
|
|
1860
|
+
var estimate = measured.length
|
|
1861
|
+
? measured.reduce(function (total, width) { return total + width; }, 0) / measured.length
|
|
1862
|
+
: columnWindow_1.COLUMN_VIRTUAL_ESTIMATE_PX;
|
|
1863
|
+
return flatColumns
|
|
1864
|
+
.slice(middleStart, middleEnd)
|
|
1865
|
+
.map(function (col) {
|
|
1866
|
+
var _a, _b;
|
|
1867
|
+
return (_b = (_a = getColumnWidth(col.key)) !== null && _a !== void 0 ? _a : columnWidthsMeasuredRef.current[col.key]) !== null && _b !== void 0 ? _b : estimate;
|
|
1868
|
+
});
|
|
1869
|
+
};
|
|
1870
|
+
var handleGetColumnWindowFor = function (view) {
|
|
1871
|
+
if (!isColumnVirtual)
|
|
1872
|
+
return null;
|
|
1873
|
+
var editIndex = flatColumns.findIndex(function (col) { return col.key === editDataHeaderKey; }) -
|
|
1874
|
+
middleStart;
|
|
1875
|
+
return (0, columnWindow_1.handleGetColumnWindow)({
|
|
1876
|
+
widths: handleGetMiddleWidths(),
|
|
1877
|
+
viewStart: view.start,
|
|
1878
|
+
viewWidth: view.width,
|
|
1879
|
+
keepIndex: editDataHeaderKey &&
|
|
1880
|
+
editIndex >= 0 &&
|
|
1881
|
+
editIndex < middleEnd - middleStart
|
|
1882
|
+
? editIndex
|
|
1883
|
+
: undefined,
|
|
1884
|
+
});
|
|
1885
|
+
};
|
|
1886
|
+
isColumnVirtualRef.current = isColumnVirtual;
|
|
1887
|
+
columnWindowForRef.current = handleGetColumnWindowFor;
|
|
1888
|
+
// INFO: before the scroller is measured, the window assumes it starts at the
|
|
1889
|
+
// first unpinned column and is as wide as the screen
|
|
1890
|
+
var drawnColumnWindow = handleGetColumnWindowFor(columnView !== null && columnView !== void 0 ? columnView : {
|
|
1891
|
+
start: 0,
|
|
1892
|
+
width: typeof window === "undefined" ? 1280 : window.innerWidth,
|
|
1893
|
+
});
|
|
1894
|
+
// INFO: a column drawn as the window moves is read for its cap like those
|
|
1895
|
+
// drawn at first, so a long value scrolled into view is capped too
|
|
1896
|
+
(0, react_2.useLayoutEffect)(function () {
|
|
1897
|
+
if (drawnColumnWindow)
|
|
1898
|
+
setCapCheck(function (previous) { return previous + 1; });
|
|
1899
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1900
|
+
}, [drawnColumnWindow === null || drawnColumnWindow === void 0 ? void 0 : drawnColumnWindow.start, drawnColumnWindow === null || drawnColumnWindow === void 0 ? void 0 : drawnColumnWindow.end]);
|
|
1901
|
+
var handleIsColumnDrawn = function (colIndex) {
|
|
1902
|
+
return !drawnColumnWindow ||
|
|
1903
|
+
colIndex < middleStart ||
|
|
1904
|
+
colIndex >= middleEnd ||
|
|
1905
|
+
(colIndex - middleStart >= drawnColumnWindow.start &&
|
|
1906
|
+
colIndex - middleStart < drawnColumnWindow.end);
|
|
1907
|
+
};
|
|
1908
|
+
/**
|
|
1909
|
+
* The cells a row draws for its columns — on a wide table a spacer on each
|
|
1910
|
+
* side stands in for the columns skipped. colIndex stays the column's place
|
|
1911
|
+
* in flatColumns, which the per-column refs are indexed by.
|
|
1912
|
+
*
|
|
1913
|
+
* @options.wrapCell - wraps each drawn cell, as a body row does to keep a cell it
|
|
1914
|
+
* already drew when the window moves
|
|
1915
|
+
*/
|
|
1916
|
+
var handleMapDrawnColumns = function (options, renderCell) {
|
|
1917
|
+
var _a = options.tag, tag = _a === void 0 ? "td" : _a, wrapCell = options.wrapCell;
|
|
1918
|
+
var cells = [];
|
|
1919
|
+
// INFO: the header's spacer sets the skipped columns' width; a row's
|
|
1920
|
+
// spacer only fills that column, so a row need not redraw when the widths
|
|
1921
|
+
// it stands in for are measured or capped
|
|
1922
|
+
var renderSpacer = function (side, width) {
|
|
1923
|
+
var spacerProps = {
|
|
1924
|
+
key: "column-spacer-".concat(side),
|
|
1925
|
+
"data-column-spacer": side,
|
|
1926
|
+
"aria-hidden": true,
|
|
1927
|
+
style: tag === "th"
|
|
1928
|
+
? { width: width, minWidth: width, maxWidth: width, padding: 0, border: 0 }
|
|
1929
|
+
: { padding: 0, border: 0 },
|
|
1930
|
+
};
|
|
1931
|
+
return tag === "th" ? react_2.default.createElement("th", __assign({}, spacerProps)) : react_2.default.createElement("td", __assign({}, spacerProps));
|
|
1932
|
+
};
|
|
1933
|
+
flatColumns.forEach(function (col, colIndex) {
|
|
1934
|
+
if (drawnColumnWindow && colIndex === middleStart)
|
|
1935
|
+
cells.push(renderSpacer("before", drawnColumnWindow.before));
|
|
1936
|
+
if (handleIsColumnDrawn(colIndex))
|
|
1937
|
+
cells.push(wrapCell
|
|
1938
|
+
? wrapCell(col, colIndex, function () { return renderCell(col, colIndex); })
|
|
1939
|
+
: renderCell(col, colIndex));
|
|
1940
|
+
if (drawnColumnWindow && colIndex === middleEnd - 1)
|
|
1941
|
+
cells.push(renderSpacer("after", drawnColumnWindow.after));
|
|
1942
|
+
});
|
|
1943
|
+
return cells;
|
|
1944
|
+
};
|
|
1945
|
+
// INFO: the cells a row draws for its columns, spacers included — a band
|
|
1946
|
+
// spanning the row counts the same
|
|
1947
|
+
var drawnColumnCount = drawnColumnWindow
|
|
1948
|
+
? flatColumns.length -
|
|
1949
|
+
(middleEnd - middleStart) +
|
|
1950
|
+
(drawnColumnWindow.end - drawnColumnWindow.start) +
|
|
1951
|
+
2
|
|
1952
|
+
: flatColumns.length;
|
|
1717
1953
|
var handleResizeStart = function (event, key) {
|
|
1718
1954
|
var _a, _b, _c, _d, _e;
|
|
1719
1955
|
event.preventDefault();
|
|
@@ -1723,11 +1959,20 @@ var NewTable = function (rawProps) {
|
|
|
1723
1959
|
resizeRef.current = { key: key, startX: event.clientX, startWidth: startWidth };
|
|
1724
1960
|
(_e = (_d = event.currentTarget).setPointerCapture) === null || _e === void 0 ? void 0 : _e.call(_d, event.pointerId);
|
|
1725
1961
|
};
|
|
1962
|
+
// INFO: the widest a drag may take a column. One already wider (its content
|
|
1963
|
+
// or a configured width made it so) keeps its width as the ceiling, so
|
|
1964
|
+
// grabbing it never snaps it narrower — it can only be dragged in. Never
|
|
1965
|
+
// below the floor, so a contact or title column is still draggable.
|
|
1966
|
+
var getColumnMaxWidth = function (key, startWidth) {
|
|
1967
|
+
var _a;
|
|
1968
|
+
var cap = (0, columnWidth_1.handleGetColumnWidthCap)(key === ((_a = flatColumns[0]) === null || _a === void 0 ? void 0 : _a.key), props.advSettings);
|
|
1969
|
+
return Math.max(cap, Math.round(startWidth), getColumnMinWidth(key));
|
|
1970
|
+
};
|
|
1726
1971
|
var handleResizeMove = function (event) {
|
|
1727
1972
|
var resizing = resizeRef.current;
|
|
1728
1973
|
if (!resizing)
|
|
1729
1974
|
return;
|
|
1730
|
-
var next = Math.max(getColumnMinWidth(resizing.key), resizing.startWidth + (event.clientX - resizing.startX));
|
|
1975
|
+
var next = Math.min(getColumnMaxWidth(resizing.key, resizing.startWidth), Math.max(getColumnMinWidth(resizing.key), resizing.startWidth + (event.clientX - resizing.startX)));
|
|
1731
1976
|
setColumnWidths(function (previous) {
|
|
1732
1977
|
var _a;
|
|
1733
1978
|
return (__assign(__assign({}, previous), (_a = {}, _a[resizing.key] = next, _a)));
|
|
@@ -1751,6 +1996,100 @@ var NewTable = function (rawProps) {
|
|
|
1751
1996
|
return rest;
|
|
1752
1997
|
});
|
|
1753
1998
|
};
|
|
1999
|
+
// INFO: a column sized by its content (no configured or dragged width) that
|
|
2000
|
+
// comes out wider than its cap is held at the cap, the same as a fixed
|
|
2001
|
+
// width, so its title and values are cut off with an ellipsis instead of
|
|
2002
|
+
// stretching it. disableEllipsisOnLongWord asks for whole values, so then
|
|
2003
|
+
// content sizes the column as before. Not under grouped headers, which draw
|
|
2004
|
+
// without fixed widths.
|
|
2005
|
+
var _55 = (0, react_2.useState)(0), capCheck = _55[0], setCapCheck = _55[1];
|
|
2006
|
+
var capsKey = [
|
|
2007
|
+
(_o = props.advSettings) === null || _o === void 0 ? void 0 : _o.maxFirstColumnWidth,
|
|
2008
|
+
(_p = props.advSettings) === null || _p === void 0 ? void 0 : _p.maxColumnWidth,
|
|
2009
|
+
props.disableEllipsisOnLongWord,
|
|
2010
|
+
flatColumns.map(function (col) { var _a; return "".concat(col.key, ":").concat((_a = col.width) !== null && _a !== void 0 ? _a : ""); }).join(","),
|
|
2011
|
+
].join("|");
|
|
2012
|
+
// INFO: only adds caps — a column already capped is at its widest. Run on
|
|
2013
|
+
// every resize too, since a value resolved later (a reference's name, say)
|
|
2014
|
+
// can widen a column after the rows arrive.
|
|
2015
|
+
var handleMeasureCaps = function () {
|
|
2016
|
+
var table = tableRef.current;
|
|
2017
|
+
if (!table || props.disableEllipsisOnLongWord)
|
|
2018
|
+
return;
|
|
2019
|
+
var hasGroupedHeaders = columns.some(function (col) { var _a, _b; return !col.hide && ((_b = (_a = col.groupData) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0; });
|
|
2020
|
+
if (hasGroupedHeaders)
|
|
2021
|
+
return;
|
|
2022
|
+
var headers = {};
|
|
2023
|
+
table
|
|
2024
|
+
.querySelectorAll("thead th[data-column-key]")
|
|
2025
|
+
.forEach(function (th) {
|
|
2026
|
+
if (th.dataset.columnKey)
|
|
2027
|
+
headers[th.dataset.columnKey] = th;
|
|
2028
|
+
});
|
|
2029
|
+
// INFO: only columns sized by their content and not yet capped — when
|
|
2030
|
+
// every column is set, dragged or capped there is nothing to read
|
|
2031
|
+
var pending = flatColumns
|
|
2032
|
+
.map(function (col, index) { return ({ col: col, index: index, th: headers[col.key] }); })
|
|
2033
|
+
.filter(function (_a) {
|
|
2034
|
+
var col = _a.col, th = _a.th;
|
|
2035
|
+
return !!th &&
|
|
2036
|
+
!columnWidths[col.key] &&
|
|
2037
|
+
!(0, columnWidth_1.handleParseColumnWidth)(col.width) &&
|
|
2038
|
+
!cappedWidths[col.key];
|
|
2039
|
+
});
|
|
2040
|
+
if (pending.length === 0)
|
|
2041
|
+
return;
|
|
2042
|
+
// INFO: a table narrower than its view is stretched to fill it, which
|
|
2043
|
+
// widens every column past what its content needs — a short table on a
|
|
2044
|
+
// wide screen would then be capped everywhere and stay that wide when the
|
|
2045
|
+
// window narrows. Such a table is drawn at its content's width for the
|
|
2046
|
+
// read, then put back, all before paint. A table already wider than its
|
|
2047
|
+
// view is drawn at its content's width, so it is read as it is, without
|
|
2048
|
+
// laying out a large table twice.
|
|
2049
|
+
var view = table.parentElement;
|
|
2050
|
+
var isStretched = !view || table.getBoundingClientRect().width <= view.clientWidth + 1;
|
|
2051
|
+
var previousWidth = table.style.width;
|
|
2052
|
+
var previousMinWidth = table.style.minWidth;
|
|
2053
|
+
if (isStretched) {
|
|
2054
|
+
table.style.width = "max-content";
|
|
2055
|
+
table.style.minWidth = "0";
|
|
2056
|
+
}
|
|
2057
|
+
var next = {};
|
|
2058
|
+
pending.forEach(function (_a) {
|
|
2059
|
+
var col = _a.col, index = _a.index, th = _a.th;
|
|
2060
|
+
var cap = Math.max((0, columnWidth_1.handleGetColumnWidthCap)(index === 0, props.advSettings), getColumnMinWidth(col.key));
|
|
2061
|
+
if (th.getBoundingClientRect().width > cap + 1)
|
|
2062
|
+
next[col.key] = cap;
|
|
2063
|
+
});
|
|
2064
|
+
if (isStretched) {
|
|
2065
|
+
table.style.width = previousWidth;
|
|
2066
|
+
table.style.minWidth = previousMinWidth;
|
|
2067
|
+
}
|
|
2068
|
+
if (Object.keys(next).length > 0)
|
|
2069
|
+
setCappedWidths(function (previous) { return (__assign(__assign({}, previous), next)); });
|
|
2070
|
+
};
|
|
2071
|
+
// INFO: new rows, columns or caps let every column size itself again, then
|
|
2072
|
+
// measure — both before paint, so a column never shows stretched
|
|
2073
|
+
(0, react_2.useLayoutEffect)(function () {
|
|
2074
|
+
setCappedWidths(function (previous) {
|
|
2075
|
+
return Object.keys(previous).length > 0 ? {} : previous;
|
|
2076
|
+
});
|
|
2077
|
+
setCapCheck(function (previous) { return previous + 1; });
|
|
2078
|
+
}, [props.data, capsKey]);
|
|
2079
|
+
(0, react_2.useLayoutEffect)(function () {
|
|
2080
|
+
handleMeasureCaps();
|
|
2081
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2082
|
+
}, [capCheck]);
|
|
2083
|
+
var measureCapsRef = (0, react_2.useRef)(handleMeasureCaps);
|
|
2084
|
+
measureCapsRef.current = handleMeasureCaps;
|
|
2085
|
+
(0, react_2.useEffect)(function () {
|
|
2086
|
+
var table = tableRef.current;
|
|
2087
|
+
if (!table || typeof ResizeObserver === "undefined")
|
|
2088
|
+
return;
|
|
2089
|
+
var observer = new ResizeObserver(function () { return measureCapsRef.current(); });
|
|
2090
|
+
observer.observe(table);
|
|
2091
|
+
return function () { return observer.disconnect(); };
|
|
2092
|
+
}, []);
|
|
1754
2093
|
var handleDragStart = function (e, id) {
|
|
1755
2094
|
e.dataTransfer.setData("itemId", id);
|
|
1756
2095
|
};
|
|
@@ -1822,10 +2161,7 @@ var NewTable = function (rawProps) {
|
|
|
1822
2161
|
};
|
|
1823
2162
|
var handleSort = function (id, type) {
|
|
1824
2163
|
var _a, _b;
|
|
1825
|
-
(_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onSortColumn) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
1826
|
-
sortId: id,
|
|
1827
|
-
type: type === "new" ? "asc" : type,
|
|
1828
|
-
});
|
|
2164
|
+
(_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onSortColumn) === null || _b === void 0 ? void 0 : _b.call(_a, { sortId: id, type: type });
|
|
1829
2165
|
};
|
|
1830
2166
|
var renderAddColumnPanel = function () {
|
|
1831
2167
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
@@ -2582,12 +2918,12 @@ var NewTable = function (rawProps) {
|
|
|
2582
2918
|
var width = (col === null || col === void 0 ? void 0 : col.width)
|
|
2583
2919
|
? DEFAULT_PIN_WIDTH
|
|
2584
2920
|
: ((_a = measuredPinWidths[key]) !== null && _a !== void 0 ? _a : DEFAULT_PIN_WIDTH);
|
|
2585
|
-
// INFO: a measured short title still keeps its floor, so
|
|
2586
|
-
//
|
|
2921
|
+
// INFO: a measured short title still keeps its floor, so its inline
|
|
2922
|
+
// editor keeps some room beside the action strips
|
|
2587
2923
|
return Math.max(width, (_b = getTitleMinWidth(key)) !== null && _b !== void 0 ? _b : 0);
|
|
2588
2924
|
};
|
|
2589
2925
|
var pinCheckboxOffset = props.checkbox &&
|
|
2590
|
-
(props.data.length > 0 || (props.spaceData && ((
|
|
2926
|
+
(props.data.length > 0 || (props.spaceData && ((_q = props.spaceData) === null || _q === void 0 ? void 0 : _q.length) > 0))
|
|
2591
2927
|
? CHECKBOX_WIDTH
|
|
2592
2928
|
: 0;
|
|
2593
2929
|
/**
|
|
@@ -2827,7 +3163,7 @@ var NewTable = function (rawProps) {
|
|
|
2827
3163
|
var handleIsCellEditing = function (rowId, colKey) {
|
|
2828
3164
|
return editDataRowId === rowId && editDataHeaderKey === colKey;
|
|
2829
3165
|
};
|
|
2830
|
-
var renderReadCellValue = function (col, row, cellValue) {
|
|
3166
|
+
var renderReadCellValue = function (col, row, cellValue, noRowLink) {
|
|
2831
3167
|
var _a;
|
|
2832
3168
|
// INFO: under gridLines="all" a list of names (a list of references)
|
|
2833
3169
|
// reads "A, B", as a multiple list's picks do — the read module joins an
|
|
@@ -2847,7 +3183,7 @@ var NewTable = function (rawProps) {
|
|
|
2847
3183
|
.join(", ")
|
|
2848
3184
|
: undefined;
|
|
2849
3185
|
var value = (0, readModule_1.renderEachRowDataBasedOnDataType)(col.key, roleLabels !== null && roleLabels !== void 0 ? roleLabels : (isNameList ? cellValue.join(", ") : cellValue), props.bareSettings, true, props.disableEllipsisOnLongWord);
|
|
2850
|
-
if (!props.newTabUrl || !props.onClickRow)
|
|
3186
|
+
if (noRowLink || !props.newTabUrl || !props.onClickRow)
|
|
2851
3187
|
return value;
|
|
2852
3188
|
return (react_2.default.createElement(link_1.Link, { href: props.newTabUrl + row.id + ((_a = props.addNewTabUrl) !== null && _a !== void 0 ? _a : ""), className: "w-full block ".concat(handleIsReadCellFixed(col) ? "truncate" : ""), linkType: props.linkType, custom: props.custom }, value));
|
|
2853
3189
|
};
|
|
@@ -2866,7 +3202,7 @@ var NewTable = function (rawProps) {
|
|
|
2866
3202
|
tagClassName: gridLines === "all" ? "!mx-0" : "" }));
|
|
2867
3203
|
};
|
|
2868
3204
|
var renderEditDataInputs = function (colIndex, col, rowData, rowId, rowBgClass, isHoverable) {
|
|
2869
|
-
var _a, _b, _c, _d;
|
|
3205
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2870
3206
|
var tempDS = __assign(__assign({}, col), { id: col.key, name: col.title, type: (_a = col.type) !== null && _a !== void 0 ? _a : "string", showTagSelections: handleColumnShowsTags(col) });
|
|
2871
3207
|
var editingRow = editDataRowId === rowId;
|
|
2872
3208
|
var cellFill = tempDS.showTagSelections
|
|
@@ -2888,6 +3224,20 @@ var NewTable = function (rawProps) {
|
|
|
2888
3224
|
? "cursor-pointer hover:brightness-95 ".concat(isFillActive ? "!shadow-[inset_0_0_0_2px_rgba(255,255,255,0.85)]" : "")
|
|
2889
3225
|
: "cursor-pointer ".concat(props.darkMode ? "hover:bg-gray-800" : "hover:bg-gray-50", " ").concat(isFillActive ? "!shadow-[inset_0_0_0_2px_#9ca3af]" : "");
|
|
2890
3226
|
var pinProps = getPinProps(col.key, false, rowBgClass, isHoverable);
|
|
3227
|
+
// INFO: the value being typed while this row is open, else the saved one
|
|
3228
|
+
var liveValue = editingRow && col.key in ((_c = editDataValueRef.current) !== null && _c !== void 0 ? _c : {})
|
|
3229
|
+
? editDataValueRef.current[col.key]
|
|
3230
|
+
: resolveValue(rowData, col.key);
|
|
3231
|
+
// INFO: an "x" that empties the cell, under gridLines="all" only — a
|
|
3232
|
+
// horizontal table's fields keep their own boxes and clear icons. A
|
|
3233
|
+
// required, read-only or grouped (dotted key) column has none. Once open,
|
|
3234
|
+
// only a typed field or a date keeps it — a dropdown's chevron sits where
|
|
3235
|
+
// the "x" would, and its open list is where a pick is changed.
|
|
3236
|
+
var isClearable = isFillInput &&
|
|
3237
|
+
CLEAR_OPEN_EDITOR_TYPES.includes((_d = col.type) !== null && _d !== void 0 ? _d : "string") &&
|
|
3238
|
+
// INFO: the title's right edge holds the row's own actions
|
|
3239
|
+
!(hasRowActions && col.key === ((_e = flatColumns[0]) === null || _e === void 0 ? void 0 : _e.key)) &&
|
|
3240
|
+
handleIsCellClearable(col, liveValue, rowData);
|
|
2891
3241
|
return (react_2.default.createElement("td", { key: col.key + String(colIndex), "data-cell-key": col.key, "data-pin-key": handleGetPinKey(col.key), "data-edit-cell": "".concat(rowId, ":").concat(col.key), "data-cell-fill": cellFill ? "" : undefined,
|
|
2892
3242
|
// INFO: pinned columns use whitespace-normal so text wraps within the fixed width.
|
|
2893
3243
|
// col.width must match the read-only cell's width source so a column keeps one
|
|
@@ -2895,7 +3245,7 @@ var NewTable = function (rawProps) {
|
|
|
2895
3245
|
// shrinks/grows on hover and staggers the column.
|
|
2896
3246
|
// INFO: a cell fill comes after the pin classes so its colour wins over
|
|
2897
3247
|
// a pinned cell's row background
|
|
2898
|
-
className: "".concat(editCellPadding, " ").concat(handleCellMinWidth(col.type), " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : "", " ").concat(getPinProps(col.key, false) ? "whitespace-normal break-words" : col.width ? "" : "whitespace-nowrap", " text-sm ").concat(cellFontColor, " ").concat(cellFill ? handleDropCellBg(pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) : ((
|
|
3248
|
+
className: "".concat(isClearable && !((_f = pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) === null || _f === void 0 ? void 0 : _f.includes("sticky")) ? "relative" : "", " ").concat(editCellPadding, " ").concat(handleCellMinWidth(col.type), " ").concat(col.width ? "".concat(col.width, " flex-shrink-0") : "", " ").concat(getPinProps(col.key, false) ? "whitespace-normal break-words" : col.width ? "" : "whitespace-nowrap", " text-sm ").concat(cellFontColor, " ").concat(cellFill ? handleDropCellBg(pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) : ((_g = pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) !== null && _g !== void 0 ? _g : ""), " ").concat((_h = cellFill === null || cellFill === void 0 ? void 0 : cellFill.className) !== null && _h !== void 0 ? _h : "", " ").concat(fillStateClass, " ").concat(isFillInput ? "".concat(FILL_INPUT_CELL_CLASS, " ").concat(props.darkMode ? FILL_INPUT_EDIT_BG_DARK_CLASS : FILL_INPUT_EDIT_BG_CLASS, " ").concat(isFillActive ? "".concat(FILL_INPUT_ACTIVE_CLASS, " ").concat(props.darkMode ? FILL_INPUT_ACTIVE_BG_DARK_CLASS : FILL_INPUT_ACTIVE_BG_CLASS) : "") : ""), style: __assign(__assign({}, pinProps === null || pinProps === void 0 ? void 0 : pinProps.style), cellFill === null || cellFill === void 0 ? void 0 : cellFill.style) },
|
|
2899
3249
|
react_2.default.createElement("div", {
|
|
2900
3250
|
// INFO: w-0 on the control, not min-w-0 — the table is sized w-max, so
|
|
2901
3251
|
// an input's browser-default ~20ch intrinsic width feeds max-content
|
|
@@ -2942,26 +3292,56 @@ var NewTable = function (rawProps) {
|
|
|
2942
3292
|
fill: isFillColumn || isFillInput,
|
|
2943
3293
|
// INFO: this editor mounts on the click that opens it
|
|
2944
3294
|
openOnMount: isFillInput,
|
|
3295
|
+
isUpdate: true,
|
|
2945
3296
|
onBlur: function (updateData, options) {
|
|
2946
3297
|
return handleEditDataOnBlur(col.key, updateData !== null && updateData !== void 0 ? updateData : (editDataRowIdRef.current === rowId
|
|
2947
3298
|
? editDataValueRef.current
|
|
2948
3299
|
: rowData), options);
|
|
2949
3300
|
},
|
|
2950
|
-
}))
|
|
3301
|
+
})),
|
|
3302
|
+
isClearable && renderClearCellButton(col, rowId, rowData, false)));
|
|
3303
|
+
};
|
|
3304
|
+
// INFO: a cell's "x" is offered under gridLines="all" on an optional column
|
|
3305
|
+
// whose type CLEAR_CELL_VALUES lists, while the cell holds a value. A
|
|
3306
|
+
// required (or required for this row), read-only, rating or grouped (dotted
|
|
3307
|
+
// key) column has none.
|
|
3308
|
+
var handleIsCellClearable = function (col, value, rowData) {
|
|
3309
|
+
var _a, _b;
|
|
3310
|
+
return !!((_a = props.editable) === null || _a === void 0 ? void 0 : _a.active) &&
|
|
3311
|
+
!!CLEAR_CELL_VALUES[(_b = col.type) !== null && _b !== void 0 ? _b : "string"] &&
|
|
3312
|
+
!col.ratingMax &&
|
|
3313
|
+
!(0, updateModule_1.handleIsFieldRequired)(col, rowData) &&
|
|
3314
|
+
!col.readOnly &&
|
|
3315
|
+
!col.disabled &&
|
|
3316
|
+
!col.key.includes(".") &&
|
|
3317
|
+
!handleIsEmptyCellValue(value);
|
|
2951
3318
|
};
|
|
3319
|
+
// INFO: shown only to a mouse — a touch screen taps the cell to edit it and
|
|
3320
|
+
// has no hover to reveal the button by. On a cell that is read it shows while
|
|
3321
|
+
// the cell is hovered; on an open text, number or date field it stays, over
|
|
3322
|
+
// the field's right edge.
|
|
3323
|
+
var renderClearCellButton = function (col, rowId, rowData, onHover) { return (react_2.default.createElement("button", { type: "button", "aria-label": "Clear ".concat(typeof col.title === "string" ? col.title : col.key), "data-testid": "cell-clear", className: "absolute right-1.5 top-1/2 z-[3] hidden h-5 w-5 -translate-y-1/2 items-center justify-center rounded ".concat(onHover ? "[@media(hover:hover)_and_(pointer:fine)]:group-hover/clear:flex" : "[@media(hover:hover)_and_(pointer:fine)]:flex", " ").concat(props.darkMode ? "bg-gray-700 text-gray-300 hover:bg-gray-600" : "bg-gray-100 text-gray-500 hover:bg-gray-200"),
|
|
3324
|
+
// INFO: a field being typed in keeps its focus, or its blur would save
|
|
3325
|
+
// the value being cleared and close the cell under the click
|
|
3326
|
+
onMouseDown: function (e) { return e.preventDefault(); }, onClick: function (e) {
|
|
3327
|
+
e.stopPropagation();
|
|
3328
|
+
handleOpenAfterLeaving(e.currentTarget, function () {
|
|
3329
|
+
handleClearCell(rowId, col, rowData);
|
|
3330
|
+
});
|
|
3331
|
+
} },
|
|
3332
|
+
react_2.default.createElement(solid_2.XMarkIcon, { className: "h-3.5 w-3.5", "aria-hidden": "true" }))); };
|
|
2952
3333
|
var renderActionStrip = function (testId, right, children) { return (react_2.default.createElement("div", { "data-testid": testId, className: "absolute inset-y-0 z-20 flex items-center justify-center border-l ".concat(borderColor), style: { right: right, width: ACTION_STRIP_WIDTH } }, children)); };
|
|
2953
|
-
var renderActivityButton = function (id, positioned
|
|
3334
|
+
var renderActivityButton = function (id, positioned) {
|
|
2954
3335
|
var _a, _b;
|
|
2955
3336
|
if (positioned === void 0) { positioned = false; }
|
|
2956
|
-
if (chevronBgClass === void 0) { chevronBgClass = ""; }
|
|
2957
3337
|
if (!hasRowActions)
|
|
2958
3338
|
return null;
|
|
2959
3339
|
// INFO: a mobile card opens its record from the card, so it keeps the
|
|
2960
|
-
// pencil and the bubble beside its title and drops the
|
|
3340
|
+
// pencil and the bubble beside its title and drops the eye
|
|
2961
3341
|
if (!positioned)
|
|
2962
3342
|
return (react_2.default.createElement(recordActions_1.RecordActions, { id: id, onEdit: props.onRowEdit, onActivity: props.onRowActivity, commentCount: (_a = props.commentCounts) === null || _a === void 0 ? void 0 : _a[id] }));
|
|
2963
3343
|
return (react_2.default.createElement(react_2.default.Fragment, null,
|
|
2964
|
-
props.onRowOpen && (react_2.default.createElement(recordActions_1.RecordActions, { id: id, onOpen: props.onRowOpen, className: "absolute top-1/2 -translate-y-1/2 z-20 rounded-lg
|
|
3344
|
+
props.onRowOpen && (react_2.default.createElement(recordActions_1.RecordActions, { id: id, onOpen: props.onRowOpen, className: "absolute top-1/2 -translate-y-1/2 z-20 rounded-lg", style: { right: titleStripsWidth + 4 } })),
|
|
2965
3345
|
props.onRowEdit &&
|
|
2966
3346
|
renderActionStrip("record-edit-strip", activityStripWidth, react_2.default.createElement(recordActions_1.RecordActions, { id: id, onEdit: props.onRowEdit })),
|
|
2967
3347
|
props.onRowActivity &&
|
|
@@ -3034,7 +3414,7 @@ var NewTable = function (rawProps) {
|
|
|
3034
3414
|
};
|
|
3035
3415
|
// INFO: worked out here, after the Actions and "+" helpers it reads, and
|
|
3036
3416
|
// only read by the render helpers called from the return below
|
|
3037
|
-
var
|
|
3417
|
+
var _56 = handleFitPins(), fittedLeftPins = _56.widths, narrowPins = _56.narrow;
|
|
3038
3418
|
var renderActionColumnHeader = function () {
|
|
3039
3419
|
if (handleShowsActionColumn()) {
|
|
3040
3420
|
var pin = handleGetActionCellPin(true);
|
|
@@ -3174,7 +3554,7 @@ var NewTable = function (rawProps) {
|
|
|
3174
3554
|
return null;
|
|
3175
3555
|
return (react_2.default.createElement("tr", { "data-testid": "table-add-row", className: "group cursor-text ".concat(props.darkMode ? "hover:bg-gray-800" : "hover:bg-gray-50") },
|
|
3176
3556
|
props.checkbox && react_2.default.createElement("td", { className: "w-10 ".concat(cellPadding) }),
|
|
3177
|
-
|
|
3557
|
+
handleMapDrawnColumns({}, function (col, index) { return (react_2.default.createElement("td", { key: col.key, "data-add-cell": col.key, className: "".concat(cellPadding, " h-10"), onClick: function () { return handleStartAdd(col.key); } }, index === 0 && (react_2.default.createElement(solid_1.PlusIcon, { className: "h-4 w-4 ".concat(props.darkMode ? "text-gray-500" : "text-gray-400"), "aria-hidden": "true" })))); }),
|
|
3178
3558
|
renderAddColumnCell(),
|
|
3179
3559
|
handleShowsActionColumn() && (react_2.default.createElement("td", { className: "".concat(cellPadding, " ").concat(handleGetActionCellPin(false).className, " ").concat(props.darkMode ? "group-hover:bg-gray-800" : "group-hover:bg-gray-50"), style: handleGetActionCellPin(false).style }))));
|
|
3180
3560
|
};
|
|
@@ -3222,7 +3602,7 @@ var NewTable = function (rawProps) {
|
|
|
3222
3602
|
};
|
|
3223
3603
|
// INFO: true when maxSelectedCount is set and the current selection has reached the limit
|
|
3224
3604
|
var isMaxReached = !!props.maxSelectedCount &&
|
|
3225
|
-
((
|
|
3605
|
+
((_s = (_r = props.selectedIds) === null || _r === void 0 ? void 0 : _r.length) !== null && _s !== void 0 ? _s : 0) >= props.maxSelectedCount;
|
|
3226
3606
|
// INFO: one desktop row. groupAccent carries the group's colour so member
|
|
3227
3607
|
// rows show the band's colour as a bar down their left edge.
|
|
3228
3608
|
var handleRowDragStart = function (event, rowId) {
|
|
@@ -3310,7 +3690,7 @@ var NewTable = function (rawProps) {
|
|
|
3310
3690
|
? (0, rowRendering_1.handleGetIdentity)(rawProps[key])
|
|
3311
3691
|
: (0, rowRendering_1.handleFingerprint)(rawProps[key]));
|
|
3312
3692
|
});
|
|
3313
|
-
var
|
|
3693
|
+
var cellKey = __spreadArray(__spreadArray([], propParts, true), [
|
|
3314
3694
|
(0, rowRendering_1.handleFingerprint)(columnTypeActions),
|
|
3315
3695
|
isFixed,
|
|
3316
3696
|
editDataRowId,
|
|
@@ -3332,6 +3712,14 @@ var NewTable = function (rawProps) {
|
|
|
3332
3712
|
(0, rowRendering_1.handleGetIdentity)(measuredPinWidths),
|
|
3333
3713
|
(0, rowRendering_1.handleGetIdentity)(columnWidths),
|
|
3334
3714
|
], false).join("|");
|
|
3715
|
+
if (cellKey !== cellVersionRef.current.key)
|
|
3716
|
+
cellVersionRef.current = {
|
|
3717
|
+
key: cellKey,
|
|
3718
|
+
version: cellVersionRef.current.version + 1,
|
|
3719
|
+
};
|
|
3720
|
+
var key = "".concat(cellKey, "|").concat(drawnColumnWindow
|
|
3721
|
+
? "".concat(drawnColumnWindow.start, "-").concat(drawnColumnWindow.end)
|
|
3722
|
+
: "");
|
|
3335
3723
|
if (key !== tableVersionRef.current.key)
|
|
3336
3724
|
tableVersionRef.current = {
|
|
3337
3725
|
key: key,
|
|
@@ -3537,6 +3925,11 @@ var NewTable = function (rawProps) {
|
|
|
3537
3925
|
((_d = props.selectAll) !== null && _d !== void 0 ? _d : false);
|
|
3538
3926
|
var rowBgClass = isSelected ? selectedRowBg : bgColor;
|
|
3539
3927
|
var isRowHoverable = !!props.onClickRow && !isSelected;
|
|
3928
|
+
// INFO: each body cell is kept on the same terms as its row, so the drawn
|
|
3929
|
+
// columns moving mounts only those coming into view
|
|
3930
|
+
var memoCells = {
|
|
3931
|
+
wrapCell: function (col, _colIndex, render) { return (react_2.default.createElement(rowRendering_1.NewTableMemoCell, { key: col.key, row: row, spaceRow: spaceRow, colKey: col.key, index: index, groupAccent: groupAccent, dropGroupId: dropGroup === null || dropGroup === void 0 ? void 0 : dropGroup.id, isSelected: isSelected, editValue: editDataRowId === row.id ? editDataValue : undefined, cellVersion: cellVersionRef.current.version, render: render })); },
|
|
3932
|
+
};
|
|
3540
3933
|
return (react_2.default.createElement("tr", __assign({ key: row.id, "data-dtw-record-id": row.id, draggable: canDragRows && dragArmedRowId === row.id, onDragStart: function (e) { return handleRowDragStart(e, row.id); }, onDragEnd: handleRowDragEnd }, (dropGroup ? handleGroupDropProps(dropGroup) : {}), { onClick: function (e) {
|
|
3541
3934
|
var _a, _b;
|
|
3542
3935
|
// INFO: a link or form field placed in a cell does its own default
|
|
@@ -3568,21 +3961,20 @@ var NewTable = function (rawProps) {
|
|
|
3568
3961
|
props.checkbox && (react_2.default.createElement("td", { className: "w-10 ".concat(cellPadding, " ").concat(hasPinColumns ? "".concat(rowBgClass, " ").concat(isRowHoverable ? (props.darkMode ? "group-hover:bg-gray-700" : "group-hover:bg-gray-100") : "") : ""), style: handleGetCheckboxPinStyle(1), onClick: function (e) { return handleSelectRow(row.id, e); }, onMouseDown: function (e) { return handleDragSelectStart(row.id, e); }, onMouseEnter: function () { return handleDragSelectOver(row.id); } }, renderCheckbox(isSelected, function () { }, undefined, isMaxReached && !isSelected
|
|
3569
3962
|
? "opacity-50 cursor-not-allowed"
|
|
3570
3963
|
: ""))),
|
|
3571
|
-
|
|
3964
|
+
handleMapDrawnColumns(memoCells, function (col, colIndex) {
|
|
3572
3965
|
var dragHandle = colIndex === 0 && canDragRows && dropGroup
|
|
3573
3966
|
? renderRowDragHandle(row.id)
|
|
3574
3967
|
: null;
|
|
3575
3968
|
// INFO: keep the action outside links and inline editors in every
|
|
3576
3969
|
// cell variant
|
|
3577
3970
|
var handleDecorateCell = function (cell) {
|
|
3578
|
-
var _a, _b, _c, _d, _e
|
|
3971
|
+
var _a, _b, _c, _d, _e;
|
|
3579
3972
|
if (colIndex !== 0 || (!hasRowActions && !dragHandle))
|
|
3580
3973
|
return cell;
|
|
3581
3974
|
// INFO: a filled text editor rings its cell, but the title cell also
|
|
3582
3975
|
// holds the row's action strips at its right edge — so the ring
|
|
3583
3976
|
// moves off the cell onto an overlay that stops where the strips
|
|
3584
3977
|
// begin
|
|
3585
|
-
var titleStripsWidth = activityStripWidth + editStripWidth;
|
|
3586
3978
|
var cellTokens = String((_a = cell.props.className) !== null && _a !== void 0 ? _a : "").split(" ");
|
|
3587
3979
|
var hasFillRing = cellTokens.includes("focus-within:ring-2");
|
|
3588
3980
|
var isFillRingActive = cellTokens.includes("ring-2");
|
|
@@ -3592,14 +3984,14 @@ var NewTable = function (rawProps) {
|
|
|
3592
3984
|
.join(" "), " group/fillcell")
|
|
3593
3985
|
: cell.props.className;
|
|
3594
3986
|
return react_2.default.cloneElement(cell, {
|
|
3595
|
-
className: "".concat(titleCellClassName, " ").concat((_b = TITLE_ACTIONS_PADDING_CLASS[
|
|
3596
|
-
style: __assign(__assign(__assign(__assign({}, cell.props.style), { paddingRight:
|
|
3987
|
+
className: "".concat(titleCellClassName, " ").concat((_b = TITLE_ACTIONS_PADDING_CLASS[titleActionsWidth]) !== null && _b !== void 0 ? _b : "", " ").concat((_d = (_c = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _c === void 0 ? void 0 : _c.className) !== null && _d !== void 0 ? _d : ""),
|
|
3988
|
+
style: __assign(__assign(__assign(__assign({}, cell.props.style), { paddingRight: titleActionsWidth }), (_e = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _e === void 0 ? void 0 : _e.style), { position: getPinProps(col.key, false) ? "sticky" : "relative" }),
|
|
3597
3989
|
}, cell.props.children, hasFillRing && titleStripsWidth > 0 ? (react_2.default.createElement("span", { "aria-hidden": "true", "data-testid": "table-title-fill-ring", className: "pointer-events-none absolute inset-y-0 left-0 z-10 ring-2 ring-inset ring-primary-500 ".concat(isFillRingActive
|
|
3598
3990
|
? ""
|
|
3599
|
-
: "hidden group-focus-within/fillcell:block"), style: { right: titleStripsWidth } })) : null, dragHandle, renderActivityButton(row.id, true
|
|
3991
|
+
: "hidden group-focus-within/fillcell:block"), style: { right: titleStripsWidth } })) : null, dragHandle, renderActivityButton(row.id, true));
|
|
3600
3992
|
};
|
|
3601
3993
|
var renderDataCell = function () {
|
|
3602
|
-
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, _5, _6, _7, _8, _9;
|
|
3994
|
+
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, _5, _6, _7, _8, _9, _10, _11, _12;
|
|
3603
3995
|
// INFO: a coloured list cell is this table's to render, so it takes
|
|
3604
3996
|
// the raw value even when a display row is supplied. The list view
|
|
3605
3997
|
// builds those rows and puts a Tag in for a coloured value — an
|
|
@@ -3686,13 +4078,20 @@ var NewTable = function (rawProps) {
|
|
|
3686
4078
|
// table (isColumnLocked) — there a click must leave the Select alone,
|
|
3687
4079
|
// not navigate — so the overlay is gated on !editable.active.
|
|
3688
4080
|
var shouldNavigateOnClick = !((_q = props.editable) === null || _q === void 0 ? void 0 : _q.active);
|
|
4081
|
+
var isLockedFillCell = !!((_r = props.editable) === null || _r === void 0 ? void 0 : _r.active) &&
|
|
4082
|
+
gridLines === "all" &&
|
|
4083
|
+
!isActionColumn;
|
|
3689
4084
|
var cellFill = handleGetCellFill(col, rawListValue);
|
|
3690
4085
|
var pinProps = getPinProps(col.key, false, rowBgClass, isRowHoverable);
|
|
3691
|
-
return (react_2.default.createElement("td", { key: col.key, "data-cell-key": col.key, "data-pin-key": handleGetPinKey(col.key), "data-cell-fill": cellFill ? "" : undefined, className: "p-0 align-middle ".concat(cellFill ? handleDropCellBg(pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) : ((
|
|
4086
|
+
return (react_2.default.createElement("td", { key: col.key, "data-cell-key": col.key, "data-pin-key": handleGetPinKey(col.key), "data-cell-fill": cellFill ? "" : undefined, "data-cell-locked": isLockedFillCell ? "" : undefined, className: "p-0 align-middle ".concat(isLockedFillCell ? "cursor-default" : "", " ").concat(cellFill ? handleDropCellBg(pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) : ((_s = pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) !== null && _s !== void 0 ? _s : ""), " ").concat((_t = cellFill === null || cellFill === void 0 ? void 0 : cellFill.className) !== null && _t !== void 0 ? _t : ""), style: __assign(__assign({}, pinProps === null || pinProps === void 0 ? void 0 : pinProps.style), cellFill === null || cellFill === void 0 ? void 0 : cellFill.style),
|
|
4087
|
+
// INFO: a locked coloured cell in the full grid keeps its
|
|
4088
|
+
// click, as a locked text cell does
|
|
4089
|
+
onClick: isLockedFillCell ? function (e) { return e.stopPropagation(); } : undefined },
|
|
3692
4090
|
react_2.default.createElement("div", { className: "relative ".concat(cellFill ? "w-full" : "w-max", " whitespace-nowrap p-[1px]") },
|
|
3693
4091
|
renderFormCell(row, readOnlyDS, null, {
|
|
3694
4092
|
active: true,
|
|
3695
4093
|
readOnly: true,
|
|
4094
|
+
isUpdate: true,
|
|
3696
4095
|
fill: !!cellFill,
|
|
3697
4096
|
onBlur: function () { },
|
|
3698
4097
|
}),
|
|
@@ -3711,7 +4110,7 @@ var NewTable = function (rawProps) {
|
|
|
3711
4110
|
// INFO: share the column width source with the read-only/edit cell
|
|
3712
4111
|
// variants, otherwise an "Add" placeholder and a filled value in the
|
|
3713
4112
|
// same column resolve to different widths and the column looks ragged
|
|
3714
|
-
className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " ").concat(handleReadCellWidthClass(col), " ").concat((
|
|
4113
|
+
className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " ").concat(handleReadCellWidthClass(col), " ").concat((_v = (_u = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _u === void 0 ? void 0 : _u.className) !== null && _v !== void 0 ? _v : ""), style: (_w = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _w === void 0 ? void 0 : _w.style },
|
|
3715
4114
|
react_2.default.createElement("div", { className: "cursor-pointer group/modaledit flex items-center gap-x-2 min-h-6 ".concat(handleIsReadCellFixed(col) ? "w-0 min-w-full" : ""), "data-testid": "table-object-edit-".concat(col.key), onClick: function (e) {
|
|
3716
4115
|
var _a;
|
|
3717
4116
|
e.stopPropagation();
|
|
@@ -3731,7 +4130,7 @@ var NewTable = function (rawProps) {
|
|
|
3731
4130
|
// INFO: share the column width source with the read-only/edit cell
|
|
3732
4131
|
// variants, otherwise an "Add" placeholder and a filled value in the
|
|
3733
4132
|
// same column resolve to different widths and the column looks ragged
|
|
3734
|
-
className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " ").concat(handleReadCellWidthClass(col), " ").concat((
|
|
4133
|
+
className: "".concat(cellPadding, " text-sm ").concat(cellFontColor, " ").concat(handleReadCellWidthClass(col), " ").concat((_y = (_x = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _x === void 0 ? void 0 : _x.className) !== null && _y !== void 0 ? _y : ""), style: (_z = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _z === void 0 ? void 0 : _z.style },
|
|
3735
4134
|
react_2.default.createElement("div", { className: "cursor-pointer group/modaledit flex items-center gap-x-2 min-h-6 ".concat(handleIsReadCellFixed(col) ? "w-0 min-w-full" : ""), "data-testid": "table-modal-edit-".concat(col.key), onClick: function (e) {
|
|
3736
4135
|
e.stopPropagation();
|
|
3737
4136
|
handleModalEditOnClick(row.id, col.key, row);
|
|
@@ -3753,7 +4152,7 @@ var NewTable = function (rawProps) {
|
|
|
3753
4152
|
if (isEditable &&
|
|
3754
4153
|
resolvedColType === "multipleList" &&
|
|
3755
4154
|
(!isCellEditing || isLabelPickerColumn) &&
|
|
3756
|
-
!((
|
|
4155
|
+
!((_1 = (_0 = props.bareSettings) === null || _0 === void 0 ? void 0 : _0.bareListDescription) === null || _1 === void 0 ? void 0 : _1.call(_0, col.key, cellValue))) {
|
|
3757
4156
|
var isPicking = isLabelPickerColumn && isCellEditing && !!labelPickerAnchor;
|
|
3758
4157
|
var handleOpenCell_1 = function (target) {
|
|
3759
4158
|
if (gridLines === "all") {
|
|
@@ -3774,7 +4173,13 @@ var NewTable = function (rawProps) {
|
|
|
3774
4173
|
pendingFocusRef.current = "".concat(row.id, ":").concat(col.key);
|
|
3775
4174
|
};
|
|
3776
4175
|
var pickedValue = resolveValue((isCellEditing ? rowData : row), col.key);
|
|
3777
|
-
|
|
4176
|
+
// INFO: a plain multiple list under gridLines="all" gets the
|
|
4177
|
+
// cell's "x" on hover; a coloured one clears in its label picker
|
|
4178
|
+
var tagPinClass = (_3 = (_2 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _2 === void 0 ? void 0 : _2.className) !== null && _3 !== void 0 ? _3 : "";
|
|
4179
|
+
var isTagClearable = gridLines === "all" &&
|
|
4180
|
+
!isLabelPickerColumn &&
|
|
4181
|
+
handleIsCellClearable(col, pickedValue, rowData);
|
|
4182
|
+
return (react_2.default.createElement("td", { key: col.key, "data-cell-key": col.key, "data-pin-key": handleGetPinKey(col.key), className: "".concat(isTagClearable ? "group/clear ".concat(tagPinClass.includes("sticky") ? "" : "relative") : "", " ").concat(editCellPadding, " ").concat(handleCellMinWidth(col.type), " ").concat(handleReadCellWidthClass(col), " text-sm ").concat(cellFontColor, " ").concat(tagPinClass, " ").concat(isPicking ? "!shadow-[inset_0_0_0_2px_#9ca3af]" : ""), style: (_4 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _4 === void 0 ? void 0 : _4.style },
|
|
3778
4183
|
react_2.default.createElement("div", { "data-testid": "table-tag-line-".concat(col.key), role: "button", "aria-haspopup": isLabelPickerColumn ? "dialog" : undefined, "aria-expanded": isLabelPickerColumn ? isPicking : undefined, tabIndex: 0, "aria-label": "Edit ".concat(col.title), className: "flex h-[34px] cursor-pointer items-center gap-1 overflow-hidden whitespace-nowrap ".concat(handleIsReadCellFixed(col) ? "w-0 min-w-full" : ""), onClick: function (e) {
|
|
3779
4184
|
e.stopPropagation();
|
|
3780
4185
|
handleOpenCell_1(e.currentTarget);
|
|
@@ -3785,7 +4190,9 @@ var NewTable = function (rawProps) {
|
|
|
3785
4190
|
e.stopPropagation();
|
|
3786
4191
|
handleOpenCell_1(e.currentTarget);
|
|
3787
4192
|
} }, renderTagLine(col, isLabelPickerColumn ? pickedValue : cellValue)),
|
|
3788
|
-
|
|
4193
|
+
isTagClearable &&
|
|
4194
|
+
renderClearCellButton(col, row.id, rowData, true),
|
|
4195
|
+
isPicking && labelPickerAnchor && (react_2.default.createElement(labelPicker_1.LabelPicker, { anchor: labelPickerAnchor, darkMode: props.darkMode, required: (0, updateModule_1.handleIsFieldRequired)(col, rowData), allowNewValue: !!col.listNewValue, options: ((_5 = col.listSelection) !== null && _5 !== void 0 ? _5 : []).map(function (key) { return ({
|
|
3789
4196
|
key: String(key),
|
|
3790
4197
|
color: handleGetListColour(col, key),
|
|
3791
4198
|
}); }), value: (Array.isArray(pickedValue)
|
|
@@ -3799,7 +4206,7 @@ var NewTable = function (rawProps) {
|
|
|
3799
4206
|
// takes, so the save carries the same cleaned row
|
|
3800
4207
|
onChange: function (next) {
|
|
3801
4208
|
var _a, _b;
|
|
3802
|
-
var updated = (0, updateModule_1.handleClonedDataAttribute)(editDataValueRef.current, handleConvertColumnToDataStructure(flatColumns), (_b = (_a = props.devSettings) === null || _a === void 0 ? void 0 : _a.server) !== null && _b !== void 0 ? _b : "mongoServer");
|
|
4209
|
+
var updated = (0, updateModule_1.handleClonedDataAttribute)(editDataValueRef.current, handleConvertColumnToDataStructure(flatColumns), (_b = (_a = props.devSettings) === null || _a === void 0 ? void 0 : _a.server) !== null && _b !== void 0 ? _b : "mongoServer", false, false, true);
|
|
3803
4210
|
updated[col.key] = next;
|
|
3804
4211
|
editDataValueRef.current = updated;
|
|
3805
4212
|
setEditDataValue(updated);
|
|
@@ -3814,7 +4221,7 @@ var NewTable = function (rawProps) {
|
|
|
3814
4221
|
// INFO: coloured list cells are exempt from the hover swap — read and
|
|
3815
4222
|
// edit are the same filled pill, so there is nothing to swap to
|
|
3816
4223
|
var bareOverride = isEditable
|
|
3817
|
-
? (
|
|
4224
|
+
? (_7 = (_6 = props.bareSettings) === null || _6 === void 0 ? void 0 : _6.bareListDescription) === null || _7 === void 0 ? void 0 : _7.call(_6, col.key, cellValue)
|
|
3818
4225
|
: undefined;
|
|
3819
4226
|
if (isEditable && !bareOverride && handleColumnShowsTags(col))
|
|
3820
4227
|
return renderEditDataInputs(colIndex, col, rowData, row.id, rowBgClass, isRowHoverable);
|
|
@@ -3827,9 +4234,37 @@ var NewTable = function (rawProps) {
|
|
|
3827
4234
|
!bareOverride &&
|
|
3828
4235
|
gridLines === "all" &&
|
|
3829
4236
|
FILL_INPUT_TYPES.includes(resolvedColType);
|
|
4237
|
+
var readPinClass = (_9 = (_8 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _8 === void 0 ? void 0 : _8.className) !== null && _9 !== void 0 ? _9 : "";
|
|
4238
|
+
var isReadClearable = isClickToEditCell &&
|
|
4239
|
+
!handleColumnShowsTags(col) &&
|
|
4240
|
+
// INFO: the title's right edge holds the row's own actions
|
|
4241
|
+
!(hasRowActions && col.key === ((_10 = flatColumns[0]) === null || _10 === void 0 ? void 0 : _10.key)) &&
|
|
4242
|
+
handleIsCellClearable(col, rowData === null || rowData === void 0 ? void 0 : rowData[col.key], rowData);
|
|
4243
|
+
// INFO: under gridLines="all" every editable cell's click opens
|
|
4244
|
+
// its editor, so a locked cell opening the record was the odd one
|
|
4245
|
+
// out. Its click stays in the cell; the record opens from the
|
|
4246
|
+
// title's open button. The partial grid keeps the row click, since
|
|
4247
|
+
// there the row (not the cell) is what is clicked.
|
|
4248
|
+
var isLockedGridCell = !!((_11 = props.editable) === null || _11 === void 0 ? void 0 : _11.active) &&
|
|
4249
|
+
gridLines === "all" &&
|
|
4250
|
+
isColumnLocked &&
|
|
4251
|
+
!isActionColumn;
|
|
3830
4252
|
var readCell = (react_2.default.createElement("td", { key: col.key, "data-cell-key": col.key, "data-pin-key": leftPinned.includes(col.key) || rightPinned.includes(col.key)
|
|
3831
4253
|
? col.key
|
|
3832
|
-
: undefined, className: "".concat(cellPadding, " ").concat(isEditable ? "".concat(editCellMinHeight, " align-middle ").concat(handleCellMinWidth(col.type)) : "", " text-sm ").concat(colIndex === 0 && props.onClickRow ? titleFontColor : cellFontColor, " ").concat(handleReadCellWidthClass(col), " ").concat(
|
|
4254
|
+
: undefined, className: "".concat(isReadClearable ? "group/clear ".concat(readPinClass.includes("sticky") ? "" : "relative") : "", " ").concat(cellPadding, " ").concat(isEditable ? "".concat(editCellMinHeight, " align-middle ").concat(handleCellMinWidth(col.type)) : "", " ").concat(isLockedGridCell ? "cursor-default" : "", " text-sm ").concat(colIndex === 0 && props.onClickRow ? titleFontColor : cellFontColor, " ").concat(handleReadCellWidthClass(col), " ").concat(readPinClass), style: (_12 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _12 === void 0 ? void 0 : _12.style, "data-row-link-cell": props.newTabUrl && props.onClickRow && !isLockedGridCell
|
|
4255
|
+
? ""
|
|
4256
|
+
: undefined, "data-cell-locked": isLockedGridCell ? "" : undefined,
|
|
4257
|
+
// INFO: bubble phase, so a button in the cell (the title's
|
|
4258
|
+
// open, comment and drag controls) runs first; those still
|
|
4259
|
+
// reach the row as they did, anything else stops here
|
|
4260
|
+
onClick: isLockedGridCell
|
|
4261
|
+
? function (e) {
|
|
4262
|
+
var _a, _b;
|
|
4263
|
+
if ((_b = (_a = e.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, 'button, [data-testid$="-strip"], [data-testid^="table-row-drag-handle-"]'))
|
|
4264
|
+
return;
|
|
4265
|
+
e.stopPropagation();
|
|
4266
|
+
}
|
|
4267
|
+
: undefined,
|
|
3833
4268
|
// INFO: a click opens the editor in place rather than following
|
|
3834
4269
|
// the row's link
|
|
3835
4270
|
onClickCapture: isClickToEditCell
|
|
@@ -3847,7 +4282,10 @@ var NewTable = function (rawProps) {
|
|
|
3847
4282
|
handleEditDataOnClick(row.id, col.key, rowData);
|
|
3848
4283
|
});
|
|
3849
4284
|
}
|
|
3850
|
-
: undefined },
|
|
4285
|
+
: undefined },
|
|
4286
|
+
handleIsReadCellFixed(col) ? (react_2.default.createElement(hoverTooltip_1.HoverTooltip, { as: "div", className: "w-0 min-w-full truncate", onlyWhenClipped: true }, renderReadCellValue(col, row, cellValue, isLockedGridCell))) : (renderReadCellValue(col, row, cellValue, isLockedGridCell)),
|
|
4287
|
+
isReadClearable &&
|
|
4288
|
+
renderClearCellButton(col, row.id, rowData, true)));
|
|
3851
4289
|
if (!isEditable || bareOverride)
|
|
3852
4290
|
return readCell;
|
|
3853
4291
|
if (isClickToEditCell)
|
|
@@ -3919,7 +4357,7 @@ var NewTable = function (rawProps) {
|
|
|
3919
4357
|
// add-column on it left the band a column short of the row.
|
|
3920
4358
|
var columnCount = props.mobileView
|
|
3921
4359
|
? 1
|
|
3922
|
-
:
|
|
4360
|
+
: drawnColumnCount +
|
|
3923
4361
|
(props.checkbox ? 1 : 0) +
|
|
3924
4362
|
(((_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.addColumnEnabled) ? 1 : 0) +
|
|
3925
4363
|
(handleShowsActionColumn() ? 1 : 0);
|
|
@@ -4001,7 +4439,7 @@ var NewTable = function (rawProps) {
|
|
|
4001
4439
|
? "pointer-events-none"
|
|
4002
4440
|
: "cursor-text ".concat(props.darkMode ? "hover:bg-gray-800" : "hover:bg-gray-50")) }, handleGroupDropProps(group)),
|
|
4003
4441
|
props.checkbox && react_2.default.createElement("td", { className: "w-10 ".concat(cellPadding) }),
|
|
4004
|
-
|
|
4442
|
+
handleMapDrawnColumns({}, function (col, index) { return (react_2.default.createElement("td", { key: col.key, "data-add-cell": col.key, className: "".concat(cellPadding, " h-10 text-sm ").concat(props.darkMode ? "text-gray-500" : "text-gray-400", " ").concat(isBlank ? "invisible" : ""), onClick: function () {
|
|
4005
4443
|
return handleStartAdd(handleIsAddColumn(col) ? col.key : (firstAddKey !== null && firstAddKey !== void 0 ? firstAddKey : col.key), group);
|
|
4006
4444
|
} }, index === 0 && (react_2.default.createElement("span", { className: "inline-flex items-center gap-x-1 whitespace-nowrap" },
|
|
4007
4445
|
react_2.default.createElement(solid_1.PlusIcon, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
@@ -4021,7 +4459,7 @@ var NewTable = function (rawProps) {
|
|
|
4021
4459
|
return null;
|
|
4022
4460
|
return (react_2.default.createElement("tr", { "data-testid": "table-group-summary-".concat(group.id), className: "border-l-4 ".concat((_a = ACCENT_CLASS[colourKey]) !== null && _a !== void 0 ? _a : ACCENT_CLASS.default, " ").concat(props.darkMode ? "bg-gray-800" : "bg-gray-50") },
|
|
4023
4461
|
props.checkbox && react_2.default.createElement("td", { className: "w-10 ".concat(cellPadding) }),
|
|
4024
|
-
|
|
4462
|
+
handleMapDrawnColumns({}, function (col, colIndex) {
|
|
4025
4463
|
var _a, _b;
|
|
4026
4464
|
var pin = getPinProps(col.key, false, props.darkMode ? "bg-gray-800" : "bg-gray-50");
|
|
4027
4465
|
var sum = (_a = summary.sums) === null || _a === void 0 ? void 0 : _a[col.key];
|
|
@@ -4145,19 +4583,14 @@ var NewTable = function (rawProps) {
|
|
|
4145
4583
|
react_2.default.createElement("div", { className: "flex items-center overflow-x-auto mx-1 border-l ".concat(props.darkMode ? "border-gray-500" : "") }, renderActionBtns()),
|
|
4146
4584
|
renderCloseBtn())));
|
|
4147
4585
|
};
|
|
4148
|
-
// INFO: determines whether any column uses groupData — if so, a two-row
|
|
4149
|
-
// thead with colSpan/rowSpan is rendered for proper visual grouping.
|
|
4150
|
-
var hasGroupHeaders = columns.some(function (col) {
|
|
4151
|
-
return !col.hide &&
|
|
4152
|
-
col.groupData &&
|
|
4153
|
-
col.groupData.length > 0;
|
|
4154
|
-
});
|
|
4155
4586
|
var renderTableHeader = function () {
|
|
4156
4587
|
var advSettings = props.advSettings;
|
|
4157
4588
|
var cursorClassname = (advSettings === null || advSettings === void 0 ? void 0 : advSettings.dragEnabled) ? "cursor-grab" : "";
|
|
4158
4589
|
var draggable = (advSettings === null || advSettings === void 0 ? void 0 : advSettings.dragEnabled) ? true : false;
|
|
4159
4590
|
var droppable = (advSettings === null || advSettings === void 0 ? void 0 : advSettings.dragEnabled) ? true : false;
|
|
4160
|
-
|
|
4591
|
+
// INFO: no margin of its own — the icons sit in one row (see
|
|
4592
|
+
// renderHeaderIcons) that keeps the title's gap and packs them closer
|
|
4593
|
+
var sortClassname = "flex-shrink-0 h-4 w-4 cursor-pointer";
|
|
4161
4594
|
// INFO: a reference column gets a solid line under its header and a
|
|
4162
4595
|
// lookup a dashed one, so linked columns stand out without taking header
|
|
4163
4596
|
// space; the pattern, not only the colour, tells them apart
|
|
@@ -4174,77 +4607,141 @@ var NewTable = function (rawProps) {
|
|
|
4174
4607
|
return null;
|
|
4175
4608
|
return (react_2.default.createElement("span", { "aria-hidden": "true", "data-testid": "table-column-link-".concat(col.key), "data-link": link, className: "pointer-events-none absolute inset-x-2 bottom-0 border-b-2 ".concat(link === "lookup" ? "border-dashed" : "border-solid", " ").concat(props.darkMode ? "border-primary-300" : "border-primary-400") }));
|
|
4176
4609
|
};
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
var
|
|
4197
|
-
|
|
4198
|
-
event.stopPropagation();
|
|
4199
|
-
(_a = advSettings === null || advSettings === void 0 ? void 0 : advSettings.onDeleteColumn) === null || _a === void 0 ? void 0 : _a.call(advSettings, col.key);
|
|
4200
|
-
} })) : null;
|
|
4201
|
-
var editIcon = handleCanEditColumn(col) ? (react_2.default.createElement(outline_1.PencilSquareIcon, { "data-testid": "table-column-edit-".concat(col.key), className: "".concat(sortClassname, " ").concat(revealClassname), onClick: function (event) {
|
|
4202
|
-
event.stopPropagation();
|
|
4203
|
-
handleEditColumnModal(col.key);
|
|
4204
|
-
} })) : null;
|
|
4205
|
-
var sortColumnEnabled = (_a = advSettings === null || advSettings === void 0 ? void 0 : advSettings.sortOptions) === null || _a === void 0 ? void 0 : _a.some(function (eachOption) { return eachOption.key === col.key; });
|
|
4206
|
-
var filterColumnEnabled = utils_1.supportedAQList.includes((_b = col.type) !== null && _b !== void 0 ? _b : "");
|
|
4207
|
-
if (sortColumnEnabled && (advSettings === null || advSettings === void 0 ? void 0 : advSettings.sortEnabled)) {
|
|
4208
|
-
if (col.key !== ((_c = advSettings.sortId) === null || _c === void 0 ? void 0 : _c.sortId)) {
|
|
4209
|
-
sortIcon = (react_2.default.createElement(solid_2.ArrowsUpDownIcon, { "data-testid": "table-column-sort-".concat(col.key), className: sortClassname, onClick: function () { return handleSort(col.key, "new"); } }));
|
|
4210
|
-
}
|
|
4211
|
-
else if (col.key === advSettings.sortId.sortId) {
|
|
4212
|
-
if (advSettings.sortId.type === "desc") {
|
|
4213
|
-
sortIcon = (react_2.default.createElement(solid_2.BarsArrowDownIcon, { "data-testid": "table-column-sort-".concat(col.key), className: sortClassname, onClick: function () { return handleSort(col.key, "asc"); } }));
|
|
4214
|
-
}
|
|
4215
|
-
else if (advSettings.sortId.type === "asc") {
|
|
4216
|
-
sortIcon = (react_2.default.createElement(solid_2.BarsArrowUpIcon, { "data-testid": "table-column-sort-".concat(col.key), className: sortClassname, onClick: function () { return handleSort(col.key, "desc"); } }));
|
|
4217
|
-
}
|
|
4218
|
-
}
|
|
4219
|
-
}
|
|
4220
|
-
if (filterColumnEnabled && (advSettings === null || advSettings === void 0 ? void 0 : advSettings.filterEnabled)) {
|
|
4221
|
-
filterIcon = (react_2.default.createElement(outline_1.FunnelIcon, { className: sortClassname, onClick: function () { return handleFilterModal(col.key); } }));
|
|
4222
|
-
}
|
|
4223
|
-
// INFO: revealed on hover like hide; a frozen column keeps its lock in
|
|
4224
|
-
// view, so the reader sees which columns are frozen and where to undo it
|
|
4610
|
+
// INFO: a column with a set width keeps its title on one line, cut off
|
|
4611
|
+
// with an ellipsis, so the title never pushes the icons into the next
|
|
4612
|
+
// column. A cut title reads in full in the table's hover tooltip — only
|
|
4613
|
+
// when it is cut, and to a mouse only, as a cut cell value does. A column
|
|
4614
|
+
// sized by its content wraps its title as before.
|
|
4615
|
+
var renderHeaderTitle = function (col, fixed) {
|
|
4616
|
+
return fixed ? (react_2.default.createElement(hoverTooltip_1.HoverTooltip, { className: "min-w-0 truncate", text: typeof col.title === "string" ? col.title : undefined, onlyWhenClipped: true, "data-testid": "table-column-title-".concat(col.key) }, col.title)) : (col.title);
|
|
4617
|
+
};
|
|
4618
|
+
var renderHeaderIcons = function (col, fixedWidth) {
|
|
4619
|
+
var _a, _b, _c, _d;
|
|
4620
|
+
if (fixedWidth === void 0) { fixedWidth = false; }
|
|
4621
|
+
// INFO: only a column's active states stay in view — read only, its
|
|
4622
|
+
// sort, its freeze — so a narrow column keeps room for its title. Every
|
|
4623
|
+
// action sits behind the ⋯ menu, which shows on header hover.
|
|
4624
|
+
var isSortable = !!(advSettings === null || advSettings === void 0 ? void 0 : advSettings.sortEnabled) &&
|
|
4625
|
+
!!((_a = advSettings === null || advSettings === void 0 ? void 0 : advSettings.sortOptions) === null || _a === void 0 ? void 0 : _a.some(function (eachOption) { return eachOption.key === col.key; }));
|
|
4626
|
+
var activeSort = isSortable && ((_b = advSettings === null || advSettings === void 0 ? void 0 : advSettings.sortId) === null || _b === void 0 ? void 0 : _b.sortId) === col.key
|
|
4627
|
+
? advSettings.sortId.type
|
|
4628
|
+
: undefined;
|
|
4629
|
+
var isFilterable = !!(advSettings === null || advSettings === void 0 ? void 0 : advSettings.filterEnabled) &&
|
|
4630
|
+
utils_1.supportedAQList.includes((_c = col.type) !== null && _c !== void 0 ? _c : "");
|
|
4225
4631
|
var drawnFrozenKeys = handleGetDrawnFrozenKeys();
|
|
4226
4632
|
var isFrozen = drawnFrozenKeys.includes(col.key);
|
|
4227
4633
|
var isLastFrozen = drawnFrozenKeys[drawnFrozenKeys.length - 1] === col.key;
|
|
4228
|
-
var FreezeIcon = isFrozen ? outline_1.LockClosedIcon : outline_1.LockOpenIcon;
|
|
4229
4634
|
var freezeLabel = isLastFrozen
|
|
4230
4635
|
? "Unfreeze columns"
|
|
4231
4636
|
: "Freeze up to this column";
|
|
4232
|
-
var
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4637
|
+
var activeColour = props.darkMode
|
|
4638
|
+
? "text-primary-300"
|
|
4639
|
+
: "text-primary-600";
|
|
4640
|
+
// INFO: an editable table marks the columns it will not let you edit —
|
|
4641
|
+
// their cells look like every other cell otherwise. Not clickable; a
|
|
4642
|
+
// hover tooltip says why, to a mouse only. A read-only table needs no
|
|
4643
|
+
// marker, since none of its columns can be edited.
|
|
4644
|
+
var readOnlyLabel = "Editing disabled";
|
|
4645
|
+
var readOnlyIcon = ((_d = props.editable) === null || _d === void 0 ? void 0 : _d.active) && col.disabled ? (react_2.default.createElement(hoverTooltip_1.HoverTooltip, { text: readOnlyLabel, className: "inline-flex flex-shrink-0", "data-testid": "table-column-readonly-tooltip-".concat(col.key) },
|
|
4646
|
+
react_2.default.createElement(outline_1.NoSymbolIcon, { "data-testid": "table-column-readonly-".concat(col.key), role: "img", "aria-label": readOnlyLabel, className: "flex-shrink-0 h-4 w-4 cursor-default ".concat(props.darkMode ? "text-gray-500" : "text-gray-400") }))) : null;
|
|
4647
|
+
// INFO: the current sort reports itself and flips on a click, as it did
|
|
4648
|
+
var SortIcon = activeSort === "desc" ? outline_1.BarsArrowDownIcon : outline_1.BarsArrowUpIcon;
|
|
4649
|
+
var sortIcon = activeSort ? (react_2.default.createElement(SortIcon, { "data-testid": "table-column-sort-".concat(col.key), "data-sort": activeSort, role: "button", "aria-label": activeSort === "desc" ? "Sorted descending" : "Sorted ascending", title: activeSort === "desc" ? "Sorted descending" : "Sorted ascending", className: "".concat(sortClassname, " ").concat(activeColour), onClick: function (event) {
|
|
4650
|
+
event.stopPropagation();
|
|
4651
|
+
handleSort(col.key, activeSort === "desc" ? "asc" : "desc");
|
|
4652
|
+
} })) : null;
|
|
4653
|
+
// INFO: a frozen column keeps its lock in view, so the reader sees which
|
|
4654
|
+
// columns are frozen and where to undo it
|
|
4655
|
+
var freezeIcon = isFrozen && handleCanFreezeColumn(col) ? (react_2.default.createElement(outline_1.LockClosedIcon, { "data-testid": "table-column-freeze-".concat(col.key), "data-frozen": "true", role: "button", "aria-label": freezeLabel, title: freezeLabel, className: "".concat(sortClassname, " ").concat(activeColour), onClick: function (event) {
|
|
4237
4656
|
event.stopPropagation();
|
|
4238
4657
|
handleFreezeColumn(col.key);
|
|
4239
4658
|
} })) : null;
|
|
4240
|
-
|
|
4659
|
+
var menuItems = [];
|
|
4660
|
+
if (isSortable) {
|
|
4661
|
+
menuItems.push({
|
|
4662
|
+
key: "sortAsc",
|
|
4663
|
+
label: "Sort ascending",
|
|
4664
|
+
icon: outline_1.BarsArrowUpIcon,
|
|
4665
|
+
testId: "table-column-sort-asc-".concat(col.key),
|
|
4666
|
+
checked: activeSort === "asc",
|
|
4667
|
+
onClick: function () { return handleSort(col.key, "asc"); },
|
|
4668
|
+
}, {
|
|
4669
|
+
key: "sortDesc",
|
|
4670
|
+
label: "Sort descending",
|
|
4671
|
+
icon: outline_1.BarsArrowDownIcon,
|
|
4672
|
+
testId: "table-column-sort-desc-".concat(col.key),
|
|
4673
|
+
checked: activeSort === "desc",
|
|
4674
|
+
onClick: function () { return handleSort(col.key, "desc"); },
|
|
4675
|
+
});
|
|
4676
|
+
}
|
|
4677
|
+
if (isFilterable)
|
|
4678
|
+
menuItems.push({
|
|
4679
|
+
key: "filter",
|
|
4680
|
+
label: "Filter",
|
|
4681
|
+
icon: outline_1.FunnelIcon,
|
|
4682
|
+
testId: "table-column-filter-".concat(col.key),
|
|
4683
|
+
onClick: function () { return handleFilterModal(col.key); },
|
|
4684
|
+
});
|
|
4685
|
+
// INFO: a frozen column is unfrozen from its lock; the menu offers the
|
|
4686
|
+
// freeze only to a column not yet frozen
|
|
4687
|
+
if (!isFrozen && handleCanFreezeColumn(col))
|
|
4688
|
+
menuItems.push({
|
|
4689
|
+
key: "freeze",
|
|
4690
|
+
// INFO: freezes this column and every column before it
|
|
4691
|
+
label: "Freeze column",
|
|
4692
|
+
icon: outline_1.LockClosedIcon,
|
|
4693
|
+
testId: "table-column-freeze-".concat(col.key),
|
|
4694
|
+
onClick: function () { return handleFreezeColumn(col.key); },
|
|
4695
|
+
});
|
|
4696
|
+
var viewGroupStart = menuItems.length;
|
|
4697
|
+
if (advSettings === null || advSettings === void 0 ? void 0 : advSettings.onHideColumn)
|
|
4698
|
+
menuItems.push({
|
|
4699
|
+
key: "hide",
|
|
4700
|
+
label: "Hide column",
|
|
4701
|
+
icon: outline_1.EyeSlashIcon,
|
|
4702
|
+
testId: "table-column-hide-".concat(col.key),
|
|
4703
|
+
onClick: function () { var _a; return (_a = advSettings === null || advSettings === void 0 ? void 0 : advSettings.onHideColumn) === null || _a === void 0 ? void 0 : _a.call(advSettings, col.key); },
|
|
4704
|
+
});
|
|
4705
|
+
if (handleCanEditColumn(col))
|
|
4706
|
+
menuItems.push({
|
|
4707
|
+
key: "edit",
|
|
4708
|
+
label: "Edit column",
|
|
4709
|
+
icon: outline_1.PencilSquareIcon,
|
|
4710
|
+
testId: "table-column-edit-".concat(col.key),
|
|
4711
|
+
onClick: function () { return handleEditColumnModal(col.key); },
|
|
4712
|
+
});
|
|
4713
|
+
if (col.type === "math")
|
|
4714
|
+
menuItems.push({
|
|
4715
|
+
key: "math",
|
|
4716
|
+
label: "Edit calculation",
|
|
4717
|
+
icon: outline_1.PencilIcon,
|
|
4718
|
+
testId: "table-column-math-".concat(col.key),
|
|
4719
|
+
onClick: function () { return handleAddColumnModal(col.key); },
|
|
4720
|
+
});
|
|
4721
|
+
// INFO: a column the edit panel can open is deleted from inside it; the
|
|
4722
|
+
// menu keeps a delete only for the columns that panel cannot show, so a
|
|
4723
|
+
// column added from the table can still be removed from it
|
|
4724
|
+
if ((advSettings === null || advSettings === void 0 ? void 0 : advSettings.onDeleteColumn) && !handleCanEditColumn(col))
|
|
4725
|
+
menuItems.push({
|
|
4726
|
+
key: "delete",
|
|
4727
|
+
label: "Delete column",
|
|
4728
|
+
icon: outline_1.TrashIcon,
|
|
4729
|
+
testId: "table-column-delete-".concat(col.key),
|
|
4730
|
+
danger: true,
|
|
4731
|
+
divider: true,
|
|
4732
|
+
onClick: function () { var _a; return (_a = advSettings === null || advSettings === void 0 ? void 0 : advSettings.onDeleteColumn) === null || _a === void 0 ? void 0 : _a.call(advSettings, col.key); },
|
|
4733
|
+
});
|
|
4734
|
+
if (viewGroupStart > 0 && menuItems[viewGroupStart])
|
|
4735
|
+
menuItems[viewGroupStart] = __assign(__assign({}, menuItems[viewGroupStart]), { divider: true });
|
|
4736
|
+
if (!readOnlyIcon && !sortIcon && !freezeIcon && menuItems.length === 0)
|
|
4737
|
+
return null;
|
|
4738
|
+
// INFO: the icons sit at the header's right edge, as one group, at least
|
|
4739
|
+
// 12px clear of the title, so every column's icons line up the same way
|
|
4740
|
+
return (react_2.default.createElement("span", { className: "ml-auto flex flex-shrink-0 items-center gap-1.5 pl-3" },
|
|
4741
|
+
readOnlyIcon,
|
|
4241
4742
|
sortIcon,
|
|
4242
|
-
filterIcon,
|
|
4243
4743
|
freezeIcon,
|
|
4244
|
-
|
|
4245
|
-
editIcon,
|
|
4246
|
-
deleteIcon,
|
|
4247
|
-
col.type === "math" && (react_2.default.createElement(outline_1.PencilIcon, { className: sortClassname, onClick: function () { return handleAddColumnModal(col.key); } }))));
|
|
4744
|
+
react_2.default.createElement(columnMenu_1.ColumnMenu, { columnKey: col.key, columnTitle: typeof col.title === "string" ? col.title : col.key, items: menuItems, darkMode: props.darkMode, collapsed: fixedWidth })));
|
|
4248
4745
|
};
|
|
4249
4746
|
var renderAddColumnHeader = function () {
|
|
4250
4747
|
if (!(advSettings === null || advSettings === void 0 ? void 0 : advSettings.addColumnEnabled))
|
|
@@ -4270,18 +4767,20 @@ var NewTable = function (rawProps) {
|
|
|
4270
4767
|
return (react_2.default.createElement("thead", null,
|
|
4271
4768
|
react_2.default.createElement("tr", { className: "border-b ".concat(dividerColor, " ").concat(tableHeaderBgColor, " ").concat(tableHeaderFontColor) },
|
|
4272
4769
|
props.checkbox && (react_2.default.createElement("th", { className: "w-10 ".concat(cellPadding, " ").concat(hasPinColumns ? tableHeaderBgColor : ""), style: handleGetCheckboxPinStyle(3) }, renderSelectAll())),
|
|
4273
|
-
|
|
4770
|
+
handleMapDrawnColumns({ tag: "th" }, function (col) {
|
|
4274
4771
|
var _a, _b, _c, _d;
|
|
4275
|
-
return (react_2.default.createElement("th", { key: col.key, className: "group/th relative ".concat(cellPadding, " text-left text-xs font-semibold uppercase tracking-wide ").concat(cursorClassname, " ").concat((_b = (_a = getPinProps(col.key, true)) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ""), style: __assign(__assign({}, (_c = getPinProps(col.key, true)) === null || _c === void 0 ? void 0 : _c.style), (getColumnWidth(col.key)
|
|
4772
|
+
return (react_2.default.createElement("th", { key: col.key, "data-column-key": col.key, className: "group/th relative ".concat(cellPadding, " text-left text-xs font-semibold uppercase tracking-wide ").concat(cursorClassname, " ").concat((_b = (_a = getPinProps(col.key, true)) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ""), style: __assign(__assign({}, (_c = getPinProps(col.key, true)) === null || _c === void 0 ? void 0 : _c.style), (getColumnWidth(col.key)
|
|
4276
4773
|
? {
|
|
4277
4774
|
width: getColumnWidth(col.key),
|
|
4278
4775
|
minWidth: getColumnWidth(col.key),
|
|
4279
4776
|
maxWidth: getColumnWidth(col.key),
|
|
4280
4777
|
}
|
|
4281
4778
|
: {})), draggable: draggable, onDragStart: function (e) { return handleDragStart(e, col.key); }, onDrop: droppable ? function (e) { return handleDrop(e, col.key); } : undefined, onDragOver: handleDragOver },
|
|
4282
|
-
react_2.default.createElement("div", { className: "group/header flex flex-row items-center ".concat(getColumnWidth(col.key)
|
|
4283
|
-
|
|
4284
|
-
|
|
4779
|
+
react_2.default.createElement("div", { className: "group/header flex flex-row items-center ".concat(getColumnWidth(col.key)
|
|
4780
|
+
? "min-w-0 overflow-hidden"
|
|
4781
|
+
: ((_d = col.width) !== null && _d !== void 0 ? _d : "")) },
|
|
4782
|
+
renderHeaderTitle(col, !!getColumnWidth(col.key)),
|
|
4783
|
+
renderHeaderIcons(col, !!getColumnWidth(col.key))),
|
|
4285
4784
|
renderHeaderLink(col),
|
|
4286
4785
|
react_2.default.createElement("span", { "data-testid": "table-column-resize-".concat(col.key), className: "group/grip absolute inset-y-0 -right-1 z-10 flex w-2 cursor-col-resize touch-none select-none items-stretch justify-center", draggable: false, onPointerDown: function (event) { return handleResizeStart(event, col.key); }, onPointerMove: handleResizeMove, onPointerUp: handleResizeEnd, onPointerCancel: handleResizeEnd, onClick: function (event) { return event.stopPropagation(); } },
|
|
4287
4786
|
react_2.default.createElement("span", { "aria-hidden": "true", className: "w-0.5 rounded-full opacity-0 transition-opacity group-hover/th:opacity-60 group-hover/grip:!opacity-100 ".concat(props.darkMode ? "bg-gray-500" : "bg-gray-300", " group-hover/grip:bg-primary-400") }))));
|
|
@@ -4308,7 +4807,7 @@ var NewTable = function (rawProps) {
|
|
|
4308
4807
|
}
|
|
4309
4808
|
return (react_2.default.createElement("th", { key: col.key, rowSpan: 2, className: "relative ".concat(cellPadding, " text-left text-xs font-semibold uppercase tracking-wide ").concat(cursorClassname, " ").concat((_b = (_a = getPinProps(col.key, true)) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ""), style: (_c = getPinProps(col.key, true)) === null || _c === void 0 ? void 0 : _c.style, draggable: draggable, onDragStart: function (e) { return handleDragStart(e, col.key); }, onDrop: droppable ? function (e) { return handleDrop(e, col.key); } : undefined, onDragOver: handleDragOver },
|
|
4310
4809
|
react_2.default.createElement("div", { className: "group/header flex flex-row items-center ".concat((_d = col.width) !== null && _d !== void 0 ? _d : "") },
|
|
4311
|
-
col
|
|
4810
|
+
renderHeaderTitle(col, false),
|
|
4312
4811
|
renderHeaderIcons(col)),
|
|
4313
4812
|
renderHeaderLink(col)));
|
|
4314
4813
|
}),
|
|
@@ -4328,20 +4827,20 @@ var NewTable = function (rawProps) {
|
|
|
4328
4827
|
};
|
|
4329
4828
|
var renderCheckbox = function (checked, onChange, onClick, extraClassName) { return (react_2.default.createElement("input", { type: "checkbox", checked: checked, onChange: onChange, onClick: onClick, className: "rounded ".concat(props.darkMode ? "border-gray-400" : "border-gray-500", " ").concat(bgColor, " focus:ring-0 focus:ring-offset-0 focus:outline-offset-0 checked:text-primary-400 ").concat(extraClassName !== null && extraClassName !== void 0 ? extraClassName : "") })); };
|
|
4330
4829
|
if (props.mobileView) {
|
|
4331
|
-
var hasPhoneGroups = !!((
|
|
4830
|
+
var hasPhoneGroups = !!((_t = props.groups) === null || _t === void 0 ? void 0 : _t.length);
|
|
4332
4831
|
return (react_2.default.createElement("div", null,
|
|
4333
|
-
react_2.default.createElement("div", { className: "w-full ".concat(((
|
|
4832
|
+
react_2.default.createElement("div", { className: "w-full ".concat(((_u = props.mobileTooltip) === null || _u === void 0 ? void 0 : _u.tooltip) ? "overflow-visible" : "overflow-hidden", " ").concat(isFlat
|
|
4334
4833
|
? ""
|
|
4335
|
-
: "border ".concat(borderRadius, " ").concat(borderColor, " ").concat(bgColor, " shadow-sm"), " divide-y ").concat(dividerColor, " ").concat((
|
|
4834
|
+
: "border ".concat(borderRadius, " ").concat(borderColor, " ").concat(bgColor, " shadow-sm"), " divide-y ").concat(dividerColor, " ").concat((_v = props.className) !== null && _v !== void 0 ? _v : "") },
|
|
4336
4835
|
react_2.default.createElement("div", { className: "p-3 flex items-center justify-between" },
|
|
4337
4836
|
renderSelectAll(),
|
|
4338
4837
|
react_2.default.createElement("div", { className: "flex items-center gap-2" },
|
|
4339
4838
|
renderSelectedCount(),
|
|
4340
|
-
((
|
|
4839
|
+
((_w = props.advSettings) === null || _w === void 0 ? void 0 : _w.addColumnEnabled) && (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"); } })))),
|
|
4341
4840
|
props.loading &&
|
|
4342
4841
|
Array.from({ length: 3 }).map(function (_, i) { return (react_2.default.createElement("div", { key: "skeleton-".concat(i), className: "p-4" },
|
|
4343
4842
|
react_2.default.createElement("div", { className: "h-5 w-3/4 rounded-md animate-pulse ".concat(props.darkMode ? "bg-gray-700" : "bg-gray-200") }))); }),
|
|
4344
|
-
!props.loading && props.data.length === 0 && !hasPhoneGroups && (react_2.default.createElement("p", { className: "p-4 text-center text-sm ".concat(cellFontColor) }, (
|
|
4843
|
+
!props.loading && props.data.length === 0 && !hasPhoneGroups && (react_2.default.createElement("p", { className: "p-4 text-center text-sm ".concat(cellFontColor) }, (_x = props.emptyTitle) !== null && _x !== void 0 ? _x : "No items")),
|
|
4345
4844
|
!props.loading && (props.data.length > 0 || hasPhoneGroups) && (react_2.default.createElement("table", { className: "w-full table-fixed", ref: tableRef },
|
|
4346
4845
|
react_2.default.createElement("tbody", { className: "divide-y ".concat(dividerColor) }, renderDesktopRows())))),
|
|
4347
4846
|
react_2.default.createElement(newPagination_1.NewPagination, { paginationType: props.paginationType, pageIndex: props.pageIndex, limit: props.limit, size: props.size, cursor: props.cursor, resultCount: props.data.length, customPaginationSize: props.customPaginationSize, hidePagination: props.hidePagination, darkMode: props.darkMode, darkModeBg: props.darkModeBg, handleUpdatePageIndex: props.handleUpdatePageIndex, className: "".concat(props.fixedPagination
|
|
@@ -4361,13 +4860,13 @@ var NewTable = function (rawProps) {
|
|
|
4361
4860
|
: [])[0];
|
|
4362
4861
|
return WIDE_EDIT_TYPES.includes((_a = selectedDS === null || selectedDS === void 0 ? void 0 : selectedDS.type) !== null && _a !== void 0 ? _a : "") ? "4xl" : "2xl";
|
|
4363
4862
|
};
|
|
4364
|
-
return (react_2.default.createElement("div", { className: "w-full ".concat((
|
|
4863
|
+
return (react_2.default.createElement("div", { className: "w-full ".concat((_y = props.className) !== null && _y !== void 0 ? _y : "") },
|
|
4365
4864
|
react_2.default.createElement(modal_1.Modal, { open: filterModal ? true : false, title: "Filter Options", renderContent: function () {
|
|
4366
4865
|
var _a, _b;
|
|
4367
4866
|
return (react_2.default.createElement("div", { className: "pb-44" },
|
|
4368
4867
|
react_2.default.createElement("div", { className: "pb-48" }, (_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.renderFilterElements) === null || _b === void 0 ? void 0 : _b.call(_a, filterModal))));
|
|
4369
4868
|
}, onClose: function () { return setFilterModal(""); } }),
|
|
4370
|
-
react_2.default.createElement(modal_1.Modal, { open: modalEditVisible, title: (
|
|
4869
|
+
react_2.default.createElement(modal_1.Modal, { open: modalEditVisible, title: (_0 = (_z = flatColumns.find(function (eachCol) { return eachCol.key === editDataHeaderKey; })) === null || _z === void 0 ? void 0 : _z.title) !== null && _0 !== void 0 ? _0 : "Edit", maxWidth: handleGetEditModalWidth(), onClose: handleModalEditClose, renderContent: function () {
|
|
4371
4870
|
var _a, _b, _c, _d;
|
|
4372
4871
|
var selectedCol = flatColumns.find(function (eachCol) { return eachCol.key === editDataHeaderKey; });
|
|
4373
4872
|
if (!selectedCol)
|
|
@@ -4413,7 +4912,7 @@ var NewTable = function (rawProps) {
|
|
|
4413
4912
|
react_2.default.createElement(scrollShadow_1.ScrollShadow, { className: "w-full overflow-x-auto ".concat(isFlat
|
|
4414
4913
|
? ""
|
|
4415
4914
|
: "".concat(borderRadius, " border ").concat(borderColor, " ").concat(bgColor, " shadow-sm")), darkMode: props.darkMode },
|
|
4416
|
-
(props.selectAll || ((
|
|
4915
|
+
(props.selectAll || ((_2 = (_1 = props.selectedIds) === null || _1 === void 0 ? void 0 : _1.length) !== null && _2 !== void 0 ? _2 : 0) > 0) &&
|
|
4417
4916
|
(!props.multiActionFloatingBtns ||
|
|
4418
4917
|
(props.multiActionFloatingBtns &&
|
|
4419
4918
|
props.multiActionFloatingBtns.length <= 0)) && (react_2.default.createElement("div", { className: "sticky left-0 flex flex-row items-center px-4 py-3 gap-x-2" },
|
|
@@ -4434,14 +4933,14 @@ var NewTable = function (rawProps) {
|
|
|
4434
4933
|
props.loading &&
|
|
4435
4934
|
Array.from({ length: 3 }).map(function (_, i) { return (react_2.default.createElement("tr", { key: "skeleton-".concat(i) },
|
|
4436
4935
|
props.checkbox && react_2.default.createElement("td", { className: "w-10 ".concat(cellPadding) }),
|
|
4437
|
-
|
|
4936
|
+
handleMapDrawnColumns({}, function (col) { return (react_2.default.createElement("td", { key: col.key, className: cellPadding },
|
|
4438
4937
|
react_2.default.createElement("div", { className: "h-5 rounded-md animate-pulse ".concat(props.darkMode ? "bg-gray-700" : "bg-gray-200") }))); }))); }),
|
|
4439
4938
|
!props.loading && renderDesktopRows(),
|
|
4440
4939
|
!props.loading &&
|
|
4441
4940
|
(addData
|
|
4442
4941
|
? !isAddRowPinned && !addGroupId && renderAddDataRow()
|
|
4443
4942
|
: !handleHasGroupAddRows() && renderEmptyAddRow()))),
|
|
4444
|
-
!props.loading && props.data.length === 0 && (react_2.default.createElement("div", { className: "p-4 text-sm ".concat(cellFontColor, " text-center sticky left-0") }, (
|
|
4943
|
+
!props.loading && props.data.length === 0 && (react_2.default.createElement("div", { className: "p-4 text-sm ".concat(cellFontColor, " text-center sticky left-0") }, (_3 = props.emptyTitle) !== null && _3 !== void 0 ? _3 : "No items"))),
|
|
4445
4944
|
renderPinnedAddButton(),
|
|
4446
4945
|
react_2.default.createElement(newPagination_1.NewPagination, { paginationType: props.paginationType, pageIndex: props.pageIndex, limit: props.limit, size: props.size, cursor: props.cursor, resultCount: props.data.length, customPaginationSize: props.customPaginationSize, hidePagination: props.hidePagination, darkMode: props.darkMode, darkModeBg: props.darkModeBg, handleUpdatePageIndex: props.handleUpdatePageIndex, className: "".concat(props.fixedPagination
|
|
4447
4946
|
? "pagination-container w-full ".concat(borderColor, " ").concat(isFixed ? "fixed bottom-0 left-0 z-10" : "sticky top-0 left-0")
|