@rh-support/components 2.1.59 → 2.1.60

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.
@@ -36,7 +36,7 @@ const initializedCountries = COUNTRY_DATA.map((country) => {
36
36
  const formatNumber = (fullPhoneNumber, localFormat) => {
37
37
  if (isEmpty(fullPhoneNumber))
38
38
  return '';
39
- let localPhone = fullPhoneNumber === null || fullPhoneNumber === void 0 ? void 0 : fullPhoneNumber.replace(PREFIX, '');
39
+ let localPhone = fullPhoneNumber.replace(PREFIX, '');
40
40
  if (isEmpty(localPhone))
41
41
  return '';
42
42
  // Formatting inputted number
@@ -48,7 +48,7 @@ const formatNumber = (fullPhoneNumber, localFormat) => {
48
48
  });
49
49
  let pattern = '';
50
50
  let i = 0;
51
- for (let j = 0; j < (localFormat === null || localFormat === void 0 ? void 0 : localFormat.length) && i < (phone === null || phone === void 0 ? void 0 : phone.length); j++) {
51
+ for (let j = 0; j < (localFormat === null || localFormat === void 0 ? void 0 : localFormat.length) && i < phone.length; j++) {
52
52
  if (localFormat[j] === '.') {
53
53
  pattern += phone[i];
54
54
  i++;
@@ -61,7 +61,7 @@ const formatNumber = (fullPhoneNumber, localFormat) => {
61
61
  };
62
62
  // return phoneline and countrycode for any given phone
63
63
  export const getPhoneObj = (phoneNumber) => {
64
- let localPhone = phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.replace(/[^0-9]/g, '');
64
+ let localPhone = phoneNumber.replace(/[^0-9]/g, '');
65
65
  let countryCode = '';
66
66
  // Guessing countries according to user input
67
67
  const possibleCountries = initializedCountries.filter((country) => localPhone === null || localPhone === void 0 ? void 0 : localPhone.startsWith(country.dialCode.toString()));
@@ -74,7 +74,7 @@ export const getPhoneObj = (phoneNumber) => {
74
74
  }
75
75
  return {
76
76
  countryCode: PREFIX + countryCode,
77
- phoneLine: localPhone === null || localPhone === void 0 ? void 0 : localPhone.substring(countryCode.length, localPhone.length),
77
+ phoneLine: localPhone.substring(countryCode.length, localPhone.length),
78
78
  };
79
79
  };
80
80
  export function PhoneInput(props) {
@@ -7,10 +7,8 @@ interface IProps {
7
7
  topContentData: ITopContentList[];
8
8
  enableEventTracking?: boolean;
9
9
  onSearch: (searchVal: string, searchResults: ITopContentList[]) => void;
10
- searchQuery?: string;
11
- setSearchQuery?: Function;
12
10
  }
13
11
  export declare const getTopContentUrl: (contentUrl: string) => string;
14
- export declare function TopContentSearch({ topContentData, topContentResultsWrapperRef, onSearch, dataTrackingId, enableEventTracking, searchQuery, setSearchQuery, }: IProps): React.JSX.Element;
12
+ export declare function TopContentSearch({ topContentData, topContentResultsWrapperRef, onSearch, dataTrackingId, enableEventTracking, }: IProps): React.JSX.Element;
15
13
  export {};
16
14
  //# sourceMappingURL=TopContentSearch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentSearch.d.ts","sourceRoot":"","sources":["../../../src/TopContentSearch/TopContentSearch.tsx"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,2DAA2D,CAAC;AAQ5F,OAAO,KAA4D,MAAM,OAAO,CAAC;AAGjF,UAAU,MAAM;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,2BAA2B,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACzD,cAAc,EAAE,eAAe,EAAE,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC7B;AAED,eAAO,MAAM,gBAAgB,eAAgB,MAAM,WASlD,CAAC;AAOF,wBAAgB,gBAAgB,CAAC,EAC7B,cAAmB,EACnB,2BAA6C,EAC7C,QAAQ,EACR,cAAc,EACd,mBAA2B,EAC3B,WAAgB,EAChB,cAAc,GACjB,EAAE,MAAM,qBAwHR"}
1
+ {"version":3,"file":"TopContentSearch.d.ts","sourceRoot":"","sources":["../../../src/TopContentSearch/TopContentSearch.tsx"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,2DAA2D,CAAC;AAQ5F,OAAO,KAA4D,MAAM,OAAO,CAAC;AAGjF,UAAU,MAAM;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,2BAA2B,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACzD,cAAc,EAAE,eAAe,EAAE,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CAC3E;AAED,eAAO,MAAM,gBAAgB,eAAgB,MAAM,WASlD,CAAC;AAOF,wBAAgB,gBAAgB,CAAC,EAC7B,cAAmB,EACnB,2BAA6C,EAC7C,QAAQ,EACR,cAAc,EACd,mBAA2B,GAC9B,EAAE,MAAM,qBA8GR"}
@@ -31,8 +31,8 @@ var CustomEvents;
31
31
  CustomEvents["inputChange"] = "top-content-filter-input-change";
32
32
  CustomEvents["inputClear"] = "top-content-filter-input-clear";
33
33
  })(CustomEvents || (CustomEvents = {}));
34
- export function TopContentSearch({ topContentData = [], topContentResultsWrapperRef = { current: {} }, onSearch, dataTrackingId, enableEventTracking = false, searchQuery = '', setSearchQuery, }) {
35
- const [searchText, setSearchText] = useState(searchQuery);
34
+ export function TopContentSearch({ topContentData = [], topContentResultsWrapperRef = { current: {} }, onSearch, dataTrackingId, enableEventTracking = false, }) {
35
+ const [searchText, setSearchText] = useState('');
36
36
  const { t } = useTranslation();
37
37
  const searchWorkerRef = useRef(new SearchApi({
38
38
  indexMode: INDEX_MODES.ALL_SUBSTRINGS,
@@ -56,9 +56,8 @@ export function TopContentSearch({ topContentData = [], topContentResultsWrapper
56
56
  dtmTrackEvent(searchWrapperRef, eventName, event);
57
57
  };
58
58
  const highlightSearchResults = useCallback((searchTerm) => {
59
- var _a;
60
59
  // highlight search term present in contents only. Contents are present within <dd> tag
61
- const contentElements = (_a = topContentResultsWrapperRef === null || topContentResultsWrapperRef === void 0 ? void 0 : topContentResultsWrapperRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('dd.pf-v5-c-accordion__expandable-content');
60
+ const contentElements = topContentResultsWrapperRef.current.querySelectorAll('dd.pf-v5-c-accordion__expandable-content');
62
61
  const markInstance = new Mark(contentElements);
63
62
  markInstance.unmark({
64
63
  done: () => {
@@ -69,10 +68,10 @@ export function TopContentSearch({ topContentData = [], topContentResultsWrapper
69
68
  });
70
69
  }, [topContentResultsWrapperRef]);
71
70
  const onSearchInputClear = useCallback((event) => {
72
- setSearchText('');
73
- onSearch('', topContentData);
74
71
  logCustomEvent(CustomEvents.inputClear, event);
72
+ setSearchText('');
75
73
  highlightSearchResults('');
74
+ onSearch('', topContentData);
76
75
  },
77
76
  // eslint-disable-next-line react-hooks/exhaustive-deps
78
77
  [highlightSearchResults, topContentData]);
@@ -104,15 +103,8 @@ export function TopContentSearch({ topContentData = [], topContentResultsWrapper
104
103
  const debounceSearch = useMemo(() => debounce(handleSearch, 500), [handleSearch]);
105
104
  const onSearchInputChange = (value) => {
106
105
  setSearchText(value);
107
- setSearchQuery && setSearchQuery(value);
108
106
  debounceSearch(value);
109
107
  };
110
- useEffect(() => {
111
- if (searchQuery)
112
- debounceSearch(searchQuery);
113
- },
114
- // eslint-disable-next-line react-hooks/exhaustive-deps
115
- []);
116
108
  return (React.createElement("div", { className: "top-content-search-wrapper pf-v5-u-p-md", ref: searchWrapperRef },
117
109
  React.createElement("label", { htmlFor: "top-content-search-input", className: "pf-v5-u-mr-md top-content-search-label" },
118
110
  React.createElement(Trans, null, "Filter results:")),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/components",
3
- "version": "2.1.59",
3
+ "version": "2.1.60",
4
4
  "description": "Contains all reusabel components for support app",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -109,5 +109,5 @@
109
109
  "defaults and supports es6-module",
110
110
  "maintained node versions"
111
111
  ],
112
- "gitHead": "aa56a22b784978f97c2a073e1cc5868648790890"
112
+ "gitHead": "d0800f64f5543b6f26b111bd7f179a8277e32456"
113
113
  }