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