@dt-dds/react-progress-bar 1.0.0-beta.35

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 ADDED
@@ -0,0 +1,349 @@
1
+ # @dt-ui/react-progress-bar
2
+
3
+ ## 1.0.0-beta.35
4
+
5
+ ### Major Changes
6
+
7
+ - refactor!: rename pkg and publish to npmjs
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @dt-dds/react-icon@1.0.0-beta.42
13
+ - @dt-dds/react-typography@1.0.0-beta.32
14
+
15
+ ## 0.1.0-beta.34
16
+
17
+ ### Patch Changes
18
+
19
+ - refactor: drop icon funcional state
20
+ - Updated dependencies
21
+ - @dt-ui/react-icon@0.1.0-beta.41
22
+
23
+ ## 0.1.0-beta.33
24
+
25
+ ### Patch Changes
26
+
27
+ - refactor: theme typography values
28
+ - Updated dependencies
29
+ - @dt-ui/react-icon@0.1.0-beta.40
30
+ - @dt-ui/react-typography@0.1.0-beta.31
31
+
32
+ ## 0.1.0-beta.32
33
+
34
+ ### Minor Changes
35
+
36
+ - feat: update shadow theme values
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies
41
+ - @dt-ui/react-icon@0.1.0-beta.39
42
+ - @dt-ui/react-typography@0.1.0-beta.30
43
+
44
+ ## 0.1.0-beta.31
45
+
46
+ ### Minor Changes
47
+
48
+ - feat: add new icon font sizes
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies
53
+ - @dt-ui/react-icon@0.1.0-beta.38
54
+
55
+ ## 0.1.0-beta.30
56
+
57
+ ### Patch Changes
58
+
59
+ - chore: update theme font-styles
60
+ - Updated dependencies
61
+ - @dt-ui/react-icon@0.1.0-beta.37
62
+ - @dt-ui/react-typography@0.1.0-beta.29
63
+
64
+ ## 0.1.0-beta.29
65
+
66
+ ### Patch Changes
67
+
68
+ - chore: review OSS files
69
+ - Updated dependencies
70
+ - @dt-ui/react-icon@0.1.0-beta.36
71
+ - @dt-ui/react-typography@0.1.0-beta.28
72
+
73
+ ## 0.1.0-beta.28
74
+
75
+ ### Patch Changes
76
+
77
+ - chore: update contextual colors
78
+ - Updated dependencies
79
+ - @dt-ui/react-icon@0.1.0-beta.35
80
+ - @dt-ui/react-typography@0.1.0-beta.27
81
+
82
+ ## 0.1.0-beta.27
83
+
84
+ ### Minor Changes
85
+
86
+ - feat: implement IconButton contrast and size
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies
91
+ - @dt-ui/react-icon@0.1.0-beta.34
92
+
93
+ ## 0.1.0-beta.26
94
+
95
+ ### Patch Changes
96
+
97
+ - fix: change content.light contextual color
98
+ - Updated dependencies
99
+ - @dt-ui/react-icon@0.1.0-beta.33
100
+ - @dt-ui/react-typography@0.1.0-beta.26
101
+
102
+ ## 0.1.0-beta.25
103
+
104
+ ### Minor Changes
105
+
106
+ - feat: move icon-button to independent
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies
111
+ - @dt-ui/react-icon@0.1.0-beta.32
112
+
113
+ ## 0.1.0-beta.24
114
+
115
+ ### Patch Changes
116
+
117
+ - fix: add accent to colors type
118
+ - Updated dependencies
119
+ - @dt-ui/react-icon@0.1.0-beta.31
120
+ - @dt-ui/react-typography@0.1.0-beta.25
121
+
122
+ ## 0.1.0-beta.23
123
+
124
+ ### Patch Changes
125
+
126
+ - fix: change button text according to ux
127
+ - Updated dependencies
128
+ - @dt-ui/react-icon@0.1.0-beta.30
129
+ - @dt-ui/react-typography@0.1.0-beta.24
130
+
131
+ ## 0.1.0-beta.22
132
+
133
+ ### Patch Changes
134
+
135
+ - chore: update contexual colors
136
+ - Updated dependencies
137
+ - @dt-ui/react-typography@0.1.0-beta.23
138
+ - @dt-ui/react-icon@0.1.0-beta.29
139
+
140
+ ## 0.1.0-beta.21
141
+
142
+ ### Patch Changes
143
+
144
+ - style: update responsive font styles
145
+ - Updated dependencies
146
+ - @dt-ui/react-icon@0.1.0-beta.28
147
+ - @dt-ui/react-typography@0.1.0-beta.22
148
+
149
+ ## 0.1.0-beta.20
150
+
151
+ ### Minor Changes
152
+
153
+ - feat: add spinner size 'extra-small' & update specs
154
+
155
+ ### Patch Changes
156
+
157
+ - Updated dependencies
158
+ - @dt-ui/react-icon@0.1.0-beta.27
159
+ - @dt-ui/react-typography@0.1.0-beta.21
160
+
161
+ ## 0.1.0-beta.19
162
+
163
+ ### Patch Changes
164
+
165
+ - chore: add theme breakpoints
166
+ - Updated dependencies
167
+ - @dt-ui/react-icon@0.1.0-beta.26
168
+ - @dt-ui/react-typography@0.1.0-beta.20
169
+
170
+ ## 0.1.0-beta.18
171
+
172
+ ### Minor Changes
173
+
174
+ - feat: add id to base props
175
+
176
+ ### Patch Changes
177
+
178
+ - Updated dependencies
179
+ - @dt-ui/react-typography@0.1.0-beta.19
180
+ - @dt-ui/react-icon@0.1.0-beta.25
181
+
182
+ ## 0.1.0-beta.17
183
+
184
+ ### Minor Changes
185
+
186
+ - feat: change breakpoints values
187
+
188
+ ### Patch Changes
189
+
190
+ - Updated dependencies
191
+ - @dt-ui/react-icon@0.1.0-beta.24
192
+ - @dt-ui/react-typography@0.1.0-beta.18
193
+
194
+ ## 0.1.0-beta.16
195
+
196
+ ### Patch Changes
197
+
198
+ - fix: replace body to correct one
199
+ - Updated dependencies
200
+ - @dt-ui/react-icon@0.1.0-beta.23
201
+ - @dt-ui/react-typography@0.1.0-beta.17
202
+
203
+ ## 0.1.0-beta.15
204
+
205
+ ### Patch Changes
206
+
207
+ - chore: add theme colors missing types
208
+ - Updated dependencies
209
+ - @dt-ui/react-icon@0.1.0-beta.22
210
+ - @dt-ui/react-typography@0.1.0-beta.16
211
+
212
+ ## 0.1.0-beta.14
213
+
214
+ ### Patch Changes
215
+
216
+ - refactor: drop truckapi theme
217
+ - Updated dependencies
218
+ - @dt-ui/react-icon@0.1.0-beta.21
219
+ - @dt-ui/react-typography@0.1.0-beta.15
220
+
221
+ ## 0.1.0-beta.13
222
+
223
+ ### Minor Changes
224
+
225
+ - feat: update core and semantic colors
226
+ - feat: remove greenlane theme
227
+
228
+ ### Patch Changes
229
+
230
+ - Updated dependencies
231
+ - Updated dependencies
232
+ - @dt-ui/react-icon@0.1.0-beta.20
233
+ - @dt-ui/react-typography@0.1.0-beta.14
234
+
235
+ ## 0.1.0-beta.12
236
+
237
+ ### Minor Changes
238
+
239
+ - feat: add icon option for truckapi theme
240
+
241
+ ### Patch Changes
242
+
243
+ - Updated dependencies
244
+ - @dt-ui/react-icon@0.1.0-beta.19
245
+ - @dt-ui/react-typography@0.1.0-beta.13
246
+
247
+ ## 0.1.0-beta.11
248
+
249
+ ### Patch Changes
250
+
251
+ - fix: tooltip z index
252
+ - Updated dependencies
253
+ - @dt-ui/react-icon@0.1.0-beta.18
254
+ - @dt-ui/react-typography@0.1.0-beta.12
255
+
256
+ ## 0.1.0-beta.10
257
+
258
+ ### Minor Changes
259
+
260
+ - feat: add segmented control component
261
+
262
+ ### Patch Changes
263
+
264
+ - Updated dependencies
265
+ - @dt-ui/react-icon@0.1.0-beta.17
266
+ - @dt-ui/react-typography@0.1.0-beta.11
267
+
268
+ ## 0.1.0-beta.9
269
+
270
+ ### Patch Changes
271
+
272
+ - fix: add shape for tooltip on truckapi theme
273
+ - Updated dependencies
274
+ - @dt-ui/react-icon@0.1.0-beta.16
275
+ - @dt-ui/react-typography@0.1.0-beta.10
276
+
277
+ ## 0.1.0-beta.8
278
+
279
+ ### Patch Changes
280
+
281
+ - fix: remove devDependecy export
282
+ - Updated dependencies
283
+ - @dt-ui/react-icon@0.1.0-beta.15
284
+ - @dt-ui/react-typography@0.1.0-beta.9
285
+
286
+ ## 0.1.0-beta.7
287
+
288
+ ### Patch Changes
289
+
290
+ - test: add test custom render
291
+ - Updated dependencies
292
+ - @dt-ui/react-icon@0.1.0-beta.14
293
+ - @dt-ui/react-typography@0.1.0-beta.8
294
+
295
+ ## 0.1.0-beta.6
296
+
297
+ ### Minor Changes
298
+
299
+ - feat: create select
300
+
301
+ ### Patch Changes
302
+
303
+ - Updated dependencies
304
+ - @dt-ui/react-icon@0.1.0-beta.13
305
+ - @dt-ui/react-typography@0.1.0-beta.7
306
+
307
+ ## 0.1.0-beta.5
308
+
309
+ ### Patch Changes
310
+
311
+ - fix: show shadows only when scroll is visible
312
+ - Updated dependencies
313
+ - @dt-ui/react-icon@0.1.0-beta.12
314
+ - @dt-ui/react-typography@0.1.0-beta.6
315
+
316
+ ## 0.1.0-beta.4
317
+
318
+ ### Patch Changes
319
+
320
+ - fix: update border radius theme specifications
321
+ - Updated dependencies
322
+ - @dt-ui/react-icon@0.1.0-beta.11
323
+ - @dt-ui/react-typography@0.1.0-beta.5
324
+
325
+ ## 0.1.0-beta.3
326
+
327
+ ### Minor Changes
328
+
329
+ - feat: add onClick on Icon
330
+
331
+ ### Patch Changes
332
+
333
+ - Updated dependencies
334
+ - @dt-ui/react-icon@0.1.0-beta.10
335
+
336
+ ## 0.1.0-beta.2
337
+
338
+ ### Patch Changes
339
+
340
+ - fix: match accordion design
341
+ - Updated dependencies
342
+ - @dt-ui/react-icon@0.1.0-beta.9
343
+ - @dt-ui/react-typography@0.1.0-beta.4
344
+
345
+ ## 0.1.0-beta.1
346
+
347
+ ### Patch Changes
348
+
349
+ - chore: make progress-bar independent package
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Daimler Truck AG.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # ProgressBar Package
2
+
3
+ The progress bar works as a progress indicator to inform users about the status of ongoing processes.
4
+
5
+ ## ProgressBar Usage
6
+
7
+ ```jsx
8
+ import { ProgressBar } from '@dt-dds/react-progress-bar';
9
+
10
+ export const App = () => {
11
+ return (
12
+ <ProgressBar
13
+ label='State of Charge'
14
+ value={55}
15
+ state='error'
16
+ size='small'
17
+ />
18
+ );
19
+ };
20
+ ```
21
+
22
+ ### Properties
23
+
24
+ | Property | Type | Default | Description |
25
+ | ------------ | ------------------------- | -------- | ------------------------------------------------------------------------- |
26
+ | `value` | `number` | `0` | Percentage of the progress. Positive integer between 0-100 |
27
+ | `state` | `typeof ProgressBarState` | `active` | Status of the action, could be active, success, or error |
28
+ | `size` | `typeof ProgressBarSize` | `small` | Determines the size of the progress bar |
29
+ | `label` | `string` | - | A label to describe the progress bar |
30
+ | `helperText` | `string` | - | A text to complement the label |
31
+ | `info` | `typeof ProgressBarInfo` | -` | Determines which indicator to display, could be none, text, icon, or both |
32
+
33
+ ## Stack
34
+
35
+ - [TypeScript](https://www.typescriptlang.org/) for static type checking
36
+ - [React](https://reactjs.org/) — JavaScript library for user interfaces
37
+ - [Emotion](https://emotion.sh/docs/introduction) — for writing css styles with JavaScript
38
+ - [Storybook](https://storybook.js.org/) — UI component environment powered by Vite
39
+ - [Jest](https://jestjs.io/) - JavaScript Testing Framework
40
+ - [React Testing Library](https://testing-library.com/) - to test UI components in a user-centric way
41
+ - [ESLint](https://eslint.org/) for code linting
42
+ - [Prettier](https://prettier.io) for code formatting
43
+ - [Tsup](https://github.com/egoist/tsup) — TypeScript bundler powered by esbuild
44
+ - [Yarn](https://yarnpkg.com/) from managing packages
45
+
46
+ ## Commands
47
+
48
+ - `yarn build` - Build the package
49
+ - `yarn dev` - Run the package locally
50
+ - `yarn lint` - Lint all files within this package
51
+ - `yarn test` - Run all unit tests
52
+ - `yarn test:report` - Open the test coverage report
53
+ - `yarn test:update:snapshot` - Run all unit tests and update the snapshot
54
+
55
+ ## Compilation
56
+
57
+ Running `yarn build` from the root of the package will use [tsup](https://tsup.egoist.dev/) to compile the raw TypeScript and React code to plain JavaScript.
58
+
59
+ The `/dist` folder contains the compiled output.
60
+
61
+ ```bash
62
+ progress-bar
63
+ └── dist
64
+ ├── index.d.ts <-- Types
65
+ ├── index.js <-- CommonJS version
66
+ └── index.mjs <-- ES Modules version
67
+ ...
68
+ ```
69
+
70
+ ## Versioning
71
+
72
+ Follows [semantic versioning](https://semver.org/)
73
+
74
+ ## &copy; License
75
+
76
+ Licensed under [MIT License](LICENSE.md)
@@ -0,0 +1,23 @@
1
+ import { Theme } from '@dt-dds/react-core';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ type ProgressBarSize = 'small' | 'large';
5
+ type ProgressBarState = 'active' | 'success' | 'error';
6
+ type ProgressBarInfo = 'none' | 'text' | 'icon' | 'both';
7
+
8
+ interface ProgressBarProps {
9
+ state: ProgressBarState;
10
+ value: number;
11
+ label?: string;
12
+ helperText?: string;
13
+ info?: ProgressBarInfo;
14
+ size?: ProgressBarSize;
15
+ }
16
+ declare const ProgressBar: ({ state, value, label, helperText, size, info, }: ProgressBarProps) => react_jsx_runtime.JSX.Element;
17
+
18
+ declare module '@emotion/react' {
19
+ interface Theme extends Theme {
20
+ }
21
+ }
22
+
23
+ export { ProgressBar, ProgressBarProps };
package/dist/index.js ADDED
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // index.ts
31
+ var progress_bar_exports = {};
32
+ __export(progress_bar_exports, {
33
+ ProgressBar: () => ProgressBar
34
+ });
35
+ module.exports = __toCommonJS(progress_bar_exports);
36
+
37
+ // src/ProgressBar.tsx
38
+ var import_react_icon = require("@dt-dds/react-icon");
39
+ var import_react_typography = require("@dt-dds/react-typography");
40
+ var import_react = require("@emotion/react");
41
+
42
+ // src/constants/value.ts
43
+ var MIN_PROGRESS_BAR_VALUE = 0;
44
+ var MAX_PROGRESS_BAR_VALUE = 100;
45
+
46
+ // src/ProgressBar.styled.ts
47
+ var import_styled = __toESM(require("@emotion/styled"));
48
+ var progressBarHeights = {
49
+ small: "4px",
50
+ large: "8px"
51
+ };
52
+ var progressBarColors = (theme) => ({
53
+ active: {
54
+ background: theme.palette.informative.default,
55
+ helper: theme.palette.content.medium,
56
+ percentage: theme.palette.content.default
57
+ },
58
+ success: {
59
+ background: theme.palette.success.default,
60
+ helper: theme.palette.content.medium,
61
+ percentage: theme.palette.content.default
62
+ },
63
+ error: {
64
+ background: theme.palette.error.default,
65
+ helper: theme.palette.error.default,
66
+ percentage: theme.palette.error.default
67
+ }
68
+ });
69
+ var ProgressBarFieldStyled = import_styled.default.div`
70
+ ${({ theme }) => `
71
+ display: flex;
72
+ flex-direction: column;
73
+ align-items: flex-start;
74
+ gap: ${theme.spacing["5xs"]};
75
+ min-width: 48px;
76
+ `}
77
+ `;
78
+ var ProgressBarWrapperStyled = import_styled.default.div`
79
+ ${({ theme }) => `
80
+ display: grid;
81
+ grid-template-columns: minmax(48px, 1fr) 28px 16px;
82
+ align-items: center;
83
+ gap: ${theme.spacing["5xs"]};
84
+ width: 100%;
85
+ height: 16px;
86
+ `}
87
+ `;
88
+ var ProgressBarStyled = import_styled.default.div`
89
+ ${({ theme, size, state, progress }) => `
90
+ width: ${progress}%;
91
+ height: ${progressBarHeights[size]};
92
+ background-color: ${progressBarColors(theme)[state].background};
93
+ transition: width 0.2s ease-in-out;
94
+ border-radius: ${theme.radius.none} ${theme.shape.progressbar} ${theme.shape.progressbar} ${theme.radius.none};
95
+ `};
96
+ `;
97
+ var ProgressBarTrackStyled = import_styled.default.div`
98
+ ${({ theme }) => `
99
+ width: 100%;
100
+ background-color: ${theme.palette.secondary.medium};
101
+ border-radius: ${theme.shape.progressbar};
102
+ overflow: hidden;
103
+ `};
104
+ `;
105
+ var ProgressBarHelperTextStyled = import_styled.default.p`
106
+ ${({ theme, state }) => `
107
+ ${theme.fontStyles.body3}
108
+ color: ${progressBarColors(theme)[state].helper};
109
+ `};
110
+ `;
111
+ var ProgressBarPercentageTextStyled = import_styled.default.div`
112
+ ${({ theme, state }) => `
113
+ ${theme.fontStyles.body3}
114
+ text-align: center;
115
+ color: ${progressBarColors(theme)[state].percentage};
116
+ `};
117
+ `;
118
+ var ProgressBarIconStyled = import_styled.default.div`
119
+ height: 16px;
120
+ line-height: 16px;
121
+ `;
122
+
123
+ // src/ProgressBar.tsx
124
+ var import_jsx_runtime = require("react/jsx-runtime");
125
+ var ProgressBar = ({
126
+ state,
127
+ value,
128
+ label,
129
+ helperText,
130
+ size = "small",
131
+ info = "none"
132
+ }) => {
133
+ const normalizedValue = Math.min(
134
+ Math.max(value, MIN_PROGRESS_BAR_VALUE),
135
+ MAX_PROGRESS_BAR_VALUE
136
+ );
137
+ const theme = (0, import_react.useTheme)();
138
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ProgressBarFieldStyled, { children: [
139
+ label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_typography.Typography, { color: "content.default", fontStyles: "body2Bold", children: label }) : null,
140
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ProgressBarWrapperStyled, { children: [
141
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
+ ProgressBarTrackStyled,
143
+ {
144
+ "aria-label": label,
145
+ "aria-valuemax": MAX_PROGRESS_BAR_VALUE,
146
+ "aria-valuemin": MIN_PROGRESS_BAR_VALUE,
147
+ "aria-valuenow": normalizedValue,
148
+ role: "progressbar",
149
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
+ ProgressBarStyled,
151
+ {
152
+ progress: normalizedValue,
153
+ size,
154
+ state
155
+ }
156
+ )
157
+ }
158
+ ),
159
+ renderInfo()
160
+ ] }),
161
+ helperText ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBarHelperTextStyled, { state, children: helperText }) : null
162
+ ] });
163
+ function renderInfo() {
164
+ if (info === "none") {
165
+ return;
166
+ }
167
+ const ProgressIcon = {
168
+ success: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
169
+ import_react_icon.Icon,
170
+ {
171
+ code: "check_circle",
172
+ color: theme.palette.success.default,
173
+ size: "s"
174
+ }
175
+ ),
176
+ error: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icon.Icon, { code: "error", color: theme.palette.error.default, size: "s" })
177
+ };
178
+ let content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBarPercentageTextStyled, { state, children: `${normalizedValue}%` });
179
+ if (state !== "active") {
180
+ if (info === "icon") {
181
+ content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBarIconStyled, { children: ProgressIcon[state] });
182
+ }
183
+ if (info === "both") {
184
+ content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
185
+ content,
186
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBarIconStyled, { children: ProgressIcon[state] })
187
+ ] });
188
+ }
189
+ }
190
+ return content;
191
+ }
192
+ };
193
+ // Annotate the CommonJS export names for ESM import in node:
194
+ 0 && (module.exports = {
195
+ ProgressBar
196
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,159 @@
1
+ // src/ProgressBar.tsx
2
+ import { Icon } from "@dt-dds/react-icon";
3
+ import { Typography } from "@dt-dds/react-typography";
4
+ import { useTheme } from "@emotion/react";
5
+
6
+ // src/constants/value.ts
7
+ var MIN_PROGRESS_BAR_VALUE = 0;
8
+ var MAX_PROGRESS_BAR_VALUE = 100;
9
+
10
+ // src/ProgressBar.styled.ts
11
+ import styled from "@emotion/styled";
12
+ var progressBarHeights = {
13
+ small: "4px",
14
+ large: "8px"
15
+ };
16
+ var progressBarColors = (theme) => ({
17
+ active: {
18
+ background: theme.palette.informative.default,
19
+ helper: theme.palette.content.medium,
20
+ percentage: theme.palette.content.default
21
+ },
22
+ success: {
23
+ background: theme.palette.success.default,
24
+ helper: theme.palette.content.medium,
25
+ percentage: theme.palette.content.default
26
+ },
27
+ error: {
28
+ background: theme.palette.error.default,
29
+ helper: theme.palette.error.default,
30
+ percentage: theme.palette.error.default
31
+ }
32
+ });
33
+ var ProgressBarFieldStyled = styled.div`
34
+ ${({ theme }) => `
35
+ display: flex;
36
+ flex-direction: column;
37
+ align-items: flex-start;
38
+ gap: ${theme.spacing["5xs"]};
39
+ min-width: 48px;
40
+ `}
41
+ `;
42
+ var ProgressBarWrapperStyled = styled.div`
43
+ ${({ theme }) => `
44
+ display: grid;
45
+ grid-template-columns: minmax(48px, 1fr) 28px 16px;
46
+ align-items: center;
47
+ gap: ${theme.spacing["5xs"]};
48
+ width: 100%;
49
+ height: 16px;
50
+ `}
51
+ `;
52
+ var ProgressBarStyled = styled.div`
53
+ ${({ theme, size, state, progress }) => `
54
+ width: ${progress}%;
55
+ height: ${progressBarHeights[size]};
56
+ background-color: ${progressBarColors(theme)[state].background};
57
+ transition: width 0.2s ease-in-out;
58
+ border-radius: ${theme.radius.none} ${theme.shape.progressbar} ${theme.shape.progressbar} ${theme.radius.none};
59
+ `};
60
+ `;
61
+ var ProgressBarTrackStyled = styled.div`
62
+ ${({ theme }) => `
63
+ width: 100%;
64
+ background-color: ${theme.palette.secondary.medium};
65
+ border-radius: ${theme.shape.progressbar};
66
+ overflow: hidden;
67
+ `};
68
+ `;
69
+ var ProgressBarHelperTextStyled = styled.p`
70
+ ${({ theme, state }) => `
71
+ ${theme.fontStyles.body3}
72
+ color: ${progressBarColors(theme)[state].helper};
73
+ `};
74
+ `;
75
+ var ProgressBarPercentageTextStyled = styled.div`
76
+ ${({ theme, state }) => `
77
+ ${theme.fontStyles.body3}
78
+ text-align: center;
79
+ color: ${progressBarColors(theme)[state].percentage};
80
+ `};
81
+ `;
82
+ var ProgressBarIconStyled = styled.div`
83
+ height: 16px;
84
+ line-height: 16px;
85
+ `;
86
+
87
+ // src/ProgressBar.tsx
88
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
89
+ var ProgressBar = ({
90
+ state,
91
+ value,
92
+ label,
93
+ helperText,
94
+ size = "small",
95
+ info = "none"
96
+ }) => {
97
+ const normalizedValue = Math.min(
98
+ Math.max(value, MIN_PROGRESS_BAR_VALUE),
99
+ MAX_PROGRESS_BAR_VALUE
100
+ );
101
+ const theme = useTheme();
102
+ return /* @__PURE__ */ jsxs(ProgressBarFieldStyled, { children: [
103
+ label ? /* @__PURE__ */ jsx(Typography, { color: "content.default", fontStyles: "body2Bold", children: label }) : null,
104
+ /* @__PURE__ */ jsxs(ProgressBarWrapperStyled, { children: [
105
+ /* @__PURE__ */ jsx(
106
+ ProgressBarTrackStyled,
107
+ {
108
+ "aria-label": label,
109
+ "aria-valuemax": MAX_PROGRESS_BAR_VALUE,
110
+ "aria-valuemin": MIN_PROGRESS_BAR_VALUE,
111
+ "aria-valuenow": normalizedValue,
112
+ role: "progressbar",
113
+ children: /* @__PURE__ */ jsx(
114
+ ProgressBarStyled,
115
+ {
116
+ progress: normalizedValue,
117
+ size,
118
+ state
119
+ }
120
+ )
121
+ }
122
+ ),
123
+ renderInfo()
124
+ ] }),
125
+ helperText ? /* @__PURE__ */ jsx(ProgressBarHelperTextStyled, { state, children: helperText }) : null
126
+ ] });
127
+ function renderInfo() {
128
+ if (info === "none") {
129
+ return;
130
+ }
131
+ const ProgressIcon = {
132
+ success: /* @__PURE__ */ jsx(
133
+ Icon,
134
+ {
135
+ code: "check_circle",
136
+ color: theme.palette.success.default,
137
+ size: "s"
138
+ }
139
+ ),
140
+ error: /* @__PURE__ */ jsx(Icon, { code: "error", color: theme.palette.error.default, size: "s" })
141
+ };
142
+ let content = /* @__PURE__ */ jsx(ProgressBarPercentageTextStyled, { state, children: `${normalizedValue}%` });
143
+ if (state !== "active") {
144
+ if (info === "icon") {
145
+ content = /* @__PURE__ */ jsx(ProgressBarIconStyled, { children: ProgressIcon[state] });
146
+ }
147
+ if (info === "both") {
148
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
149
+ content,
150
+ /* @__PURE__ */ jsx(ProgressBarIconStyled, { children: ProgressIcon[state] })
151
+ ] });
152
+ }
153
+ }
154
+ return content;
155
+ }
156
+ };
157
+ export {
158
+ ProgressBar
159
+ };
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@dt-dds/react-progress-bar",
3
+ "version": "1.0.0-beta.35",
4
+ "license": "MIT",
5
+ "exports": {
6
+ ".": "./dist/index.js"
7
+ },
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.mjs",
10
+ "types": "./dist/index.d.ts",
11
+ "files": [
12
+ "dist/**"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsup",
16
+ "dev": "tsup --watch",
17
+ "lint": "eslint --cache .",
18
+ "test": "jest",
19
+ "test:report": "open ./jest-coverage/lcov-report/index.html",
20
+ "test:update:snapshot": "jest -u"
21
+ },
22
+ "dependencies": {
23
+ "@dt-dds/react-icon": "1.0.0-beta.42",
24
+ "@dt-dds/react-typography": "1.0.0-beta.32"
25
+ },
26
+ "devDependencies": {
27
+ "@babel/core": "^7.22.9",
28
+ "@babel/preset-env": "^7.22.9",
29
+ "@babel/preset-react": "^7.22.5",
30
+ "@babel/preset-typescript": "^7.23.3",
31
+ "@dt-dds/react-core": "1.0.0-beta.41",
32
+ "@emotion/babel-plugin": "^11.11.0",
33
+ "@emotion/css": "^11.7.1",
34
+ "@emotion/jest": "^11.10.0",
35
+ "@emotion/react": "^11.8.2",
36
+ "@emotion/styled": "^11.8.1",
37
+ "@types/react": "^18.0.9",
38
+ "@types/react-dom": "^18.0.4",
39
+ "babel-loader": "^8.3.0",
40
+ "eslint-config-custom": "*",
41
+ "eslint-plugin-storybook": "^9.1.0",
42
+ "jest-config": "*",
43
+ "react": "^18.1.0",
44
+ "react-dom": "^18.2.0",
45
+ "tsconfig": "*",
46
+ "tsup": "^6.6.3",
47
+ "typescript": "^4.5.3"
48
+ },
49
+ "peerDependencies": {
50
+ "@emotion/css": "^11.7.1",
51
+ "@emotion/react": "^11.8.2",
52
+ "@emotion/styled": "^11.8.1",
53
+ "react": ">=17.0.2",
54
+ "react-dom": ">=17.0.2"
55
+ }
56
+ }