blixify-ui-web 1.2.255 → 1.2.257

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.
@@ -517,7 +517,7 @@ var handleGetListColour = function (col, value) {
517
517
  return column.listSelectionColour[index] || undefined;
518
518
  };
519
519
  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, _3, _4, _5, _6;
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;
521
521
  // INFO: props are read through the latest render. A row that was not drawn
522
522
  // again keeps the handlers of the render that drew it, and those read
523
523
  // props.onClickRow, props.data and the rest at the time they run — so a
@@ -569,6 +569,10 @@ var NewTable = function (rawProps) {
569
569
  // INFO: the share of the scrolling view the left pins may cover, and the
570
570
  // narrowest the first pinned column is made to fit it
571
571
  var PIN_VIEW_SHARE = 0.6;
572
+ // INFO: on a wide view the frozen columns may cover all but this much, the
573
+ // room one column needs to scroll under them; the share above still rules
574
+ // a narrow view, where this room would be most of it
575
+ var PIN_SCROLL_ROOM = 240;
572
576
  var TITLE_PIN_VIEW_SHARE = 0.7;
573
577
  var MIN_PIN_WIDTH = 96;
574
578
  // INFO: room for the add row's confirm and cancel buttons plus cell padding.
@@ -584,14 +588,23 @@ var NewTable = function (rawProps) {
584
588
  groupData.forEach(function (sub) { return groupedKeys.add("".concat(col.key, ".").concat(sub.key)); });
585
589
  }
586
590
  });
591
+ // INFO: a pin naming a column the table no longer has, such as one a saved
592
+ // view kept after the column was removed, is left out
593
+ var flatKeys = new Set(flatColumns.map(function (col) { return col.key; }));
594
+ var handleKeepPin = function (key) {
595
+ return flatKeys.has(key) && !groupedKeys.has(key);
596
+ };
597
+ // INFO: the columns the host or the reader froze — not the automatic pin
598
+ // of the title below
599
+ var frozenLeftKeys = ((_d = (_c = props.pinColumns) === null || _c === void 0 ? void 0 : _c.left) !== null && _d !== void 0 ? _d : []).filter(handleKeepPin);
600
+ var rightPinned = ((_f = (_e = props.pinColumns) === null || _e === void 0 ? void 0 : _e.right) !== null && _f !== void 0 ? _f : []).filter(handleKeepPin);
587
601
  var activityPin = (props.onRowActivity || props.onRowEdit || props.onRowOpen) &&
588
- !((_d = (_c = props.pinColumns) === null || _c === void 0 ? void 0 : _c.left) === null || _d === void 0 ? void 0 : _d.length) &&
602
+ !frozenLeftKeys.length &&
589
603
  flatColumns[0] &&
590
- !((_f = (_e = props.pinColumns) === null || _e === void 0 ? void 0 : _e.right) === null || _f === void 0 ? void 0 : _f.includes(flatColumns[0].key))
591
- ? [flatColumns[0].key]
604
+ !rightPinned.includes(flatColumns[0].key)
605
+ ? [flatColumns[0].key].filter(handleKeepPin)
592
606
  : [];
593
- var leftPinned = (((_h = (_g = props.pinColumns) === null || _g === void 0 ? void 0 : _g.left) === null || _h === void 0 ? void 0 : _h.length) ? props.pinColumns.left : activityPin).filter(function (key) { return !groupedKeys.has(key); });
594
- var rightPinned = ((_k = (_j = props.pinColumns) === null || _j === void 0 ? void 0 : _j.right) !== null && _k !== void 0 ? _k : []).filter(function (key) { return !groupedKeys.has(key); });
607
+ var leftPinned = frozenLeftKeys.length ? frozenLeftKeys : activityPin;
595
608
  var hasPinColumns = leftPinned.length > 0 || rightPinned.length > 0;
596
609
  // INFO: reorder flatColumns so left-pinned come first, right-pinned come last.
597
610
  if (hasPinColumns) {
@@ -605,7 +618,7 @@ var NewTable = function (rawProps) {
605
618
  flatColumns.length = 0;
606
619
  flatColumns.push.apply(flatColumns, __spreadArray(__spreadArray(__spreadArray([], leftCols, false), middleCols, false), rightCols, false));
607
620
  }
608
- var _7 = (0, react_2.useState)(props.fixedPagination ? true : false), isFixed = _7[0], setIsFixed = _7[1];
621
+ var _3 = (0, react_2.useState)(props.fixedPagination ? true : false), isFixed = _3[0], setIsFixed = _3[1];
609
622
  // INFO: the actions sit over the title cell's right padding: the pencil and
610
623
  // the bubble in divided strips at the edge, then 8px from the text — kept
611
624
  // clear so they never cover the title, and added to the cell's measured
@@ -614,7 +627,7 @@ var NewTable = function (rawProps) {
614
627
  // to take it then, so it never covers the title or its inline editor, and
615
628
  // the column is sized and floored for that wider padding.
616
629
  var hasRowActions = !!props.onRowEdit || !!props.onRowOpen || !!props.onRowActivity;
617
- var canDragRows = !!props.onMoveRowToGroup && !!((_l = props.groups) === null || _l === void 0 ? void 0 : _l.length);
630
+ var canDragRows = !!props.onMoveRowToGroup && !!((_g = props.groups) === null || _g === void 0 ? void 0 : _g.length);
618
631
  var activityStripWidth = props.onRowActivity ? ACTION_STRIP_WIDTH : 0;
619
632
  var editStripWidth = props.onRowEdit ? ACTION_STRIP_WIDTH : 0;
620
633
  var titleActionsWidth = hasRowActions
@@ -624,37 +637,38 @@ var NewTable = function (rawProps) {
624
637
  //=====================================================================================
625
638
  // SECTION: Advanced Settings
626
639
  //=====================================================================================
627
- var _8 = (0, react_2.useState)(""), filterModal = _8[0], setFilterModal = _8[1];
628
- var _9 = (0, react_2.useState)(""), addColumnModal = _9[0], setAddColumnModal = _9[1];
640
+ var _4 = (0, react_2.useState)(""), filterModal = _4[0], setFilterModal = _4[1];
641
+ var _5 = (0, react_2.useState)(""), addColumnModal = _5[0], setAddColumnModal = _5[1];
629
642
  // INFO: what a DataTemplate around the table lets a cell save
630
643
  var columnTypeActions = (0, react_2.useContext)(context_1.ColumnTypeContext);
631
- var _10 = (0, react_2.useState)(""), newColumnName = _10[0], setNewColumnName = _10[1];
632
- var _11 = (0, react_2.useState)("string"), newColumnType = _11[0], setNewColumnType = _11[1];
633
- var _12 = (0, react_2.useState)(""), newColumnRefSpace = _12[0], setNewColumnRefSpace = _12[1];
634
- var _13 = (0, react_2.useState)(""), newColumnRefLabel = _13[0], setNewColumnRefLabel = _13[1];
635
- var _14 = (0, react_2.useState)(""), newColumnLookupReference = _14[0], setNewColumnLookupReference = _14[1];
636
- var _15 = (0, react_2.useState)(""), newColumnLookupField = _15[0], setNewColumnLookupField = _15[1];
637
- var _16 = (0, react_2.useState)([]), newColumnOptions = _16[0], setNewColumnOptions = _16[1];
644
+ var _6 = (0, react_2.useState)(""), newColumnName = _6[0], setNewColumnName = _6[1];
645
+ var _7 = (0, react_2.useState)("string"), newColumnType = _7[0], setNewColumnType = _7[1];
646
+ var _8 = (0, react_2.useState)(""), newColumnRefSpace = _8[0], setNewColumnRefSpace = _8[1];
647
+ var _9 = (0, react_2.useState)(""), newColumnRefLabel = _9[0], setNewColumnRefLabel = _9[1];
648
+ var _10 = (0, react_2.useState)(""), newColumnLookupReference = _10[0], setNewColumnLookupReference = _10[1];
649
+ var _11 = (0, react_2.useState)(""), newColumnLookupField = _11[0], setNewColumnLookupField = _11[1];
650
+ var _12 = (0, react_2.useState)([]), newColumnOptions = _12[0], setNewColumnOptions = _12[1];
638
651
  // INFO: the option row whose colour palette is open
639
- var _17 = (0, react_2.useState)(null), optionColourKey = _17[0], setOptionColourKey = _17[1];
640
- var _18 = (0, react_2.useState)(false), newColumnRequired = _18[0], setNewColumnRequired = _18[1];
641
- var _19 = (0, react_2.useState)(false), newColumnUnique = _19[0], setNewColumnUnique = _19[1];
642
- var _20 = (0, react_2.useState)(false), newColumnReadOnly = _20[0], setNewColumnReadOnly = _20[1];
643
- var _21 = (0, react_2.useState)(""), newColumnRatingMax = _21[0], setNewColumnRatingMax = _21[1];
644
- var _22 = (0, react_2.useState)(""), newColumnButtonLabel = _22[0], setNewColumnButtonLabel = _22[1];
645
- var _23 = (0, react_2.useState)(""), newColumnButtonColour = _23[0], setNewColumnButtonColour = _23[1];
646
- var _24 = (0, react_2.useState)(""), newColumnButtonConfirm = _24[0], setNewColumnButtonConfirm = _24[1];
647
- var _25 = (0, react_2.useState)(false), addingColumn = _25[0], setAddingColumn = _25[1];
652
+ var _13 = (0, react_2.useState)(null), optionColourKey = _13[0], setOptionColourKey = _13[1];
653
+ var _14 = (0, react_2.useState)(false), newColumnRequired = _14[0], setNewColumnRequired = _14[1];
654
+ var _15 = (0, react_2.useState)(false), newColumnUnique = _15[0], setNewColumnUnique = _15[1];
655
+ var _16 = (0, react_2.useState)(false), newColumnReadOnly = _16[0], setNewColumnReadOnly = _16[1];
656
+ var _17 = (0, react_2.useState)(""), newColumnRatingMax = _17[0], setNewColumnRatingMax = _17[1];
657
+ var _18 = (0, react_2.useState)(""), newColumnButtonLabel = _18[0], setNewColumnButtonLabel = _18[1];
658
+ var _19 = (0, react_2.useState)(""), newColumnButtonColour = _19[0], setNewColumnButtonColour = _19[1];
659
+ var _20 = (0, react_2.useState)(""), newColumnButtonConfirm = _20[0], setNewColumnButtonConfirm = _20[1];
660
+ var _21 = (0, react_2.useState)(false), addingColumn = _21[0], setAddingColumn = _21[1];
661
+ var _22 = (0, react_2.useState)(false), confirmDeleteColumn = _22[0], setConfirmDeleteColumn = _22[1];
648
662
  // INFO: the formula as shown in the builder — column names, not ids
649
- var _26 = (0, react_2.useState)(""), newColumnFormula = _26[0], setNewColumnFormula = _26[1];
663
+ var _23 = (0, react_2.useState)(""), newColumnFormula = _23[0], setNewColumnFormula = _23[1];
650
664
  var addColumnPopUpRef = (0, react_2.useRef)(null);
651
665
  // INFO: the column being changed — empty while the panel adds a new one
652
- var _27 = (0, react_2.useState)(null), editingColumn = _27[0], setEditingColumn = _27[1];
666
+ var _24 = (0, react_2.useState)(null), editingColumn = _24[0], setEditingColumn = _24[1];
653
667
  //=====================================================================================
654
668
  // SECTION: Editable & Addable cells
655
669
  //=====================================================================================
656
- var _28 = (0, react_2.useState)(""), editDataRowId = _28[0], setEditDataRowId = _28[1];
657
- var _29 = (0, react_2.useState)(""), editDataHeaderKey = _29[0], setEditDataHeaderKey = _29[1];
670
+ var _25 = (0, react_2.useState)(""), editDataRowId = _25[0], setEditDataRowId = _25[1];
671
+ var _26 = (0, react_2.useState)(""), editDataHeaderKey = _26[0], setEditDataHeaderKey = _26[1];
658
672
  // INFO: an editable table used to mount an input in every cell — it read as a
659
673
  // form, and a row click always landed on a child input. Only the hovered cell
660
674
  // becomes its input now; NewTableHoverCell keeps that hover to itself.
@@ -663,13 +677,13 @@ var NewTable = function (rawProps) {
663
677
  var pendingFocusRef = (0, react_2.useRef)("");
664
678
  // INFO: the cell a gridLines="all" multiple list is being picked in — its
665
679
  // popover hangs from this element
666
- var _30 = (0, react_2.useState)(null), labelPickerAnchor = _30[0], setLabelPickerAnchor = _30[1];
667
- var _31 = (0, react_2.useState)(false), modalEditVisible = _31[0], setModalEditVisible = _31[1];
680
+ var _27 = (0, react_2.useState)(null), labelPickerAnchor = _27[0], setLabelPickerAnchor = _27[1];
681
+ var _28 = (0, react_2.useState)(false), modalEditVisible = _28[0], setModalEditVisible = _28[1];
668
682
  // INFO: whether the modal's signature pad has been drawn on
669
- var _32 = (0, react_2.useState)(false), signatureSigning = _32[0], setSignatureSigning = _32[1];
670
- var _33 = (0, react_2.useState)([]), collapsedGroupIds = _33[0], setCollapsedGroupIds = _33[1];
683
+ var _29 = (0, react_2.useState)(false), signatureSigning = _29[0], setSignatureSigning = _29[1];
684
+ var _30 = (0, react_2.useState)([]), collapsedGroupIds = _30[0], setCollapsedGroupIds = _30[1];
671
685
  // INFO: rows shown per section when the sections do not page themselves
672
- var _34 = (0, react_2.useState)({}), groupVisibleCounts = _34[0], setGroupVisibleCounts = _34[1];
686
+ var _31 = (0, react_2.useState)({}), groupVisibleCounts = _31[0], setGroupVisibleCounts = _31[1];
673
687
  // INFO: per-group scroll pagination. One sentinel element per band, observed
674
688
  // by a single IntersectionObserver that fires props.onGroupLoadMore when a
675
689
  // band's sentinel scrolls into view. The debounce guard stops repeat fires
@@ -687,50 +701,52 @@ var NewTable = function (rawProps) {
687
701
  var lastSelectedRowRef = (0, react_2.useRef)(null);
688
702
  var dragSelectRef = (0, react_2.useRef)(null);
689
703
  var suppressNextClickRef = (0, react_2.useRef)(false);
690
- var _35 = (0, react_2.useState)(false), isDragSelecting = _35[0], setIsDragSelecting = _35[1];
691
- var _36 = (0, react_2.useState)(0), copiedCount = _36[0], setCopiedCount = _36[1];
692
- var _37 = (0, react_2.useState)({}), editDataValue = _37[0], setEditDataValue = _37[1];
693
- var _38 = (0, react_2.useState)(false), editDataIsLoading = _38[0], setEditDataIsLoading = _38[1];
704
+ var _32 = (0, react_2.useState)(false), isDragSelecting = _32[0], setIsDragSelecting = _32[1];
705
+ var _33 = (0, react_2.useState)(0), copiedCount = _33[0], setCopiedCount = _33[1];
706
+ var _34 = (0, react_2.useState)({}), editDataValue = _34[0], setEditDataValue = _34[1];
707
+ var _35 = (0, react_2.useState)(false), editDataIsLoading = _35[0], setEditDataIsLoading = _35[1];
694
708
  // INFO: true while the empty bottom row is being filled in; the row itself is
695
709
  // always there in an addable table
696
- var _39 = (0, react_2.useState)(false), addData = _39[0], setAddData = _39[1];
710
+ var _36 = (0, react_2.useState)(false), addData = _36[0], setAddData = _36[1];
697
711
  var isAddRowPinned = props.paginationType === "scroll";
698
- var _40 = (0, react_2.useState)({}), addDataValue = _40[0], setAddDataValue = _40[1];
712
+ var _37 = (0, react_2.useState)({}), addDataValue = _37[0], setAddDataValue = _37[1];
699
713
  // INFO: bumped after each saved row, so the next one starts with fresh
700
714
  // inputs and its first cell takes the focus
701
- var _41 = (0, react_2.useState)(0), addRowKey = _41[0], setAddRowKey = _41[1];
715
+ var _38 = (0, react_2.useState)(0), addRowKey = _38[0], setAddRowKey = _38[1];
702
716
  // INFO: the add row's coloured multiple list being picked under
703
717
  // gridLines="all" — its label picker hangs from this cell
704
718
  // INFO: the new row's required tag columns left empty on a save — their
705
719
  // cells are ringed red until a label is picked
706
- var _42 = (0, react_2.useState)([]), addTagErrors = _42[0], setAddTagErrors = _42[1];
707
- var _43 = (0, react_2.useState)(null), addLabelPicker = _43[0], setAddLabelPicker = _43[1];
720
+ var _39 = (0, react_2.useState)([]), addTagErrors = _39[0], setAddTagErrors = _39[1];
721
+ var _40 = (0, react_2.useState)(null), addLabelPicker = _40[0], setAddLabelPicker = _40[1];
708
722
  // INFO: the group whose own add row is being filled in; "" = the bottom row
709
- var _44 = (0, react_2.useState)(""), addGroupId = _44[0], setAddGroupId = _44[1];
723
+ var _41 = (0, react_2.useState)(""), addGroupId = _41[0], setAddGroupId = _41[1];
710
724
  // INFO: the row armed by a press on its handle, so only the handle — never
711
725
  // a click or a text selection in a cell — starts a drag
712
- var _45 = (0, react_2.useState)(""), dragArmedRowId = _45[0], setDragArmedRowId = _45[1];
713
- var _46 = (0, react_2.useState)(""), draggingRowId = _46[0], setDraggingRowId = _46[1];
714
- var _47 = (0, react_2.useState)(""), dropGroupId = _47[0], setDropGroupId = _47[1];
715
- var _48 = (0, react_2.useState)({}), referencesOptions = _48[0], setReferencesOptions = _48[1];
726
+ var _42 = (0, react_2.useState)(""), dragArmedRowId = _42[0], setDragArmedRowId = _42[1];
727
+ var _43 = (0, react_2.useState)(""), draggingRowId = _43[0], setDraggingRowId = _43[1];
728
+ var _44 = (0, react_2.useState)(""), dropGroupId = _44[0], setDropGroupId = _44[1];
729
+ var _45 = (0, react_2.useState)({}), referencesOptions = _45[0], setReferencesOptions = _45[1];
716
730
  // INFO: seeded options sit under the local map so a cell's own search
717
731
  // results still win per key
718
- var mergedReferencesOptions = __assign(__assign({}, ((_m = props.referencesOptions) !== null && _m !== void 0 ? _m : {})), referencesOptions);
719
- var _49 = (0, react_2.useState)({}), referencesDetails = _49[0], setReferencesDetails = _49[1];
732
+ var mergedReferencesOptions = __assign(__assign({}, ((_h = props.referencesOptions) !== null && _h !== void 0 ? _h : {})), referencesOptions);
733
+ var _46 = (0, react_2.useState)({}), referencesDetails = _46[0], setReferencesDetails = _46[1];
720
734
  // INFO: per column, the records a search found and the records the parent
721
735
  // passes in, matched by id — a search copies the parent's records into the
722
736
  // local map, so the parent's copy wins and a reload of the list reaches the
723
737
  // cells, while a record only the search found is kept
724
738
  // INFO: worked out once per change, not on every redraw — a cell being
725
739
  // typed into redraws the table on each key
726
- var mergedReferencesDetails = (0, react_2.useMemo)(function () { return handleMergeReferencesDetails(referencesDetails, props.referencesDetails); }, [referencesDetails, props.referencesDetails]);
727
- var _50 = (0, react_2.useState)(false), referenceLoading = _50[0], setReferenceLoading = _50[1];
740
+ var mergedReferencesDetails = (0, react_2.useMemo)(function () {
741
+ return handleMergeReferencesDetails(referencesDetails, props.referencesDetails);
742
+ }, [referencesDetails, props.referencesDetails]);
743
+ var _47 = (0, react_2.useState)(false), referenceLoading = _47[0], setReferenceLoading = _47[1];
728
744
  // INFO: measured pixel widths for pinned columns without an explicit width.
729
- var _51 = (0, react_2.useState)({}), measuredPinWidths = _51[0], setMeasuredPinWidths = _51[1];
745
+ var _48 = (0, react_2.useState)({}), measuredPinWidths = _48[0], setMeasuredPinWidths = _48[1];
730
746
  // INFO: the scrolling view's width, which caps how much the left pins take
731
- var _52 = (0, react_2.useState)(0), pinViewWidth = _52[0], setPinViewWidth = _52[1];
747
+ var _49 = (0, react_2.useState)(0), pinViewWidth = _49[0], setPinViewWidth = _49[1];
732
748
  // INFO: per large group, the rows [start, end) drawn; the rest are spacers
733
- var _53 = (0, react_2.useState)({}), virtualRanges = _53[0], setVirtualRanges = _53[1];
749
+ var _50 = (0, react_2.useState)({}), virtualRanges = _50[0], setVirtualRanges = _50[1];
734
750
  // INFO: each drawn row's measured height, kept so a spacer is as tall as the
735
751
  // rows it stands in for
736
752
  var rowHeightsRef = (0, react_2.useRef)(new Map());
@@ -846,21 +862,19 @@ var NewTable = function (rawProps) {
846
862
  };
847
863
  // eslint-disable-next-line react-hooks/exhaustive-deps
848
864
  }, []);
849
- // INFO: ensures pinned column measurement runs only once per mount.
850
- var hasMeasuredRef = (0, react_2.useRef)(false);
851
865
  //=====================================================================================
852
866
  // SECTION: Style & Classname
853
867
  //=====================================================================================
854
868
  var bgColor = props.darkMode
855
869
  ? props.darkModeBg || "bg-gray-900"
856
870
  : "bg-white";
857
- var isFlat = !!((_o = props.advSettings) === null || _o === void 0 ? void 0 : _o.flat);
871
+ var isFlat = !!((_j = props.advSettings) === null || _j === void 0 ? void 0 : _j.flat);
858
872
  var borderRadius = isFlat ? "" : "rounded-2xl";
859
873
  var borderColor = props.darkMode ? "border-gray-700" : "border-gray-100";
860
874
  var selectedRowBg = props.darkMode ? "bg-gray-700" : "bg-primary-50";
861
875
  var rowHoverBg = props.darkMode ? "hover:bg-gray-700" : "hover:bg-gray-100";
862
876
  var dividerColor = props.darkMode ? "divide-gray-700" : "divide-gray-100";
863
- var gridLines = (_p = props.gridLines) !== null && _p !== void 0 ? _p : "horizontal";
877
+ var gridLines = (_k = props.gridLines) !== null && _k !== void 0 ? _k : "horizontal";
864
878
  // INFO: under gridLines="all" a coloured list cell paints its whole table
865
879
  // cell, like a spreadsheet's cell fill, instead of holding a chip. The Select
866
880
  // inside is told (cellInput.fill) to keep only the label colour. Same shades
@@ -932,8 +946,8 @@ var NewTable = function (rawProps) {
932
946
  var errorFontColor = props.darkMode ? "text-red-300" : "text-red-500";
933
947
  // INFO: an edit commits on blur, but navigating away unmounts the table
934
948
  // without one — the cell was left dirty on screen and the value never sent.
935
- var onUpdateDataRef = (0, react_2.useRef)((_q = props.editable) === null || _q === void 0 ? void 0 : _q.onUpdateData);
936
- onUpdateDataRef.current = (_r = props.editable) === null || _r === void 0 ? void 0 : _r.onUpdateData;
949
+ var onUpdateDataRef = (0, react_2.useRef)((_l = props.editable) === null || _l === void 0 ? void 0 : _l.onUpdateData);
950
+ onUpdateDataRef.current = (_m = props.editable) === null || _m === void 0 ? void 0 : _m.onUpdateData;
937
951
  (0, react_2.useEffect)(function () {
938
952
  return function () {
939
953
  var _a, _b;
@@ -1141,15 +1155,16 @@ var NewTable = function (rawProps) {
1141
1155
  }, [props.groupLoadingStatus]);
1142
1156
  // INFO: one-time measurement of pinned columns without an explicit width.
1143
1157
  // Measures the first body <td> content after data renders — Capacitor-safe.
1158
+ // INFO: a column frozen later, from its header, is measured when it is
1159
+ // first pinned; one measured before keeps its width
1160
+ var pinnedKeysKey = __spreadArray(__spreadArray(__spreadArray([], leftPinned, true), ["|"], false), rightPinned, true).join(",");
1144
1161
  (0, react_2.useEffect)(function () {
1145
1162
  if (!hasPinColumns || !tableRef.current || props.data.length === 0)
1146
1163
  return;
1147
- if (hasMeasuredRef.current)
1148
- return;
1149
1164
  var allPinned = __spreadArray(__spreadArray([], leftPinned, true), rightPinned, true);
1150
1165
  var needsMeasure = allPinned.filter(function (key) {
1151
1166
  var col = flatColumns.find(function (c) { return c.key === key; });
1152
- return !(col === null || col === void 0 ? void 0 : col.width);
1167
+ return !(col === null || col === void 0 ? void 0 : col.width) && !(key in measuredPinWidths);
1153
1168
  });
1154
1169
  if (needsMeasure.length === 0)
1155
1170
  return;
@@ -1196,7 +1211,6 @@ var NewTable = function (rawProps) {
1196
1211
  }
1197
1212
  });
1198
1213
  if (Object.keys(widths).length > 0) {
1199
- hasMeasuredRef.current = true;
1200
1214
  setMeasuredPinWidths(function (prev) {
1201
1215
  var changed = Object.keys(widths).some(function (k) { return prev[k] !== widths[k]; });
1202
1216
  return changed ? __assign(__assign({}, prev), widths) : prev;
@@ -1204,7 +1218,7 @@ var NewTable = function (rawProps) {
1204
1218
  }
1205
1219
  });
1206
1220
  return function () { return cancelAnimationFrame(frameId); };
1207
- }, [hasPinColumns, props.data.length]);
1221
+ }, [hasPinColumns, props.data.length, pinnedKeysKey]);
1208
1222
  (0, react_2.useEffect)(function () {
1209
1223
  var _a;
1210
1224
  if (!hasPinColumns || typeof ResizeObserver === "undefined")
@@ -1655,7 +1669,7 @@ var NewTable = function (rawProps) {
1655
1669
  // it stays here until the table unmounts. Tailwind cannot emit a runtime
1656
1670
  // w-[Npx], so a width drives an inline style and wins over the col.width
1657
1671
  // class.
1658
- var _54 = (0, react_2.useState)({}), columnWidths = _54[0], setColumnWidths = _54[1];
1672
+ var _51 = (0, react_2.useState)({}), columnWidths = _51[0], setColumnWidths = _51[1];
1659
1673
  var resizeRef = (0, react_2.useRef)(null);
1660
1674
  // INFO: a dragged width first, else the column's own fixed width in pixels
1661
1675
  // whatever form it is stored in ("180px", "w-[180px]", "w-48")
@@ -1682,7 +1696,7 @@ var NewTable = function (rawProps) {
1682
1696
  // has a set width — a pinned title, or one dragged or configured. A title
1683
1697
  // sized by its content would widen and shift the table on every hover, so
1684
1698
  // it keeps the chevron's room all the time instead.
1685
- var titleKey = (_s = flatColumns[0]) === null || _s === void 0 ? void 0 : _s.key;
1699
+ var titleKey = (_o = flatColumns[0]) === null || _o === void 0 ? void 0 : _o.key;
1686
1700
  var isTitleWidthFixed = !!titleKey &&
1687
1701
  (leftPinned.includes(titleKey) ||
1688
1702
  rightPinned.includes(titleKey) ||
@@ -1756,6 +1770,56 @@ var NewTable = function (rawProps) {
1756
1770
  (_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onDragColumn) === null || _b === void 0 ? void 0 : _b.call(_a, data, id, clonedHeader);
1757
1771
  }
1758
1772
  };
1773
+ // INFO: only where the built-in panel can show the column — a type it
1774
+ // offers (a math column opens its formula from its own pencil, an object
1775
+ // column needs the nested schema) — and its definition is read on click
1776
+ var handleCanEditColumn = function (col) {
1777
+ var _a, _b, _c, _d;
1778
+ return !!((_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onEditColumn) &&
1779
+ !!((_b = props.advSettings) === null || _b === void 0 ? void 0 : _b.getColumnSchema) &&
1780
+ !!((_c = props.advSettings) === null || _c === void 0 ? void 0 : _c.onAddColumn) &&
1781
+ !((_d = props.advSettings) === null || _d === void 0 ? void 0 : _d.renderAddColumnElements) &&
1782
+ ADD_COLUMN_TYPES.some(function (eachType) { return eachType.key === col.type; });
1783
+ };
1784
+ // INFO: every body cell of a pinned column carries its key, because the
1785
+ // width measurement finds the cell by it; a cell without it is never
1786
+ // measured and the next pinned column is placed by a guessed width
1787
+ var handleGetPinKey = function (key) {
1788
+ return leftPinned.includes(key) || rightPinned.includes(key) ? key : undefined;
1789
+ };
1790
+ // INFO: whether a header can freeze its column — not a grouped column, a
1791
+ // column pinned right, or a system column such as created at
1792
+ var handleCanFreezeColumn = function (col) {
1793
+ var _a, _b;
1794
+ return !!((_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onPinColumns) &&
1795
+ !groupedKeys.has(col.key) &&
1796
+ !(((_b = col.groupData) === null || _b === void 0 ? void 0 : _b.length) > 0) &&
1797
+ !rightPinned.includes(col.key) &&
1798
+ !(0, systemColumns_1.handleIsSystemColumn)(col.key);
1799
+ };
1800
+ // INFO: the frozen columns the view has room to keep at the left edge; a
1801
+ // frozen column dropped to fit shows an open lock, as it scrolls
1802
+ var handleGetDrawnFrozenKeys = function () {
1803
+ return frozenLeftKeys.filter(function (key) { return key in fittedLeftPins; });
1804
+ };
1805
+ // INFO: freezes every column shown before this one and the column itself,
1806
+ // in the order they are drawn; freezing the last frozen column again
1807
+ // unfreezes them all
1808
+ var handleFreezeColumn = function (key) {
1809
+ var _a, _b;
1810
+ var order = flatColumns
1811
+ .map(function (col) { return col.key; })
1812
+ .filter(function (eachKey) { return handleKeepPin(eachKey); })
1813
+ .filter(function (eachKey) { return !rightPinned.includes(eachKey); });
1814
+ var index = order.indexOf(key);
1815
+ if (index < 0)
1816
+ return;
1817
+ var drawnFrozenKeys = handleGetDrawnFrozenKeys();
1818
+ var isLastFrozen = drawnFrozenKeys[drawnFrozenKeys.length - 1] === key;
1819
+ (_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onPinColumns) === null || _b === void 0 ? void 0 : _b.call(_a, {
1820
+ left: isLastFrozen ? [] : order.slice(0, index + 1),
1821
+ });
1822
+ };
1759
1823
  var handleSort = function (id, type) {
1760
1824
  var _a, _b;
1761
1825
  (_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onSortColumn) === null || _b === void 0 ? void 0 : _b.call(_a, {
@@ -1764,7 +1828,7 @@ var NewTable = function (rawProps) {
1764
1828
  });
1765
1829
  };
1766
1830
  var renderAddColumnPanel = function () {
1767
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1831
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1768
1832
  // INFO: a caller that renders its own form keeps full control; the
1769
1833
  // built-in one only appears when it hands over onAddColumn instead
1770
1834
  if ((_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.renderAddColumnElements)
@@ -1844,7 +1908,8 @@ var NewTable = function (rawProps) {
1844
1908
  !derivedId ||
1845
1909
  taken ||
1846
1910
  addingColumn ||
1847
- !handleIsNewColumnReady(), onClick: handleSubmitNewColumn }))));
1911
+ !handleIsNewColumnReady(), onClick: handleSubmitNewColumn })),
1912
+ editingColumn && ((_k = props.advSettings) === null || _k === void 0 ? void 0 : _k.onDeleteColumn) && (react_2.default.createElement(textButton_1.TextButton, { id: "table-column-panel-delete", className: "self-start text-sm !text-red-600 hover:!text-red-700", text: confirmDeleteColumn ? "Confirm delete" : "Delete column", disable: addingColumn, onClick: handleDeleteEditingColumn }))));
1848
1913
  };
1849
1914
  var renderAddColumnModal = function () { return (react_2.default.createElement(modal_1.Modal, { open: addColumnModal ? true : false, maxWidth: newColumnType === "formula" ? "2xl" : undefined, title: editingColumn ? "Edit Column" : "Add Column", renderContent: renderAddColumnPanel, onClose: function () { return handleAddColumnModal(""); } })); };
1850
1915
  var handleChangeOption = function (key, change) {
@@ -1973,8 +2038,38 @@ var NewTable = function (rawProps) {
1973
2038
  var top = panel.getBoundingClientRect().top;
1974
2039
  panel.style.maxHeight = "".concat(Math.max(240, window.innerHeight - top - 16), "px");
1975
2040
  };
2041
+ var handleDeleteEditingColumn = function () { return __awaiter(void 0, void 0, void 0, function () {
2042
+ var _a, _b;
2043
+ return __generator(this, function (_c) {
2044
+ switch (_c.label) {
2045
+ case 0:
2046
+ if (!editingColumn)
2047
+ return [2 /*return*/];
2048
+ if (!confirmDeleteColumn) {
2049
+ setConfirmDeleteColumn(true);
2050
+ return [2 /*return*/];
2051
+ }
2052
+ // INFO: the button is disabled while this runs, so a double click on
2053
+ // Confirm delete reports the delete once
2054
+ setAddingColumn(true);
2055
+ _c.label = 1;
2056
+ case 1:
2057
+ _c.trys.push([1, , 3, 4]);
2058
+ return [4 /*yield*/, ((_b = (_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.onDeleteColumn) === null || _b === void 0 ? void 0 : _b.call(_a, editingColumn.id))];
2059
+ case 2:
2060
+ _c.sent();
2061
+ handleAddColumnModal("");
2062
+ return [3 /*break*/, 4];
2063
+ case 3:
2064
+ setAddingColumn(false);
2065
+ return [7 /*endfinally*/];
2066
+ case 4: return [2 /*return*/];
2067
+ }
2068
+ });
2069
+ }); };
1976
2070
  var handleAddColumnModal = function (id) {
1977
2071
  setAddColumnModal(id);
2072
+ setConfirmDeleteColumn(false);
1978
2073
  if (!id) {
1979
2074
  setEditingColumn(null);
1980
2075
  setNewColumnName("");
@@ -2492,14 +2587,15 @@ var NewTable = function (rawProps) {
2492
2587
  return Math.max(width, (_b = getTitleMinWidth(key)) !== null && _b !== void 0 ? _b : 0);
2493
2588
  };
2494
2589
  var pinCheckboxOffset = props.checkbox &&
2495
- (props.data.length > 0 || (props.spaceData && ((_t = props.spaceData) === null || _t === void 0 ? void 0 : _t.length) > 0))
2590
+ (props.data.length > 0 || (props.spaceData && ((_p = props.spaceData) === null || _p === void 0 ? void 0 : _p.length) > 0))
2496
2591
  ? CHECKBOX_WIDTH
2497
2592
  : 0;
2498
2593
  /**
2499
2594
  * INFO: sticky columns wider than the view cover every column that scrolls,
2500
2595
  * so on a phone in portrait the table did scroll, but always underneath the
2501
2596
  * pinned title and looked stuck. While every pin (the checkbox, left and
2502
- * right pins, the "+" and Actions) fits in PIN_VIEW_SHARE of the view,
2597
+ * right pins, the "+" and Actions) fits in PIN_VIEW_SHARE of the view, or
2598
+ * all of it but PIN_SCROLL_ROOM on a wide one,
2503
2599
  * nothing changes. Past that only the first column stays pinned, narrowed to
2504
2600
  * fit with its text wrapping, and everything else scrolls with the table.
2505
2601
  */
@@ -2510,12 +2606,27 @@ var NewTable = function (rawProps) {
2510
2606
  var rightNatural = rightPinned.reduce(function (sum, key) { return sum + handleGetPinWidth(key); }, 0) +
2511
2607
  (handleShowsActionColumn() ? ACTION_COLUMN_WIDTH : 0) +
2512
2608
  (((_a = props.advSettings) === null || _a === void 0 ? void 0 : _a.addColumnEnabled) ? ADD_COLUMN_WIDTH : 0);
2513
- var budget = pinViewWidth ? pinViewWidth * PIN_VIEW_SHARE : Infinity;
2609
+ var budget = pinViewWidth
2610
+ ? Math.max(pinViewWidth * PIN_VIEW_SHARE, pinViewWidth - PIN_SCROLL_ROOM)
2611
+ : Infinity;
2514
2612
  var widths = {};
2515
2613
  if (leftNatural + rightNatural <= budget) {
2516
2614
  leftPinned.forEach(function (key) { return (widths[key] = handleGetPinWidth(key)); });
2517
2615
  return { widths: widths, narrow: false };
2518
2616
  }
2617
+ // INFO: several frozen columns past the share — the last ones scroll
2618
+ // again until the rest fit, so a view frozen on a wide screen still
2619
+ // scrolls on a narrow one. Nothing is saved; a wider view freezes them all
2620
+ // again. Only when the first alone does not fit does the narrow fallback
2621
+ // below take over.
2622
+ var kept = __spreadArray([], leftPinned, true);
2623
+ var keptWidth = leftNatural;
2624
+ while (kept.length > 1 && keptWidth + rightNatural > budget)
2625
+ keptWidth -= handleGetPinWidth(kept.pop());
2626
+ if (kept.length > 0 && keptWidth + rightNatural <= budget) {
2627
+ kept.forEach(function (key) { return (widths[key] = handleGetPinWidth(key)); });
2628
+ return { widths: widths, narrow: false };
2629
+ }
2519
2630
  var first = leftPinned[0];
2520
2631
  // INFO: a title that carries its row's actions keeps a larger share, so
2521
2632
  // its text is not squeezed to a few letters a line beside them
@@ -2777,7 +2888,7 @@ var NewTable = function (rawProps) {
2777
2888
  ? "cursor-pointer hover:brightness-95 ".concat(isFillActive ? "!shadow-[inset_0_0_0_2px_rgba(255,255,255,0.85)]" : "")
2778
2889
  : "cursor-pointer ".concat(props.darkMode ? "hover:bg-gray-800" : "hover:bg-gray-50", " ").concat(isFillActive ? "!shadow-[inset_0_0_0_2px_#9ca3af]" : "");
2779
2890
  var pinProps = getPinProps(col.key, false, rowBgClass, isHoverable);
2780
- return (react_2.default.createElement("td", { key: col.key + String(colIndex), "data-cell-key": col.key, "data-edit-cell": "".concat(rowId, ":").concat(col.key), "data-cell-fill": cellFill ? "" : undefined,
2891
+ 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,
2781
2892
  // INFO: pinned columns use whitespace-normal so text wraps within the fixed width.
2782
2893
  // col.width must match the read-only cell's width source so a column keeps one
2783
2894
  // width whether a row is being edited or shown read-only — without it the cell
@@ -2923,7 +3034,7 @@ var NewTable = function (rawProps) {
2923
3034
  };
2924
3035
  // INFO: worked out here, after the Actions and "+" helpers it reads, and
2925
3036
  // only read by the render helpers called from the return below
2926
- var _55 = handleFitPins(), fittedLeftPins = _55.widths, narrowPins = _55.narrow;
3037
+ var _52 = handleFitPins(), fittedLeftPins = _52.widths, narrowPins = _52.narrow;
2927
3038
  var renderActionColumnHeader = function () {
2928
3039
  if (handleShowsActionColumn()) {
2929
3040
  var pin = handleGetActionCellPin(true);
@@ -3009,7 +3120,7 @@ var NewTable = function (rawProps) {
3009
3120
  isPicking && addLabelPicker && (react_2.default.createElement(labelPicker_1.LabelPicker, { anchor: addLabelPicker.anchor, darkMode: props.darkMode, options: ((_a = col.listSelection) !== null && _a !== void 0 ? _a : []).map(function (key) { return ({
3010
3121
  key: String(key),
3011
3122
  color: handleGetListColour(col, key),
3012
- }); }), value: picks, required: (0, updateModule_1.handleIsFieldRequired)(col, addDataValue),
3123
+ }); }), value: picks, required: (0, updateModule_1.handleIsFieldRequired)(col, addDataValue), allowNewValue: !!col.listNewValue,
3013
3124
  // INFO: through the same clone every other cell's change takes,
3014
3125
  // so the row keeps the defaults it shows (a required date's
3015
3126
  // today, a required list's first option) when this is the only
@@ -3111,7 +3222,7 @@ var NewTable = function (rawProps) {
3111
3222
  };
3112
3223
  // INFO: true when maxSelectedCount is set and the current selection has reached the limit
3113
3224
  var isMaxReached = !!props.maxSelectedCount &&
3114
- ((_v = (_u = props.selectedIds) === null || _u === void 0 ? void 0 : _u.length) !== null && _v !== void 0 ? _v : 0) >= props.maxSelectedCount;
3225
+ ((_r = (_q = props.selectedIds) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r : 0) >= props.maxSelectedCount;
3115
3226
  // INFO: one desktop row. groupAccent carries the group's colour so member
3116
3227
  // rows show the band's colour as a bar down their left edge.
3117
3228
  var handleRowDragStart = function (event, rowId) {
@@ -3510,7 +3621,7 @@ var NewTable = function (rawProps) {
3510
3621
  columnTypeActions.canUpdate &&
3511
3622
  columnTypeActions.onUpdateCell &&
3512
3623
  !col.disabled)
3513
- return (react_2.default.createElement("td", { key: col.key, "data-cell-key": col.key,
3624
+ return (react_2.default.createElement("td", { key: col.key, "data-cell-key": col.key, "data-pin-key": handleGetPinKey(col.key),
3514
3625
  // INFO: no padding — the cell's own button carries it, so the
3515
3626
  // whole cell is the click target. Under gridLines="all" the
3516
3627
  // cell is the box the open cell's ring covers.
@@ -3577,7 +3688,7 @@ var NewTable = function (rawProps) {
3577
3688
  var shouldNavigateOnClick = !((_q = props.editable) === null || _q === void 0 ? void 0 : _q.active);
3578
3689
  var cellFill = handleGetCellFill(col, rawListValue);
3579
3690
  var pinProps = getPinProps(col.key, false, rowBgClass, isRowHoverable);
3580
- return (react_2.default.createElement("td", { key: col.key, "data-cell-fill": cellFill ? "" : undefined, className: "p-0 align-middle ".concat(cellFill ? handleDropCellBg(pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) : ((_r = pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) !== null && _r !== void 0 ? _r : ""), " ").concat((_s = cellFill === null || cellFill === void 0 ? void 0 : cellFill.className) !== null && _s !== void 0 ? _s : ""), style: __assign(__assign({}, pinProps === null || pinProps === void 0 ? void 0 : pinProps.style), cellFill === null || cellFill === void 0 ? void 0 : cellFill.style) },
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) : ((_r = pinProps === null || pinProps === void 0 ? void 0 : pinProps.className) !== null && _r !== void 0 ? _r : ""), " ").concat((_s = cellFill === null || cellFill === void 0 ? void 0 : cellFill.className) !== null && _s !== void 0 ? _s : ""), style: __assign(__assign({}, pinProps === null || pinProps === void 0 ? void 0 : pinProps.style), cellFill === null || cellFill === void 0 ? void 0 : cellFill.style) },
3581
3692
  react_2.default.createElement("div", { className: "relative ".concat(cellFill ? "w-full" : "w-max", " whitespace-nowrap p-[1px]") },
3582
3693
  renderFormCell(row, readOnlyDS, null, {
3583
3694
  active: true,
@@ -3646,7 +3757,9 @@ var NewTable = function (rawProps) {
3646
3757
  var isPicking = isLabelPickerColumn && isCellEditing && !!labelPickerAnchor;
3647
3758
  var handleOpenCell_1 = function (target) {
3648
3759
  if (gridLines === "all") {
3649
- handleOpenAfterLeaving(target, function () { return handleOpenTagCell_1(target); });
3760
+ handleOpenAfterLeaving(target, function () {
3761
+ return handleOpenTagCell_1(target);
3762
+ });
3650
3763
  return;
3651
3764
  }
3652
3765
  handleOpenTagCell_1(target);
@@ -3661,7 +3774,7 @@ var NewTable = function (rawProps) {
3661
3774
  pendingFocusRef.current = "".concat(row.id, ":").concat(col.key);
3662
3775
  };
3663
3776
  var pickedValue = resolveValue((isCellEditing ? rowData : row), col.key);
3664
- return (react_2.default.createElement("td", { key: col.key, "data-cell-key": col.key, className: "".concat(editCellPadding, " ").concat(handleCellMinWidth(col.type), " ").concat(handleReadCellWidthClass(col), " text-sm ").concat(cellFontColor, " ").concat((_2 = (_1 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _1 === void 0 ? void 0 : _1.className) !== null && _2 !== void 0 ? _2 : "", " ").concat(isPicking ? "!shadow-[inset_0_0_0_2px_#9ca3af]" : ""), style: (_3 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _3 === void 0 ? void 0 : _3.style },
3777
+ return (react_2.default.createElement("td", { key: col.key, "data-cell-key": col.key, "data-pin-key": handleGetPinKey(col.key), className: "".concat(editCellPadding, " ").concat(handleCellMinWidth(col.type), " ").concat(handleReadCellWidthClass(col), " text-sm ").concat(cellFontColor, " ").concat((_2 = (_1 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _1 === void 0 ? void 0 : _1.className) !== null && _2 !== void 0 ? _2 : "", " ").concat(isPicking ? "!shadow-[inset_0_0_0_2px_#9ca3af]" : ""), style: (_3 = getPinProps(col.key, false, rowBgClass, isRowHoverable)) === null || _3 === void 0 ? void 0 : _3.style },
3665
3778
  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) {
3666
3779
  e.stopPropagation();
3667
3780
  handleOpenCell_1(e.currentTarget);
@@ -3672,7 +3785,7 @@ var NewTable = function (rawProps) {
3672
3785
  e.stopPropagation();
3673
3786
  handleOpenCell_1(e.currentTarget);
3674
3787
  } }, renderTagLine(col, isLabelPickerColumn ? pickedValue : cellValue)),
3675
- isPicking && labelPickerAnchor && (react_2.default.createElement(labelPicker_1.LabelPicker, { anchor: labelPickerAnchor, darkMode: props.darkMode, required: (0, updateModule_1.handleIsFieldRequired)(col, rowData), options: ((_4 = col.listSelection) !== null && _4 !== void 0 ? _4 : []).map(function (key) { return ({
3788
+ 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: ((_4 = col.listSelection) !== null && _4 !== void 0 ? _4 : []).map(function (key) { return ({
3676
3789
  key: String(key),
3677
3790
  color: handleGetListColour(col, key),
3678
3791
  }); }), value: (Array.isArray(pickedValue)
@@ -4077,22 +4190,15 @@ var NewTable = function (rawProps) {
4077
4190
  event.stopPropagation();
4078
4191
  (_a = advSettings === null || advSettings === void 0 ? void 0 : advSettings.onHideColumn) === null || _a === void 0 ? void 0 : _a.call(advSettings, col.key);
4079
4192
  } })) : null;
4080
- // INFO: revealed on hover like hide, and only when the caller can act on
4081
- // it. Adding a column from the table is one-way otherwise — a typo means
4082
- // leaving the page for the schema editor to undo it.
4083
- var deleteIcon = (advSettings === null || advSettings === void 0 ? void 0 : advSettings.onDeleteColumn) ? (react_2.default.createElement(outline_1.TrashIcon, { "data-testid": "table-column-delete-".concat(col.key), className: "".concat(sortClassname, " ").concat(revealClassname, " text-red-400 hover:text-red-600"), onClick: function (event) {
4193
+ // INFO: a column the edit panel can open is deleted from inside it; the
4194
+ // header keeps a trash only for the columns that panel cannot show, so
4195
+ // a column added from the table can still be removed from it
4196
+ var deleteIcon = (advSettings === null || advSettings === void 0 ? void 0 : advSettings.onDeleteColumn) && !handleCanEditColumn(col) ? (react_2.default.createElement(outline_1.TrashIcon, { "data-testid": "table-column-delete-".concat(col.key), className: "".concat(sortClassname, " ").concat(revealClassname, " text-red-400 hover:text-red-600"), onClick: function (event) {
4084
4197
  var _a;
4085
4198
  event.stopPropagation();
4086
4199
  (_a = advSettings === null || advSettings === void 0 ? void 0 : advSettings.onDeleteColumn) === null || _a === void 0 ? void 0 : _a.call(advSettings, col.key);
4087
4200
  } })) : null;
4088
- // INFO: only where the built-in panel can show the column — a type it
4089
- // offers (a math column opens its formula from its own pencil, an object
4090
- // column needs the nested schema) — and its definition is read on click
4091
- var editIcon = (advSettings === null || advSettings === void 0 ? void 0 : advSettings.onEditColumn) &&
4092
- (advSettings === null || advSettings === void 0 ? void 0 : advSettings.getColumnSchema) &&
4093
- (advSettings === null || advSettings === void 0 ? void 0 : advSettings.onAddColumn) &&
4094
- !(advSettings === null || advSettings === void 0 ? void 0 : advSettings.renderAddColumnElements) &&
4095
- ADD_COLUMN_TYPES.some(function (eachType) { return eachType.key === col.type; }) ? (react_2.default.createElement(outline_1.PencilSquareIcon, { "data-testid": "table-column-edit-".concat(col.key), className: "".concat(sortClassname, " ").concat(revealClassname), onClick: function (event) {
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) {
4096
4202
  event.stopPropagation();
4097
4203
  handleEditColumnModal(col.key);
4098
4204
  } })) : null;
@@ -4114,9 +4220,27 @@ var NewTable = function (rawProps) {
4114
4220
  if (filterColumnEnabled && (advSettings === null || advSettings === void 0 ? void 0 : advSettings.filterEnabled)) {
4115
4221
  filterIcon = (react_2.default.createElement(outline_1.FunnelIcon, { className: sortClassname, onClick: function () { return handleFilterModal(col.key); } }));
4116
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
4225
+ var drawnFrozenKeys = handleGetDrawnFrozenKeys();
4226
+ var isFrozen = drawnFrozenKeys.includes(col.key);
4227
+ var isLastFrozen = drawnFrozenKeys[drawnFrozenKeys.length - 1] === col.key;
4228
+ var FreezeIcon = isFrozen ? outline_1.LockClosedIcon : outline_1.LockOpenIcon;
4229
+ var freezeLabel = isLastFrozen
4230
+ ? "Unfreeze columns"
4231
+ : "Freeze up to this column";
4232
+ var freezeIcon = handleCanFreezeColumn(col) ? (react_2.default.createElement(FreezeIcon, { "data-testid": "table-column-freeze-".concat(col.key), "data-frozen": isFrozen ? "true" : "false", role: "button", "aria-label": freezeLabel, title: freezeLabel, className: "".concat(sortClassname, " ").concat(isFrozen
4233
+ ? props.darkMode
4234
+ ? "text-primary-300"
4235
+ : "text-primary-600"
4236
+ : revealClassname), onClick: function (event) {
4237
+ event.stopPropagation();
4238
+ handleFreezeColumn(col.key);
4239
+ } })) : null;
4117
4240
  return (react_2.default.createElement(react_2.default.Fragment, null,
4118
4241
  sortIcon,
4119
4242
  filterIcon,
4243
+ freezeIcon,
4120
4244
  hideIcon,
4121
4245
  editIcon,
4122
4246
  deleteIcon,
@@ -4204,20 +4328,20 @@ var NewTable = function (rawProps) {
4204
4328
  };
4205
4329
  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 : "") })); };
4206
4330
  if (props.mobileView) {
4207
- var hasPhoneGroups = !!((_w = props.groups) === null || _w === void 0 ? void 0 : _w.length);
4331
+ var hasPhoneGroups = !!((_s = props.groups) === null || _s === void 0 ? void 0 : _s.length);
4208
4332
  return (react_2.default.createElement("div", null,
4209
- react_2.default.createElement("div", { className: "w-full ".concat(((_x = props.mobileTooltip) === null || _x === void 0 ? void 0 : _x.tooltip) ? "overflow-visible" : "overflow-hidden", " ").concat(isFlat
4333
+ react_2.default.createElement("div", { className: "w-full ".concat(((_t = props.mobileTooltip) === null || _t === void 0 ? void 0 : _t.tooltip) ? "overflow-visible" : "overflow-hidden", " ").concat(isFlat
4210
4334
  ? ""
4211
- : "border ".concat(borderRadius, " ").concat(borderColor, " ").concat(bgColor, " shadow-sm"), " divide-y ").concat(dividerColor, " ").concat((_y = props.className) !== null && _y !== void 0 ? _y : "") },
4335
+ : "border ".concat(borderRadius, " ").concat(borderColor, " ").concat(bgColor, " shadow-sm"), " divide-y ").concat(dividerColor, " ").concat((_u = props.className) !== null && _u !== void 0 ? _u : "") },
4212
4336
  react_2.default.createElement("div", { className: "p-3 flex items-center justify-between" },
4213
4337
  renderSelectAll(),
4214
4338
  react_2.default.createElement("div", { className: "flex items-center gap-2" },
4215
4339
  renderSelectedCount(),
4216
- ((_z = props.advSettings) === null || _z === void 0 ? void 0 : _z.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"); } })))),
4340
+ ((_v = props.advSettings) === null || _v === void 0 ? void 0 : _v.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"); } })))),
4217
4341
  props.loading &&
4218
4342
  Array.from({ length: 3 }).map(function (_, i) { return (react_2.default.createElement("div", { key: "skeleton-".concat(i), className: "p-4" },
4219
4343
  react_2.default.createElement("div", { className: "h-5 w-3/4 rounded-md animate-pulse ".concat(props.darkMode ? "bg-gray-700" : "bg-gray-200") }))); }),
4220
- !props.loading && props.data.length === 0 && !hasPhoneGroups && (react_2.default.createElement("p", { className: "p-4 text-center text-sm ".concat(cellFontColor) }, (_0 = props.emptyTitle) !== null && _0 !== void 0 ? _0 : "No items")),
4344
+ !props.loading && props.data.length === 0 && !hasPhoneGroups && (react_2.default.createElement("p", { className: "p-4 text-center text-sm ".concat(cellFontColor) }, (_w = props.emptyTitle) !== null && _w !== void 0 ? _w : "No items")),
4221
4345
  !props.loading && (props.data.length > 0 || hasPhoneGroups) && (react_2.default.createElement("table", { className: "w-full table-fixed", ref: tableRef },
4222
4346
  react_2.default.createElement("tbody", { className: "divide-y ".concat(dividerColor) }, renderDesktopRows())))),
4223
4347
  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
@@ -4237,13 +4361,13 @@ var NewTable = function (rawProps) {
4237
4361
  : [])[0];
4238
4362
  return WIDE_EDIT_TYPES.includes((_a = selectedDS === null || selectedDS === void 0 ? void 0 : selectedDS.type) !== null && _a !== void 0 ? _a : "") ? "4xl" : "2xl";
4239
4363
  };
4240
- return (react_2.default.createElement("div", { className: "w-full ".concat((_1 = props.className) !== null && _1 !== void 0 ? _1 : "") },
4364
+ return (react_2.default.createElement("div", { className: "w-full ".concat((_x = props.className) !== null && _x !== void 0 ? _x : "") },
4241
4365
  react_2.default.createElement(modal_1.Modal, { open: filterModal ? true : false, title: "Filter Options", renderContent: function () {
4242
4366
  var _a, _b;
4243
4367
  return (react_2.default.createElement("div", { className: "pb-44" },
4244
4368
  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))));
4245
4369
  }, onClose: function () { return setFilterModal(""); } }),
4246
- react_2.default.createElement(modal_1.Modal, { open: modalEditVisible, title: (_3 = (_2 = flatColumns.find(function (eachCol) { return eachCol.key === editDataHeaderKey; })) === null || _2 === void 0 ? void 0 : _2.title) !== null && _3 !== void 0 ? _3 : "Edit", maxWidth: handleGetEditModalWidth(), onClose: handleModalEditClose, renderContent: function () {
4370
+ react_2.default.createElement(modal_1.Modal, { open: modalEditVisible, title: (_z = (_y = flatColumns.find(function (eachCol) { return eachCol.key === editDataHeaderKey; })) === null || _y === void 0 ? void 0 : _y.title) !== null && _z !== void 0 ? _z : "Edit", maxWidth: handleGetEditModalWidth(), onClose: handleModalEditClose, renderContent: function () {
4247
4371
  var _a, _b, _c, _d;
4248
4372
  var selectedCol = flatColumns.find(function (eachCol) { return eachCol.key === editDataHeaderKey; });
4249
4373
  if (!selectedCol)
@@ -4289,7 +4413,7 @@ var NewTable = function (rawProps) {
4289
4413
  react_2.default.createElement(scrollShadow_1.ScrollShadow, { className: "w-full overflow-x-auto ".concat(isFlat
4290
4414
  ? ""
4291
4415
  : "".concat(borderRadius, " border ").concat(borderColor, " ").concat(bgColor, " shadow-sm")), darkMode: props.darkMode },
4292
- (props.selectAll || ((_5 = (_4 = props.selectedIds) === null || _4 === void 0 ? void 0 : _4.length) !== null && _5 !== void 0 ? _5 : 0) > 0) &&
4416
+ (props.selectAll || ((_1 = (_0 = props.selectedIds) === null || _0 === void 0 ? void 0 : _0.length) !== null && _1 !== void 0 ? _1 : 0) > 0) &&
4293
4417
  (!props.multiActionFloatingBtns ||
4294
4418
  (props.multiActionFloatingBtns &&
4295
4419
  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" },
@@ -4317,7 +4441,7 @@ var NewTable = function (rawProps) {
4317
4441
  (addData
4318
4442
  ? !isAddRowPinned && !addGroupId && renderAddDataRow()
4319
4443
  : !handleHasGroupAddRows() && renderEmptyAddRow()))),
4320
- !props.loading && props.data.length === 0 && (react_2.default.createElement("div", { className: "p-4 text-sm ".concat(cellFontColor, " text-center sticky left-0") }, (_6 = props.emptyTitle) !== null && _6 !== void 0 ? _6 : "No items"))),
4444
+ !props.loading && props.data.length === 0 && (react_2.default.createElement("div", { className: "p-4 text-sm ".concat(cellFontColor, " text-center sticky left-0") }, (_2 = props.emptyTitle) !== null && _2 !== void 0 ? _2 : "No items"))),
4321
4445
  renderPinnedAddButton(),
4322
4446
  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
4323
4447
  ? "pagination-container w-full ".concat(borderColor, " ").concat(isFixed ? "fixed bottom-0 left-0 z-10" : "sticky top-0 left-0")