@box/blueprint-web 12.136.1 → 12.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ import { type HTMLAttributes } from 'react';
2
+ export interface CircularProgressProps extends HTMLAttributes<HTMLDivElement> {
3
+ /** Required accessible label for the progress indicator. */
4
+ 'aria-label': string;
5
+ /** Progress value from 0 to 100. */
6
+ value: number;
7
+ }
8
+ export declare const CircularProgress: import("react").ForwardRefExoticComponent<CircularProgressProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,54 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { clsx } from 'clsx';
3
+ import { forwardRef } from 'react';
4
+ import styles from './circular-progress.module.js';
5
+
6
+ const SIZE = 24;
7
+ const STROKE_WIDTH = 2;
8
+ const RADIUS = (SIZE - STROKE_WIDTH) / 2;
9
+ const CIRCUMFERENCE = 2 * Math.PI * RADIUS;
10
+ function CircularProgressComponent(props, ref) {
11
+ const {
12
+ 'aria-label': ariaLabel,
13
+ value,
14
+ className,
15
+ ...rest
16
+ } = props;
17
+ const clampedValue = Math.min(100, Math.max(0, value));
18
+ const strokeDashoffset = CIRCUMFERENCE * (1 - clampedValue / 100);
19
+ const center = SIZE / 2;
20
+ return jsx("div", {
21
+ ...rest,
22
+ ref: ref,
23
+ "aria-label": ariaLabel,
24
+ "aria-valuemax": 100,
25
+ "aria-valuemin": 0,
26
+ "aria-valuenow": clampedValue,
27
+ className: clsx(styles['circular-progress'], className),
28
+ role: "progressbar",
29
+ children: jsxs("svg", {
30
+ "aria-hidden": "true",
31
+ className: styles.svg,
32
+ viewBox: `0 0 ${SIZE} ${SIZE}`,
33
+ children: [jsx("circle", {
34
+ className: styles.track,
35
+ cx: center,
36
+ cy: center,
37
+ r: RADIUS,
38
+ strokeWidth: STROKE_WIDTH
39
+ }), jsx("circle", {
40
+ className: styles.fill,
41
+ cx: center,
42
+ cy: center,
43
+ r: RADIUS,
44
+ strokeDasharray: CIRCUMFERENCE,
45
+ strokeDashoffset: strokeDashoffset,
46
+ strokeWidth: STROKE_WIDTH
47
+ })]
48
+ })
49
+ });
50
+ }
51
+ const CircularProgress = /*#__PURE__*/forwardRef(CircularProgressComponent);
52
+ CircularProgress.displayName = 'CircularProgress';
53
+
54
+ export { CircularProgress };
@@ -0,0 +1,4 @@
1
+ import '../index.css';
2
+ var styles = {"circular-progress":"bp_circular_progress_module_circular-progress--73ea7","svg":"bp_circular_progress_module_svg--73ea7","track":"bp_circular_progress_module_track--73ea7","fill":"bp_circular_progress_module_fill--73ea7"};
3
+
4
+ export { styles as default };
@@ -0,0 +1 @@
1
+ export { CircularProgress, type CircularProgressProps } from './circular-progress';