@datarobot/design-system 29.2.1 → 29.4.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.
@@ -12,7 +12,7 @@ export type ChildrenWrapperTypes = {
12
12
  export type PopperDropdownWrapperChildren = ((props: ChildrenWrapperTypes) => ReactNode) | ReactNode;
13
13
  export type PopperDropdownWrapperProps = {
14
14
  children: PopperDropdownWrapperChildren;
15
- closeDropdown: () => void;
15
+ closeDropdown: (e?: Event) => void;
16
16
  anchorRef?: AnchorEl;
17
17
  open: boolean;
18
18
  openedWithKeyboard?: boolean;
@@ -20,7 +20,7 @@ function useInnerStateFallback(onExternalStateUpdate, externalState, decoratorFn
20
20
  const onChangeState = fn => {
21
21
  // we are setting innerState and outer externalState as the same object "nextData"
22
22
  // it means that their links should be equal. If their links are not equal, it means externalState was altered by the user
23
- // thus expandedRows should take precedence over inner expandedState that has fallen behind
23
+ // thus external state should take precedence over inner state that has fallen behind
24
24
  const currentState = externalState && externalState !== innerState ? externalState : innerState;
25
25
  const nextData = typeof fn === 'function' ? fn(currentState) : fn;
26
26
  const nextDecoratedData = decoratorFn(nextData);
@@ -208,7 +208,7 @@ function Typeahead({
208
208
  const showClearButton = isClearable && searchValue !== '' && !isDisabled;
209
209
  const handleClickElsewhere = (0, _react.useCallback)(event => {
210
210
  // Handle focus to false if the click is outside of the typeahead container
211
- if (!anchorRef.current?.contains(event.target)) {
211
+ if (!anchorRef.current?.contains(event?.target)) {
212
212
  if (isFocus || isMultiSelect) {
213
213
  inputRef.current?.blur();
214
214
  handleExit();
@@ -251,7 +251,9 @@ function Typeahead({
251
251
  }, [defaultValue]);
252
252
  (0, _react.useEffect)(() => setIsTouched(isTouched), [isTouched]);
253
253
  const PopperWrapper = (0, _react.useMemo)(() => /*#__PURE__*/(0, _jsxRuntime.jsx)(_dropdown.PopperDropdownWrapper, {
254
- closeDropdown: closeDropdown,
254
+ closeDropdown: e => {
255
+ handleClickElsewhere(e);
256
+ },
255
257
  anchorRef: anchorRef.current,
256
258
  open: isOpen,
257
259
  contentClassName: (0, _classnames.default)('typeahead-dropdown-content', dropdownContentClass),
@@ -275,7 +277,7 @@ function Typeahead({
275
277
  listId: listId,
276
278
  noItemsText: noItemsText
277
279
  })
278
- }), [isOpen, width, searchValue, options, isShowAll]);
280
+ }), [isOpen, width, searchValue, options, isShowAll, handleClickElsewhere]);
279
281
  const {
280
282
  isShowOptions
281
283
  } = (0, _useVisibleOptions.useVisibleOptions)({
@@ -12,7 +12,7 @@ export type ChildrenWrapperTypes = {
12
12
  export type PopperDropdownWrapperChildren = ((props: ChildrenWrapperTypes) => ReactNode) | ReactNode;
13
13
  export type PopperDropdownWrapperProps = {
14
14
  children: PopperDropdownWrapperChildren;
15
- closeDropdown: () => void;
15
+ closeDropdown: (e?: Event) => void;
16
16
  anchorRef?: AnchorEl;
17
17
  open: boolean;
18
18
  openedWithKeyboard?: boolean;
@@ -14,7 +14,7 @@ export function useInnerStateFallback(onExternalStateUpdate, externalState, deco
14
14
  const onChangeState = fn => {
15
15
  // we are setting innerState and outer externalState as the same object "nextData"
16
16
  // it means that their links should be equal. If their links are not equal, it means externalState was altered by the user
17
- // thus expandedRows should take precedence over inner expandedState that has fallen behind
17
+ // thus external state should take precedence over inner state that has fallen behind
18
18
  const currentState = externalState && externalState !== innerState ? externalState : innerState;
19
19
  const nextData = typeof fn === 'function' ? fn(currentState) : fn;
20
20
  const nextDecoratedData = decoratorFn(nextData);
@@ -200,7 +200,7 @@ function Typeahead({
200
200
  const showClearButton = isClearable && searchValue !== '' && !isDisabled;
201
201
  const handleClickElsewhere = useCallback(event => {
202
202
  // Handle focus to false if the click is outside of the typeahead container
203
- if (!anchorRef.current?.contains(event.target)) {
203
+ if (!anchorRef.current?.contains(event?.target)) {
204
204
  if (isFocus || isMultiSelect) {
205
205
  inputRef.current?.blur();
206
206
  handleExit();
@@ -243,7 +243,9 @@ function Typeahead({
243
243
  }, [defaultValue]);
244
244
  useEffect(() => setIsTouched(isTouched), [isTouched]);
245
245
  const PopperWrapper = useMemo(() => /*#__PURE__*/_jsx(PopperDropdownWrapper, {
246
- closeDropdown: closeDropdown,
246
+ closeDropdown: e => {
247
+ handleClickElsewhere(e);
248
+ },
247
249
  anchorRef: anchorRef.current,
248
250
  open: isOpen,
249
251
  contentClassName: classNames('typeahead-dropdown-content', dropdownContentClass),
@@ -267,7 +269,7 @@ function Typeahead({
267
269
  listId: listId,
268
270
  noItemsText: noItemsText
269
271
  })
270
- }), [isOpen, width, searchValue, options, isShowAll]);
272
+ }), [isOpen, width, searchValue, options, isShowAll, handleClickElsewhere]);
271
273
  const {
272
274
  isShowOptions
273
275
  } = useVisibleOptions({
@@ -78498,7 +78498,7 @@ function useInnerStateFallback(onExternalStateUpdate, externalState) {
78498
78498
  var onChangeState = function onChangeState(fn) {
78499
78499
  // we are setting innerState and outer externalState as the same object "nextData"
78500
78500
  // it means that their links should be equal. If their links are not equal, it means externalState was altered by the user
78501
- // thus expandedRows should take precedence over inner expandedState that has fallen behind
78501
+ // thus external state should take precedence over inner state that has fallen behind
78502
78502
  var currentState = externalState && externalState !== innerState ? externalState : innerState;
78503
78503
  var nextData = typeof fn === 'function' ? fn(currentState) : fn;
78504
78504
  var nextDecoratedData = decoratorFn(nextData);
@@ -86666,7 +86666,7 @@ function Typeahead(_ref) {
86666
86666
  var handleClickElsewhere = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (event) {
86667
86667
  var _anchorRef$current;
86668
86668
  // Handle focus to false if the click is outside of the typeahead container
86669
- if (!((_anchorRef$current = anchorRef.current) !== null && _anchorRef$current !== void 0 && _anchorRef$current.contains(event.target))) {
86669
+ if (!((_anchorRef$current = anchorRef.current) !== null && _anchorRef$current !== void 0 && _anchorRef$current.contains(event === null || event === void 0 ? void 0 : event.target))) {
86670
86670
  if (isFocus || isMultiSelect) {
86671
86671
  var _inputRef$current;
86672
86672
  (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.blur();
@@ -86715,7 +86715,9 @@ function Typeahead(_ref) {
86715
86715
  }, [isTouched]);
86716
86716
  var PopperWrapper = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
86717
86717
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_dropdown__WEBPACK_IMPORTED_MODULE_2__.PopperDropdownWrapper, {
86718
- closeDropdown: closeDropdown,
86718
+ closeDropdown: function closeDropdown(e) {
86719
+ handleClickElsewhere(e);
86720
+ },
86719
86721
  anchorRef: anchorRef.current,
86720
86722
  open: isOpen,
86721
86723
  contentClassName: classnames__WEBPACK_IMPORTED_MODULE_1___default()('typeahead-dropdown-content', dropdownContentClass),
@@ -86741,7 +86743,7 @@ function Typeahead(_ref) {
86741
86743
  listId: listId,
86742
86744
  noItemsText: noItemsText
86743
86745
  }));
86744
- }, [isOpen, width, searchValue, options, isShowAll]);
86746
+ }, [isOpen, width, searchValue, options, isShowAll, handleClickElsewhere]);
86745
86747
  var _useVisibleOptions = (0,_use_visible_options__WEBPACK_IMPORTED_MODULE_9__.useVisibleOptions)({
86746
86748
  formatSearchValue: formatSearchValue,
86747
86749
  searchValue: searchValue,