@nucleux/md3-progress 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/index.cjs +112 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nucleux
|
|
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,26 @@
|
|
|
1
|
+
# @nucleux/md3-progress
|
|
2
|
+
|
|
3
|
+
Material 3 progress indicators (linear, circular) — Nucleux agentic UI for React.
|
|
4
|
+
|
|
5
|
+
Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @nucleux/md3-progress @nucleux/tokens
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`react` / `react-dom` are peer dependencies.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Md3Progress } from "@nucleux/md3-progress";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
|
|
22
|
+
and the Tailwind preset from `@nucleux/tokens/preset`.
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT © Nucleux
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var utils = require('@nucleux/utils');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
|
+
|
|
28
|
+
// src/index.tsx
|
|
29
|
+
var Md3LinearProgress = React__namespace.forwardRef(
|
|
30
|
+
({ value, className, "aria-label": ariaLabel = "Loading", ...props }, ref) => {
|
|
31
|
+
const indeterminate = value === void 0;
|
|
32
|
+
const pct = indeterminate ? 40 : Math.min(100, Math.max(0, value));
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
ref,
|
|
37
|
+
role: "progressbar",
|
|
38
|
+
"aria-label": ariaLabel,
|
|
39
|
+
"aria-valuenow": indeterminate ? void 0 : pct,
|
|
40
|
+
"aria-valuemin": indeterminate ? void 0 : 0,
|
|
41
|
+
"aria-valuemax": indeterminate ? void 0 : 100,
|
|
42
|
+
className: utils.cn("h-1 w-full overflow-hidden rounded-full bg-md-surface-variant", className),
|
|
43
|
+
...props,
|
|
44
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
className: utils.cn("h-full rounded-full bg-md-primary transition-[width]", indeterminate && "animate-pulse"),
|
|
48
|
+
style: { width: `${pct}%` }
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
Md3LinearProgress.displayName = "Md3LinearProgress";
|
|
56
|
+
var Md3CircularProgress = React__namespace.forwardRef(
|
|
57
|
+
({ value, size = 48, strokeWidth = 4, className, "aria-label": ariaLabel = "Loading", ...props }, ref) => {
|
|
58
|
+
const indeterminate = value === void 0;
|
|
59
|
+
const r = (size - strokeWidth) / 2;
|
|
60
|
+
const c = 2 * Math.PI * r;
|
|
61
|
+
const pct = indeterminate ? 25 : Math.min(100, Math.max(0, value));
|
|
62
|
+
const offset = c - pct / 100 * c;
|
|
63
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
ref,
|
|
67
|
+
role: "progressbar",
|
|
68
|
+
"aria-label": ariaLabel,
|
|
69
|
+
"aria-valuenow": indeterminate ? void 0 : pct,
|
|
70
|
+
"aria-valuemin": indeterminate ? void 0 : 0,
|
|
71
|
+
"aria-valuemax": indeterminate ? void 0 : 100,
|
|
72
|
+
className: utils.cn("inline-flex", indeterminate && "animate-spin", className),
|
|
73
|
+
style: { width: size, height: size },
|
|
74
|
+
...props,
|
|
75
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
77
|
+
"circle",
|
|
78
|
+
{
|
|
79
|
+
cx: size / 2,
|
|
80
|
+
cy: size / 2,
|
|
81
|
+
r,
|
|
82
|
+
fill: "none",
|
|
83
|
+
stroke: "hsl(var(--nx-md-surface-variant))",
|
|
84
|
+
strokeWidth
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
+
"circle",
|
|
89
|
+
{
|
|
90
|
+
cx: size / 2,
|
|
91
|
+
cy: size / 2,
|
|
92
|
+
r,
|
|
93
|
+
fill: "none",
|
|
94
|
+
stroke: "hsl(var(--nx-md-primary))",
|
|
95
|
+
strokeWidth,
|
|
96
|
+
strokeLinecap: "round",
|
|
97
|
+
strokeDasharray: c,
|
|
98
|
+
strokeDashoffset: offset,
|
|
99
|
+
transform: `rotate(-90 ${size / 2} ${size / 2})`
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
] })
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
Md3CircularProgress.displayName = "Md3CircularProgress";
|
|
108
|
+
|
|
109
|
+
exports.Md3CircularProgress = Md3CircularProgress;
|
|
110
|
+
exports.Md3LinearProgress = Md3LinearProgress;
|
|
111
|
+
//# sourceMappingURL=index.cjs.map
|
|
112
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["React","jsx","cn","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,IAAM,iBAAA,GAA0BA,gBAAA,CAAA,UAAA;AAAA,EACrC,CAAC,EAAE,KAAA,EAAO,SAAA,EAAW,YAAA,EAAc,YAAY,SAAA,EAAW,GAAG,KAAA,EAAM,EAAG,GAAA,KAAQ;AAC5E,IAAA,MAAM,gBAAgB,KAAA,KAAU,MAAA;AAChC,IAAA,MAAM,GAAA,GAAM,aAAA,GAAgB,EAAA,GAAK,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,KAAK,CAAC,CAAA;AACjE,IAAA,uBACEC,cAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,IAAA,EAAK,aAAA;AAAA,QACL,YAAA,EAAY,SAAA;AAAA,QACZ,eAAA,EAAe,gBAAgB,MAAA,GAAY,GAAA;AAAA,QAC3C,eAAA,EAAe,gBAAgB,MAAA,GAAY,CAAA;AAAA,QAC3C,eAAA,EAAe,gBAAgB,MAAA,GAAY,GAAA;AAAA,QAC3C,SAAA,EAAWC,QAAA,CAAG,+DAAA,EAAiE,SAAS,CAAA;AAAA,QACvF,GAAG,KAAA;AAAA,QAEJ,QAAA,kBAAAD,cAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAWC,QAAA,CAAG,sDAAA,EAAwD,aAAA,IAAiB,eAAe,CAAA;AAAA,YACtG,KAAA,EAAO,EAAE,KAAA,EAAO,CAAA,EAAG,GAAG,CAAA,CAAA,CAAA;AAAI;AAAA;AAC5B;AAAA,KACF;AAAA,EAEJ;AACF;AACA,iBAAA,CA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A,CAAA,EAAI,IAAI,CAAA,CAAA,EAC1D,QAAA,EAAA;AAAA,0BAAAF,cAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAI,IAAA,GAAO,CAAA;AAAA,cACX,IAAI,IAAA,GAAO,CAAA;AAAA,cACX,CAAA;AAAA,cACA,IAAA,EAAK,MAAA;AAAA,cACL,MAAA,EAAO,mCAAA;AAAA,cACP;AAAA;AAAA,WACF;AAAA,0BACAA,cAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAI,IAAA,GAAO,CAAA;AAAA,cACX,IAAI,IAAA,GAAO,CAAA;AAAA,cACX,CAAA;AAAA,cACA,IAAA,EAAK,MAAA;AAAA,cACL,MAAA,EAAO,2BAAA;AAAA,cACP,WAAA;AAAA,cACA,aAAA,EAAc,OAAA;AAAA,cACd,eAAA,EAAiB,CAAA;AAAA,cACjB,gBAAA,EAAkB,MAAA;AAAA,cAClB,WAAW,CAAA,WAAA,EAAc,IAAA,GAAO,CAAC,CAAA,CAAA,EAAI,OAAO,CAAC,CAAA,CAAA;AAAA;AAAA;AAC/C,SAAA,EACF;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AACA,mBAAA,CAAoB,WAAA,GAAc,qBAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport interface Md3LinearProgressProps extends React.HTMLAttributes<HTMLDivElement> {\n /** 0–100. Omit for an indeterminate indicator. */\n value?: number;\n \"aria-label\"?: string;\n}\n\n/** A Material Design 3 linear progress indicator (determinate or indeterminate). */\nexport const Md3LinearProgress = React.forwardRef<HTMLDivElement, Md3LinearProgressProps>(\n ({ value, className, \"aria-label\": ariaLabel = \"Loading\", ...props }, ref) => {\n const indeterminate = value === undefined;\n const pct = indeterminate ? 40 : Math.min(100, Math.max(0, value));\n return (\n <div\n ref={ref}\n role=\"progressbar\"\n aria-label={ariaLabel}\n aria-valuenow={indeterminate ? undefined : pct}\n aria-valuemin={indeterminate ? undefined : 0}\n aria-valuemax={indeterminate ? undefined : 100}\n className={cn(\"h-1 w-full overflow-hidden rounded-full bg-md-surface-variant\", className)}\n {...props}\n >\n <div\n className={cn(\"h-full rounded-full bg-md-primary transition-[width]\", indeterminate && \"animate-pulse\")}\n style={{ width: `${pct}%` }}\n />\n </div>\n );\n },\n);\nMd3LinearProgress.displayName = \"Md3LinearProgress\";\n\nexport interface Md3CircularProgressProps extends React.HTMLAttributes<HTMLDivElement> {\n /** 0–100. Omit for an indeterminate spinner. */\n value?: number;\n /** Diameter in px. */\n size?: number;\n strokeWidth?: number;\n \"aria-label\"?: string;\n}\n\n/** A Material Design 3 circular progress indicator (determinate or indeterminate). */\nexport const Md3CircularProgress = React.forwardRef<HTMLDivElement, Md3CircularProgressProps>(\n ({ value, size = 48, strokeWidth = 4, className, \"aria-label\": ariaLabel = \"Loading\", ...props }, ref) => {\n const indeterminate = value === undefined;\n const r = (size - strokeWidth) / 2;\n const c = 2 * Math.PI * r;\n const pct = indeterminate ? 25 : Math.min(100, Math.max(0, value));\n const offset = c - (pct / 100) * c;\n\n return (\n <div\n ref={ref}\n role=\"progressbar\"\n aria-label={ariaLabel}\n aria-valuenow={indeterminate ? undefined : pct}\n aria-valuemin={indeterminate ? undefined : 0}\n aria-valuemax={indeterminate ? undefined : 100}\n className={cn(\"inline-flex\", indeterminate && \"animate-spin\", className)}\n style={{ width: size, height: size }}\n {...props}\n >\n <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`}>\n <circle\n cx={size / 2}\n cy={size / 2}\n r={r}\n fill=\"none\"\n stroke=\"hsl(var(--nx-md-surface-variant))\"\n strokeWidth={strokeWidth}\n />\n <circle\n cx={size / 2}\n cy={size / 2}\n r={r}\n fill=\"none\"\n stroke=\"hsl(var(--nx-md-primary))\"\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeDasharray={c}\n strokeDashoffset={offset}\n transform={`rotate(-90 ${size / 2} ${size / 2})`}\n />\n </svg>\n </div>\n );\n },\n);\nMd3CircularProgress.displayName = \"Md3CircularProgress\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface Md3LinearProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** 0–100. Omit for an indeterminate indicator. */
|
|
5
|
+
value?: number;
|
|
6
|
+
"aria-label"?: string;
|
|
7
|
+
}
|
|
8
|
+
/** A Material Design 3 linear progress indicator (determinate or indeterminate). */
|
|
9
|
+
declare const Md3LinearProgress: React.ForwardRefExoticComponent<Md3LinearProgressProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
interface Md3CircularProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
11
|
+
/** 0–100. Omit for an indeterminate spinner. */
|
|
12
|
+
value?: number;
|
|
13
|
+
/** Diameter in px. */
|
|
14
|
+
size?: number;
|
|
15
|
+
strokeWidth?: number;
|
|
16
|
+
"aria-label"?: string;
|
|
17
|
+
}
|
|
18
|
+
/** A Material Design 3 circular progress indicator (determinate or indeterminate). */
|
|
19
|
+
declare const Md3CircularProgress: React.ForwardRefExoticComponent<Md3CircularProgressProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
|
|
21
|
+
export { Md3CircularProgress, type Md3CircularProgressProps, Md3LinearProgress, type Md3LinearProgressProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface Md3LinearProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** 0–100. Omit for an indeterminate indicator. */
|
|
5
|
+
value?: number;
|
|
6
|
+
"aria-label"?: string;
|
|
7
|
+
}
|
|
8
|
+
/** A Material Design 3 linear progress indicator (determinate or indeterminate). */
|
|
9
|
+
declare const Md3LinearProgress: React.ForwardRefExoticComponent<Md3LinearProgressProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
interface Md3CircularProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
11
|
+
/** 0–100. Omit for an indeterminate spinner. */
|
|
12
|
+
value?: number;
|
|
13
|
+
/** Diameter in px. */
|
|
14
|
+
size?: number;
|
|
15
|
+
strokeWidth?: number;
|
|
16
|
+
"aria-label"?: string;
|
|
17
|
+
}
|
|
18
|
+
/** A Material Design 3 circular progress indicator (determinate or indeterminate). */
|
|
19
|
+
declare const Md3CircularProgress: React.ForwardRefExoticComponent<Md3CircularProgressProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
|
|
21
|
+
export { Md3CircularProgress, type Md3CircularProgressProps, Md3LinearProgress, type Md3LinearProgressProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from '@nucleux/utils';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/index.tsx
|
|
7
|
+
var Md3LinearProgress = React.forwardRef(
|
|
8
|
+
({ value, className, "aria-label": ariaLabel = "Loading", ...props }, ref) => {
|
|
9
|
+
const indeterminate = value === void 0;
|
|
10
|
+
const pct = indeterminate ? 40 : Math.min(100, Math.max(0, value));
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
ref,
|
|
15
|
+
role: "progressbar",
|
|
16
|
+
"aria-label": ariaLabel,
|
|
17
|
+
"aria-valuenow": indeterminate ? void 0 : pct,
|
|
18
|
+
"aria-valuemin": indeterminate ? void 0 : 0,
|
|
19
|
+
"aria-valuemax": indeterminate ? void 0 : 100,
|
|
20
|
+
className: cn("h-1 w-full overflow-hidden rounded-full bg-md-surface-variant", className),
|
|
21
|
+
...props,
|
|
22
|
+
children: /* @__PURE__ */ jsx(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
className: cn("h-full rounded-full bg-md-primary transition-[width]", indeterminate && "animate-pulse"),
|
|
26
|
+
style: { width: `${pct}%` }
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
Md3LinearProgress.displayName = "Md3LinearProgress";
|
|
34
|
+
var Md3CircularProgress = React.forwardRef(
|
|
35
|
+
({ value, size = 48, strokeWidth = 4, className, "aria-label": ariaLabel = "Loading", ...props }, ref) => {
|
|
36
|
+
const indeterminate = value === void 0;
|
|
37
|
+
const r = (size - strokeWidth) / 2;
|
|
38
|
+
const c = 2 * Math.PI * r;
|
|
39
|
+
const pct = indeterminate ? 25 : Math.min(100, Math.max(0, value));
|
|
40
|
+
const offset = c - pct / 100 * c;
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
ref,
|
|
45
|
+
role: "progressbar",
|
|
46
|
+
"aria-label": ariaLabel,
|
|
47
|
+
"aria-valuenow": indeterminate ? void 0 : pct,
|
|
48
|
+
"aria-valuemin": indeterminate ? void 0 : 0,
|
|
49
|
+
"aria-valuemax": indeterminate ? void 0 : 100,
|
|
50
|
+
className: cn("inline-flex", indeterminate && "animate-spin", className),
|
|
51
|
+
style: { width: size, height: size },
|
|
52
|
+
...props,
|
|
53
|
+
children: /* @__PURE__ */ jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
"circle",
|
|
56
|
+
{
|
|
57
|
+
cx: size / 2,
|
|
58
|
+
cy: size / 2,
|
|
59
|
+
r,
|
|
60
|
+
fill: "none",
|
|
61
|
+
stroke: "hsl(var(--nx-md-surface-variant))",
|
|
62
|
+
strokeWidth
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
"circle",
|
|
67
|
+
{
|
|
68
|
+
cx: size / 2,
|
|
69
|
+
cy: size / 2,
|
|
70
|
+
r,
|
|
71
|
+
fill: "none",
|
|
72
|
+
stroke: "hsl(var(--nx-md-primary))",
|
|
73
|
+
strokeWidth,
|
|
74
|
+
strokeLinecap: "round",
|
|
75
|
+
strokeDasharray: c,
|
|
76
|
+
strokeDashoffset: offset,
|
|
77
|
+
transform: `rotate(-90 ${size / 2} ${size / 2})`
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
] })
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
Md3CircularProgress.displayName = "Md3CircularProgress";
|
|
86
|
+
|
|
87
|
+
export { Md3CircularProgress, Md3LinearProgress };
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;AAUO,IAAM,iBAAA,GAA0B,KAAA,CAAA,UAAA;AAAA,EACrC,CAAC,EAAE,KAAA,EAAO,SAAA,EAAW,YAAA,EAAc,YAAY,SAAA,EAAW,GAAG,KAAA,EAAM,EAAG,GAAA,KAAQ;AAC5E,IAAA,MAAM,gBAAgB,KAAA,KAAU,MAAA;AAChC,IAAA,MAAM,GAAA,GAAM,aAAA,GAAgB,EAAA,GAAK,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,KAAK,CAAC,CAAA;AACjE,IAAA,uBACE,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,IAAA,EAAK,aAAA;AAAA,QACL,YAAA,EAAY,SAAA;AAAA,QACZ,eAAA,EAAe,gBAAgB,MAAA,GAAY,GAAA;AAAA,QAC3C,eAAA,EAAe,gBAAgB,MAAA,GAAY,CAAA;AAAA,QAC3C,eAAA,EAAe,gBAAgB,MAAA,GAAY,GAAA;AAAA,QAC3C,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B,MAAA,GAAY,GAAA;AAAA,QAC3C,SAAA,EAAW,EAAA,CAAG,aAAA,EAAe,aAAA,IAAiB,gBAAgB,SAAS,CAAA;AAAA,QACvE,KAAA,EAAO,EAAE,KAAA,EAAO,IAAA,EAAM,QAAQ,IAAA,EAAK;AAAA,QAClC,GAAG,KAAA;AAAA,QAEJ,QAAA,kBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,OAAA,EAAS,CAAA,IAAA,EAAO,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA,EAC1D,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAI,IAAA,GAAO,CAAA;AAAA,cACX,IAAI,IAAA,GAAO,CAAA;AAAA,cACX,CAAA;AAAA,cACA,IAAA,EAAK,MAAA;AAAA,cACL,MAAA,EAAO,mCAAA;AAAA,cACP;AAAA;AAAA,WACF;AAAA,0BACA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAI,IAAA,GAAO,CAAA;AAAA,cACX,IAAI,IAAA,GAAO,CAAA;AAAA,cACX,CAAA;AAAA,cACA,IAAA,EAAK,MAAA;AAAA,cACL,MAAA,EAAO,2BAAA;AAAA,cACP,WAAA;AAAA,cACA,aAAA,EAAc,OAAA;AAAA,cACd,eAAA,EAAiB,CAAA;AAAA,cACjB,gBAAA,EAAkB,MAAA;AAAA,cAClB,WAAW,CAAA,WAAA,EAAc,IAAA,GAAO,CAAC,CAAA,CAAA,EAAI,OAAO,CAAC,CAAA,CAAA;AAAA;AAAA;AAC/C,SAAA,EACF;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AACA,mBAAA,CAAoB,WAAA,GAAc,qBAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport interface Md3LinearProgressProps extends React.HTMLAttributes<HTMLDivElement> {\n /** 0–100. Omit for an indeterminate indicator. */\n value?: number;\n \"aria-label\"?: string;\n}\n\n/** A Material Design 3 linear progress indicator (determinate or indeterminate). */\nexport const Md3LinearProgress = React.forwardRef<HTMLDivElement, Md3LinearProgressProps>(\n ({ value, className, \"aria-label\": ariaLabel = \"Loading\", ...props }, ref) => {\n const indeterminate = value === undefined;\n const pct = indeterminate ? 40 : Math.min(100, Math.max(0, value));\n return (\n <div\n ref={ref}\n role=\"progressbar\"\n aria-label={ariaLabel}\n aria-valuenow={indeterminate ? undefined : pct}\n aria-valuemin={indeterminate ? undefined : 0}\n aria-valuemax={indeterminate ? undefined : 100}\n className={cn(\"h-1 w-full overflow-hidden rounded-full bg-md-surface-variant\", className)}\n {...props}\n >\n <div\n className={cn(\"h-full rounded-full bg-md-primary transition-[width]\", indeterminate && \"animate-pulse\")}\n style={{ width: `${pct}%` }}\n />\n </div>\n );\n },\n);\nMd3LinearProgress.displayName = \"Md3LinearProgress\";\n\nexport interface Md3CircularProgressProps extends React.HTMLAttributes<HTMLDivElement> {\n /** 0–100. Omit for an indeterminate spinner. */\n value?: number;\n /** Diameter in px. */\n size?: number;\n strokeWidth?: number;\n \"aria-label\"?: string;\n}\n\n/** A Material Design 3 circular progress indicator (determinate or indeterminate). */\nexport const Md3CircularProgress = React.forwardRef<HTMLDivElement, Md3CircularProgressProps>(\n ({ value, size = 48, strokeWidth = 4, className, \"aria-label\": ariaLabel = \"Loading\", ...props }, ref) => {\n const indeterminate = value === undefined;\n const r = (size - strokeWidth) / 2;\n const c = 2 * Math.PI * r;\n const pct = indeterminate ? 25 : Math.min(100, Math.max(0, value));\n const offset = c - (pct / 100) * c;\n\n return (\n <div\n ref={ref}\n role=\"progressbar\"\n aria-label={ariaLabel}\n aria-valuenow={indeterminate ? undefined : pct}\n aria-valuemin={indeterminate ? undefined : 0}\n aria-valuemax={indeterminate ? undefined : 100}\n className={cn(\"inline-flex\", indeterminate && \"animate-spin\", className)}\n style={{ width: size, height: size }}\n {...props}\n >\n <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`}>\n <circle\n cx={size / 2}\n cy={size / 2}\n r={r}\n fill=\"none\"\n stroke=\"hsl(var(--nx-md-surface-variant))\"\n strokeWidth={strokeWidth}\n />\n <circle\n cx={size / 2}\n cy={size / 2}\n r={r}\n fill=\"none\"\n stroke=\"hsl(var(--nx-md-primary))\"\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeDasharray={c}\n strokeDashoffset={offset}\n transform={`rotate(-90 ${size / 2} ${size / 2})`}\n />\n </svg>\n </div>\n );\n },\n);\nMd3CircularProgress.displayName = \"Md3CircularProgress\";\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nucleux/md3-progress",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "Material 3 progress indicators (linear, circular) — Nucleux agentic UI for React.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"nucleux",
|
|
9
|
+
"react",
|
|
10
|
+
"ui",
|
|
11
|
+
"components",
|
|
12
|
+
"agentic",
|
|
13
|
+
"ai",
|
|
14
|
+
"tailwind",
|
|
15
|
+
"md3-progress"
|
|
16
|
+
],
|
|
17
|
+
"main": "./dist/index.cjs",
|
|
18
|
+
"module": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"require": "./dist/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": ">=18",
|
|
33
|
+
"react-dom": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@nucleux/utils": "0.4.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"tsup": "^8.3.5",
|
|
40
|
+
"typescript": "^5.7.2",
|
|
41
|
+
"@types/react": "^18.3.18",
|
|
42
|
+
"react": "^18.3.1",
|
|
43
|
+
"lucide-react": "^0.469.0"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
|
|
52
|
+
"directory": "packages/md3-progress"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup"
|
|
57
|
+
}
|
|
58
|
+
}
|