@atlaskit/renderer 114.11.2 → 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 (30) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/react/nodes/blockCard.js +24 -8
  4. package/dist/cjs/react/nodes/table/colgroup.js +5 -2
  5. package/dist/cjs/react/nodes/table/table.js +6 -1
  6. package/dist/cjs/react/nodes/table.js +51 -23
  7. package/dist/cjs/react/nodes/tableNew.js +550 -0
  8. package/dist/cjs/ui/Renderer/breakout-ssr.js +22 -22
  9. package/dist/cjs/ui/Renderer/index.js +1 -1
  10. package/dist/es2019/react/nodes/blockCard.js +24 -8
  11. package/dist/es2019/react/nodes/table/colgroup.js +5 -2
  12. package/dist/es2019/react/nodes/table/table.js +6 -1
  13. package/dist/es2019/react/nodes/table.js +50 -22
  14. package/dist/es2019/react/nodes/tableNew.js +501 -0
  15. package/dist/es2019/ui/Renderer/breakout-ssr.js +22 -22
  16. package/dist/es2019/ui/Renderer/index.js +1 -1
  17. package/dist/esm/react/nodes/blockCard.js +24 -8
  18. package/dist/esm/react/nodes/table/colgroup.js +5 -2
  19. package/dist/esm/react/nodes/table/table.js +6 -1
  20. package/dist/esm/react/nodes/table.js +51 -21
  21. package/dist/esm/react/nodes/tableNew.js +544 -0
  22. package/dist/esm/ui/Renderer/breakout-ssr.js +22 -22
  23. package/dist/esm/ui/Renderer/index.js +1 -1
  24. package/dist/types/react/nodes/table.d.ts +35 -254
  25. package/dist/types/react/nodes/tableNew.d.ts +83 -0
  26. package/dist/types/ui/Renderer/breakout-ssr.d.ts +1 -2
  27. package/dist/types-ts4.5/react/nodes/table.d.ts +35 -254
  28. package/dist/types-ts4.5/react/nodes/tableNew.d.ts +83 -0
  29. package/dist/types-ts4.5/ui/Renderer/breakout-ssr.d.ts +1 -2
  30. package/package.json +10 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 114.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#147188](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/147188)
8
+ [`55a71b17e1c48`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/55a71b17e1c48) -
9
+ Updated smartlink card view to support SSR
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 114.11.2
4
16
 
5
17
  ### Patch Changes
@@ -47,6 +47,9 @@
47
47
  {
48
48
  "path": "../../editor-shared-styles/afm-cc/tsconfig.json"
49
49
  },
50
+ {
51
+ "path": "../../editor-tables/afm-cc/tsconfig.json"
52
+ },
50
53
  {
51
54
  "path": "../../../elements/emoji/afm-cc/tsconfig.json"
52
55
  },
@@ -14,6 +14,8 @@ var _getCardClickHandler = require("../utils/getCardClickHandler");
14
14
  var _inlineCard = _interopRequireDefault(require("./inlineCard"));
15
15
  var _analyticsNext = require("@atlaskit/analytics-next");
16
16
  var _linkDatasource = require("@atlaskit/link-datasource");
17
+ var _ssr = require("@atlaskit/smart-card/ssr");
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
19
  var _colors = require("@atlaskit/theme/colors");
18
20
  var _utils = require("@atlaskit/editor-common/utils");
19
21
  /**
@@ -122,6 +124,27 @@ function BlockCard(props) {
122
124
  url: url
123
125
  });
124
126
  }
127
+ var cardComponent;
128
+ if (smartLinks !== null && smartLinks !== void 0 && smartLinks.ssr && url && (0, _platformFeatureFlags.fg)('platform_ssr_smartlink_cards')) {
129
+ cardComponent = (0, _react.jsx)(_ssr.CardSSR, (0, _extends2.default)({
130
+ appearance: "block",
131
+ platform: platform
132
+ // Ignored via go/ees005
133
+ // eslint-disable-next-line react/jsx-props-no-spreading
134
+ }, cardProps, {
135
+ url: url,
136
+ onError: onError
137
+ }));
138
+ } else {
139
+ cardComponent = (0, _react.jsx)(_smartCard.Card, (0, _extends2.default)({
140
+ appearance: "block",
141
+ platform: platform
142
+ // Ignored via go/ees005
143
+ // eslint-disable-next-line react/jsx-props-no-spreading
144
+ }, cardProps, {
145
+ onError: onError
146
+ }));
147
+ }
125
148
  return (0, _react.jsx)(_analyticsNext.AnalyticsContext, {
126
149
  data: analyticsData
127
150
  }, (0, _react.jsx)("div", {
@@ -134,12 +157,5 @@ function BlockCard(props) {
134
157
  unsupportedComponent: _ui.UnsupportedBlock
135
158
  // Ignored via go/ees005
136
159
  // eslint-disable-next-line react/jsx-props-no-spreading
137
- }, cardProps), (0, _react.jsx)(_smartCard.Card, (0, _extends2.default)({
138
- appearance: "block",
139
- platform: platform
140
- // Ignored via go/ees005
141
- // eslint-disable-next-line react/jsx-props-no-spreading
142
- }, cardProps, {
143
- onError: onError
144
- })))));
160
+ }, cardProps), cardComponent)));
145
161
  }
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.Colgroup = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var _styles = require("@atlaskit/editor-common/styles");
11
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
13
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
@@ -198,7 +199,9 @@ var Colgroup = exports.Colgroup = function Colgroup(props) {
198
199
  }
199
200
  return /*#__PURE__*/_react.default.createElement("colgroup", null, isNumberColumnEnabled && /*#__PURE__*/_react.default.createElement("col", {
200
201
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
201
- style: {
202
+ style: (0, _platformFeatureFlags.fg)('platform-ssr-table-resize') ? undefined :
203
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
204
+ {
202
205
  width: _editorSharedStyles.akEditorTableNumberColumnWidth
203
206
  },
204
207
  "data-test-id": 'num'
@@ -209,7 +212,7 @@ var Colgroup = exports.Colgroup = function Colgroup(props) {
209
212
  // eslint-disable-next-line react/no-array-index-key, @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
210
213
  _react.default.createElement("col", {
211
214
  key: idx,
212
- style: style
215
+ style: (0, _platformFeatureFlags.fg)('platform-ssr-table-resize') ? undefined : style
213
216
  })
214
217
  );
215
218
  }));
@@ -31,7 +31,12 @@ var Table = exports.Table = /*#__PURE__*/_react.default.memo(function (_ref) {
31
31
  tableWidth = 'inherit';
32
32
  }
33
33
  if (rendererAppearance === 'comment' && !allowTableResizing) {
34
- tableWidth = renderWidth;
34
+ // in the case we have css container stylings,
35
+ // we don't need to calculate width here as this
36
+ // is done via css
37
+ if (!(0, _platformFeatureFlags.fg)('platform-ssr-table-resize')) {
38
+ tableWidth = renderWidth;
39
+ }
35
40
  }
36
41
  var tableLayout = tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.layout;
37
42
  var tableDisplayMode = tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.displayMode;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.isTableResizingEnabled = exports.isStickyScrollbarEnabled = exports.default = exports.TableProcessor = exports.TableContainer = void 0;
7
+ exports.tableCanBeSticky = exports.shouldHeaderStick = exports.shouldHeaderPinBottom = exports.orderChildren = exports.isTableResizingEnabled = exports.isStickyScrollbarEnabled = exports.isHeaderRowEnabled = exports.hasRowspan = exports.getRefTop = exports.default = exports.addSortableColumn = exports.TableProcessor = exports.TableContainer = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -29,6 +29,7 @@ var _sticky = require("./table/sticky");
29
29
  var _table = require("./table/table");
30
30
  var _appearance = require("../utils/appearance");
31
31
  var _TableStickyScrollbar = require("./TableStickyScrollbar");
32
+ var _tableNew = require("./tableNew");
32
33
  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; } } }; }
33
34
  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; } }
34
35
  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; }
@@ -44,7 +45,7 @@ var isStickyScrollbarEnabled = exports.isStickyScrollbarEnabled = function isSti
44
45
  exposure: true
45
46
  });
46
47
  };
47
- var orderChildren = function orderChildren(children, tableNode, smartCardStorage, tableOrderStatus) {
48
+ var orderChildren = exports.orderChildren = function orderChildren(children, tableNode, smartCardStorage, tableOrderStatus) {
48
49
  if (!tableOrderStatus || tableOrderStatus.order === _types.SortOrder.NO_ORDER) {
49
50
  return children;
50
51
  }
@@ -78,23 +79,23 @@ var orderChildren = function orderChildren(children, tableNode, smartCardStorage
78
79
  return elem.rowReact;
79
80
  });
80
81
  };
81
- var hasRowspan = function hasRowspan(row) {
82
+ var hasRowspan = exports.hasRowspan = function hasRowspan(row) {
82
83
  var hasRowspan = false;
83
84
  row.forEach(function (cell) {
84
85
  return hasRowspan = hasRowspan || cell.attrs.rowspan > 1;
85
86
  });
86
87
  return hasRowspan;
87
88
  };
88
- var getRefTop = function getRefTop(refElement) {
89
+ var getRefTop = exports.getRefTop = function getRefTop(refElement) {
89
90
  return Math.round(refElement.getBoundingClientRect().top);
90
91
  };
91
- var shouldHeaderStick = function shouldHeaderStick(scrollTop, tableTop, tableBottom, rowHeight) {
92
+ var shouldHeaderStick = exports.shouldHeaderStick = function shouldHeaderStick(scrollTop, tableTop, tableBottom, rowHeight) {
92
93
  return tableTop <= scrollTop && !(tableBottom - rowHeight <= scrollTop);
93
94
  };
94
- var shouldHeaderPinBottom = function shouldHeaderPinBottom(scrollTop, tableBottom, rowHeight) {
95
+ var shouldHeaderPinBottom = exports.shouldHeaderPinBottom = function shouldHeaderPinBottom(scrollTop, tableBottom, rowHeight) {
95
96
  return tableBottom - rowHeight <= scrollTop && !(tableBottom < scrollTop);
96
97
  };
97
- var addSortableColumn = function addSortableColumn(rows, tableOrderStatus, onSorting) {
98
+ var addSortableColumn = exports.addSortableColumn = function addSortableColumn(rows, tableOrderStatus, onSorting) {
98
99
  return _react.default.Children.map(rows, function (row, index) {
99
100
  if (index === 0) {
100
101
  return /*#__PURE__*/_react.default.cloneElement(_react.default.Children.only(row), {
@@ -105,7 +106,7 @@ var addSortableColumn = function addSortableColumn(rows, tableOrderStatus, onSor
105
106
  return row;
106
107
  });
107
108
  };
108
- var isHeaderRowEnabled = function isHeaderRowEnabled(rows) {
109
+ var isHeaderRowEnabled = exports.isHeaderRowEnabled = function isHeaderRowEnabled(rows) {
109
110
  if (!rows.length) {
110
111
  return false;
111
112
  }
@@ -122,7 +123,7 @@ var isHeaderRowEnabled = function isHeaderRowEnabled(rows) {
122
123
  return node.type === _tableCell.TableHeader;
123
124
  });
124
125
  };
125
- var tableCanBeSticky = function tableCanBeSticky(node, children) {
126
+ var tableCanBeSticky = exports.tableCanBeSticky = function tableCanBeSticky(node, children) {
126
127
  return isHeaderRowEnabled(children) && node && node.firstChild && !hasRowspan(node.firstChild);
127
128
  };
128
129
  // Ignored via go/ees005
@@ -592,7 +593,18 @@ var TableProcessor = exports.TableProcessor = /*#__PURE__*/function (_React$Comp
592
593
  return /*#__PURE__*/_react.default.createElement(TableContainer, this.props, orderedChildren);
593
594
  }
594
595
  }]);
595
- }(_react.default.Component);
596
+ }(_react.default.Component); // eslint-disable-next-line @typescript-eslint/no-explicit-any
597
+ var TableWithShadowsAndContainerStyles = (0, _ui.overflowShadow)(_tableNew.TableProcessorWithContainerStyles, {
598
+ /**
599
+ * The :scope is in reference to table container and we are selecting only
600
+ * direct children that match the table node wrapper selector, not their
601
+ * descendants.
602
+ */
603
+ overflowSelector: ":scope > .".concat(_styles.TableSharedCssClassName.TABLE_NODE_WRAPPER),
604
+ useShadowObserver: true
605
+ });
606
+
607
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
596
608
  var TableWithShadows = (0, _ui.overflowShadow)(TableProcessor, {
597
609
  /**
598
610
  * The :scope is in reference to table container and we are selecting only
@@ -603,27 +615,43 @@ var TableWithShadows = (0, _ui.overflowShadow)(TableProcessor, {
603
615
  useShadowObserver: true
604
616
  });
605
617
  var TableWithWidth = function TableWithWidth(props) {
606
- // Remember, `width` will be 0 during SSR
607
- return /*#__PURE__*/_react.default.createElement(_ui.WidthConsumer, null, function (_ref2) {
618
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
619
+ if ((0, _platformFeatureFlags.fg)('platform-ssr-table-resize')) {
608
620
  var _props$columnWidths;
609
- var width = _ref2.width;
610
- var renderWidth = props.rendererAppearance === 'full-page' ? width - _style.FullPagePadding * 2 : width;
611
621
  var colWidthsSum = ((_props$columnWidths = props.columnWidths) === null || _props$columnWidths === void 0 ? void 0 : _props$columnWidths.reduce(function (total, val) {
612
622
  return total + val;
613
623
  }, 0)) || 0;
614
624
  if (colWidthsSum || props.allowTableResizing) {
615
625
  // Ignored via go/ees005
616
626
  // eslint-disable-next-line react/jsx-props-no-spreading
617
- return /*#__PURE__*/_react.default.createElement(TableWithShadows, (0, _extends2.default)({
627
+ return /*#__PURE__*/_react.default.createElement(TableWithShadowsAndContainerStyles, props);
628
+ }
629
+ return /*#__PURE__*/_react.default.createElement(_tableNew.TableProcessorWithContainerStyles
630
+ // Ignored via go/ees005
631
+ // eslint-disable-next-line react/jsx-props-no-spreading
632
+ , props);
633
+ } else {
634
+ return /*#__PURE__*/_react.default.createElement(_ui.WidthConsumer, null, function (_ref2) {
635
+ var _props$columnWidths2;
636
+ var width = _ref2.width;
637
+ var renderWidth = props.rendererAppearance === 'full-page' ? width - _style.FullPagePadding * 2 : width;
638
+ var colWidthsSum = ((_props$columnWidths2 = props.columnWidths) === null || _props$columnWidths2 === void 0 ? void 0 : _props$columnWidths2.reduce(function (total, val) {
639
+ return total + val;
640
+ }, 0)) || 0;
641
+ if (colWidthsSum || props.allowTableResizing) {
642
+ // Ignored via go/ees005
643
+ // eslint-disable-next-line react/jsx-props-no-spreading
644
+ return /*#__PURE__*/_react.default.createElement(TableWithShadows, (0, _extends2.default)({
645
+ renderWidth: renderWidth
646
+ }, props));
647
+ }
648
+ // there should not be a case when colWidthsSum is 0 and table is in overflow state - so no need to render shadows in this case
649
+ return /*#__PURE__*/_react.default.createElement(TableProcessor, (0, _extends2.default)({
618
650
  renderWidth: renderWidth
651
+ // Ignored via go/ees005
652
+ // eslint-disable-next-line react/jsx-props-no-spreading
619
653
  }, props));
620
- }
621
- // there should not be a case when colWidthsSum is 0 and table is in overflow state - so no need to render shadows in this case
622
- return /*#__PURE__*/_react.default.createElement(TableProcessor, (0, _extends2.default)({
623
- renderWidth: renderWidth
624
- // Ignored via go/ees005
625
- // eslint-disable-next-line react/jsx-props-no-spreading
626
- }, props));
627
- });
654
+ });
655
+ }
628
656
  };
629
657
  var _default = exports.default = (0, _SmartCardStorage.withSmartCardStorage)(TableWithWidth);