@datarobot/design-system 30.1.1 → 30.1.3

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.
@@ -21,7 +21,16 @@ const Markdown = ({
21
21
  const {
22
22
  t
23
23
  } = (0, _useTranslation.useTranslation)();
24
+ const clearPrevChildrenState = () => {
25
+ if (error) {
26
+ setError('');
27
+ }
28
+ if (html) {
29
+ setHtml('');
30
+ }
31
+ };
24
32
  (0, _react.useEffect)(() => {
33
+ clearPrevChildrenState();
25
34
  Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "unified" */'unified'))), Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "remark-gfm" */'remark-gfm'))), Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "remark-parse" */'remark-parse'))), Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "remark-rehype" */'remark-rehype'))), Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "rehype-sanitize" */'rehype-sanitize'))), Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "rehype-stringify" */'rehype-stringify'))), Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "rehype-highlight" */'rehype-highlight'))), Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "rehype-katex" */'rehype-katex'))), Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "remark-math" */'remark-math')))]).then(([{
26
35
  unified
27
36
  }, {
@@ -55,7 +64,7 @@ const Markdown = ({
55
64
  }).catch(err => {
56
65
  setError(err);
57
66
  });
58
- }, []);
67
+ }, [children]);
59
68
  if (error) {
60
69
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_message.Message, {
61
70
  type: _message.MESSAGE_TYPES.ERROR,
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { SidebarCardProps } from './types';
2
3
  import './sidebar-card.less';
3
4
  /** A SidebarCards: Card
@@ -6,4 +7,5 @@ import './sidebar-card.less';
6
7
  * @midnight-gray-supported
7
8
  * @alpine-light-supported
8
9
  * */
9
- export default function SidebarCard({ testId, id, isDisabled, isSelected, isReadOnly, hasCheckbox, isChecked, leftItem, checkboxTooltip, isCheckboxDisabled, title, titleTooltip, headerContentLeft, headerContentRight, content, onCheckboxSelect, className, shouldSelectTileOnEnter, ...other }: SidebarCardProps): import("react/jsx-runtime").JSX.Element;
10
+ declare const SidebarCard: React.ForwardRefExoticComponent<SidebarCardProps & React.RefAttributes<HTMLDivElement>>;
11
+ export default SidebarCard;
@@ -3,21 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = SidebarCard;
7
- var _react = _interopRequireDefault(require("react"));
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _sidebarCardHeader = _interopRequireDefault(require("./sidebar-card-header"));
10
10
  var _sidebarCardContent = _interopRequireDefault(require("./sidebar-card-content"));
11
11
  var _hooks = require("../hooks");
12
12
  var _jsxRuntime = require("react/jsx-runtime");
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ 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); }
14
15
  /** A SidebarCards: Card
15
16
  * with optional customized header and footer
16
17
  * @uxr-only-supported
17
18
  * @midnight-gray-supported
18
19
  * @alpine-light-supported
19
20
  * */
20
- function SidebarCard({
21
+ const SidebarCard = /*#__PURE__*/_react.default.forwardRef(function SidebarCard({
21
22
  testId = 'sidebar-card',
22
23
  id,
23
24
  isDisabled = false,
@@ -37,10 +38,10 @@ function SidebarCard({
37
38
  className = '',
38
39
  shouldSelectTileOnEnter,
39
40
  ...other
40
- }) {
41
+ }, forwardedRef) {
41
42
  const {
42
43
  listItemAttrs,
43
- ref
44
+ ref: listItemRef
44
45
  } = (0, _hooks.useListItemNavigation)({
45
46
  id,
46
47
  isSelected,
@@ -55,6 +56,11 @@ function SidebarCard({
55
56
  }
56
57
  }
57
58
  });
59
+ const [setForwardedRef] = (0, _hooks.useForwardRef)(forwardedRef);
60
+ const mergedRef = (0, _react.useCallback)(el => {
61
+ listItemRef(el);
62
+ setForwardedRef(el);
63
+ }, [listItemRef, setForwardedRef]);
58
64
  return (
59
65
  /*#__PURE__*/
60
66
  // useListItemNavigation returns onKeyDown, role and tabIndex
@@ -67,7 +73,7 @@ function SidebarCard({
67
73
  }),
68
74
  ...other,
69
75
  ...listItemAttrs,
70
- ref: ref,
76
+ ref: mergedRef,
71
77
  children: [leftItem, /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
72
78
  className: "sidebar-card-content-section",
73
79
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarCardHeader.default, {
@@ -90,4 +96,5 @@ function SidebarCard({
90
96
  })]
91
97
  })
92
98
  );
93
- }
99
+ });
100
+ var _default = exports.default = SidebarCard;
@@ -47,6 +47,7 @@ function SidebarCards({
47
47
  const isSelected = Boolean(item.isSelected);
48
48
  const isCheckboxDisabled = Boolean(item.isCheckboxDisabled ?? isDisabled);
49
49
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarCard.default, {
50
+ ref: item.ref,
50
51
  id: item.id,
51
52
  leftItem: item.leftItem,
52
53
  testId: itemTestId,
@@ -65,6 +65,8 @@ export type SidebarCardItemProps = {
65
65
  className?: string;
66
66
  /** Defines if left item should be added */
67
67
  leftItem?: React.ReactNode | null;
68
+ /** Optional ref to attach to the card's root element */
69
+ ref?: React.Ref<HTMLDivElement>;
68
70
  };
69
71
  export type SidebarCardProps = {
70
72
  /** Test id */
@@ -13,7 +13,16 @@ const Markdown = ({
13
13
  const {
14
14
  t
15
15
  } = useTranslation();
16
+ const clearPrevChildrenState = () => {
17
+ if (error) {
18
+ setError('');
19
+ }
20
+ if (html) {
21
+ setHtml('');
22
+ }
23
+ };
16
24
  useEffect(() => {
25
+ clearPrevChildrenState();
17
26
  Promise.all([import(/* webpackChunkName: "unified" */'unified'), import(/* webpackChunkName: "remark-gfm" */'remark-gfm'), import(/* webpackChunkName: "remark-parse" */'remark-parse'), import(/* webpackChunkName: "remark-rehype" */'remark-rehype'), import(/* webpackChunkName: "rehype-sanitize" */'rehype-sanitize'), import(/* webpackChunkName: "rehype-stringify" */'rehype-stringify'), import(/* webpackChunkName: "rehype-highlight" */'rehype-highlight'), import(/* webpackChunkName: "rehype-katex" */'rehype-katex'), import(/* webpackChunkName: "remark-math" */'remark-math')]).then(([{
18
27
  unified
19
28
  }, {
@@ -47,7 +56,7 @@ const Markdown = ({
47
56
  }).catch(err => {
48
57
  setError(err);
49
58
  });
50
- }, []);
59
+ }, [children]);
51
60
  if (error) {
52
61
  return /*#__PURE__*/_jsx(Message, {
53
62
  type: MESSAGE_TYPES.ERROR,
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { SidebarCardProps } from './types';
2
3
  import './sidebar-card.less';
3
4
  /** A SidebarCards: Card
@@ -6,4 +7,5 @@ import './sidebar-card.less';
6
7
  * @midnight-gray-supported
7
8
  * @alpine-light-supported
8
9
  * */
9
- export default function SidebarCard({ testId, id, isDisabled, isSelected, isReadOnly, hasCheckbox, isChecked, leftItem, checkboxTooltip, isCheckboxDisabled, title, titleTooltip, headerContentLeft, headerContentRight, content, onCheckboxSelect, className, shouldSelectTileOnEnter, ...other }: SidebarCardProps): import("react/jsx-runtime").JSX.Element;
10
+ declare const SidebarCard: React.ForwardRefExoticComponent<SidebarCardProps & React.RefAttributes<HTMLDivElement>>;
11
+ export default SidebarCard;
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import SidebarCardHeader from './sidebar-card-header';
4
4
  import SidebarCardContent from './sidebar-card-content';
5
- import { useListItemNavigation } from '../hooks';
5
+ import { useListItemNavigation, useForwardRef } from '../hooks';
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  /** A SidebarCards: Card
8
8
  * with optional customized header and footer
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  * @midnight-gray-supported
11
11
  * @alpine-light-supported
12
12
  * */
13
- export default function SidebarCard({
13
+ const SidebarCard = /*#__PURE__*/React.forwardRef(function SidebarCard({
14
14
  testId = 'sidebar-card',
15
15
  id,
16
16
  isDisabled = false,
@@ -30,10 +30,10 @@ export default function SidebarCard({
30
30
  className = '',
31
31
  shouldSelectTileOnEnter,
32
32
  ...other
33
- }) {
33
+ }, forwardedRef) {
34
34
  const {
35
35
  listItemAttrs,
36
- ref
36
+ ref: listItemRef
37
37
  } = useListItemNavigation({
38
38
  id,
39
39
  isSelected,
@@ -48,6 +48,11 @@ export default function SidebarCard({
48
48
  }
49
49
  }
50
50
  });
51
+ const [setForwardedRef] = useForwardRef(forwardedRef);
52
+ const mergedRef = useCallback(el => {
53
+ listItemRef(el);
54
+ setForwardedRef(el);
55
+ }, [listItemRef, setForwardedRef]);
51
56
  return (
52
57
  /*#__PURE__*/
53
58
  // useListItemNavigation returns onKeyDown, role and tabIndex
@@ -60,7 +65,7 @@ export default function SidebarCard({
60
65
  }),
61
66
  ...other,
62
67
  ...listItemAttrs,
63
- ref: ref,
68
+ ref: mergedRef,
64
69
  children: [leftItem, /*#__PURE__*/_jsxs("div", {
65
70
  className: "sidebar-card-content-section",
66
71
  children: [/*#__PURE__*/_jsx(SidebarCardHeader, {
@@ -83,4 +88,5 @@ export default function SidebarCard({
83
88
  })]
84
89
  })
85
90
  );
86
- }
91
+ });
92
+ export default SidebarCard;
@@ -39,6 +39,7 @@ export default function SidebarCards({
39
39
  const isSelected = Boolean(item.isSelected);
40
40
  const isCheckboxDisabled = Boolean(item.isCheckboxDisabled ?? isDisabled);
41
41
  return /*#__PURE__*/_jsx(SidebarCard, {
42
+ ref: item.ref,
42
43
  id: item.id,
43
44
  leftItem: item.leftItem,
44
45
  testId: itemTestId,
@@ -65,6 +65,8 @@ export type SidebarCardItemProps = {
65
65
  className?: string;
66
66
  /** Defines if left item should be added */
67
67
  leftItem?: React.ReactNode | null;
68
+ /** Optional ref to attach to the card's root element */
69
+ ref?: React.Ref<HTMLDivElement>;
68
70
  };
69
71
  export type SidebarCardProps = {
70
72
  /** Test id */
@@ -69502,7 +69502,16 @@ var Markdown = function Markdown(_ref) {
69502
69502
  setError = _useState4[1];
69503
69503
  var _useTranslation = (0,_hooks_use_translation__WEBPACK_IMPORTED_MODULE_4__.useTranslation)(),
69504
69504
  t = _useTranslation.t;
69505
+ var clearPrevChildrenState = function clearPrevChildrenState() {
69506
+ if (error) {
69507
+ setError('');
69508
+ }
69509
+ if (html) {
69510
+ setHtml('');
69511
+ }
69512
+ };
69505
69513
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
69514
+ clearPrevChildrenState();
69506
69515
  Promise.all([Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! unified */ "unified", 23)), Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! remark-gfm */ "remark-gfm", 23)), Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! remark-parse */ "remark-parse", 23)), Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! remark-rehype */ "remark-rehype", 23)), Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! rehype-sanitize */ "rehype-sanitize", 23)), Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! rehype-stringify */ "rehype-stringify", 23)), Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! rehype-highlight */ "rehype-highlight", 23)), Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! rehype-katex */ "rehype-katex", 23)), Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! remark-math */ "remark-math", 23))]).then(function (_ref2) {
69507
69516
  var _ref3 = _slicedToArray(_ref2, 9),
69508
69517
  unified = _ref3[0].unified,
@@ -69528,7 +69537,7 @@ var Markdown = function Markdown(_ref) {
69528
69537
  })["catch"](function (err) {
69529
69538
  setError(err);
69530
69539
  });
69531
- }, []);
69540
+ }, [children]);
69532
69541
  if (error) {
69533
69542
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_message__WEBPACK_IMPORTED_MODULE_2__.Message, {
69534
69543
  type: _message__WEBPACK_IMPORTED_MODULE_2__.MESSAGE_TYPES.ERROR
@@ -75248,7 +75257,7 @@ var SidebarCardHeader = function SidebarCardHeader(_ref) {
75248
75257
 
75249
75258
  "use strict";
75250
75259
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
75251
- /* harmony export */ "default": () => (/* binding */ SidebarCard)
75260
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
75252
75261
  /* harmony export */ });
75253
75262
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
75254
75263
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
@@ -75261,6 +75270,12 @@ var SidebarCardHeader = function SidebarCardHeader(_ref) {
75261
75270
  /* harmony import */ var _sidebar_card_less__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_sidebar_card_less__WEBPACK_IMPORTED_MODULE_5__);
75262
75271
  var _excluded = ["testId", "id", "isDisabled", "isSelected", "isReadOnly", "hasCheckbox", "isChecked", "leftItem", "checkboxTooltip", "isCheckboxDisabled", "title", "titleTooltip", "headerContentLeft", "headerContentRight", "content", "onCheckboxSelect", "className", "shouldSelectTileOnEnter"];
75263
75272
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
75273
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
75274
+ 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."); }
75275
+ 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; } }
75276
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
75277
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
75278
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
75264
75279
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
75265
75280
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
75266
75281
 
@@ -75276,7 +75291,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
75276
75291
  * @midnight-gray-supported
75277
75292
  * @alpine-light-supported
75278
75293
  * */
75279
- function SidebarCard(_ref) {
75294
+ var SidebarCard = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef(function SidebarCard(_ref, forwardedRef) {
75280
75295
  var _ref$testId = _ref.testId,
75281
75296
  testId = _ref$testId === void 0 ? 'sidebar-card' : _ref$testId,
75282
75297
  id = _ref.id,
@@ -75320,7 +75335,14 @@ function SidebarCard(_ref) {
75320
75335
  }
75321
75336
  }),
75322
75337
  listItemAttrs = _useListItemNavigatio.listItemAttrs,
75323
- ref = _useListItemNavigatio.ref;
75338
+ listItemRef = _useListItemNavigatio.ref;
75339
+ var _useForwardRef = (0,_hooks__WEBPACK_IMPORTED_MODULE_4__.useForwardRef)(forwardedRef),
75340
+ _useForwardRef2 = _slicedToArray(_useForwardRef, 1),
75341
+ setForwardedRef = _useForwardRef2[0];
75342
+ var mergedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (el) {
75343
+ listItemRef(el);
75344
+ setForwardedRef(el);
75345
+ }, [listItemRef, setForwardedRef]);
75324
75346
  return (
75325
75347
  /*#__PURE__*/
75326
75348
  // useListItemNavigation returns onKeyDown, role and tabIndex
@@ -75332,7 +75354,7 @@ function SidebarCard(_ref) {
75332
75354
  'is-selected-card': isSelected
75333
75355
  })
75334
75356
  }, other, listItemAttrs, {
75335
- ref: ref
75357
+ ref: mergedRef
75336
75358
  }), leftItem, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
75337
75359
  className: "sidebar-card-content-section"
75338
75360
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_sidebar_card_header__WEBPACK_IMPORTED_MODULE_2__["default"], {
@@ -75353,7 +75375,8 @@ function SidebarCard(_ref) {
75353
75375
  content: content
75354
75376
  })))
75355
75377
  );
75356
- }
75378
+ });
75379
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SidebarCard);
75357
75380
 
75358
75381
  /***/ }),
75359
75382
 
@@ -75420,6 +75443,7 @@ function SidebarCards(_ref) {
75420
75443
  var isCheckboxDisabled = Boolean((_item$isCheckboxDisab = item.isCheckboxDisabled) !== null && _item$isCheckboxDisab !== void 0 ? _item$isCheckboxDisab : isDisabled);
75421
75444
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_sidebar_card__WEBPACK_IMPORTED_MODULE_3__["default"], {
75422
75445
  key: item.id,
75446
+ ref: item.ref,
75423
75447
  id: item.id,
75424
75448
  leftItem: item.leftItem,
75425
75449
  testId: itemTestId,