@datarobot/design-system 30.2.0 → 30.3.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.
- package/cjs/table-react/components/table-settings/table-settings-item.js +13 -0
- package/esm/table-react/components/table-settings/table-settings-item.js +13 -0
- package/js/bundle/bundle.js +16 -4
- package/js/bundle/bundle.min.js +1 -1
- package/package.json +1 -1
- package/styles/index.css +3 -0
- package/styles/index.min.css +1 -1
|
@@ -15,6 +15,7 @@ var _truncateWithTooltip = require("../../../truncate-with-tooltip");
|
|
|
15
15
|
var _button = require("../../../button");
|
|
16
16
|
var _fontAwesomeIcon = require("../../../font-awesome-icon");
|
|
17
17
|
var _hooks = require("../../../hooks");
|
|
18
|
+
var _useTranslation = require("../../../hooks/use-translation");
|
|
18
19
|
var _types = require("../../types");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -30,6 +31,9 @@ function TableSettingsItem({
|
|
|
30
31
|
handleKeyboardColumnsReorder,
|
|
31
32
|
localizationText
|
|
32
33
|
}) {
|
|
34
|
+
const {
|
|
35
|
+
t
|
|
36
|
+
} = (0, _useTranslation.useTranslation)();
|
|
33
37
|
const isPinned = listItem.getIsPinned();
|
|
34
38
|
const sorted = listItem.getIsSorted();
|
|
35
39
|
const isVisible = listItem.getIsVisible();
|
|
@@ -67,6 +71,13 @@ function TableSettingsItem({
|
|
|
67
71
|
break;
|
|
68
72
|
}
|
|
69
73
|
};
|
|
74
|
+
const visibleColumns = settings.getVisibleLeafColumns().filter(({
|
|
75
|
+
columnDef: {
|
|
76
|
+
meta
|
|
77
|
+
}
|
|
78
|
+
}) => meta?.hideFromSettings !== true);
|
|
79
|
+
const isOneVisible = visibleColumns.length === 1;
|
|
80
|
+
const disableHideColumns = isOneVisible && isVisible;
|
|
70
81
|
return (
|
|
71
82
|
/*#__PURE__*/
|
|
72
83
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -87,6 +98,8 @@ function TableSettingsItem({
|
|
|
87
98
|
id: `checkbox-${listItem.id}`,
|
|
88
99
|
testId: `visibility-checkbox-${listItem.id}`,
|
|
89
100
|
isChecked: isVisible,
|
|
101
|
+
isDisabled: disableHideColumns,
|
|
102
|
+
tooltipText: disableHideColumns ? t('At least one column must stay selected') : undefined,
|
|
90
103
|
onChange: listItem.getToggleVisibilityHandler(),
|
|
91
104
|
className: "table-settings-checkbox",
|
|
92
105
|
ariaLabel: listItem.columnDef.header
|
|
@@ -9,6 +9,7 @@ import { TruncateWithTooltip } from '../../../truncate-with-tooltip';
|
|
|
9
9
|
import { ACCENT_TYPES, Button, BUTTON_SIZES } from '../../../button';
|
|
10
10
|
import { FontAwesomeIcon } from '../../../font-awesome-icon';
|
|
11
11
|
import { useFocusWithin } from '../../../hooks';
|
|
12
|
+
import { useTranslation } from '../../../hooks/use-translation';
|
|
12
13
|
import { PINNED_WIDTH_THRESHOLD, SORTING } from '../../types';
|
|
13
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
export function TableSettingsItem({
|
|
@@ -22,6 +23,9 @@ export function TableSettingsItem({
|
|
|
22
23
|
handleKeyboardColumnsReorder,
|
|
23
24
|
localizationText
|
|
24
25
|
}) {
|
|
26
|
+
const {
|
|
27
|
+
t
|
|
28
|
+
} = useTranslation();
|
|
25
29
|
const isPinned = listItem.getIsPinned();
|
|
26
30
|
const sorted = listItem.getIsSorted();
|
|
27
31
|
const isVisible = listItem.getIsVisible();
|
|
@@ -59,6 +63,13 @@ export function TableSettingsItem({
|
|
|
59
63
|
break;
|
|
60
64
|
}
|
|
61
65
|
};
|
|
66
|
+
const visibleColumns = settings.getVisibleLeafColumns().filter(({
|
|
67
|
+
columnDef: {
|
|
68
|
+
meta
|
|
69
|
+
}
|
|
70
|
+
}) => meta?.hideFromSettings !== true);
|
|
71
|
+
const isOneVisible = visibleColumns.length === 1;
|
|
72
|
+
const disableHideColumns = isOneVisible && isVisible;
|
|
62
73
|
return (
|
|
63
74
|
/*#__PURE__*/
|
|
64
75
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -79,6 +90,8 @@ export function TableSettingsItem({
|
|
|
79
90
|
id: `checkbox-${listItem.id}`,
|
|
80
91
|
testId: `visibility-checkbox-${listItem.id}`,
|
|
81
92
|
isChecked: isVisible,
|
|
93
|
+
isDisabled: disableHideColumns,
|
|
94
|
+
tooltipText: disableHideColumns ? t('At least one column must stay selected') : undefined,
|
|
82
95
|
onChange: listItem.getToggleVisibilityHandler(),
|
|
83
96
|
className: "table-settings-checkbox",
|
|
84
97
|
ariaLabel: listItem.columnDef.header
|
package/js/bundle/bundle.js
CHANGED
|
@@ -79076,7 +79076,8 @@ function TableSettingsGroup(_ref) {
|
|
|
79076
79076
|
/* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../button */ "./src/components/button/index.ts");
|
|
79077
79077
|
/* harmony import */ var _font_awesome_icon__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../font-awesome-icon */ "./src/components/font-awesome-icon/index.ts");
|
|
79078
79078
|
/* harmony import */ var _hooks__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../hooks */ "./src/components/hooks/index.ts");
|
|
79079
|
-
/* harmony import */ var
|
|
79079
|
+
/* harmony import */ var _hooks_use_translation__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../hooks/use-translation */ "./src/components/hooks/use-translation/index.ts");
|
|
79080
|
+
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../types */ "./src/components/table-react/types.ts");
|
|
79080
79081
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
79081
79082
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
79082
79083
|
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; } }
|
|
@@ -79095,6 +79096,7 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
|
79095
79096
|
|
|
79096
79097
|
|
|
79097
79098
|
|
|
79099
|
+
|
|
79098
79100
|
function TableSettingsItem(_ref) {
|
|
79099
79101
|
var index = _ref.index,
|
|
79100
79102
|
listItem = _ref.listItem,
|
|
@@ -79105,6 +79107,8 @@ function TableSettingsItem(_ref) {
|
|
|
79105
79107
|
isReorderEnabled = _ref.isReorderEnabled,
|
|
79106
79108
|
handleKeyboardColumnsReorder = _ref.handleKeyboardColumnsReorder,
|
|
79107
79109
|
localizationText = _ref.localizationText;
|
|
79110
|
+
var _useTranslation = (0,_hooks_use_translation__WEBPACK_IMPORTED_MODULE_11__.useTranslation)(),
|
|
79111
|
+
t = _useTranslation.t;
|
|
79108
79112
|
var isPinned = listItem.getIsPinned();
|
|
79109
79113
|
var sorted = listItem.getIsSorted();
|
|
79110
79114
|
var isVisible = listItem.getIsVisible();
|
|
@@ -79120,10 +79124,10 @@ function TableSettingsItem(_ref) {
|
|
|
79120
79124
|
setItemFocused(false);
|
|
79121
79125
|
}
|
|
79122
79126
|
});
|
|
79123
|
-
var sortIcon = sorted ===
|
|
79127
|
+
var sortIcon = sorted === _types__WEBPACK_IMPORTED_MODULE_12__.SORTING.DESC ? _fortawesome_free_solid_svg_icons_faDownLong__WEBPACK_IMPORTED_MODULE_2__.faDownLong : _fortawesome_free_solid_svg_icons_faUpLong__WEBPACK_IMPORTED_MODULE_3__.faUpLong;
|
|
79124
79128
|
var nextSorting = listItem.getNextSortingOrder();
|
|
79125
|
-
var nextSortIcon = nextSorting ===
|
|
79126
|
-
var isColumnPinDisabled = !isPinned && (listItem.getSize() + settings.getLeftTotalSize()) / tableContainerWidth >
|
|
79129
|
+
var nextSortIcon = nextSorting === _types__WEBPACK_IMPORTED_MODULE_12__.SORTING.DESC ? _fortawesome_free_solid_svg_icons_faDownLong__WEBPACK_IMPORTED_MODULE_2__.faDownLong : _fortawesome_free_solid_svg_icons_faUpLong__WEBPACK_IMPORTED_MODULE_3__.faUpLong;
|
|
79130
|
+
var isColumnPinDisabled = !isPinned && (listItem.getSize() + settings.getLeftTotalSize()) / tableContainerWidth > _types__WEBPACK_IMPORTED_MODULE_12__.PINNED_WIDTH_THRESHOLD;
|
|
79127
79131
|
var togglePin = function togglePin() {
|
|
79128
79132
|
if (isPinned) {
|
|
79129
79133
|
listItem.pin(false);
|
|
@@ -79145,6 +79149,12 @@ function TableSettingsItem(_ref) {
|
|
|
79145
79149
|
break;
|
|
79146
79150
|
}
|
|
79147
79151
|
};
|
|
79152
|
+
var visibleColumns = settings.getVisibleLeafColumns().filter(function (_ref2) {
|
|
79153
|
+
var meta = _ref2.columnDef.meta;
|
|
79154
|
+
return (meta === null || meta === void 0 ? void 0 : meta.hideFromSettings) !== true;
|
|
79155
|
+
});
|
|
79156
|
+
var isOneVisible = visibleColumns.length === 1;
|
|
79157
|
+
var disableHideColumns = isOneVisible && isVisible;
|
|
79148
79158
|
return (
|
|
79149
79159
|
/*#__PURE__*/
|
|
79150
79160
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -79166,6 +79176,8 @@ function TableSettingsItem(_ref) {
|
|
|
79166
79176
|
id: "checkbox-".concat(listItem.id),
|
|
79167
79177
|
testId: "visibility-checkbox-".concat(listItem.id),
|
|
79168
79178
|
isChecked: isVisible,
|
|
79179
|
+
isDisabled: disableHideColumns,
|
|
79180
|
+
tooltipText: disableHideColumns ? t('At least one column must stay selected') : undefined,
|
|
79169
79181
|
onChange: listItem.getToggleVisibilityHandler(),
|
|
79170
79182
|
className: "table-settings-checkbox",
|
|
79171
79183
|
ariaLabel: listItem.columnDef.header
|