@spark-ui/progress 1.4.1 → 1.4.2
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 +4 -0
- package/dist/ProgressContext.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +22 -23
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
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.2](https://github.com/adevinta/spark/compare/@spark-ui/progress@1.4.1...@spark-ui/progress@1.4.2) (2024-04-22)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @spark-ui/progress
|
9
|
+
|
6
10
|
## [1.4.1](https://github.com/adevinta/spark/compare/@spark-ui/progress@1.4.0...@spark-ui/progress@1.4.1) (2023-12-05)
|
7
11
|
|
8
12
|
**Note:** Version bump only for package @spark-ui/progress
|
@@ -8,4 +8,5 @@ export interface ProgressContextValue {
|
|
8
8
|
onLabelId: (id?: string) => void;
|
9
9
|
}
|
10
10
|
export declare const ProgressContext: import("react").Context<ProgressContextValue | null>;
|
11
|
+
export declare const ID_PREFIX = ":progress";
|
11
12
|
export declare const useProgress: () => ProgressContextValue;
|
package/dist/index.js
CHANGED
@@ -1 +1 @@
|
|
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("@
|
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("@spark-ui/use-merge-refs"),I=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},w=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:[]}}}),u=e.forwardRef(({className:a,style:r,...s},n)=>{const{value:l,max:t,intent:o,shape:c,isIndeterminate:i}=b(),d=(t-l)/t*100;return e.createElement(h.ProgressIndicator,{className:w({className:a,intent:o,shape:c,isIndeterminate:i}),style:{...r,...!i&&{transform:`translateX(-${d}%)`}},ref:n,...s})});u.displayName="Progress.Indicator";const m=e.forwardRef(({className:a,children:r=e.createElement(u,null),...s},n)=>{const{shape:l}=b();return e.createElement("div",{className:I({className:a,shape:l}),ref:n,...s},r)});m.displayName="Progress.Bar";const P=e.forwardRef(({className:a,value:r,max:s=100,shape:n="square",intent:l="basic",isIndeterminate:t=!1,children:o=e.createElement(m,null),...c},i)=>{const[d,f]=e.useState(),y=e.useMemo(()=>({value:r??0,max:s,intent:l,shape:n,isIndeterminate:t,onLabelId:f}),[s,r,l,n,t,f]);return e.createElement(v.Provider,{"data-spark-component":"progress",value:y},e.createElement(h.Progress,{ref:i,className:g.cx("flex flex-col gap-sm",a),value:r,"aria-labelledby":d,max:s,...c},o))});P.displayName="Progress";const p=e.forwardRef(({id:a,children:r,...s},n)=>{const l=`:progress-label-${e.useId()}`,t=a||l,{onLabelId:o}=b(),c=e.useCallback(d=>{o(d?t:void 0)},[t,o]),i=x.useMergeRefs(n,c);return e.createElement("span",{id:t,className:"text-body-2 text-on-surface",ref:i,...s},r)});p.displayName="Progress.Label";const N=Object.assign(P,{Label:p,Bar:m,Indicator:u});N.displayName="Progress",m.displayName="Progress.Bar",u.displayName="Progress.Indicator",p.displayName="Progress.Label",exports.Progress=N;
|
package/dist/index.mjs
CHANGED
@@ -1,37 +1,36 @@
|
|
1
|
-
import o, { createContext as x, useContext as y, forwardRef as
|
2
|
-
import { ProgressIndicator as
|
3
|
-
import { cva as h, cx as
|
4
|
-
import { useId as B } from "@radix-ui/react-id";
|
1
|
+
import o, { createContext as x, useContext as y, forwardRef as d, useState as I, useMemo as E, useId as w, useCallback as L } from "react";
|
2
|
+
import { ProgressIndicator as k, Progress as q } from "@radix-ui/react-progress";
|
3
|
+
import { cva as h, cx as B } from "class-variance-authority";
|
5
4
|
import { useMergeRefs as C } from "@spark-ui/use-merge-refs";
|
6
5
|
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
6
|
const e = y(N);
|
8
7
|
if (!e)
|
9
8
|
throw new Error("useProgress must be used within a Progress provider");
|
10
9
|
return e;
|
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: [] } } }),
|
12
|
-
const { value:
|
13
|
-
return o.createElement(
|
10
|
+
}, 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: [] } } }), u = d(({ className: e, style: a, ...s }, t) => {
|
11
|
+
const { value: n, max: r, intent: l, shape: m, isIndeterminate: i } = g(), c = (r - n) / r * 100;
|
12
|
+
return o.createElement(k, { className: R({ className: e, intent: l, shape: m, isIndeterminate: i }), style: { ...a, ...!i && { transform: `translateX(-${c}%)` } }, ref: t, ...s });
|
14
13
|
});
|
15
|
-
|
16
|
-
const
|
17
|
-
const { shape:
|
18
|
-
return o.createElement("div", { className: M({ className: e, shape:
|
14
|
+
u.displayName = "Progress.Indicator";
|
15
|
+
const p = d(({ className: e, children: a = o.createElement(u, null), ...s }, t) => {
|
16
|
+
const { shape: n } = g();
|
17
|
+
return o.createElement("div", { className: M({ className: e, shape: n }), ref: t, ...s }, a);
|
19
18
|
});
|
20
|
-
|
21
|
-
const v =
|
22
|
-
const [
|
23
|
-
return o.createElement(N.Provider, { "data-spark-component": "progress", value: P }, o.createElement(
|
19
|
+
p.displayName = "Progress.Bar";
|
20
|
+
const v = d(({ className: e, value: a, max: s = 100, shape: t = "square", intent: n = "basic", isIndeterminate: r = !1, children: l = o.createElement(p, null), ...m }, i) => {
|
21
|
+
const [c, f] = I(), P = E(() => ({ value: a ?? 0, max: s, intent: n, shape: t, isIndeterminate: r, onLabelId: f }), [s, a, n, t, r, f]);
|
22
|
+
return o.createElement(N.Provider, { "data-spark-component": "progress", value: P }, o.createElement(q, { ref: i, className: B("flex flex-col gap-sm", e), value: a, "aria-labelledby": c, max: s, ...m }, l));
|
24
23
|
});
|
25
24
|
v.displayName = "Progress";
|
26
|
-
const b =
|
27
|
-
const
|
28
|
-
|
29
|
-
}, [
|
30
|
-
return o.createElement("span", { id:
|
25
|
+
const b = d(({ id: e, children: a, ...s }, t) => {
|
26
|
+
const n = `:progress-label-${w()}`, r = e || n, { onLabelId: l } = g(), m = L((c) => {
|
27
|
+
l(c ? r : void 0);
|
28
|
+
}, [r, l]), i = C(t, m);
|
29
|
+
return o.createElement("span", { id: r, className: "text-body-2 text-on-surface", ref: i, ...s }, a);
|
31
30
|
});
|
32
31
|
b.displayName = "Progress.Label";
|
33
|
-
const
|
34
|
-
|
32
|
+
const $ = Object.assign(v, { Label: b, Bar: p, Indicator: u });
|
33
|
+
$.displayName = "Progress", p.displayName = "Progress.Bar", u.displayName = "Progress.Indicator", b.displayName = "Progress.Label";
|
35
34
|
export {
|
36
|
-
|
35
|
+
$ as Progress
|
37
36
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@spark-ui/progress",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.2",
|
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"
|
@@ -23,7 +23,6 @@
|
|
23
23
|
"build": "vite build"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@radix-ui/react-id": "1.0.1",
|
27
26
|
"@radix-ui/react-progress": "1.0.3",
|
28
27
|
"@spark-ui/use-merge-refs": "^0.4.0",
|
29
28
|
"class-variance-authority": "0.7.0"
|
@@ -48,5 +47,5 @@
|
|
48
47
|
},
|
49
48
|
"homepage": "https://sparkui.vercel.app",
|
50
49
|
"license": "MIT",
|
51
|
-
"gitHead": "
|
50
|
+
"gitHead": "5ed3e4725b9166b355dc96ce39f0d35e414a1ad9"
|
52
51
|
}
|