@rh-support/react-context 2.1.28 → 2.1.29

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AccountSelectorInternal.d.ts","sourceRoot":"","sources":["../../../../src/components/AccountSelector/AccountSelectorInternal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAgBhF,OAAO,EAAE,kBAAkB,EAA8B,MAAM,wBAAwB,CAAC;AAOxF,UAAU,MAAO,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IACjD,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC7B,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC;IACzC,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAkCD,iBAAS,uBAAuB,CAAC,KAAK,EAAE,MAAM,eAiR7C;kBAjRQ,uBAAuB;;;AAoRhC,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"AccountSelectorInternal.d.ts","sourceRoot":"","sources":["../../../../src/components/AccountSelector/AccountSelectorInternal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAehF,OAAO,EAAE,kBAAkB,EAA8B,MAAM,wBAAwB,CAAC;AAQxF,UAAU,MAAO,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IACjD,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC7B,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC;IACzC,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAkCD,iBAAS,uBAAuB,CAAC,KAAK,EAAE,MAAM,eAmS7C;kBAnSQ,uBAAuB;;;AAsShC,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -8,12 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { accounts } from '@cee-eng/hydrajs';
11
- import { Button, Flex, FlexItem, MenuToggle, Select, SelectList, SelectOption, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
11
+ import { Button, Flex, FlexItem, MenuToggle, Select, SelectOption, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, } from '@patternfly/react-core';
12
12
  import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
13
13
  import TimesCircleIcon from '@patternfly/react-icons/dist/js/icons/times-circle-icon';
14
14
  import { LoadingIndicator, useFetch } from '@rh-support/components';
15
15
  import { isUndefined } from 'lodash';
16
16
  import isEmpty from 'lodash/isEmpty';
17
+ import isNull from 'lodash/isNull';
17
18
  import uniqBy from 'lodash/uniqBy';
18
19
  import React, { useEffect, useMemo, useRef, useState } from 'react';
19
20
  import { Trans, useTranslation } from 'react-i18next';
@@ -80,23 +81,33 @@ function AccountSelectorInternal(props) {
80
81
  setResultSize((pre) => Math.min(pre + pageSize, items.length));
81
82
  setIsOpen(true);
82
83
  };
83
- const dropdownOptions = useMemo(() => [
84
- ...itemsToRender.map((item, index) => (React.createElement(SelectOption, { isFocused: focusedItemIndex === index, key: index, value: item, hasCheckbox: props.multiple, isSelected: selectedItems.some((account) => item.accountNumber === account.accountNumber) }, props.restrictedOnSubscriptionAbuse && item.subscriptionAbuse ? (React.createElement(Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
85
- React.createElement(FlexItem, { className: "form-instructions form-invalid" }, getDisplayName(item)),
86
- React.createElement(FlexItem, { className: "form-instructions form-invalid pf-v5-u-text-nowrap pf-v5-u-pr-sm" },
87
- React.createElement(InfoCircleIcon, null),
88
- " ",
89
- React.createElement(Trans, null, "Subscription abuse")))) : (React.createElement("span", null, getDisplayName(item)))))),
90
- ...(resultSize < items.length
91
- ? [
92
- React.createElement("div", { className: "pf-v5-c-divider", role: "separator", key: "separator" }),
93
- React.createElement(SelectOption, { key: 'diplay-more-option', onClick: onDisplayMoreClick, value: 'display-more' },
94
- React.createElement(Flex, { justifyContent: { default: 'justifyContentCenter' } },
95
- React.createElement(FlexItem, { className: '"pf-v5-c-button pf-m-link pf-m-inline' },
96
- React.createElement(Trans, null, "Display additional results")))),
97
- ]
98
- : []),
99
- ],
84
+ const dropdownOptions = useMemo(() => {
85
+ if (isFetching && isEmpty(itemsToRender)) {
86
+ return (React.createElement(SelectOption, { key: "searching" },
87
+ React.createElement(Trans, null, "Searching...")));
88
+ }
89
+ if (!isEmpty(query) && isEmpty(itemsToRender)) {
90
+ return (React.createElement(SelectOption, { key: "no-results" },
91
+ React.createElement(Trans, null, "No results found")));
92
+ }
93
+ return [
94
+ ...itemsToRender.map((item, index) => (React.createElement(SelectOption, { isFocused: focusedItemIndex === index, key: index, value: item, hasCheckbox: props.multiple, isSelected: selectedItems.some((account) => item.accountNumber === account.accountNumber) }, props.restrictedOnSubscriptionAbuse && item.subscriptionAbuse ? (React.createElement(Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
95
+ React.createElement(FlexItem, { className: "form-instructions form-invalid" }, getDisplayName(item)),
96
+ React.createElement(FlexItem, { className: "form-instructions form-invalid pf-v5-u-text-nowrap pf-v5-u-pr-sm" },
97
+ React.createElement(InfoCircleIcon, null),
98
+ " ",
99
+ React.createElement(Trans, null, "Subscription abuse")))) : (React.createElement("span", null, getDisplayName(item)))))),
100
+ ...(resultSize < items.length
101
+ ? [
102
+ React.createElement("div", { className: "pf-v5-c-divider", role: "separator", key: "separator" }),
103
+ React.createElement(SelectOption, { key: 'diplay-more-option', onClick: onDisplayMoreClick, value: 'display-more' },
104
+ React.createElement(Flex, { justifyContent: { default: 'justifyContentCenter' } },
105
+ React.createElement(FlexItem, { className: '"pf-v5-c-button pf-m-link pf-m-inline' },
106
+ React.createElement(Trans, null, "Display additional results")))),
107
+ ]
108
+ : []),
109
+ ];
110
+ },
100
111
  // eslint-disable-next-line react-hooks/exhaustive-deps
101
112
  [items, bookmarkedAccountsDeduped]);
102
113
  const fetchAccounts = (query) => __awaiter(this, void 0, void 0, function* () {
@@ -179,7 +190,7 @@ function AccountSelectorInternal(props) {
179
190
  (_a = textInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
180
191
  };
181
192
  const onSelect = (selection) => {
182
- if (selection === 'display-more' || isUndefined(selection))
193
+ if (selection === 'display-more' || isUndefined(selection) || isNull(selection))
183
194
  return;
184
195
  props.multiple ? onMultiAccountSelection(selection) : onSingleAccountSelection(selection);
185
196
  };
@@ -233,8 +244,7 @@ function AccountSelectorInternal(props) {
233
244
  React.createElement(TextInputGroup, { isPlain: true, innerRef: inputGroupRef },
234
245
  React.createElement(TextInputGroupMain, { value: query, onClick: onToggleClick, onKeyDown: onInputKeyDown, onChange: onFilter, placeholder: t(props.placeholder || ''), isExpanded: isOpen, innerRef: textInputRef, "aria-controls": `select${props.multiple ? '-multi' : ''}-typeahead-listbox` }),
235
246
  React.createElement(TextInputGroupUtilities, null, !isEmpty(query) && (React.createElement(Button, { variant: "plain", onClick: onClearSelection, isDisabled: isFetching, "aria-label": t('Clear') }, isFetching ? React.createElement(LoadingIndicator, { show: true, size: "sm" }) : React.createElement(TimesCircleIcon, { "aria-hidden": true })))))));
236
- return (React.createElement(Select, { "data-tracking-id": "account-selector-dropdown", isOpen: isOpen, onOpenChange: () => setIsOpen(false), id: props.id, toggle: toggle, popperProps: { direction: 'down', enableFlip: false }, onSelect: (_e, v) => onSelect(v), selected: selectedItems, isScrollable: true },
237
- React.createElement(SelectList, null, dropdownOptions)));
247
+ return (React.createElement(Select, { "data-tracking-id": "account-selector-dropdown", isOpen: isOpen, onOpenChange: () => setIsOpen(false), id: props.id, toggle: toggle, popperProps: { direction: 'down', enableFlip: false }, onSelect: (_e, v) => onSelect(v), selected: selectedItems, isScrollable: true }, dropdownOptions));
238
248
  }
239
249
  AccountSelectorInternal.defaultProps = defaultProps;
240
250
  export { AccountSelectorInternal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "2.1.28",
3
+ "version": "2.1.29",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -85,5 +85,5 @@
85
85
  "defaults and supports es6-module",
86
86
  "maintained node versions"
87
87
  ],
88
- "gitHead": "0273a1330065ecbdbd6e0cddf5bbbd96d562c191"
88
+ "gitHead": "ed9cba460bdbf0d0104fe6e8f21a0ca554bdaee8"
89
89
  }