@synerise/ds-progress-bar 1.2.0 → 1.2.1
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/CHANGELOG.md +4 -0
- package/dist/Multivalue/MultiValue.styles.d.ts +2 -2
- package/dist/Multivalue/MultiValue.styles.js +9 -11
- package/dist/Multivalue/Multivalue.d.ts +2 -2
- package/dist/Multivalue/Multivalue.js +17 -29
- package/dist/Multivalue/Multivalue.types.d.ts +3 -3
- package/dist/Multivalue/Multivalue.types.js +1 -1
- package/dist/ProgressBar.d.ts +2 -2
- package/dist/ProgressBar.js +40 -62
- package/dist/ProgressBar.styles.d.ts +9 -9
- package/dist/ProgressBar.styles.js +26 -31
- package/dist/ProgressBar.types.d.ts +2 -2
- package/dist/ProgressBar.types.js +1 -1
- package/dist/ProgressTiles/ProgressTiles.d.ts +2 -2
- package/dist/ProgressTiles/ProgressTiles.js +31 -37
- package/dist/ProgressTiles/ProgressTiles.styles.d.ts +4 -4
- package/dist/ProgressTiles/ProgressTiles.styles.js +15 -17
- package/dist/ProgressTiles/ProgressTiles.types.d.ts +2 -2
- package/dist/ProgressTiles/ProgressTiles.types.js +1 -1
- package/dist/index.js +8 -3
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.2.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-progress-bar@1.2.0...@synerise/ds-progress-bar@1.2.1) (2026-03-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-progress-bar
|
|
9
|
+
|
|
6
10
|
# [1.2.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-progress-bar@1.1.40...@synerise/ds-progress-bar@1.2.0) (2026-03-20)
|
|
7
11
|
|
|
8
12
|
### Features
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare const Multivalue: import(
|
|
1
|
+
export declare const Multivalue: import('styled-components').StyledComponent<"div", any, {
|
|
2
2
|
color: string;
|
|
3
3
|
percent: number;
|
|
4
4
|
}, never>;
|
|
5
|
-
export declare const Container: import(
|
|
5
|
+
export declare const Container: import('styled-components').StyledComponent<"div", any, {
|
|
6
6
|
stackedBars: boolean;
|
|
7
7
|
}, never>;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
const Multivalue = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "MultiValuestyles__Multivalue",
|
|
4
4
|
componentId: "sc-145qx7z-0"
|
|
5
|
-
})(["background:", ";width:", "%;height:6px;border-radius:6px;overflow:hidden;margin-top:-6px;"],
|
|
6
|
-
|
|
7
|
-
}, function (props) {
|
|
8
|
-
return props.percent;
|
|
9
|
-
});
|
|
10
|
-
export var Container = styled.div.withConfig({
|
|
5
|
+
})(["background:", ";width:", "%;height:6px;border-radius:6px;overflow:hidden;margin-top:-6px;"], (props) => props.color, (props) => props.percent);
|
|
6
|
+
const Container = /* @__PURE__ */ styled.div.withConfig({
|
|
11
7
|
displayName: "MultiValuestyles__Container",
|
|
12
8
|
componentId: "sc-145qx7z-1"
|
|
13
|
-
})(["position:relative;height:16px;width:100%;padding-top:11px;", ""],
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
})(["position:relative;height:16px;width:100%;padding-top:11px;", ""], (props) => props.stackedBars ? css(["", ":not(:first-child){border-top-right-radius:0px;border-bottom-right-radius:0px;border-right:2px solid white;}"], Multivalue) : css(["justify-content:flex-start;display:flex;gap:2px;", "{border-radius:0;&:first-child{border-top-left-radius:6px;border-bottom-left-radius:6px;}&:last-child{border-top-right-radius:6px;border-bottom-right-radius:6px;}}"], Multivalue));
|
|
10
|
+
export {
|
|
11
|
+
Container,
|
|
12
|
+
Multivalue
|
|
13
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { MultivalueProps } from './Multivalue.types';
|
|
3
3
|
declare const Multivalue: ({ values, stackedBars, ...htmlAttributes }: MultivalueProps) => React.JSX.Element;
|
|
4
4
|
export default Multivalue;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import * as S from './MultiValue.styles';
|
|
7
|
-
var normalizePercent = function normalizePercent(value) {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
4
|
+
import { Container, Multivalue as Multivalue$1 } from "./MultiValue.styles.js";
|
|
5
|
+
const normalizePercent = (value) => {
|
|
8
6
|
if (value < 0) {
|
|
9
7
|
return 0;
|
|
10
8
|
}
|
|
@@ -13,26 +11,16 @@ var normalizePercent = function normalizePercent(value) {
|
|
|
13
11
|
}
|
|
14
12
|
return value;
|
|
15
13
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, htmlAttributes), finalValues.map(function (val, index) {
|
|
29
|
-
return /*#__PURE__*/React.createElement(Tooltip, _extends({
|
|
30
|
-
title: val.tooltip
|
|
31
|
-
}, val == null ? void 0 : val.tooltipProps), /*#__PURE__*/React.createElement(S.Multivalue, {
|
|
32
|
-
key: val.color + "-" + val.percent + "-" + index,
|
|
33
|
-
color: val.color,
|
|
34
|
-
percent: normalizePercent(val.percent)
|
|
35
|
-
}));
|
|
36
|
-
}));
|
|
14
|
+
const Multivalue = ({
|
|
15
|
+
values,
|
|
16
|
+
stackedBars = true,
|
|
17
|
+
...htmlAttributes
|
|
18
|
+
}) => {
|
|
19
|
+
const finalValues = useMemo(() => stackedBars ? values.sort((a, b) => {
|
|
20
|
+
return b.percent - a.percent;
|
|
21
|
+
}) : values, [stackedBars, values]);
|
|
22
|
+
return /* @__PURE__ */ jsx(Container, { stackedBars, ...htmlAttributes, children: finalValues.map((val, index) => /* @__PURE__ */ jsx(Tooltip, { title: val.tooltip, ...val?.tooltipProps, children: /* @__PURE__ */ jsx(Multivalue$1, { color: val.color, percent: normalizePercent(val.percent) }, `${val.color}-${val.percent}-${index}`) })) });
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
Multivalue as default
|
|
37
26
|
};
|
|
38
|
-
export default Multivalue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TooltipProps } from '@synerise/ds-tooltip';
|
|
3
|
+
import { WithHTMLAttributes } from '@synerise/ds-utils';
|
|
4
4
|
export type MultivalueProps = WithHTMLAttributes<HTMLDivElement, {
|
|
5
5
|
values: ProgressValue[];
|
|
6
6
|
stackedBars?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/dist/ProgressBar.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ProgressProps } from './ProgressBar.types';
|
|
3
3
|
declare const ProgressBar: ({ description, label, steps, width, customColor, percent, className, thin, containerStyles, inline, ...rest }: ProgressProps) => React.JSX.Element;
|
|
4
4
|
export default ProgressBar;
|
package/dist/ProgressBar.js
CHANGED
|
@@ -1,63 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return /*#__PURE__*/React.createElement(S.Container, _extends({
|
|
42
|
-
className: (className || '') + " progress-bar-container",
|
|
43
|
-
"data-testid": "progress-bar-container",
|
|
44
|
-
$steps: steps,
|
|
45
|
-
$inline: inline
|
|
46
|
-
}, rest), label && !inline && /*#__PURE__*/React.createElement(S.LabelWrapper, null, label && /*#__PURE__*/React.createElement(S.Label, {
|
|
47
|
-
"data-testid": "progress-bar-label"
|
|
48
|
-
}, label), /*#__PURE__*/React.createElement(S.Percent, {
|
|
49
|
-
"data-testid": "progress-bar-max-percent"
|
|
50
|
-
}, percent + "%")), /*#__PURE__*/React.createElement(S.ProgressOuter, null, tiles.map(function (tile, i) {
|
|
51
|
-
return /*#__PURE__*/React.createElement(S.ProgressWrapper, {
|
|
52
|
-
$thin: thin,
|
|
53
|
-
key: "key-" + tile.id,
|
|
54
|
-
$width: width
|
|
55
|
-
}, /*#__PURE__*/React.createElement(S.ProgressBar, {
|
|
56
|
-
customColor: customColor,
|
|
57
|
-
$width: (tilesWidthRatios[i] || 0) * MAX_PERCENT + "%"
|
|
58
|
-
}));
|
|
59
|
-
})), inline && /*#__PURE__*/React.createElement(S.PercentWrapper, null, label || percent + "%"), description && !inline && /*#__PURE__*/React.createElement(S.ProgressBarDescription, {
|
|
60
|
-
"data-testid": "progress-bar-description"
|
|
61
|
-
}, description));
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { v4 } from "uuid";
|
|
4
|
+
import { Container, LabelWrapper, Label, Percent, ProgressOuter, ProgressWrapper, ProgressBar as ProgressBar$1, PercentWrapper, ProgressBarDescription } from "./ProgressBar.styles.js";
|
|
5
|
+
const MAX_PERCENT = 100;
|
|
6
|
+
const ProgressBar = ({
|
|
7
|
+
description = "",
|
|
8
|
+
label,
|
|
9
|
+
steps = 1,
|
|
10
|
+
width = "100%",
|
|
11
|
+
customColor = "",
|
|
12
|
+
percent = 50,
|
|
13
|
+
className,
|
|
14
|
+
thin = false,
|
|
15
|
+
containerStyles,
|
|
16
|
+
inline = false,
|
|
17
|
+
...rest
|
|
18
|
+
}) => {
|
|
19
|
+
const tiles = useMemo(() => Array.from({
|
|
20
|
+
length: steps
|
|
21
|
+
}, () => ({
|
|
22
|
+
id: v4()
|
|
23
|
+
})), [steps]);
|
|
24
|
+
const tileWidthRatio = MAX_PERCENT / steps;
|
|
25
|
+
const currentProgress = percent / tileWidthRatio;
|
|
26
|
+
const tileWidths = Array(Math.floor(currentProgress)).fill(1);
|
|
27
|
+
const lastTileWidth = currentProgress % 1;
|
|
28
|
+
const tilesWidthRatios = [...tileWidths, lastTileWidth];
|
|
29
|
+
return /* @__PURE__ */ jsxs(Container, { className: `${className || ""} progress-bar-container`, "data-testid": "progress-bar-container", $steps: steps, $inline: inline, ...rest, children: [
|
|
30
|
+
label && !inline && /* @__PURE__ */ jsxs(LabelWrapper, { children: [
|
|
31
|
+
label && /* @__PURE__ */ jsx(Label, { "data-testid": "progress-bar-label", children: label }),
|
|
32
|
+
/* @__PURE__ */ jsx(Percent, { "data-testid": "progress-bar-max-percent", children: `${percent}%` })
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ jsx(ProgressOuter, { children: tiles.map((tile, i) => /* @__PURE__ */ jsx(ProgressWrapper, { $thin: thin, $width: width, children: /* @__PURE__ */ jsx(ProgressBar$1, { customColor, $width: `${(tilesWidthRatios[i] || 0) * MAX_PERCENT}%` }) }, `key-${tile.id}`)) }),
|
|
35
|
+
inline && /* @__PURE__ */ jsx(PercentWrapper, { children: label || `${percent}%` }),
|
|
36
|
+
description && !inline && /* @__PURE__ */ jsx(ProgressBarDescription, { "data-testid": "progress-bar-description", children: description })
|
|
37
|
+
] });
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
ProgressBar as default
|
|
62
41
|
};
|
|
63
|
-
export default ProgressBar;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export declare const LabelWrapper: import(
|
|
2
|
-
export declare const Label: import(
|
|
3
|
-
export declare const ProgressWrapper: import(
|
|
1
|
+
export declare const LabelWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const Label: import('styled-components').StyledComponent<({ id, label, tooltip, tooltipConfig, children, ...htmlAttributes }: import('@synerise/ds-form-field').FormFieldLabelProps) => React.JSX.Element, any, {}, never>;
|
|
3
|
+
export declare const ProgressWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
4
4
|
$width: string;
|
|
5
5
|
$thin: boolean;
|
|
6
6
|
}, never>;
|
|
7
|
-
export declare const ProgressOuter: import(
|
|
8
|
-
export declare const Percent: import(
|
|
9
|
-
export declare const ProgressBarDescription: import(
|
|
10
|
-
export declare const ProgressBar: import(
|
|
7
|
+
export declare const ProgressOuter: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const Percent: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
9
|
+
export declare const ProgressBarDescription: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
10
|
+
export declare const ProgressBar: import('styled-components').StyledComponent<"div", any, {
|
|
11
11
|
customColor: string;
|
|
12
12
|
$width: string;
|
|
13
13
|
}, never>;
|
|
14
|
-
export declare const PercentWrapper: import(
|
|
15
|
-
export declare const Container: import(
|
|
14
|
+
export declare const PercentWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
15
|
+
export declare const Container: import('styled-components').StyledComponent<"div", any, {
|
|
16
16
|
$steps?: number;
|
|
17
17
|
$inline?: boolean;
|
|
18
18
|
}, never>;
|
|
@@ -1,54 +1,49 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
import { FormFieldLabel } from
|
|
3
|
-
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { FormFieldLabel } from "@synerise/ds-form-field";
|
|
3
|
+
const LabelWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
4
4
|
displayName: "ProgressBarstyles__LabelWrapper",
|
|
5
5
|
componentId: "sc-1gqovic-0"
|
|
6
6
|
})(["display:flex;align-items:center;margin-bottom:8px;"]);
|
|
7
|
-
|
|
7
|
+
const Label = /* @__PURE__ */ styled(FormFieldLabel).withConfig({
|
|
8
8
|
displayName: "ProgressBarstyles__Label",
|
|
9
9
|
componentId: "sc-1gqovic-1"
|
|
10
10
|
})(["&&&{margin:0 8px 0 0;align-items:center;}"]);
|
|
11
|
-
|
|
11
|
+
const ProgressWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
12
12
|
displayName: "ProgressBarstyles__ProgressWrapper",
|
|
13
13
|
componentId: "sc-1gqovic-2"
|
|
14
|
-
})(["position:relative;margin-right:2px;width:", ";height:", ";background:", ";"],
|
|
15
|
-
|
|
16
|
-
}, function (props) {
|
|
17
|
-
return props.$thin ? '4px' : '6px';
|
|
18
|
-
}, function (props) {
|
|
19
|
-
return props.theme.palette['grey-200'];
|
|
20
|
-
});
|
|
21
|
-
export var ProgressOuter = styled.div.withConfig({
|
|
14
|
+
})(["position:relative;margin-right:2px;width:", ";height:", ";background:", ";"], (props) => props.$width, (props) => props.$thin ? "4px" : "6px", (props) => props.theme.palette["grey-200"]);
|
|
15
|
+
const ProgressOuter = /* @__PURE__ */ styled.div.withConfig({
|
|
22
16
|
displayName: "ProgressBarstyles__ProgressOuter",
|
|
23
17
|
componentId: "sc-1gqovic-3"
|
|
24
18
|
})(["display:flex;align-items:center;min-width:0;flex:1 1 auto;"]);
|
|
25
|
-
|
|
19
|
+
const Percent = /* @__PURE__ */ styled.span.withConfig({
|
|
26
20
|
displayName: "ProgressBarstyles__Percent",
|
|
27
21
|
componentId: "sc-1gqovic-4"
|
|
28
22
|
})([""]);
|
|
29
|
-
|
|
23
|
+
const ProgressBarDescription = /* @__PURE__ */ styled.span.withConfig({
|
|
30
24
|
displayName: "ProgressBarstyles__ProgressBarDescription",
|
|
31
25
|
componentId: "sc-1gqovic-5"
|
|
32
26
|
})(["margin-top:8px;"]);
|
|
33
|
-
|
|
27
|
+
const ProgressBar = /* @__PURE__ */ styled.div.withConfig({
|
|
34
28
|
displayName: "ProgressBarstyles__ProgressBar",
|
|
35
29
|
componentId: "sc-1gqovic-6"
|
|
36
|
-
})(["position:absolute;height:100%;width:", ";background-color:", ";"],
|
|
37
|
-
|
|
38
|
-
}, function (props) {
|
|
39
|
-
return props.customColor ? props.customColor : props.theme.palette['green-500'];
|
|
40
|
-
});
|
|
41
|
-
export var PercentWrapper = styled.div.withConfig({
|
|
30
|
+
})(["position:absolute;height:100%;width:", ";background-color:", ";"], (props) => props.$width, (props) => props.customColor ? props.customColor : props.theme.palette["green-500"]);
|
|
31
|
+
const PercentWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
42
32
|
displayName: "ProgressBarstyles__PercentWrapper",
|
|
43
33
|
componentId: "sc-1gqovic-7"
|
|
44
|
-
})(["margin-left:8px;color:", ";font-weight:400;"],
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
export var Container = styled.div.withConfig({
|
|
34
|
+
})(["margin-left:8px;color:", ";font-weight:400;"], (props) => props.theme.palette["grey-800"]);
|
|
35
|
+
const Container = /* @__PURE__ */ styled.div.withConfig({
|
|
48
36
|
displayName: "ProgressBarstyles__Container",
|
|
49
37
|
componentId: "sc-1gqovic-8"
|
|
50
|
-
})(["width:100%;display:flex;justify-content:center;flex-direction:", ";", ":last-of-type{border-radius:3px;", ":last-of-type{border-radius:3px;}}", ""],
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
})(["width:100%;display:flex;justify-content:center;flex-direction:", ";", ":last-of-type{border-radius:3px;", ":last-of-type{border-radius:3px;}}", ""], (props) => props.$inline ? "row" : "column", ProgressWrapper, ProgressBar, (props) => props.$steps !== 1 && css(["", ":first-of-type{border-radius:3px 0 0 3px;", ":first-of-type{border-radius:3px 0 0 3px;}}", ":last-of-type{border-radius:0 3px 3px 0;", ":last-of-type{border-radius:0 3px 3px 0;}}"], ProgressWrapper, ProgressBar, ProgressWrapper, ProgressBar));
|
|
39
|
+
export {
|
|
40
|
+
Container,
|
|
41
|
+
Label,
|
|
42
|
+
LabelWrapper,
|
|
43
|
+
Percent,
|
|
44
|
+
PercentWrapper,
|
|
45
|
+
ProgressBar,
|
|
46
|
+
ProgressBarDescription,
|
|
47
|
+
ProgressOuter,
|
|
48
|
+
ProgressWrapper
|
|
49
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { WithHTMLAttributes } from '@synerise/ds-utils';
|
|
3
3
|
export type ProgressProps = WithHTMLAttributes<HTMLDivElement, {
|
|
4
4
|
label?: ReactNode;
|
|
5
5
|
steps?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ProgressTilesProps } from './ProgressTiles.types';
|
|
3
3
|
export declare const ProgressTiles: ({ colors, label, tileWidth, percent, ...rest }: ProgressTilesProps) => React.JSX.Element;
|
|
4
4
|
export default ProgressTiles;
|
|
@@ -1,39 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return colors.map(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
width: (tilesWidthRatios[i] || 0) * MAX_PERCENT + "%"
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
}, [colors, percent]);
|
|
27
|
-
return /*#__PURE__*/React.createElement(S.TilesWrapper, rest, label && /*#__PURE__*/React.createElement(S.Label, null, label), /*#__PURE__*/React.createElement("div", {
|
|
28
|
-
className: "progress-bar-wrapper"
|
|
29
|
-
}, getTilesConfig().map(function (tile) {
|
|
30
|
-
return /*#__PURE__*/React.createElement(S.TileContainer, {
|
|
31
|
-
key: "key-" + tile.key,
|
|
32
|
-
width: tileWidth
|
|
33
|
-
}, /*#__PURE__*/React.createElement(S.TileProgress, {
|
|
34
|
-
color: tile.color,
|
|
35
|
-
width: tile.width
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { TilesWrapper, Label, TileContainer, TileProgress } from "./ProgressTiles.styles.js";
|
|
4
|
+
const MAX_PERCENT = 100;
|
|
5
|
+
const ProgressTiles = ({
|
|
6
|
+
colors,
|
|
7
|
+
label,
|
|
8
|
+
tileWidth,
|
|
9
|
+
percent,
|
|
10
|
+
...rest
|
|
11
|
+
}) => {
|
|
12
|
+
const getTilesConfig = useCallback(() => {
|
|
13
|
+
const TILES_COUNT = colors.length;
|
|
14
|
+
const tileWidthRatio = MAX_PERCENT / TILES_COUNT;
|
|
15
|
+
const currentProgress = percent / tileWidthRatio;
|
|
16
|
+
const tileWidths = Array(Math.floor(currentProgress)).fill(1);
|
|
17
|
+
const lastTileWidth = currentProgress % 1;
|
|
18
|
+
const tilesWidthRatios = [...tileWidths, lastTileWidth];
|
|
19
|
+
return colors.map((color, i) => ({
|
|
20
|
+
key: i,
|
|
21
|
+
color,
|
|
22
|
+
width: `${(tilesWidthRatios[i] || 0) * MAX_PERCENT}%`
|
|
36
23
|
}));
|
|
37
|
-
})
|
|
24
|
+
}, [colors, percent]);
|
|
25
|
+
return /* @__PURE__ */ jsxs(TilesWrapper, { ...rest, children: [
|
|
26
|
+
label && /* @__PURE__ */ jsx(Label, { children: label }),
|
|
27
|
+
/* @__PURE__ */ jsx("div", { className: "progress-bar-wrapper", children: getTilesConfig().map((tile) => /* @__PURE__ */ jsx(TileContainer, { width: tileWidth, children: /* @__PURE__ */ jsx(TileProgress, { color: tile.color, width: tile.width }) }, `key-${tile.key}`)) })
|
|
28
|
+
] });
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
ProgressTiles,
|
|
32
|
+
ProgressTiles as default
|
|
38
33
|
};
|
|
39
|
-
export default ProgressTiles;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare const TileContainer: import(
|
|
1
|
+
export declare const TileContainer: import('styled-components').StyledComponent<"div", any, {
|
|
2
2
|
width: string;
|
|
3
3
|
}, never>;
|
|
4
|
-
export declare const TileProgress: import(
|
|
4
|
+
export declare const TileProgress: import('styled-components').StyledComponent<"div", any, {
|
|
5
5
|
color: string;
|
|
6
6
|
width: string;
|
|
7
7
|
}, never>;
|
|
8
|
-
export declare const Label: import(
|
|
9
|
-
export declare const TilesWrapper: import(
|
|
8
|
+
export declare const Label: import('styled-components').StyledComponent<({ id, label, tooltip, tooltipConfig, children, ...htmlAttributes }: import('@synerise/ds-form-field').FormFieldLabelProps) => React.JSX.Element, any, {}, never>;
|
|
9
|
+
export declare const TilesWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
import { FormFieldLabel } from
|
|
3
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { FormFieldLabel } from "@synerise/ds-form-field";
|
|
3
|
+
const TileContainer = /* @__PURE__ */ styled.div.withConfig({
|
|
4
4
|
displayName: "ProgressTilesstyles__TileContainer",
|
|
5
5
|
componentId: "sc-sod9jl-0"
|
|
6
|
-
})(["position:relative;margin-right:2px;width:", ";height:6px;background:", ";"],
|
|
7
|
-
|
|
8
|
-
}, function (props) {
|
|
9
|
-
return props.theme.palette['grey-200'];
|
|
10
|
-
});
|
|
11
|
-
export var TileProgress = styled.div.withConfig({
|
|
6
|
+
})(["position:relative;margin-right:2px;width:", ";height:6px;background:", ";"], (props) => props.width, (props) => props.theme.palette["grey-200"]);
|
|
7
|
+
const TileProgress = /* @__PURE__ */ styled.div.withConfig({
|
|
12
8
|
displayName: "ProgressTilesstyles__TileProgress",
|
|
13
9
|
componentId: "sc-sod9jl-1"
|
|
14
|
-
})(["position:absolute;height:100%;width:", ";background-color:", ";"],
|
|
15
|
-
|
|
16
|
-
}, function (props) {
|
|
17
|
-
return props.color;
|
|
18
|
-
});
|
|
19
|
-
export var Label = styled(FormFieldLabel).withConfig({
|
|
10
|
+
})(["position:absolute;height:100%;width:", ";background-color:", ";"], (props) => props.width, (props) => props.color);
|
|
11
|
+
const Label = /* @__PURE__ */ styled(FormFieldLabel).withConfig({
|
|
20
12
|
displayName: "ProgressTilesstyles__Label",
|
|
21
13
|
componentId: "sc-sod9jl-2"
|
|
22
14
|
})(["margin-bottom:12px;cursor:pointer;"]);
|
|
23
|
-
|
|
15
|
+
const TilesWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
24
16
|
displayName: "ProgressTilesstyles__TilesWrapper",
|
|
25
17
|
componentId: "sc-sod9jl-3"
|
|
26
|
-
})(["width:100%;display:flex;justify-content:center;flex-direction:column;.progress-bar-wrapper{display:flex;}", ":first-of-type{border-radius:3px 0 0 3px;", ":first-of-type{border-radius:3px 0 0 3px;}}", ":last-of-type{border-radius:0 3px 3px 0;", ":last-of-type{border-radius:0 3px 3px 0;}}"], TileContainer, TileProgress, TileContainer, TileProgress);
|
|
18
|
+
})(["width:100%;display:flex;justify-content:center;flex-direction:column;.progress-bar-wrapper{display:flex;}", ":first-of-type{border-radius:3px 0 0 3px;", ":first-of-type{border-radius:3px 0 0 3px;}}", ":last-of-type{border-radius:0 3px 3px 0;", ":last-of-type{border-radius:0 3px 3px 0;}}"], TileContainer, TileProgress, TileContainer, TileProgress);
|
|
19
|
+
export {
|
|
20
|
+
Label,
|
|
21
|
+
TileContainer,
|
|
22
|
+
TileProgress,
|
|
23
|
+
TilesWrapper
|
|
24
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { WithHTMLAttributes } from '@synerise/ds-utils';
|
|
3
3
|
export type ProgressTilesProps = WithHTMLAttributes<HTMLDivElement, {
|
|
4
4
|
tileWidth: string;
|
|
5
5
|
colors: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { default as default2 } from "./ProgressBar.js";
|
|
2
|
+
import { default as default3 } from "./Multivalue/Multivalue.js";
|
|
3
|
+
import { ProgressTiles } from "./ProgressTiles/ProgressTiles.js";
|
|
4
|
+
export {
|
|
5
|
+
default3 as Multivalue,
|
|
6
|
+
ProgressTiles,
|
|
7
|
+
default2 as default
|
|
8
|
+
};
|
package/dist/modules.d.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-progress-bar",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Progress-Bar UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "vite build",
|
|
20
20
|
"build:css": "node ../../../scripts/style/less.js",
|
|
21
21
|
"build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
|
|
22
|
-
"build:watch": "
|
|
22
|
+
"build:watch": "vite build --watch",
|
|
23
23
|
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
24
24
|
"pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
|
|
25
25
|
"prepublish": "pnpm run build",
|
|
@@ -35,14 +35,15 @@
|
|
|
35
35
|
],
|
|
36
36
|
"types": "dist/index.d.ts",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@synerise/ds-form-field": "^1.3.
|
|
39
|
-
"@synerise/ds-tooltip": "^1.4.
|
|
40
|
-
"@synerise/ds-utils": "^1.7.
|
|
38
|
+
"@synerise/ds-form-field": "^1.3.10",
|
|
39
|
+
"@synerise/ds-tooltip": "^1.4.10",
|
|
40
|
+
"@synerise/ds-utils": "^1.7.1",
|
|
41
|
+
"uuid": "^8.3.2"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"@synerise/ds-core": "*",
|
|
44
45
|
"react": ">=16.9.0 <= 18.3.1",
|
|
45
46
|
"styled-components": "^5.3.3"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "e4ecca8944fc9b41c1b9d59c8bcad5e5e2013225"
|
|
48
49
|
}
|