@scality/core-ui 0.127.0 → 0.129.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.
- package/dist/components/UnsuccessfulResult.component.d.ts +24 -0
- package/dist/components/UnsuccessfulResult.component.d.ts.map +1 -0
- package/dist/components/UnsuccessfulResult.component.js +21 -0
- package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
- package/dist/components/tablev2/TableCommon.js +6 -12
- package/dist/components/tablev2/TableUtils.d.ts +1 -1
- package/dist/components/tablev2/TableUtils.d.ts.map +1 -1
- package/dist/components/tablev2/TableUtils.js +1 -1
- package/dist/components/tablev2/Tablestyle.d.ts +0 -5
- package/dist/components/tablev2/Tablestyle.d.ts.map +1 -1
- package/dist/components/tablev2/Tablestyle.js +0 -9
- package/dist/components/tabsv2/StyledTabs.d.ts +1 -0
- package/dist/components/tabsv2/StyledTabs.d.ts.map +1 -1
- package/dist/components/tabsv2/StyledTabs.js +1 -1
- package/dist/components/tabsv2/Tab.d.ts +1 -0
- package/dist/components/tabsv2/Tab.d.ts.map +1 -1
- package/dist/components/tabsv2/Tabsv2.component.d.ts +3 -3
- package/dist/components/tabsv2/Tabsv2.component.d.ts.map +1 -1
- package/dist/components/tabsv2/Tabsv2.component.js +6 -7
- package/dist/components/tabsv2/useScrollingTabs.d.ts +1 -1
- package/dist/components/tabsv2/useScrollingTabs.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/UnsuccessfulResult.component.tsx +50 -0
- package/src/lib/components/tablev2/TableCommon.tsx +10 -27
- package/src/lib/components/tablev2/TableUtils.ts +2 -2
- package/src/lib/components/tablev2/Tablestyle.tsx +0 -9
- package/src/lib/components/tabsv2/StyledTabs.ts +5 -2
- package/src/lib/components/tabsv2/Tab.ts +1 -0
- package/src/lib/components/tabsv2/Tabsv2.component.tsx +44 -36
- package/src/lib/components/tabsv2/useScrollingTabs.ts +1 -1
- package/stories/noresult.stories.tsx +33 -0
- package/stories/tablev2.stories.tsx +38 -32
- package/stories/tabsv2.stories.tsx +56 -40
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableHeightKeyType, TableLocalType } from './tablev2/TableUtils';
|
|
3
|
+
export type UnsuccessfulResultProps = {
|
|
4
|
+
name?: {
|
|
5
|
+
en: {
|
|
6
|
+
singular: string;
|
|
7
|
+
plural: string;
|
|
8
|
+
};
|
|
9
|
+
fr?: {
|
|
10
|
+
singular: string;
|
|
11
|
+
plural: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
locale?: TableLocalType;
|
|
15
|
+
status: 'error' | 'loading' | 'idle' | 'noResult';
|
|
16
|
+
} & ({
|
|
17
|
+
rowHeight: TableHeightKeyType;
|
|
18
|
+
heightInRem?: never;
|
|
19
|
+
} | {
|
|
20
|
+
rowHeight?: never;
|
|
21
|
+
heightInRem?: number | string;
|
|
22
|
+
});
|
|
23
|
+
export declare const UnsuccessfulResult: (props: UnsuccessfulResultProps) => JSX.Element;
|
|
24
|
+
//# sourceMappingURL=UnsuccessfulResult.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnsuccessfulResult.component.d.ts","sourceRoot":"","sources":["../../src/lib/components/UnsuccessfulResult.component.tsx"],"names":[],"mappings":";AAGA,OAAO,EACL,kBAAkB,EAClB,cAAc,EAGf,MAAM,sBAAsB,CAAC;AAc9B,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,CAAC,EAAE;QACL,EAAE,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QACzC,EAAE,CAAC,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;KAC3C,CAAC;IACF,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;CACnD,GAAG,CACA;IAAE,SAAS,EAAE,kBAAkB,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,GACtD;IAAE,SAAS,CAAC,EAAE,KAAK,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CACvD,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,uBAAuB,gBAehE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Icon } from './icon/Icon.component';
|
|
4
|
+
import { Loader } from './loader/Loader.component';
|
|
5
|
+
import { tableRowHeight, translatedMessages, } from './tablev2/TableUtils';
|
|
6
|
+
import { Text } from './text/Text.component';
|
|
7
|
+
import { Box } from './box/Box';
|
|
8
|
+
import { spacing } from '../spacing';
|
|
9
|
+
const NoResult = styled(Box) `
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
color: ${(props) => props.theme.textSecondary};
|
|
14
|
+
height: ${(props) => props.height}rem;
|
|
15
|
+
gap: ${spacing.r8};
|
|
16
|
+
`;
|
|
17
|
+
export const UnsuccessfulResult = (props) => {
|
|
18
|
+
const { heightInRem = 5, name, locale, status, rowHeight } = props;
|
|
19
|
+
const height = rowHeight ? tableRowHeight[rowHeight] : heightInRem;
|
|
20
|
+
return (_jsxs(NoResult, { height: height, children: [(status === 'loading' || status === 'idle') && _jsx(Loader, {}), status === 'error' && (_jsx(Icon, { name: "Exclamation-circle", color: "statusWarning" })), _jsx(Text, { color: "textSecondary", children: translatedMessages(status, name, locale) })] }));
|
|
21
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCommon.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tablev2/TableCommon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAyB,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EACL,aAAa,EAEb,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,
|
|
1
|
+
{"version":3,"file":"TableCommon.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tablev2/TableCommon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAyB,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EACL,aAAa,EAEb,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,kBAAkB,EAClB,cAAc,EAEf,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,KAAK,mBAAmB,CACtB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAChE;IACF,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;IACtB,SAAS,EAAE,aAAa,CAAC,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACnE,SAAS,EAAE,kBAAkB,CAAC;IAC9B,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;CACrD,CAAC;AAEF,eAAO,MAAM,eAAe,kNA8C3B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;CAwB7B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,KAAK,cAAc,CACjB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAChE;IACF,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC;IAClD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,CAAC;IAC1D,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAClC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,aAAa,KAAK,GAAG,CAAC,OAAO,CACjD,CAAC;CACH,CAAC;AACF,wBAAgB,SAAS,CACvB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,sBA0DzE"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useState } from 'react';
|
|
3
3
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
4
4
|
import { FixedSizeList as List, } from 'react-window';
|
|
5
|
-
import { convertRemToPixels,
|
|
5
|
+
import { convertRemToPixels, tableRowHeight, } from './TableUtils';
|
|
6
6
|
import { useTableContext } from './Tablev2.component';
|
|
7
|
-
import { NoResult } from './Tablestyle';
|
|
8
|
-
import { Loader } from '../loader/Loader.component';
|
|
9
|
-
import { Text } from '../text/Text.component';
|
|
10
|
-
import { Icon } from '../icon/Icon.component';
|
|
11
7
|
import useSyncedScroll from './useSyncedScroll';
|
|
8
|
+
import { UnsuccessfulResult } from '../UnsuccessfulResult.component';
|
|
12
9
|
export const VirtualizedRows = ({ rows, rowHeight, setHasScrollbar, onBottom, onBottomOffset, RenderRow, listRef, itemKey, }) => (_jsx(AutoSizer, { children: ({ height, width }) => {
|
|
13
10
|
return (_jsx(List, { height: height, itemCount: rows.length, itemSize: convertRemToPixels(tableRowHeight[rowHeight]), width: width, itemKey: itemKey, itemData: rows, ref: listRef, onItemsRendered: ({ visibleStartIndex, visibleStopIndex, overscanStopIndex, }) => {
|
|
14
11
|
setHasScrollbar(visibleStopIndex - visibleStartIndex < overscanStopIndex);
|
|
@@ -49,11 +46,8 @@ export function TableRows({ locale, children, customItemKey, RenderRow }) {
|
|
|
49
46
|
}
|
|
50
47
|
return index;
|
|
51
48
|
}
|
|
52
|
-
if (status === 'idle' || status === 'loading') {
|
|
53
|
-
return (
|
|
54
|
-
}
|
|
55
|
-
if (status === 'error') {
|
|
56
|
-
return (_jsxs(NoResult, { rowHeight: rowHeight, children: [_jsx(Icon, { name: "Exclamation-circle", color: "statusWarning" }), _jsx(Text, { color: "textSecondary", children: translatedMessages('error', entityName, locale) })] }));
|
|
49
|
+
if (status === 'idle' || status === 'loading' || status === 'error') {
|
|
50
|
+
return (_jsx(UnsuccessfulResult, { name: entityName, status: status, locale: locale, rowHeight: rowHeight }));
|
|
57
51
|
}
|
|
58
52
|
if (status === 'success' || status === undefined) {
|
|
59
53
|
if (typeof children === 'function') {
|
|
@@ -63,7 +57,7 @@ export function TableRows({ locale, children, customItemKey, RenderRow }) {
|
|
|
63
57
|
return (_jsx(VirtualizedRows, { rows: rows, listRef: bodyRef, setHasScrollbar: setHasScrollbar, onBottom: onBottom, onBottomOffset: onBottomOffset, itemKey: itemKey, rowHeight: rowHeight, RenderRow: RenderRow }));
|
|
64
58
|
}
|
|
65
59
|
else {
|
|
66
|
-
return
|
|
60
|
+
return _jsx(UnsuccessfulResult, { name: entityName, status: "noResult" });
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
63
|
return null;
|
|
@@ -14,7 +14,7 @@ export declare const tableRowHeight: {
|
|
|
14
14
|
h48: string;
|
|
15
15
|
h64: string;
|
|
16
16
|
};
|
|
17
|
-
type TableMessagesType = 'error' | 'loading' | 'noResult';
|
|
17
|
+
type TableMessagesType = 'error' | 'loading' | 'idle' | 'noResult';
|
|
18
18
|
export declare const translatedMessages: (type: TableMessagesType, entityName?: {
|
|
19
19
|
en: {
|
|
20
20
|
singular: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableUtils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tablev2/TableUtils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe,aAAa,CAAC;AACnC,QAAA,MAAM,cAAc,YAAY,CAAC;AACjC,QAAA,MAAM,WAAW,SAAS,CAAC;AAC3B,QAAA,MAAM,aAAa,YAAY,CAAC;AAEhC,KAAK,UAAU,GACX,OAAO,eAAe,GACtB,OAAO,cAAc,GACrB,OAAO,WAAW,GAClB,OAAO,aAAa,CAAC;AAGzB,wBAAgB,aAAa,CAC3B,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,UAAU,GAClB,MAAM,GAAG,SAAS,CAuBpB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,KAAA,UAErC;AACD,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,CAAC;AAGvB,eAAO,MAAM,cAAc;;;;;CAK1B,CAAC;AAEF,KAAK,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"TableUtils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tablev2/TableUtils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe,aAAa,CAAC;AACnC,QAAA,MAAM,cAAc,YAAY,CAAC;AACjC,QAAA,MAAM,WAAW,SAAS,CAAC;AAC3B,QAAA,MAAM,aAAa,YAAY,CAAC;AAEhC,KAAK,UAAU,GACX,OAAO,eAAe,GACtB,OAAO,cAAc,GACrB,OAAO,WAAW,GAClB,OAAO,aAAa,CAAC;AAGzB,wBAAgB,aAAa,CAC3B,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,UAAU,GAClB,MAAM,GAAG,SAAS,CAuBpB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,KAAA,UAErC;AACD,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,CAAC;AAGvB,eAAO,MAAM,cAAc;;;;;CAK1B,CAAC;AAEF,KAAK,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;AAEnE,eAAO,MAAM,kBAAkB,SACvB,iBAAiB,eACV;IACX,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,EAAE,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,WACQ,cAAc,WA2BxB,CAAC"}
|
|
@@ -39,7 +39,7 @@ export const translatedMessages = (type, entityName, locale) => {
|
|
|
39
39
|
return `An error occurred while loading ${entityName ? `the ${entityName.en.plural}` : 'data'}, please refresh the
|
|
40
40
|
page.`;
|
|
41
41
|
}
|
|
42
|
-
if (type === 'loading') {
|
|
42
|
+
if (type === 'loading' || type === 'idle') {
|
|
43
43
|
if (locale === 'fr') {
|
|
44
44
|
return `Chargement des ${((_b = entityName === null || entityName === void 0 ? void 0 : entityName.fr) === null || _b === void 0 ? void 0 : _b.plural) || 'données'}...`;
|
|
45
45
|
}
|
|
@@ -28,11 +28,6 @@ export declare const TableRowMultiSelectable: import("styled-components").Styled
|
|
|
28
28
|
export declare const TableBody: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
29
29
|
export declare const TableWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
30
30
|
export declare const TooltipContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
31
|
-
export declare const NoResult: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").GridProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & import("styled-system").BordersProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ShadowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
32
|
-
gap?: string | number | undefined;
|
|
33
|
-
} & {
|
|
34
|
-
rowHeight: TableHeightKeyType;
|
|
35
|
-
}, never>;
|
|
36
31
|
export declare const SortCaret: <DATA_ROW extends Record<string, unknown> = Record<string, unknown>>({ column, }: {
|
|
37
32
|
column: HeaderGroup<DATA_ROW>;
|
|
38
33
|
}) => JSX.Element | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tablestyle.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tablev2/Tablestyle.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,kBAAkB,EAElB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,eAAO,MAAM,aAAa,0GAGzB,CAAC;AACF,eAAO,MAAM,gBAAgB,0GAG5B,CAAC;AACF,eAAO,MAAM,WAAW;;cAEZ,MAAM,GAAG,SAAS;SAkB7B,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,qBAAqB,EAAE,gBAAgB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,OAAO,kHAmBnB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,gBAAgB,CAAC;CACzC,CAAC;AACF,eAAO,MAAM,QAAQ,mHAmCpB,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB,qBAAqB,EAAE,gBAAgB,CAAC;CACzC,CAAC;AACF,eAAO,MAAM,uBAAuB,kIAqBnC,CAAC;AAEF,eAAO,MAAM,SAAS,yGAKrB,CAAC;AACF,eAAO,MAAM,YAAY,yGAKxB,CAAC;AACF,eAAO,MAAM,cAAc,yGAI1B,CAAC;AAEF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"Tablestyle.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tablev2/Tablestyle.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,kBAAkB,EAElB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,eAAO,MAAM,aAAa,0GAGzB,CAAC;AACF,eAAO,MAAM,gBAAgB,0GAG5B,CAAC;AACF,eAAO,MAAM,WAAW;;cAEZ,MAAM,GAAG,SAAS;SAkB7B,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,qBAAqB,EAAE,gBAAgB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,OAAO,kHAmBnB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,gBAAgB,CAAC;CACzC,CAAC;AACF,eAAO,MAAM,QAAQ,mHAmCpB,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB,qBAAqB,EAAE,gBAAgB,CAAC;CACzC,CAAC;AACF,eAAO,MAAM,uBAAuB,kIAqBnC,CAAC;AAEF,eAAO,MAAM,SAAS,yGAKrB,CAAC;AACF,eAAO,MAAM,YAAY,yGAKxB,CAAC;AACF,eAAO,MAAM,cAAc,yGAI1B,CAAC;AAEF,eAAO,MAAM,SAAS;;wBAsBrB,CAAC"}
|
|
@@ -4,7 +4,6 @@ import { tableRowHeight, } from './TableUtils';
|
|
|
4
4
|
import { Icon } from '../icon/Icon.component';
|
|
5
5
|
import { FocusVisibleStyle } from '../buttonv2/Buttonv2.component';
|
|
6
6
|
import { spacing } from '../../spacing';
|
|
7
|
-
import { Box } from '../box/Box';
|
|
8
7
|
const borderSize = '4px';
|
|
9
8
|
export const SortIncentive = styled.span `
|
|
10
9
|
position: absolute;
|
|
@@ -125,14 +124,6 @@ export const TooltipContent = styled.div `
|
|
|
125
124
|
font-weight: bold;
|
|
126
125
|
min-width: 60px;
|
|
127
126
|
`;
|
|
128
|
-
export const NoResult = styled(Box) `
|
|
129
|
-
display: flex;
|
|
130
|
-
justify-content: center;
|
|
131
|
-
align-items: center;
|
|
132
|
-
color: ${(props) => props.theme.textSecondary};
|
|
133
|
-
height: ${(props) => tableRowHeight[props.rowHeight]}rem;
|
|
134
|
-
gap: ${spacing.r8};
|
|
135
|
-
`;
|
|
136
127
|
export const SortCaret = ({ column, }) => {
|
|
137
128
|
return !column.disableSortBy ? (_jsx(SortCaretWrapper, { children: column.isSorted ? (column.isSortedDesc ? (_jsx(Icon, { name: "Sort-down" })) : (_jsx(Icon, { name: "Sort-up" }))) : (_jsx(SortIncentive, { children: _jsx(Icon, { name: "Sort" }) })) })) : null;
|
|
138
129
|
};
|
|
@@ -12,6 +12,7 @@ export declare const TabsContainer: import("styled-components").StyledComponent<
|
|
|
12
12
|
}, never>;
|
|
13
13
|
export declare const TabContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
14
14
|
tabContentColor?: string | undefined;
|
|
15
|
+
withoutPadding?: boolean | undefined;
|
|
15
16
|
}, never>;
|
|
16
17
|
export declare const ScrollableContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
17
18
|
export declare const TabsScroller: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledTabs.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tabsv2/StyledTabs.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,yGAGlB,CAAC;AACF,eAAO,MAAM,OAAO;;;;;;SAkDnB,CAAC;AACF,eAAO,MAAM,aAAa;;oBAER,MAAM;SAyBvB,CAAC;AACF,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"StyledTabs.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tabsv2/StyledTabs.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,yGAGlB,CAAC;AACF,eAAO,MAAM,OAAO;;;;;;SAkDnB,CAAC;AACF,eAAO,MAAM,aAAa;;oBAER,MAAM;SAyBvB,CAAC;AACF,eAAO,MAAM,UAAU;;;SAatB,CAAC;AACF,eAAO,MAAM,mBAAmB,yGAE/B,CAAC;AACF,eAAO,MAAM,YAAY,yGAYxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tabsv2/Tab.ts"],"names":[],"mappings":";AAEA,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3C,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACxB,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tabsv2/Tab.ts"],"names":[],"mappings":";AAEA,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3C,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACxB,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,iBAAS,GAAG,CAAC,CAAC,EAAE,QAAQ,QAQvB;AAED,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Element, ChildrenArray } from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
3
2
|
import { Tab } from './Tab';
|
|
3
|
+
import { TabProps } from './Tab';
|
|
4
4
|
type TabsProps = {
|
|
5
5
|
activeTabColor?: string;
|
|
6
6
|
activeTabSeparator?: string;
|
|
@@ -9,7 +9,7 @@ type TabsProps = {
|
|
|
9
9
|
tabContentColor?: string;
|
|
10
10
|
separatorColor?: string;
|
|
11
11
|
tabHoverColor?: string;
|
|
12
|
-
children:
|
|
12
|
+
children: ReactElement<TabProps>[];
|
|
13
13
|
className?: string;
|
|
14
14
|
};
|
|
15
15
|
export declare const TabsContext: React.Context<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabsv2.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tabsv2/Tabsv2.component.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Tabsv2.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tabsv2/Tabsv2.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAKZ,YAAY,EACb,MAAM,OAAO,CAAC;AAmBf,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAS,MAAM,OAAO,CAAC;AAKxC,KAAK,SAAS,GAAG;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,WAAW,wBAAgC,CAAC;AAMzD,iBAAS,IAAI,CAAC,EACZ,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,aAAa,EACb,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,SAAS,eAgMX;kBA3MQ,IAAI;;;AA+Mb,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
import React, { createContext, useEffect, useState, useCallback } from 'react';
|
|
2
|
+
import React, { createContext, useEffect, useState, useCallback, } from 'react';
|
|
4
3
|
import { TabBar, ScrollableContainer, TabContent, TabItem, TabsContainer, TabsScroller, } from './StyledTabs';
|
|
5
4
|
import { useHistory, useLocation, useRouteMatch, matchPath, Route, } from 'react-router-dom';
|
|
6
5
|
import { SecondaryText, BasicText, EmphaseText } from '../text/Text.component';
|
|
@@ -77,12 +76,12 @@ function Tabs({ activeTabColor, activeTabSeparator, tabLineColor, inactiveTabCol
|
|
|
77
76
|
event.preventDefault();
|
|
78
77
|
history.push(getPushHistoryPath(path, query));
|
|
79
78
|
}
|
|
80
|
-
}, ...childRest, children: [icon && _jsx(TabIcon, { label: label, children: icon }), isSelected ? (_jsx(BasicText, {
|
|
79
|
+
}, ...childRest, children: [icon && _jsx(TabIcon, { label: label, children: icon }), isSelected ? (_jsx(BasicText, { children: label })) : (_jsx(SecondaryText, { children: label })), textBadge && _jsx(EmphaseText, { children: textBadge })] }, index));
|
|
81
80
|
});
|
|
82
|
-
return (_jsx(TabsContext.Provider, { value: true, children: _jsxs(TabsContainer, { style: { containerType: 'size' }, className: ['sc-tabs', className].join(' '), tabLineColor: tabLineColor, separatorColor: separatorColor, ...rest, children: [_jsxs(ScrollableContainer, { children: [displayScroll.start && (_jsx(ScrollButton, { ref: scrollButtonStartRef, direction: "left", onClick: handleStartScrollClick })), _jsx(TabsScroller, { ref: tabsRef, onScroll: handleTabsScroll, children: _jsx(TabBar, { onKeyDown: handleKeyDown, ref: tabsListRef, className: "sc-tabs-bar", role: "tablist", children: tabItems }) }), displayScroll.end && (_jsx(ScrollButton, { ref: scrollButtonEndRef, direction: "right", onClick: handleEndScrollClick }))] }),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
return (_jsx(TabsContext.Provider, { value: true, children: _jsxs(TabsContainer, { style: { containerType: 'size' }, className: ['sc-tabs', className].join(' '), tabLineColor: tabLineColor, separatorColor: separatorColor, ...rest, children: [_jsxs(ScrollableContainer, { children: [displayScroll.start && (_jsx(ScrollButton, { ref: scrollButtonStartRef, direction: "left", onClick: handleStartScrollClick })), _jsx(TabsScroller, { ref: tabsRef, onScroll: handleTabsScroll, children: _jsx(TabBar, { onKeyDown: handleKeyDown, ref: tabsListRef, className: "sc-tabs-bar", role: "tablist", children: tabItems }) }), displayScroll.end && (_jsx(ScrollButton, { ref: scrollButtonEndRef, direction: "right", onClick: handleEndScrollClick }))] }), filteredTabsChildren.map((tab, index) => (_jsx(Route, { exact: tab.props.exact, sensitive: tab.props.sensitive, strict: tab.props.strict, path: tab.props.path.startsWith('/')
|
|
82
|
+
? tab.props.path
|
|
83
|
+
: url + '/' + tab.props.path, children: !tab.props.query ||
|
|
84
|
+
(tab.props.query && matchQuery(tab.props.query)) ? (_jsx(TabContent, { className: "sc-tabs-item-content", tabContentColor: tabContentColor, withoutPadding: tab.props.withoutPadding, children: tab.props.children })) : (_jsx(_Fragment, {})) }, index)))] }) }));
|
|
86
85
|
}
|
|
87
86
|
Tabs.Tab = Tab;
|
|
88
87
|
// re-export Tab
|
|
@@ -4,7 +4,7 @@ declare const useScrollingTabs: (selectedTabIndex: number | null | undefined) =>
|
|
|
4
4
|
scrollButtonEndRef: import("react").MutableRefObject<HTMLDivElement | null | undefined>;
|
|
5
5
|
tabsRef: import("react").MutableRefObject<any>;
|
|
6
6
|
tabsListRef: import("react").RefObject<HTMLDivElement>;
|
|
7
|
-
handleKeyDown: (event: KeyboardEvent) => void;
|
|
7
|
+
handleKeyDown: (event: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
8
8
|
handleTabsScroll: () => void;
|
|
9
9
|
handleStartScrollClick: () => void;
|
|
10
10
|
handleEndScrollClick: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollingTabs.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tabsv2/useScrollingTabs.ts"],"names":[],"mappings":";AAmIA,QAAA,MAAM,gBAAgB,qBAAsB,MAAM,GAAG,IAAI,GAAG,SAAS;;;;;2BA0JrC,
|
|
1
|
+
{"version":3,"file":"useScrollingTabs.d.ts","sourceRoot":"","sources":["../../../src/lib/components/tabsv2/useScrollingTabs.ts"],"names":[],"mappings":";AAmIA,QAAA,MAAM,gBAAgB,qBAAsB,MAAM,GAAG,IAAI,GAAG,SAAS;;;;;2BA0JrC,mBAAmB,CAAC,cAAc,CAAC;;;;;;;;CA+ClE,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Icon } from './icon/Icon.component';
|
|
3
|
+
import { Loader } from './loader/Loader.component';
|
|
4
|
+
import {
|
|
5
|
+
TableHeightKeyType,
|
|
6
|
+
TableLocalType,
|
|
7
|
+
tableRowHeight,
|
|
8
|
+
translatedMessages,
|
|
9
|
+
} from './tablev2/TableUtils';
|
|
10
|
+
import { Text } from './text/Text.component';
|
|
11
|
+
import { Box } from './box/Box';
|
|
12
|
+
import { spacing } from '../spacing';
|
|
13
|
+
|
|
14
|
+
const NoResult = styled(Box)<{ height: number | string }>`
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
align-items: center;
|
|
18
|
+
color: ${(props) => props.theme.textSecondary};
|
|
19
|
+
height: ${(props) => props.height}rem;
|
|
20
|
+
gap: ${spacing.r8};
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export type UnsuccessfulResultProps = {
|
|
24
|
+
name?: {
|
|
25
|
+
en: { singular: string; plural: string };
|
|
26
|
+
fr?: { singular: string; plural: string };
|
|
27
|
+
};
|
|
28
|
+
locale?: TableLocalType;
|
|
29
|
+
status: 'error' | 'loading' | 'idle' | 'noResult';
|
|
30
|
+
} & (
|
|
31
|
+
| { rowHeight: TableHeightKeyType; heightInRem?: never }
|
|
32
|
+
| { rowHeight?: never; heightInRem?: number | string }
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const UnsuccessfulResult = (props: UnsuccessfulResultProps) => {
|
|
36
|
+
const { heightInRem = 5, name, locale, status, rowHeight } = props;
|
|
37
|
+
const height = rowHeight ? tableRowHeight[rowHeight] : heightInRem;
|
|
38
|
+
return (
|
|
39
|
+
<NoResult height={height}>
|
|
40
|
+
{(status === 'loading' || status === 'idle') && <Loader />}
|
|
41
|
+
{status === 'error' && (
|
|
42
|
+
<Icon name="Exclamation-circle" color="statusWarning" />
|
|
43
|
+
)}
|
|
44
|
+
|
|
45
|
+
<Text color="textSecondary">
|
|
46
|
+
{translatedMessages(status, name, locale)}
|
|
47
|
+
</Text>
|
|
48
|
+
</NoResult>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -9,18 +9,14 @@ import {
|
|
|
9
9
|
} from 'react-window';
|
|
10
10
|
import {
|
|
11
11
|
convertRemToPixels,
|
|
12
|
-
translatedMessages,
|
|
13
12
|
TableHeightKeyType,
|
|
14
13
|
TableLocalType,
|
|
15
14
|
tableRowHeight,
|
|
16
15
|
} from './TableUtils';
|
|
17
16
|
import { useTableContext } from './Tablev2.component';
|
|
18
|
-
import { NoResult } from './Tablestyle';
|
|
19
|
-
import { Loader } from '../loader/Loader.component';
|
|
20
|
-
import { Text } from '../text/Text.component';
|
|
21
|
-
import { Icon } from '../icon/Icon.component';
|
|
22
17
|
import useSyncedScroll from './useSyncedScroll';
|
|
23
18
|
import { CSSProperties } from 'styled-components';
|
|
19
|
+
import { UnsuccessfulResult } from '../UnsuccessfulResult.component';
|
|
24
20
|
|
|
25
21
|
type VirtualizedRowsType<
|
|
26
22
|
DATA_ROW extends Record<string, unknown> = Record<string, unknown>,
|
|
@@ -141,26 +137,17 @@ export function TableRows<
|
|
|
141
137
|
return index;
|
|
142
138
|
}
|
|
143
139
|
|
|
144
|
-
if (status === 'idle' || status === 'loading') {
|
|
140
|
+
if (status === 'idle' || status === 'loading' || status === 'error') {
|
|
145
141
|
return (
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
if (status === 'error') {
|
|
155
|
-
return (
|
|
156
|
-
<NoResult rowHeight={rowHeight}>
|
|
157
|
-
<Icon name="Exclamation-circle" color="statusWarning" />
|
|
158
|
-
<Text color="textSecondary">
|
|
159
|
-
{translatedMessages('error', entityName, locale)}
|
|
160
|
-
</Text>
|
|
161
|
-
</NoResult>
|
|
142
|
+
<UnsuccessfulResult
|
|
143
|
+
name={entityName}
|
|
144
|
+
status={status}
|
|
145
|
+
locale={locale}
|
|
146
|
+
rowHeight={rowHeight}
|
|
147
|
+
/>
|
|
162
148
|
);
|
|
163
149
|
}
|
|
150
|
+
|
|
164
151
|
if (status === 'success' || status === undefined) {
|
|
165
152
|
if (typeof children === 'function') {
|
|
166
153
|
return children(
|
|
@@ -189,11 +176,7 @@ export function TableRows<
|
|
|
189
176
|
/>
|
|
190
177
|
);
|
|
191
178
|
} else {
|
|
192
|
-
return
|
|
193
|
-
<NoResult rowHeight={rowHeight}>
|
|
194
|
-
{translatedMessages('noResult', entityName, locale)}
|
|
195
|
-
</NoResult>
|
|
196
|
-
);
|
|
179
|
+
return <UnsuccessfulResult name={entityName} status="noResult" />;
|
|
197
180
|
}
|
|
198
181
|
}
|
|
199
182
|
|
|
@@ -59,7 +59,7 @@ export const tableRowHeight = {
|
|
|
59
59
|
h64: '4.572', //3 line
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
type TableMessagesType = 'error' | 'loading' | 'noResult';
|
|
62
|
+
type TableMessagesType = 'error' | 'loading' | 'idle' | 'noResult';
|
|
63
63
|
|
|
64
64
|
export const translatedMessages = (
|
|
65
65
|
type: TableMessagesType,
|
|
@@ -80,7 +80,7 @@ export const translatedMessages = (
|
|
|
80
80
|
}, please refresh the
|
|
81
81
|
page.`;
|
|
82
82
|
}
|
|
83
|
-
if (type === 'loading') {
|
|
83
|
+
if (type === 'loading' || type === 'idle') {
|
|
84
84
|
if (locale === 'fr') {
|
|
85
85
|
return `Chargement des ${entityName?.fr?.plural || 'données'}...`;
|
|
86
86
|
}
|
|
@@ -156,15 +156,6 @@ export const TooltipContent = styled.div`
|
|
|
156
156
|
min-width: 60px;
|
|
157
157
|
`;
|
|
158
158
|
|
|
159
|
-
export const NoResult = styled(Box)<{ rowHeight: TableHeightKeyType }>`
|
|
160
|
-
display: flex;
|
|
161
|
-
justify-content: center;
|
|
162
|
-
align-items: center;
|
|
163
|
-
color: ${(props) => props.theme.textSecondary};
|
|
164
|
-
height: ${(props) => tableRowHeight[props.rowHeight]}rem;
|
|
165
|
-
gap: ${spacing.r8};
|
|
166
|
-
`;
|
|
167
|
-
|
|
168
159
|
export const SortCaret = <
|
|
169
160
|
DATA_ROW extends Record<string, unknown> = Record<string, unknown>,
|
|
170
161
|
>({
|
|
@@ -84,9 +84,12 @@ export const TabsContainer = styled.div<{
|
|
|
84
84
|
margin-right: -1px;
|
|
85
85
|
}
|
|
86
86
|
`;
|
|
87
|
-
export const TabContent = styled.div<{
|
|
87
|
+
export const TabContent = styled.div<{
|
|
88
|
+
tabContentColor?: string;
|
|
89
|
+
withoutPadding?: boolean;
|
|
90
|
+
}>`
|
|
88
91
|
margin: 0;
|
|
89
|
-
padding: 0;
|
|
92
|
+
padding: ${(props) => (props.withoutPadding ? '0' : spacing.r16)};
|
|
90
93
|
display: block;
|
|
91
94
|
width: 100%;
|
|
92
95
|
height: 100%;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
useEffect,
|
|
4
|
+
useState,
|
|
5
|
+
useCallback,
|
|
6
|
+
ReactElement,
|
|
7
|
+
} from 'react';
|
|
4
8
|
import {
|
|
5
9
|
TabBar,
|
|
6
10
|
ScrollableContainer,
|
|
@@ -15,6 +19,7 @@ import {
|
|
|
15
19
|
useRouteMatch,
|
|
16
20
|
matchPath,
|
|
17
21
|
Route,
|
|
22
|
+
Switch,
|
|
18
23
|
} from 'react-router-dom';
|
|
19
24
|
import { SecondaryText, BasicText, EmphaseText } from '../text/Text.component';
|
|
20
25
|
import { ScrollButton } from './ScrollButton';
|
|
@@ -32,7 +37,7 @@ type TabsProps = {
|
|
|
32
37
|
tabContentColor?: string;
|
|
33
38
|
separatorColor?: string;
|
|
34
39
|
tabHoverColor?: string;
|
|
35
|
-
children:
|
|
40
|
+
children: ReactElement<TabProps>[];
|
|
36
41
|
className?: string;
|
|
37
42
|
};
|
|
38
43
|
export const TabsContext = createContext<boolean>(false);
|
|
@@ -60,9 +65,11 @@ function Tabs({
|
|
|
60
65
|
number | null | undefined
|
|
61
66
|
>(null);
|
|
62
67
|
const queryURL = new URLSearchParams(location.search);
|
|
63
|
-
const filteredTabsChildren = React.Children.toArray(
|
|
68
|
+
const filteredTabsChildren: ReactElement<TabProps>[] = React.Children.toArray(
|
|
69
|
+
children,
|
|
70
|
+
).filter(
|
|
64
71
|
(child) => React.isValidElement(child) && child.type === Tab,
|
|
65
|
-
);
|
|
72
|
+
) as ReactElement<TabProps>[];
|
|
66
73
|
|
|
67
74
|
const matchQuery = useCallback(
|
|
68
75
|
(query: Query): boolean => {
|
|
@@ -168,18 +175,17 @@ function Tabs({
|
|
|
168
175
|
>
|
|
169
176
|
{icon && <TabIcon label={label}>{icon}</TabIcon>}
|
|
170
177
|
{isSelected ? (
|
|
171
|
-
<BasicText
|
|
178
|
+
<BasicText>{label}</BasicText>
|
|
172
179
|
) : (
|
|
173
|
-
<SecondaryText
|
|
174
|
-
)}
|
|
175
|
-
{textBadge && (
|
|
176
|
-
<EmphaseText className="sc-tabs-item-icon">{textBadge}</EmphaseText>
|
|
180
|
+
<SecondaryText>{label}</SecondaryText>
|
|
177
181
|
)}
|
|
182
|
+
{textBadge && <EmphaseText>{textBadge}</EmphaseText>}
|
|
178
183
|
</TabItem>
|
|
179
184
|
);
|
|
180
185
|
});
|
|
181
186
|
return (
|
|
182
187
|
<TabsContext.Provider value={true}>
|
|
188
|
+
{/*@ts-expect-error containerType is not yet a valid prop for react */}
|
|
183
189
|
<TabsContainer
|
|
184
190
|
style={{ containerType: 'size' }}
|
|
185
191
|
className={['sc-tabs', className].join(' ')}
|
|
@@ -213,31 +219,33 @@ function Tabs({
|
|
|
213
219
|
/>
|
|
214
220
|
)}
|
|
215
221
|
</ScrollableContainer>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
tab.props.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
222
|
+
|
|
223
|
+
{filteredTabsChildren.map((tab, index) => (
|
|
224
|
+
<Route
|
|
225
|
+
exact={tab.props.exact}
|
|
226
|
+
sensitive={tab.props.sensitive}
|
|
227
|
+
strict={tab.props.strict}
|
|
228
|
+
path={
|
|
229
|
+
tab.props.path.startsWith('/')
|
|
230
|
+
? tab.props.path
|
|
231
|
+
: url + '/' + tab.props.path
|
|
232
|
+
}
|
|
233
|
+
key={index}
|
|
234
|
+
>
|
|
235
|
+
{!tab.props.query ||
|
|
236
|
+
(tab.props.query && matchQuery(tab.props.query)) ? (
|
|
237
|
+
<TabContent
|
|
238
|
+
className="sc-tabs-item-content"
|
|
239
|
+
tabContentColor={tabContentColor}
|
|
240
|
+
withoutPadding={tab.props.withoutPadding}
|
|
241
|
+
>
|
|
242
|
+
{tab.props.children}
|
|
243
|
+
</TabContent>
|
|
244
|
+
) : (
|
|
245
|
+
<></>
|
|
246
|
+
)}
|
|
247
|
+
</Route>
|
|
248
|
+
))}
|
|
241
249
|
</TabsContainer>
|
|
242
250
|
</TabsContext.Provider>
|
|
243
251
|
);
|
|
@@ -283,7 +283,7 @@ const useScrollingTabs = (selectedTabIndex: number | null | undefined) => {
|
|
|
283
283
|
scrollSelectedIntoView();
|
|
284
284
|
}, [scrollSelectedIntoView, selectedTabIndex]);
|
|
285
285
|
|
|
286
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
286
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
287
287
|
const list = tabsListRef.current;
|
|
288
288
|
const ownerDocument = (list && list.ownerDocument) || document;
|
|
289
289
|
const currentFocus = ownerDocument.activeElement;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import {
|
|
4
|
+
UnsuccessfulResult,
|
|
5
|
+
UnsuccessfulResultProps,
|
|
6
|
+
} from '../src/lib/components/UnsuccessfulResult.component.tsx';
|
|
7
|
+
|
|
8
|
+
type Story = StoryObj<UnsuccessfulResultProps>;
|
|
9
|
+
|
|
10
|
+
const meta: Meta<UnsuccessfulResultProps> = {
|
|
11
|
+
title: 'Components/NoResult',
|
|
12
|
+
component: UnsuccessfulResult,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
export const Loading: Story = {
|
|
18
|
+
render: () => {
|
|
19
|
+
return <UnsuccessfulResult status="loading" />;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const Error: Story = {
|
|
24
|
+
render: () => {
|
|
25
|
+
return <UnsuccessfulResult status="error" />;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const NoResult: Story = {
|
|
30
|
+
render: () => {
|
|
31
|
+
return <UnsuccessfulResult status="noResult" />;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -70,6 +70,8 @@ const columns: Column<Entry>[] = [
|
|
|
70
70
|
Header: 'First Name',
|
|
71
71
|
accessor: 'firstName',
|
|
72
72
|
cellStyle: {
|
|
73
|
+
width: 'unset',
|
|
74
|
+
flex: 2,
|
|
73
75
|
textAlign: 'left',
|
|
74
76
|
},
|
|
75
77
|
Cell: ({ value }) => {
|
|
@@ -81,6 +83,8 @@ const columns: Column<Entry>[] = [
|
|
|
81
83
|
Header: 'Last Name',
|
|
82
84
|
accessor: 'lastName',
|
|
83
85
|
cellStyle: {
|
|
86
|
+
width: 'unset',
|
|
87
|
+
flex: 2,
|
|
84
88
|
textAlign: 'left',
|
|
85
89
|
},
|
|
86
90
|
// disable the sorting on this column
|
|
@@ -90,7 +94,8 @@ const columns: Column<Entry>[] = [
|
|
|
90
94
|
Header: 'Age',
|
|
91
95
|
accessor: 'age',
|
|
92
96
|
cellStyle: {
|
|
93
|
-
width: '
|
|
97
|
+
width: 'unset',
|
|
98
|
+
flex: 1,
|
|
94
99
|
textAlign: 'left',
|
|
95
100
|
},
|
|
96
101
|
},
|
|
@@ -99,6 +104,8 @@ const columns: Column<Entry>[] = [
|
|
|
99
104
|
accessor: 'health',
|
|
100
105
|
sortType: 'health',
|
|
101
106
|
cellStyle: {
|
|
107
|
+
width: 'unset',
|
|
108
|
+
flex: 1,
|
|
102
109
|
textAlign: 'left',
|
|
103
110
|
},
|
|
104
111
|
},
|
|
@@ -119,26 +126,27 @@ export const SimpleContentTable = {
|
|
|
119
126
|
>
|
|
120
127
|
{location.search}
|
|
121
128
|
</span>
|
|
122
|
-
<Table
|
|
129
|
+
<Table
|
|
130
|
+
columns={columns}
|
|
131
|
+
data={data}
|
|
132
|
+
defaultSortingKey={'health'}
|
|
133
|
+
entityName={{
|
|
134
|
+
en: {
|
|
135
|
+
singular: 'user',
|
|
136
|
+
plural: 'users',
|
|
137
|
+
},
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
123
140
|
<div
|
|
124
141
|
style={{
|
|
125
142
|
margin: '16px 0',
|
|
126
143
|
}}
|
|
127
144
|
>
|
|
128
|
-
<Table.SearchWithQueryParams
|
|
129
|
-
displayedName={{
|
|
130
|
-
singular: 'person',
|
|
131
|
-
plural: 'persons',
|
|
132
|
-
}}
|
|
133
|
-
/>
|
|
145
|
+
<Table.SearchWithQueryParams />
|
|
134
146
|
</div>
|
|
135
147
|
<Table.SingleSelectableContent
|
|
136
148
|
rowHeight="h40"
|
|
137
149
|
separationLineVariant="backgroundLevel3"
|
|
138
|
-
backgroundVariant="backgroundLevel1"
|
|
139
|
-
children={(Rows) => {
|
|
140
|
-
return <>{Rows}</>;
|
|
141
|
-
}}
|
|
142
150
|
></Table.SingleSelectableContent>
|
|
143
151
|
</Table>
|
|
144
152
|
</>
|
|
@@ -158,7 +166,6 @@ export const SimpleContentTable = {
|
|
|
158
166
|
<Table.SingleSelectableContent
|
|
159
167
|
rowHeight="h32"
|
|
160
168
|
separationLineVariant="backgroundLevel3"
|
|
161
|
-
backgroundVariant="backgroundLevel1"
|
|
162
169
|
/>
|
|
163
170
|
</Table>
|
|
164
171
|
</div>
|
|
@@ -178,7 +185,6 @@ export const SimpleContentTable = {
|
|
|
178
185
|
<Table.SingleSelectableContent
|
|
179
186
|
rowHeight="h40"
|
|
180
187
|
separationLineVariant="backgroundLevel3"
|
|
181
|
-
backgroundVariant="backgroundLevel1"
|
|
182
188
|
selectedId={'Rodolph Yohann'}
|
|
183
189
|
onRowSelected={action('Table Row Clicked')}
|
|
184
190
|
/>
|
|
@@ -211,7 +217,6 @@ export const SimpleContentTable = {
|
|
|
211
217
|
<Table.SingleSelectableContent
|
|
212
218
|
rowHeight="h40"
|
|
213
219
|
separationLineVariant="backgroundLevel3"
|
|
214
|
-
backgroundVariant="backgroundLevel1"
|
|
215
220
|
onRowSelected={action('Table Row Clicked')}
|
|
216
221
|
/>
|
|
217
222
|
</Table>
|
|
@@ -233,7 +238,6 @@ export const SimpleContentTable = {
|
|
|
233
238
|
<Table.MultiSelectableContent
|
|
234
239
|
rowHeight="h40"
|
|
235
240
|
separationLineVariant="backgroundLevel3"
|
|
236
|
-
backgroundVariant="backgroundLevel1"
|
|
237
241
|
onMultiSelectionChanged={(rows) => {
|
|
238
242
|
console.log('Table.MultiSelectableContent selected row', rows);
|
|
239
243
|
}}
|
|
@@ -290,6 +294,8 @@ export const asyncTable = {
|
|
|
290
294
|
accessor: 'firstName',
|
|
291
295
|
cellStyle: {
|
|
292
296
|
textAlign: 'left',
|
|
297
|
+
width: 'unset',
|
|
298
|
+
flex: 1,
|
|
293
299
|
},
|
|
294
300
|
Cell: renderRowSubComponent,
|
|
295
301
|
},
|
|
@@ -298,14 +304,17 @@ export const asyncTable = {
|
|
|
298
304
|
accessor: 'lastName',
|
|
299
305
|
cellStyle: {
|
|
300
306
|
textAlign: 'left',
|
|
307
|
+
width: 'unset',
|
|
308
|
+
flex: 1,
|
|
301
309
|
},
|
|
302
310
|
},
|
|
303
311
|
{
|
|
304
312
|
Header: 'Age',
|
|
305
313
|
accessor: 'age',
|
|
306
314
|
cellStyle: {
|
|
307
|
-
width: '50px',
|
|
308
315
|
textAlign: 'left',
|
|
316
|
+
width: 'unset',
|
|
317
|
+
flex: 0.5,
|
|
309
318
|
},
|
|
310
319
|
},
|
|
311
320
|
{
|
|
@@ -314,6 +323,8 @@ export const asyncTable = {
|
|
|
314
323
|
sortType: 'health',
|
|
315
324
|
cellStyle: {
|
|
316
325
|
textAlign: 'left',
|
|
326
|
+
width: 'unset',
|
|
327
|
+
flex: 1,
|
|
317
328
|
},
|
|
318
329
|
},
|
|
319
330
|
];
|
|
@@ -333,13 +344,10 @@ export const asyncTable = {
|
|
|
333
344
|
data={data}
|
|
334
345
|
defaultSortingKey={'health'}
|
|
335
346
|
>
|
|
336
|
-
<Table.SearchWithQueryParams
|
|
337
|
-
displayedName={{ singular: 'user', plural: 'users' }}
|
|
338
|
-
></Table.SearchWithQueryParams>
|
|
347
|
+
<Table.SearchWithQueryParams></Table.SearchWithQueryParams>
|
|
339
348
|
<Table.SingleSelectableContent
|
|
340
349
|
rowHeight="h40"
|
|
341
350
|
separationLineVariant="backgroundLevel3"
|
|
342
|
-
backgroundVariant="backgroundLevel1"
|
|
343
351
|
selectedId={'Rodolph Yohann'}
|
|
344
352
|
onRowSelected={action('Table Row Clicked')}
|
|
345
353
|
/>
|
|
@@ -401,7 +409,6 @@ export const OnBottomCallback = {
|
|
|
401
409
|
<Table.SingleSelectableContent
|
|
402
410
|
rowHeight="h40"
|
|
403
411
|
separationLineVariant="backgroundLevel3"
|
|
404
|
-
backgroundVariant="backgroundLevel1"
|
|
405
412
|
/>
|
|
406
413
|
</Table>
|
|
407
414
|
</div>
|
|
@@ -554,14 +561,15 @@ export const EmptyTable = {
|
|
|
554
561
|
render: (args) => {
|
|
555
562
|
const { background } = args;
|
|
556
563
|
return (
|
|
557
|
-
<
|
|
558
|
-
<Table
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
564
|
+
<Box width="500px" height="200px">
|
|
565
|
+
<Table columns={columns} data={[]} defaultSortingKey={'firstName'}>
|
|
566
|
+
<Table.SingleSelectableContent
|
|
567
|
+
rowHeight="h40"
|
|
568
|
+
separationLineVariant={background}
|
|
569
|
+
onRowSelected={action('Table Row Clicked')}
|
|
570
|
+
/>
|
|
571
|
+
</Table>
|
|
572
|
+
</Box>
|
|
565
573
|
);
|
|
566
574
|
},
|
|
567
575
|
argTypes: {
|
|
@@ -595,7 +603,6 @@ export const LoadingTable = {
|
|
|
595
603
|
<Table.SingleSelectableContent
|
|
596
604
|
rowHeight="h40"
|
|
597
605
|
separationLineVariant="backgroundLevel3"
|
|
598
|
-
backgroundVariant="backgroundLevel1"
|
|
599
606
|
/>
|
|
600
607
|
</Table>
|
|
601
608
|
</Box>
|
|
@@ -621,7 +628,6 @@ export const ErrorTable = {
|
|
|
621
628
|
<Table.SingleSelectableContent
|
|
622
629
|
rowHeight="h40"
|
|
623
630
|
separationLineVariant="backgroundLevel4"
|
|
624
|
-
backgroundVariant="backgroundLevel1"
|
|
625
631
|
locale="en"
|
|
626
632
|
/>
|
|
627
633
|
</Table>
|
|
@@ -5,15 +5,23 @@ import { Wrapper, Title } from './common';
|
|
|
5
5
|
import { BrowserRouter } from 'react-router-dom';
|
|
6
6
|
import { brand, spacing } from '../src/lib/style/theme';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
-
import { useLocation } from 'react-router';
|
|
8
|
+
import { MemoryRouter, Route, useLocation } from 'react-router';
|
|
9
|
+
|
|
9
10
|
const Content = styled.div`
|
|
10
11
|
padding: ${spacing.sp24};
|
|
11
12
|
color: ${(props) => props.theme.textPrimary};
|
|
13
|
+
height: 100%;
|
|
12
14
|
`;
|
|
13
15
|
export default {
|
|
14
16
|
title: 'Components/Navigation/Tabs',
|
|
15
17
|
component: Tabs,
|
|
16
|
-
decorators: [
|
|
18
|
+
decorators: [
|
|
19
|
+
(story) => (
|
|
20
|
+
<BrowserRouter>
|
|
21
|
+
<Wrapper style={{ minHeight: '30rem' }}>{story()}</Wrapper>
|
|
22
|
+
</BrowserRouter>
|
|
23
|
+
),
|
|
24
|
+
],
|
|
17
25
|
argTypes: {
|
|
18
26
|
activeTabSeparator: {
|
|
19
27
|
control: {
|
|
@@ -79,44 +87,52 @@ const DefaultTabsDetails = (props) => {
|
|
|
79
87
|
<Title>
|
|
80
88
|
{location.pathname} / {location.search}
|
|
81
89
|
</Title>
|
|
82
|
-
<
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
90
|
+
<MemoryRouter initialEntries={['/path?tab=group']} initialIndex={0}>
|
|
91
|
+
<Route
|
|
92
|
+
path="/:path?"
|
|
93
|
+
render={() => (
|
|
94
|
+
<Tabs {...props}>
|
|
95
|
+
<Tab path="/path" label="Users" withoutPadding>
|
|
96
|
+
<Content>Users Content</Content>
|
|
97
|
+
</Tab>
|
|
98
|
+
<Tab
|
|
99
|
+
path="/path1"
|
|
100
|
+
query={{
|
|
101
|
+
tab: 'group',
|
|
102
|
+
}}
|
|
103
|
+
label="Groups"
|
|
104
|
+
>
|
|
105
|
+
{details()}
|
|
106
|
+
</Tab>
|
|
107
|
+
<Tab
|
|
108
|
+
path="/path1"
|
|
109
|
+
query={{
|
|
110
|
+
tab: 'role',
|
|
111
|
+
}}
|
|
112
|
+
label="Roles"
|
|
113
|
+
withoutPadding
|
|
114
|
+
>
|
|
115
|
+
<Content>Roles content</Content>
|
|
116
|
+
</Tab>
|
|
117
|
+
<Tab
|
|
118
|
+
path="/path1"
|
|
119
|
+
query={{
|
|
120
|
+
tab: 'policies',
|
|
121
|
+
}}
|
|
122
|
+
label="Policies"
|
|
123
|
+
>
|
|
124
|
+
<Content>Policies content</Content>
|
|
125
|
+
</Tab>
|
|
126
|
+
<Tab path="/path4" label="Storage Location">
|
|
127
|
+
<Content>Storage Location Content</Content>
|
|
128
|
+
</Tab>
|
|
129
|
+
<Tab path="/path5" label="Properties">
|
|
130
|
+
<Content>Properties Content</Content>
|
|
131
|
+
</Tab>
|
|
132
|
+
</Tabs>
|
|
133
|
+
)}
|
|
134
|
+
/>
|
|
135
|
+
</MemoryRouter>
|
|
120
136
|
</>
|
|
121
137
|
);
|
|
122
138
|
};
|