@gravity-ui/dashkit 8.7.0 → 8.7.2
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.
|
@@ -143,26 +143,26 @@ class OverlayControls extends react_1.default.Component {
|
|
|
143
143
|
const controls = hasCustomOverlayLeftControls
|
|
144
144
|
? customLeftControls.map((item, index, items) => this.renderControlsItem(item, index, items.length + 1))
|
|
145
145
|
: defaultControl;
|
|
146
|
-
const menu = this.renderMenu();
|
|
146
|
+
const menu = this.renderMenu(controls === null);
|
|
147
147
|
return (react_1.default.createElement("div", { className: b('default-controls', {
|
|
148
148
|
'with-custom-left': hasCustomOverlayLeftControls,
|
|
149
149
|
}) },
|
|
150
150
|
controls,
|
|
151
151
|
menu));
|
|
152
152
|
}
|
|
153
|
-
renderMenu() {
|
|
153
|
+
renderMenu(isOnlyOneItem) {
|
|
154
154
|
const { view, size } = this.props;
|
|
155
|
-
const dropdown = this.renderDropdownMenu();
|
|
155
|
+
const dropdown = this.renderDropdownMenu(isOnlyOneItem);
|
|
156
156
|
if (dropdown) {
|
|
157
157
|
return dropdown;
|
|
158
158
|
}
|
|
159
|
-
return (react_1.default.createElement(uikit_1.Button, { key: 'delete-control', view: view, size: size, title: (0, i18n_1.i18n)('label_delete'), pin:
|
|
159
|
+
return (react_1.default.createElement(uikit_1.Button, { key: 'delete-control', view: view, size: size, title: (0, i18n_1.i18n)('label_delete'), pin: isOnlyOneItem ? 'round-round' : 'brick-round', onClick: this.onRemoveItem, qa: "dashkit-overlay-control-menu" },
|
|
160
160
|
react_1.default.createElement(uikit_1.Icon, { data: CloseIcon_1.CloseIcon, size: "12" })));
|
|
161
161
|
}
|
|
162
162
|
isDefaultMenu(menu) {
|
|
163
163
|
return menu === null || menu === void 0 ? void 0 : menu.every((item) => Object.values(constants_1.MenuItems).includes(String(item)));
|
|
164
164
|
}
|
|
165
|
-
renderDropdownMenu() {
|
|
165
|
+
renderDropdownMenu(isOnlyOneItem) {
|
|
166
166
|
const { view, size } = this.props;
|
|
167
167
|
const { menu: contextMenu, itemsParams, itemsState } = this.context;
|
|
168
168
|
const configItem = this.props.configItem;
|
|
@@ -204,7 +204,7 @@ class OverlayControls extends react_1.default.Component {
|
|
|
204
204
|
if (items.length === 0) {
|
|
205
205
|
return null;
|
|
206
206
|
}
|
|
207
|
-
return (react_1.default.createElement(uikit_1.DropdownMenu, { items: items, renderSwitcher: (props) => (react_1.default.createElement(uikit_1.Button, Object.assign({}, props, { view: view, size: size, pin:
|
|
207
|
+
return (react_1.default.createElement(uikit_1.DropdownMenu, { items: items, renderSwitcher: (props) => (react_1.default.createElement(uikit_1.Button, Object.assign({}, props, { view: view, size: size, pin: isOnlyOneItem ? 'round-round' : 'brick-round', qa: "dashkit-overlay-control-menu" }),
|
|
208
208
|
react_1.default.createElement(uikit_1.Icon, { data: DotsIcon_1.DotsIcon, size: "16" }))) }));
|
|
209
209
|
}
|
|
210
210
|
getControlItemPinStyle(index, itemsLength) {
|
|
@@ -225,8 +225,9 @@ class OverlayControls extends react_1.default.Component {
|
|
|
225
225
|
getCustomControlsWithWidgets() {
|
|
226
226
|
const items = this.getItems();
|
|
227
227
|
const result = items.map((item, index, controlItems) => this.renderControlsItem(item, index, controlItems.length));
|
|
228
|
+
const isOnlyOneItem = items.length === 0;
|
|
228
229
|
// Добавляем контрол удаления или меню виджета по умолчанию
|
|
229
|
-
result.push(this.renderMenu());
|
|
230
|
+
result.push(this.renderMenu(isOnlyOneItem));
|
|
230
231
|
return result;
|
|
231
232
|
}
|
|
232
233
|
}
|
|
@@ -140,26 +140,26 @@ class OverlayControls extends React.Component {
|
|
|
140
140
|
const controls = hasCustomOverlayLeftControls
|
|
141
141
|
? customLeftControls.map((item, index, items) => this.renderControlsItem(item, index, items.length + 1))
|
|
142
142
|
: defaultControl;
|
|
143
|
-
const menu = this.renderMenu();
|
|
143
|
+
const menu = this.renderMenu(controls === null);
|
|
144
144
|
return (React.createElement("div", { className: b('default-controls', {
|
|
145
145
|
'with-custom-left': hasCustomOverlayLeftControls,
|
|
146
146
|
}) },
|
|
147
147
|
controls,
|
|
148
148
|
menu));
|
|
149
149
|
}
|
|
150
|
-
renderMenu() {
|
|
150
|
+
renderMenu(isOnlyOneItem) {
|
|
151
151
|
const { view, size } = this.props;
|
|
152
|
-
const dropdown = this.renderDropdownMenu();
|
|
152
|
+
const dropdown = this.renderDropdownMenu(isOnlyOneItem);
|
|
153
153
|
if (dropdown) {
|
|
154
154
|
return dropdown;
|
|
155
155
|
}
|
|
156
|
-
return (React.createElement(Button, { key: 'delete-control', view: view, size: size, title: i18n('label_delete'), pin:
|
|
156
|
+
return (React.createElement(Button, { key: 'delete-control', view: view, size: size, title: i18n('label_delete'), pin: isOnlyOneItem ? 'round-round' : 'brick-round', onClick: this.onRemoveItem, qa: "dashkit-overlay-control-menu" },
|
|
157
157
|
React.createElement(Icon, { data: CloseIcon, size: "12" })));
|
|
158
158
|
}
|
|
159
159
|
isDefaultMenu(menu) {
|
|
160
160
|
return menu === null || menu === void 0 ? void 0 : menu.every((item) => Object.values(MenuItems).includes(String(item)));
|
|
161
161
|
}
|
|
162
|
-
renderDropdownMenu() {
|
|
162
|
+
renderDropdownMenu(isOnlyOneItem) {
|
|
163
163
|
const { view, size } = this.props;
|
|
164
164
|
const { menu: contextMenu, itemsParams, itemsState } = this.context;
|
|
165
165
|
const configItem = this.props.configItem;
|
|
@@ -201,7 +201,7 @@ class OverlayControls extends React.Component {
|
|
|
201
201
|
if (items.length === 0) {
|
|
202
202
|
return null;
|
|
203
203
|
}
|
|
204
|
-
return (React.createElement(DropdownMenu, { items: items, renderSwitcher: (props) => (React.createElement(Button, Object.assign({}, props, { view: view, size: size, pin:
|
|
204
|
+
return (React.createElement(DropdownMenu, { items: items, renderSwitcher: (props) => (React.createElement(Button, Object.assign({}, props, { view: view, size: size, pin: isOnlyOneItem ? 'round-round' : 'brick-round', qa: "dashkit-overlay-control-menu" }),
|
|
205
205
|
React.createElement(Icon, { data: DotsIcon, size: "16" }))) }));
|
|
206
206
|
}
|
|
207
207
|
getControlItemPinStyle(index, itemsLength) {
|
|
@@ -222,8 +222,9 @@ class OverlayControls extends React.Component {
|
|
|
222
222
|
getCustomControlsWithWidgets() {
|
|
223
223
|
const items = this.getItems();
|
|
224
224
|
const result = items.map((item, index, controlItems) => this.renderControlsItem(item, index, controlItems.length));
|
|
225
|
+
const isOnlyOneItem = items.length === 0;
|
|
225
226
|
// Добавляем контрол удаления или меню виджета по умолчанию
|
|
226
|
-
result.push(this.renderMenu());
|
|
227
|
+
result.push(this.renderMenu(isOnlyOneItem));
|
|
227
228
|
return result;
|
|
228
229
|
}
|
|
229
230
|
}
|