@rh-support/components 2.1.60 → 2.1.61
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.
- package/lib/esm/PaginatedList/PaginatedList.d.ts +1 -0
- package/lib/esm/PaginatedList/PaginatedList.d.ts.map +1 -1
- package/lib/esm/PaginatedList/PaginatedList.js +9 -0
- package/lib/esm/PhoneInput/PhoneInput.js +4 -4
- package/lib/esm/TopContentSearch/TopContentSearch.d.ts +3 -1
- package/lib/esm/TopContentSearch/TopContentSearch.d.ts.map +1 -1
- package/lib/esm/TopContentSearch/TopContentSearch.js +13 -5
- package/package.json +3 -3
|
@@ -12,6 +12,7 @@ interface IProps {
|
|
|
12
12
|
onPerPageSelect?: (pageSize: number) => void;
|
|
13
13
|
perPageOptions?: PaginationProps['perPageOptions'];
|
|
14
14
|
errorMessage?: string;
|
|
15
|
+
setPaginatedListLength?: React.Dispatch<React.SetStateAction<number | undefined>>;
|
|
15
16
|
}
|
|
16
17
|
export declare function PaginatedList(props: IProps): React.JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginatedList.d.ts","sourceRoot":"","sources":["../../../src/PaginatedList/PaginatedList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIH,eAAe,EAElB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,UAAU,MAAM;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,cAAc,CAAC,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAC;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"PaginatedList.d.ts","sourceRoot":"","sources":["../../../src/PaginatedList/PaginatedList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIH,eAAe,EAElB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,UAAU,MAAM;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,cAAc,CAAC,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAC;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;CACrF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,qBAwE1C"}
|
|
@@ -14,6 +14,15 @@ export function PaginatedList(props) {
|
|
|
14
14
|
if (!props.serverPaginated) {
|
|
15
15
|
listItems = listItems.slice(indexOfFirstShownElement, indexOfFirstShownElement + pageSize);
|
|
16
16
|
}
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
// Only update the external state if the prop function is provided
|
|
19
|
+
if (props.setPaginatedListLength) {
|
|
20
|
+
// Calculate the length based on current page and perPage, or directly use listItems.length
|
|
21
|
+
listItems &&
|
|
22
|
+
props.setPaginatedListLength(listItems.slice(indexOfFirstShownElement, indexOfFirstShownElement + pageSize).length);
|
|
23
|
+
}
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
|
+
}, [props.listItems.length]);
|
|
17
26
|
const onSetPage = (event, pageNumber) => {
|
|
18
27
|
setCurrentPage(pageNumber);
|
|
19
28
|
props.onSetPage && props.onSetPage(pageNumber);
|
|
@@ -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.replace(PREFIX, '');
|
|
39
|
+
let localPhone = fullPhoneNumber === null || fullPhoneNumber === void 0 ? void 0 : 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.length; j++) {
|
|
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++) {
|
|
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.replace(/[^0-9]/g, '');
|
|
64
|
+
let localPhone = phoneNumber === null || phoneNumber === void 0 ? void 0 : 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.substring(countryCode.length, localPhone.length),
|
|
77
|
+
phoneLine: localPhone === null || localPhone === void 0 ? void 0 : localPhone.substring(countryCode.length, localPhone.length),
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
80
|
export function PhoneInput(props) {
|
|
@@ -7,8 +7,10 @@ interface IProps {
|
|
|
7
7
|
topContentData: ITopContentList[];
|
|
8
8
|
enableEventTracking?: boolean;
|
|
9
9
|
onSearch: (searchVal: string, searchResults: ITopContentList[]) => void;
|
|
10
|
+
searchQuery?: string;
|
|
11
|
+
setSearchQuery?: Function;
|
|
10
12
|
}
|
|
11
13
|
export declare const getTopContentUrl: (contentUrl: string) => string;
|
|
12
|
-
export declare function TopContentSearch({ topContentData, topContentResultsWrapperRef, onSearch, dataTrackingId, enableEventTracking, }: IProps): React.JSX.Element;
|
|
14
|
+
export declare function TopContentSearch({ topContentData, topContentResultsWrapperRef, onSearch, dataTrackingId, enableEventTracking, searchQuery, setSearchQuery, }: IProps): React.JSX.Element;
|
|
13
15
|
export {};
|
|
14
16
|
//# 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;
|
|
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"}
|
|
@@ -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, }) {
|
|
35
|
-
const [searchText, setSearchText] = useState(
|
|
34
|
+
export function TopContentSearch({ topContentData = [], topContentResultsWrapperRef = { current: {} }, onSearch, dataTrackingId, enableEventTracking = false, searchQuery = '', setSearchQuery, }) {
|
|
35
|
+
const [searchText, setSearchText] = useState(searchQuery);
|
|
36
36
|
const { t } = useTranslation();
|
|
37
37
|
const searchWorkerRef = useRef(new SearchApi({
|
|
38
38
|
indexMode: INDEX_MODES.ALL_SUBSTRINGS,
|
|
@@ -56,8 +56,9 @@ export function TopContentSearch({ topContentData = [], topContentResultsWrapper
|
|
|
56
56
|
dtmTrackEvent(searchWrapperRef, eventName, event);
|
|
57
57
|
};
|
|
58
58
|
const highlightSearchResults = useCallback((searchTerm) => {
|
|
59
|
+
var _a;
|
|
59
60
|
// highlight search term present in contents only. Contents are present within <dd> tag
|
|
60
|
-
const contentElements = topContentResultsWrapperRef.current.querySelectorAll('dd.pf-v5-c-accordion__expandable-content');
|
|
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');
|
|
61
62
|
const markInstance = new Mark(contentElements);
|
|
62
63
|
markInstance.unmark({
|
|
63
64
|
done: () => {
|
|
@@ -68,10 +69,10 @@ export function TopContentSearch({ topContentData = [], topContentResultsWrapper
|
|
|
68
69
|
});
|
|
69
70
|
}, [topContentResultsWrapperRef]);
|
|
70
71
|
const onSearchInputClear = useCallback((event) => {
|
|
71
|
-
logCustomEvent(CustomEvents.inputClear, event);
|
|
72
72
|
setSearchText('');
|
|
73
|
-
highlightSearchResults('');
|
|
74
73
|
onSearch('', topContentData);
|
|
74
|
+
logCustomEvent(CustomEvents.inputClear, event);
|
|
75
|
+
highlightSearchResults('');
|
|
75
76
|
},
|
|
76
77
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
78
|
[highlightSearchResults, topContentData]);
|
|
@@ -103,8 +104,15 @@ export function TopContentSearch({ topContentData = [], topContentResultsWrapper
|
|
|
103
104
|
const debounceSearch = useMemo(() => debounce(handleSearch, 500), [handleSearch]);
|
|
104
105
|
const onSearchInputChange = (value) => {
|
|
105
106
|
setSearchText(value);
|
|
107
|
+
setSearchQuery && setSearchQuery(value);
|
|
106
108
|
debounceSearch(value);
|
|
107
109
|
};
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (searchQuery)
|
|
112
|
+
debounceSearch(searchQuery);
|
|
113
|
+
},
|
|
114
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
115
|
+
[]);
|
|
108
116
|
return (React.createElement("div", { className: "top-content-search-wrapper pf-v5-u-p-md", ref: searchWrapperRef },
|
|
109
117
|
React.createElement("label", { htmlFor: "top-content-search-input", className: "pf-v5-u-mr-md top-content-search-label" },
|
|
110
118
|
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.
|
|
3
|
+
"version": "2.1.61",
|
|
4
4
|
"description": "Contains all reusabel components for support app",
|
|
5
5
|
"author": "Vikas Rathee <vrathee@redhat.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@patternfly/react-core": "5.1.1",
|
|
69
69
|
"@patternfly/react-table": "5.1.1",
|
|
70
70
|
"@rh-support/types": "2.0.3",
|
|
71
|
-
"@rh-support/user-permissions": "2.1.
|
|
71
|
+
"@rh-support/user-permissions": "2.1.44",
|
|
72
72
|
"@rh-support/utils": "2.1.33",
|
|
73
73
|
"dompurify": "^2.2.6",
|
|
74
74
|
"downshift": "^6.0.5",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"defaults and supports es6-module",
|
|
110
110
|
"maintained node versions"
|
|
111
111
|
],
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "908b440e3c6cd625c77178c3205f4e2908630446"
|
|
113
113
|
}
|