@sonic-equipment/ui 205.0.0 → 206.0.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.
|
@@ -4,9 +4,11 @@ export interface TableCardProps {
|
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
className?: string;
|
|
6
6
|
'data-test-selector'?: string;
|
|
7
|
+
isLoading?: boolean;
|
|
7
8
|
paging?: React.ReactNode;
|
|
9
|
+
results?: number;
|
|
8
10
|
showError?: Error | TranslationId | boolean | null;
|
|
9
11
|
stickyHeader?: boolean;
|
|
10
12
|
title?: TranslationId;
|
|
11
13
|
}
|
|
12
|
-
export declare function TableCard({ actions, children, className, 'data-test-selector': dataTestSelector, paging, showError, stickyHeader, title, }: TableCardProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function TableCard({ actions, children, className, 'data-test-selector': dataTestSelector, isLoading, paging, results, showError, stickyHeader, title, }: TableCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,10 +5,8 @@ import { UnauthorizedRequestError } from '../../shared/fetch/request.js';
|
|
|
5
5
|
import { Heading } from '../../typography/heading/heading.js';
|
|
6
6
|
import styles from './table-card.module.css.js';
|
|
7
7
|
|
|
8
|
-
function TableCard({ actions, children, className, 'data-test-selector': dataTestSelector,
|
|
9
|
-
|
|
10
|
-
paging, showError = false, stickyHeader = false, title, }) {
|
|
11
|
-
return (jsxs("section", { className: clsx(styles['table-card-container'], stickyHeader && styles['sticky-header'], className), "data-test-selector": dataTestSelector, children: [title && (jsx(Heading, { className: styles.title, size: "xxs", tag: "h3", children: jsx(FormattedMessage, { id: title }) })), jsx("div", { className: styles['table-card'], children: showError ? (jsx("div", { className: styles['error-container'], children: showError instanceof UnauthorizedRequestError ? (jsx(FormattedMessage, { id: "You are not authorized to access this information." })) : typeof showError === 'string' ? (jsx(FormattedMessage, { id: showError })) : (jsx(FormattedMessage, { id: "An unexpected error occured" })) })) : children ? (jsxs(Fragment, { children: [Boolean(actions?.length) && (jsx("div", { className: styles['actions'], children: actions })), jsx("div", { className: styles['data'], children: children }), paging && jsx("div", { className: styles['paging'], children: paging })] })) : (jsx("div", { className: clsx(styles['no-data-container']), children: jsx(FormattedMessage, { id: "There is no information to display" }) })) }), jsx("div", { className: styles['sticky-bar'], role: "presentation" })] }));
|
|
8
|
+
function TableCard({ actions, children, className, 'data-test-selector': dataTestSelector, isLoading, paging, results = 0, showError = false, stickyHeader = false, title, }) {
|
|
9
|
+
return (jsxs("section", { className: clsx(styles['table-card-container'], stickyHeader && styles['sticky-header'], className), "data-test-selector": dataTestSelector, children: [title && (jsx(Heading, { className: styles.title, size: "xxs", tag: "h3", children: jsx(FormattedMessage, { id: title }) })), jsx("div", { className: styles['table-card'], children: showError ? (jsx("div", { className: styles['error-container'], children: showError instanceof UnauthorizedRequestError ? (jsx(FormattedMessage, { id: "You are not authorized to access this information." })) : typeof showError === 'string' ? (jsx(FormattedMessage, { id: showError })) : (jsx(FormattedMessage, { id: "An unexpected error occured" })) })) : (jsxs(Fragment, { children: [Boolean(actions?.length) && (jsx("div", { className: styles['actions'], children: actions })), results === 0 && !isLoading && (jsx("div", { className: clsx(styles['no-data-container']), children: jsx(FormattedMessage, { id: "There is no information to display" }) })), jsx("div", { className: styles['data'], children: children }), paging && jsx("div", { className: styles['paging'], children: paging })] })) }), jsx("div", { className: styles['sticky-bar'], role: "presentation" })] }));
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
export { TableCard };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useState, useRef } from 'react';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { useIntersectionObserver } from '../shared/hooks/use-intersection-observer.js';
|
|
6
6
|
import { ProgressCircle } from './progress-circle.js';
|
|
@@ -21,6 +21,12 @@ function DynamicLoadingOverlay({ children, className, isLoading, }) {
|
|
|
21
21
|
},
|
|
22
22
|
threshold,
|
|
23
23
|
});
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!isLoading) {
|
|
26
|
+
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
27
|
+
setIntersectedHeight(0);
|
|
28
|
+
}
|
|
29
|
+
}, [isLoading]);
|
|
24
30
|
return (jsxs("div", { ref: container, className: clsx(styles['dynamic-loading-overlay'], isLoading && styles['is-loading'], className), style: { '--intersected-height': `${intersectedHeight}px` }, children: [jsx("div", { className: styles['content'], children: children }), jsx("div", { className: styles['loading-indicator'], children: jsx(ProgressCircle, { className: styles['spinner'], variant: "gray" }) })] }));
|
|
25
31
|
}
|
|
26
32
|
|
|
@@ -18,15 +18,16 @@ import styles from './connected-address-book-widget.module.css.js';
|
|
|
18
18
|
|
|
19
19
|
function ConnectedAddressBookWidget() {
|
|
20
20
|
const t = useFormattedMessage();
|
|
21
|
+
const { pathname, search: searchParams } = useLocation();
|
|
22
|
+
const href = `${pathname}${searchParams}`;
|
|
23
|
+
const paths = usePaths();
|
|
21
24
|
const [sort, setSort] = useState({
|
|
22
25
|
name: 'companyName',
|
|
23
|
-
order: '
|
|
26
|
+
order: 'ASC',
|
|
24
27
|
});
|
|
25
28
|
const [search, setSearch] = useState('');
|
|
26
29
|
const [page, setPage] = useState(1);
|
|
27
30
|
const addressBookRef = useRef(null);
|
|
28
|
-
const { href } = useLocation();
|
|
29
|
-
const paths = usePaths();
|
|
30
31
|
const { data, error, isFetching } = useFetchPagedShipToAddresses({
|
|
31
32
|
page,
|
|
32
33
|
pageSize: 20,
|
|
@@ -49,8 +50,8 @@ function ConnectedAddressBookWidget() {
|
|
|
49
50
|
return (jsx(TableCard, { stickyHeader: true, actions: [
|
|
50
51
|
jsx(SearchField, { isDebounced: true, className: styles['search-field'], label: t('Search'), onChange: searchAddresses, placeholder: t('Search'), showLabel: false, size: "md", variant: "outline" }, "searchAddresses"),
|
|
51
52
|
jsx(Button, { color: "secondary", href: `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/current${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/new?returnUrl=${encodeURIComponent(href)}`, size: "sm", variant: "outline", children: t('Add address') }, "addAddress"),
|
|
52
|
-
], className: styles['address-book-widget'], "data-test-selector": "address-book-widget", paging: addresses &&
|
|
53
|
-
addresses.length > 0 && (jsx("nav", { className: styles['paging'], children: jsx(Pagination, { currentPage: pagination?.currentPage || 1, onChange: page => setPage(page), totalPages: pagination?.numberOfPages || 1 }) })), showError: error, title: "Address book", children: jsx("div", { ref: addressBookRef, "aria-label": "Results", "aria-live": "polite", className: styles['results'], children: jsx(DynamicLoadingOverlay, { isLoading: isFetching, children:
|
|
53
|
+
], className: styles['address-book-widget'], "data-test-selector": "address-book-widget", isLoading: isFetching, paging: addresses &&
|
|
54
|
+
addresses.length > 0 && (jsx("nav", { className: styles['paging'], children: jsx(Pagination, { currentPage: pagination?.currentPage || 1, onChange: page => setPage(page), totalPages: pagination?.numberOfPages || 1 }) })), results: addresses ? addresses.length : 0, showError: error, title: "Address book", children: jsx("div", { ref: addressBookRef, "aria-label": "Results", "aria-live": "polite", className: styles['results'], children: jsx(DynamicLoadingOverlay, { isLoading: isFetching, children: jsx(DataTable, { actions: [
|
|
54
55
|
{
|
|
55
56
|
href: address => `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/current${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${address.id}?returnUrl=${encodeURIComponent(href)}`,
|
|
56
57
|
key: 'edit',
|
|
@@ -83,7 +84,7 @@ function ConnectedAddressBookWidget() {
|
|
|
83
84
|
sticky: true,
|
|
84
85
|
truncated: 3,
|
|
85
86
|
},
|
|
86
|
-
sort: { direction:
|
|
87
|
+
sort: { direction: sort.order, isEnabled: true },
|
|
87
88
|
value: {
|
|
88
89
|
propertyName: 'companyName',
|
|
89
90
|
},
|
|
@@ -153,14 +154,14 @@ function ConnectedAddressBookWidget() {
|
|
|
153
154
|
action: 'edit',
|
|
154
155
|
},
|
|
155
156
|
},
|
|
156
|
-
], data: addresses, onSort: (key, direction) => {
|
|
157
|
+
], data: addresses && addresses.length > 0 ? addresses : [], onSort: (key, direction) => {
|
|
157
158
|
if (direction === 'NONE')
|
|
158
159
|
return;
|
|
159
160
|
setSort({
|
|
160
161
|
name: key,
|
|
161
162
|
order: direction,
|
|
162
163
|
});
|
|
163
|
-
} })
|
|
164
|
+
} }) }) }) }));
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
export { ConnectedAddressBookWidget };
|