@atlaskit/editor-plugin-insert-block 3.1.7 → 3.2.1
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 +23 -0
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +2 -1
- package/dist/cjs/ui/ToolbarInsertBlock/index.js +5 -4
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +2 -1
- package/dist/es2019/ui/ToolbarInsertBlock/index.js +3 -2
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +2 -1
- package/dist/esm/ui/ToolbarInsertBlock/index.js +3 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/insertBlockPluginType.d.ts +2 -2
- package/dist/types/types/index.d.ts +7 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/insertBlockPluginType.d.ts +2 -2
- package/dist/types-ts4.5/types/index.d.ts +7 -1
- package/package.json +25 -22
- package/dist/cjs/ui/ToolbarInsertBlock/table-selector-popup-with-listeners.js +0 -258
- package/dist/cjs/ui/ToolbarInsertBlock/table-selector-popup.js +0 -158
- package/dist/es2019/ui/ToolbarInsertBlock/table-selector-popup-with-listeners.js +0 -250
- package/dist/es2019/ui/ToolbarInsertBlock/table-selector-popup.js +0 -150
- package/dist/esm/ui/ToolbarInsertBlock/table-selector-popup-with-listeners.js +0 -252
- package/dist/esm/ui/ToolbarInsertBlock/table-selector-popup.js +0 -150
- package/dist/types/ui/ToolbarInsertBlock/table-selector-popup-with-listeners.d.ts +0 -20
- package/dist/types/ui/ToolbarInsertBlock/table-selector-popup.d.ts +0 -31
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/table-selector-popup-with-listeners.d.ts +0 -20
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/table-selector-popup.d.ts +0 -31
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
/**
|
|
6
|
-
* @jsxRuntime classic
|
|
7
|
-
* @jsx jsx
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
13
|
-
import { css, jsx } from '@emotion/react';
|
|
14
|
-
import { bind } from 'bind-event-listener';
|
|
15
|
-
import { Popup } from '@atlaskit/editor-common/ui';
|
|
16
|
-
import { withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
17
|
-
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
18
|
-
import { N0, N30A, N60A } from '@atlaskit/theme/colors';
|
|
19
|
-
import tableSelectorPopup, { TABLE_SELECTOR_BUTTON_GAP, TABLE_SELECTOR_BUTTON_SIZE } from './table-selector-popup';
|
|
20
|
-
var TABLE_SELECTOR_PADDING_TOP = 8;
|
|
21
|
-
var TABLE_SELECTOR_PADDING_SIDE = 10;
|
|
22
|
-
var DEFAULT_TABLE_SELECTOR_ROWS = 5;
|
|
23
|
-
var DEFAULT_TABLE_SELECTOR_COLS = 10;
|
|
24
|
-
var DEFAULT_TABLE_SELECTOR_SELECTION_SIZE = 1;
|
|
25
|
-
var DEFAULT_MAX_TABLE_SELECTOR_ROWS = 10;
|
|
26
|
-
var TableSelectorWithListeners = withOuterListeners(tableSelectorPopup);
|
|
27
|
-
var initialSizeState = {
|
|
28
|
-
col: DEFAULT_TABLE_SELECTOR_SELECTION_SIZE,
|
|
29
|
-
row: DEFAULT_TABLE_SELECTOR_SELECTION_SIZE,
|
|
30
|
-
maxCol: DEFAULT_TABLE_SELECTOR_COLS,
|
|
31
|
-
maxRow: DEFAULT_TABLE_SELECTOR_ROWS
|
|
32
|
-
};
|
|
33
|
-
var tableSelectorPopupWrapperStyles = css({
|
|
34
|
-
borderRadius: "var(--ds-border-radius, 3px)",
|
|
35
|
-
backgroundColor: "var(--ds-surface-overlay, ".concat(N0, ")"),
|
|
36
|
-
boxShadow: "var(--ds-shadow-overlay, ".concat("0 0 0 1px ".concat(N30A, ", 0 2px 1px ").concat(N30A, ", 0 0 20px -6px ").concat(N60A), ")"),
|
|
37
|
-
padding: "".concat("var(--ds-space-100, ".concat("".concat(TABLE_SELECTOR_PADDING_TOP, "px"), ")"), " ", TABLE_SELECTOR_PADDING_SIDE, "px")
|
|
38
|
-
});
|
|
39
|
-
export var TableSelectorPopup = function TableSelectorPopup(props) {
|
|
40
|
-
var _useState = useState(initialSizeState),
|
|
41
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
42
|
-
size = _useState2[0],
|
|
43
|
-
setSize = _useState2[1];
|
|
44
|
-
var tablePopupRef = useRef(null);
|
|
45
|
-
// If popup opened by keyboard enable keyboard mode
|
|
46
|
-
var isKeyboardMode = useRef(props.isOpenedByKeyboard);
|
|
47
|
-
var enableKeyboardMode = useCallback(function () {
|
|
48
|
-
if (!isKeyboardMode.current) {
|
|
49
|
-
isKeyboardMode.current = true;
|
|
50
|
-
}
|
|
51
|
-
}, [isKeyboardMode]);
|
|
52
|
-
var disableKeyboardMode = useCallback(function () {
|
|
53
|
-
if (isKeyboardMode.current) {
|
|
54
|
-
isKeyboardMode.current = false;
|
|
55
|
-
}
|
|
56
|
-
}, [isKeyboardMode]);
|
|
57
|
-
|
|
58
|
-
// Mouse move is used to allow selection changes outside of the popup and is more reactive to changes.
|
|
59
|
-
var handleMouseMove = useCallback(function (e) {
|
|
60
|
-
if (!tablePopupRef.current) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
disableKeyboardMode();
|
|
64
|
-
var tablePopup = tablePopupRef.current;
|
|
65
|
-
var _tablePopup$getBoundi = tablePopup.getBoundingClientRect(),
|
|
66
|
-
left = _tablePopup$getBoundi.left,
|
|
67
|
-
top = _tablePopup$getBoundi.top;
|
|
68
|
-
|
|
69
|
-
// Mouse position on popup
|
|
70
|
-
var selectedWidth = e.clientX - left;
|
|
71
|
-
var selectedHeight = e.clientY - top;
|
|
72
|
-
|
|
73
|
-
// Calculate number grid cells selected
|
|
74
|
-
var selectedGridCols = Math.ceil((selectedWidth - TABLE_SELECTOR_PADDING_SIDE + TABLE_SELECTOR_BUTTON_GAP) / (TABLE_SELECTOR_BUTTON_GAP + TABLE_SELECTOR_BUTTON_SIZE));
|
|
75
|
-
var selectedGridRows = Math.ceil((selectedHeight - TABLE_SELECTOR_PADDING_TOP + TABLE_SELECTOR_BUTTON_GAP) / (TABLE_SELECTOR_BUTTON_GAP + TABLE_SELECTOR_BUTTON_SIZE));
|
|
76
|
-
// Keep the selected rows and columns within the defined bounds
|
|
77
|
-
var gridRows = DEFAULT_TABLE_SELECTOR_ROWS;
|
|
78
|
-
if (selectedGridCols < 1) {
|
|
79
|
-
selectedGridCols = 1;
|
|
80
|
-
}
|
|
81
|
-
if (selectedGridCols > size.maxCol) {
|
|
82
|
-
selectedGridCols = size.maxCol;
|
|
83
|
-
}
|
|
84
|
-
if (selectedGridRows < 1) {
|
|
85
|
-
selectedGridRows = 1;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Expand grid when row selection is greater than the default grid size
|
|
89
|
-
if (selectedGridRows >= DEFAULT_TABLE_SELECTOR_ROWS && selectedGridRows < DEFAULT_MAX_TABLE_SELECTOR_ROWS) {
|
|
90
|
-
gridRows = selectedGridRows + 1;
|
|
91
|
-
}
|
|
92
|
-
if (selectedGridRows >= DEFAULT_MAX_TABLE_SELECTOR_ROWS) {
|
|
93
|
-
selectedGridRows = DEFAULT_MAX_TABLE_SELECTOR_ROWS;
|
|
94
|
-
gridRows = DEFAULT_MAX_TABLE_SELECTOR_ROWS;
|
|
95
|
-
}
|
|
96
|
-
if (selectedGridCols !== size.col || selectedGridRows !== size.row) {
|
|
97
|
-
setSize({
|
|
98
|
-
col: selectedGridCols,
|
|
99
|
-
row: selectedGridRows,
|
|
100
|
-
maxCol: DEFAULT_TABLE_SELECTOR_COLS,
|
|
101
|
-
maxRow: gridRows
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}, [disableKeyboardMode, size, setSize]);
|
|
105
|
-
var decreasingSequence = function decreasingSequence(maxNumber, prevNumber) {
|
|
106
|
-
var nextNumber = prevNumber - 1;
|
|
107
|
-
if (prevNumber === 1) {
|
|
108
|
-
nextNumber = maxNumber;
|
|
109
|
-
}
|
|
110
|
-
return nextNumber;
|
|
111
|
-
};
|
|
112
|
-
var getMaxRow = function getMaxRow(prevSize, eventKey) {
|
|
113
|
-
switch (eventKey) {
|
|
114
|
-
case 'ArrowDown':
|
|
115
|
-
// Expand the grid size when last row selected
|
|
116
|
-
if (prevSize.maxRow < DEFAULT_MAX_TABLE_SELECTOR_ROWS && prevSize.row >= DEFAULT_TABLE_SELECTOR_ROWS - 1) {
|
|
117
|
-
return prevSize.maxRow + 1;
|
|
118
|
-
}
|
|
119
|
-
if (prevSize.row === DEFAULT_MAX_TABLE_SELECTOR_ROWS) {
|
|
120
|
-
return DEFAULT_TABLE_SELECTOR_ROWS;
|
|
121
|
-
}
|
|
122
|
-
return prevSize.maxRow;
|
|
123
|
-
case 'ArrowLeft':
|
|
124
|
-
var moveToPrevRow = prevSize.col === 1 && prevSize.row > 1;
|
|
125
|
-
var moveToLastRow = prevSize.row === 1 && prevSize.col === 1;
|
|
126
|
-
// Expand the popup to max size when selected row wraps around to last row
|
|
127
|
-
if (moveToLastRow) {
|
|
128
|
-
return DEFAULT_MAX_TABLE_SELECTOR_ROWS;
|
|
129
|
-
}
|
|
130
|
-
// Decrease the popup when decreased row selection
|
|
131
|
-
if (prevSize.maxRow > DEFAULT_TABLE_SELECTOR_ROWS && moveToPrevRow) {
|
|
132
|
-
return prevSize.row;
|
|
133
|
-
}
|
|
134
|
-
return prevSize.maxRow;
|
|
135
|
-
case 'ArrowUp':
|
|
136
|
-
if (prevSize.row === 1) {
|
|
137
|
-
return DEFAULT_MAX_TABLE_SELECTOR_ROWS;
|
|
138
|
-
// Decrease the popup size when decreased row selection
|
|
139
|
-
} else if (prevSize.maxRow > DEFAULT_TABLE_SELECTOR_ROWS) {
|
|
140
|
-
return prevSize.row;
|
|
141
|
-
}
|
|
142
|
-
return prevSize.maxRow;
|
|
143
|
-
case 'ArrowRight':
|
|
144
|
-
var moveToNextRow = prevSize.col === DEFAULT_TABLE_SELECTOR_COLS;
|
|
145
|
-
var increaseMaxRow = prevSize.maxRow < DEFAULT_MAX_TABLE_SELECTOR_ROWS && moveToNextRow && prevSize.row + 1 === prevSize.maxRow;
|
|
146
|
-
|
|
147
|
-
// Decrease popup size for wrap around to selection 1 x 1
|
|
148
|
-
if (prevSize.row === DEFAULT_MAX_TABLE_SELECTOR_ROWS && prevSize.col === DEFAULT_TABLE_SELECTOR_COLS) {
|
|
149
|
-
return DEFAULT_TABLE_SELECTOR_ROWS;
|
|
150
|
-
// Decrease the popup size when decreased row selection
|
|
151
|
-
} else if (increaseMaxRow) {
|
|
152
|
-
return prevSize.maxRow + 1;
|
|
153
|
-
}
|
|
154
|
-
return prevSize.maxRow;
|
|
155
|
-
default:
|
|
156
|
-
return prevSize.maxRow;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
var handleInitialButtonFocus = useCallback(function () {
|
|
160
|
-
if (isKeyboardMode.current !== true) {
|
|
161
|
-
enableKeyboardMode();
|
|
162
|
-
setSize(initialSizeState);
|
|
163
|
-
}
|
|
164
|
-
}, [enableKeyboardMode, setSize]);
|
|
165
|
-
var handleKeyDown = useCallback(
|
|
166
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
167
|
-
function (event) {
|
|
168
|
-
if (event.key === 'ArrowDown') {
|
|
169
|
-
enableKeyboardMode();
|
|
170
|
-
setSize(function (prevSize) {
|
|
171
|
-
return _objectSpread(_objectSpread({}, prevSize), {}, {
|
|
172
|
-
row: prevSize.row % prevSize.maxRow + 1,
|
|
173
|
-
maxRow: getMaxRow(prevSize, event.key)
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
if (event.key === 'ArrowRight') {
|
|
178
|
-
enableKeyboardMode();
|
|
179
|
-
setSize(function (prevSize) {
|
|
180
|
-
var moveToNextRow = prevSize.col === DEFAULT_TABLE_SELECTOR_COLS;
|
|
181
|
-
return _objectSpread(_objectSpread({}, prevSize), {}, {
|
|
182
|
-
col: prevSize.col % DEFAULT_TABLE_SELECTOR_COLS + 1,
|
|
183
|
-
row: moveToNextRow ? prevSize.row % prevSize.maxRow + 1 : prevSize.row,
|
|
184
|
-
maxRow: getMaxRow(prevSize, event.key)
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
if (event.key === 'ArrowLeft') {
|
|
189
|
-
enableKeyboardMode();
|
|
190
|
-
setSize(function (prevSize) {
|
|
191
|
-
var getRow = function getRow(prevRow, prevCol) {
|
|
192
|
-
var row = prevRow;
|
|
193
|
-
// Move to previous row for wrap around
|
|
194
|
-
if (prevSize.col === 1 && prevSize.row > 1) {
|
|
195
|
-
return prevRow - 1;
|
|
196
|
-
// Increase the selection to max size when selected row and column wraps around
|
|
197
|
-
} else if (prevRow === 1 && prevCol === 1) {
|
|
198
|
-
return DEFAULT_MAX_TABLE_SELECTOR_ROWS;
|
|
199
|
-
}
|
|
200
|
-
return row;
|
|
201
|
-
};
|
|
202
|
-
return _objectSpread(_objectSpread({}, prevSize), {}, {
|
|
203
|
-
col: decreasingSequence(prevSize.maxCol, prevSize.col),
|
|
204
|
-
row: getRow(prevSize.row, prevSize.col),
|
|
205
|
-
maxRow: getMaxRow(prevSize, event.key)
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
if (event.key === 'ArrowUp') {
|
|
210
|
-
enableKeyboardMode();
|
|
211
|
-
setSize(function (prevSize) {
|
|
212
|
-
var moveToLastRow = prevSize.row === 1;
|
|
213
|
-
return _objectSpread(_objectSpread({}, prevSize), {}, {
|
|
214
|
-
row: moveToLastRow ? DEFAULT_MAX_TABLE_SELECTOR_ROWS : decreasingSequence(prevSize.maxRow, prevSize.row),
|
|
215
|
-
maxRow: getMaxRow(prevSize, event.key)
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}, [enableKeyboardMode, setSize]);
|
|
220
|
-
useEffect(function () {
|
|
221
|
-
var unbind = bind(window, {
|
|
222
|
-
type: 'mousemove',
|
|
223
|
-
listener: handleMouseMove
|
|
224
|
-
});
|
|
225
|
-
return unbind;
|
|
226
|
-
}, [handleMouseMove]);
|
|
227
|
-
return jsx(Popup, {
|
|
228
|
-
target: props.target,
|
|
229
|
-
offset: [0, 3],
|
|
230
|
-
mountTo: props.popupsMountPoint,
|
|
231
|
-
boundariesElement: props.popupsBoundariesElement,
|
|
232
|
-
scrollableElement: props.popupsScrollableElement,
|
|
233
|
-
focusTrap: true,
|
|
234
|
-
onUnmount: props.onUnmount,
|
|
235
|
-
zIndex: akEditorMenuZIndex
|
|
236
|
-
}, jsx("div", {
|
|
237
|
-
css: tableSelectorPopupWrapperStyles,
|
|
238
|
-
ref: tablePopupRef
|
|
239
|
-
}, jsx(TableSelectorWithListeners, {
|
|
240
|
-
handleClickOutside: props.handleClickOutside,
|
|
241
|
-
handleEscapeKeydown: props.handleEscapeKeydown,
|
|
242
|
-
maxCols: size.maxCol,
|
|
243
|
-
maxRows: size.maxRow,
|
|
244
|
-
onSelection: props.onSelection,
|
|
245
|
-
selectedCol: size.col,
|
|
246
|
-
selectedRow: size.row,
|
|
247
|
-
onKeyDown: handleKeyDown,
|
|
248
|
-
isFocused: isKeyboardMode.current,
|
|
249
|
-
handleInitialButtonFocus: handleInitialButtonFocus
|
|
250
|
-
})));
|
|
251
|
-
};
|
|
252
|
-
export default TableSelectorPopup;
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import { useContext, useEffect, useMemo, useRef } from 'react';
|
|
6
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
|
-
import { css, jsx } from '@emotion/react';
|
|
8
|
-
import { injectIntl } from 'react-intl-next';
|
|
9
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
|
-
import { OutsideClickTargetRefContext } from '@atlaskit/editor-common/ui-react';
|
|
11
|
-
import { Stack } from '@atlaskit/primitives';
|
|
12
|
-
import { B100 } from '@atlaskit/theme/colors';
|
|
13
|
-
export var TABLE_SELECTOR_BUTTON_GAP = 2;
|
|
14
|
-
export var TABLE_SELECTOR_BUTTON_SIZE = 17;
|
|
15
|
-
var selectedButtonStyles = css({
|
|
16
|
-
backgroundColor: "var(--ds-background-accent-blue-subtlest, #579DFF)",
|
|
17
|
-
border: "1px solid ".concat("var(--ds-background-accent-blue-subtle, #579DFF)")
|
|
18
|
-
});
|
|
19
|
-
var buttonStyles = css({
|
|
20
|
-
height: "".concat(TABLE_SELECTOR_BUTTON_SIZE, "px"),
|
|
21
|
-
width: "".concat(TABLE_SELECTOR_BUTTON_SIZE, "px"),
|
|
22
|
-
border: "1px solid ".concat("var(--ds-border, #091e4224)"),
|
|
23
|
-
backgroundColor: "var(--ds-background-input, #ffffff)",
|
|
24
|
-
borderRadius: '3px',
|
|
25
|
-
cursor: 'pointer',
|
|
26
|
-
display: 'block',
|
|
27
|
-
'&:focus': {
|
|
28
|
-
outline: 'none',
|
|
29
|
-
border: "1px solid ".concat("var(--ds-border-focused, ".concat(B100, ")")),
|
|
30
|
-
boxShadow: "0 0 0 0.5px ".concat("var(--ds-border-focused, ".concat(B100, ")"))
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
var selectionSizeTextStyles = css({
|
|
34
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
35
|
-
lineHeight: '14px',
|
|
36
|
-
display: 'flex',
|
|
37
|
-
justifyContent: 'center',
|
|
38
|
-
marginTop: "var(--ds-space-075, 5px)",
|
|
39
|
-
padding: "var(--ds-space-075, 10px)"
|
|
40
|
-
});
|
|
41
|
-
var TableSelectorButton = function TableSelectorButton(_ref) {
|
|
42
|
-
var row = _ref.row,
|
|
43
|
-
col = _ref.col,
|
|
44
|
-
isActive = _ref.isActive,
|
|
45
|
-
_onClick = _ref.onClick,
|
|
46
|
-
label = _ref.label,
|
|
47
|
-
onKeyDown = _ref.onKeyDown,
|
|
48
|
-
isFocused = _ref.isFocused,
|
|
49
|
-
handleInitialButtonFocus = _ref.handleInitialButtonFocus;
|
|
50
|
-
var btnRef = useRef(null);
|
|
51
|
-
useEffect(function () {
|
|
52
|
-
if (btnRef.current) {
|
|
53
|
-
if (isFocused) {
|
|
54
|
-
btnRef.current.focus();
|
|
55
|
-
} else {
|
|
56
|
-
btnRef.current.blur();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}, [isFocused, btnRef]);
|
|
60
|
-
var handleFocus = col === 1 && row === 1 ? function () {
|
|
61
|
-
return handleInitialButtonFocus();
|
|
62
|
-
} : undefined;
|
|
63
|
-
return jsx("button", {
|
|
64
|
-
type: "button",
|
|
65
|
-
css: [buttonStyles, isActive ? selectedButtonStyles : undefined],
|
|
66
|
-
onClick: function onClick() {
|
|
67
|
-
return _onClick(row, col);
|
|
68
|
-
},
|
|
69
|
-
"aria-label": label,
|
|
70
|
-
onKeyDown: onKeyDown,
|
|
71
|
-
ref: btnRef,
|
|
72
|
-
onFocus: handleFocus
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
var createArray = function createArray(maxCols, maxRows) {
|
|
76
|
-
var arr = [];
|
|
77
|
-
for (var i = 1; i < maxRows + 1; i++) {
|
|
78
|
-
for (var j = 1; j < maxCols + 1; j++) {
|
|
79
|
-
arr.push({
|
|
80
|
-
col: j,
|
|
81
|
-
row: i
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return arr;
|
|
86
|
-
};
|
|
87
|
-
var gridWrapperStyles = function gridWrapperStyles(_ref2) {
|
|
88
|
-
var maxCols = _ref2.maxCols,
|
|
89
|
-
maxRows = _ref2.maxRows;
|
|
90
|
-
return css({
|
|
91
|
-
display: 'grid',
|
|
92
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
93
|
-
gridTemplateColumns: "repeat(".concat(maxCols, ", 1fr)"),
|
|
94
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
95
|
-
gridTemplateRows: "repeat(".concat(maxRows, ", 1fr)"),
|
|
96
|
-
gap: "".concat("var(--ds-space-025, ".concat("".concat(TABLE_SELECTOR_BUTTON_GAP, "px"), ")"))
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
var TableSelectorPopup = function TableSelectorPopup(_ref3) {
|
|
100
|
-
var maxCols = _ref3.maxCols,
|
|
101
|
-
maxRows = _ref3.maxRows,
|
|
102
|
-
onSelection = _ref3.onSelection,
|
|
103
|
-
selectedCol = _ref3.selectedCol,
|
|
104
|
-
selectedRow = _ref3.selectedRow,
|
|
105
|
-
onKeyDown = _ref3.onKeyDown,
|
|
106
|
-
isFocused = _ref3.isFocused,
|
|
107
|
-
handleInitialButtonFocus = _ref3.handleInitialButtonFocus,
|
|
108
|
-
formatMessage = _ref3.intl.formatMessage;
|
|
109
|
-
var buttons = useMemo(function () {
|
|
110
|
-
return createArray(maxCols, maxRows);
|
|
111
|
-
}, [maxCols, maxRows]);
|
|
112
|
-
var setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
|
|
113
|
-
return jsx(Stack, {
|
|
114
|
-
ref: setOutsideClickTargetRef
|
|
115
|
-
}, jsx("div", {
|
|
116
|
-
"aria-label": "".concat(formatMessage(messages.tableSizeSelectorPopup)),
|
|
117
|
-
css:
|
|
118
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
119
|
-
gridWrapperStyles({
|
|
120
|
-
maxCols: maxCols,
|
|
121
|
-
maxRows: maxRows
|
|
122
|
-
})
|
|
123
|
-
}, buttons.map(function (_ref4, index) {
|
|
124
|
-
var col = _ref4.col,
|
|
125
|
-
row = _ref4.row;
|
|
126
|
-
var isCurrentFocused = isFocused && selectedCol === col && selectedRow === row;
|
|
127
|
-
var isActive = selectedCol >= col && selectedRow >= row ? true : false;
|
|
128
|
-
return jsx(TableSelectorButton
|
|
129
|
-
// Ignored via go/ees005
|
|
130
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
131
|
-
, {
|
|
132
|
-
key: index,
|
|
133
|
-
isActive: isActive,
|
|
134
|
-
col: col,
|
|
135
|
-
row: row,
|
|
136
|
-
onClick: onSelection,
|
|
137
|
-
label: "".concat(formatMessage(messages.tableSizeSelectorButton, {
|
|
138
|
-
numberOfColumns: col,
|
|
139
|
-
numberOfRows: row
|
|
140
|
-
})),
|
|
141
|
-
onKeyDown: onKeyDown,
|
|
142
|
-
isFocused: isCurrentFocused,
|
|
143
|
-
handleInitialButtonFocus: handleInitialButtonFocus
|
|
144
|
-
});
|
|
145
|
-
})), jsx("span", {
|
|
146
|
-
css: selectionSizeTextStyles,
|
|
147
|
-
"aria-hidden": true
|
|
148
|
-
}, "".concat(selectedCol, " x ").concat(selectedRow)));
|
|
149
|
-
};
|
|
150
|
-
export default injectIntl(TableSelectorPopup);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import { jsx } from '@emotion/react';
|
|
6
|
-
import type { OnTableSizeSelection } from './table-selector-popup';
|
|
7
|
-
type SimpleEventHandler<T> = (event: T) => void;
|
|
8
|
-
export interface TableSelectorPopupProps {
|
|
9
|
-
onUnmount?: () => void;
|
|
10
|
-
onSelection: OnTableSizeSelection;
|
|
11
|
-
target?: HTMLElement;
|
|
12
|
-
popupsMountPoint?: HTMLElement;
|
|
13
|
-
popupsBoundariesElement?: HTMLElement;
|
|
14
|
-
popupsScrollableElement?: HTMLElement;
|
|
15
|
-
handleClickOutside?: SimpleEventHandler<MouseEvent>;
|
|
16
|
-
handleEscapeKeydown?: SimpleEventHandler<KeyboardEvent>;
|
|
17
|
-
isOpenedByKeyboard: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare const TableSelectorPopup: (props: TableSelectorPopupProps) => jsx.JSX.Element;
|
|
20
|
-
export default TableSelectorPopup;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { KeyboardEventHandler, SyntheticEvent } from 'react';
|
|
2
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
export declare const TABLE_SELECTOR_BUTTON_GAP = 2;
|
|
4
|
-
export declare const TABLE_SELECTOR_BUTTON_SIZE = 17;
|
|
5
|
-
export interface TableSelectorButtonProps {
|
|
6
|
-
row: number;
|
|
7
|
-
col: number;
|
|
8
|
-
isActive: boolean;
|
|
9
|
-
onClick: OnTableSizeSelection;
|
|
10
|
-
label: string;
|
|
11
|
-
onKeyDown: KeyboardEventHandler<HTMLButtonElement>;
|
|
12
|
-
isFocused: boolean;
|
|
13
|
-
handleInitialButtonFocus: () => void;
|
|
14
|
-
}
|
|
15
|
-
export interface OnTableSizeSelection {
|
|
16
|
-
(rowsCount: number, colsCount: number, event?: SyntheticEvent): void;
|
|
17
|
-
}
|
|
18
|
-
interface TableSelectorPopupProps {
|
|
19
|
-
maxCols: number;
|
|
20
|
-
maxRows: number;
|
|
21
|
-
onSelection: OnTableSizeSelection;
|
|
22
|
-
selectedCol: number;
|
|
23
|
-
selectedRow: number;
|
|
24
|
-
onKeyDown: KeyboardEventHandler<HTMLButtonElement>;
|
|
25
|
-
isFocused: boolean;
|
|
26
|
-
handleInitialButtonFocus: () => void;
|
|
27
|
-
}
|
|
28
|
-
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<TableSelectorPopupProps & WrappedComponentProps>> & {
|
|
29
|
-
WrappedComponent: import("react").ComponentType<TableSelectorPopupProps & WrappedComponentProps>;
|
|
30
|
-
};
|
|
31
|
-
export default _default;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import { jsx } from '@emotion/react';
|
|
6
|
-
import type { OnTableSizeSelection } from './table-selector-popup';
|
|
7
|
-
type SimpleEventHandler<T> = (event: T) => void;
|
|
8
|
-
export interface TableSelectorPopupProps {
|
|
9
|
-
onUnmount?: () => void;
|
|
10
|
-
onSelection: OnTableSizeSelection;
|
|
11
|
-
target?: HTMLElement;
|
|
12
|
-
popupsMountPoint?: HTMLElement;
|
|
13
|
-
popupsBoundariesElement?: HTMLElement;
|
|
14
|
-
popupsScrollableElement?: HTMLElement;
|
|
15
|
-
handleClickOutside?: SimpleEventHandler<MouseEvent>;
|
|
16
|
-
handleEscapeKeydown?: SimpleEventHandler<KeyboardEvent>;
|
|
17
|
-
isOpenedByKeyboard: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare const TableSelectorPopup: (props: TableSelectorPopupProps) => jsx.JSX.Element;
|
|
20
|
-
export default TableSelectorPopup;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { KeyboardEventHandler, SyntheticEvent } from 'react';
|
|
2
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
export declare const TABLE_SELECTOR_BUTTON_GAP = 2;
|
|
4
|
-
export declare const TABLE_SELECTOR_BUTTON_SIZE = 17;
|
|
5
|
-
export interface TableSelectorButtonProps {
|
|
6
|
-
row: number;
|
|
7
|
-
col: number;
|
|
8
|
-
isActive: boolean;
|
|
9
|
-
onClick: OnTableSizeSelection;
|
|
10
|
-
label: string;
|
|
11
|
-
onKeyDown: KeyboardEventHandler<HTMLButtonElement>;
|
|
12
|
-
isFocused: boolean;
|
|
13
|
-
handleInitialButtonFocus: () => void;
|
|
14
|
-
}
|
|
15
|
-
export interface OnTableSizeSelection {
|
|
16
|
-
(rowsCount: number, colsCount: number, event?: SyntheticEvent): void;
|
|
17
|
-
}
|
|
18
|
-
interface TableSelectorPopupProps {
|
|
19
|
-
maxCols: number;
|
|
20
|
-
maxRows: number;
|
|
21
|
-
onSelection: OnTableSizeSelection;
|
|
22
|
-
selectedCol: number;
|
|
23
|
-
selectedRow: number;
|
|
24
|
-
onKeyDown: KeyboardEventHandler<HTMLButtonElement>;
|
|
25
|
-
isFocused: boolean;
|
|
26
|
-
handleInitialButtonFocus: () => void;
|
|
27
|
-
}
|
|
28
|
-
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<TableSelectorPopupProps & WrappedComponentProps>> & {
|
|
29
|
-
WrappedComponent: import("react").ComponentType<TableSelectorPopupProps & WrappedComponentProps>;
|
|
30
|
-
};
|
|
31
|
-
export default _default;
|