@atlaskit/renderer 114.11.1 → 114.12.0

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/react/marks/alignment.js +3 -15
  4. package/dist/cjs/react/nodes/blockCard.js +24 -8
  5. package/dist/cjs/react/nodes/codeBlock/components/codeBlockContainer.js +3 -10
  6. package/dist/cjs/react/nodes/codeBlock/components/lightWeightCodeBlock.js +8 -53
  7. package/dist/cjs/react/nodes/layoutColumn.js +3 -11
  8. package/dist/cjs/react/nodes/media/index.js +28 -58
  9. package/dist/cjs/react/nodes/panel.js +2 -26
  10. package/dist/cjs/react/nodes/table/colgroup.js +5 -2
  11. package/dist/cjs/react/nodes/table/sticky.js +3 -57
  12. package/dist/cjs/react/nodes/table/table.js +6 -1
  13. package/dist/cjs/react/nodes/table.js +51 -23
  14. package/dist/cjs/react/nodes/tableNew.js +550 -0
  15. package/dist/cjs/ui/Expand.js +12 -62
  16. package/dist/cjs/ui/Renderer/RendererStyleContainer.js +19 -42
  17. package/dist/cjs/ui/Renderer/breakout-ssr.js +22 -22
  18. package/dist/cjs/ui/Renderer/index.js +4 -2
  19. package/dist/cjs/ui/Renderer/style.js +2 -208
  20. package/dist/cjs/ui/annotations/draft/component.js +2 -17
  21. package/dist/cjs/ui/annotations/element/mark.js +12 -61
  22. package/dist/es2019/react/marks/alignment.js +2 -17
  23. package/dist/es2019/react/nodes/blockCard.js +24 -8
  24. package/dist/es2019/react/nodes/codeBlock/components/codeBlockContainer.js +2 -39
  25. package/dist/es2019/react/nodes/codeBlock/components/lightWeightCodeBlock.js +5 -50
  26. package/dist/es2019/react/nodes/layoutColumn.js +4 -12
  27. package/dist/es2019/react/nodes/media/index.js +3 -36
  28. package/dist/es2019/react/nodes/panel.js +2 -41
  29. package/dist/es2019/react/nodes/table/colgroup.js +5 -2
  30. package/dist/es2019/react/nodes/table/sticky.js +3 -70
  31. package/dist/es2019/react/nodes/table/table.js +6 -1
  32. package/dist/es2019/react/nodes/table.js +50 -22
  33. package/dist/es2019/react/nodes/tableNew.js +501 -0
  34. package/dist/es2019/ui/Expand.js +11 -67
  35. package/dist/es2019/ui/Renderer/RendererStyleContainer.js +20 -43
  36. package/dist/es2019/ui/Renderer/breakout-ssr.js +22 -22
  37. package/dist/es2019/ui/Renderer/index.js +4 -2
  38. package/dist/es2019/ui/Renderer/style.js +1 -889
  39. package/dist/es2019/ui/annotations/draft/component.js +2 -15
  40. package/dist/es2019/ui/annotations/element/mark.js +9 -71
  41. package/dist/esm/react/marks/alignment.js +2 -16
  42. package/dist/esm/react/nodes/blockCard.js +24 -8
  43. package/dist/esm/react/nodes/codeBlock/components/codeBlockContainer.js +2 -11
  44. package/dist/esm/react/nodes/codeBlock/components/lightWeightCodeBlock.js +7 -52
  45. package/dist/esm/react/nodes/layoutColumn.js +4 -12
  46. package/dist/esm/react/nodes/media/index.js +28 -58
  47. package/dist/esm/react/nodes/panel.js +3 -27
  48. package/dist/esm/react/nodes/table/colgroup.js +5 -2
  49. package/dist/esm/react/nodes/table/sticky.js +3 -57
  50. package/dist/esm/react/nodes/table/table.js +6 -1
  51. package/dist/esm/react/nodes/table.js +51 -21
  52. package/dist/esm/react/nodes/tableNew.js +544 -0
  53. package/dist/esm/ui/Expand.js +12 -62
  54. package/dist/esm/ui/Renderer/RendererStyleContainer.js +20 -43
  55. package/dist/esm/ui/Renderer/breakout-ssr.js +22 -22
  56. package/dist/esm/ui/Renderer/index.js +4 -2
  57. package/dist/esm/ui/Renderer/style.js +1 -203
  58. package/dist/esm/ui/annotations/draft/component.js +2 -17
  59. package/dist/esm/ui/annotations/element/mark.js +9 -56
  60. package/dist/types/react/nodes/codeBlock/components/lightWeightCodeBlock.d.ts +1 -1
  61. package/dist/types/react/nodes/table.d.ts +35 -254
  62. package/dist/types/react/nodes/tableNew.d.ts +83 -0
  63. package/dist/types/ui/Renderer/breakout-ssr.d.ts +1 -2
  64. package/dist/types/ui/Renderer/style.d.ts +0 -11
  65. package/dist/types/ui/annotations/element/mark.d.ts +30 -6
  66. package/dist/types-ts4.5/react/nodes/codeBlock/components/lightWeightCodeBlock.d.ts +1 -1
  67. package/dist/types-ts4.5/react/nodes/table.d.ts +35 -254
  68. package/dist/types-ts4.5/react/nodes/tableNew.d.ts +83 -0
  69. package/dist/types-ts4.5/ui/Renderer/breakout-ssr.d.ts +1 -2
  70. package/dist/types-ts4.5/ui/Renderer/style.d.ts +0 -11
  71. package/dist/types-ts4.5/ui/annotations/element/mark.d.ts +30 -6
  72. package/package.json +14 -7
@@ -0,0 +1,550 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.tableCanBeSticky = exports.shouldHeaderStick = exports.shouldHeaderPinBottom = exports.orderChildren = exports.isTableResizingEnabled = exports.isStickyScrollbarEnabled = exports.isHeaderRowEnabled = exports.hasRowspan = exports.getRefTop = exports.addSortableColumn = exports.TableProcessorWithContainerStyles = exports.TableContainer = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
11
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _styles = require("@atlaskit/editor-common/styles");
16
+ var _utils = require("@atlaskit/editor-common/utils");
17
+ var _types = require("@atlaskit/editor-common/types");
18
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
19
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
20
+ var _tableCell = require("./tableCell");
21
+ var _sticky = require("./table/sticky");
22
+ var _table = require("./table/table");
23
+ var _tableMap = require("@atlaskit/editor-tables/table-map");
24
+ var _appearance = require("../utils/appearance");
25
+ var _TableStickyScrollbar = require("./TableStickyScrollbar");
26
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
27
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
28
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
29
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
30
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* eslint-disable @atlaskit/ui-styling-standard/no-classname-prop, @atlaskit/ui-styling-standard/enforce-style-prop */
31
+ var getResizerMinWidth = function getResizerMinWidth(node) {
32
+ var currentColumnCount = getColgroupChildrenLength(node);
33
+ var minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
34
+ // add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
35
+ // the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
36
+ return minColumnWidth + 1;
37
+ };
38
+ var getColgroupChildrenLength = function getColgroupChildrenLength(table) {
39
+ var map = _tableMap.TableMap.get(table);
40
+ return map.width;
41
+ };
42
+ var gutterPadding = (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2;
43
+ var COLUMN_MIN_WIDTH = 48;
44
+ var isTableResizingEnabled = exports.isTableResizingEnabled = function isTableResizingEnabled(appearance) {
45
+ return (0, _appearance.isFullWidthOrFullPageAppearance)(appearance) || (0, _appearance.isCommentAppearance)(appearance) && (0, _experiments.editorExperiment)('support_table_in_comment', true, {
46
+ exposure: true
47
+ });
48
+ };
49
+ var isStickyScrollbarEnabled = exports.isStickyScrollbarEnabled = function isStickyScrollbarEnabled(appearance) {
50
+ return (0, _appearance.isFullWidthOrFullPageAppearance)(appearance) && (0, _experiments.editorExperiment)('platform_renderer_table_sticky_scrollbar', true, {
51
+ exposure: true
52
+ });
53
+ };
54
+ var orderChildren = exports.orderChildren = function orderChildren(children, tableNode, smartCardStorage, tableOrderStatus) {
55
+ if (!tableOrderStatus || tableOrderStatus.order === _types.SortOrder.NO_ORDER) {
56
+ return children;
57
+ }
58
+ var order = tableOrderStatus.order,
59
+ columnIndex = tableOrderStatus.columnIndex;
60
+ var compareNodesInOrder = (0, _utils.createCompareNodes)({
61
+ getInlineCardTextFromStore: function getInlineCardTextFromStore(attrs) {
62
+ var _ref = attrs,
63
+ url = _ref.url;
64
+ if (!url) {
65
+ return null;
66
+ }
67
+ return smartCardStorage.get(url) || null;
68
+ }
69
+ }, order);
70
+ var tableArray = (0, _utils.convertProsemirrorTableNodeToArrayOfRows)(tableNode);
71
+ var tableArrayWithChildren = tableArray.map(function (rowNodes, index) {
72
+ return {
73
+ rowNodes: rowNodes,
74
+ rowReact: children[index]
75
+ };
76
+ });
77
+ var headerRow = tableArrayWithChildren.shift();
78
+ var sortedTable = tableArrayWithChildren.sort(function (rowA, rowB) {
79
+ return compareNodesInOrder(rowA.rowNodes[columnIndex], rowB.rowNodes[columnIndex]);
80
+ });
81
+ if (headerRow) {
82
+ sortedTable.unshift(headerRow);
83
+ }
84
+ return sortedTable.map(function (elem) {
85
+ return elem.rowReact;
86
+ });
87
+ };
88
+ var hasRowspan = exports.hasRowspan = function hasRowspan(row) {
89
+ var hasRowspan = false;
90
+ row.forEach(function (cell) {
91
+ return hasRowspan = hasRowspan || cell.attrs.rowspan > 1;
92
+ });
93
+ return hasRowspan;
94
+ };
95
+ var getRefTop = exports.getRefTop = function getRefTop(refElement) {
96
+ return Math.round(refElement.getBoundingClientRect().top);
97
+ };
98
+ var shouldHeaderStick = exports.shouldHeaderStick = function shouldHeaderStick(scrollTop, tableTop, tableBottom, rowHeight) {
99
+ return tableTop <= scrollTop && !(tableBottom - rowHeight <= scrollTop);
100
+ };
101
+ var shouldHeaderPinBottom = exports.shouldHeaderPinBottom = function shouldHeaderPinBottom(scrollTop, tableBottom, rowHeight) {
102
+ return tableBottom - rowHeight <= scrollTop && !(tableBottom < scrollTop);
103
+ };
104
+ var addSortableColumn = exports.addSortableColumn = function addSortableColumn(rows, tableOrderStatus, onSorting) {
105
+ return _react.default.Children.map(rows, function (row, index) {
106
+ if (index === 0) {
107
+ return /*#__PURE__*/_react.default.cloneElement(_react.default.Children.only(row), {
108
+ tableOrderStatus: tableOrderStatus,
109
+ onSorting: onSorting
110
+ });
111
+ }
112
+ return row;
113
+ });
114
+ };
115
+ var isHeaderRowEnabled = exports.isHeaderRowEnabled = function isHeaderRowEnabled(rows) {
116
+ if (!rows.length) {
117
+ return false;
118
+ }
119
+ // Ignored via go/ees005
120
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
121
+ var children = rows[0].props.children;
122
+ if (!children.length) {
123
+ return false;
124
+ }
125
+ if (children.length === 1) {
126
+ return children[0].type === _tableCell.TableHeader;
127
+ }
128
+ return children.every(function (node) {
129
+ return node.type === _tableCell.TableHeader;
130
+ });
131
+ };
132
+ var tableCanBeSticky = exports.tableCanBeSticky = function tableCanBeSticky(node, children) {
133
+ return isHeaderRowEnabled(children) && node && node.firstChild && !hasRowspan(node.firstChild);
134
+ };
135
+ // Ignored via go/ees005
136
+ // eslint-disable-next-line @repo/internal/react/no-class-components
137
+ var TableContainer = exports.TableContainer = /*#__PURE__*/function (_React$Component) {
138
+ function TableContainer() {
139
+ var _this;
140
+ (0, _classCallCheck2.default)(this, TableContainer);
141
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
142
+ args[_key] = arguments[_key];
143
+ }
144
+ _this = _callSuper(this, TableContainer, [].concat(args));
145
+ (0, _defineProperty2.default)(_this, "state", {
146
+ stickyMode: 'none',
147
+ wrapperWidth: 0,
148
+ headerRowHeight: 0
149
+ });
150
+ (0, _defineProperty2.default)(_this, "tableRef", /*#__PURE__*/_react.default.createRef());
151
+ (0, _defineProperty2.default)(_this, "stickyHeaderRef", /*#__PURE__*/_react.default.createRef());
152
+ (0, _defineProperty2.default)(_this, "stickyScrollbarRef", /*#__PURE__*/_react.default.createRef());
153
+ // used for sync scroll + copying wrapper width to sticky header
154
+ (0, _defineProperty2.default)(_this, "stickyWrapperRef", /*#__PURE__*/_react.default.createRef());
155
+ (0, _defineProperty2.default)(_this, "wrapperRef", /*#__PURE__*/_react.default.createRef());
156
+ (0, _defineProperty2.default)(_this, "overflowParent", null);
157
+ (0, _defineProperty2.default)(_this, "updatedLayout", 'custom');
158
+ (0, _defineProperty2.default)(_this, "resizeObserver", null);
159
+ (0, _defineProperty2.default)(_this, "applyResizerChange", function (entries) {
160
+ var wrapperWidth = _this.state.wrapperWidth;
161
+ var headerRowHeight = _this.state.headerRowHeight;
162
+ var _iterator = _createForOfIteratorHelper(entries),
163
+ _step;
164
+ try {
165
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
166
+ var entry = _step.value;
167
+ if (entry.target === _this.wrapperRef.current) {
168
+ wrapperWidth = entry.contentRect.width;
169
+ } else if (entry.target === _this.stickyHeaderRef.current) {
170
+ headerRowHeight = Math.round(entry.contentRect.height);
171
+ }
172
+ }
173
+ } catch (err) {
174
+ _iterator.e(err);
175
+ } finally {
176
+ _iterator.f();
177
+ }
178
+ if (headerRowHeight !== _this.state.headerRowHeight || wrapperWidth !== _this.state.wrapperWidth) {
179
+ _this.setState({
180
+ wrapperWidth: wrapperWidth,
181
+ headerRowHeight: headerRowHeight
182
+ });
183
+ }
184
+ });
185
+ (0, _defineProperty2.default)(_this, "componentWillUnmount", function () {
186
+ if (_this.overflowParent) {
187
+ // Ignored via go/ees005
188
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
189
+ _this.overflowParent.removeEventListener('scroll', _this.onScroll);
190
+ }
191
+ if (_this.nextFrame) {
192
+ cancelAnimationFrame(_this.nextFrame);
193
+ }
194
+ if (_this.resizeObserver) {
195
+ _this.resizeObserver.disconnect();
196
+ }
197
+ if (_this.stickyScrollbar) {
198
+ _this.stickyScrollbar.dispose();
199
+ }
200
+ });
201
+ (0, _defineProperty2.default)(_this, "getScrollTop", function () {
202
+ var stickyHeaders = _this.props.stickyHeaders;
203
+ var offsetTop = stickyHeaders && stickyHeaders.offsetTop || 0;
204
+ return (_this.overflowParent ? _this.overflowParent.top : 0) + offsetTop;
205
+ });
206
+ (0, _defineProperty2.default)(_this, "updateSticky", function () {
207
+ var tableElem = _this.tableRef.current;
208
+ var refElem = _this.stickyHeaderRef.current;
209
+ if (!tableElem || !refElem) {
210
+ return;
211
+ }
212
+ var scrollTop = _this.getScrollTop() + _sticky.tableStickyPadding;
213
+ var tableTop = getRefTop(tableElem);
214
+ var tableBottom = tableTop + tableElem.clientHeight;
215
+ var shouldSticky = shouldHeaderStick(scrollTop, tableTop, tableBottom, refElem.clientHeight);
216
+ var shouldPin = shouldHeaderPinBottom(scrollTop, tableBottom, refElem.clientHeight);
217
+ var stickyMode = 'none';
218
+ if (shouldPin) {
219
+ stickyMode = 'pin-bottom';
220
+ } else if (shouldSticky) {
221
+ stickyMode = 'stick';
222
+ }
223
+ if (_this.state.stickyMode !== stickyMode) {
224
+ _this.setState({
225
+ stickyMode: stickyMode
226
+ });
227
+ }
228
+ _this.nextFrame = undefined;
229
+ });
230
+ (0, _defineProperty2.default)(_this, "onScroll", function () {
231
+ if (!_this.nextFrame) {
232
+ _this.nextFrame = requestAnimationFrame(_this.updateSticky);
233
+ }
234
+ });
235
+ (0, _defineProperty2.default)(_this, "onWrapperScrolled", function () {
236
+ if (!_this.wrapperRef.current || !_this.stickyWrapperRef.current) {
237
+ return;
238
+ }
239
+ _this.stickyWrapperRef.current.scrollLeft = _this.wrapperRef.current.scrollLeft;
240
+ if (_this.stickyScrollbarRef.current) {
241
+ _this.stickyScrollbarRef.current.scrollLeft = _this.wrapperRef.current.scrollLeft;
242
+ }
243
+ });
244
+ (0, _defineProperty2.default)(_this, "grabFirstRowRef", function (children) {
245
+ // Ignored via go/ees005
246
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
247
+ return _react.default.Children.map(children || false, function (child, idx) {
248
+ if (idx === 0 && /*#__PURE__*/_react.default.isValidElement(child)) {
249
+ return /*#__PURE__*/_react.default.cloneElement(child, {
250
+ innerRef: _this.stickyHeaderRef
251
+ });
252
+ }
253
+ return child;
254
+ });
255
+ });
256
+ return _this;
257
+ }
258
+ (0, _inherits2.default)(TableContainer, _React$Component);
259
+ return (0, _createClass2.default)(TableContainer, [{
260
+ key: "componentDidMount",
261
+ value: function componentDidMount() {
262
+ this.resizeObserver = new ResizeObserver(this.applyResizerChange);
263
+ if (this.wrapperRef.current) {
264
+ this.resizeObserver.observe(this.wrapperRef.current);
265
+ }
266
+ if (this.stickyHeaderRef.current) {
267
+ this.resizeObserver.observe(this.stickyHeaderRef.current);
268
+ }
269
+ if (this.props.stickyHeaders) {
270
+ var _this$props$stickyHea;
271
+ this.overflowParent = _sticky.OverflowParent.fromElement(this.tableRef.current, (_this$props$stickyHea = this.props.stickyHeaders) === null || _this$props$stickyHea === void 0 ? void 0 : _this$props$stickyHea.defaultScrollRootId_DO_NOT_USE);
272
+ // Ignored via go/ees005
273
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
274
+ this.overflowParent.addEventListener('scroll', this.onScroll);
275
+ }
276
+ if (this.wrapperRef.current && isStickyScrollbarEnabled(this.props.rendererAppearance)) {
277
+ this.stickyScrollbar = new _TableStickyScrollbar.TableStickyScrollbar(this.wrapperRef.current);
278
+ }
279
+ }
280
+ }, {
281
+ key: "componentDidUpdate",
282
+ value: function componentDidUpdate(prevProps, prevState) {
283
+ // toggling sticky headers visiblity
284
+ if (this.props.stickyHeaders && !this.overflowParent) {
285
+ var _this$props$stickyHea2;
286
+ this.overflowParent = _sticky.OverflowParent.fromElement(this.tableRef.current, (_this$props$stickyHea2 = this.props.stickyHeaders) === null || _this$props$stickyHea2 === void 0 ? void 0 : _this$props$stickyHea2.defaultScrollRootId_DO_NOT_USE);
287
+ } else if (!this.props.stickyHeaders && this.overflowParent) {
288
+ // Ignored via go/ees005
289
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
290
+ this.overflowParent.removeEventListener('scroll', this.onScroll);
291
+ this.overflowParent = null;
292
+ }
293
+
294
+ // offsetTop might have changed, re-position sticky header
295
+ if (this.props.stickyHeaders !== prevProps.stickyHeaders) {
296
+ this.updateSticky();
297
+ }
298
+
299
+ // sync horizontal scroll in floating div when toggling modes
300
+ if (prevState.stickyMode !== this.state.stickyMode) {
301
+ this.onWrapperScrolled();
302
+ }
303
+ }
304
+ }, {
305
+ key: "pinTop",
306
+ get: function get() {
307
+ if (!this.tableRef.current || !this.stickyHeaderRef.current) {
308
+ return;
309
+ }
310
+ return this.tableRef.current.offsetHeight - this.stickyHeaderRef.current.offsetHeight + _styles.tableMarginTop - _sticky.tableStickyPadding;
311
+ }
312
+ }, {
313
+ key: "shouldAddOverflowParentOffsetTop_DO_NOT_USE",
314
+ get: function get() {
315
+ // IF the StickyHeaderConfig specifies that the default scroll root offsetTop should be added
316
+ // AND the StickyHeaderConfig specifies a default scroll root id
317
+ // AND the OverflowParent is the corresponding element
318
+ // THEN we should add the OverflowParent offset top (RETURN TRUE)
319
+ return this.props.stickyHeaders && !!this.props.stickyHeaders.shouldAddDefaultScrollRootOffsetTop_DO_NOT_USE && !!this.props.stickyHeaders.defaultScrollRootId_DO_NOT_USE && this.overflowParent && this.overflowParent.id === this.props.stickyHeaders.defaultScrollRootId_DO_NOT_USE;
320
+ }
321
+ }, {
322
+ key: "stickyTop",
323
+ get: function get() {
324
+ switch (this.state.stickyMode) {
325
+ case 'pin-bottom':
326
+ return this.pinTop;
327
+ case 'stick':
328
+ var offsetTop = this.props.stickyHeaders && this.props.stickyHeaders.offsetTop;
329
+ if (typeof offsetTop === 'number' && this.shouldAddOverflowParentOffsetTop_DO_NOT_USE) {
330
+ var overflowParentOffsetTop = this.overflowParent ? this.overflowParent.top : 0;
331
+ return offsetTop + overflowParentOffsetTop;
332
+ } else {
333
+ return offsetTop;
334
+ }
335
+ default:
336
+ return undefined;
337
+ }
338
+ }
339
+ }, {
340
+ key: "render",
341
+ value: function render() {
342
+ var _this$tableRef$curren;
343
+ var _this$props = this.props,
344
+ isNumberColumnEnabled = _this$props.isNumberColumnEnabled,
345
+ layout = _this$props.layout,
346
+ renderWidth = _this$props.renderWidth,
347
+ columnWidths = _this$props.columnWidths,
348
+ stickyHeaders = _this$props.stickyHeaders,
349
+ tableNode = _this$props.tableNode,
350
+ rendererAppearance = _this$props.rendererAppearance,
351
+ isInsideOfBlockNode = _this$props.isInsideOfBlockNode,
352
+ isInsideOfTable = _this$props.isInsideOfTable,
353
+ isinsideMultiBodiedExtension = _this$props.isinsideMultiBodiedExtension,
354
+ allowTableResizing = _this$props.allowTableResizing,
355
+ isPresentational = _this$props.isPresentational;
356
+ var stickyMode = this.state.stickyMode;
357
+ var tableWidthAttribute = tableNode !== null && tableNode !== void 0 && tableNode.attrs.width ? "".concat(tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width, "px") : "100%";
358
+ var children = _react.default.Children.toArray(this.props.children);
359
+ var tableMinWidth;
360
+ if (tableNode) {
361
+ tableMinWidth = getResizerMinWidth(tableNode);
362
+ }
363
+
364
+ // Historically, tables in the full-width renderer had their layout set to 'default' which is deceiving.
365
+ // This check caters for those tables and helps with SSR logic
366
+ var isFullWidth = !(tableNode !== null && tableNode !== void 0 && tableNode.attrs.width) && rendererAppearance === 'full-width' && layout !== 'full-width';
367
+ if (isFullWidth) {
368
+ this.updatedLayout = 'full-width';
369
+ // if table has width explicity set, ensure SSR is handled
370
+ } else if (tableNode !== null && tableNode !== void 0 && tableNode.attrs.width) {
371
+ this.updatedLayout = 'custom';
372
+ } else {
373
+ this.updatedLayout = layout;
374
+ }
375
+ return /*#__PURE__*/_react.default.createElement("div", {
376
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
377
+ className: "table-alignment-container"
378
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
379
+ ,
380
+ style: {
381
+ display: 'flex',
382
+ justifyContent: 'center'
383
+ }
384
+ }, /*#__PURE__*/_react.default.createElement("div", {
385
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
386
+ className: "pm-table-resizer-container"
387
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
388
+ ,
389
+ style: {
390
+ width: "min(calc(100cqw - ".concat(gutterPadding, "px) ").concat(tableWidthAttribute)
391
+ }
392
+ }, /*#__PURE__*/_react.default.createElement("div", {
393
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
394
+ className: "resizer-item display-handle",
395
+ style: (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
396
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
397
+ position: 'relative',
398
+ userSelect: 'auto',
399
+ boxSizing: 'border-box'
400
+ }, '--ak-editor-table-gutter-padding', "".concat(gutterPadding, "px")), '--ak-editor-table-max-width', "1800px"), '--ak-editor-table-min-width', "".concat(tableMinWidth, "px")), "minWidth", 'var(--ak-editor-table-min-width)'), "maxWidth", "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))"), "width", "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ".concat(tableWidthAttribute, ")"))
401
+ }, /*#__PURE__*/_react.default.createElement("span", {
402
+ className: "resizer-hover-zone"
403
+ }, /*#__PURE__*/_react.default.createElement("div", {
404
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
405
+ className: "".concat(_styles.TableSharedCssClassName.TABLE_CONTAINER, " ").concat(this.props.shadowClassNames || ''),
406
+ "data-number-column": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.isNumberColumnEnabled,
407
+ "data-layout": this.updatedLayout,
408
+ "data-testid": "table-container",
409
+ ref: this.props.handleRef
410
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
411
+ }, isStickyScrollbarEnabled(this.props.rendererAppearance) && /*#__PURE__*/_react.default.createElement("div", {
412
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
413
+ className: _styles.TableSharedCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
414
+ "data-testid": "sticky-scrollbar-sentinel-top"
415
+ }), stickyHeaders && tableNode && tableCanBeSticky(tableNode, children) && /*#__PURE__*/_react.default.createElement(_sticky.StickyTable, {
416
+ isNumberColumnEnabled: isNumberColumnEnabled,
417
+ renderWidth: renderWidth,
418
+ tableWidth: "inherit",
419
+ layout: layout,
420
+ handleRef: this.props.handleRef,
421
+ shadowClassNames: this.props.shadowClassNames,
422
+ top: this.stickyTop,
423
+ mode: stickyMode,
424
+ innerRef: this.stickyWrapperRef,
425
+ wrapperWidth: this.state.wrapperWidth,
426
+ columnWidths: columnWidths,
427
+ rowHeight: this.state.headerRowHeight,
428
+ tableNode: tableNode,
429
+ rendererAppearance: rendererAppearance,
430
+ allowTableResizing: allowTableResizing
431
+ }, [children && children[0]]), /*#__PURE__*/_react.default.createElement("div", {
432
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
433
+ className: _styles.TableSharedCssClassName.TABLE_NODE_WRAPPER,
434
+ ref: this.wrapperRef,
435
+ "data-number-column": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.isNumberColumnEnabled,
436
+ "data-layout": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout,
437
+ "data-autosize": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.__autoSize,
438
+ "data-table-local-id": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId,
439
+ "data-table-width": tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.width,
440
+ "data-vc": "table-node-wrapper",
441
+ onScroll: this.props.stickyHeaders && this.onWrapperScrolled
442
+ }, /*#__PURE__*/_react.default.createElement(_table.Table, {
443
+ innerRef: this.tableRef,
444
+ columnWidths: columnWidths,
445
+ layout: layout,
446
+ isNumberColumnEnabled: isNumberColumnEnabled,
447
+ renderWidth: renderWidth,
448
+ tableNode: tableNode,
449
+ rendererAppearance: rendererAppearance,
450
+ isInsideOfBlockNode: isInsideOfBlockNode,
451
+ isInsideOfTable: isInsideOfTable,
452
+ isinsideMultiBodiedExtension: isinsideMultiBodiedExtension,
453
+ allowTableResizing: allowTableResizing,
454
+ isPresentational: isPresentational
455
+ }, this.grabFirstRowRef(children))), isStickyScrollbarEnabled(this.props.rendererAppearance) && /*#__PURE__*/_react.default.createElement("div", {
456
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
457
+ className: _styles.TableSharedCssClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
458
+ ref: this.stickyScrollbarRef,
459
+ "data-vc": "table-sticky-scrollbar-container",
460
+ style: {
461
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
462
+ height: "var(--ds-space-250, 20px)",
463
+ // MAX_BROWSER_SCROLLBAR_HEIGHT
464
+ // Follow editor to hide by default so it does not show empty gap in SSR
465
+ // https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/editor/editor-plugin-table/src/nodeviews/TableComponent.tsx#957
466
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
467
+ display: 'block',
468
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
469
+ width: '100%'
470
+ }
471
+ }, /*#__PURE__*/_react.default.createElement("div", {
472
+ style: {
473
+ width: (_this$tableRef$curren = this.tableRef.current) === null || _this$tableRef$curren === void 0 ? void 0 : _this$tableRef$curren.clientWidth,
474
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
475
+ height: '100%'
476
+ }
477
+ })), isStickyScrollbarEnabled(this.props.rendererAppearance) && /*#__PURE__*/_react.default.createElement("div", {
478
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
479
+ className: _styles.TableSharedCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM,
480
+ "data-testid": "sticky-scrollbar-sentinel-bottom"
481
+ }))))));
482
+ }
483
+ }]);
484
+ }(_react.default.Component);
485
+ // Ignored via go/ees005
486
+ // eslint-disable-next-line @repo/internal/react/no-class-components
487
+ var TableProcessorWithContainerStyles = exports.TableProcessorWithContainerStyles = /*#__PURE__*/function (_React$Component2) {
488
+ function TableProcessorWithContainerStyles() {
489
+ var _this2;
490
+ (0, _classCallCheck2.default)(this, TableProcessorWithContainerStyles);
491
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
492
+ args[_key2] = arguments[_key2];
493
+ }
494
+ _this2 = _callSuper(this, TableProcessorWithContainerStyles, [].concat(args));
495
+ (0, _defineProperty2.default)(_this2, "state", {
496
+ tableOrderStatus: undefined
497
+ });
498
+ // adds sortable + re-orders children
499
+ (0, _defineProperty2.default)(_this2, "addSortableColumn", function (childrenArray) {
500
+ var _this2$props = _this2.props,
501
+ tableNode = _this2$props.tableNode,
502
+ allowColumnSorting = _this2$props.allowColumnSorting,
503
+ smartCardStorage = _this2$props.smartCardStorage;
504
+ var tableOrderStatus = _this2.state.tableOrderStatus;
505
+ if (allowColumnSorting && isHeaderRowEnabled(childrenArray) && tableNode && !(0, _utils.hasMergedCell)(tableNode)) {
506
+ return addSortableColumn(orderChildren(childrenArray, tableNode, smartCardStorage, tableOrderStatus), tableOrderStatus, _this2.changeSortOrder);
507
+ }
508
+ return childrenArray;
509
+ });
510
+ (0, _defineProperty2.default)(_this2, "changeSortOrder", function (columnIndex, sortOrder) {
511
+ _this2.setState({
512
+ tableOrderStatus: {
513
+ columnIndex: columnIndex,
514
+ order: sortOrder
515
+ }
516
+ });
517
+ });
518
+ // Ignored via go/ees005
519
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
520
+ (0, _defineProperty2.default)(_this2, "addNumberColumnIndexes", function (rows) {
521
+ var isNumberColumnEnabled = _this2.props.isNumberColumnEnabled;
522
+ var headerRowEnabled = isHeaderRowEnabled(rows);
523
+ return _react.default.Children.map(rows, function (row, index) {
524
+ return /*#__PURE__*/_react.default.cloneElement(_react.default.Children.only(row), {
525
+ isNumberColumnEnabled: isNumberColumnEnabled,
526
+ index: headerRowEnabled ? index === 0 ? '' : index : index + 1
527
+ });
528
+ });
529
+ });
530
+ return _this2;
531
+ }
532
+ (0, _inherits2.default)(TableProcessorWithContainerStyles, _React$Component2);
533
+ return (0, _createClass2.default)(TableProcessorWithContainerStyles, [{
534
+ key: "render",
535
+ value: function render() {
536
+ var children = this.props.children;
537
+ if (!children) {
538
+ return null;
539
+ }
540
+ var childrenArray = _react.default.Children.toArray(children);
541
+ var orderedChildren = (0, _utils.compose)(this.addNumberColumnIndexes, this.addSortableColumn
542
+ // @ts-expect-error TS2345: Argument of type '(ReactChild | ReactFragment | ReactPortal)[]' is not assignable to parameter of type 'ReactElement<any, string | JSXElementConstructor<any>>[]'
543
+ )(childrenArray);
544
+
545
+ // Ignored via go/ees005
546
+ // eslint-disable-next-line react/jsx-props-no-spreading
547
+ return /*#__PURE__*/_react.default.createElement(TableContainer, this.props, orderedChildren);
548
+ }
549
+ }]);
550
+ }(_react.default.Component);