@scality/core-ui 0.161.0 → 0.163.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/README.md +15 -15
- package/dist/components/accordion/Accordion.component.d.ts +0 -1
- package/dist/components/accordion/Accordion.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.d.ts +53 -0
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -0
- package/dist/components/barchartv2/Barchart.component.js +86 -0
- package/dist/components/barchartv2/utils.d.ts +118 -0
- package/dist/components/barchartv2/utils.d.ts.map +1 -0
- package/dist/components/barchartv2/utils.js +337 -0
- package/dist/components/buttonv2/Buttonv2.component.d.ts +1 -1
- package/dist/components/buttonv2/Buttonv2.component.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegend.d.ts +8 -0
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -0
- package/dist/components/chartlegend/ChartLegend.js +65 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +17 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -0
- package/dist/components/chartlegend/ChartLegendWrapper.js +50 -0
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts +2 -1
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
- package/dist/components/constrainedtext/Constrainedtext.component.js +5 -4
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts +0 -1
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.d.ts +4 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +24 -1
- package/dist/components/date/FormattedDateTime.spec.js +12 -0
- package/dist/components/emptytable/Emptytable.component.d.ts +0 -1
- package/dist/components/emptytable/Emptytable.component.d.ts.map +1 -1
- package/dist/components/emptytable/Emptytable.component.js +1 -0
- package/dist/components/error-pages/ErrorPage401.component.d.ts +0 -1
- package/dist/components/error-pages/ErrorPage401.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPage404.component.d.ts +0 -1
- package/dist/components/error-pages/ErrorPage404.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPage500.component.d.ts +0 -1
- package/dist/components/error-pages/ErrorPage500.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPageAuth.component.d.ts.map +1 -1
- package/dist/components/form/Form.component.d.ts +2 -2
- package/dist/components/form/Form.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.d.ts +5 -5
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +33 -31
- package/dist/components/infomessage/InfoMessage.component.d.ts +0 -1
- package/dist/components/infomessage/InfoMessage.component.d.ts.map +1 -1
- package/dist/components/lateralnavbarlayout/LateralNavbarLayout.component.d.ts.map +1 -1
- package/dist/components/layout/Layout.component.d.ts.map +1 -1
- package/dist/components/layout/v2/panels.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +33 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +249 -0
- package/dist/components/modal/Modal.component.js +2 -2
- package/dist/components/navbar/Navbar.component.js +2 -2
- package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts +0 -1
- package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts.map +1 -1
- package/dist/components/searchinput/SearchInput.component.d.ts +1 -2
- package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.d.ts +5 -5
- package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.js +11 -6
- package/dist/components/statuswrapper/Statuswrapper.component.d.ts +0 -1
- package/dist/components/statuswrapper/Statuswrapper.component.d.ts.map +1 -1
- package/dist/components/steppers/Stepper.component.d.ts.map +1 -1
- package/dist/components/steppers/Stepper.component.js +9 -8
- package/dist/components/tablev2/Search.js +2 -2
- package/dist/components/tablev2/SingleSelectableContent.d.ts +1 -2
- package/dist/components/tablev2/SingleSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/TableCommon.d.ts +2 -2
- package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
- package/dist/components/tablev2/TableSync.d.ts +8 -0
- package/dist/components/tablev2/TableSync.d.ts.map +1 -0
- package/dist/components/tablev2/TableSync.js +11 -0
- package/dist/components/tablev2/Tablev2.component.d.ts +2 -1
- package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -1
- package/dist/components/tablev2/Tablev2.component.js +10 -9
- package/dist/components/tabsv2/ScrollButton.d.ts +1 -2
- package/dist/components/tabsv2/ScrollButton.d.ts.map +1 -1
- package/dist/components/tabsv2/ScrollButton.js +2 -2
- package/dist/components/tabsv2/Tabsv2.component.d.ts +2 -2
- package/dist/components/tabsv2/Tabsv2.component.d.ts.map +1 -1
- package/dist/components/tabsv2/Tabsv2.component.js +2 -2
- package/dist/components/text/Text.component.d.ts +0 -1
- package/dist/components/text/Text.component.d.ts.map +1 -1
- package/dist/components/textarea/TextArea.component.d.ts +3 -3
- package/dist/components/textarea/TextArea.component.d.ts.map +1 -1
- package/dist/components/textbadge/TextBadge.component.d.ts +0 -1
- package/dist/components/textbadge/TextBadge.component.d.ts.map +1 -1
- package/dist/components/toast/Toast.component.d.ts +1 -1
- package/dist/components/toast/Toast.component.d.ts.map +1 -1
- package/dist/components/toast/ToastProvider.d.ts.map +1 -1
- package/dist/components/toast/ToastProvider.js +4 -5
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts +1 -2
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +1 -1
- package/dist/components/vegachartv2/SyncedCursorCharts.js +3 -5
- package/dist/components/vegachartv2/VegaChartV2.component.d.ts +1 -2
- package/dist/components/vegachartv2/VegaChartV2.component.d.ts.map +1 -1
- package/dist/components/vegachartv2/VegaChartV2.component.js +2 -2
- package/dist/icons/branding.d.ts.map +1 -1
- package/dist/icons/scality-loading.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/next.d.ts +2 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +2 -0
- package/dist/style/theme.d.ts +20 -0
- package/dist/style/theme.d.ts.map +1 -1
- package/dist/style/theme.js +46 -1
- package/package.json +7 -4
- package/setupTests.js +6 -0
- package/src/lib/components/accordion/Accordion.component.tsx +1 -1
- package/src/lib/components/accordion/Accordion.test.tsx +7 -15
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +364 -0
- package/src/lib/components/barchartv2/Barchart.component.tsx +321 -0
- package/src/lib/components/barchartv2/utils.test.ts +899 -0
- package/src/lib/components/barchartv2/utils.ts +534 -0
- package/src/lib/components/buttonv2/Buttonv2.component.tsx +1 -1
- package/src/lib/components/chartlegend/ChartLegend.tsx +113 -0
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +85 -0
- package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +22 -3
- package/src/lib/components/coreuithemeprovider/CoreUiThemeProvider.tsx +0 -1
- package/src/lib/components/date/FormattedDateTime.spec.tsx +24 -0
- package/src/lib/components/date/FormattedDateTime.tsx +42 -2
- package/src/lib/components/emptytable/Emptytable.component.tsx +1 -1
- package/src/lib/components/error-pages/ErrorPage401.component.tsx +0 -1
- package/src/lib/components/error-pages/ErrorPage404.component.tsx +0 -1
- package/src/lib/components/error-pages/ErrorPage500.component.tsx +0 -1
- package/src/lib/components/error-pages/ErrorPageAuth.component.tsx +0 -1
- package/src/lib/components/form/Form.component.tsx +1 -1
- package/src/lib/components/healthselectorv2/HealthSelector.component.test.tsx +3 -3
- package/src/lib/components/icon/Icon.component.tsx +48 -60
- package/src/lib/components/infomessage/InfoMessage.component.tsx +0 -1
- package/src/lib/components/inlineinput/InlineInput.test.tsx +22 -19
- package/src/lib/components/inputlist/InputList.test.tsx +21 -19
- package/src/lib/components/lateralnavbarlayout/LateralNavbarLayout.component.tsx +0 -1
- package/src/lib/components/layout/Layout.component.tsx +0 -1
- package/src/lib/components/layout/v2/panels.tsx +1 -1
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +502 -0
- package/src/lib/components/modal/Modal.component.tsx +2 -2
- package/src/lib/components/navbar/Navbar.component.tsx +2 -2
- package/src/lib/components/scrollbarwrapper/ScrollbarWrapper.component.tsx +0 -1
- package/src/lib/components/searchinput/SearchInput.component.tsx +0 -1
- package/src/lib/components/searchinput/SearchInput.test.tsx +3 -7
- package/src/lib/components/selectv2/Selectv2.component.tsx +24 -14
- package/src/lib/components/selectv2/selectv2.test.tsx +62 -57
- package/src/lib/components/sidebar/Sidebar.component.tsx +1 -1
- package/src/lib/components/statuswrapper/Statuswrapper.component.tsx +0 -1
- package/src/lib/components/steppers/Stepper.component.tsx +10 -8
- package/src/lib/components/tablev2/Search.tsx +2 -2
- package/src/lib/components/tablev2/SingleSelectableContent.tsx +2 -2
- package/src/lib/components/tablev2/TableCommon.tsx +1 -1
- package/src/lib/components/tablev2/TableSync.test.tsx +28 -0
- package/src/lib/components/tablev2/TableSync.tsx +36 -0
- package/src/lib/components/tablev2/Tablev2.component.tsx +11 -9
- package/src/lib/components/tablev2/Tablev2.test.tsx +36 -37
- package/src/lib/components/tabsv2/ScrollButton.tsx +2 -2
- package/src/lib/components/tabsv2/Tabsv2.component.tsx +6 -6
- package/src/lib/components/text/Text.component.tsx +4 -5
- package/src/lib/components/textarea/TextArea.component.tsx +3 -2
- package/src/lib/components/textbadge/TextBadge.component.tsx +0 -1
- package/src/lib/components/toast/Toast.component.tsx +1 -1
- package/src/lib/components/toast/ToastProvider.tsx +17 -7
- package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +5 -7
- package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +2 -2
- package/src/lib/icons/branding.tsx +0 -2
- package/src/lib/icons/scality-loading.tsx +0 -2
- package/src/lib/index.ts +1 -0
- package/src/lib/next.ts +6 -0
- package/src/lib/style/theme.ts +53 -1
- package/stories/BarChart/barchart.stories.tsx +822 -0
- package/stories/areachart.stories.tsx +0 -1
- package/stories/format.mdx +4 -2
- package/stories/linetimeseriechart.stories.tsx +485 -0
- package/stories/tablev2.stories.tsx +41 -0
- package/tsconfig.json +5 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="react-table-config.ts" />
|
|
2
|
-
|
|
3
|
-
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import {
|
|
5
5
|
Column as TableColumn,
|
|
6
6
|
CellProps as TableCellProps,
|
|
@@ -33,6 +33,7 @@ import { TableWrapper, TooltipContent } from './Tablestyle';
|
|
|
33
33
|
import { compareHealth, TableHeightKeyType } from './TableUtils';
|
|
34
34
|
import { useCheckbox } from './useCheckbox';
|
|
35
35
|
import { Icon } from '../icon/Icon.component';
|
|
36
|
+
import { TableSync } from './TableSync';
|
|
36
37
|
|
|
37
38
|
type UpdateTableData<
|
|
38
39
|
DATA_ROW extends Record<string, unknown> = Record<string, unknown>,
|
|
@@ -110,12 +111,12 @@ type TableContextType<
|
|
|
110
111
|
setHasScrollbar: React.Dispatch<React.SetStateAction<boolean>>;
|
|
111
112
|
hasScrollbar?: boolean;
|
|
112
113
|
};
|
|
113
|
-
const TableContext =
|
|
114
|
+
const TableContext = createContext<TableContextType | null>(null);
|
|
114
115
|
|
|
115
116
|
export const useTableContext = <
|
|
116
117
|
DATA_ROW extends Record<string, unknown> = Record<string, unknown>,
|
|
117
118
|
>() => {
|
|
118
|
-
const tableProps =
|
|
119
|
+
const tableProps = useContext(TableContext);
|
|
119
120
|
|
|
120
121
|
if (!tableProps) {
|
|
121
122
|
throw new Error(
|
|
@@ -192,7 +193,7 @@ function Table<
|
|
|
192
193
|
...sortTypes,
|
|
193
194
|
};
|
|
194
195
|
|
|
195
|
-
const stringifyFilter =
|
|
196
|
+
const stringifyFilter = useMemo(() => {
|
|
196
197
|
return (rows: Row<object>[], columnIds: string[], value) => {
|
|
197
198
|
const filteredRows = rows.filter((row) => {
|
|
198
199
|
// we stringify the object to make sure we can match the value
|
|
@@ -204,7 +205,7 @@ function Table<
|
|
|
204
205
|
};
|
|
205
206
|
}, []);
|
|
206
207
|
|
|
207
|
-
const formattedInitiallySelectedRows =
|
|
208
|
+
const formattedInitiallySelectedRows = useMemo(() => {
|
|
208
209
|
if (initiallySelectedRowsIds) {
|
|
209
210
|
return Array.from(initiallySelectedRowsIds).reduce(
|
|
210
211
|
(accumulatedValue, currentValue) => ({
|
|
@@ -217,13 +218,13 @@ function Table<
|
|
|
217
218
|
return {};
|
|
218
219
|
}, []) as Record<IdType<DATA_ROW>, boolean>;
|
|
219
220
|
|
|
220
|
-
const [rowHeight, setRowHeight] =
|
|
221
|
+
const [rowHeight, setRowHeight] = useState<TableHeightKeyType>('h40');
|
|
221
222
|
|
|
222
|
-
const [syncScrollListener, setSyncScrollListener] =
|
|
223
|
+
const [syncScrollListener, setSyncScrollListener] = useState<
|
|
223
224
|
((event: Event) => void) | null
|
|
224
225
|
>(null);
|
|
225
226
|
|
|
226
|
-
const [hasScrollbar, setHasScrollbar] =
|
|
227
|
+
const [hasScrollbar, setHasScrollbar] = useState<boolean>(false);
|
|
227
228
|
|
|
228
229
|
const {
|
|
229
230
|
headerGroups,
|
|
@@ -341,4 +342,5 @@ Table.SingleSelectableContent = SingleSelectableContent;
|
|
|
341
342
|
Table.MultiSelectableContent = MultiSelectableContent;
|
|
342
343
|
Table.Search = Search;
|
|
343
344
|
Table.SearchWithQueryParams = SearchWithQueryParams;
|
|
345
|
+
Table.Sync = TableSync;
|
|
344
346
|
export { Table };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Table } from './Tablev2.component';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { render } from '@testing-library/react';
|
|
4
|
-
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
5
4
|
|
|
6
5
|
jest.mock('./TableUtils', () => ({
|
|
7
6
|
...jest.requireActual('./TableUtils'),
|
|
@@ -66,17 +65,17 @@ const columns = [
|
|
|
66
65
|
describe('TableV2', () => {
|
|
67
66
|
test('it should display all the data', async () => {
|
|
68
67
|
const { getAllByRole } = render(
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
<Table
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
</div>
|
|
78
|
-
</QueryClientProvider>,
|
|
68
|
+
<div>
|
|
69
|
+
<Table columns={columns} data={data} defaultSortingKey={'health'}>
|
|
70
|
+
<Table.SingleSelectableContent
|
|
71
|
+
rowHeight="h40"
|
|
72
|
+
separationLineVariant="backgroundLevel3"
|
|
73
|
+
/>
|
|
74
|
+
</Table>
|
|
75
|
+
</div>
|
|
79
76
|
);
|
|
77
|
+
await waitFor(() => screen.queryAllByRole('img', { hidden: true }));
|
|
78
|
+
|
|
80
79
|
// we check that the table is displaying all the data
|
|
81
80
|
const rows = getAllByRole('row');
|
|
82
81
|
expect(rows[4]).toHaveTextContent(/Ninette/i);
|
|
@@ -85,17 +84,17 @@ describe('TableV2', () => {
|
|
|
85
84
|
});
|
|
86
85
|
test('it should sort by defaultSortingKey', async () => {
|
|
87
86
|
const { getAllByRole } = render(
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
<Table
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
</div>
|
|
97
|
-
</QueryClientProvider>,
|
|
87
|
+
<div>
|
|
88
|
+
<Table columns={columns} data={data} defaultSortingKey={'firstName'}>
|
|
89
|
+
<Table.SingleSelectableContent
|
|
90
|
+
rowHeight="h40"
|
|
91
|
+
separationLineVariant="backgroundLevel3"
|
|
92
|
+
/>
|
|
93
|
+
</Table>
|
|
94
|
+
</div>
|
|
98
95
|
);
|
|
96
|
+
await waitFor(() => screen.queryAllByRole('img', { hidden: true }));
|
|
97
|
+
|
|
99
98
|
// we check that the table is displaying all the data
|
|
100
99
|
const rows = getAllByRole('row');
|
|
101
100
|
expect(rows[1]).toHaveTextContent(/ninette/i);
|
|
@@ -104,22 +103,22 @@ describe('TableV2', () => {
|
|
|
104
103
|
});
|
|
105
104
|
test('it should filterGlobally', async () => {
|
|
106
105
|
const { getAllByRole } = render(
|
|
107
|
-
<
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
</div>
|
|
121
|
-
</QueryClientProvider>,
|
|
106
|
+
<div>
|
|
107
|
+
<Table
|
|
108
|
+
columns={columns}
|
|
109
|
+
data={data}
|
|
110
|
+
defaultSortingKey={'firstName'}
|
|
111
|
+
globalFilter="an"
|
|
112
|
+
>
|
|
113
|
+
<Table.SingleSelectableContent
|
|
114
|
+
rowHeight="h40"
|
|
115
|
+
separationLineVariant="backgroundLevel3"
|
|
116
|
+
/>
|
|
117
|
+
</Table>
|
|
118
|
+
</div>
|
|
122
119
|
);
|
|
120
|
+
await waitFor(() => screen.queryAllByRole('img', { hidden: true }));
|
|
121
|
+
|
|
123
122
|
// we check that the table is displaying all the data
|
|
124
123
|
const rows = getAllByRole('row');
|
|
125
124
|
expect(rows[1]).toHaveTextContent(/an/i); //first name yoh-an-n
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import styled from 'styled-components';
|
|
3
2
|
import { zIndex } from '../../style/theme';
|
|
4
3
|
import { spacing } from '../../spacing';
|
|
5
4
|
import { getThemePropSelector } from '../../utils';
|
|
6
5
|
import { Icon } from '../icon/Icon.component';
|
|
6
|
+
import { forwardRef } from 'react';
|
|
7
7
|
|
|
8
8
|
const StyledScrollButton = styled.div`
|
|
9
9
|
display: flex;
|
|
@@ -28,7 +28,7 @@ type Props = {
|
|
|
28
28
|
direction: 'left' | 'right';
|
|
29
29
|
onClick: (arg0: React.SyntheticEvent<HTMLDivElement>) => void;
|
|
30
30
|
};
|
|
31
|
-
const ScrollButton =
|
|
31
|
+
const ScrollButton = forwardRef(({ direction, onClick }: Props, ref) => {
|
|
32
32
|
return (
|
|
33
33
|
// @ts-ignore
|
|
34
34
|
<StyledScrollButton direction={direction} onClick={onClick} ref={ref}>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
2
|
createContext,
|
|
3
3
|
ReactElement,
|
|
4
4
|
useCallback,
|
|
5
5
|
useEffect,
|
|
6
6
|
useState,
|
|
7
|
+
Children,
|
|
8
|
+
isValidElement,
|
|
7
9
|
} from 'react';
|
|
8
10
|
import {
|
|
9
11
|
matchPath,
|
|
@@ -65,10 +67,10 @@ function Tabs({
|
|
|
65
67
|
number | null | undefined
|
|
66
68
|
>(null);
|
|
67
69
|
const queryURL = new URLSearchParams(location.search);
|
|
68
|
-
const filteredTabsChildren: ReactElement<TabProps>[] =
|
|
70
|
+
const filteredTabsChildren: ReactElement<TabProps>[] = Children.toArray(
|
|
69
71
|
children,
|
|
70
72
|
).filter(
|
|
71
|
-
(child) =>
|
|
73
|
+
(child) => isValidElement(child) && child.type === Tab,
|
|
72
74
|
) as ReactElement<TabProps>[];
|
|
73
75
|
|
|
74
76
|
const matchQuery = useCallback(
|
|
@@ -234,9 +236,7 @@ function Tabs({
|
|
|
234
236
|
return (
|
|
235
237
|
<Route
|
|
236
238
|
key={index}
|
|
237
|
-
path={
|
|
238
|
-
tab.props.path.startsWith('/') ? '/' + path : path
|
|
239
|
-
}
|
|
239
|
+
path={tab.props.path.startsWith('/') ? '/' + path : path}
|
|
240
240
|
element={
|
|
241
241
|
<>
|
|
242
242
|
<TabContent
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import styled from 'styled-components';
|
|
3
2
|
import { spacing } from '../../spacing';
|
|
4
3
|
import { CoreUITheme } from '../../style/theme';
|
|
@@ -142,17 +141,17 @@ export const Text = styled.span<{
|
|
|
142
141
|
line-height: 1.5;
|
|
143
142
|
`
|
|
144
143
|
: props.variant === 'Large'
|
|
145
|
-
|
|
144
|
+
? `
|
|
146
145
|
font-size: 1.14rem;
|
|
147
146
|
line-height: 1.5;
|
|
148
147
|
`
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
: props.variant === 'Smaller'
|
|
149
|
+
? `
|
|
151
150
|
font-size: 0.71rem;
|
|
152
151
|
line-height: 1.4;
|
|
153
152
|
letter-spacing: 2%;// to be defined, percentage value is not valid
|
|
154
153
|
`
|
|
155
|
-
|
|
154
|
+
: `
|
|
156
155
|
font-size: 1rem;
|
|
157
156
|
line-height: ${spacing.r24};
|
|
158
157
|
`}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
2
|
CSSProperties,
|
|
3
3
|
forwardRef,
|
|
4
4
|
TextareaHTMLAttributes,
|
|
5
|
+
ForwardedRef,
|
|
5
6
|
} from 'react';
|
|
6
7
|
import styled, { css } from 'styled-components';
|
|
7
8
|
import { spacing } from '../../spacing';
|
|
@@ -77,7 +78,7 @@ const TextAreaContainer = styled.textarea<{
|
|
|
77
78
|
|
|
78
79
|
function TextAreaElement(
|
|
79
80
|
{ rows = 3, cols = 20, width, height, variant = 'code', ...rest }: Props,
|
|
80
|
-
ref:
|
|
81
|
+
ref: ForwardedRef<RefType>,
|
|
81
82
|
) {
|
|
82
83
|
if (width || height) {
|
|
83
84
|
return (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { motion } from 'framer-motion';
|
|
2
|
-
import
|
|
2
|
+
import { ReactNode, useRef } from 'react';
|
|
3
3
|
import { useTheme } from 'styled-components';
|
|
4
4
|
import { Box } from '../box/Box';
|
|
5
5
|
import { Button } from '../buttonv2/Buttonv2.component';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, createContext, useContext, useState } from 'react';
|
|
1
|
+
import { ReactNode, createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
2
2
|
import { Toast, ToastProps } from './Toast.component';
|
|
3
3
|
|
|
4
4
|
export type ToastContextState = Omit<ToastProps, 'onClose'>;
|
|
@@ -14,18 +14,27 @@ export const ToastContext = createContext<ToastContextType | undefined>(
|
|
|
14
14
|
interface ToastProviderProps {
|
|
15
15
|
children: ReactNode;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
export const ToastProvider: React.FC<
|
|
19
|
+
React.PropsWithChildren<ToastProviderProps>
|
|
20
|
+
> = ({ children }) => {
|
|
18
21
|
const [toastProps, setToastProps] = useState<ToastContextState | null>(null);
|
|
19
22
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const toastCtxValue = useMemo(
|
|
24
|
+
() => ({ showToast: setToastProps }),
|
|
25
|
+
[],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const closeToast = useCallback(
|
|
29
|
+
() => setToastProps(null),
|
|
30
|
+
[]
|
|
31
|
+
);
|
|
23
32
|
|
|
24
33
|
return (
|
|
25
|
-
<ToastContext.Provider value={
|
|
34
|
+
<ToastContext.Provider value={toastCtxValue}>
|
|
26
35
|
{children}
|
|
27
36
|
{toastProps && (
|
|
28
|
-
<Toast {...toastProps} onClose={
|
|
37
|
+
<Toast {...toastProps} onClose={closeToast} />
|
|
29
38
|
)}
|
|
30
39
|
</ToastContext.Provider>
|
|
31
40
|
);
|
|
@@ -36,5 +45,6 @@ export const useToast = () => {
|
|
|
36
45
|
if (!context) {
|
|
37
46
|
throw new Error('useToast must be used within a ToastProvider');
|
|
38
47
|
}
|
|
48
|
+
|
|
39
49
|
return context;
|
|
40
50
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, createContext, useContext, useMemo, useCallback } from 'react';
|
|
2
2
|
export const SyncedCursorChartsContext = createContext<{
|
|
3
3
|
cursorX: number;
|
|
4
4
|
setCursorX: (cursorX: number) => void;
|
|
@@ -17,13 +17,11 @@ export const useCursorX = (): {
|
|
|
17
17
|
};
|
|
18
18
|
export function SyncedCursorCharts({ children }: { children: JSX.Element }) {
|
|
19
19
|
const [cursorX, setCursorX] = useState(0);
|
|
20
|
+
|
|
21
|
+
const contextValue = useMemo(() => ({cursorX, setCursorX}), [cursorX]);
|
|
22
|
+
|
|
20
23
|
return (
|
|
21
|
-
<SyncedCursorChartsContext.Provider
|
|
22
|
-
value={{
|
|
23
|
-
cursorX,
|
|
24
|
-
setCursorX,
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
24
|
+
<SyncedCursorChartsContext.Provider value={contextValue}>
|
|
27
25
|
{children}
|
|
28
26
|
</SyncedCursorChartsContext.Provider>
|
|
29
27
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import
|
|
2
|
+
import { useEffect, useRef, useLayoutEffect, useMemo, forwardRef } from 'react';
|
|
3
3
|
import * as vega from 'vega';
|
|
4
4
|
import vegaEmbed, { Result } from 'vega-embed';
|
|
5
5
|
import { createGlobalStyle, css, useTheme } from 'styled-components';
|
|
@@ -273,4 +273,4 @@ function VegaChartInternal(
|
|
|
273
273
|
);
|
|
274
274
|
} // @ts-expect-error
|
|
275
275
|
|
|
276
|
-
export const VegaChart =
|
|
276
|
+
export const VegaChart = forwardRef(VegaChartInternal);
|
package/src/lib/index.ts
CHANGED
|
@@ -82,3 +82,4 @@ export { InfoMessage } from './components/infomessage/InfoMessage.component';
|
|
|
82
82
|
export { InputList } from './components/inputlist/InputList.component';
|
|
83
83
|
export { InlineInput } from './components/inlineinput/InlineInput';
|
|
84
84
|
export { UnsuccessfulResult } from './components/UnsuccessfulResult.component';
|
|
85
|
+
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
package/src/lib/next.ts
CHANGED
|
@@ -16,3 +16,9 @@ export { CoreUiThemeProvider } from './components/coreuithemeprovider/CoreUiThem
|
|
|
16
16
|
export { Box } from './components/box/Box';
|
|
17
17
|
export { Input } from './components/inputv2/inputv2';
|
|
18
18
|
export { Accordion } from './components/accordion/Accordion.component';
|
|
19
|
+
export {
|
|
20
|
+
Barchart,
|
|
21
|
+
BarchartSortFn,
|
|
22
|
+
BarchartTooltipFn,
|
|
23
|
+
} from './components/barchartv2/Barchart.component';
|
|
24
|
+
export { ChartLegendWrapper } from './components/chartlegend/ChartLegendWrapper';
|
package/src/lib/style/theme.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lighten, darken } from 'polished';
|
|
1
2
|
//== Colors
|
|
2
3
|
export const hotPink = '#E40046';
|
|
3
4
|
export const pink = '#EB4962';
|
|
@@ -149,10 +150,19 @@ export const coreUIAvailableThemes: Record<CoreUIThemeName, CoreUITheme> = {
|
|
|
149
150
|
*/
|
|
150
151
|
export const defaultTheme = coreUIAvailableThemes;
|
|
151
152
|
|
|
152
|
-
|
|
153
|
+
/**
|
|
154
|
+
* @deprecated
|
|
155
|
+
* Instead should use useTheme()
|
|
156
|
+
* import { useTheme } from 'styled-components';
|
|
157
|
+
* const theme = useTheme();
|
|
158
|
+
* e.g: color={theme.statusHealthy}
|
|
159
|
+
*
|
|
160
|
+
*/
|
|
161
|
+
|
|
153
162
|
export const brand = coreUIAvailableThemes.darkRebrand;
|
|
154
163
|
|
|
155
164
|
export type ThemeColors = keyof CoreUITheme;
|
|
165
|
+
|
|
156
166
|
// LineChart colors
|
|
157
167
|
export const lineColor1 = '#A14FBF';
|
|
158
168
|
export const lineColor2 = '#BE9A40';
|
|
@@ -162,6 +172,20 @@ export const lineColor5 = '#E3FF73';
|
|
|
162
172
|
export const lineColor6 = '#BE2543';
|
|
163
173
|
export const lineColor7 = '#FD8144';
|
|
164
174
|
export const lineColor8 = '#F6B187';
|
|
175
|
+
|
|
176
|
+
export type ChartColors = keyof typeof chartColors;
|
|
177
|
+
|
|
178
|
+
export const chartColors = {
|
|
179
|
+
lineColor1,
|
|
180
|
+
lineColor2,
|
|
181
|
+
lineColor3,
|
|
182
|
+
lineColor4,
|
|
183
|
+
lineColor5,
|
|
184
|
+
lineColor6,
|
|
185
|
+
lineColor7,
|
|
186
|
+
lineColor8,
|
|
187
|
+
};
|
|
188
|
+
|
|
165
189
|
export const fontSize = {
|
|
166
190
|
smaller: '0.71rem',
|
|
167
191
|
small: '0.85rem',
|
|
@@ -268,3 +292,31 @@ export const navbarItemWidth = '4.286rem';
|
|
|
268
292
|
//sidebar
|
|
269
293
|
export const sidebarItemHeight = spacing.sp40;
|
|
270
294
|
export const sidebarWidth = spacing.sp40;
|
|
295
|
+
|
|
296
|
+
// We use 8 main color from the palette and decline them (lighter/ darker) when we have more than 8 datasets
|
|
297
|
+
export const lineTimeSeriesColorRange = [
|
|
298
|
+
lineColor1,
|
|
299
|
+
lineColor2,
|
|
300
|
+
lineColor3,
|
|
301
|
+
lineColor4,
|
|
302
|
+
lineColor5,
|
|
303
|
+
lineColor6,
|
|
304
|
+
lineColor7,
|
|
305
|
+
lineColor8,
|
|
306
|
+
lighten(0.3, lineColor1),
|
|
307
|
+
lighten(0.3, lineColor2),
|
|
308
|
+
lighten(0.3, lineColor3),
|
|
309
|
+
lighten(0.3, lineColor4),
|
|
310
|
+
lighten(0.3, lineColor5),
|
|
311
|
+
lighten(0.3, lineColor6),
|
|
312
|
+
lighten(0.3, lineColor7),
|
|
313
|
+
lighten(0.3, lineColor8),
|
|
314
|
+
darken(0.2, lineColor1),
|
|
315
|
+
darken(0.2, lineColor2),
|
|
316
|
+
darken(0.2, lineColor3),
|
|
317
|
+
darken(0.2, lineColor4),
|
|
318
|
+
darken(0.3, lineColor5),
|
|
319
|
+
darken(0.3, lineColor6),
|
|
320
|
+
darken(0.3, lineColor7),
|
|
321
|
+
darken(0.3, lineColor8),
|
|
322
|
+
];
|