@atlaskit/renderer 137.1.8 → 137.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/cjs/react/index.js +1 -1
- package/dist/cjs/react/nodes/table/colgroup.js +1 -2
- package/dist/cjs/react/nodes/table/sticky.js +2 -4
- package/dist/cjs/react/nodes/table/table.js +1 -12
- package/dist/cjs/react/nodes/table.js +471 -203
- package/dist/cjs/ui/Expand.js +33 -7
- package/dist/cjs/ui/Renderer/breakout-ssr.js +1 -2
- package/dist/cjs/ui/Renderer/index.js +3 -3
- package/dist/cjs/ui/utils/expand-body.js +218 -0
- package/dist/cjs/ui/utils/expand-search-text.js +39 -1
- package/dist/es2019/react/index.js +1 -1
- package/dist/es2019/react/nodes/table/colgroup.js +1 -2
- package/dist/es2019/react/nodes/table/sticky.js +2 -3
- package/dist/es2019/react/nodes/table/table.js +1 -12
- package/dist/es2019/react/nodes/table.js +457 -190
- package/dist/es2019/ui/Expand.js +33 -7
- package/dist/es2019/ui/Renderer/breakout-ssr.js +1 -2
- package/dist/es2019/ui/Renderer/index.js +3 -3
- package/dist/es2019/ui/utils/expand-body.js +198 -0
- package/dist/es2019/ui/utils/expand-search-text.js +38 -0
- package/dist/esm/react/index.js +1 -1
- package/dist/esm/react/nodes/table/colgroup.js +1 -2
- package/dist/esm/react/nodes/table/sticky.js +2 -4
- package/dist/esm/react/nodes/table/table.js +1 -12
- package/dist/esm/react/nodes/table.js +471 -202
- package/dist/esm/ui/Expand.js +33 -7
- package/dist/esm/ui/Renderer/breakout-ssr.js +1 -2
- package/dist/esm/ui/Renderer/index.js +3 -3
- package/dist/esm/ui/utils/expand-body.js +210 -0
- package/dist/esm/ui/utils/expand-search-text.js +38 -0
- package/dist/types/react/nodes/table/sticky.d.ts +1 -2
- package/dist/types/react/nodes/table.d.ts +78 -8
- package/dist/types/ui/{expand-body.d.ts → utils/expand-body.d.ts} +26 -5
- package/dist/types/ui/utils/expand-search-text.d.ts +14 -0
- package/package.json +6 -9
- package/dist/cjs/react/nodes/tableNew.js +0 -1050
- package/dist/cjs/ui/expand-body.js +0 -122
- package/dist/es2019/react/nodes/tableNew.js +0 -986
- package/dist/es2019/ui/expand-body.js +0 -107
- package/dist/esm/react/nodes/tableNew.js +0 -1044
- package/dist/esm/ui/expand-body.js +0 -114
- package/dist/types/react/nodes/tableNew.d.ts +0 -189
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import React, { createContext, isValidElement, useContext } from 'react';
|
|
2
|
-
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
3
|
-
import { BLOCK_SEPARATOR, getBlockSearchText, holdsRevealableContent, isExpandNode } from './utils/expand-search-text';
|
|
4
|
-
var ExpandBodyContext = /*#__PURE__*/createContext(null);
|
|
5
|
-
export var ExpandBodyProvider = ExpandBodyContext.Provider;
|
|
6
|
-
export var useExpandBody = function useExpandBody() {
|
|
7
|
-
return useContext(ExpandBodyContext);
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* One or more neighbouring blocks of an expand's body. Shows their text until the expand is
|
|
11
|
-
* opened, then renders them. Falls back to rendering if there is no text, or if there is no
|
|
12
|
-
* expand above it.
|
|
13
|
-
*
|
|
14
|
-
* The text is rendered as-is, with no element around it. Nothing reads it but browser find,
|
|
15
|
-
* which only needs the characters to be in the DOM.
|
|
16
|
-
*/
|
|
17
|
-
export var ExpandBodyBlock = function ExpandBodyBlock(_ref) {
|
|
18
|
-
var children = _ref.children,
|
|
19
|
-
searchText = _ref.searchText;
|
|
20
|
-
var body = useExpandBody();
|
|
21
|
-
if (searchText === undefined || body === null || body.revealed) {
|
|
22
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
23
|
-
}
|
|
24
|
-
return searchText;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Called for every node the serializer renders. If the node is a block of an expand's body,
|
|
29
|
-
* wraps it so it can show its text instead of rendering while that expand is collapsed.
|
|
30
|
-
* Everything else is returned untouched.
|
|
31
|
-
*
|
|
32
|
-
* A block holding an expand of its own is also returned untouched, so a table with a nested
|
|
33
|
-
* expand in it, or an extension holding stashed ADF, renders even while collapsed. That
|
|
34
|
-
* expand needs an element of its own, because the element browser find reveals is the only
|
|
35
|
-
* way we learn the match was inside it rather than higher up. We give up the saving on those
|
|
36
|
-
* blocks so the reader searches once instead of once per level.
|
|
37
|
-
*
|
|
38
|
-
* `ancestors` is the node's ancestor chain, nearest last.
|
|
39
|
-
*/
|
|
40
|
-
export var withExpandBodyBlock = function withExpandBodyBlock(node, ancestors, index, serialized) {
|
|
41
|
-
var parent = ancestors[ancestors.length - 1];
|
|
42
|
-
if (!parent || !isExpandNode(parent)) {
|
|
43
|
-
return serialized;
|
|
44
|
-
}
|
|
45
|
-
if (!isExperimentEnabled('platform_editor_defer_collapsed_expand_body') || holdsRevealableContent(node)) {
|
|
46
|
-
return serialized;
|
|
47
|
-
}
|
|
48
|
-
var searchText = getBlockSearchText(node);
|
|
49
|
-
if (searchText === undefined) {
|
|
50
|
-
return serialized;
|
|
51
|
-
}
|
|
52
|
-
return /*#__PURE__*/React.createElement(ExpandBodyBlock, {
|
|
53
|
-
key: "expand-body-block-".concat(index),
|
|
54
|
-
searchText: searchText
|
|
55
|
-
}, serialized);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/** Whatever the serializer produced for one child: an element, a string, an array of either. */
|
|
59
|
-
|
|
60
|
-
var searchTextOf = function searchTextOf(child) {
|
|
61
|
-
return /*#__PURE__*/isValidElement(child) && child.type === ExpandBodyBlock ? child.props.searchText : undefined;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Joins neighbouring blocks that are showing text into one, so a run of them is a single string in
|
|
66
|
-
* the DOM rather than one per block. A body of twenty paragraphs becomes one text node instead of
|
|
67
|
-
* twenty.
|
|
68
|
-
*
|
|
69
|
-
* A block that is being rendered — a nested expand, say — ends the run, because the text either
|
|
70
|
-
* side of it has to stay either side of it.
|
|
71
|
-
*/
|
|
72
|
-
export var mergeExpandBodyText = function mergeExpandBodyText(children) {
|
|
73
|
-
// Called for every fragment in the document, and only an expand's body has anything to merge, so
|
|
74
|
-
// leave the array alone unless two neighbours are actually showing text.
|
|
75
|
-
var hasRun = children.some(function (child, index) {
|
|
76
|
-
return index > 0 && searchTextOf(child) !== undefined && searchTextOf(children[index - 1]) !== undefined;
|
|
77
|
-
});
|
|
78
|
-
if (!hasRun) {
|
|
79
|
-
return children;
|
|
80
|
-
}
|
|
81
|
-
var merged = [];
|
|
82
|
-
var run = [];
|
|
83
|
-
var endRun = function endRun() {
|
|
84
|
-
if (run.length === 0) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (run.length === 1) {
|
|
88
|
-
merged.push(run[0]);
|
|
89
|
-
} else {
|
|
90
|
-
var _key;
|
|
91
|
-
var text = run.map(searchTextOf).filter(Boolean).join(BLOCK_SEPARATOR);
|
|
92
|
-
// The blocks themselves, not the wrappers around them: nesting the wrappers would show
|
|
93
|
-
// each block's text again inside the joined run.
|
|
94
|
-
var blocks = run.map(function (child) {
|
|
95
|
-
return child.props.children;
|
|
96
|
-
});
|
|
97
|
-
merged.push( /*#__PURE__*/React.createElement(ExpandBodyBlock, {
|
|
98
|
-
key: (_key = run[0].key) !== null && _key !== void 0 ? _key : undefined,
|
|
99
|
-
searchText: text
|
|
100
|
-
}, blocks));
|
|
101
|
-
}
|
|
102
|
-
run = [];
|
|
103
|
-
};
|
|
104
|
-
children.forEach(function (child) {
|
|
105
|
-
if (searchTextOf(child) === undefined) {
|
|
106
|
-
endRun();
|
|
107
|
-
merged.push(child);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
run.push(child);
|
|
111
|
-
});
|
|
112
|
-
endRun();
|
|
113
|
-
return merged;
|
|
114
|
-
};
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
4
|
-
import type { OverflowShadowProps } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
6
|
-
import type { RendererAppearance, StickyHeaderConfig } from '../../ui/Renderer/types';
|
|
7
|
-
import type { WithSmartCardStorageProps } from '../../ui/SmartCardStorage';
|
|
8
|
-
import type { StickyMode } from './table/sticky';
|
|
9
|
-
import { OverflowParent } from './table/sticky';
|
|
10
|
-
import type { SharedTableProps } from './table/types';
|
|
11
|
-
import { TableStickyScrollbar } from './TableStickyScrollbar';
|
|
12
|
-
export type TableArrayMapped = {
|
|
13
|
-
rowNodes: Array<PMNode | null>;
|
|
14
|
-
rowReact: React.ReactElement;
|
|
15
|
-
};
|
|
16
|
-
export declare const isTableResizingEnabled: (appearance: RendererAppearance) => boolean;
|
|
17
|
-
export declare const isStickyScrollbarEnabled: (appearance: RendererAppearance) => boolean;
|
|
18
|
-
export declare const orderChildren: (children: React.ReactElement[], tableNode: PMNode, smartCardStorage: WithSmartCardStorageProps['smartCardStorage'], tableOrderStatus?: TableOrderStatus) => React.ReactElement[];
|
|
19
|
-
export declare const hasRowspan: (row: PMNode) => boolean;
|
|
20
|
-
export declare const getRefTop: (refElement: HTMLElement) => number;
|
|
21
|
-
export declare const shouldHeaderStick: (scrollTop: number, tableTop: number, tableBottom: number, rowHeight: number) => boolean;
|
|
22
|
-
export declare const shouldHeaderPinBottom: (scrollTop: number, tableBottom: number, rowHeight: number) => boolean;
|
|
23
|
-
export declare const addSortableColumn: (rows: React.ReactElement<any>[], tableOrderStatus: TableOrderStatus | undefined, onSorting: (columnIndex: number, sortOrder: SortOrder) => void) => React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
24
|
-
export type TableProps = SharedTableProps & {
|
|
25
|
-
allowColumnSorting?: boolean;
|
|
26
|
-
allowTableAlignment?: boolean;
|
|
27
|
-
allowTableResizing?: boolean;
|
|
28
|
-
children: React.ReactElement<any> | Array<React.ReactElement<any>>;
|
|
29
|
-
isPresentational?: boolean;
|
|
30
|
-
rendererAppearance?: RendererAppearance;
|
|
31
|
-
stickyHeaders?: StickyHeaderConfig;
|
|
32
|
-
tableNode?: PMNode;
|
|
33
|
-
};
|
|
34
|
-
export declare const isHeaderRowEnabled: (rows: (React.ReactElement | number | string | React.ReactFragment | React.ReactPortal)[]) => any;
|
|
35
|
-
export declare const tableCanBeSticky: (node: PMNode | undefined, children: (React.ReactElement | number | string | React.ReactFragment | React.ReactPortal)[]) => any;
|
|
36
|
-
export interface TableOrderStatus {
|
|
37
|
-
columnIndex: number;
|
|
38
|
-
order: SortOrder;
|
|
39
|
-
}
|
|
40
|
-
export interface TableState {
|
|
41
|
-
headerRowHeight: number;
|
|
42
|
-
stickyMode: StickyMode;
|
|
43
|
-
wrapperWidth: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Reads `nestedRendererType` from RendererContext and renders the fake left/right
|
|
47
|
-
* borders only when the current renderer is the nested renderer for a reference
|
|
48
|
-
* synced block.
|
|
49
|
-
*/
|
|
50
|
-
export declare const RefSyncBlockFakeBorders: ({ isNumberColumnEnabled, }: {
|
|
51
|
-
isNumberColumnEnabled: boolean;
|
|
52
|
-
}) => React.JSX.Element | null;
|
|
53
|
-
/**
|
|
54
|
-
* TableContainer renders tables using only CSS-based rules
|
|
55
|
-
*/
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
*/
|
|
59
|
-
export declare class TableContainer extends React.Component<TableProps & OverflowShadowProps & WithSmartCardStorageProps, TableState> {
|
|
60
|
-
state: TableState;
|
|
61
|
-
tableRef: React.RefObject<HTMLTableElement>;
|
|
62
|
-
stickyHeaderRef: React.RefObject<HTMLElement>;
|
|
63
|
-
stickyScrollbarRef: React.RefObject<HTMLDivElement>;
|
|
64
|
-
stickyWrapperRef: React.RefObject<HTMLDivElement>;
|
|
65
|
-
wrapperRef: React.RefObject<HTMLDivElement>;
|
|
66
|
-
stickyScrollbar?: TableStickyScrollbar;
|
|
67
|
-
nextFrame: number | undefined;
|
|
68
|
-
overflowParent: OverflowParent | null;
|
|
69
|
-
updatedLayout: TableLayout | 'custom';
|
|
70
|
-
private containerRef;
|
|
71
|
-
private _isInsideNestedRenderer;
|
|
72
|
-
private _isInsideTableCell;
|
|
73
|
-
private lastComputedStyle;
|
|
74
|
-
private resizeObserver;
|
|
75
|
-
private applyResizerChange;
|
|
76
|
-
/**
|
|
77
|
-
* Checks if this table is inside a nested renderer (e.g. Include Page macro)
|
|
78
|
-
* by looking for multiple .ak-renderer-document ancestors in the DOM.
|
|
79
|
-
* The result is cached since a table's position in the DOM tree is stable after mount.
|
|
80
|
-
*/
|
|
81
|
-
private isInsideNestedRenderer;
|
|
82
|
-
/**
|
|
83
|
-
* Checks if this table is inside a table cell in the DOM. The result is cached
|
|
84
|
-
* since a table's position in the DOM tree is stable after mount.
|
|
85
|
-
*/
|
|
86
|
-
private isInsideTableCell;
|
|
87
|
-
private isInsideTableContext;
|
|
88
|
-
/**
|
|
89
|
-
* For tables inside nested renderers (e.g. Include Page macro), the parent
|
|
90
|
-
* renderer's CSS override forces width:100%!important and left:0!important
|
|
91
|
-
* which overrides the inline styles set by this component. Using
|
|
92
|
-
* style.setProperty with 'important' priority on inline styles beats
|
|
93
|
-
* stylesheet !important rules per the CSS cascade.
|
|
94
|
-
*
|
|
95
|
-
* Tables that are nested inside another table need to remain constrained by
|
|
96
|
-
* their table-cell context. Do not promote their width to inline !important,
|
|
97
|
-
* otherwise nested tables rendered through macros such as Excerpt Include can
|
|
98
|
-
* overflow and overlap adjacent cells.
|
|
99
|
-
*
|
|
100
|
-
* Top-level tables in nested renderers still preserve their saved width, but
|
|
101
|
-
* are capped to their containing block so wide tables do not escape constrained
|
|
102
|
-
* macro bodies such as Excerpt Include panels.
|
|
103
|
-
*
|
|
104
|
-
* Uses lastComputedStyle (populated during render) rather than reading from
|
|
105
|
-
* element.style, because React may remove properties from the DOM when their
|
|
106
|
-
* values transition to undefined between renders.
|
|
107
|
-
*
|
|
108
|
-
* `platform_nested_table_style_override_2` fixes a follow-up regression where a
|
|
109
|
-
* NON-resized table inside an Excerpt macro (not Excerpt Include) on a
|
|
110
|
-
* wide/full-width page shrinks to only show its first columns in the renderer.
|
|
111
|
-
* Inside a nested renderer (a macro body) a non-resized table's computed width
|
|
112
|
-
* is a default layout cap (760px/1800px, or a `cqw` length for full-page
|
|
113
|
-
* appearances) taken from the outer renderer's width context. That value does
|
|
114
|
-
* not match the macro's own box, so promoting it to inline `!important` makes
|
|
115
|
-
* the table collapse. Such tables have no author-chosen size to preserve, so
|
|
116
|
-
* under this gate we re-assert the parent stylesheet's intent (fill the box:
|
|
117
|
-
* `width: 100%; left: 0`) with inline `!important`.
|
|
118
|
-
*
|
|
119
|
-
* Explicitly resized tables (`tableNode.attrs.width` set) are excluded and keep
|
|
120
|
-
* the original PGXT-10226 behavior: their author-chosen width/left is promoted
|
|
121
|
-
* verbatim so the Include Page macro does not stretch or indent them. The
|
|
122
|
-
* table-cell short-circuit (PGXT-10294) above also still applies.
|
|
123
|
-
*/
|
|
124
|
-
private applyNestedRendererTableFix;
|
|
125
|
-
/**
|
|
126
|
-
* Callback ref that captures the container DOM element and also forwards
|
|
127
|
-
* to the handleRef prop from the overflow shadow HOC.
|
|
128
|
-
*/
|
|
129
|
-
private setContainerRef;
|
|
130
|
-
/**
|
|
131
|
-
* Starts observing table dimensions and wires sticky header/scrollbar behavior after mount.
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
*/
|
|
135
|
-
componentDidMount(): void;
|
|
136
|
-
/**
|
|
137
|
-
* Updates sticky header wiring and scroll synchronization after prop or state changes.
|
|
138
|
-
*
|
|
139
|
-
* @param prevProps
|
|
140
|
-
* @param prevState
|
|
141
|
-
* @example
|
|
142
|
-
*/
|
|
143
|
-
componentDidUpdate(prevProps: TableProps, prevState: TableState): void;
|
|
144
|
-
componentWillUnmount: () => void;
|
|
145
|
-
getScrollTop: () => number;
|
|
146
|
-
updateSticky: () => void;
|
|
147
|
-
onScroll: () => void;
|
|
148
|
-
onWrapperScrolled: () => void;
|
|
149
|
-
/**
|
|
150
|
-
* Calculates the top offset used when the sticky header is pinned to the table bottom.
|
|
151
|
-
*/
|
|
152
|
-
get pinTop(): number | undefined;
|
|
153
|
-
/**
|
|
154
|
-
* Determines whether sticky header positioning should include the default scroll root offset.
|
|
155
|
-
*/
|
|
156
|
-
get shouldAddOverflowParentOffsetTop_DO_NOT_USE(): boolean | null | undefined;
|
|
157
|
-
/**
|
|
158
|
-
* Resolves the top position for the sticky header based on the current sticky mode.
|
|
159
|
-
*/
|
|
160
|
-
get stickyTop(): number | undefined;
|
|
161
|
-
/**
|
|
162
|
-
* Renders the table container, sticky header, table content, sticky scrollbar, and synced block borders.
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
*/
|
|
166
|
-
render(): React.JSX.Element;
|
|
167
|
-
private grabFirstRowRef;
|
|
168
|
-
}
|
|
169
|
-
type TableProcessorState = {
|
|
170
|
-
tableOrderStatus?: TableOrderStatus;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Processes table children before passing them to the styled table container.
|
|
174
|
-
*/
|
|
175
|
-
export declare class TableProcessorWithContainerStyles extends React.Component<TableProps & OverflowShadowProps & WithSmartCardStorageProps, TableProcessorState> {
|
|
176
|
-
state: {
|
|
177
|
-
tableOrderStatus: undefined;
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Renders processed table children inside the table container.
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
*/
|
|
184
|
-
render(): React.JSX.Element | null;
|
|
185
|
-
private addSortableColumn;
|
|
186
|
-
private changeSortOrder;
|
|
187
|
-
private addNumberColumnIndexes;
|
|
188
|
-
}
|
|
189
|
-
export {};
|