@scality/core-ui 0.165.0 → 0.167.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/.storybook/preview.js +6 -4
- package/README.md +27 -80
- package/dist/components/barchart/BarChart.component.d.ts +5 -0
- package/dist/components/barchart/BarChart.component.d.ts.map +1 -1
- package/dist/components/barchart/BarChart.component.js +5 -0
- package/dist/components/barchartv2/Barchart.component.d.ts +19 -0
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.js +31 -5
- package/dist/components/barchartv2/ChartTooltip.d.ts +18 -0
- package/dist/components/barchartv2/ChartTooltip.d.ts.map +1 -0
- package/dist/components/barchartv2/ChartTooltip.js +31 -0
- package/dist/components/barchartv2/utils.d.ts +0 -7
- package/dist/components/barchartv2/utils.d.ts.map +1 -1
- package/dist/components/barchartv2/utils.js +1 -29
- package/dist/components/button/Button.component.d.ts +2 -1
- package/dist/components/button/Button.component.d.ts.map +1 -1
- package/dist/components/button/Button.component.js +2 -1
- package/dist/components/chartlegend/ChartLegend.d.ts +9 -0
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegend.js +32 -9
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +3 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegendWrapper.js +18 -2
- package/dist/components/constants.d.ts +2 -0
- package/dist/components/constants.d.ts.map +1 -1
- package/dist/components/constants.js +6 -0
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts +3 -1
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
- package/dist/components/constrainedtext/Constrainedtext.component.js +2 -2
- package/dist/components/date/FormattedDateTime.d.ts +2 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +10 -0
- package/dist/components/icon/Icon.component.d.ts +9 -11
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +2 -0
- package/dist/components/linetemporalchart/ChartUtil.d.ts +3 -2
- package/dist/components/linetemporalchart/ChartUtil.d.ts.map +1 -1
- package/dist/components/linetemporalchart/ChartUtil.js +24 -20
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts +4 -0
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +1 -1
- package/dist/components/linetemporalchart/LineTemporalChart.component.js +4 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +4 -2
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +5 -7
- package/dist/components/text/Text.component.js +1 -1
- package/dist/components/toast/Toast.component.d.ts.map +1 -1
- package/dist/components/toast/Toast.component.js +24 -11
- package/dist/index.d.ts +1 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -11
- package/dist/next.d.ts +2 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -0
- package/jest.config.js +1 -0
- package/package.json +16 -38
- package/src/lib/components/barchart/BarChart.component.tsx +5 -0
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +99 -1
- package/src/lib/components/barchartv2/Barchart.component.tsx +39 -11
- package/src/lib/components/barchartv2/ChartTooltip.tsx +76 -0
- package/src/lib/components/barchartv2/utils.ts +2 -33
- package/src/lib/components/button/Button.component.tsx +2 -1
- package/src/lib/components/chartlegend/ChartLegend.test.tsx +235 -0
- package/src/lib/components/chartlegend/ChartLegend.tsx +36 -8
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +67 -29
- package/src/lib/components/constants.ts +11 -0
- package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +5 -2
- package/src/lib/components/date/FormattedDateTime.tsx +15 -1
- package/src/lib/components/icon/Icon.component.tsx +12 -1
- package/src/lib/components/linetemporalchart/ChartUtil.test.ts +23 -35
- package/src/lib/components/linetemporalchart/ChartUtil.ts +32 -26
- package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +19 -15
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +13 -11
- package/src/lib/components/selectv2/selectv2.test.tsx +1 -1
- package/src/lib/components/text/Text.component.tsx +1 -1
- package/src/lib/components/toast/Toast.component.tsx +27 -19
- package/src/lib/components/toast/useMutationsHandler.test.tsx +22 -32
- package/src/lib/index.ts +6 -11
- package/src/lib/next.ts +2 -0
- package/stories/barchart.stories.tsx +1 -1
- package/stories/card.stories.tsx +7 -5
- package/stories/constrainedtext.stories.tsx +4 -1
- package/stories/controls.ts +19 -20
- package/stories/linecharttemporal.stories.tsx +1 -1
- package/stories/linetimeseriechart.stories.tsx +79 -25
- package/stories/navbar.stories.tsx +103 -0
- package/stories/tabsv2.stories.tsx +51 -56
- package/dist/components/areachart/AreaChart.component.d.ts +0 -13
- package/dist/components/areachart/AreaChart.component.d.ts.map +0 -1
- package/dist/components/areachart/AreaChart.component.js +0 -27
- package/dist/components/chips/Chips.component.d.ts +0 -21
- package/dist/components/chips/Chips.component.d.ts.map +0 -1
- package/dist/components/chips/Chips.component.js +0 -105
- package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts +0 -10
- package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts.map +0 -1
- package/dist/components/cloudprogressbar/CloudProgressBar.component.js +0 -38
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts +0 -9
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts.map +0 -1
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.js +0 -44
- package/dist/components/linechart/LineChart.component.d.ts +0 -21
- package/dist/components/linechart/LineChart.component.d.ts.map +0 -1
- package/dist/components/linechart/LineChart.component.js +0 -109
- package/dist/components/multiselect/MultiSelect.component.d.ts +0 -28
- package/dist/components/multiselect/MultiSelect.component.d.ts.map +0 -1
- package/dist/components/multiselect/MultiSelect.component.js +0 -73
- package/dist/components/select/Select.component.d.ts +0 -14
- package/dist/components/select/Select.component.d.ts.map +0 -1
- package/dist/components/select/Select.component.js +0 -71
- package/dist/components/spacedbox/SpacedBox.d.ts +0 -34
- package/dist/components/spacedbox/SpacedBox.d.ts.map +0 -1
- package/dist/components/spacedbox/SpacedBox.js +0 -64
- package/dist/components/sparkline/SparkLine.component.d.ts +0 -18
- package/dist/components/sparkline/SparkLine.component.d.ts.map +0 -1
- package/dist/components/sparkline/SparkLine.component.js +0 -148
- package/dist/components/vegachart/VegaChart.component.d.ts +0 -13
- package/dist/components/vegachart/VegaChart.component.d.ts.map +0 -1
- package/dist/components/vegachart/VegaChart.component.js +0 -120
- package/plopfile.js +0 -38
- package/src/lib/components/areachart/AreaChart.component.tsx +0 -49
- package/src/lib/components/chips/Chips.component.tsx +0 -169
- package/src/lib/components/cloudprogressbar/CloudProgressBar.component.tsx +0 -105
- package/src/lib/components/collapsiblepanel/CollapsiblePanel.component.tsx +0 -77
- package/src/lib/components/linechart/LineChart.component.tsx +0 -152
- package/src/lib/components/multiselect/MultiSelect.component.tsx +0 -158
- package/src/lib/components/select/Select.component.tsx +0 -98
- package/src/lib/components/spacedbox/SpacedBox.ts +0 -116
- package/src/lib/components/sparkline/SparkLine.component.tsx +0 -176
- package/src/lib/components/vegachart/VegaChart.component.tsx +0 -146
- package/stories/areachart.stories.tsx +0 -120
- package/stories/chips.stories.tsx +0 -107
- package/stories/cloudprogressbar.stories.tsx +0 -93
- package/stories/collapsiblepanel.stories.tsx +0 -57
- package/stories/data/areachart.ts +0 -122
- package/stories/data/sparklinechart.ts +0 -164
- package/stories/linechart.stories.tsx +0 -319
- package/stories/multiselect.stories.tsx +0 -126
- package/stories/select.stories.tsx +0 -52
- package/stories/sparkline.stories.tsx +0 -85
- package/stories/vegachart.stories.tsx +0 -98
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { Banner } from './components/banner/Banner.component';
|
|
2
2
|
export { Breadcrumb } from './components/breadcrumb/Breadcrumb.component';
|
|
3
|
-
export { Button } from './components/button/Button.component';
|
|
4
3
|
export { Checkbox } from './components/checkbox/Checkbox.component';
|
|
5
|
-
export { Chips } from './components/chips/Chips.component';
|
|
6
4
|
export { Dropdown } from './components/dropdown/Dropdown.component';
|
|
7
5
|
export { LOADER_SIZE, STATUS_CRITICAL, STATUS_WARNING, STATUS_SUCCESS, STATUS_HEALTHY, STATUS_INFO, STATUS_UNKNOWN, STATUS_NONE, } from './components/constants';
|
|
8
6
|
export { Layout } from './components/layout/Layout.component';
|
|
@@ -11,22 +9,14 @@ export { Modal } from './components/modal/Modal.component';
|
|
|
11
9
|
export { Navbar } from './components/navbar/Navbar.component';
|
|
12
10
|
export { Notifications } from './components/notifications/Notifications.component';
|
|
13
11
|
export { SearchInput } from './components/searchinput/SearchInput.component';
|
|
14
|
-
export { Select } from './components/select/Select.component';
|
|
15
12
|
export { Sidebar } from './components/sidebar/Sidebar.component';
|
|
16
13
|
export { Steppers } from './components/steppers/Steppers.component';
|
|
17
14
|
export { Toggle } from './components/toggle/Toggle.component';
|
|
18
15
|
export { Tooltip } from './components/tooltip/Tooltip.component';
|
|
19
|
-
export { MultiSelect } from './components/multiselect/MultiSelect.component';
|
|
20
|
-
export { VegaChart } from './components/vegachart/VegaChart.component';
|
|
21
|
-
export { LineChart } from './components/linechart/LineChart.component';
|
|
22
16
|
export { ProgressBar } from './components/progressbar/ProgressBar.component';
|
|
23
17
|
export { TextArea } from './components/textarea/TextArea.component';
|
|
24
|
-
export { CloudProgressBar } from './components/cloudprogressbar/CloudProgressBar.component';
|
|
25
|
-
export { Sparkline } from './components/sparkline/SparkLine.component';
|
|
26
18
|
export { BarChart } from './components/barchart/BarChart.component';
|
|
27
19
|
export { CircularProgressBar } from './components/circularprogressbar/CircularProgressBar.component';
|
|
28
|
-
export { AreaChart } from './components/areachart/AreaChart.component';
|
|
29
|
-
export { CollapsiblePanel } from './components/collapsiblepanel/CollapsiblePanel.component';
|
|
30
20
|
export { LateralNavbarLayout } from './components/lateralnavbarlayout/LateralNavbarLayout.component';
|
|
31
21
|
export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBar.component';
|
|
32
22
|
export { ConstrainedText } from './components/constrainedtext/Constrainedtext.component';
|
|
@@ -38,7 +28,6 @@ export { ErrorPage404 } from './components/error-pages/ErrorPage404.component';
|
|
|
38
28
|
export { ErrorPage500 } from './components/error-pages/ErrorPage500.component';
|
|
39
29
|
export { ErrorPageAuth } from './components/error-pages/ErrorPageAuth.component';
|
|
40
30
|
export { TextBadge } from './components/textbadge/TextBadge.component';
|
|
41
|
-
export { SpacedBox } from './components/spacedbox/SpacedBox';
|
|
42
31
|
export { Layout as Layout2 } from './components/layout/v2';
|
|
43
32
|
export { TwoPanelLayout } from './components/layout/v2/panels';
|
|
44
33
|
export { AppContainer } from './components/layout/v2/AppContainer';
|
package/dist/next.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ export { Box } from './components/box/Box';
|
|
|
14
14
|
export { Input } from './components/inputv2/inputv2';
|
|
15
15
|
export { Accordion } from './components/accordion/Accordion.component';
|
|
16
16
|
export { Barchart, BarchartSortFn, BarchartTooltipFn, } from './components/barchartv2/Barchart.component';
|
|
17
|
+
export { ChartTooltip } from './components/barchartv2/ChartTooltip';
|
|
17
18
|
export { ChartLegendWrapper } from './components/chartlegend/ChartLegendWrapper';
|
|
18
19
|
export { ChartLegend } from './components/chartlegend/ChartLegend';
|
|
19
20
|
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
|
21
|
+
export { CoreUITheme } from './style/theme';
|
|
20
22
|
//# sourceMappingURL=next.d.ts.map
|
package/dist/next.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../src/lib/next.ts"],"names":[],"mappings":"AAAA,OAAO,2CAA2C,CAAC;AACnD,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4DAA4D,CAAC;AAC/F,OAAO,EACL,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC;AACvE,OAAO,EACL,QAAQ,EACR,cAAc,EACd,iBAAiB,GAClB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC"}
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../src/lib/next.ts"],"names":[],"mappings":"AAAA,OAAO,2CAA2C,CAAC;AACnD,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4DAA4D,CAAC;AAC/F,OAAO,EACL,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC;AACvE,OAAO,EACL,QAAQ,EACR,cAAc,EACd,iBAAiB,GAClB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/next.js
CHANGED
|
@@ -14,6 +14,7 @@ export { Box } from './components/box/Box';
|
|
|
14
14
|
export { Input } from './components/inputv2/inputv2';
|
|
15
15
|
export { Accordion } from './components/accordion/Accordion.component';
|
|
16
16
|
export { Barchart, } from './components/barchartv2/Barchart.component';
|
|
17
|
+
export { ChartTooltip } from './components/barchartv2/ChartTooltip';
|
|
17
18
|
export { ChartLegendWrapper } from './components/chartlegend/ChartLegendWrapper';
|
|
18
19
|
export { ChartLegend } from './components/chartlegend/ChartLegend';
|
|
19
20
|
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scality/core-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.167.0",
|
|
4
4
|
"description": "Scality common React component library",
|
|
5
5
|
"author": "Scality Engineering",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -19,12 +19,10 @@
|
|
|
19
19
|
"lint": "eslint src/* --ext .js --no-error-on-unmatched-pattern",
|
|
20
20
|
"prepare": "npm run build",
|
|
21
21
|
"postbuild": "npm run copy-files",
|
|
22
|
-
"plop": "plop",
|
|
23
22
|
"test": "jest",
|
|
24
23
|
"storybook": "storybook dev -p 3000",
|
|
25
24
|
"build-storybook": "storybook build",
|
|
26
|
-
"storybook:deploy": "storybook-to-ghpages"
|
|
27
|
-
"preview": "jest-preview"
|
|
25
|
+
"storybook:deploy": "storybook-to-ghpages"
|
|
28
26
|
},
|
|
29
27
|
"keywords": [],
|
|
30
28
|
"browserslist": [
|
|
@@ -40,23 +38,19 @@
|
|
|
40
38
|
"@babel/preset-react": "^7.16.7",
|
|
41
39
|
"@babel/preset-typescript": "^7.16.7",
|
|
42
40
|
"@chromatic-com/storybook": "^1.9.0",
|
|
43
|
-
"@storybook/addon-actions": "^8.
|
|
44
|
-
"@storybook/addon-essentials": "^8.
|
|
45
|
-
"@storybook/addon-
|
|
46
|
-
"@storybook/addon-
|
|
47
|
-
"@storybook/addon-storysource": "^8.3.6",
|
|
41
|
+
"@storybook/addon-actions": "^8.6.14",
|
|
42
|
+
"@storybook/addon-essentials": "^8.6.14",
|
|
43
|
+
"@storybook/addon-mdx-gfm": "^8.6.14",
|
|
44
|
+
"@storybook/addon-storysource": "^8.6.14",
|
|
48
45
|
"@storybook/addon-webpack5-compiler-swc": "^1.0.5",
|
|
49
|
-
"@storybook/blocks": "^8.
|
|
50
|
-
"@storybook/manager-api": "^8.
|
|
51
|
-
"@storybook/react": "^8.
|
|
52
|
-
"@storybook/react-webpack5": "^8.
|
|
53
|
-
"@storybook/
|
|
54
|
-
"@storybook/theming": "^8.3.6",
|
|
46
|
+
"@storybook/blocks": "^8.6.14",
|
|
47
|
+
"@storybook/manager-api": "^8.6.14",
|
|
48
|
+
"@storybook/react": "^8.6.14",
|
|
49
|
+
"@storybook/react-webpack5": "^8.6.14",
|
|
50
|
+
"@storybook/theming": "^8.6.14",
|
|
55
51
|
"@testing-library/jest-dom": "^5.14.1",
|
|
56
52
|
"@testing-library/react": "^15.0.7",
|
|
57
|
-
"@testing-library/react-hooks": "^8.0.1",
|
|
58
53
|
"@testing-library/user-event": "^13.5.0",
|
|
59
|
-
"@types/jest": "^27.5.0",
|
|
60
54
|
"@types/react": "^18.3.12",
|
|
61
55
|
"@types/react-dom": "^18.3.1",
|
|
62
56
|
"@types/react-router": "^5.1.20",
|
|
@@ -70,21 +64,17 @@
|
|
|
70
64
|
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
71
65
|
"@typescript-eslint/parser": "^6.12.0",
|
|
72
66
|
"copyfiles": "^2.4.1",
|
|
73
|
-
"cross-env": "^7.0.3",
|
|
74
|
-
"csstype": "^3.1.0",
|
|
75
67
|
"eslint": "^8.15.0",
|
|
76
68
|
"eslint-config-react-app": "^7.0.1",
|
|
77
69
|
"eslint-plugin-storybook": "^0.10.1",
|
|
78
70
|
"husky": "^3.0.5",
|
|
79
|
-
"
|
|
80
|
-
"jest": "^26.6.3",
|
|
71
|
+
"jest": "^30.0.5",
|
|
81
72
|
"jest-canvas-mock": "^2.3.1",
|
|
82
|
-
"jest-
|
|
83
|
-
"plop": "^2.4.0",
|
|
73
|
+
"jest-environment-jsdom": "^30.0.5",
|
|
84
74
|
"regenerator-runtime": "^0.13.7",
|
|
85
75
|
"rimraf": "^3.0.0",
|
|
86
76
|
"source-map-explorer": "^2.0.1",
|
|
87
|
-
"storybook": "^8.
|
|
77
|
+
"storybook": "^8.6.14",
|
|
88
78
|
"typescript": "^5.3.2"
|
|
89
79
|
},
|
|
90
80
|
"husky": {
|
|
@@ -92,15 +82,6 @@
|
|
|
92
82
|
"pre-commit": "npm run lint"
|
|
93
83
|
}
|
|
94
84
|
},
|
|
95
|
-
"jest": {
|
|
96
|
-
"setupFiles": [
|
|
97
|
-
"jest-canvas-mock"
|
|
98
|
-
],
|
|
99
|
-
"transform": {
|
|
100
|
-
"^.+\\.[tj]sx?$": "babel-jest",
|
|
101
|
-
"^.+\\.mdx?$": "@storybook/addon-docs/jest-transform-mdx"
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
85
|
"dependencies": {
|
|
105
86
|
"@floating-ui/dom": "^1.6.3",
|
|
106
87
|
"@floating-ui/react": "^0.26.28",
|
|
@@ -112,19 +93,16 @@
|
|
|
112
93
|
"@js-temporal/polyfill": "^0.4.4",
|
|
113
94
|
"@storybook/preview-api": "^8.3.6",
|
|
114
95
|
"downshift": "^7.0.5",
|
|
115
|
-
"framer-motion": "^4.1.17",
|
|
116
96
|
"polished": "3.4.1",
|
|
117
97
|
"pretty-bytes": "^5.6.0",
|
|
118
|
-
"react-debounce-input": "3.2.2",
|
|
119
98
|
"react-dropzone": "^14.2.3",
|
|
120
99
|
"react-hook-form": "^7.49.2",
|
|
121
100
|
"react-query": "^3.34.0",
|
|
122
|
-
"react-router": "7.
|
|
123
|
-
"react-router-dom": "7.
|
|
101
|
+
"react-router": "7.8.1",
|
|
102
|
+
"react-router-dom": "7.8.1",
|
|
124
103
|
"react-select": "4.3.1",
|
|
125
104
|
"react-table": "^7.7.0",
|
|
126
105
|
"react-test-renderer": "^18.3.1",
|
|
127
|
-
"react-virtualized": "9.22.3",
|
|
128
106
|
"react-virtualized-auto-sizer": "^1.0.24",
|
|
129
107
|
"react-window": "^1.8.6",
|
|
130
108
|
"recharts": "^3.0.2",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
2
|
import { getWrapper } from '../../testUtils';
|
|
3
|
-
import { Barchart } from './Barchart.component';
|
|
3
|
+
import { Barchart, CustomTick, formatDate } from './Barchart.component';
|
|
4
4
|
import { ChartLegendWrapper } from '../chartlegend/ChartLegendWrapper';
|
|
5
|
+
import React from 'react';
|
|
5
6
|
|
|
6
7
|
const ONE_DAY_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
|
|
7
8
|
const ONE_HOUR_IN_MILLISECONDS = 60 * 60 * 1000;
|
|
@@ -384,4 +385,101 @@ describe('Barchart', () => {
|
|
|
384
385
|
expect(screen.getByText('Test Right Title')).toBeInTheDocument();
|
|
385
386
|
expect(screen.getByLabelText('Info')).toBeInTheDocument();
|
|
386
387
|
});
|
|
388
|
+
describe('formatDate', () => {
|
|
389
|
+
it('should render the CustomTick component with over a day interval', () => {
|
|
390
|
+
const { Wrapper } = getWrapper();
|
|
391
|
+
render(
|
|
392
|
+
<Wrapper>
|
|
393
|
+
<CustomTick
|
|
394
|
+
type={{
|
|
395
|
+
type: 'time',
|
|
396
|
+
timeRange: {
|
|
397
|
+
startDate: new Date('2024-07-05'),
|
|
398
|
+
endDate: new Date('2024-07-07'),
|
|
399
|
+
interval: 2 * ONE_DAY_IN_MILLISECONDS,
|
|
400
|
+
},
|
|
401
|
+
}}
|
|
402
|
+
x={100}
|
|
403
|
+
y={100}
|
|
404
|
+
payload={{ value: new Date('2024-07-05T10:00:00').getTime() }}
|
|
405
|
+
visibleTicksCount={10}
|
|
406
|
+
width={100}
|
|
407
|
+
/>
|
|
408
|
+
</Wrapper>,
|
|
409
|
+
);
|
|
410
|
+
expect(screen.getByText('Fri05Jul 10:00')).toBeInTheDocument();
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it('should render the CustomTick component with day format', () => {
|
|
414
|
+
const { Wrapper } = getWrapper();
|
|
415
|
+
render(
|
|
416
|
+
<Wrapper>
|
|
417
|
+
<CustomTick
|
|
418
|
+
type={{
|
|
419
|
+
type: 'time',
|
|
420
|
+
timeRange: {
|
|
421
|
+
startDate: new Date('2024-07-05'),
|
|
422
|
+
endDate: new Date('2024-07-07'),
|
|
423
|
+
interval: ONE_DAY_IN_MILLISECONDS,
|
|
424
|
+
},
|
|
425
|
+
}}
|
|
426
|
+
x={100}
|
|
427
|
+
y={100}
|
|
428
|
+
payload={{ value: new Date('2024-07-05T10:00:00').getTime() }}
|
|
429
|
+
visibleTicksCount={10}
|
|
430
|
+
width={100}
|
|
431
|
+
/>
|
|
432
|
+
</Wrapper>,
|
|
433
|
+
);
|
|
434
|
+
expect(screen.getByText('Fri05Jul')).toBeInTheDocument();
|
|
435
|
+
});
|
|
436
|
+
it('should render the CustomTick component with hour format', () => {
|
|
437
|
+
const { Wrapper } = getWrapper();
|
|
438
|
+
render(
|
|
439
|
+
<Wrapper>
|
|
440
|
+
<CustomTick
|
|
441
|
+
type={{
|
|
442
|
+
type: 'time',
|
|
443
|
+
timeRange: {
|
|
444
|
+
startDate: new Date('2024-07-05'),
|
|
445
|
+
endDate: new Date('2024-07-07'),
|
|
446
|
+
interval: ONE_HOUR_IN_MILLISECONDS,
|
|
447
|
+
},
|
|
448
|
+
}}
|
|
449
|
+
x={100}
|
|
450
|
+
y={100}
|
|
451
|
+
payload={{ value: new Date('2024-07-05T10:00:00').getTime() }}
|
|
452
|
+
visibleTicksCount={10}
|
|
453
|
+
width={100}
|
|
454
|
+
/>
|
|
455
|
+
</Wrapper>,
|
|
456
|
+
);
|
|
457
|
+
expect(screen.getByText('10:00')).toBeInTheDocument();
|
|
458
|
+
});
|
|
459
|
+
it('should render the CustomTick component with minute format', () => {
|
|
460
|
+
const { Wrapper } = getWrapper();
|
|
461
|
+
render(
|
|
462
|
+
<Wrapper>
|
|
463
|
+
<CustomTick
|
|
464
|
+
type={{
|
|
465
|
+
type: 'time',
|
|
466
|
+
timeRange: {
|
|
467
|
+
startDate: new Date('2024-07-05'),
|
|
468
|
+
endDate: new Date('2024-07-07'),
|
|
469
|
+
interval: 1000 * 30,
|
|
470
|
+
},
|
|
471
|
+
}}
|
|
472
|
+
x={100}
|
|
473
|
+
y={100}
|
|
474
|
+
payload={{ value: new Date('2024-07-05T10:00:00').getTime() }}
|
|
475
|
+
visibleTicksCount={10}
|
|
476
|
+
width={100}
|
|
477
|
+
/>
|
|
478
|
+
</Wrapper>,
|
|
479
|
+
);
|
|
480
|
+
expect(
|
|
481
|
+
screen.getByText(new Date('2024-07-05T10:00:00').getTime()),
|
|
482
|
+
).toBeInTheDocument();
|
|
483
|
+
});
|
|
484
|
+
});
|
|
387
485
|
});
|
|
@@ -18,13 +18,9 @@ import { ConstrainedText } from '../constrainedtext/Constrainedtext.component';
|
|
|
18
18
|
import { IconHelp } from '../iconhelper/IconHelper';
|
|
19
19
|
import { Loader } from '../loader/Loader.component';
|
|
20
20
|
import { Text } from '../text/Text.component';
|
|
21
|
-
import {
|
|
22
|
-
formatDate,
|
|
23
|
-
renderTooltipContent,
|
|
24
|
-
UnitRange,
|
|
25
|
-
useChartData,
|
|
26
|
-
} from './utils';
|
|
21
|
+
import { renderTooltipContent, UnitRange, useChartData } from './utils';
|
|
27
22
|
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
23
|
+
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
28
24
|
|
|
29
25
|
const CHART_CONSTANTS = {
|
|
30
26
|
TICK_WIDTH_OFFSET: 5,
|
|
@@ -37,7 +33,7 @@ const CHART_CONSTANTS = {
|
|
|
37
33
|
top: 0,
|
|
38
34
|
bottom: 0,
|
|
39
35
|
},
|
|
40
|
-
}
|
|
36
|
+
};
|
|
41
37
|
|
|
42
38
|
/* ---------------------------------- TYPE ---------------------------------- */
|
|
43
39
|
|
|
@@ -100,7 +96,7 @@ interface CustomTickProps {
|
|
|
100
96
|
x: number;
|
|
101
97
|
y: number;
|
|
102
98
|
payload: {
|
|
103
|
-
value:
|
|
99
|
+
value: number;
|
|
104
100
|
};
|
|
105
101
|
visibleTicksCount: number;
|
|
106
102
|
width: number;
|
|
@@ -109,7 +105,38 @@ interface CustomTickProps {
|
|
|
109
105
|
|
|
110
106
|
/* ---------------------------------- COMPONENTS ---------------------------------- */
|
|
111
107
|
|
|
112
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Formats a date based on the interval
|
|
110
|
+
* @param timestamp - Timestamp
|
|
111
|
+
* @param interval - Interval in milliseconds
|
|
112
|
+
* @returns Formatted string
|
|
113
|
+
*/
|
|
114
|
+
export const formatDate = (
|
|
115
|
+
timestamp: number,
|
|
116
|
+
interval: number,
|
|
117
|
+
): React.ReactNode => {
|
|
118
|
+
const date = new Date(timestamp);
|
|
119
|
+
// More than 24 hours interval - use day and time format
|
|
120
|
+
if (interval > 24 * 60 * 60 * 1000) {
|
|
121
|
+
return (
|
|
122
|
+
<>
|
|
123
|
+
<FormattedDateTime format="chart-date" value={date} />{' '}
|
|
124
|
+
<FormattedDateTime format="time" value={date} />
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
} else if (interval === 24 * 60 * 60 * 1000) {
|
|
128
|
+
// Daily interval - use day format
|
|
129
|
+
return <FormattedDateTime format="chart-date" value={date} />;
|
|
130
|
+
} else if (interval >= 60 * 1000) {
|
|
131
|
+
//Hourly and minute intervals - use minute format
|
|
132
|
+
return <FormattedDateTime format="time" value={date} />;
|
|
133
|
+
} else {
|
|
134
|
+
// minute interval or less - use full timestamp
|
|
135
|
+
return timestamp;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const CustomTick = ({
|
|
113
140
|
x,
|
|
114
141
|
y,
|
|
115
142
|
payload,
|
|
@@ -131,10 +158,11 @@ const CustomTick = ({
|
|
|
131
158
|
overflow="visible"
|
|
132
159
|
>
|
|
133
160
|
<ConstrainedText
|
|
161
|
+
color="textSecondary"
|
|
134
162
|
text={
|
|
135
|
-
<Text variant="Smaller"
|
|
163
|
+
<Text variant="Smaller">
|
|
136
164
|
{type.type === 'time'
|
|
137
|
-
? formatDate(
|
|
165
|
+
? formatDate(payload.value, type.timeRange.interval)
|
|
138
166
|
: String(payload.value)}
|
|
139
167
|
</Text>
|
|
140
168
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { spacing, Stack, Wrap } from '../../spacing';
|
|
3
|
+
import { Text } from '../text/Text.component';
|
|
4
|
+
import { BarchartBars } from './Barchart.component';
|
|
5
|
+
import { fontSize, fontWeight } from '../../style/theme';
|
|
6
|
+
import { LegendShape } from '../chartlegend/ChartLegend';
|
|
7
|
+
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
8
|
+
|
|
9
|
+
export const ChartTooltipContainer = styled.div`
|
|
10
|
+
background-color: ${({ theme }) => theme.backgroundLevel1};
|
|
11
|
+
padding: ${spacing.r4} ${spacing.r8};
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
width: max-content;
|
|
14
|
+
max-width: 40rem;
|
|
15
|
+
border: 1px solid ${({ theme }) => theme.border};
|
|
16
|
+
display: flex;
|
|
17
|
+
font-size: ${fontSize.small};
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 16px;
|
|
20
|
+
align-items: center;
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export const ChartTooltipItem = styled.div<{ isHovered: boolean }>`
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: 8px;
|
|
27
|
+
font-weight: ${({ isHovered }) =>
|
|
28
|
+
isHovered ? fontWeight.bold : fontWeight.base};
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export const ChartTooltip = <T extends BarchartBars>({
|
|
32
|
+
type,
|
|
33
|
+
currentPoint,
|
|
34
|
+
colorSet,
|
|
35
|
+
}: {
|
|
36
|
+
type: 'time' | 'category';
|
|
37
|
+
currentPoint: {
|
|
38
|
+
category: string | number;
|
|
39
|
+
values: { label: T[number]['label']; value: number; isHovered: boolean }[];
|
|
40
|
+
};
|
|
41
|
+
colorSet: Record<string, string>;
|
|
42
|
+
}) => {
|
|
43
|
+
return (
|
|
44
|
+
<ChartTooltipContainer>
|
|
45
|
+
<Text isEmphazed>
|
|
46
|
+
{type === 'time' ? (
|
|
47
|
+
<FormattedDateTime
|
|
48
|
+
format="long-date"
|
|
49
|
+
value={new Date(currentPoint.category)}
|
|
50
|
+
/>
|
|
51
|
+
) : (
|
|
52
|
+
currentPoint.category
|
|
53
|
+
)}
|
|
54
|
+
</Text>
|
|
55
|
+
<Stack direction="vertical" gap="r8" style={{ width: '100%' }}>
|
|
56
|
+
{currentPoint.values.map((value) => {
|
|
57
|
+
return (
|
|
58
|
+
<Wrap key={value.label}>
|
|
59
|
+
<ChartTooltipItem isHovered={value.isHovered}>
|
|
60
|
+
<LegendShape
|
|
61
|
+
color={colorSet[value.label as keyof typeof colorSet]}
|
|
62
|
+
shape="rectangle"
|
|
63
|
+
chartColors={colorSet}
|
|
64
|
+
/>
|
|
65
|
+
{value.label}
|
|
66
|
+
</ChartTooltipItem>
|
|
67
|
+
<ChartTooltipItem isHovered={value.isHovered}>
|
|
68
|
+
{value.value}
|
|
69
|
+
</ChartTooltipItem>
|
|
70
|
+
</Wrap>
|
|
71
|
+
);
|
|
72
|
+
})}
|
|
73
|
+
</Stack>
|
|
74
|
+
</ChartTooltipContainer>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
BarchartBars,
|
|
4
4
|
BarchartTooltipFn,
|
|
5
5
|
} from './Barchart.component';
|
|
6
|
-
import { DAY_MONTH_FORMATER, TIME_FORMATER } from '../date/FormattedDateTime';
|
|
7
6
|
import { TooltipContentProps } from 'recharts';
|
|
8
7
|
import { chartColors, ChartColors } from '../../style/theme';
|
|
9
8
|
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
@@ -84,31 +83,6 @@ const generateTimeRanges = (
|
|
|
84
83
|
return ranges;
|
|
85
84
|
};
|
|
86
85
|
|
|
87
|
-
/**
|
|
88
|
-
* Formats a date based on the interval
|
|
89
|
-
* @param date - Date object
|
|
90
|
-
* @param interval - Interval in milliseconds
|
|
91
|
-
* @returns Formatted string
|
|
92
|
-
*/
|
|
93
|
-
export const formatDate = (date: Date, interval: number): string => {
|
|
94
|
-
if (interval > 24 * 60 * 60 * 1000) {
|
|
95
|
-
return (
|
|
96
|
-
DAY_MONTH_FORMATER.format(date).replace(/[ ,]/g, '') +
|
|
97
|
-
' ' +
|
|
98
|
-
TIME_FORMATER.format(date)
|
|
99
|
-
);
|
|
100
|
-
} else if (interval === 24 * 60 * 60 * 1000) {
|
|
101
|
-
// Daily or longer intervals - use day format
|
|
102
|
-
return DAY_MONTH_FORMATER.format(date).replace(/[ ,]/g, '');
|
|
103
|
-
} else if (interval >= 60 * 1000) {
|
|
104
|
-
//Handle hourly and minute intervals - use minute format
|
|
105
|
-
return TIME_FORMATER.format(date);
|
|
106
|
-
} else {
|
|
107
|
-
// Second intervals or less - use full timestamp
|
|
108
|
-
return date.toISOString();
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
86
|
/**
|
|
113
87
|
* Finds the time range that contains the given date
|
|
114
88
|
* @param date - Data point date
|
|
@@ -149,17 +123,12 @@ export const transformTimeData = <T extends BarchartBars>(
|
|
|
149
123
|
type.timeRange.interval,
|
|
150
124
|
);
|
|
151
125
|
|
|
152
|
-
const categoryMap = new Map<
|
|
153
|
-
string | number,
|
|
154
|
-
{ [key: string]: string | number }
|
|
155
|
-
>();
|
|
126
|
+
const categoryMap = new Map<number, { [key: string]: string | number }>();
|
|
156
127
|
|
|
157
128
|
// Initialize all ranges with zeros
|
|
158
129
|
timeRanges.forEach((range) => {
|
|
159
|
-
// const categoryDisplay = formatDate(range.start, type.timeRange.interval);
|
|
160
|
-
const categoryDisplay = range.start.getTime();
|
|
161
130
|
const initialData: { [key: string]: string | number } = {
|
|
162
|
-
category:
|
|
131
|
+
category: range.start.getTime(),
|
|
163
132
|
};
|
|
164
133
|
barDataKeys.forEach((dataKey) => {
|
|
165
134
|
initialData[dataKey] = 0;
|
|
@@ -242,8 +242,9 @@ const Anchor = ButtonStyled.withComponent('a');
|
|
|
242
242
|
|
|
243
243
|
/**
|
|
244
244
|
* @deprecated
|
|
245
|
+
* Used only in Dropdown.component.tsx, can be removed after refactoring
|
|
245
246
|
* You should use ButtonV2 with
|
|
246
|
-
* import { Button } from '@scality/core-ui/dist/next';
|
|
247
|
+
* @example import { Button } from '@scality/core-ui/dist/next';
|
|
247
248
|
*/
|
|
248
249
|
function Button({
|
|
249
250
|
text = '',
|