@spark-ui/progress 1.4.0 → 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 CHANGED
@@ -3,6 +3,14 @@
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
+
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)
11
+
12
+ **Note:** Version bump only for package @spark-ui/progress
13
+
6
14
  # [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
15
 
8
16
  ### Features
@@ -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("@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;
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 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";
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: [] } } }), 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 });
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
- 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
+ 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
- u.displayName = "Progress.Bar";
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));
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 = 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);
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 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
+ 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
- j as Progress
35
+ $ as Progress
37
36
  };
@@ -126,7 +126,7 @@
126
126
  },
127
127
  "intent": {
128
128
  "defaultValue": null,
129
- "description": "",
129
+ "description": "Color scheme of the progress component.",
130
130
  "name": "intent",
131
131
  "declarations": [],
132
132
  "required": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-ui/progress",
3
- "version": "1.4.0",
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": "24c1a2854b821dbe54d3a7bef88468ced9552aef"
50
+ "gitHead": "5ed3e4725b9166b355dc96ce39f0d35e414a1ad9"
52
51
  }