@spark-ui/progress 1.2.0 → 1.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/CHANGELOG.md +18 -0
- package/README.md +6 -6
- package/dist/Progress.d.ts +3 -1
- package/dist/ProgressBar.styles.d.ts +5 -0
- package/dist/ProgressContext.d.ts +3 -0
- package/dist/ProgressIndicator.styles.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +28 -25
- package/dist/public/docgen.json +68 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,24 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.4.0](https://github.com/adevinta/spark/compare/@spark-ui/progress@1.3.0...@spark-ui/progress@1.4.0) (2023-10-13)
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
- **progress:** add intent prop ([a13d817](https://github.com/adevinta/spark/commit/a13d817cb512c083bb77907c06a9be1ed128f68a))
|
11
|
+
- **progress:** add shape prop ([f955926](https://github.com/adevinta/spark/commit/f955926a099b5bc1778ed61edb7228b8bb24d570))
|
12
|
+
|
13
|
+
# [1.3.0](https://github.com/adevinta/spark/compare/@spark-ui/progress@1.2.0...@spark-ui/progress@1.3.0) (2023-09-29)
|
14
|
+
|
15
|
+
### Bug Fixes
|
16
|
+
|
17
|
+
- doc ([5506203](https://github.com/adevinta/spark/commit/55062039dc67c3532be42a4661540052094163d9))
|
18
|
+
- **progress:** doc ([8935b5f](https://github.com/adevinta/spark/commit/8935b5f5e8f162530af2ea1d8b9d8fee5600d23c))
|
19
|
+
|
20
|
+
### Features
|
21
|
+
|
22
|
+
- **progress:** lint ([1a6c11f](https://github.com/adevinta/spark/commit/1a6c11f4b81e204b47c189cc0afb8458e7eb84b0))
|
23
|
+
|
6
24
|
# [1.2.0](https://github.com/adevinta/spark/compare/@spark-ui/progress@1.1.2...@spark-ui/progress@1.2.0) (2023-09-28)
|
7
25
|
|
8
26
|
### Features
|
package/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Progress
|
2
2
|
> @spark-ui/progress
|
3
3
|
|
4
|
-
](https://sparkui.vercel.app/?path=/docs/components-progress--docs)
|
5
|
+
[](https://sparkui-adv.vercel.app/docs/components/progress)
|
6
|
+
[](https://github.com/adevinta/spark/issues/new?&projects=4&template=bug-report.yml&assignees=&labels=component,progress)
|
7
|
+
[](https://www.npmjs.com/package/@spark-ui/progress)
|
8
8
|
|
9
9
|
|
10
10
|
This package is part of the [`@spark-ui`](https://github.com/adevinta/spark) react-js user interface component library project.
|
11
11
|
|
12
|
-

|
12
|
+
[](https://github.com/adevinta/spark/issues?q=is%3Aopen+label%3Acomponent+label%3Aprogress)
|
13
|
+
[](https://github.com/adevinta/spark/blob/main/packages/components/progress/LICENSE.md)
|
package/dist/Progress.d.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { ProgressProps as ProgressPrimitiveProps } from '@radix-ui/react-progress';
|
2
|
-
|
2
|
+
import { ProgressIndicatorStylesProps } from './ProgressIndicator.styles';
|
3
|
+
export interface ProgressProps extends ProgressPrimitiveProps, Pick<ProgressIndicatorStylesProps, 'intent'> {
|
4
|
+
shape?: 'square' | 'rounded';
|
3
5
|
isIndeterminate?: boolean;
|
4
6
|
}
|
5
7
|
export declare const Progress: import("react").ForwardRefExoticComponent<ProgressProps & {
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
2
|
+
export declare const progressBarStyles: (props?: ({
|
3
|
+
shape?: "square" | "rounded" | null | undefined;
|
4
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
5
|
+
export type ProgressBarStylesProps = VariantProps<typeof progressBarStyles>;
|
@@ -1,7 +1,10 @@
|
|
1
|
+
import { ProgressIndicatorStylesProps } from './ProgressIndicator.styles';
|
1
2
|
export interface ProgressContextValue {
|
2
3
|
value: number;
|
3
4
|
max: number;
|
4
5
|
isIndeterminate: boolean;
|
6
|
+
shape: 'square' | 'rounded';
|
7
|
+
intent: ProgressIndicatorStylesProps['intent'];
|
5
8
|
onLabelId: (id?: string) => void;
|
6
9
|
}
|
7
10
|
export declare const ProgressContext: import("react").Context<ProgressContextValue | null>;
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
2
2
|
export declare const progressIndicatorStyles: (props?: ({
|
3
|
+
intent?: "main" | "basic" | "support" | "accent" | "success" | "alert" | "danger" | "info" | "neutral" | null | undefined;
|
4
|
+
shape?: "square" | "rounded" | null | undefined;
|
3
5
|
isIndeterminate?: boolean | null | undefined;
|
4
6
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
5
7
|
export type ProgressIndicatorStylesProps = VariantProps<typeof progressIndicatorStyles>;
|
package/dist/index.d.ts
CHANGED
@@ -8,6 +8,7 @@ export declare const Progress: FC<ProgressProps> & {
|
|
8
8
|
Bar: typeof ProgressBar;
|
9
9
|
Indicator: typeof ProgressIndicator;
|
10
10
|
};
|
11
|
+
export { type ProgressProps } from './Progress';
|
11
12
|
export { type ProgressBarProps } from './ProgressBar';
|
12
13
|
export { type ProgressLabelProps } from './ProgressLabel';
|
13
14
|
export { type ProgressIndicatorProps } from './ProgressIndicator';
|
package/dist/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),h=require("@radix-ui/react-progress"),g=require("class-variance-authority"),x=require("@radix-ui/react-id"),I=require("@spark-ui/use-merge-refs"),w=g.cva(["relative","h-sz-4 w-full","transform-gpu overflow-hidden","bg-on-background/dim-4"],{variants:{shape:{square:[],rounded:["rounded-sm"]}}}),v=e.createContext(null),b=()=>{const a=e.useContext(v);if(!a)throw new Error("useProgress must be used within a Progress provider");return a},q=g.cva(["h-full w-full","transition-transform duration-400"],{variants:{intent:{basic:["bg-basic"],main:["bg-main"],support:["bg-support"],accent:["bg-accent"],success:["bg-success"],alert:["bg-alert"],danger:["bg-error"],info:["bg-info"],neutral:["bg-neutral"]},shape:{square:[],rounded:["rounded-sm"]},isIndeterminate:{true:["absolute","-translate-x-1/2","animate-standalone-indeterminate-bar"],false:[]}}}),d=e.forwardRef(({className:a,style:s,...t},n)=>{const{value:r,max:l,intent:i,shape:c,isIndeterminate:o}=b(),m=(l-r)/l*100;return e.createElement(h.ProgressIndicator,{className:q({className:a,intent:i,shape:c,isIndeterminate:o}),style:{...s,...!o&&{transform:`translateX(-${m}%)`}},ref:n,...t})});d.displayName="Progress.Indicator";const u=e.forwardRef(({className:a,children:s=e.createElement(d,null),...t},n)=>{const{shape:r}=b();return e.createElement("div",{className:w({className:a,shape:r}),ref:n,...t},s)});u.displayName="Progress.Bar";const P=e.forwardRef(({className:a,value:s,max:t=100,shape:n="square",intent:r="basic",isIndeterminate:l=!1,children:i=e.createElement(u,null),...c},o)=>{const[m,p]=e.useState(),y=e.useMemo(()=>({value:s??0,max:t,intent:r,shape:n,isIndeterminate:l,onLabelId:p}),[t,s,r,n,l,p]);return e.createElement(v.Provider,{"data-spark-component":"progress",value:y},e.createElement(h.Progress,{ref:o,className:g.cx("flex flex-col gap-sm",a),value:s,"aria-labelledby":m,max:t,...c},i))});P.displayName="Progress";const f=e.forwardRef(({id:a,children:s,...t},n)=>{const r=x.useId(a),{onLabelId:l}=b(),i=e.useCallback(o=>{l(o?r:void 0)},[r,l]),c=I.useMergeRefs(n,i);return e.createElement("span",{id:r,className:"text-body-2 text-on-surface",ref:c,...t},s)});f.displayName="Progress.Label";const N=Object.assign(P,{Label:f,Bar:u,Indicator:d});N.displayName="Progress",u.displayName="Progress.Bar",d.displayName="Progress.Indicator",f.displayName="Progress.Label",exports.Progress=N;
|
package/dist/index.mjs
CHANGED
@@ -1,34 +1,37 @@
|
|
1
|
-
import o, { createContext as
|
2
|
-
import { ProgressIndicator as
|
3
|
-
import { cva as
|
4
|
-
import { useId as
|
5
|
-
import { useMergeRefs as
|
6
|
-
const
|
7
|
-
const e =
|
1
|
+
import o, { createContext as x, useContext as y, forwardRef as c, useState as I, useMemo as E, useCallback as w } from "react";
|
2
|
+
import { ProgressIndicator as L, Progress as k } from "@radix-ui/react-progress";
|
3
|
+
import { cva as h, cx as q } from "class-variance-authority";
|
4
|
+
import { useId as B } from "@radix-ui/react-id";
|
5
|
+
import { useMergeRefs as C } from "@spark-ui/use-merge-refs";
|
6
|
+
const M = h(["relative", "h-sz-4 w-full", "transform-gpu overflow-hidden", "bg-on-background/dim-4"], { variants: { shape: { square: [], rounded: ["rounded-sm"] } } }), N = x(null), g = () => {
|
7
|
+
const e = y(N);
|
8
8
|
if (!e)
|
9
9
|
throw new Error("useProgress must be used within a Progress provider");
|
10
10
|
return e;
|
11
|
-
},
|
12
|
-
const { value:
|
13
|
-
return o.createElement(
|
11
|
+
}, R = h(["h-full w-full", "transition-transform duration-400"], { variants: { intent: { basic: ["bg-basic"], main: ["bg-main"], support: ["bg-support"], accent: ["bg-accent"], success: ["bg-success"], alert: ["bg-alert"], danger: ["bg-error"], info: ["bg-info"], neutral: ["bg-neutral"] }, shape: { square: [], rounded: ["rounded-sm"] }, isIndeterminate: { true: ["absolute", "-translate-x-1/2", "animate-standalone-indeterminate-bar"], false: [] } } }), d = c(({ className: e, style: s, ...r }, t) => {
|
12
|
+
const { value: a, max: n, intent: i, shape: m, isIndeterminate: l } = g(), p = (n - a) / n * 100;
|
13
|
+
return o.createElement(L, { className: R({ className: e, intent: i, shape: m, isIndeterminate: l }), style: { ...s, ...!l && { transform: `translateX(-${p}%)` } }, ref: t, ...r });
|
14
|
+
});
|
15
|
+
d.displayName = "Progress.Indicator";
|
16
|
+
const u = c(({ className: e, children: s = o.createElement(d, null), ...r }, t) => {
|
17
|
+
const { shape: a } = g();
|
18
|
+
return o.createElement("div", { className: M({ className: e, shape: a }), ref: t, ...r }, s);
|
14
19
|
});
|
15
|
-
c.displayName = "Progress.Indicator";
|
16
|
-
const u = d(({ className: e, children: a = o.createElement(c, null), ...s }, r) => o.createElement("div", { className: g("relative h-sz-4 w-full transform-gpu overflow-hidden rounded-sm bg-on-background/dim-4", e), ref: r, ...s }, a));
|
17
20
|
u.displayName = "Progress.Bar";
|
18
|
-
const
|
19
|
-
const [
|
20
|
-
return o.createElement(
|
21
|
+
const v = c(({ className: e, value: s, max: r = 100, shape: t = "square", intent: a = "basic", isIndeterminate: n = !1, children: i = o.createElement(u, null), ...m }, l) => {
|
22
|
+
const [p, f] = I(), P = E(() => ({ value: s ?? 0, max: r, intent: a, shape: t, isIndeterminate: n, onLabelId: f }), [r, s, a, t, n, f]);
|
23
|
+
return o.createElement(N.Provider, { "data-spark-component": "progress", value: P }, o.createElement(k, { ref: l, className: q("flex flex-col gap-sm", e), value: s, "aria-labelledby": p, max: r, ...m }, i));
|
21
24
|
});
|
22
|
-
|
23
|
-
const
|
24
|
-
const
|
25
|
-
n(
|
26
|
-
}, [
|
27
|
-
return o.createElement("span", { id:
|
25
|
+
v.displayName = "Progress";
|
26
|
+
const b = c(({ id: e, children: s, ...r }, t) => {
|
27
|
+
const a = B(e), { onLabelId: n } = g(), i = w((l) => {
|
28
|
+
n(l ? a : void 0);
|
29
|
+
}, [a, n]), m = C(t, i);
|
30
|
+
return o.createElement("span", { id: a, className: "text-body-2 text-on-surface", ref: m, ...r }, s);
|
28
31
|
});
|
29
|
-
|
30
|
-
const
|
31
|
-
|
32
|
+
b.displayName = "Progress.Label";
|
33
|
+
const j = Object.assign(v, { Label: b, Bar: u, Indicator: d });
|
34
|
+
j.displayName = "Progress", u.displayName = "Progress.Bar", d.displayName = "Progress.Indicator", b.displayName = "Progress.Label";
|
32
35
|
export {
|
33
|
-
|
36
|
+
j as Progress
|
34
37
|
};
|
package/dist/public/docgen.json
CHANGED
@@ -5,6 +5,34 @@
|
|
5
5
|
"displayName": "Progress",
|
6
6
|
"methods": [],
|
7
7
|
"props": {
|
8
|
+
"shape": {
|
9
|
+
"defaultValue": null,
|
10
|
+
"description": "",
|
11
|
+
"name": "shape",
|
12
|
+
"parent": {
|
13
|
+
"fileName": "progress/src/Progress.tsx",
|
14
|
+
"name": "ProgressProps"
|
15
|
+
},
|
16
|
+
"declarations": [
|
17
|
+
{
|
18
|
+
"fileName": "progress/src/Progress.tsx",
|
19
|
+
"name": "ProgressProps"
|
20
|
+
}
|
21
|
+
],
|
22
|
+
"required": false,
|
23
|
+
"type": {
|
24
|
+
"name": "enum",
|
25
|
+
"raw": "\"square\" | \"rounded\"",
|
26
|
+
"value": [
|
27
|
+
{
|
28
|
+
"value": "\"square\""
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"value": "\"rounded\""
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
},
|
8
36
|
"isIndeterminate": {
|
9
37
|
"defaultValue": null,
|
10
38
|
"description": "",
|
@@ -95,6 +123,46 @@
|
|
95
123
|
"type": {
|
96
124
|
"name": "boolean"
|
97
125
|
}
|
126
|
+
},
|
127
|
+
"intent": {
|
128
|
+
"defaultValue": null,
|
129
|
+
"description": "",
|
130
|
+
"name": "intent",
|
131
|
+
"declarations": [],
|
132
|
+
"required": false,
|
133
|
+
"type": {
|
134
|
+
"name": "enum",
|
135
|
+
"raw": "\"main\" | \"basic\" | \"support\" | \"accent\" | \"success\" | \"alert\" | \"danger\" | \"info\" | \"neutral\"",
|
136
|
+
"value": [
|
137
|
+
{
|
138
|
+
"value": "\"main\""
|
139
|
+
},
|
140
|
+
{
|
141
|
+
"value": "\"basic\""
|
142
|
+
},
|
143
|
+
{
|
144
|
+
"value": "\"support\""
|
145
|
+
},
|
146
|
+
{
|
147
|
+
"value": "\"accent\""
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"value": "\"success\""
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"value": "\"alert\""
|
154
|
+
},
|
155
|
+
{
|
156
|
+
"value": "\"danger\""
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"value": "\"info\""
|
160
|
+
},
|
161
|
+
{
|
162
|
+
"value": "\"neutral\""
|
163
|
+
}
|
164
|
+
]
|
165
|
+
}
|
98
166
|
}
|
99
167
|
}
|
100
168
|
},
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@spark-ui/progress",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.4.0",
|
4
4
|
"description": "Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.",
|
5
5
|
"publishConfig": {
|
6
6
|
"access": "public"
|
@@ -48,5 +48,5 @@
|
|
48
48
|
},
|
49
49
|
"homepage": "https://sparkui.vercel.app",
|
50
50
|
"license": "MIT",
|
51
|
-
"gitHead": "
|
51
|
+
"gitHead": "24c1a2854b821dbe54d3a7bef88468ced9552aef"
|
52
52
|
}
|