@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/.storybook/preview.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
3
3
|
import { CoreUiThemeProvider } from '../src/lib/next';
|
|
4
|
-
import {
|
|
4
|
+
import { coreUIAvailableThemes } from '../src/lib/style/theme';
|
|
5
5
|
import { Wrapper } from '../stories/common';
|
|
6
6
|
import { ToastProvider } from '../src/lib';
|
|
7
7
|
|
|
@@ -72,9 +72,11 @@ export const parameters = {
|
|
|
72
72
|
controls: {
|
|
73
73
|
//All props with color in name will automatically have a control 'color'
|
|
74
74
|
//with colors presets to theme colors, possible to have the color name from theme in control
|
|
75
|
-
presetColors: Object.entries(
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
presetColors: Object.entries(coreUIAvailableThemes.darkRebrand).map(
|
|
76
|
+
(color) => {
|
|
77
|
+
return { color: color[1], title: color[0] };
|
|
78
|
+
},
|
|
79
|
+
),
|
|
78
80
|
matchers: {
|
|
79
81
|
color: /color/i,
|
|
80
82
|
},
|
package/README.md
CHANGED
|
@@ -11,38 +11,21 @@ Core-UI is a component library containing all components, layouts, icons and the
|
|
|
11
11
|
- Add `@scality/core-ui` in the `package.json`'s dependencies of your project.
|
|
12
12
|
|
|
13
13
|
```json
|
|
14
|
-
"@scality/core-ui": "0.
|
|
14
|
+
"@scality/core-ui": "^0.165.0",
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
- `@scality/core-ui` requires the peerDependencies below. Make sure that you have them in the `package.json`'s dependencies.
|
|
18
18
|
|
|
19
19
|
```json
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"@fortawesome/free-solid-svg-icons": "^5.15.3",
|
|
24
|
-
"@fortawesome/react-fontawesome": "^0.1.14",
|
|
25
|
-
"@js-temporal/polyfill": "^0.4.4",
|
|
26
|
-
"polished": "3.4.1",
|
|
27
|
-
"pretty-bytes": "^5.6.0",
|
|
28
|
-
"react": "^17.0.2",
|
|
29
|
-
"react-debounce-input": "3.2.2",
|
|
30
|
-
"react-dom": "^17.0.2",
|
|
31
|
-
"react-dropzone": "^14.2.3",
|
|
20
|
+
"react": "^18.0.0",
|
|
21
|
+
"react-dom": "^18.0.0",
|
|
22
|
+
// to provides a Provider to the components using react-query
|
|
32
23
|
"react-query": "^3.34.0",
|
|
33
|
-
|
|
34
|
-
"react-router
|
|
35
|
-
"react-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"react-virtualized-auto-sizer": "^1.0.5",
|
|
39
|
-
"react-window": "^1.8.6",
|
|
40
|
-
"styled-components": "^4.1.2",
|
|
41
|
-
"styled-system": "^5.1.5",
|
|
42
|
-
"vega": "^5.17.3",
|
|
43
|
-
"vega-embed": "^6.0.0",
|
|
44
|
-
"vega-lite": "^5.0.0",
|
|
45
|
-
"vega-tooltip": "^0.27.0"
|
|
24
|
+
// for the components using react router
|
|
25
|
+
"react-router": "^7.0.1",
|
|
26
|
+
"react-router-dom": "^7.0.1",
|
|
27
|
+
// for legacy chart components
|
|
28
|
+
"canvas": "^2.10.1",
|
|
46
29
|
```
|
|
47
30
|
|
|
48
31
|
- Install the dependencies :
|
|
@@ -90,51 +73,23 @@ import { coreUIAvailableThemes as themes } from '@scality/core-ui/dist/style/the
|
|
|
90
73
|
|
|
91
74
|
There is 2 default theme available in Core-UI : you can find them [here](https://github.com/scality/core-ui/pull/684#:~:text=https%3A//github.com/scality/core%2Dui/blob/development/1.0/src/lib/style/theme.ts)
|
|
92
75
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
You can also modify or create a new theme. In this case make sure to respect this type :
|
|
76
|
+
You can also modify or create a new theme but make sure to extend this type:
|
|
96
77
|
|
|
97
78
|
```tsx
|
|
98
|
-
|
|
99
|
-
statusHealthy: string;
|
|
100
|
-
statusHealthyRGB: string;
|
|
101
|
-
statusWarning: string;
|
|
102
|
-
statusWarningRGB: string;
|
|
103
|
-
statusCritical: string;
|
|
104
|
-
statusCriticalRGB: string;
|
|
105
|
-
selectedActive: string;
|
|
106
|
-
highlight: string;
|
|
107
|
-
border: string;
|
|
108
|
-
buttonPrimary: string;
|
|
109
|
-
buttonSecondary: string;
|
|
110
|
-
buttonDelete: string;
|
|
111
|
-
infoPrimary: string;
|
|
112
|
-
infoSecondary: string;
|
|
113
|
-
backgroundLevel1: string;
|
|
114
|
-
backgroundLevel2: string;
|
|
115
|
-
backgroundLevel3: string;
|
|
116
|
-
backgroundLevel4: string;
|
|
117
|
-
textPrimary: string;
|
|
118
|
-
textSecondary: string;
|
|
119
|
-
textTertiary: string;
|
|
120
|
-
textReverse: string;
|
|
121
|
-
textLink: string;
|
|
122
|
-
};
|
|
79
|
+
import { CoreUITheme } from "@scality/core-ui/dist/next";
|
|
123
80
|
```
|
|
124
81
|
|
|
125
|
-
<br />
|
|
126
|
-
|
|
127
82
|
## Development
|
|
128
83
|
|
|
129
84
|
This project is built with [React](https://react.dev/) and [TypeScript](https://www.typescriptlang.org/), and styled with [styled-components](https://styled-components.com/).
|
|
130
85
|
|
|
131
|
-
To start contributing to core-ui, clone the repository
|
|
86
|
+
To start contributing to core-ui, clone the repository:
|
|
132
87
|
|
|
133
88
|
```sh
|
|
134
89
|
git clone git@github.com:scality/core-ui.git
|
|
135
90
|
```
|
|
136
91
|
|
|
137
|
-
then install the dependancies
|
|
92
|
+
then install the dependancies:
|
|
138
93
|
|
|
139
94
|
```sh
|
|
140
95
|
npm install
|
|
@@ -142,7 +97,7 @@ npm install
|
|
|
142
97
|
|
|
143
98
|
### Create a new branch
|
|
144
99
|
|
|
145
|
-
Give your branch an explicit name with the reference to the Jira ticket or issue if it exists, and prefix it with
|
|
100
|
+
Give your branch an explicit name with the reference to the Jira ticket or issue if it exists, and prefix it with:
|
|
146
101
|
|
|
147
102
|
- feature/ for new component or major component update : `feature/TICKET-123-some-feature`
|
|
148
103
|
- improvement/ for code improvement, component update : `improvement/TICKET-456-some-improvement`
|
|
@@ -183,7 +138,7 @@ When creating a new version of an existing component, expose it in `src/lib/next
|
|
|
183
138
|
|
|
184
139
|
You can use storybook to help with the development.
|
|
185
140
|
Storybook helps to test and vizualize component in isolation.
|
|
186
|
-
If it doesn't exist, write a [story](https://storybook.js.org/docs/get-started/whats-a-story) for the component
|
|
141
|
+
If it doesn't exist, write a [story](https://storybook.js.org/docs/get-started/whats-a-story) for the component:
|
|
187
142
|
|
|
188
143
|
```jsx
|
|
189
144
|
// in stories/example/example.stories.tsx
|
|
@@ -200,10 +155,9 @@ type Story = StoryObj<typeof Example>;
|
|
|
200
155
|
export const Default: Story = {
|
|
201
156
|
render: () => <Example />,
|
|
202
157
|
};
|
|
203
|
-
|
|
204
158
|
```
|
|
205
159
|
|
|
206
|
-
|
|
160
|
+
Then launch storybook:
|
|
207
161
|
|
|
208
162
|
```sh
|
|
209
163
|
npm run storybook
|
|
@@ -213,7 +167,7 @@ Storybook will be launched on `http://localhost:3000`.
|
|
|
213
167
|
|
|
214
168
|
### Lint
|
|
215
169
|
|
|
216
|
-
To make sure your code is correctly lint, run
|
|
170
|
+
To make sure your code is correctly lint, run:
|
|
217
171
|
|
|
218
172
|
```sh
|
|
219
173
|
npm run lint
|
|
@@ -225,13 +179,13 @@ It will run ESLint by using `eslint-config-react-app` which is a shareable ESLin
|
|
|
225
179
|
|
|
226
180
|
Build tests with [jest](https://jestjs.io/)
|
|
227
181
|
|
|
228
|
-
Make sure to write tests that cover all cases, then you can run all tests with
|
|
182
|
+
Make sure to write tests that cover all cases, then you can run all tests with:
|
|
229
183
|
|
|
230
184
|
```sh
|
|
231
185
|
npm run test
|
|
232
186
|
```
|
|
233
187
|
|
|
234
|
-
|
|
188
|
+
Or run a specific test with:
|
|
235
189
|
|
|
236
190
|
```sh
|
|
237
191
|
npm run test Example.test.tsx
|
|
@@ -241,7 +195,6 @@ npm run test Example.test.tsx
|
|
|
241
195
|
|
|
242
196
|
Core-UI uses [storybook](https://storybook.js.org/) for its documentation. \
|
|
243
197
|
Illustrate use cases and state variations with [stories](https://storybook.js.org/docs/writing-stories).
|
|
244
|
-
All stories should be type.
|
|
245
198
|
|
|
246
199
|
If possible create or update the component guideline.
|
|
247
200
|
This guideline is an MDX file containing details about the component usage and is illustrated with the stories write in stories.tsx file.
|
|
@@ -259,29 +212,23 @@ import * as ExampleStories from './Example.stories';
|
|
|
259
212
|
An Example component is used for example.
|
|
260
213
|
|
|
261
214
|
<Canvas of={ExampleStories.Default} />
|
|
262
|
-
|
|
263
215
|
```
|
|
264
216
|
|
|
265
|
-
###
|
|
266
|
-
|
|
267
|
-
Push your code on the repository
|
|
268
|
-
|
|
269
|
-
```sh
|
|
270
|
-
git push origin <branch-name>
|
|
271
|
-
```
|
|
217
|
+
### Contributing
|
|
272
218
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
219
|
+
- Push your code on a branch following the [branch naming convention](#create-a-new-branch)
|
|
220
|
+
- Create a pull request.
|
|
221
|
+
- Obtain the approval of at least one reviewer.
|
|
222
|
+
- Then comment with `/approve` to merge the PR.
|
|
276
223
|
|
|
277
224
|
### Release
|
|
278
225
|
|
|
279
226
|
After merging one or more PR in Core-UI, it is possible to plublish a new release.
|
|
280
|
-
In the Core-UI repo, follow these steps
|
|
227
|
+
In the Core-UI repo, follow these steps:
|
|
281
228
|
|
|
282
229
|
1. Go on `Releases` then `Draft a new release`
|
|
283
|
-
2. In the select menu `Choose a tag
|
|
284
|
-
3. You can now `Generate release notes
|
|
230
|
+
2. In the select menu `Choose a tag`: Create a new tag (the current tag increment by 1).
|
|
231
|
+
3. You can now `Generate release notes`: it will add all the PR infos since the last release. \
|
|
285
232
|
You can add details if necessary.
|
|
286
233
|
4. `Publish release`
|
|
287
234
|
5. It will create a PR that need to be approved.
|
|
@@ -7,6 +7,11 @@ type Props = {
|
|
|
7
7
|
height?: number;
|
|
8
8
|
barConfig?: Record<string, any>;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use Barchart v2 instead
|
|
12
|
+
* @example import { Barchart } from '@scality/core-ui/dist/next';
|
|
13
|
+
|
|
14
|
+
*/
|
|
10
15
|
declare function BarChart({ id, data, xAxis, yAxis, color, height, barConfig, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
16
|
export { BarChart };
|
|
12
17
|
//# sourceMappingURL=BarChart.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchart/BarChart.component.tsx"],"names":[],"mappings":"AACA,KAAK,KAAK,GAAG;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC,CAAC;AAEF,iBAAS,QAAQ,CAAC,EAChB,EAAE,EACF,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAY,EACZ,SAAS,GACV,EAAE,KAAK,2CAwBP;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"BarChart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchart/BarChart.component.tsx"],"names":[],"mappings":"AACA,KAAK,KAAK,GAAG;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC,CAAC;AAEF;;;;GAIG;AACH,iBAAS,QAAQ,CAAC,EAChB,EAAE,EACF,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAY,EACZ,SAAS,GACV,EAAE,KAAK,2CAwBP;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { VegaChart } from '../vegachartv2/VegaChartV2.component';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use Barchart v2 instead
|
|
5
|
+
* @example import { Barchart } from '@scality/core-ui/dist/next';
|
|
6
|
+
|
|
7
|
+
*/
|
|
3
8
|
function BarChart({ id, data, xAxis, yAxis, color, height = 200, barConfig, }) {
|
|
4
9
|
const spec = {
|
|
5
10
|
mark: {
|
|
@@ -57,5 +57,24 @@ export type BarchartProps<T extends BarchartBars> = {
|
|
|
57
57
|
isLoading?: boolean;
|
|
58
58
|
isError?: boolean;
|
|
59
59
|
};
|
|
60
|
+
interface CustomTickProps {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
payload: {
|
|
64
|
+
value: number;
|
|
65
|
+
};
|
|
66
|
+
visibleTicksCount: number;
|
|
67
|
+
width: number;
|
|
68
|
+
type: TimeType;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Formats a date based on the interval
|
|
72
|
+
* @param timestamp - Timestamp
|
|
73
|
+
* @param interval - Interval in milliseconds
|
|
74
|
+
* @returns Formatted string
|
|
75
|
+
*/
|
|
76
|
+
export declare const formatDate: (timestamp: number, interval: number) => React.ReactNode;
|
|
77
|
+
export declare const CustomTick: ({ x, y, payload, visibleTicksCount, width, type, }: CustomTickProps) => import("react/jsx-runtime").JSX.Element;
|
|
60
78
|
export declare const Barchart: <T extends BarchartBars>(props: BarchartProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
export {};
|
|
61
80
|
//# sourceMappingURL=Barchart.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Barchart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/Barchart.component.tsx"],"names":[],"mappings":"AAoBA,OAAO,
|
|
1
|
+
{"version":3,"file":"Barchart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/Barchart.component.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAwB,SAAS,EAAgB,MAAM,SAAS,CAAC;AAmBxE,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE;QACT,SAAS,EAAE,IAAI,CAAC;QAChB,OAAO,EAAE,IAAI,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AACF,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,SAAS;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC;CACvE,EAAE,CAAC;AAEJ,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,YAAY,IAAI,CAAC,YAAY,EAAE;IACrE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,MAAM,EAAE;QAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;QAAC,KAAK,EAA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E,MAAM,CAAC;IACV,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB;AAID;;;;;GAKG;AACH,eAAO,MAAM,UAAU,cACV,MAAM,YACP,MAAM,KACf,KAAK,CAAC,SAoBR,CAAC;AAEF,eAAO,MAAM,UAAU,uDAOpB,eAAe,4CAkCjB,CAAC;AA2EF,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,YAAY,SAAS,aAAa,CAAC,CAAC,CAAC,4CAwIvE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Bar, BarChart, CartesianGrid, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts';
|
|
4
4
|
import styled, { useTheme } from 'styled-components';
|
|
@@ -9,8 +9,9 @@ import { ConstrainedText } from '../constrainedtext/Constrainedtext.component';
|
|
|
9
9
|
import { IconHelp } from '../iconhelper/IconHelper';
|
|
10
10
|
import { Loader } from '../loader/Loader.component';
|
|
11
11
|
import { Text } from '../text/Text.component';
|
|
12
|
-
import {
|
|
12
|
+
import { renderTooltipContent, useChartData } from './utils';
|
|
13
13
|
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
14
|
+
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
14
15
|
const CHART_CONSTANTS = {
|
|
15
16
|
TICK_WIDTH_OFFSET: 5,
|
|
16
17
|
BAR_SIZE: 12,
|
|
@@ -24,12 +25,37 @@ const CHART_CONSTANTS = {
|
|
|
24
25
|
},
|
|
25
26
|
};
|
|
26
27
|
/* ---------------------------------- COMPONENTS ---------------------------------- */
|
|
27
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Formats a date based on the interval
|
|
30
|
+
* @param timestamp - Timestamp
|
|
31
|
+
* @param interval - Interval in milliseconds
|
|
32
|
+
* @returns Formatted string
|
|
33
|
+
*/
|
|
34
|
+
export const formatDate = (timestamp, interval) => {
|
|
35
|
+
const date = new Date(timestamp);
|
|
36
|
+
// More than 24 hours interval - use day and time format
|
|
37
|
+
if (interval > 24 * 60 * 60 * 1000) {
|
|
38
|
+
return (_jsxs(_Fragment, { children: [_jsx(FormattedDateTime, { format: "chart-date", value: date }), ' ', _jsx(FormattedDateTime, { format: "time", value: date })] }));
|
|
39
|
+
}
|
|
40
|
+
else if (interval === 24 * 60 * 60 * 1000) {
|
|
41
|
+
// Daily interval - use day format
|
|
42
|
+
return _jsx(FormattedDateTime, { format: "chart-date", value: date });
|
|
43
|
+
}
|
|
44
|
+
else if (interval >= 60 * 1000) {
|
|
45
|
+
//Hourly and minute intervals - use minute format
|
|
46
|
+
return _jsx(FormattedDateTime, { format: "time", value: date });
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// minute interval or less - use full timestamp
|
|
50
|
+
return timestamp;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export const CustomTick = ({ x, y, payload, visibleTicksCount, width, type, }) => {
|
|
28
54
|
const theme = useTheme();
|
|
29
55
|
const tickWidth = width / visibleTicksCount - CHART_CONSTANTS.TICK_WIDTH_OFFSET;
|
|
30
56
|
const centerX = x - tickWidth / 2;
|
|
31
|
-
return (_jsx("foreignObject", { x: centerX, y: y, width: tickWidth, color: theme.textSecondary, overflow: "visible", children: _jsx(ConstrainedText, { text: _jsx(Text, { variant: "Smaller",
|
|
32
|
-
? formatDate(
|
|
57
|
+
return (_jsx("foreignObject", { x: centerX, y: y, width: tickWidth, color: theme.textSecondary, overflow: "visible", children: _jsx(ConstrainedText, { color: "textSecondary", text: _jsx(Text, { variant: "Smaller", children: type.type === 'time'
|
|
58
|
+
? formatDate(payload.value, type.timeRange.interval)
|
|
33
59
|
: String(payload.value) }), centered: true, tooltipStyle: {
|
|
34
60
|
backgroundColor: theme.backgroundLevel1,
|
|
35
61
|
padding: spacing.r10,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BarchartBars } from './Barchart.component';
|
|
2
|
+
export declare const ChartTooltipContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const ChartTooltipItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
4
|
+
isHovered: boolean;
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const ChartTooltip: <T extends BarchartBars>({ type, currentPoint, colorSet, }: {
|
|
7
|
+
type: "time" | "category";
|
|
8
|
+
currentPoint: {
|
|
9
|
+
category: string | number;
|
|
10
|
+
values: {
|
|
11
|
+
label: T[number]["label"];
|
|
12
|
+
value: number;
|
|
13
|
+
isHovered: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
colorSet: Record<string, string>;
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=ChartTooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/ChartTooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKpD,eAAO,MAAM,qBAAqB,yGAYjC,CAAC;AAEF,eAAO,MAAM,gBAAgB;eAA2B,OAAO;SAM9D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,YAAY,qCAIhD;IACD,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,YAAY,EAAE;QACZ,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;QAC1B,MAAM,EAAE;YAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,OAAO,CAAA;SAAE,EAAE,CAAC;KAC5E,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,4CAkCA,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { spacing, Stack, Wrap } from '../../spacing';
|
|
4
|
+
import { Text } from '../text/Text.component';
|
|
5
|
+
import { fontSize, fontWeight } from '../../style/theme';
|
|
6
|
+
import { LegendShape } from '../chartlegend/ChartLegend';
|
|
7
|
+
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
8
|
+
export const ChartTooltipContainer = styled.div `
|
|
9
|
+
background-color: ${({ theme }) => theme.backgroundLevel1};
|
|
10
|
+
padding: ${spacing.r4} ${spacing.r8};
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
width: max-content;
|
|
13
|
+
max-width: 40rem;
|
|
14
|
+
border: 1px solid ${({ theme }) => theme.border};
|
|
15
|
+
display: flex;
|
|
16
|
+
font-size: ${fontSize.small};
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: 16px;
|
|
19
|
+
align-items: center;
|
|
20
|
+
`;
|
|
21
|
+
export const ChartTooltipItem = styled.div `
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 8px;
|
|
25
|
+
font-weight: ${({ isHovered }) => isHovered ? fontWeight.bold : fontWeight.base};
|
|
26
|
+
`;
|
|
27
|
+
export const ChartTooltip = ({ type, currentPoint, colorSet, }) => {
|
|
28
|
+
return (_jsxs(ChartTooltipContainer, { children: [_jsx(Text, { isEmphazed: true, children: type === 'time' ? (_jsx(FormattedDateTime, { format: "long-date", value: new Date(currentPoint.category) })) : (currentPoint.category) }), _jsx(Stack, { direction: "vertical", gap: "r8", style: { width: '100%' }, children: currentPoint.values.map((value) => {
|
|
29
|
+
return (_jsxs(Wrap, { children: [_jsxs(ChartTooltipItem, { isHovered: value.isHovered, children: [_jsx(LegendShape, { color: colorSet[value.label], shape: "rectangle", chartColors: colorSet }), value.label] }), _jsx(ChartTooltipItem, { isHovered: value.isHovered, children: value.value })] }, value.label));
|
|
30
|
+
}) })] }));
|
|
31
|
+
};
|
|
@@ -5,13 +5,6 @@ export declare const getRoundReferenceValue: (value: number) => number;
|
|
|
5
5
|
export declare const getMaxBarValue: (data: {
|
|
6
6
|
[key: string]: string | number;
|
|
7
7
|
}[], stacked?: boolean) => number;
|
|
8
|
-
/**
|
|
9
|
-
* Formats a date based on the interval
|
|
10
|
-
* @param date - Date object
|
|
11
|
-
* @param interval - Interval in milliseconds
|
|
12
|
-
* @returns Formatted string
|
|
13
|
-
*/
|
|
14
|
-
export declare const formatDate: (date: Date, interval: number) => string;
|
|
15
8
|
/**
|
|
16
9
|
* Transforms time-based data into chart format
|
|
17
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG7D,eAAO,MAAM,sBAAsB,UAAW,MAAM,KAAG,MAkBtD,CAAC;AAEF,eAAO,MAAM,cAAc,SACnB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,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AAC,MAAM,CAAC,YACpB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,YACpC,OAAO,gBACH,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,cACjC,SAAS,mBACJ,SAAS,GAAG,QAAQ;;iBApCZ,MAAM;cAAQ,MAAM;kBAAY,MAAM;;;;;CAuEhE,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DAY_MONTH_FORMATER, TIME_FORMATER } from '../date/FormattedDateTime';
|
|
2
1
|
import { chartColors } from '../../style/theme';
|
|
3
2
|
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
4
3
|
export const getRoundReferenceValue = (value) => {
|
|
@@ -62,31 +61,6 @@ const generateTimeRanges = (startDate, endDate, interval) => {
|
|
|
62
61
|
}
|
|
63
62
|
return ranges;
|
|
64
63
|
};
|
|
65
|
-
/**
|
|
66
|
-
* Formats a date based on the interval
|
|
67
|
-
* @param date - Date object
|
|
68
|
-
* @param interval - Interval in milliseconds
|
|
69
|
-
* @returns Formatted string
|
|
70
|
-
*/
|
|
71
|
-
export const formatDate = (date, interval) => {
|
|
72
|
-
if (interval > 24 * 60 * 60 * 1000) {
|
|
73
|
-
return (DAY_MONTH_FORMATER.format(date).replace(/[ ,]/g, '') +
|
|
74
|
-
' ' +
|
|
75
|
-
TIME_FORMATER.format(date));
|
|
76
|
-
}
|
|
77
|
-
else if (interval === 24 * 60 * 60 * 1000) {
|
|
78
|
-
// Daily or longer intervals - use day format
|
|
79
|
-
return DAY_MONTH_FORMATER.format(date).replace(/[ ,]/g, '');
|
|
80
|
-
}
|
|
81
|
-
else if (interval >= 60 * 1000) {
|
|
82
|
-
//Handle hourly and minute intervals - use minute format
|
|
83
|
-
return TIME_FORMATER.format(date);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// Second intervals or less - use full timestamp
|
|
87
|
-
return date.toISOString();
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
64
|
/**
|
|
91
65
|
* Finds the time range that contains the given date
|
|
92
66
|
* @param date - Data point date
|
|
@@ -105,10 +79,8 @@ export const transformTimeData = (bars, type, barDataKeys) => {
|
|
|
105
79
|
const categoryMap = new Map();
|
|
106
80
|
// Initialize all ranges with zeros
|
|
107
81
|
timeRanges.forEach((range) => {
|
|
108
|
-
// const categoryDisplay = formatDate(range.start, type.timeRange.interval);
|
|
109
|
-
const categoryDisplay = range.start.getTime();
|
|
110
82
|
const initialData = {
|
|
111
|
-
category:
|
|
83
|
+
category: range.start.getTime(),
|
|
112
84
|
};
|
|
113
85
|
barDataKeys.forEach((dataKey) => {
|
|
114
86
|
initialData[dataKey] = 0;
|
|
@@ -19,8 +19,9 @@ export declare const ButtonText: import("styled-components").StyledComponent<"sp
|
|
|
19
19
|
export declare const ButtonContent: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
20
20
|
/**
|
|
21
21
|
* @deprecated
|
|
22
|
+
* Used only in Dropdown.component.tsx, can be removed after refactoring
|
|
22
23
|
* You should use ButtonV2 with
|
|
23
|
-
* import { Button } from '@scality/core-ui/dist/next';
|
|
24
|
+
* @example import { Button } from '@scality/core-ui/dist/next';
|
|
24
25
|
*/
|
|
25
26
|
declare function Button({ text, href, icon, size, variant, outlined, disabled, onClick, title, isLoading, type, inverted, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
26
27
|
export { Button };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/button/Button.component.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IAIZ,OAAO,CAAC,EACJ,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,kBAAkB,CAAC;IAEvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAC/B,CAAC;AACF,eAAO,MAAM,YAAY,4GA+LxB,CAAC;AACF,eAAO,MAAM,UAAU,0GAStB,CAAC;AACF,eAAO,MAAM,UAAU,0GAItB,CAAC;AACF,eAAO,MAAM,aAAa,0GAEzB,CAAC;AAGF
|
|
1
|
+
{"version":3,"file":"Button.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/button/Button.component.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IAIZ,OAAO,CAAC,EACJ,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,kBAAkB,CAAC;IAEvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAC/B,CAAC;AACF,eAAO,MAAM,YAAY,4GA+LxB,CAAC;AACF,eAAO,MAAM,UAAU,0GAStB,CAAC;AACF,eAAO,MAAM,UAAU,0GAItB,CAAC;AACF,eAAO,MAAM,aAAa,0GAEzB,CAAC;AAGF;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,EACd,IAAS,EACT,IAAS,EACT,IAAW,EACX,IAAa,EACb,OAAyB,EACzB,QAAgB,EAChB,QAAgB,EAChB,OAAO,EACP,KAAU,EACV,SAAiB,EACjB,IAAe,EACf,QAAgB,EAChB,GAAG,IAAI,EACR,EAAE,KAAK,2CAgDP;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -218,8 +218,9 @@ export const ButtonContent = styled.span `
|
|
|
218
218
|
const Anchor = ButtonStyled.withComponent('a');
|
|
219
219
|
/**
|
|
220
220
|
* @deprecated
|
|
221
|
+
* Used only in Dropdown.component.tsx, can be removed after refactoring
|
|
221
222
|
* You should use ButtonV2 with
|
|
222
|
-
* import { Button } from '@scality/core-ui/dist/next';
|
|
223
|
+
* @example import { Button } from '@scality/core-ui/dist/next';
|
|
223
224
|
*/
|
|
224
225
|
function Button({ text = '', href = '', icon = null, size = 'base', variant = 'buttonPrimary', outlined = false, disabled = false, onClick, title = '', isLoading = false, type = 'button', inverted = false, ...rest }) {
|
|
225
226
|
return href && href.length ? (_jsxs(Anchor, { className: "sc-button", href: href, variant: variant, outlined: outlined, disabled: disabled, size: size, title: title, ...rest, children: [icon && (_jsx(ButtonIcon, { text: text, size: size, children: icon })), _jsx(ButtonText, { children: text })] })) : (_jsx(ButtonStyled, { className: "sc-button", variant: variant, outlined: outlined, disabled: disabled || isLoading, size: size, onClick: onClick, title: title, isLoading: isLoading, type: type, inverted: inverted, icon: icon, text: text, ...rest, children: _jsxs(ButtonContent, { children: [isLoading && _jsx(Loader, { size: size }), _jsxs("span", { className: "sc-button-text", children: [icon && (_jsx(ButtonIcon, { text: text, size: size, children: icon })), _jsx(ButtonText, { children: text })] })] }) }));
|
|
@@ -3,6 +3,15 @@ type ChartLegendProps = {
|
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
direction?: 'horizontal' | 'vertical';
|
|
5
5
|
};
|
|
6
|
+
export declare const LegendItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
selected?: boolean;
|
|
9
|
+
}, never>;
|
|
10
|
+
export declare const LegendShape: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
11
|
+
color?: string;
|
|
12
|
+
shape: "line" | "rectangle";
|
|
13
|
+
chartColors: Record<string, string>;
|
|
14
|
+
}, never>;
|
|
6
15
|
export declare const ChartLegend: ({ shape, disabled, direction, }: ChartLegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
16
|
export {};
|
|
8
17
|
//# sourceMappingURL=ChartLegend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegend.tsx"],"names":[],"mappings":"AAMA,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACvC,CAAC;
|
|
1
|
+
{"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegend.tsx"],"names":[],"mappings":"AAMA,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACvC,CAAC;AAUF,eAAO,MAAM,UAAU;eACV,OAAO;eACP,OAAO;SAYnB,CAAC;AAEF,eAAO,MAAM,WAAW;YACd,MAAM;WACP,MAAM,GAAG,WAAW;iBACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;SAsBpC,CAAC;AAEF,eAAO,MAAM,WAAW,oCAIrB,gBAAgB,4CAyElB,CAAC"}
|
|
@@ -10,7 +10,7 @@ const Legend = styled.div `
|
|
|
10
10
|
gap: ${({ direction }) => (direction === 'horizontal' ? '16px' : '8px')};
|
|
11
11
|
flex-wrap: wrap;
|
|
12
12
|
`;
|
|
13
|
-
const LegendItem = styled.div `
|
|
13
|
+
export const LegendItem = styled.div `
|
|
14
14
|
display: flex;
|
|
15
15
|
align-items: center;
|
|
16
16
|
gap: 8px;
|
|
@@ -22,7 +22,7 @@ const LegendItem = styled.div `
|
|
|
22
22
|
opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
|
-
const LegendShape = styled.div `
|
|
25
|
+
export const LegendShape = styled.div `
|
|
26
26
|
${({ shape, color, chartColors }) => {
|
|
27
27
|
if (shape === 'line') {
|
|
28
28
|
return `
|
|
@@ -45,21 +45,44 @@ const LegendShape = styled.div `
|
|
|
45
45
|
}}
|
|
46
46
|
`;
|
|
47
47
|
export const ChartLegend = ({ shape, disabled = false, direction = 'horizontal', }) => {
|
|
48
|
-
const { listResources, getColor, isSelected, addSelectedResource, removeSelectedResource, } = useChartLegend();
|
|
48
|
+
const { listResources, getColor, isSelected, addSelectedResource, removeSelectedResource, selectAllResources, selectOnlyResource, isOnlyOneSelected, } = useChartLegend();
|
|
49
49
|
const resources = listResources();
|
|
50
|
-
const handleLegendClick = useCallback((resource) => {
|
|
50
|
+
const handleLegendClick = useCallback((resource, event) => {
|
|
51
51
|
if (disabled)
|
|
52
52
|
return;
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const isModifierClick = event.metaKey || event.ctrlKey;
|
|
54
|
+
const itemIsSelected = isSelected(resource);
|
|
55
|
+
if (isModifierClick) {
|
|
56
|
+
if (itemIsSelected) {
|
|
57
|
+
if (isOnlyOneSelected()) {
|
|
58
|
+
selectAllResources();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
removeSelectedResource(resource);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
addSelectedResource(resource);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (itemIsSelected && isOnlyOneSelected()) {
|
|
69
|
+
selectAllResources();
|
|
55
70
|
}
|
|
56
71
|
else {
|
|
57
|
-
|
|
72
|
+
selectOnlyResource(resource);
|
|
58
73
|
}
|
|
59
|
-
}, [
|
|
74
|
+
}, [
|
|
75
|
+
disabled,
|
|
76
|
+
isSelected,
|
|
77
|
+
addSelectedResource,
|
|
78
|
+
removeSelectedResource,
|
|
79
|
+
selectAllResources,
|
|
80
|
+
selectOnlyResource,
|
|
81
|
+
isOnlyOneSelected,
|
|
82
|
+
]);
|
|
60
83
|
return (_jsx(Legend, { direction: direction, children: resources.map((resource) => {
|
|
61
84
|
const color = getColor(resource);
|
|
62
85
|
const selected = isSelected(resource);
|
|
63
|
-
return (_jsxs(LegendItem, { disabled: disabled, selected: selected, onClick: () => handleLegendClick(resource), children: [_jsx(LegendShape, { color: color, shape: shape, chartColors: chartColors }), _jsx(Text, { variant: "Basic", children: resource })] }, resource));
|
|
86
|
+
return (_jsxs(LegendItem, { disabled: disabled, selected: selected, "aria-label": `${resource} ${selected ? 'selected' : 'not selected'}`, onClick: (event) => handleLegendClick(resource, event), children: [_jsx(LegendShape, { color: color, shape: shape, chartColors: chartColors }), _jsx(Text, { variant: "Basic", children: resource })] }, resource));
|
|
64
87
|
}) }));
|
|
65
88
|
};
|
|
@@ -4,9 +4,12 @@ export type ChartLegendState = {
|
|
|
4
4
|
selectedResources: string[];
|
|
5
5
|
addSelectedResource: (resource: string) => void;
|
|
6
6
|
removeSelectedResource: (resource: string) => void;
|
|
7
|
+
selectAllResources: () => void;
|
|
8
|
+
selectOnlyResource: (resource: string) => void;
|
|
7
9
|
isSelected: (resource: string) => boolean;
|
|
8
10
|
getColor: (resource: string) => string | undefined;
|
|
9
11
|
listResources: () => string[];
|
|
12
|
+
isOnlyOneSelected: () => boolean;
|
|
10
13
|
};
|
|
11
14
|
export type ChartLegendWrapperProps = {
|
|
12
15
|
children: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartLegendWrapper.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegendWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ChartLegendWrapper.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegendWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAGV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,sBAAsB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC1C,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACnD,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,iBAAiB,EAAE,MAAM,OAAO,CAAC;CAClC,CAAC;AAIF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,kBAAkB,4BAG5B,uBAAuB,4CAiFzB,CAAC;AAGF,eAAO,MAAM,cAAc,wBAM1B,CAAC"}
|