@chayns-components/core 5.0.26 → 5.0.28
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/lib/cjs/components/progress-bar/ProgressBar.js +117 -176
- package/lib/cjs/components/progress-bar/ProgressBar.js.map +1 -1
- package/lib/cjs/components/progress-bar/ProgressBar.styles.js +6 -4
- package/lib/cjs/components/progress-bar/ProgressBar.styles.js.map +1 -1
- package/lib/esm/components/progress-bar/ProgressBar.js +107 -168
- package/lib/esm/components/progress-bar/ProgressBar.js.map +1 -1
- package/lib/esm/components/progress-bar/ProgressBar.styles.js +6 -4
- package/lib/esm/components/progress-bar/ProgressBar.styles.js.map +1 -1
- package/lib/types/components/progress-bar/ProgressBar.d.ts +4 -0
- package/lib/types/components/progress-bar/ProgressBar.styles.d.ts +1 -0
- package/package.json +2 -2
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _reactCompilerRuntime = require("react-compiler-runtime");
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
8
|
var _uuid = require("../../hooks/uuid");
|
|
10
9
|
var _ProgressBar = require("./ProgressBar.styles");
|
|
@@ -13,198 +12,140 @@ var _styledComponents = require("styled-components");
|
|
|
13
12
|
var _Popup = _interopRequireDefault(require("../popup/Popup"));
|
|
14
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
14
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
-
const ProgressBar =
|
|
17
|
-
|
|
15
|
+
const ProgressBar = ({
|
|
16
|
+
percentage,
|
|
17
|
+
label,
|
|
18
|
+
shouldHideProgress = false,
|
|
19
|
+
shouldShowLabelInline = false,
|
|
20
|
+
steps,
|
|
21
|
+
colors,
|
|
22
|
+
thumbLabel,
|
|
23
|
+
showShine = false,
|
|
24
|
+
height
|
|
25
|
+
}) => {
|
|
26
|
+
'use memo';
|
|
18
27
|
|
|
19
|
-
const $ = (0, _reactCompilerRuntime.c)(29);
|
|
20
|
-
const {
|
|
21
|
-
percentage,
|
|
22
|
-
label,
|
|
23
|
-
shouldHideProgress: t1,
|
|
24
|
-
shouldShowLabelInline: t2,
|
|
25
|
-
steps,
|
|
26
|
-
colors,
|
|
27
|
-
thumbLabel,
|
|
28
|
-
showShine: t3
|
|
29
|
-
} = t0;
|
|
30
|
-
const shouldHideProgress = t1 === undefined ? false : t1;
|
|
31
|
-
const shouldShowLabelInline = t2 === undefined ? false : t2;
|
|
32
|
-
const showShine = t3 === undefined ? false : t3;
|
|
33
28
|
const uuid = (0, _uuid.useUuid)();
|
|
29
|
+
const [coordinates, setCoordinates] = (0, _react.useState)();
|
|
34
30
|
const popupRef = (0, _react.useRef)(null);
|
|
31
|
+
const hostContainerRef = (0, _react.useRef)(null);
|
|
35
32
|
const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const shineEffect = (0, _react.useMemo)(() => {
|
|
34
|
+
if (!showShine || percentage === undefined) return null;
|
|
35
|
+
const MIN_ANIMATION_LENGTH = 1;
|
|
36
|
+
const MAX_ANIMATION_LENGTH = 5;
|
|
37
|
+
const MAX_SHINE_COUNT = 6;
|
|
38
|
+
const t = percentage / 100;
|
|
39
|
+
const shineCount = Math.ceil(MAX_SHINE_COUNT * t);
|
|
40
|
+
const speed = MIN_ANIMATION_LENGTH + (MAX_ANIMATION_LENGTH - MIN_ANIMATION_LENGTH) * t;
|
|
41
|
+
return Array.from({
|
|
42
|
+
length: shineCount
|
|
43
|
+
}).map((_, index) => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarShine
|
|
44
|
+
/* eslint-disable-next-line react/no-array-index-key */, {
|
|
45
|
+
key: `progress-bar-shine__${shineCount}__${index}`,
|
|
46
|
+
$speed: speed,
|
|
47
|
+
$delay: -(speed / shineCount) * index
|
|
48
|
+
}));
|
|
49
|
+
}, [percentage, showShine]);
|
|
50
|
+
(0, _react.useEffect)(() => {
|
|
51
|
+
var _hostContainerRef$cur;
|
|
52
|
+
if (thumbLabel) setCoordinates((_hostContainerRef$cur = hostContainerRef.current) === null || _hostContainerRef$cur === void 0 ? void 0 : _hostContainerRef$cur.getBoundingClientRect());
|
|
53
|
+
}, [thumbLabel]);
|
|
54
|
+
(0, _react.useEffect)(() => {
|
|
55
|
+
var _popupRef$current;
|
|
56
|
+
if (coordinates) (_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 || _popupRef$current.show();
|
|
57
|
+
}, [coordinates]);
|
|
58
|
+
const progressBar = (0, _react.useMemo)(() => {
|
|
59
|
+
if (shouldHideProgress) {
|
|
60
|
+
return null;
|
|
41
61
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if ($[0] !== shineCount) {
|
|
46
|
-
t5 = Array.from({
|
|
47
|
-
length: shineCount
|
|
48
|
-
});
|
|
49
|
-
$[0] = shineCount;
|
|
50
|
-
$[1] = t5;
|
|
51
|
-
} else {
|
|
52
|
-
t5 = $[1];
|
|
53
|
-
}
|
|
54
|
-
let t6;
|
|
55
|
-
if ($[2] !== shineCount || $[3] !== speed || $[4] !== t5) {
|
|
56
|
-
t6 = t5.map((_, index) => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarShine, {
|
|
57
|
-
key: `progress-bar-shine__${shineCount}__${index}`,
|
|
58
|
-
$speed: speed,
|
|
59
|
-
$delay: 5 / shineCount * index
|
|
60
|
-
}));
|
|
61
|
-
$[2] = shineCount;
|
|
62
|
-
$[3] = speed;
|
|
63
|
-
$[4] = t5;
|
|
64
|
-
$[5] = t6;
|
|
65
|
-
} else {
|
|
66
|
-
t6 = $[5];
|
|
67
|
-
}
|
|
68
|
-
t4 = t6;
|
|
69
|
-
}
|
|
70
|
-
const shineEffect = t4;
|
|
71
|
-
let t5;
|
|
72
|
-
if ($[6] !== (colors === null || colors === void 0 ? void 0 : colors.backgroundColor) || $[7] !== (colors === null || colors === void 0 ? void 0 : colors.primaryTextColor) || $[8] !== (colors === null || colors === void 0 ? void 0 : colors.progressColor) || $[9] !== (colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor) || $[10] !== (colors === null || colors === void 0 ? void 0 : colors.stepColor) || $[11] !== label || $[12] !== percentage || $[13] !== shineEffect || $[14] !== shouldHideProgress || $[15] !== shouldShowLabelInline || $[16] !== showShine || $[17] !== steps || $[18] !== theme || $[19] !== thumbLabel || $[20] !== uuid) {
|
|
73
|
-
colors === null || colors === void 0 || colors.backgroundColor;
|
|
74
|
-
colors === null || colors === void 0 || colors.primaryTextColor;
|
|
75
|
-
colors === null || colors === void 0 || colors.progressColor;
|
|
76
|
-
colors === null || colors === void 0 || colors.secondaryTextColor;
|
|
77
|
-
colors === null || colors === void 0 || colors.stepColor;
|
|
78
|
-
t5 = (() => {
|
|
79
|
-
if (shouldHideProgress) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
if (percentage === undefined) {
|
|
83
|
-
return /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarProgressWrapper, null, /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledMotionProgressBarProgress, {
|
|
84
|
-
key: `progress-bar-loop__${uuid}`,
|
|
85
|
-
$color: colors === null || colors === void 0 ? void 0 : colors.progressColor,
|
|
86
|
-
initial: {
|
|
87
|
-
width: "200px",
|
|
88
|
-
left: "-200px"
|
|
89
|
-
},
|
|
90
|
-
animate: {
|
|
91
|
-
width: "200px",
|
|
92
|
-
left: "100%"
|
|
93
|
-
},
|
|
94
|
-
exit: {
|
|
95
|
-
width: "200px",
|
|
96
|
-
left: "100%"
|
|
97
|
-
},
|
|
98
|
-
transition: {
|
|
99
|
-
type: "tween",
|
|
100
|
-
repeat: Infinity,
|
|
101
|
-
repeatDelay: 0,
|
|
102
|
-
duration: 1
|
|
103
|
-
}
|
|
104
|
-
}), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarBackground, {
|
|
105
|
-
$color: colors === null || colors === void 0 ? void 0 : colors.backgroundColor
|
|
106
|
-
}));
|
|
107
|
-
}
|
|
108
|
-
return /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarProgressWrapper, {
|
|
109
|
-
$isBig: shouldShowLabelInline
|
|
110
|
-
}, !!(steps !== null && steps !== void 0 && steps.length) && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarStepWrapper, null, steps.map(step => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarStep, {
|
|
111
|
-
$position: step,
|
|
112
|
-
key: `progress-step-${step}`,
|
|
113
|
-
$color: colors === null || colors === void 0 ? void 0 : colors.stepColor
|
|
114
|
-
}))), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledMotionProgressBarProgress, {
|
|
62
|
+
if (percentage === undefined) {
|
|
63
|
+
return /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarProgressWrapper, null, /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledMotionProgressBarProgress, {
|
|
64
|
+
key: `progress-bar-loop__${uuid}`,
|
|
115
65
|
$color: colors === null || colors === void 0 ? void 0 : colors.progressColor,
|
|
116
|
-
key: `progress-bar__${uuid}`,
|
|
117
66
|
initial: {
|
|
118
|
-
width:
|
|
67
|
+
width: '200px',
|
|
68
|
+
left: '-200px'
|
|
119
69
|
},
|
|
120
70
|
animate: {
|
|
121
|
-
width:
|
|
71
|
+
width: '200px',
|
|
72
|
+
left: '100%'
|
|
122
73
|
},
|
|
123
74
|
exit: {
|
|
124
|
-
width:
|
|
75
|
+
width: '200px',
|
|
76
|
+
left: '100%'
|
|
125
77
|
},
|
|
126
78
|
transition: {
|
|
127
|
-
type:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return (_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : _popupRef$current.show();
|
|
132
|
-
},
|
|
133
|
-
onAnimationComplete: () => {
|
|
134
|
-
var _popupRef$current2;
|
|
135
|
-
return (_popupRef$current2 = popupRef.current) === null || _popupRef$current2 === void 0 ? void 0 : _popupRef$current2.show();
|
|
136
|
-
}
|
|
137
|
-
}, showShine && shineEffect, thumbLabel && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarThumbLabel, {
|
|
138
|
-
onClick: _temp
|
|
139
|
-
}, /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
|
|
140
|
-
theme: {
|
|
141
|
-
"000": (colors === null || colors === void 0 ? void 0 : colors.backgroundColor) ?? (theme === null || theme === void 0 ? void 0 : theme["104"]),
|
|
142
|
-
text: (colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor) ?? (theme === null || theme === void 0 ? void 0 : theme["300"])
|
|
143
|
-
}
|
|
144
|
-
}, /*#__PURE__*/_react.default.createElement(_Popup.default, {
|
|
145
|
-
ref: popupRef,
|
|
146
|
-
content: thumbLabel,
|
|
147
|
-
alignment: _popup.PopupAlignment.TopCenter,
|
|
148
|
-
onHide: () => {
|
|
149
|
-
var _popupRef$current3;
|
|
150
|
-
return (_popupRef$current3 = popupRef.current) === null || _popupRef$current3 === void 0 ? void 0 : _popupRef$current3.show();
|
|
79
|
+
type: 'tween',
|
|
80
|
+
repeat: Infinity,
|
|
81
|
+
repeatDelay: 0,
|
|
82
|
+
duration: 1
|
|
151
83
|
}
|
|
152
|
-
})
|
|
153
|
-
$shouldShowLabelInline: shouldShowLabelInline,
|
|
154
|
-
$primaryColor: colors === null || colors === void 0 ? void 0 : colors.primaryTextColor,
|
|
155
|
-
$secondaryColor: colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor,
|
|
156
|
-
$colorSplitPosition: percentage
|
|
157
|
-
}, label), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarBackground, {
|
|
84
|
+
}), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarBackground, {
|
|
158
85
|
$color: colors === null || colors === void 0 ? void 0 : colors.backgroundColor
|
|
159
86
|
}));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
87
|
+
}
|
|
88
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
89
|
+
ref: hostContainerRef
|
|
90
|
+
}, /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarProgressWrapper, {
|
|
91
|
+
$isBig: shouldShowLabelInline,
|
|
92
|
+
$height: height
|
|
93
|
+
}, !!(steps !== null && steps !== void 0 && steps.length) && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarStepWrapper, null, steps.map(step => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarStep, {
|
|
94
|
+
$position: step,
|
|
95
|
+
key: `progress-step-${step}`,
|
|
96
|
+
$color: colors === null || colors === void 0 ? void 0 : colors.stepColor
|
|
97
|
+
}))), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledMotionProgressBarProgress, {
|
|
98
|
+
$color: colors === null || colors === void 0 ? void 0 : colors.progressColor,
|
|
99
|
+
key: `progress-bar__${uuid}`,
|
|
100
|
+
initial: {
|
|
101
|
+
width: '0%'
|
|
102
|
+
},
|
|
103
|
+
animate: {
|
|
104
|
+
width: `${percentage}%`
|
|
105
|
+
},
|
|
106
|
+
exit: {
|
|
107
|
+
width: '0%'
|
|
108
|
+
},
|
|
109
|
+
transition: {
|
|
110
|
+
type: 'tween'
|
|
111
|
+
},
|
|
112
|
+
onUpdate: () => {
|
|
113
|
+
var _popupRef$current2;
|
|
114
|
+
return (_popupRef$current2 = popupRef.current) === null || _popupRef$current2 === void 0 ? void 0 : _popupRef$current2.show();
|
|
115
|
+
},
|
|
116
|
+
onAnimationComplete: () => {
|
|
117
|
+
var _popupRef$current3;
|
|
118
|
+
return (_popupRef$current3 = popupRef.current) === null || _popupRef$current3 === void 0 ? void 0 : _popupRef$current3.show();
|
|
119
|
+
}
|
|
120
|
+
}, showShine && shineEffect, thumbLabel && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarThumbLabel, {
|
|
121
|
+
onClick: event => event.stopPropagation()
|
|
122
|
+
}, /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
|
|
123
|
+
theme: {
|
|
124
|
+
'000': (colors === null || colors === void 0 ? void 0 : colors.backgroundColor) ?? (theme === null || theme === void 0 ? void 0 : theme['104']),
|
|
125
|
+
text: (colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor) ?? (theme === null || theme === void 0 ? void 0 : theme['300'])
|
|
126
|
+
}
|
|
127
|
+
}, /*#__PURE__*/_react.default.createElement(_Popup.default, {
|
|
128
|
+
ref: popupRef,
|
|
129
|
+
content: thumbLabel,
|
|
130
|
+
alignment: _popup.PopupAlignment.TopCenter,
|
|
131
|
+
onHide: () => {
|
|
132
|
+
var _popupRef$current4;
|
|
133
|
+
return (_popupRef$current4 = popupRef.current) === null || _popupRef$current4 === void 0 ? void 0 : _popupRef$current4.show();
|
|
134
|
+
},
|
|
135
|
+
container: hostContainerRef.current ?? undefined
|
|
136
|
+
})))), shouldShowLabelInline && label && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarLabel, {
|
|
137
|
+
$shouldShowLabelInline: shouldShowLabelInline,
|
|
138
|
+
$primaryColor: colors === null || colors === void 0 ? void 0 : colors.primaryTextColor,
|
|
139
|
+
$secondaryColor: colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor,
|
|
140
|
+
$colorSplitPosition: percentage
|
|
141
|
+
}, label), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarBackground, {
|
|
142
|
+
$color: colors === null || colors === void 0 ? void 0 : colors.backgroundColor
|
|
143
|
+
})));
|
|
144
|
+
}, [colors === null || colors === void 0 ? void 0 : colors.backgroundColor, colors === null || colors === void 0 ? void 0 : colors.primaryTextColor, colors === null || colors === void 0 ? void 0 : colors.progressColor, colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor, colors === null || colors === void 0 ? void 0 : colors.stepColor, height, label, percentage, shineEffect, shouldHideProgress, shouldShowLabelInline, showShine, steps, theme, thumbLabel, uuid]);
|
|
145
|
+
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBar, null, progressBar, label && !shouldShowLabelInline && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarLabel, {
|
|
146
|
+
$primaryColor: colors === null || colors === void 0 ? void 0 : colors.primaryTextColor
|
|
147
|
+
}, label)), [colors === null || colors === void 0 ? void 0 : colors.primaryTextColor, label, progressBar, shouldShowLabelInline]);
|
|
204
148
|
};
|
|
205
149
|
ProgressBar.displayName = 'ProgressBar';
|
|
206
150
|
var _default = exports.default = ProgressBar;
|
|
207
|
-
function _temp(event) {
|
|
208
|
-
return event.stopPropagation();
|
|
209
|
-
}
|
|
210
151
|
//# sourceMappingURL=ProgressBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","names":["_react","_interopRequireWildcard","require","_uuid","_ProgressBar","_popup","_styledComponents","_Popup","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ProgressBar","t0","$","_reactCompilerRuntime","c","percentage","label","shouldHideProgress","t1","shouldShowLabelInline","t2","steps","colors","thumbLabel","showShine","t3","undefined","uuid","useUuid","popupRef","useRef","theme","useContext","ThemeContext","t4","bb0","shineCount","Math","ceil","speed","t5","Array","from","length","t6","map","_","index","createElement","StyledProgressBarShine","key","$delay","shineEffect","backgroundColor","primaryTextColor","progressColor","secondaryTextColor","stepColor","StyledProgressBarProgressWrapper","StyledMotionProgressBarProgress","$color","initial","width","left","animate","exit","transition","type","repeat","Infinity","repeatDelay","duration","StyledProgressBarBackground","StyledProgressBarStepWrapper","step","StyledProgressBarStep","onUpdate","_popupRef$current","current","show","onAnimationComplete","_popupRef$current2","StyledProgressBarThumbLabel","onClick","_temp","ThemeProvider","text","alignment","PopupAlignment","TopCenter","onHide","_popupRef$current3","StyledProgressBarLabel","$primaryColor","$secondaryColor","progressBar","t7","StyledProgressBar","displayName","_default","exports","event","stopPropagation"],"sources":["../../../../src/components/progress-bar/ProgressBar.tsx"],"sourcesContent":["import React, { FC, useContext, useMemo, useRef } from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport {\n StyledMotionProgressBarProgress,\n StyledProgressBar,\n StyledProgressBarBackground,\n StyledProgressBarLabel,\n StyledProgressBarProgressWrapper,\n StyledProgressBarShine,\n StyledProgressBarStep,\n StyledProgressBarStepWrapper,\n StyledProgressBarThumbLabel,\n} from './ProgressBar.styles';\nimport { PopupAlignment, PopupRef } from '../../types/popup';\nimport { ThemeContext, ThemeProvider } from 'styled-components';\nimport { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Popup from '../popup/Popup';\n\ntype Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N\n ? Acc[number]\n : Enumerate<N, [...Acc, Acc['length']]>;\n\ntype Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;\n\ninterface Colors {\n backgroundColor?: string;\n progressColor?: string;\n stepColor?: string;\n primaryTextColor?: string;\n secondaryTextColor?: string;\n}\n\nexport type ProgressBarProps = {\n /**\n * The colors of the ProgressBar.\n */\n colors?: Colors;\n /**\n * The label that should be displayed under the progressbar.\n */\n label?: string;\n /**\n * The percentage of the progress. Number between 0 and 100.\n */\n percentage?: Range<0, 101>;\n /**\n * Whether the progress should be hide and just display the label.\n */\n shouldHideProgress?: boolean;\n /**\n * Whether the label should be displayed inside the ProgressBar.\n */\n shouldShowLabelInline?: boolean;\n /**\n * Visual marked steps.\n */\n steps?: Range<0, 101>[];\n /**\n * The label that should be displayed on the thumb of the progress bar.\n */\n thumbLabel?: React.ReactNode;\n /**\n * Whether a shine animation should be shown on the progress bar. The amount of shine is based on the percentage value.\n */\n showShine?: boolean;\n};\n\nconst ProgressBar: FC<ProgressBarProps> = ({\n percentage,\n label,\n shouldHideProgress = false,\n shouldShowLabelInline = false,\n steps,\n colors,\n thumbLabel,\n showShine = false,\n}) => {\n 'use memo';\n\n const uuid = useUuid();\n const popupRef = useRef<PopupRef | null>(null);\n\n const theme = useContext(ThemeContext) as Theme | undefined;\n\n const shineEffect = useMemo(() => {\n if (!showShine || percentage === undefined) return null;\n const FULL_ANIMATION_LENGTH = 5;\n const MAX_SHINE_COUNT = 6;\n\n const shineCount = Math.ceil(MAX_SHINE_COUNT * (percentage / 100));\n const speed = FULL_ANIMATION_LENGTH * (percentage / 100);\n return Array.from({ length: shineCount }).map((_, index) => (\n <StyledProgressBarShine\n /* eslint-disable-next-line react/no-array-index-key */\n key={`progress-bar-shine__${shineCount}__${index}`}\n $speed={speed}\n $delay={(FULL_ANIMATION_LENGTH / shineCount) * index}\n />\n ));\n }, [percentage, showShine]);\n\n const progressBar = useMemo(() => {\n if (shouldHideProgress) {\n return null;\n }\n\n if (percentage === undefined) {\n return (\n <StyledProgressBarProgressWrapper>\n <StyledMotionProgressBarProgress\n key={`progress-bar-loop__${uuid}`}\n $color={colors?.progressColor}\n initial={{ width: '200px', left: '-200px' }}\n animate={{ width: '200px', left: '100%' }}\n exit={{ width: '200px', left: '100%' }}\n transition={{\n type: 'tween',\n repeat: Infinity,\n repeatDelay: 0,\n duration: 1,\n }}\n />\n <StyledProgressBarBackground $color={colors?.backgroundColor} />\n </StyledProgressBarProgressWrapper>\n );\n }\n\n return (\n <StyledProgressBarProgressWrapper $isBig={shouldShowLabelInline}>\n {!!steps?.length && (\n <StyledProgressBarStepWrapper>\n {steps.map((step) => (\n <StyledProgressBarStep\n $position={step}\n key={`progress-step-${step}`}\n $color={colors?.stepColor}\n />\n ))}\n </StyledProgressBarStepWrapper>\n )}\n <StyledMotionProgressBarProgress\n $color={colors?.progressColor}\n key={`progress-bar__${uuid}`}\n initial={{ width: '0%' }}\n animate={{ width: `${percentage}%` }}\n exit={{ width: '0%' }}\n transition={{ type: 'tween' }}\n onUpdate={() => popupRef.current?.show()}\n onAnimationComplete={() => popupRef.current?.show()}\n >\n {showShine && shineEffect}\n {thumbLabel && (\n <StyledProgressBarThumbLabel onClick={(event) => event.stopPropagation()}>\n <ThemeProvider\n theme={{\n '000': colors?.backgroundColor ?? theme?.['104'],\n text: colors?.secondaryTextColor ?? theme?.['300'],\n }}\n >\n <Popup\n ref={popupRef}\n content={thumbLabel}\n alignment={PopupAlignment.TopCenter}\n onHide={() => popupRef.current?.show()}\n >\n {}\n </Popup>\n </ThemeProvider>\n </StyledProgressBarThumbLabel>\n )}\n </StyledMotionProgressBarProgress>\n\n {shouldShowLabelInline && label && (\n <StyledProgressBarLabel\n $shouldShowLabelInline={shouldShowLabelInline}\n $primaryColor={colors?.primaryTextColor}\n $secondaryColor={colors?.secondaryTextColor}\n $colorSplitPosition={percentage}\n >\n {label}\n </StyledProgressBarLabel>\n )}\n\n <StyledProgressBarBackground $color={colors?.backgroundColor} />\n </StyledProgressBarProgressWrapper>\n );\n }, [\n colors?.backgroundColor,\n colors?.primaryTextColor,\n colors?.progressColor,\n colors?.secondaryTextColor,\n colors?.stepColor,\n label,\n percentage,\n shineEffect,\n shouldHideProgress,\n shouldShowLabelInline,\n showShine,\n steps,\n theme,\n thumbLabel,\n uuid,\n ]);\n\n return useMemo(\n () => (\n <StyledProgressBar>\n {progressBar}\n {label && !shouldShowLabelInline && (\n <StyledProgressBarLabel $primaryColor={colors?.primaryTextColor}>\n {label}\n </StyledProgressBarLabel>\n )}\n </StyledProgressBar>\n ),\n [colors?.primaryTextColor, label, progressBar, shouldShowLabelInline],\n );\n};\n\nProgressBar.displayName = 'ProgressBar';\n\nexport default ProgressBar;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAWA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAC,sBAAA,CAAAN,OAAA;AAAmC,SAAAM,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,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B,QACbF,WAAW,EACXnD,EAKc,CAAC;IAAAhC,CAAA,OAAAmF,WAAA;IAAAnF,CAAA,OAAAgC,EAAA;IAAAhC,CAAA,OAAAoF,EAAA;EAAA;IAAAA,EAAA,GAAApF,CAAA;EAAA;EAAA,OAPpBoF,EAOoB;AAAA,CAI/B;AAEDtF,WAAW,CAACwF,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3G,OAAA,GAEzBiB,WAAW;AA1JgB,SAAA0E,MAAAiB,KAAA;EAAA,OAqF+BA,KAAK,CAAAC,eAAgB,CAAC,CAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","names":["_react","_interopRequireWildcard","require","_uuid","_ProgressBar","_popup","_styledComponents","_Popup","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ProgressBar","percentage","label","shouldHideProgress","shouldShowLabelInline","steps","colors","thumbLabel","showShine","height","uuid","useUuid","coordinates","setCoordinates","useState","popupRef","useRef","hostContainerRef","theme","useContext","ThemeContext","shineEffect","useMemo","undefined","MIN_ANIMATION_LENGTH","MAX_ANIMATION_LENGTH","MAX_SHINE_COUNT","shineCount","Math","ceil","speed","Array","from","length","map","_","index","createElement","StyledProgressBarShine","key","$speed","$delay","useEffect","_hostContainerRef$cur","current","getBoundingClientRect","_popupRef$current","show","progressBar","StyledProgressBarProgressWrapper","StyledMotionProgressBarProgress","$color","progressColor","initial","width","left","animate","exit","transition","type","repeat","Infinity","repeatDelay","duration","StyledProgressBarBackground","backgroundColor","ref","$isBig","$height","StyledProgressBarStepWrapper","step","StyledProgressBarStep","$position","stepColor","onUpdate","_popupRef$current2","onAnimationComplete","_popupRef$current3","StyledProgressBarThumbLabel","onClick","event","stopPropagation","ThemeProvider","text","secondaryTextColor","content","alignment","PopupAlignment","TopCenter","onHide","_popupRef$current4","container","StyledProgressBarLabel","$shouldShowLabelInline","$primaryColor","primaryTextColor","$secondaryColor","$colorSplitPosition","StyledProgressBar","displayName","_default","exports"],"sources":["../../../../src/components/progress-bar/ProgressBar.tsx"],"sourcesContent":["import React, { FC, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport {\n StyledMotionProgressBarProgress,\n StyledProgressBar,\n StyledProgressBarBackground,\n StyledProgressBarLabel,\n StyledProgressBarProgressWrapper,\n StyledProgressBarShine,\n StyledProgressBarStep,\n StyledProgressBarStepWrapper,\n StyledProgressBarThumbLabel,\n} from './ProgressBar.styles';\nimport { PopupAlignment, PopupRef } from '../../types/popup';\nimport { ThemeContext, ThemeProvider } from 'styled-components';\nimport { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Popup from '../popup/Popup';\n\ntype Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N\n ? Acc[number]\n : Enumerate<N, [...Acc, Acc['length']]>;\n\ntype Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;\n\ninterface Colors {\n backgroundColor?: string;\n progressColor?: string;\n stepColor?: string;\n primaryTextColor?: string;\n secondaryTextColor?: string;\n}\n\nexport type ProgressBarProps = {\n /**\n * The colors of the ProgressBar.\n */\n colors?: Colors;\n /**\n * The label that should be displayed under the progressbar.\n */\n label?: string;\n /**\n * The percentage of the progress. Number between 0 and 100.\n */\n percentage?: Range<0, 101>;\n /**\n * Whether the progress should be hide and just display the label.\n */\n shouldHideProgress?: boolean;\n /**\n * Whether the label should be displayed inside the ProgressBar.\n */\n shouldShowLabelInline?: boolean;\n /**\n * Visual marked steps.\n */\n steps?: Range<0, 101>[];\n /**\n * The label that should be displayed on the thumb of the progress bar.\n */\n thumbLabel?: React.ReactNode;\n /**\n * Whether a shine animation should be shown on the progress bar. The amount of shine is based on the percentage value.\n */\n showShine?: boolean;\n /**\n * The height of the progress bar in pixels. If not provided, it will be 10px if shouldShowLabelInline is false and 20px if shouldShowLabelInline is true.\n */\n height?: number;\n};\n\nconst ProgressBar: FC<ProgressBarProps> = ({\n percentage,\n label,\n shouldHideProgress = false,\n shouldShowLabelInline = false,\n steps,\n colors,\n thumbLabel,\n showShine = false,\n height,\n}) => {\n 'use memo';\n\n const uuid = useUuid();\n const [coordinates, setCoordinates] = useState<{ x: number; y: number }>();\n const popupRef = useRef<PopupRef | null>(null);\n const hostContainerRef = useRef<HTMLDivElement | null>(null);\n\n const theme = useContext(ThemeContext) as Theme | undefined;\n\n const shineEffect = useMemo(() => {\n if (!showShine || percentage === undefined) return null;\n const MIN_ANIMATION_LENGTH = 1;\n const MAX_ANIMATION_LENGTH = 5;\n const MAX_SHINE_COUNT = 6;\n const t = percentage / 100;\n\n const shineCount = Math.ceil(MAX_SHINE_COUNT * t);\n\n const speed = MIN_ANIMATION_LENGTH + (MAX_ANIMATION_LENGTH - MIN_ANIMATION_LENGTH) * t;\n\n return Array.from({ length: shineCount }).map((_, index) => (\n <StyledProgressBarShine\n /* eslint-disable-next-line react/no-array-index-key */\n key={`progress-bar-shine__${shineCount}__${index}`}\n $speed={speed}\n $delay={-(speed / shineCount) * index}\n />\n ));\n }, [percentage, showShine]);\n\n useEffect(() => {\n if (thumbLabel) setCoordinates(hostContainerRef.current?.getBoundingClientRect());\n }, [thumbLabel]);\n\n useEffect(() => {\n if (coordinates) popupRef.current?.show();\n }, [coordinates]);\n\n const progressBar = useMemo(() => {\n if (shouldHideProgress) {\n return null;\n }\n\n if (percentage === undefined) {\n return (\n <StyledProgressBarProgressWrapper>\n <StyledMotionProgressBarProgress\n key={`progress-bar-loop__${uuid}`}\n $color={colors?.progressColor}\n initial={{ width: '200px', left: '-200px' }}\n animate={{ width: '200px', left: '100%' }}\n exit={{ width: '200px', left: '100%' }}\n transition={{\n type: 'tween',\n repeat: Infinity,\n repeatDelay: 0,\n duration: 1,\n }}\n />\n <StyledProgressBarBackground $color={colors?.backgroundColor} />\n </StyledProgressBarProgressWrapper>\n );\n }\n\n return (\n <div ref={hostContainerRef}>\n <StyledProgressBarProgressWrapper $isBig={shouldShowLabelInline} $height={height}>\n {!!steps?.length && (\n <StyledProgressBarStepWrapper>\n {steps.map((step) => (\n <StyledProgressBarStep\n $position={step}\n key={`progress-step-${step}`}\n $color={colors?.stepColor}\n />\n ))}\n </StyledProgressBarStepWrapper>\n )}\n <StyledMotionProgressBarProgress\n $color={colors?.progressColor}\n key={`progress-bar__${uuid}`}\n initial={{ width: '0%' }}\n animate={{ width: `${percentage}%` }}\n exit={{ width: '0%' }}\n transition={{ type: 'tween' }}\n onUpdate={() => popupRef.current?.show()}\n onAnimationComplete={() => popupRef.current?.show()}\n >\n {showShine && shineEffect}\n {thumbLabel && (\n <StyledProgressBarThumbLabel\n onClick={(event) => event.stopPropagation()}\n >\n <ThemeProvider\n theme={{\n '000': colors?.backgroundColor ?? theme?.['104'],\n text: colors?.secondaryTextColor ?? theme?.['300'],\n }}\n >\n <Popup\n ref={popupRef}\n content={thumbLabel}\n alignment={PopupAlignment.TopCenter}\n onHide={() => popupRef.current?.show()}\n container={hostContainerRef.current ?? undefined}\n >\n {}\n </Popup>\n </ThemeProvider>\n </StyledProgressBarThumbLabel>\n )}\n </StyledMotionProgressBarProgress>\n\n {shouldShowLabelInline && label && (\n <StyledProgressBarLabel\n $shouldShowLabelInline={shouldShowLabelInline}\n $primaryColor={colors?.primaryTextColor}\n $secondaryColor={colors?.secondaryTextColor}\n $colorSplitPosition={percentage}\n >\n {label}\n </StyledProgressBarLabel>\n )}\n\n <StyledProgressBarBackground $color={colors?.backgroundColor} />\n </StyledProgressBarProgressWrapper>\n </div>\n );\n }, [\n colors?.backgroundColor,\n colors?.primaryTextColor,\n colors?.progressColor,\n colors?.secondaryTextColor,\n colors?.stepColor,\n height,\n label,\n percentage,\n shineEffect,\n shouldHideProgress,\n shouldShowLabelInline,\n showShine,\n steps,\n theme,\n thumbLabel,\n uuid,\n ]);\n\n return useMemo(\n () => (\n <StyledProgressBar>\n {progressBar}\n {label && !shouldShowLabelInline && (\n <StyledProgressBarLabel $primaryColor={colors?.primaryTextColor}>\n {label}\n </StyledProgressBarLabel>\n )}\n </StyledProgressBar>\n ),\n [colors?.primaryTextColor, label, progressBar, shouldShowLabelInline],\n );\n};\n\nProgressBar.displayName = 'ProgressBar';\n\nexport default ProgressBar;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAWA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAC,sBAAA,CAAAN,OAAA;AAAmC,SAAAM,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAG,CAAA,OAAAK,CAAA,IAAAD,CAAA,GAAAS,MAAA,CAAAC,cAAA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,aAANA,MAAM,uBAANA,MAAM,CAAEmE,SAAS,EACjBhE,MAAM,EACNP,KAAK,EACLD,UAAU,EACVoB,WAAW,EACXlB,kBAAkB,EAClBC,qBAAqB,EACrBI,SAAS,EACTH,KAAK,EACLa,KAAK,EACLX,UAAU,EACVG,IAAI,CACP,CAAC;EAEF,OAAO,IAAAY,cAAO,EACV,mBACIlD,MAAA,CAAAW,OAAA,CAAAsD,aAAA,CAAC7D,YAAA,CAAA0H,iBAAiB,QACblD,WAAW,EACX9C,KAAK,IAAI,CAACE,qBAAqB,iBAC5BhC,MAAA,CAAAW,OAAA,CAAAsD,aAAA,CAAC7D,YAAA,CAAAoH,sBAAsB;IAACE,aAAa,EAAExF,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEyF;EAAiB,GAC3D7F,KACmB,CAEb,CACtB,EACD,CAACI,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEyF,gBAAgB,EAAE7F,KAAK,EAAE8C,WAAW,EAAE5C,qBAAqB,CACxE,CAAC;AACL,CAAC;AAEDJ,WAAW,CAACmG,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtH,OAAA,GAEzBiB,WAAW","ignoreList":[]}
|
|
@@ -23,18 +23,20 @@ const StyledProgressBarProgressWrapper = exports.StyledProgressBarProgressWrappe
|
|
|
23
23
|
position: relative;
|
|
24
24
|
width: 100%;
|
|
25
25
|
height: ${({
|
|
26
|
+
$height,
|
|
26
27
|
$isBig
|
|
27
|
-
}) => $isBig ? 20 : 10}px;
|
|
28
|
+
}) => $height || ($isBig ? 20 : 10)}px;
|
|
28
29
|
border-radius: ${({
|
|
30
|
+
$height,
|
|
29
31
|
$isBig
|
|
30
|
-
}) => $isBig ? 20 :
|
|
32
|
+
}) => $isBig ? $height ?? 20 : ($height ?? 10) / 5}px;
|
|
31
33
|
`;
|
|
32
34
|
const shineMove = (0, _styledComponents.keyframes)`
|
|
33
35
|
from {
|
|
34
|
-
transform: translateX(-
|
|
36
|
+
transform: translateX(-100%);
|
|
35
37
|
}
|
|
36
38
|
to {
|
|
37
|
-
transform: translateX(
|
|
39
|
+
transform: translateX(100%);
|
|
38
40
|
}
|
|
39
41
|
`;
|
|
40
42
|
const StyledProgressBarShine = exports.StyledProgressBarShine = _styledComponents.default.div.attrs(({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledProgressBar","exports","styled","div","StyledProgressBarBackground","theme","$color","StyledProgressBarProgressWrapper","$isBig","shineMove","keyframes","StyledProgressBarShine","attrs","$delay","style","animationDelay","$speed","StyledMotionProgressBarProgress","motion","headline","StyledProgressBarLabel","$shouldShowLabelInline","$colorSplitPosition","$primaryColor","$secondaryColor","css","StyledProgressBarStepWrapper","StyledProgressBarStep","$position","StyledProgressBarThumbLabel"],"sources":["../../../../src/components/progress-bar/ProgressBar.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css, keyframes } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledProgressBar = styled.div`\n position: relative;\n`;\n\ntype StyledProgressBarBackgroundProps = WithTheme<{ $color?: string }>;\n\nexport const StyledProgressBarBackground = styled.div<StyledProgressBarBackgroundProps>`\n height: 100%;\n width: 100%;\n background-color: ${({ theme, $color }: StyledProgressBarBackgroundProps) =>\n $color ?? theme['104']};\n`;\n\ntype StyledProgressBarProgressWrapperProps = WithTheme<{\n $isBig?: boolean;\n}>;\n\nexport const StyledProgressBarProgressWrapper = styled.div<StyledProgressBarProgressWrapperProps>`\n overflow: hidden;\n position: relative;\n width: 100%;\n height: ${({ $isBig }) => ($isBig ? 20 : 10)}px;\n border-radius: ${({ $isBig }) => ($isBig ? 20 :
|
|
1
|
+
{"version":3,"file":"ProgressBar.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledProgressBar","exports","styled","div","StyledProgressBarBackground","theme","$color","StyledProgressBarProgressWrapper","$height","$isBig","shineMove","keyframes","StyledProgressBarShine","attrs","$delay","style","animationDelay","$speed","StyledMotionProgressBarProgress","motion","headline","StyledProgressBarLabel","$shouldShowLabelInline","$colorSplitPosition","$primaryColor","$secondaryColor","css","StyledProgressBarStepWrapper","StyledProgressBarStep","$position","StyledProgressBarThumbLabel"],"sources":["../../../../src/components/progress-bar/ProgressBar.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css, keyframes } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledProgressBar = styled.div`\n position: relative;\n`;\n\ntype StyledProgressBarBackgroundProps = WithTheme<{ $color?: string }>;\n\nexport const StyledProgressBarBackground = styled.div<StyledProgressBarBackgroundProps>`\n height: 100%;\n width: 100%;\n background-color: ${({ theme, $color }: StyledProgressBarBackgroundProps) =>\n $color ?? theme['104']};\n`;\n\ntype StyledProgressBarProgressWrapperProps = WithTheme<{\n $isBig?: boolean;\n $height?: number;\n}>;\n\nexport const StyledProgressBarProgressWrapper = styled.div<StyledProgressBarProgressWrapperProps>`\n overflow: hidden;\n position: relative;\n width: 100%;\n height: ${({ $height, $isBig }) => $height || ($isBig ? 20 : 10)}px;\n border-radius: ${({ $height, $isBig }) => ($isBig ? ($height ?? 20) : ($height ?? 10) / 5)}px;\n`;\n\ntype StyledProgressBarProgressProps = WithTheme<{ $color?: string }>;\n\nconst shineMove = keyframes`\n from {\n transform: translateX(-100%);\n }\n to {\n transform: translateX(100%);\n }\n`;\n\nexport const StyledProgressBarShine = styled.div.attrs<{ $speed?: number; $delay?: number }>(\n ({ $delay }) => ({\n style: { animationDelay: `${$delay ?? 0}s` },\n }),\n)`\n position: absolute;\n width: 100%;\n height: 100%;\n background: linear-gradient(\n 90deg,\n rgba(255, 255, 255, 0) 33%,\n rgba(255, 255, 255, 0.5) 50%,\n rgba(255, 255, 255, 0) 66%\n );\n transform: translateX(-150%);\n animation: ${shineMove} ${({ $speed = 5 }) => `${$speed}s`} linear infinite;\n opacity: 0.95;\n`;\n\nexport const StyledMotionProgressBarProgress = styled(motion.div)<StyledProgressBarProgressProps>`\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n overflow: hidden;\n z-index: 2;\n display: flex;\n align-items: center;\n padding-left: 12px;\n background-color: ${({ theme, $color }: StyledProgressBarProgressProps) =>\n $color ?? theme.headline};\n`;\n\ntype StyledProgressBarLabelProps = WithTheme<{\n $shouldShowLabelInline?: boolean;\n $primaryColor?: string;\n $secondaryColor?: string;\n $colorSplitPosition?: number;\n}>;\n\nexport const StyledProgressBarLabel = styled.div<StyledProgressBarLabelProps>`\n font-size: 85%;\n color: ${({ theme, $shouldShowLabelInline }: StyledProgressBarLabelProps) =>\n $shouldShowLabelInline ? theme['100'] : theme.headline};\n white-space: nowrap;\n\n ${({ $colorSplitPosition, $primaryColor, $secondaryColor, theme }) =>\n $colorSplitPosition &&\n css`\n position: absolute;\n z-index: 2;\n width: 100%;\n height: 100%;\n\n display: flex;\n align-items: center;\n\n padding-left: 8px;\n\n font-weight: bold;\n\n -webkit-background-clip: text;\n\n color: transparent;\n background-image: linear-gradient(\n 90deg,\n ${$primaryColor ?? theme['100']} ${$colorSplitPosition}%,\n ${$secondaryColor ?? theme['300']} ${$colorSplitPosition}%\n );\n `}\n`;\n\nexport const StyledProgressBarStepWrapper = styled.div`\n height: 100%;\n width: 100%;\n position: absolute;\n`;\n\ntype StyledProgressBarStepProps = WithTheme<{\n $position: number;\n $color?: string;\n}>;\n\nexport const StyledProgressBarStep = styled.div<StyledProgressBarStepProps>`\n background-color: ${({ theme, $color }: StyledProgressBarStepProps) => $color ?? theme['102']};\n height: 100%;\n width: 2px;\n position: absolute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AID,KAAK,CAACe,QAAQ;AAChC,CAAC;AASM,MAAMC,sBAAsB,GAAApB,OAAA,CAAAoB,sBAAA,GAAGnB,yBAAM,CAACC,GAAgC;AAC7E;AACA,aAAa,CAAC;EAAEE,KAAK;EAAEiB;AAAoD,CAAC,KACpEA,sBAAsB,GAAGjB,KAAK,CAAC,KAAK,CAAC,GAAGA,KAAK,CAACe,QAAQ;AAC9D;AACA;AACA,MAAM,CAAC;EAAEG,mBAAmB;EAAEC,aAAa;EAAEC,eAAe;EAAEpB;AAAM,CAAC,KAC7DkB,mBAAmB,IACnB,IAAAG,qBAAG;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBF,aAAa,IAAInB,KAAK,CAAC,KAAK,CAAC,IAAIkB,mBAAmB;AACtE,kBAAkBE,eAAe,IAAIpB,KAAK,CAAC,KAAK,CAAC,IAAIkB,mBAAmB;AACxE;AACA,SAAS;AACT,CAAC;AAEM,MAAMI,4BAA4B,GAAA1B,OAAA,CAAA0B,4BAAA,GAAGzB,yBAAM,CAACC,GAAG;AACtD;AACA;AACA;AACA,CAAC;AAOM,MAAMyB,qBAAqB,GAAA3B,OAAA,CAAA2B,qBAAA,GAAG1B,yBAAM,CAACC,GAA+B;AAC3E,wBAAwB,CAAC;EAAEE,KAAK;EAAEC;AAAmC,CAAC,KAAKA,MAAM,IAAID,KAAK,CAAC,KAAK,CAAC;AACjG;AACA;AACA;AACA;AACA,YAAY,CAAC;EAAEwB;AAAsC,CAAC,KAAKA,SAAS;AACpE,CAAC;AAEM,MAAMC,2BAA2B,GAAA7B,OAAA,CAAA6B,2BAAA,GAAG5B,yBAAM,CAACC,GAAG;AACrD;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -1,193 +1,132 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React, { useContext, useMemo, useRef } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
2
|
import { useUuid } from '../../hooks/uuid';
|
|
4
3
|
import { StyledMotionProgressBarProgress, StyledProgressBar, StyledProgressBarBackground, StyledProgressBarLabel, StyledProgressBarProgressWrapper, StyledProgressBarShine, StyledProgressBarStep, StyledProgressBarStepWrapper, StyledProgressBarThumbLabel } from './ProgressBar.styles';
|
|
5
4
|
import { PopupAlignment } from '../../types/popup';
|
|
6
5
|
import { ThemeContext, ThemeProvider } from 'styled-components';
|
|
7
6
|
import Popup from '../popup/Popup';
|
|
8
|
-
const ProgressBar =
|
|
9
|
-
|
|
7
|
+
const ProgressBar = ({
|
|
8
|
+
percentage,
|
|
9
|
+
label,
|
|
10
|
+
shouldHideProgress = false,
|
|
11
|
+
shouldShowLabelInline = false,
|
|
12
|
+
steps,
|
|
13
|
+
colors,
|
|
14
|
+
thumbLabel,
|
|
15
|
+
showShine = false,
|
|
16
|
+
height
|
|
17
|
+
}) => {
|
|
18
|
+
'use memo';
|
|
10
19
|
|
|
11
|
-
const $ = _c(29);
|
|
12
|
-
const {
|
|
13
|
-
percentage,
|
|
14
|
-
label,
|
|
15
|
-
shouldHideProgress: t1,
|
|
16
|
-
shouldShowLabelInline: t2,
|
|
17
|
-
steps,
|
|
18
|
-
colors,
|
|
19
|
-
thumbLabel,
|
|
20
|
-
showShine: t3
|
|
21
|
-
} = t0;
|
|
22
|
-
const shouldHideProgress = t1 === undefined ? false : t1;
|
|
23
|
-
const shouldShowLabelInline = t2 === undefined ? false : t2;
|
|
24
|
-
const showShine = t3 === undefined ? false : t3;
|
|
25
20
|
const uuid = useUuid();
|
|
21
|
+
const [coordinates, setCoordinates] = useState();
|
|
26
22
|
const popupRef = useRef(null);
|
|
23
|
+
const hostContainerRef = useRef(null);
|
|
27
24
|
const theme = useContext(ThemeContext);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
const shineEffect = useMemo(() => {
|
|
26
|
+
if (!showShine || percentage === undefined) return null;
|
|
27
|
+
const MIN_ANIMATION_LENGTH = 1;
|
|
28
|
+
const MAX_ANIMATION_LENGTH = 5;
|
|
29
|
+
const MAX_SHINE_COUNT = 6;
|
|
30
|
+
const t = percentage / 100;
|
|
31
|
+
const shineCount = Math.ceil(MAX_SHINE_COUNT * t);
|
|
32
|
+
const speed = MIN_ANIMATION_LENGTH + (MAX_ANIMATION_LENGTH - MIN_ANIMATION_LENGTH) * t;
|
|
33
|
+
return Array.from({
|
|
34
|
+
length: shineCount
|
|
35
|
+
}).map((_, index) => /*#__PURE__*/React.createElement(StyledProgressBarShine
|
|
36
|
+
/* eslint-disable-next-line react/no-array-index-key */, {
|
|
37
|
+
key: `progress-bar-shine__${shineCount}__${index}`,
|
|
38
|
+
$speed: speed,
|
|
39
|
+
$delay: -(speed / shineCount) * index
|
|
40
|
+
}));
|
|
41
|
+
}, [percentage, showShine]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (thumbLabel) setCoordinates(hostContainerRef.current?.getBoundingClientRect());
|
|
44
|
+
}, [thumbLabel]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (coordinates) popupRef.current?.show();
|
|
47
|
+
}, [coordinates]);
|
|
48
|
+
const progressBar = useMemo(() => {
|
|
49
|
+
if (shouldHideProgress) {
|
|
50
|
+
return null;
|
|
33
51
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if ($[0] !== shineCount) {
|
|
38
|
-
t5 = Array.from({
|
|
39
|
-
length: shineCount
|
|
40
|
-
});
|
|
41
|
-
$[0] = shineCount;
|
|
42
|
-
$[1] = t5;
|
|
43
|
-
} else {
|
|
44
|
-
t5 = $[1];
|
|
45
|
-
}
|
|
46
|
-
let t6;
|
|
47
|
-
if ($[2] !== shineCount || $[3] !== speed || $[4] !== t5) {
|
|
48
|
-
t6 = t5.map((_, index) => /*#__PURE__*/React.createElement(StyledProgressBarShine, {
|
|
49
|
-
key: `progress-bar-shine__${shineCount}__${index}`,
|
|
50
|
-
$speed: speed,
|
|
51
|
-
$delay: 5 / shineCount * index
|
|
52
|
-
}));
|
|
53
|
-
$[2] = shineCount;
|
|
54
|
-
$[3] = speed;
|
|
55
|
-
$[4] = t5;
|
|
56
|
-
$[5] = t6;
|
|
57
|
-
} else {
|
|
58
|
-
t6 = $[5];
|
|
59
|
-
}
|
|
60
|
-
t4 = t6;
|
|
61
|
-
}
|
|
62
|
-
const shineEffect = t4;
|
|
63
|
-
let t5;
|
|
64
|
-
if ($[6] !== colors?.backgroundColor || $[7] !== colors?.primaryTextColor || $[8] !== colors?.progressColor || $[9] !== colors?.secondaryTextColor || $[10] !== colors?.stepColor || $[11] !== label || $[12] !== percentage || $[13] !== shineEffect || $[14] !== shouldHideProgress || $[15] !== shouldShowLabelInline || $[16] !== showShine || $[17] !== steps || $[18] !== theme || $[19] !== thumbLabel || $[20] !== uuid) {
|
|
65
|
-
colors?.backgroundColor;
|
|
66
|
-
colors?.primaryTextColor;
|
|
67
|
-
colors?.progressColor;
|
|
68
|
-
colors?.secondaryTextColor;
|
|
69
|
-
colors?.stepColor;
|
|
70
|
-
t5 = (() => {
|
|
71
|
-
if (shouldHideProgress) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
if (percentage === undefined) {
|
|
75
|
-
return /*#__PURE__*/React.createElement(StyledProgressBarProgressWrapper, null, /*#__PURE__*/React.createElement(StyledMotionProgressBarProgress, {
|
|
76
|
-
key: `progress-bar-loop__${uuid}`,
|
|
77
|
-
$color: colors?.progressColor,
|
|
78
|
-
initial: {
|
|
79
|
-
width: "200px",
|
|
80
|
-
left: "-200px"
|
|
81
|
-
},
|
|
82
|
-
animate: {
|
|
83
|
-
width: "200px",
|
|
84
|
-
left: "100%"
|
|
85
|
-
},
|
|
86
|
-
exit: {
|
|
87
|
-
width: "200px",
|
|
88
|
-
left: "100%"
|
|
89
|
-
},
|
|
90
|
-
transition: {
|
|
91
|
-
type: "tween",
|
|
92
|
-
repeat: Infinity,
|
|
93
|
-
repeatDelay: 0,
|
|
94
|
-
duration: 1
|
|
95
|
-
}
|
|
96
|
-
}), /*#__PURE__*/React.createElement(StyledProgressBarBackground, {
|
|
97
|
-
$color: colors?.backgroundColor
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
return /*#__PURE__*/React.createElement(StyledProgressBarProgressWrapper, {
|
|
101
|
-
$isBig: shouldShowLabelInline
|
|
102
|
-
}, !!steps?.length && /*#__PURE__*/React.createElement(StyledProgressBarStepWrapper, null, steps.map(step => /*#__PURE__*/React.createElement(StyledProgressBarStep, {
|
|
103
|
-
$position: step,
|
|
104
|
-
key: `progress-step-${step}`,
|
|
105
|
-
$color: colors?.stepColor
|
|
106
|
-
}))), /*#__PURE__*/React.createElement(StyledMotionProgressBarProgress, {
|
|
52
|
+
if (percentage === undefined) {
|
|
53
|
+
return /*#__PURE__*/React.createElement(StyledProgressBarProgressWrapper, null, /*#__PURE__*/React.createElement(StyledMotionProgressBarProgress, {
|
|
54
|
+
key: `progress-bar-loop__${uuid}`,
|
|
107
55
|
$color: colors?.progressColor,
|
|
108
|
-
key: `progress-bar__${uuid}`,
|
|
109
56
|
initial: {
|
|
110
|
-
width:
|
|
57
|
+
width: '200px',
|
|
58
|
+
left: '-200px'
|
|
111
59
|
},
|
|
112
60
|
animate: {
|
|
113
|
-
width:
|
|
61
|
+
width: '200px',
|
|
62
|
+
left: '100%'
|
|
114
63
|
},
|
|
115
64
|
exit: {
|
|
116
|
-
width:
|
|
65
|
+
width: '200px',
|
|
66
|
+
left: '100%'
|
|
117
67
|
},
|
|
118
68
|
transition: {
|
|
119
|
-
type:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}, showShine && shineEffect, thumbLabel && /*#__PURE__*/React.createElement(StyledProgressBarThumbLabel, {
|
|
124
|
-
onClick: _temp
|
|
125
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
126
|
-
theme: {
|
|
127
|
-
"000": colors?.backgroundColor ?? theme?.["104"],
|
|
128
|
-
text: colors?.secondaryTextColor ?? theme?.["300"]
|
|
69
|
+
type: 'tween',
|
|
70
|
+
repeat: Infinity,
|
|
71
|
+
repeatDelay: 0,
|
|
72
|
+
duration: 1
|
|
129
73
|
}
|
|
130
|
-
}, /*#__PURE__*/React.createElement(
|
|
131
|
-
ref: popupRef,
|
|
132
|
-
content: thumbLabel,
|
|
133
|
-
alignment: PopupAlignment.TopCenter,
|
|
134
|
-
onHide: () => popupRef.current?.show()
|
|
135
|
-
})))), shouldShowLabelInline && label && /*#__PURE__*/React.createElement(StyledProgressBarLabel, {
|
|
136
|
-
$shouldShowLabelInline: shouldShowLabelInline,
|
|
137
|
-
$primaryColor: colors?.primaryTextColor,
|
|
138
|
-
$secondaryColor: colors?.secondaryTextColor,
|
|
139
|
-
$colorSplitPosition: percentage
|
|
140
|
-
}, label), /*#__PURE__*/React.createElement(StyledProgressBarBackground, {
|
|
74
|
+
}), /*#__PURE__*/React.createElement(StyledProgressBarBackground, {
|
|
141
75
|
$color: colors?.backgroundColor
|
|
142
76
|
}));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
77
|
+
}
|
|
78
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
ref: hostContainerRef
|
|
80
|
+
}, /*#__PURE__*/React.createElement(StyledProgressBarProgressWrapper, {
|
|
81
|
+
$isBig: shouldShowLabelInline,
|
|
82
|
+
$height: height
|
|
83
|
+
}, !!steps?.length && /*#__PURE__*/React.createElement(StyledProgressBarStepWrapper, null, steps.map(step => /*#__PURE__*/React.createElement(StyledProgressBarStep, {
|
|
84
|
+
$position: step,
|
|
85
|
+
key: `progress-step-${step}`,
|
|
86
|
+
$color: colors?.stepColor
|
|
87
|
+
}))), /*#__PURE__*/React.createElement(StyledMotionProgressBarProgress, {
|
|
88
|
+
$color: colors?.progressColor,
|
|
89
|
+
key: `progress-bar__${uuid}`,
|
|
90
|
+
initial: {
|
|
91
|
+
width: '0%'
|
|
92
|
+
},
|
|
93
|
+
animate: {
|
|
94
|
+
width: `${percentage}%`
|
|
95
|
+
},
|
|
96
|
+
exit: {
|
|
97
|
+
width: '0%'
|
|
98
|
+
},
|
|
99
|
+
transition: {
|
|
100
|
+
type: 'tween'
|
|
101
|
+
},
|
|
102
|
+
onUpdate: () => popupRef.current?.show(),
|
|
103
|
+
onAnimationComplete: () => popupRef.current?.show()
|
|
104
|
+
}, showShine && shineEffect, thumbLabel && /*#__PURE__*/React.createElement(StyledProgressBarThumbLabel, {
|
|
105
|
+
onClick: event => event.stopPropagation()
|
|
106
|
+
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
107
|
+
theme: {
|
|
108
|
+
'000': colors?.backgroundColor ?? theme?.['104'],
|
|
109
|
+
text: colors?.secondaryTextColor ?? theme?.['300']
|
|
110
|
+
}
|
|
111
|
+
}, /*#__PURE__*/React.createElement(Popup, {
|
|
112
|
+
ref: popupRef,
|
|
113
|
+
content: thumbLabel,
|
|
114
|
+
alignment: PopupAlignment.TopCenter,
|
|
115
|
+
onHide: () => popupRef.current?.show(),
|
|
116
|
+
container: hostContainerRef.current ?? undefined
|
|
117
|
+
})))), shouldShowLabelInline && label && /*#__PURE__*/React.createElement(StyledProgressBarLabel, {
|
|
118
|
+
$shouldShowLabelInline: shouldShowLabelInline,
|
|
119
|
+
$primaryColor: colors?.primaryTextColor,
|
|
120
|
+
$secondaryColor: colors?.secondaryTextColor,
|
|
121
|
+
$colorSplitPosition: percentage
|
|
122
|
+
}, label), /*#__PURE__*/React.createElement(StyledProgressBarBackground, {
|
|
123
|
+
$color: colors?.backgroundColor
|
|
124
|
+
})));
|
|
125
|
+
}, [colors?.backgroundColor, colors?.primaryTextColor, colors?.progressColor, colors?.secondaryTextColor, colors?.stepColor, height, label, percentage, shineEffect, shouldHideProgress, shouldShowLabelInline, showShine, steps, theme, thumbLabel, uuid]);
|
|
126
|
+
return useMemo(() => /*#__PURE__*/React.createElement(StyledProgressBar, null, progressBar, label && !shouldShowLabelInline && /*#__PURE__*/React.createElement(StyledProgressBarLabel, {
|
|
127
|
+
$primaryColor: colors?.primaryTextColor
|
|
128
|
+
}, label)), [colors?.primaryTextColor, label, progressBar, shouldShowLabelInline]);
|
|
187
129
|
};
|
|
188
130
|
ProgressBar.displayName = 'ProgressBar';
|
|
189
131
|
export default ProgressBar;
|
|
190
|
-
function _temp(event) {
|
|
191
|
-
return event.stopPropagation();
|
|
192
|
-
}
|
|
193
132
|
//# sourceMappingURL=ProgressBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","names":["React","useContext","useMemo","useRef","useUuid","StyledMotionProgressBarProgress","StyledProgressBar","StyledProgressBarBackground","StyledProgressBarLabel","StyledProgressBarProgressWrapper","StyledProgressBarShine","StyledProgressBarStep","StyledProgressBarStepWrapper","StyledProgressBarThumbLabel","PopupAlignment","ThemeContext","ThemeProvider","Popup","ProgressBar","t0","$","_c","percentage","label","shouldHideProgress","t1","shouldShowLabelInline","t2","steps","colors","thumbLabel","showShine","t3","undefined","uuid","popupRef","theme","t4","bb0","shineCount","Math","ceil","speed","t5","Array","from","length","t6","map","_","index","createElement","key","$delay","shineEffect","backgroundColor","primaryTextColor","progressColor","secondaryTextColor","stepColor","$color","initial","width","left","animate","exit","transition","type","repeat","Infinity","repeatDelay","duration","step","onUpdate","current","show","onAnimationComplete","onClick","_temp","text","alignment","TopCenter","onHide","$primaryColor","$secondaryColor","progressBar","t7","displayName","event","stopPropagation"],"sources":["../../../../src/components/progress-bar/ProgressBar.tsx"],"sourcesContent":["import React, { FC, useContext, useMemo, useRef } from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport {\n StyledMotionProgressBarProgress,\n StyledProgressBar,\n StyledProgressBarBackground,\n StyledProgressBarLabel,\n StyledProgressBarProgressWrapper,\n StyledProgressBarShine,\n StyledProgressBarStep,\n StyledProgressBarStepWrapper,\n StyledProgressBarThumbLabel,\n} from './ProgressBar.styles';\nimport { PopupAlignment, PopupRef } from '../../types/popup';\nimport { ThemeContext, ThemeProvider } from 'styled-components';\nimport { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Popup from '../popup/Popup';\n\ntype Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N\n ? Acc[number]\n : Enumerate<N, [...Acc, Acc['length']]>;\n\ntype Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;\n\ninterface Colors {\n backgroundColor?: string;\n progressColor?: string;\n stepColor?: string;\n primaryTextColor?: string;\n secondaryTextColor?: string;\n}\n\nexport type ProgressBarProps = {\n /**\n * The colors of the ProgressBar.\n */\n colors?: Colors;\n /**\n * The label that should be displayed under the progressbar.\n */\n label?: string;\n /**\n * The percentage of the progress. Number between 0 and 100.\n */\n percentage?: Range<0, 101>;\n /**\n * Whether the progress should be hide and just display the label.\n */\n shouldHideProgress?: boolean;\n /**\n * Whether the label should be displayed inside the ProgressBar.\n */\n shouldShowLabelInline?: boolean;\n /**\n * Visual marked steps.\n */\n steps?: Range<0, 101>[];\n /**\n * The label that should be displayed on the thumb of the progress bar.\n */\n thumbLabel?: React.ReactNode;\n /**\n * Whether a shine animation should be shown on the progress bar. The amount of shine is based on the percentage value.\n */\n showShine?: boolean;\n};\n\nconst ProgressBar: FC<ProgressBarProps> = ({\n percentage,\n label,\n shouldHideProgress = false,\n shouldShowLabelInline = false,\n steps,\n colors,\n thumbLabel,\n showShine = false,\n}) => {\n 'use memo';\n\n const uuid = useUuid();\n const popupRef = useRef<PopupRef | null>(null);\n\n const theme = useContext(ThemeContext) as Theme | undefined;\n\n const shineEffect = useMemo(() => {\n if (!showShine || percentage === undefined) return null;\n const FULL_ANIMATION_LENGTH = 5;\n const MAX_SHINE_COUNT = 6;\n\n const shineCount = Math.ceil(MAX_SHINE_COUNT * (percentage / 100));\n const speed = FULL_ANIMATION_LENGTH * (percentage / 100);\n return Array.from({ length: shineCount }).map((_, index) => (\n <StyledProgressBarShine\n /* eslint-disable-next-line react/no-array-index-key */\n key={`progress-bar-shine__${shineCount}__${index}`}\n $speed={speed}\n $delay={(FULL_ANIMATION_LENGTH / shineCount) * index}\n />\n ));\n }, [percentage, showShine]);\n\n const progressBar = useMemo(() => {\n if (shouldHideProgress) {\n return null;\n }\n\n if (percentage === undefined) {\n return (\n <StyledProgressBarProgressWrapper>\n <StyledMotionProgressBarProgress\n key={`progress-bar-loop__${uuid}`}\n $color={colors?.progressColor}\n initial={{ width: '200px', left: '-200px' }}\n animate={{ width: '200px', left: '100%' }}\n exit={{ width: '200px', left: '100%' }}\n transition={{\n type: 'tween',\n repeat: Infinity,\n repeatDelay: 0,\n duration: 1,\n }}\n />\n <StyledProgressBarBackground $color={colors?.backgroundColor} />\n </StyledProgressBarProgressWrapper>\n );\n }\n\n return (\n <StyledProgressBarProgressWrapper $isBig={shouldShowLabelInline}>\n {!!steps?.length && (\n <StyledProgressBarStepWrapper>\n {steps.map((step) => (\n <StyledProgressBarStep\n $position={step}\n key={`progress-step-${step}`}\n $color={colors?.stepColor}\n />\n ))}\n </StyledProgressBarStepWrapper>\n )}\n <StyledMotionProgressBarProgress\n $color={colors?.progressColor}\n key={`progress-bar__${uuid}`}\n initial={{ width: '0%' }}\n animate={{ width: `${percentage}%` }}\n exit={{ width: '0%' }}\n transition={{ type: 'tween' }}\n onUpdate={() => popupRef.current?.show()}\n onAnimationComplete={() => popupRef.current?.show()}\n >\n {showShine && shineEffect}\n {thumbLabel && (\n <StyledProgressBarThumbLabel onClick={(event) => event.stopPropagation()}>\n <ThemeProvider\n theme={{\n '000': colors?.backgroundColor ?? theme?.['104'],\n text: colors?.secondaryTextColor ?? theme?.['300'],\n }}\n >\n <Popup\n ref={popupRef}\n content={thumbLabel}\n alignment={PopupAlignment.TopCenter}\n onHide={() => popupRef.current?.show()}\n >\n {}\n </Popup>\n </ThemeProvider>\n </StyledProgressBarThumbLabel>\n )}\n </StyledMotionProgressBarProgress>\n\n {shouldShowLabelInline && label && (\n <StyledProgressBarLabel\n $shouldShowLabelInline={shouldShowLabelInline}\n $primaryColor={colors?.primaryTextColor}\n $secondaryColor={colors?.secondaryTextColor}\n $colorSplitPosition={percentage}\n >\n {label}\n </StyledProgressBarLabel>\n )}\n\n <StyledProgressBarBackground $color={colors?.backgroundColor} />\n </StyledProgressBarProgressWrapper>\n );\n }, [\n colors?.backgroundColor,\n colors?.primaryTextColor,\n colors?.progressColor,\n colors?.secondaryTextColor,\n colors?.stepColor,\n label,\n percentage,\n shineEffect,\n shouldHideProgress,\n shouldShowLabelInline,\n showShine,\n steps,\n theme,\n thumbLabel,\n uuid,\n ]);\n\n return useMemo(\n () => (\n <StyledProgressBar>\n {progressBar}\n {label && !shouldShowLabelInline && (\n <StyledProgressBarLabel $primaryColor={colors?.primaryTextColor}>\n {label}\n </StyledProgressBarLabel>\n )}\n </StyledProgressBar>\n ),\n [colors?.primaryTextColor, label, progressBar, shouldShowLabelInline],\n );\n};\n\nProgressBar.displayName = 'ProgressBar';\n\nexport default ProgressBar;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAQC,UAAU,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC9D,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,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AA,SAAAM,qBAAA;IAPhBqB,EAAA,GAAAxB,KAA+B,IAA/B,CAAUG,qBAIV,iBAJA1B,KAAA,CAAAmD,aAAA,CACI3C,sBAAsB;MAAgB2E,aAAwB,EAAxBtD,MAAM,EAAA2B;IAAkB,GAC1DjC,KAET,CAAC;IAAAH,CAAA,OAAAS,MAAA,EAAA2B,gBAAA;IAAApC,CAAA,OAAAG,KAAA;IAAAH,CAAA,OAAAM,qBAAA;IAAAN,CAAA,OAAA2B,EAAA;EAAA;IAAAA,EAAA,GAAA3B,CAAA;EAAA;EAAA,IAAAkE,EAAA;EAAA,IAAAlE,CAAA,SAAAiE,WAAA,IAAAjE,CAAA,SAAA2B,EAAA;IANLuC,EAAA,gBAAAtF,KAAA,CAAAmD,aAAA,CAAC7C,iBAAiB,QACb+E,WAAW,EACXtC,EAKc,CAAC;IAAA3B,CAAA,OAAAiE,WAAA;IAAAjE,CAAA,OAAA2B,EAAA;IAAA3B,CAAA,OAAAkE,EAAA;EAAA;IAAAA,EAAA,GAAAlE,CAAA;EAAA;EAAA,OAPpBkE,EAOoB;AAAA,CAI/B;AAEDpE,WAAW,CAACqE,WAAW,GAAG,aAAa;AAEvC,eAAerE,WAAW;AA1JgB,SAAA4D,MAAAU,KAAA;EAAA,OAqF+BA,KAAK,CAAAC,eAAgB,CAAC,CAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","names":["React","useContext","useEffect","useMemo","useRef","useState","useUuid","StyledMotionProgressBarProgress","StyledProgressBar","StyledProgressBarBackground","StyledProgressBarLabel","StyledProgressBarProgressWrapper","StyledProgressBarShine","StyledProgressBarStep","StyledProgressBarStepWrapper","StyledProgressBarThumbLabel","PopupAlignment","ThemeContext","ThemeProvider","Popup","ProgressBar","percentage","label","shouldHideProgress","shouldShowLabelInline","steps","colors","thumbLabel","showShine","height","uuid","coordinates","setCoordinates","popupRef","hostContainerRef","theme","shineEffect","undefined","MIN_ANIMATION_LENGTH","MAX_ANIMATION_LENGTH","MAX_SHINE_COUNT","t","shineCount","Math","ceil","speed","Array","from","length","map","_","index","createElement","key","$speed","$delay","current","getBoundingClientRect","show","progressBar","$color","progressColor","initial","width","left","animate","exit","transition","type","repeat","Infinity","repeatDelay","duration","backgroundColor","ref","$isBig","$height","step","$position","stepColor","onUpdate","onAnimationComplete","onClick","event","stopPropagation","text","secondaryTextColor","content","alignment","TopCenter","onHide","container","$shouldShowLabelInline","$primaryColor","primaryTextColor","$secondaryColor","$colorSplitPosition","displayName"],"sources":["../../../../src/components/progress-bar/ProgressBar.tsx"],"sourcesContent":["import React, { FC, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport {\n StyledMotionProgressBarProgress,\n StyledProgressBar,\n StyledProgressBarBackground,\n StyledProgressBarLabel,\n StyledProgressBarProgressWrapper,\n StyledProgressBarShine,\n StyledProgressBarStep,\n StyledProgressBarStepWrapper,\n StyledProgressBarThumbLabel,\n} from './ProgressBar.styles';\nimport { PopupAlignment, PopupRef } from '../../types/popup';\nimport { ThemeContext, ThemeProvider } from 'styled-components';\nimport { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Popup from '../popup/Popup';\n\ntype Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N\n ? Acc[number]\n : Enumerate<N, [...Acc, Acc['length']]>;\n\ntype Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;\n\ninterface Colors {\n backgroundColor?: string;\n progressColor?: string;\n stepColor?: string;\n primaryTextColor?: string;\n secondaryTextColor?: string;\n}\n\nexport type ProgressBarProps = {\n /**\n * The colors of the ProgressBar.\n */\n colors?: Colors;\n /**\n * The label that should be displayed under the progressbar.\n */\n label?: string;\n /**\n * The percentage of the progress. Number between 0 and 100.\n */\n percentage?: Range<0, 101>;\n /**\n * Whether the progress should be hide and just display the label.\n */\n shouldHideProgress?: boolean;\n /**\n * Whether the label should be displayed inside the ProgressBar.\n */\n shouldShowLabelInline?: boolean;\n /**\n * Visual marked steps.\n */\n steps?: Range<0, 101>[];\n /**\n * The label that should be displayed on the thumb of the progress bar.\n */\n thumbLabel?: React.ReactNode;\n /**\n * Whether a shine animation should be shown on the progress bar. The amount of shine is based on the percentage value.\n */\n showShine?: boolean;\n /**\n * The height of the progress bar in pixels. If not provided, it will be 10px if shouldShowLabelInline is false and 20px if shouldShowLabelInline is true.\n */\n height?: number;\n};\n\nconst ProgressBar: FC<ProgressBarProps> = ({\n percentage,\n label,\n shouldHideProgress = false,\n shouldShowLabelInline = false,\n steps,\n colors,\n thumbLabel,\n showShine = false,\n height,\n}) => {\n 'use memo';\n\n const uuid = useUuid();\n const [coordinates, setCoordinates] = useState<{ x: number; y: number }>();\n const popupRef = useRef<PopupRef | null>(null);\n const hostContainerRef = useRef<HTMLDivElement | null>(null);\n\n const theme = useContext(ThemeContext) as Theme | undefined;\n\n const shineEffect = useMemo(() => {\n if (!showShine || percentage === undefined) return null;\n const MIN_ANIMATION_LENGTH = 1;\n const MAX_ANIMATION_LENGTH = 5;\n const MAX_SHINE_COUNT = 6;\n const t = percentage / 100;\n\n const shineCount = Math.ceil(MAX_SHINE_COUNT * t);\n\n const speed = MIN_ANIMATION_LENGTH + (MAX_ANIMATION_LENGTH - MIN_ANIMATION_LENGTH) * t;\n\n return Array.from({ length: shineCount }).map((_, index) => (\n <StyledProgressBarShine\n /* eslint-disable-next-line react/no-array-index-key */\n key={`progress-bar-shine__${shineCount}__${index}`}\n $speed={speed}\n $delay={-(speed / shineCount) * index}\n />\n ));\n }, [percentage, showShine]);\n\n useEffect(() => {\n if (thumbLabel) setCoordinates(hostContainerRef.current?.getBoundingClientRect());\n }, [thumbLabel]);\n\n useEffect(() => {\n if (coordinates) popupRef.current?.show();\n }, [coordinates]);\n\n const progressBar = useMemo(() => {\n if (shouldHideProgress) {\n return null;\n }\n\n if (percentage === undefined) {\n return (\n <StyledProgressBarProgressWrapper>\n <StyledMotionProgressBarProgress\n key={`progress-bar-loop__${uuid}`}\n $color={colors?.progressColor}\n initial={{ width: '200px', left: '-200px' }}\n animate={{ width: '200px', left: '100%' }}\n exit={{ width: '200px', left: '100%' }}\n transition={{\n type: 'tween',\n repeat: Infinity,\n repeatDelay: 0,\n duration: 1,\n }}\n />\n <StyledProgressBarBackground $color={colors?.backgroundColor} />\n </StyledProgressBarProgressWrapper>\n );\n }\n\n return (\n <div ref={hostContainerRef}>\n <StyledProgressBarProgressWrapper $isBig={shouldShowLabelInline} $height={height}>\n {!!steps?.length && (\n <StyledProgressBarStepWrapper>\n {steps.map((step) => (\n <StyledProgressBarStep\n $position={step}\n key={`progress-step-${step}`}\n $color={colors?.stepColor}\n />\n ))}\n </StyledProgressBarStepWrapper>\n )}\n <StyledMotionProgressBarProgress\n $color={colors?.progressColor}\n key={`progress-bar__${uuid}`}\n initial={{ width: '0%' }}\n animate={{ width: `${percentage}%` }}\n exit={{ width: '0%' }}\n transition={{ type: 'tween' }}\n onUpdate={() => popupRef.current?.show()}\n onAnimationComplete={() => popupRef.current?.show()}\n >\n {showShine && shineEffect}\n {thumbLabel && (\n <StyledProgressBarThumbLabel\n onClick={(event) => event.stopPropagation()}\n >\n <ThemeProvider\n theme={{\n '000': colors?.backgroundColor ?? theme?.['104'],\n text: colors?.secondaryTextColor ?? theme?.['300'],\n }}\n >\n <Popup\n ref={popupRef}\n content={thumbLabel}\n alignment={PopupAlignment.TopCenter}\n onHide={() => popupRef.current?.show()}\n container={hostContainerRef.current ?? undefined}\n >\n {}\n </Popup>\n </ThemeProvider>\n </StyledProgressBarThumbLabel>\n )}\n </StyledMotionProgressBarProgress>\n\n {shouldShowLabelInline && label && (\n <StyledProgressBarLabel\n $shouldShowLabelInline={shouldShowLabelInline}\n $primaryColor={colors?.primaryTextColor}\n $secondaryColor={colors?.secondaryTextColor}\n $colorSplitPosition={percentage}\n >\n {label}\n </StyledProgressBarLabel>\n )}\n\n <StyledProgressBarBackground $color={colors?.backgroundColor} />\n </StyledProgressBarProgressWrapper>\n </div>\n );\n }, [\n colors?.backgroundColor,\n colors?.primaryTextColor,\n colors?.progressColor,\n colors?.secondaryTextColor,\n colors?.stepColor,\n height,\n label,\n percentage,\n shineEffect,\n shouldHideProgress,\n shouldShowLabelInline,\n showShine,\n steps,\n theme,\n thumbLabel,\n uuid,\n ]);\n\n return useMemo(\n () => (\n <StyledProgressBar>\n {progressBar}\n {label && !shouldShowLabelInline && (\n <StyledProgressBarLabel $primaryColor={colors?.primaryTextColor}>\n {label}\n </StyledProgressBarLabel>\n )}\n </StyledProgressBar>\n ),\n [colors?.primaryTextColor, label, progressBar, shouldShowLabelInline],\n );\n};\n\nProgressBar.displayName = 'ProgressBar';\n\nexport default ProgressBar;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAQC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnF,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SACIC,+BAA+B,EAC/BC,iBAAiB,EACjBC,2BAA2B,EAC3BC,sBAAsB,EACtBC,gCAAgC,EAChCC,sBAAsB,EACtBC,qBAAqB,EACrBC,4BAA4B,EAC5BC,2BAA2B,QACxB,sBAAsB;AAC7B,SAASC,cAAc,QAAkB,mBAAmB;AAC5D,SAASC,YAAY,EAAEC,aAAa,QAAQ,mBAAmB;AAE/D,OAAOC,KAAK,MAAM,gBAAgB;AAuDlC,MAAMC,WAAiC,GAAGA,CAAC;EACvCC,UAAU;EACVC,KAAK;EACLC,kBAAkB,GAAG,KAAK;EAC1BC,qBAAqB,GAAG,KAAK;EAC7BC,KAAK;EACLC,MAAM;EACNC,UAAU;EACVC,SAAS,GAAG,KAAK;EACjBC;AACJ,CAAC,KAAK;EACF,UAAU;;EAEV,MAAMC,IAAI,GAAGxB,OAAO,CAAC,CAAC;EACtB,MAAM,CAACyB,WAAW,EAAEC,cAAc,CAAC,GAAG3B,QAAQ,CAA2B,CAAC;EAC1E,MAAM4B,QAAQ,GAAG7B,MAAM,C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InB;IAAU,CAG9C,CACI,CACU,CAEJ,CAAC,EAEjCb,qBAAqB,IAAIF,KAAK,iBAC3BtB,KAAA,CAAAoD,aAAA,CAAC1C,sBAAsB;MACnBkF,sBAAsB,EAAEpE,qBAAsB;MAC9CqE,aAAa,EAAEnE,MAAM,EAAEoE,gBAAiB;MACxCC,eAAe,EAAErE,MAAM,EAAE4D,kBAAmB;MAC5CU,mBAAmB,EAAE3E;IAAW,GAE/BC,KACmB,CAC3B,eAEDtB,KAAA,CAAAoD,aAAA,CAAC3C,2BAA2B;MAACmD,MAAM,EAAElC,MAAM,EAAE+C;IAAgB,CAAE,CACjC,CACjC,CAAC;EAEd,CAAC,EAAE,CACC/C,MAAM,EAAE+C,eAAe,EACvB/C,MAAM,EAAEoE,gBAAgB,EACxBpE,MAAM,EAAEmC,aAAa,EACrBnC,MAAM,EAAE4D,kBAAkB,EAC1B5D,MAAM,EAAEqD,SAAS,EACjBlD,MAAM,EACNP,KAAK,EACLD,UAAU,EACVe,WAAW,EACXb,kBAAkB,EAClBC,qBAAqB,EACrBI,SAAS,EACTH,KAAK,EACLU,KAAK,EACLR,UAAU,EACVG,IAAI,CACP,CAAC;EAEF,OAAO3B,OAAO,CACV,mBACIH,KAAA,CAAAoD,aAAA,CAAC5C,iBAAiB,QACbmD,WAAW,EACXrC,KAAK,IAAI,CAACE,qBAAqB,iBAC5BxB,KAAA,CAAAoD,aAAA,CAAC1C,sBAAsB;IAACmF,aAAa,EAAEnE,MAAM,EAAEoE;EAAiB,GAC3DxE,KACmB,CAEb,CACtB,EACD,CAACI,MAAM,EAAEoE,gBAAgB,EAAExE,KAAK,EAAEqC,WAAW,EAAEnC,qBAAqB,CACxE,CAAC;AACL,CAAC;AAEDJ,WAAW,CAAC6E,WAAW,GAAG,aAAa;AAEvC,eAAe7E,WAAW","ignoreList":[]}
|
|
@@ -16,18 +16,20 @@ export const StyledProgressBarProgressWrapper = styled.div`
|
|
|
16
16
|
position: relative;
|
|
17
17
|
width: 100%;
|
|
18
18
|
height: ${({
|
|
19
|
+
$height,
|
|
19
20
|
$isBig
|
|
20
|
-
}) => $isBig ? 20 : 10}px;
|
|
21
|
+
}) => $height || ($isBig ? 20 : 10)}px;
|
|
21
22
|
border-radius: ${({
|
|
23
|
+
$height,
|
|
22
24
|
$isBig
|
|
23
|
-
}) => $isBig ? 20 :
|
|
25
|
+
}) => $isBig ? $height ?? 20 : ($height ?? 10) / 5}px;
|
|
24
26
|
`;
|
|
25
27
|
const shineMove = keyframes`
|
|
26
28
|
from {
|
|
27
|
-
transform: translateX(-
|
|
29
|
+
transform: translateX(-100%);
|
|
28
30
|
}
|
|
29
31
|
to {
|
|
30
|
-
transform: translateX(
|
|
32
|
+
transform: translateX(100%);
|
|
31
33
|
}
|
|
32
34
|
`;
|
|
33
35
|
export const StyledProgressBarShine = styled.div.attrs(({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.styles.js","names":["motion","styled","css","keyframes","StyledProgressBar","div","StyledProgressBarBackground","theme","$color","StyledProgressBarProgressWrapper","$isBig","shineMove","StyledProgressBarShine","attrs","$delay","style","animationDelay","$speed","StyledMotionProgressBarProgress","headline","StyledProgressBarLabel","$shouldShowLabelInline","$colorSplitPosition","$primaryColor","$secondaryColor","StyledProgressBarStepWrapper","StyledProgressBarStep","$position","StyledProgressBarThumbLabel"],"sources":["../../../../src/components/progress-bar/ProgressBar.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css, keyframes } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledProgressBar = styled.div`\n position: relative;\n`;\n\ntype StyledProgressBarBackgroundProps = WithTheme<{ $color?: string }>;\n\nexport const StyledProgressBarBackground = styled.div<StyledProgressBarBackgroundProps>`\n height: 100%;\n width: 100%;\n background-color: ${({ theme, $color }: StyledProgressBarBackgroundProps) =>\n $color ?? theme['104']};\n`;\n\ntype StyledProgressBarProgressWrapperProps = WithTheme<{\n $isBig?: boolean;\n}>;\n\nexport const StyledProgressBarProgressWrapper = styled.div<StyledProgressBarProgressWrapperProps>`\n overflow: hidden;\n position: relative;\n width: 100%;\n height: ${({ $isBig }) => ($isBig ? 20 : 10)}px;\n border-radius: ${({ $isBig }) => ($isBig ? 20 :
|
|
1
|
+
{"version":3,"file":"ProgressBar.styles.js","names":["motion","styled","css","keyframes","StyledProgressBar","div","StyledProgressBarBackground","theme","$color","StyledProgressBarProgressWrapper","$height","$isBig","shineMove","StyledProgressBarShine","attrs","$delay","style","animationDelay","$speed","StyledMotionProgressBarProgress","headline","StyledProgressBarLabel","$shouldShowLabelInline","$colorSplitPosition","$primaryColor","$secondaryColor","StyledProgressBarStepWrapper","StyledProgressBarStep","$position","StyledProgressBarThumbLabel"],"sources":["../../../../src/components/progress-bar/ProgressBar.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css, keyframes } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledProgressBar = styled.div`\n position: relative;\n`;\n\ntype StyledProgressBarBackgroundProps = WithTheme<{ $color?: string }>;\n\nexport const StyledProgressBarBackground = styled.div<StyledProgressBarBackgroundProps>`\n height: 100%;\n width: 100%;\n background-color: ${({ theme, $color }: StyledProgressBarBackgroundProps) =>\n $color ?? theme['104']};\n`;\n\ntype StyledProgressBarProgressWrapperProps = WithTheme<{\n $isBig?: boolean;\n $height?: number;\n}>;\n\nexport const StyledProgressBarProgressWrapper = styled.div<StyledProgressBarProgressWrapperProps>`\n overflow: hidden;\n position: relative;\n width: 100%;\n height: ${({ $height, $isBig }) => $height || ($isBig ? 20 : 10)}px;\n border-radius: ${({ $height, $isBig }) => ($isBig ? ($height ?? 20) : ($height ?? 10) / 5)}px;\n`;\n\ntype StyledProgressBarProgressProps = WithTheme<{ $color?: string }>;\n\nconst shineMove = keyframes`\n from {\n transform: translateX(-100%);\n }\n to {\n transform: translateX(100%);\n }\n`;\n\nexport const StyledProgressBarShine = styled.div.attrs<{ $speed?: number; $delay?: number }>(\n ({ $delay }) => ({\n style: { animationDelay: `${$delay ?? 0}s` },\n }),\n)`\n position: absolute;\n width: 100%;\n height: 100%;\n background: linear-gradient(\n 90deg,\n rgba(255, 255, 255, 0) 33%,\n rgba(255, 255, 255, 0.5) 50%,\n rgba(255, 255, 255, 0) 66%\n );\n transform: translateX(-150%);\n animation: ${shineMove} ${({ $speed = 5 }) => `${$speed}s`} linear infinite;\n opacity: 0.95;\n`;\n\nexport const StyledMotionProgressBarProgress = styled(motion.div)<StyledProgressBarProgressProps>`\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n overflow: hidden;\n z-index: 2;\n display: flex;\n align-items: center;\n padding-left: 12px;\n background-color: ${({ theme, $color }: StyledProgressBarProgressProps) =>\n $color ?? theme.headline};\n`;\n\ntype StyledProgressBarLabelProps = WithTheme<{\n $shouldShowLabelInline?: boolean;\n $primaryColor?: string;\n $secondaryColor?: string;\n $colorSplitPosition?: number;\n}>;\n\nexport const StyledProgressBarLabel = styled.div<StyledProgressBarLabelProps>`\n font-size: 85%;\n color: ${({ theme, $shouldShowLabelInline }: StyledProgressBarLabelProps) =>\n $shouldShowLabelInline ? theme['100'] : theme.headline};\n white-space: nowrap;\n\n ${({ $colorSplitPosition, $primaryColor, $secondaryColor, theme }) =>\n $colorSplitPosition &&\n css`\n position: absolute;\n z-index: 2;\n width: 100%;\n height: 100%;\n\n display: flex;\n align-items: center;\n\n padding-left: 8px;\n\n font-weight: bold;\n\n -webkit-background-clip: text;\n\n color: transparent;\n background-image: linear-gradient(\n 90deg,\n ${$primaryColor ?? theme['100']} ${$colorSplitPosition}%,\n ${$secondaryColor ?? theme['300']} ${$colorSplitPosition}%\n );\n `}\n`;\n\nexport const StyledProgressBarStepWrapper = styled.div`\n height: 100%;\n width: 100%;\n position: absolute;\n`;\n\ntype StyledProgressBarStepProps = WithTheme<{\n $position: number;\n $color?: string;\n}>;\n\nexport const StyledProgressBarStep = styled.div<StyledProgressBarStepProps>`\n background-color: ${({ theme, $color }: StyledProgressBarStepProps) => $color ?? theme['102']};\n height: 100%;\n width: 2px;\n position: absolute;\n top: 0;\n left: ${({ $position }: StyledProgressBarStepProps) => $position}%;\n`;\n\nexport const StyledProgressBarThumbLabel = styled.div`\n position: absolute;\n right: 0;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,IAAIC,GAAG,EAAEC,SAAS,QAAQ,mBAAmB;AAG1D,OAAO,MAAMC,iBAAiB,GAAGH,MAAM,CAACI,GAAG;AAC3C;AACA,CAAC;AAID,OAAO,MAAMC,2BAA2B,GAAGL,MAAM,CAACI,GAAqC;AACvF;AACA;AACA,wBAAwB,CAAC;EAAEE,KAAK;EAAEC;AAAyC,CAAC,KACpEA,MAAM,IAAID,KAAK,CAAC,KAAK,CAAC;AAC9B,CAAC;AAOD,OAAO,MAAME,gCAAgC,GAAGR,MAAM,CAACI,GAA0C;AACjG;AACA;AACA;AACA,cAAc,CAAC;EAAEK,OAAO;EAAEC;AAAO,CAAC,KAAKD,OAAO,KAAKC,MAAM,GAAG,EAAE,GAAG,EAAE,CAAC;AACpE,qBAAqB,CAAC;EAAED,OAAO;EAAEC;AAAO,CAAC,KAAMA,MAAM,GAAID,OAAO,IAAI,EAAE,GAAI,CAACA,OAAO,IAAI,EAAE,IAAI,CAAE;AAC9F,CAAC;AAID,MAAME,SAAS,GAAGT,SAAS;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMU,sBAAsB,GAAGZ,MAAM,CAACI,GAAG,CAACS,KAAK,CAClD,CAAC;EAAEC;AAAO,CAAC,MAAM;EACbC,KAAK,EAAE;IAAEC,cAAc,EAAE,GAAGF,MAAM,IAAI,CAAC;EAAI;AAC/C,CAAC,CACL,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiBH,SAAS,IAAI,CAAC;EAAEM,MAAM,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C","ignoreList":[]}
|
|
@@ -41,6 +41,10 @@ export type ProgressBarProps = {
|
|
|
41
41
|
* Whether a shine animation should be shown on the progress bar. The amount of shine is based on the percentage value.
|
|
42
42
|
*/
|
|
43
43
|
showShine?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The height of the progress bar in pixels. If not provided, it will be 10px if shouldShowLabelInline is false and 20px if shouldShowLabelInline is true.
|
|
46
|
+
*/
|
|
47
|
+
height?: number;
|
|
44
48
|
};
|
|
45
49
|
declare const ProgressBar: FC<ProgressBarProps>;
|
|
46
50
|
export default ProgressBar;
|
|
@@ -6,6 +6,7 @@ type StyledProgressBarBackgroundProps = WithTheme<{
|
|
|
6
6
|
export declare const StyledProgressBarBackground: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledProgressBarBackgroundProps>> & string;
|
|
7
7
|
type StyledProgressBarProgressWrapperProps = WithTheme<{
|
|
8
8
|
$isBig?: boolean;
|
|
9
|
+
$height?: number;
|
|
9
10
|
}>;
|
|
10
11
|
export declare const StyledProgressBarProgressWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledProgressBarProgressWrapperProps>> & string;
|
|
11
12
|
type StyledProgressBarProgressProps = WithTheme<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.28",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "73767c299ffefdadd9a7aeace40f43fc0181fee7"
|
|
90
90
|
}
|