@datarobot/design-system 29.0.0 → 29.1.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.
@@ -3,6 +3,7 @@ import { IconProp } from '@fortawesome/fontawesome-svg-core';
3
3
  import { TooltipPlacementsType } from '../tooltip';
4
4
  import './dropdown-item-title.less';
5
5
  export type DropdownItemTitleOption = {
6
+ key: string | number;
6
7
  iconClass?: string;
7
8
  icon?: IconProp;
8
9
  title?: ReactNode;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _faChevronRight = require("@fortawesome/free-solid-svg-icons/faChevronRight");
10
10
  var _fontAwesomeIcon = require("../font-awesome-icon");
@@ -12,6 +12,7 @@ var _truncateWithTooltip = require("../truncate-with-tooltip");
12
12
  var _tooltip = require("../tooltip");
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
16
  const DropdownItemTitle = ({
16
17
  option,
17
18
  isMultiLevelHandler = false
@@ -25,7 +26,8 @@ const DropdownItemTitle = ({
25
26
  tooltipPlacement,
26
27
  tooltipText,
27
28
  tooltipDocsLink,
28
- tooltipTestId
29
+ tooltipTestId,
30
+ key
29
31
  } = option;
30
32
  const props = {
31
33
  tooltipText,
@@ -59,14 +61,14 @@ const DropdownItemTitle = ({
59
61
  })
60
62
  });
61
63
  const withTruncatableText = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
62
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_truncateWithTooltip.TruncateWithTooltip, {
64
+ children: [/*#__PURE__*/(0, _react.createElement)(_truncateWithTooltip.TruncateWithTooltip, {
63
65
  ...props,
64
- children: itemTitle
65
- }), subtext && /*#__PURE__*/(0, _jsxRuntime.jsx)(_truncateWithTooltip.TruncateWithTooltip, {
66
+ key: key
67
+ }, itemTitle), subtext && /*#__PURE__*/(0, _react.createElement)(_truncateWithTooltip.TruncateWithTooltip, {
66
68
  ...props,
67
69
  tooltipTestId: `${tooltipTestId}-subtext`,
68
- children: itemSubText
69
- })]
70
+ key: `${key}-subtext`
71
+ }, itemSubText)]
70
72
  });
71
73
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
72
74
  className: (0, _classnames.default)('drop-item-content-wrap', {
@@ -22,7 +22,7 @@ const DefaultTriggerContent = ({
22
22
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
23
23
  children: selectedItem?.title ?? defaultTriggerText
24
24
  })
25
- });
25
+ }, selectedItem?.key ?? 0);
26
26
  const DropdownMenuTrigger = /*#__PURE__*/(0, _react.forwardRef)(({
27
27
  onClick,
28
28
  isOpen,
@@ -31,6 +31,7 @@ const DefaultTriggerContent = function ({
31
31
  });
32
32
  }
33
33
  const triggerContent = getGenericTriggerContent(selectedItem, options);
34
+ const key = selectedItem?.key;
34
35
  if (triggerContent) {
35
36
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
36
37
  className: "selected-item-details",
@@ -38,7 +39,7 @@ const DefaultTriggerContent = function ({
38
39
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
39
40
  children: triggerContent
40
41
  })
41
- })
42
+ }, key)
42
43
  });
43
44
  }
44
45
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_truncateWithTooltip.TruncateWithTooltip, {
@@ -46,7 +47,7 @@ const DefaultTriggerContent = function ({
46
47
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
47
48
  children: defaultTriggerText
48
49
  })
49
- });
50
+ }, key);
50
51
  };
51
52
  function getGenericTriggerContent(selectedItem, options) {
52
53
  const selectedOptions = options.filter(option => option.isChecked).map(option => option.title);
@@ -76,11 +76,16 @@ export type TypeaheadProps = {
76
76
  optionalLabelText?: string;
77
77
  autoFocus?: boolean;
78
78
  noItemsText?: string;
79
+ /**
80
+ * By default, on select won't be invoked if the label of selected option is the same as defaultValue
81
+ * but there are cases when we do want to call it anyway. In that cases this prop should be set to true
82
+ */
83
+ shouldCallOnSelectWithOldValue?: boolean;
79
84
  };
80
85
  /** Searchable select
81
86
  * [CAPITALIZATION] Use sentence case for options, label, and input text. Do not end with ellipses (...).
82
87
  * @midnight-gray-supported
83
88
  * @alpine-light-supported
84
89
  */
85
- declare function Typeahead({ defaultValue, onSearch, optionComponent, OptionList, onBlur, onKeyDown, onClear, onSelect, onDelete, searchFields, placement, options, items, optionId, optionLabel, isMultiSelect, focused, isTouched, forceShowAllOnFocus, showAllOnFocus, isDisabled, disabledInfo, isRequired, isOptional, isClearable, optionalLabelText, handleFocus, placeholder, containerRef, inputRef: inputRefProp, helperTextPosition, testId, id, label, labelTestId, ariaLabel, validity, validationTestId, asyncValidation, labelIcon, labelIconTooltipText, labelIconTestId, dropdownContentClass, wrapperClass, fieldClass, helperText, autoComplete, keepInvalidText, formatSearchValue, className, autoFocus, noItemsText, }: TypeaheadProps): import("react/jsx-runtime").JSX.Element;
90
+ declare function Typeahead({ defaultValue, onSearch, optionComponent, OptionList, onBlur, onKeyDown, onClear, onSelect, onDelete, searchFields, placement, options, items, optionId, optionLabel, isMultiSelect, focused, isTouched, forceShowAllOnFocus, showAllOnFocus, isDisabled, disabledInfo, isRequired, isOptional, isClearable, optionalLabelText, handleFocus, placeholder, containerRef, inputRef: inputRefProp, helperTextPosition, testId, id, label, labelTestId, ariaLabel, validity, validationTestId, asyncValidation, labelIcon, labelIconTooltipText, labelIconTestId, dropdownContentClass, wrapperClass, fieldClass, helperText, autoComplete, keepInvalidText, formatSearchValue, className, autoFocus, noItemsText, shouldCallOnSelectWithOldValue, }: TypeaheadProps): import("react/jsx-runtime").JSX.Element;
86
91
  export default Typeahead;
@@ -80,7 +80,8 @@ function Typeahead({
80
80
  formatSearchValue,
81
81
  className,
82
82
  autoFocus = false,
83
- noItemsText
83
+ noItemsText,
84
+ shouldCallOnSelectWithOldValue = false
84
85
  }) {
85
86
  const {
86
87
  t
@@ -125,7 +126,7 @@ function Typeahead({
125
126
  }
126
127
  if (isMultiSelect) {
127
128
  onSelect(option);
128
- } else if (String(option?.[optionLabel]) !== defaultValue) {
129
+ } else if (String(option?.[optionLabel]) !== defaultValue || shouldCallOnSelectWithOldValue) {
129
130
  onSelect(option);
130
131
  }
131
132
  setIsTouched(true);
@@ -3,6 +3,7 @@ import { IconProp } from '@fortawesome/fontawesome-svg-core';
3
3
  import { TooltipPlacementsType } from '../tooltip';
4
4
  import './dropdown-item-title.less';
5
5
  export type DropdownItemTitleOption = {
6
+ key: string | number;
6
7
  iconClass?: string;
7
8
  icon?: IconProp;
8
9
  title?: ReactNode;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { createElement as _createElement } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { faChevronRight } from '@fortawesome/free-solid-svg-icons/faChevronRight';
4
4
  import { FontAwesomeIcon } from '../font-awesome-icon';
@@ -18,7 +18,8 @@ const DropdownItemTitle = ({
18
18
  tooltipPlacement,
19
19
  tooltipText,
20
20
  tooltipDocsLink,
21
- tooltipTestId
21
+ tooltipTestId,
22
+ key
22
23
  } = option;
23
24
  const props = {
24
25
  tooltipText,
@@ -52,14 +53,14 @@ const DropdownItemTitle = ({
52
53
  })
53
54
  });
54
55
  const withTruncatableText = /*#__PURE__*/_jsxs(_Fragment, {
55
- children: [/*#__PURE__*/_jsx(TruncateWithTooltip, {
56
+ children: [/*#__PURE__*/_createElement(TruncateWithTooltip, {
56
57
  ...props,
57
- children: itemTitle
58
- }), subtext && /*#__PURE__*/_jsx(TruncateWithTooltip, {
58
+ key: key
59
+ }, itemTitle), subtext && /*#__PURE__*/_createElement(TruncateWithTooltip, {
59
60
  ...props,
60
61
  tooltipTestId: `${tooltipTestId}-subtext`,
61
- children: itemSubText
62
- })]
62
+ key: `${key}-subtext`
63
+ }, itemSubText)]
63
64
  });
64
65
  return /*#__PURE__*/_jsx("div", {
65
66
  className: classnames('drop-item-content-wrap', {
@@ -14,7 +14,7 @@ const DefaultTriggerContent = ({
14
14
  children: /*#__PURE__*/_jsx("span", {
15
15
  children: selectedItem?.title ?? defaultTriggerText
16
16
  })
17
- });
17
+ }, selectedItem?.key ?? 0);
18
18
  const DropdownMenuTrigger = /*#__PURE__*/forwardRef(({
19
19
  onClick,
20
20
  isOpen,
@@ -23,6 +23,7 @@ const DefaultTriggerContent = function ({
23
23
  });
24
24
  }
25
25
  const triggerContent = getGenericTriggerContent(selectedItem, options);
26
+ const key = selectedItem?.key;
26
27
  if (triggerContent) {
27
28
  return /*#__PURE__*/_jsx("span", {
28
29
  className: "selected-item-details",
@@ -30,7 +31,7 @@ const DefaultTriggerContent = function ({
30
31
  children: /*#__PURE__*/_jsx("span", {
31
32
  children: triggerContent
32
33
  })
33
- })
34
+ }, key)
34
35
  });
35
36
  }
36
37
  return /*#__PURE__*/_jsx(TruncateWithTooltip, {
@@ -38,7 +39,7 @@ const DefaultTriggerContent = function ({
38
39
  children: /*#__PURE__*/_jsx("span", {
39
40
  children: defaultTriggerText
40
41
  })
41
- });
42
+ }, key);
42
43
  };
43
44
  function getGenericTriggerContent(selectedItem, options) {
44
45
  const selectedOptions = options.filter(option => option.isChecked).map(option => option.title);
@@ -76,11 +76,16 @@ export type TypeaheadProps = {
76
76
  optionalLabelText?: string;
77
77
  autoFocus?: boolean;
78
78
  noItemsText?: string;
79
+ /**
80
+ * By default, on select won't be invoked if the label of selected option is the same as defaultValue
81
+ * but there are cases when we do want to call it anyway. In that cases this prop should be set to true
82
+ */
83
+ shouldCallOnSelectWithOldValue?: boolean;
79
84
  };
80
85
  /** Searchable select
81
86
  * [CAPITALIZATION] Use sentence case for options, label, and input text. Do not end with ellipses (...).
82
87
  * @midnight-gray-supported
83
88
  * @alpine-light-supported
84
89
  */
85
- declare function Typeahead({ defaultValue, onSearch, optionComponent, OptionList, onBlur, onKeyDown, onClear, onSelect, onDelete, searchFields, placement, options, items, optionId, optionLabel, isMultiSelect, focused, isTouched, forceShowAllOnFocus, showAllOnFocus, isDisabled, disabledInfo, isRequired, isOptional, isClearable, optionalLabelText, handleFocus, placeholder, containerRef, inputRef: inputRefProp, helperTextPosition, testId, id, label, labelTestId, ariaLabel, validity, validationTestId, asyncValidation, labelIcon, labelIconTooltipText, labelIconTestId, dropdownContentClass, wrapperClass, fieldClass, helperText, autoComplete, keepInvalidText, formatSearchValue, className, autoFocus, noItemsText, }: TypeaheadProps): import("react/jsx-runtime").JSX.Element;
90
+ declare function Typeahead({ defaultValue, onSearch, optionComponent, OptionList, onBlur, onKeyDown, onClear, onSelect, onDelete, searchFields, placement, options, items, optionId, optionLabel, isMultiSelect, focused, isTouched, forceShowAllOnFocus, showAllOnFocus, isDisabled, disabledInfo, isRequired, isOptional, isClearable, optionalLabelText, handleFocus, placeholder, containerRef, inputRef: inputRefProp, helperTextPosition, testId, id, label, labelTestId, ariaLabel, validity, validationTestId, asyncValidation, labelIcon, labelIconTooltipText, labelIconTestId, dropdownContentClass, wrapperClass, fieldClass, helperText, autoComplete, keepInvalidText, formatSearchValue, className, autoFocus, noItemsText, shouldCallOnSelectWithOldValue, }: TypeaheadProps): import("react/jsx-runtime").JSX.Element;
86
91
  export default Typeahead;
@@ -72,7 +72,8 @@ function Typeahead({
72
72
  formatSearchValue,
73
73
  className,
74
74
  autoFocus = false,
75
- noItemsText
75
+ noItemsText,
76
+ shouldCallOnSelectWithOldValue = false
76
77
  }) {
77
78
  const {
78
79
  t
@@ -117,7 +118,7 @@ function Typeahead({
117
118
  }
118
119
  if (isMultiSelect) {
119
120
  onSelect(option);
120
- } else if (String(option?.[optionLabel]) !== defaultValue) {
121
+ } else if (String(option?.[optionLabel]) !== defaultValue || shouldCallOnSelectWithOldValue) {
121
122
  onSelect(option);
122
123
  }
123
124
  setIsTouched(true);
@@ -50824,7 +50824,8 @@ var DropdownItemTitle = function DropdownItemTitle(_ref) {
50824
50824
  tooltipPlacement = option.tooltipPlacement,
50825
50825
  tooltipText = option.tooltipText,
50826
50826
  tooltipDocsLink = option.tooltipDocsLink,
50827
- tooltipTestId = option.tooltipTestId;
50827
+ tooltipTestId = option.tooltipTestId,
50828
+ key = option.key;
50828
50829
  var props = {
50829
50830
  tooltipText: tooltipText,
50830
50831
  tooltipPlacement: tooltipPlacement || _tooltip__WEBPACK_IMPORTED_MODULE_5__.TOOLTIP_PLACEMENT_TYPES.RIGHT,
@@ -50852,8 +50853,11 @@ var DropdownItemTitle = function DropdownItemTitle(_ref) {
50852
50853
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
50853
50854
  className: "menu-item-subtext"
50854
50855
  }, subtext));
50855
- var withTruncatableText = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_truncate_with_tooltip__WEBPACK_IMPORTED_MODULE_4__.TruncateWithTooltip, props, itemTitle), subtext && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_truncate_with_tooltip__WEBPACK_IMPORTED_MODULE_4__.TruncateWithTooltip, _extends({}, props, {
50856
- tooltipTestId: "".concat(tooltipTestId, "-subtext")
50856
+ var withTruncatableText = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_truncate_with_tooltip__WEBPACK_IMPORTED_MODULE_4__.TruncateWithTooltip, _extends({}, props, {
50857
+ key: key
50858
+ }), itemTitle), subtext && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_truncate_with_tooltip__WEBPACK_IMPORTED_MODULE_4__.TruncateWithTooltip, _extends({}, props, {
50859
+ tooltipTestId: "".concat(tooltipTestId, "-subtext"),
50860
+ key: "".concat(key, "-subtext")
50857
50861
  }), itemSubText));
50858
50862
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
50859
50863
  className: classnames__WEBPACK_IMPORTED_MODULE_1___default()('drop-item-content-wrap', {
@@ -51541,10 +51545,12 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
51541
51545
 
51542
51546
 
51543
51547
  var DefaultTriggerContent = function DefaultTriggerContent(_ref) {
51544
- var _selectedItem$title;
51548
+ var _selectedItem$key, _selectedItem$title;
51545
51549
  var selectedItem = _ref.selectedItem,
51546
51550
  defaultTriggerText = _ref.defaultTriggerText;
51547
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_truncate_with_tooltip__WEBPACK_IMPORTED_MODULE_4__.TruncateWithTooltip, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", null, (_selectedItem$title = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.title) !== null && _selectedItem$title !== void 0 ? _selectedItem$title : defaultTriggerText));
51551
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_truncate_with_tooltip__WEBPACK_IMPORTED_MODULE_4__.TruncateWithTooltip, {
51552
+ key: (_selectedItem$key = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.key) !== null && _selectedItem$key !== void 0 ? _selectedItem$key : 0
51553
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", null, (_selectedItem$title = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.title) !== null && _selectedItem$title !== void 0 ? _selectedItem$title : defaultTriggerText));
51548
51554
  };
51549
51555
  var DropdownMenuTrigger = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function (_ref2, ref) {
51550
51556
  var onClick = _ref2.onClick,
@@ -52186,13 +52192,17 @@ var DefaultTriggerContent = function DefaultTriggerContent(_ref) {
52186
52192
  });
52187
52193
  }
52188
52194
  var triggerContent = getGenericTriggerContent(selectedItem, options);
52195
+ var key = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.key;
52189
52196
  if (triggerContent) {
52190
52197
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
52191
52198
  className: "selected-item-details"
52192
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_truncate_with_tooltip__WEBPACK_IMPORTED_MODULE_5__.TruncateWithTooltip, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", null, triggerContent)));
52199
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_truncate_with_tooltip__WEBPACK_IMPORTED_MODULE_5__.TruncateWithTooltip, {
52200
+ key: key
52201
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", null, triggerContent)));
52193
52202
  }
52194
52203
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_truncate_with_tooltip__WEBPACK_IMPORTED_MODULE_5__.TruncateWithTooltip, {
52195
- className: "placeholder"
52204
+ className: "placeholder",
52205
+ key: key
52196
52206
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", null, defaultTriggerText));
52197
52207
  };
52198
52208
  function getGenericTriggerContent(selectedItem, options) {
@@ -86219,7 +86229,9 @@ function Typeahead(_ref) {
86219
86229
  className = _ref.className,
86220
86230
  _ref$autoFocus = _ref.autoFocus,
86221
86231
  autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
86222
- noItemsText = _ref.noItemsText;
86232
+ noItemsText = _ref.noItemsText,
86233
+ _ref$shouldCallOnSele = _ref.shouldCallOnSelectWithOldValue,
86234
+ shouldCallOnSelectWithOldValue = _ref$shouldCallOnSele === void 0 ? false : _ref$shouldCallOnSele;
86223
86235
  var _useTranslation = (0,_hooks_use_translation__WEBPACK_IMPORTED_MODULE_10__.useTranslation)(),
86224
86236
  t = _useTranslation.t;
86225
86237
  var listId = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
@@ -86290,7 +86302,7 @@ function Typeahead(_ref) {
86290
86302
  }
86291
86303
  if (isMultiSelect) {
86292
86304
  onSelect(option);
86293
- } else if (String(option === null || option === void 0 ? void 0 : option[optionLabel]) !== defaultValue) {
86305
+ } else if (String(option === null || option === void 0 ? void 0 : option[optionLabel]) !== defaultValue || shouldCallOnSelectWithOldValue) {
86294
86306
  onSelect(option);
86295
86307
  }
86296
86308
  setIsTouched(true);