@scality/core-ui 0.161.0 → 0.162.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.
Files changed (136) hide show
  1. package/README.md +15 -15
  2. package/dist/components/accordion/Accordion.component.d.ts +0 -1
  3. package/dist/components/accordion/Accordion.component.d.ts.map +1 -1
  4. package/dist/components/barchartv2/Barchart.component.d.ts +55 -0
  5. package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -0
  6. package/dist/components/barchartv2/Barchart.component.js +76 -0
  7. package/dist/components/barchartv2/utils.d.ts +95 -0
  8. package/dist/components/barchartv2/utils.d.ts.map +1 -0
  9. package/dist/components/barchartv2/utils.js +305 -0
  10. package/dist/components/buttonv2/Buttonv2.component.d.ts +1 -1
  11. package/dist/components/buttonv2/Buttonv2.component.d.ts.map +1 -1
  12. package/dist/components/constrainedtext/Constrainedtext.component.d.ts +2 -1
  13. package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
  14. package/dist/components/constrainedtext/Constrainedtext.component.js +5 -4
  15. package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts +0 -1
  16. package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts.map +1 -1
  17. package/dist/components/date/FormattedDateTime.d.ts +1 -0
  18. package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
  19. package/dist/components/date/FormattedDateTime.js +5 -0
  20. package/dist/components/emptytable/Emptytable.component.d.ts +0 -1
  21. package/dist/components/emptytable/Emptytable.component.d.ts.map +1 -1
  22. package/dist/components/emptytable/Emptytable.component.js +1 -0
  23. package/dist/components/error-pages/ErrorPage401.component.d.ts +0 -1
  24. package/dist/components/error-pages/ErrorPage401.component.d.ts.map +1 -1
  25. package/dist/components/error-pages/ErrorPage404.component.d.ts +0 -1
  26. package/dist/components/error-pages/ErrorPage404.component.d.ts.map +1 -1
  27. package/dist/components/error-pages/ErrorPage500.component.d.ts +0 -1
  28. package/dist/components/error-pages/ErrorPage500.component.d.ts.map +1 -1
  29. package/dist/components/error-pages/ErrorPageAuth.component.d.ts.map +1 -1
  30. package/dist/components/form/Form.component.d.ts +2 -2
  31. package/dist/components/form/Form.component.d.ts.map +1 -1
  32. package/dist/components/infomessage/InfoMessage.component.d.ts +0 -1
  33. package/dist/components/infomessage/InfoMessage.component.d.ts.map +1 -1
  34. package/dist/components/lateralnavbarlayout/LateralNavbarLayout.component.d.ts.map +1 -1
  35. package/dist/components/layout/Layout.component.d.ts.map +1 -1
  36. package/dist/components/layout/v2/panels.d.ts.map +1 -1
  37. package/dist/components/modal/Modal.component.js +2 -2
  38. package/dist/components/navbar/Navbar.component.js +2 -2
  39. package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts +0 -1
  40. package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts.map +1 -1
  41. package/dist/components/searchinput/SearchInput.component.d.ts +1 -2
  42. package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -1
  43. package/dist/components/selectv2/Selectv2.component.d.ts +5 -5
  44. package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
  45. package/dist/components/statuswrapper/Statuswrapper.component.d.ts +0 -1
  46. package/dist/components/statuswrapper/Statuswrapper.component.d.ts.map +1 -1
  47. package/dist/components/tablev2/Search.js +2 -2
  48. package/dist/components/tablev2/SingleSelectableContent.d.ts +1 -2
  49. package/dist/components/tablev2/SingleSelectableContent.d.ts.map +1 -1
  50. package/dist/components/tablev2/TableCommon.d.ts +2 -2
  51. package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
  52. package/dist/components/tablev2/TableSync.d.ts +8 -0
  53. package/dist/components/tablev2/TableSync.d.ts.map +1 -0
  54. package/dist/components/tablev2/TableSync.js +11 -0
  55. package/dist/components/tablev2/Tablev2.component.d.ts +2 -1
  56. package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -1
  57. package/dist/components/tablev2/Tablev2.component.js +10 -9
  58. package/dist/components/tabsv2/ScrollButton.d.ts +1 -2
  59. package/dist/components/tabsv2/ScrollButton.d.ts.map +1 -1
  60. package/dist/components/tabsv2/ScrollButton.js +2 -2
  61. package/dist/components/tabsv2/Tabsv2.component.d.ts +2 -2
  62. package/dist/components/tabsv2/Tabsv2.component.d.ts.map +1 -1
  63. package/dist/components/tabsv2/Tabsv2.component.js +2 -2
  64. package/dist/components/text/Text.component.d.ts +0 -1
  65. package/dist/components/text/Text.component.d.ts.map +1 -1
  66. package/dist/components/textarea/TextArea.component.d.ts +3 -3
  67. package/dist/components/textarea/TextArea.component.d.ts.map +1 -1
  68. package/dist/components/textbadge/TextBadge.component.d.ts +0 -1
  69. package/dist/components/textbadge/TextBadge.component.d.ts.map +1 -1
  70. package/dist/components/toast/Toast.component.d.ts +1 -1
  71. package/dist/components/toast/Toast.component.d.ts.map +1 -1
  72. package/dist/components/toast/ToastProvider.d.ts.map +1 -1
  73. package/dist/components/vegachartv2/SyncedCursorCharts.d.ts +1 -2
  74. package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +1 -1
  75. package/dist/components/vegachartv2/VegaChartV2.component.d.ts +1 -2
  76. package/dist/components/vegachartv2/VegaChartV2.component.d.ts.map +1 -1
  77. package/dist/components/vegachartv2/VegaChartV2.component.js +2 -2
  78. package/dist/icons/branding.d.ts.map +1 -1
  79. package/dist/icons/scality-loading.d.ts.map +1 -1
  80. package/dist/next.d.ts +1 -0
  81. package/dist/next.d.ts.map +1 -1
  82. package/dist/next.js +1 -0
  83. package/dist/style/theme.d.ts +19 -0
  84. package/dist/style/theme.d.ts.map +1 -1
  85. package/dist/style/theme.js +18 -1
  86. package/package.json +6 -3
  87. package/setupTests.js +6 -0
  88. package/src/lib/components/accordion/Accordion.component.tsx +1 -1
  89. package/src/lib/components/barchartv2/Barchart.component.test.tsx +383 -0
  90. package/src/lib/components/barchartv2/Barchart.component.tsx +309 -0
  91. package/src/lib/components/barchartv2/utils.test.ts +782 -0
  92. package/src/lib/components/barchartv2/utils.ts +486 -0
  93. package/src/lib/components/buttonv2/Buttonv2.component.tsx +1 -1
  94. package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +22 -3
  95. package/src/lib/components/coreuithemeprovider/CoreUiThemeProvider.tsx +0 -1
  96. package/src/lib/components/date/FormattedDateTime.tsx +6 -0
  97. package/src/lib/components/emptytable/Emptytable.component.tsx +1 -1
  98. package/src/lib/components/error-pages/ErrorPage401.component.tsx +0 -1
  99. package/src/lib/components/error-pages/ErrorPage404.component.tsx +0 -1
  100. package/src/lib/components/error-pages/ErrorPage500.component.tsx +0 -1
  101. package/src/lib/components/error-pages/ErrorPageAuth.component.tsx +0 -1
  102. package/src/lib/components/form/Form.component.tsx +1 -1
  103. package/src/lib/components/infomessage/InfoMessage.component.tsx +0 -1
  104. package/src/lib/components/lateralnavbarlayout/LateralNavbarLayout.component.tsx +0 -1
  105. package/src/lib/components/layout/Layout.component.tsx +0 -1
  106. package/src/lib/components/layout/v2/panels.tsx +1 -1
  107. package/src/lib/components/modal/Modal.component.tsx +2 -2
  108. package/src/lib/components/navbar/Navbar.component.tsx +2 -2
  109. package/src/lib/components/scrollbarwrapper/ScrollbarWrapper.component.tsx +0 -1
  110. package/src/lib/components/searchinput/SearchInput.component.tsx +0 -1
  111. package/src/lib/components/selectv2/Selectv2.component.tsx +11 -9
  112. package/src/lib/components/sidebar/Sidebar.component.tsx +1 -1
  113. package/src/lib/components/statuswrapper/Statuswrapper.component.tsx +0 -1
  114. package/src/lib/components/tablev2/Search.tsx +2 -2
  115. package/src/lib/components/tablev2/SingleSelectableContent.tsx +2 -2
  116. package/src/lib/components/tablev2/TableCommon.tsx +1 -1
  117. package/src/lib/components/tablev2/TableSync.test.tsx +31 -0
  118. package/src/lib/components/tablev2/TableSync.tsx +36 -0
  119. package/src/lib/components/tablev2/Tablev2.component.tsx +11 -9
  120. package/src/lib/components/tabsv2/ScrollButton.tsx +2 -2
  121. package/src/lib/components/tabsv2/Tabsv2.component.tsx +6 -6
  122. package/src/lib/components/text/Text.component.tsx +4 -5
  123. package/src/lib/components/textarea/TextArea.component.tsx +3 -2
  124. package/src/lib/components/textbadge/TextBadge.component.tsx +0 -1
  125. package/src/lib/components/toast/Toast.component.tsx +1 -1
  126. package/src/lib/components/toast/ToastProvider.tsx +3 -1
  127. package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +1 -1
  128. package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +2 -2
  129. package/src/lib/icons/branding.tsx +0 -2
  130. package/src/lib/icons/scality-loading.tsx +0 -2
  131. package/src/lib/next.ts +5 -0
  132. package/src/lib/style/theme.ts +24 -1
  133. package/stories/BarChart/barchart.stories.tsx +655 -0
  134. package/stories/areachart.stories.tsx +0 -1
  135. package/stories/tablev2.stories.tsx +41 -0
  136. package/tsconfig.json +5 -2
@@ -1,4 +1,4 @@
1
- import React, {
1
+ import {
2
2
  createContext,
3
3
  useContext,
4
4
  useState,
@@ -8,6 +8,8 @@ import React, {
8
8
  ForwardRefExoticComponent,
9
9
  RefAttributes,
10
10
  useImperativeHandle,
11
+ ReactNode,
12
+ Ref,
11
13
  } from 'react';
12
14
  import { ScrollbarWrapper, Tooltip } from '../../index';
13
15
  import {
@@ -31,10 +33,10 @@ const NOPT_SEARCH = 8;
31
33
  export type OptionProps = {
32
34
  title?: string;
33
35
  disabled?: boolean;
34
- icon?: React.ReactNode;
35
- children?: React.ReactNode;
36
+ icon?: ReactNode;
37
+ children?: ReactNode;
36
38
  value: string;
37
- disabledReason?: React.ReactNode;
39
+ disabledReason?: ReactNode;
38
40
  };
39
41
  const usePreviousValue = (value) => {
40
42
  const ref = useRef(null);
@@ -335,7 +337,7 @@ export type SelectProps = {
335
337
  id: string;
336
338
  placeholder?: string;
337
339
  disabled?: boolean;
338
- children?: React.ReactNode;
340
+ children?: ReactNode;
339
341
  value?: string;
340
342
  onFocus?: (event: FocusEvent) => void;
341
343
  onBlur?: (event: FocusEvent) => void;
@@ -349,11 +351,11 @@ export type SelectProps = {
349
351
 
350
352
  type SelectOptionProps = {
351
353
  value: string;
352
- label: React.ReactNode;
354
+ label: ReactNode;
353
355
  isDisabled: boolean;
354
- icon?: React.ReactNode;
356
+ icon?: ReactNode;
355
357
  optionProps: any;
356
- disabledReason?: React.ReactNode;
358
+ disabledReason?: ReactNode;
357
359
  };
358
360
 
359
361
  type SelectComponentType<
@@ -388,7 +390,7 @@ function SelectBox<
388
390
  selectRef,
389
391
  ...rest
390
392
  }: SelectProps & {
391
- selectRef?: React.Ref<SelectRef<OptionType, IsMulti, GroupType>>;
393
+ selectRef?: Ref<SelectRef<OptionType, IsMulti, GroupType>>;
392
394
  }) {
393
395
  const [keyboardFocusEnabled, setKeyboardFocusEnabled] = useState(false);
394
396
  const [searchSelection, setSearchSelection] = useState('');
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import { useState } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
 
4
4
  import {
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  import styled, { css } from 'styled-components';
3
2
 
4
3
  import {
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import styled from 'styled-components';
2
+ import { useEffect } from 'react';
3
3
  import { useTableContext } from './Tablev2.component';
4
4
  import { SearchInput } from '../searchinput/SearchInput.component';
5
5
  import { Props } from '../searchinput/SearchInput.component';
@@ -74,7 +74,7 @@ export function TableSearch(props: SearchProps) {
74
74
  entityName = { en: { singular: 'result', plural: 'results' } },
75
75
  } = useTableContext();
76
76
  const totalDispayedRows = totalCount ? totalCount : rows.length;
77
- React.useEffect(() => {
77
+ useEffect(() => {
78
78
  setGlobalFilter(value);
79
79
  }, [value, setGlobalFilter, preGlobalFilteredRows]);
80
80
  return (
@@ -1,4 +1,4 @@
1
- import React, { memo, useEffect } from 'react';
1
+ import { memo, useEffect } from 'react';
2
2
  import { areEqual } from 'react-window';
3
3
  import { Row } from 'react-table';
4
4
  import { useTableContext } from './Tablev2.component';
@@ -32,7 +32,7 @@ export type SingleSelectableContentProps<
32
32
  customItemKey?: (index: number, data: DATA_ROW) => string;
33
33
  hasScrollbar?: boolean;
34
34
  isLoadingMoreItems?: boolean;
35
- children?: (rows: React.JSX.Element) => React.JSX.Element;
35
+ children?: (rows: JSX.Element) => JSX.Element;
36
36
  };
37
37
 
38
38
  export function SingleSelectableContent<
@@ -1,4 +1,4 @@
1
- import React, { ComponentType, LegacyRef, useCallback, useState } from 'react';
1
+ import { ComponentType, LegacyRef, useCallback, useState } from 'react';
2
2
  import { Row } from 'react-table';
3
3
  import AutoSizer from 'react-virtualized-auto-sizer';
4
4
  import {
@@ -0,0 +1,31 @@
1
+ import { fireEvent, render, screen } from '@testing-library/react';
2
+ import React from 'react';
3
+ import { TableSync } from './TableSync';
4
+ import { QueryClient, QueryClientProvider } from 'react-query';
5
+
6
+ describe('TableSync', () => {
7
+ it('should render correctly', () => {
8
+ const onSync = jest.fn();
9
+ render(
10
+ <QueryClientProvider client={new QueryClient()}>
11
+ <TableSync onSync={onSync} />
12
+ </QueryClientProvider>,
13
+ );
14
+
15
+ const button = screen.getByRole('button');
16
+ expect(button).toBeInTheDocument();
17
+ });
18
+
19
+ it('should call onSync when clicked', () => {
20
+ const onSync = jest.fn();
21
+ render(
22
+ <QueryClientProvider client={new QueryClient()}>
23
+ <TableSync onSync={onSync} />
24
+ </QueryClientProvider>,
25
+ );
26
+
27
+ const button = screen.getByRole('button');
28
+ fireEvent.click(button);
29
+ expect(onSync).toHaveBeenCalledTimes(1);
30
+ });
31
+ });
@@ -0,0 +1,36 @@
1
+ import { ButtonHTMLAttributes } from 'react';
2
+ import styled from 'styled-components';
3
+ import { Button } from '../buttonv2/Buttonv2.component';
4
+ import { Icon } from '../icon/Icon.component';
5
+
6
+ export type TableSyncProps = {
7
+ onSync: () => void;
8
+ tooltipOverlay?: string;
9
+ loading?: boolean;
10
+ } & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>;
11
+
12
+ const TableSyncContainer = styled.div`
13
+ display: flex;
14
+ align-items: center;
15
+ `;
16
+
17
+ export function TableSync({
18
+ onSync,
19
+ tooltipOverlay,
20
+ loading = false,
21
+ ...rest
22
+ }: TableSyncProps) {
23
+ return (
24
+ <TableSyncContainer>
25
+ <Button
26
+ icon={<Icon name="Sync" />}
27
+ tooltip={tooltipOverlay ? { overlay: tooltipOverlay } : undefined}
28
+ onClick={onSync}
29
+ aria-label="Synchronize table data"
30
+ role="button"
31
+ isLoading={loading}
32
+ {...rest}
33
+ />
34
+ </TableSyncContainer>
35
+ );
36
+ }
@@ -1,6 +1,6 @@
1
1
  /// <reference path="react-table-config.ts" />
2
- import * as React from 'react';
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 = React.createContext<TableContextType | null>(null);
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 = React.useContext(TableContext);
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 = React.useMemo(() => {
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 = React.useMemo(() => {
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] = React.useState<TableHeightKeyType>('h40');
221
+ const [rowHeight, setRowHeight] = useState<TableHeightKeyType>('h40');
221
222
 
222
- const [syncScrollListener, setSyncScrollListener] = React.useState<
223
+ const [syncScrollListener, setSyncScrollListener] = useState<
223
224
  ((event: Event) => void) | null
224
225
  >(null);
225
226
 
226
- const [hasScrollbar, setHasScrollbar] = React.useState<boolean>(false);
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,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 = React.forwardRef(({ direction, onClick }: Props, ref) => {
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 React, {
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>[] = React.Children.toArray(
70
+ const filteredTabsChildren: ReactElement<TabProps>[] = Children.toArray(
69
71
  children,
70
72
  ).filter(
71
- (child) => React.isValidElement(child) && child.type === Tab,
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
- : props.variant === 'Smaller'
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 React, {
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: React.ForwardedRef<RefType>,
81
+ ref: ForwardedRef<RefType>,
81
82
  ) {
82
83
  if (width || height) {
83
84
  return (
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import styled from 'styled-components';
3
2
  import { spacing } from '../../spacing';
4
3
  import { fontWeight } from '../../style/theme';
@@ -1,5 +1,5 @@
1
1
  import { motion } from 'framer-motion';
2
- import React, { ReactNode, useRef } from 'react';
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';
@@ -14,7 +14,9 @@ export const ToastContext = createContext<ToastContextType | undefined>(
14
14
  interface ToastProviderProps {
15
15
  children: ReactNode;
16
16
  }
17
- export const ToastProvider: React.FC<React.PropsWithChildren<ToastProviderProps>> = ({ children }) => {
17
+ export const ToastProvider: React.FC<
18
+ React.PropsWithChildren<ToastProviderProps>
19
+ > = ({ children }) => {
18
20
  const [toastProps, setToastProps] = useState<ToastContextState | null>(null);
19
21
 
20
22
  const showToast = (toastProps: ToastContextState) => {
@@ -1,4 +1,4 @@
1
- import React, { useState, createContext, useContext } from 'react';
1
+ import { useState, createContext, useContext } from 'react';
2
2
  export const SyncedCursorChartsContext = createContext<{
3
3
  cursorX: number;
4
4
  setCursorX: (cursorX: number) => void;
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck
2
- import React, { useEffect, useRef, useLayoutEffect, useMemo } from 'react';
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 = React.forwardRef(VegaChartInternal);
276
+ export const VegaChart = forwardRef(VegaChartInternal);
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  const Logo = () => (
4
2
  <svg
5
3
  xmlns="http://www.w3.org/2000/svg"
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  const LoaderIcon = () => (
4
2
  <svg
5
3
  xmlns="http://www.w3.org/2000/svg"
package/src/lib/next.ts CHANGED
@@ -16,3 +16,8 @@ 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';
@@ -149,10 +149,19 @@ export const coreUIAvailableThemes: Record<CoreUIThemeName, CoreUITheme> = {
149
149
  */
150
150
  export const defaultTheme = coreUIAvailableThemes;
151
151
 
152
- // Why use this and not directly coreUIAvailableThemes.darkRebrand ?
152
+ /**
153
+ * @deprecated
154
+ * Instead should use useTheme()
155
+ * import { useTheme } from 'styled-components';
156
+ * const theme = useTheme();
157
+ * e.g: color={theme.statusHealthy}
158
+ *
159
+ */
160
+
153
161
  export const brand = coreUIAvailableThemes.darkRebrand;
154
162
 
155
163
  export type ThemeColors = keyof CoreUITheme;
164
+
156
165
  // LineChart colors
157
166
  export const lineColor1 = '#A14FBF';
158
167
  export const lineColor2 = '#BE9A40';
@@ -162,6 +171,20 @@ export const lineColor5 = '#E3FF73';
162
171
  export const lineColor6 = '#BE2543';
163
172
  export const lineColor7 = '#FD8144';
164
173
  export const lineColor8 = '#F6B187';
174
+
175
+ export type ChartColors = keyof typeof chartColors;
176
+
177
+ export const chartColors = {
178
+ lineColor1,
179
+ lineColor2,
180
+ lineColor3,
181
+ lineColor4,
182
+ lineColor5,
183
+ lineColor6,
184
+ lineColor7,
185
+ lineColor8,
186
+ };
187
+
165
188
  export const fontSize = {
166
189
  smaller: '0.71rem',
167
190
  small: '0.85rem',