@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 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
- ![storybook](https://img.shields.io/badge/storybook-black?logo=storybook&link=https%3A%2F%2Fsparkui.vercel.app%2F%3Fpath%3D%2Fdocs%2Fcomponents-progress--docs)
5
- ![documentation](https://img.shields.io/badge/documentation-black?logo=googledocs&link=https%3A%2F%2Fsparkui-adv.vercel.app%2Fdocs%2Fcomponents%2Fprogress)
6
- ![issue](https://img.shields.io/badge/report%20a%20bug-black?logo=openbugbounty&logoColor=red&link=https%3A%2F%2Fgithub.com%2Fadevinta%2Fspark%2Fissues%2Fnew%3F%26projects%3D4%26template%3Dbug-report.yml%26assignees%3D%26labels%3Dcomponent%2Cprogress)
7
- ![npm](https://img.shields.io/npm/dt/%40spark-ui/progress?logo=npm&labelColor=black&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40spark-ui%2Fprogress)
4
+ [![storybook](https://img.shields.io/badge/storybook-black?logo=storybook)](https://sparkui.vercel.app/?path=/docs/components-progress--docs)
5
+ [![documentation](https://img.shields.io/badge/documentation-black?logo=googledocs)](https://sparkui-adv.vercel.app/docs/components/progress)
6
+ [![issue](https://img.shields.io/badge/report%20a%20bug-black?logo=openbugbounty&logoColor=red)](https://github.com/adevinta/spark/issues/new?&projects=4&template=bug-report.yml&assignees=&labels=component,progress)
7
+ [![npm](https://img.shields.io/npm/dt/%40spark-ui/progress?logo=npm&labelColor=black)](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
- ![Issues open](https://img.shields.io/github/issues-search/adevinta/spark?query=is%3Aopen%20label%3Acomponent%20label%3Aprogressl&logo=openbugbounty&logoColor=red&label=issues%20open&color=red&link=https%3A%2F%2Fgithub.com%2Fadevinta%2Fspark%2Fissues%3Fq%3Dis%253Aopen%2Blabel%253Acomponent%2Blabel%253Aprogress)
13
- ![NPM](https://img.shields.io/npm/l/%40spark-ui%2Fprogress)
12
+ [![Issues open](https://img.shields.io/github/issues-search/adevinta/spark?query=is%3Aopen%20label%3Acomponent%20label%3Aprogressl&logo=openbugbounty&logoColor=red&label=issues%20open&color=red)](https://github.com/adevinta/spark/issues?q=is%3Aopen+label%3Acomponent+label%3Aprogress)
13
+ [![NPM](https://img.shields.io/npm/l/%40spark-ui%2Fprogress)](https://github.com/adevinta/spark/blob/main/packages/components/progress/LICENSE.md)
@@ -1,5 +1,7 @@
1
1
  import { ProgressProps as ProgressPrimitiveProps } from '@radix-ui/react-progress';
2
- export interface ProgressProps extends ProgressPrimitiveProps {
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"),b=require("@radix-ui/react-progress"),u=require("class-variance-authority"),y=require("@radix-ui/react-id"),x=require("@spark-ui/use-merge-refs"),p=e.createContext(null),N=()=>{const r=e.useContext(p);if(!r)throw new Error("useProgress must be used within a Progress provider");return r},I=u.cva(["h-full w-full","bg-basic","rounded-sm","transition-transform duration-400"],{variants:{isIndeterminate:{true:["absolute","-translate-x-1/2","animate-standalone-indeterminate-bar"],false:[]}}}),m=e.forwardRef(({className:r,style:a,...s},t)=>{const{value:n,max:l,isIndeterminate:o}=N(),i=(l-n)/l*100;return e.createElement(b.ProgressIndicator,{className:I({isIndeterminate:o,className:r}),style:{...a,...!o&&{transform:`translateX(-${i}%)`}},ref:t,...s})});m.displayName="Progress.Indicator";const c=e.forwardRef(({className:r,children:a=e.createElement(m,null),...s},t)=>e.createElement("div",{className:u.cx("relative h-sz-4 w-full transform-gpu overflow-hidden rounded-sm bg-on-background/dim-4",r),ref:t,...s},a));c.displayName="Progress.Bar";const P=e.forwardRef(({className:r,value:a,max:s=100,isIndeterminate:t=!1,children:n=e.createElement(c,null),...l},o)=>{const[i,d]=e.useState(),v=e.useMemo(()=>({value:a??0,max:s,isIndeterminate:t,onLabelId:d}),[s,a,t,d]);return e.createElement(p.Provider,{"data-spark-component":"progress",value:v},e.createElement(b.Progress,{ref:o,className:u.cx("flex flex-col gap-sm",r),value:a,"aria-labelledby":i,max:s,...l},n))});P.displayName="Progress";const f=e.forwardRef(({id:r,children:a,...s},t)=>{const n=y.useId(r),{onLabelId:l}=N(),o=e.useCallback(d=>{l(d?n:void 0)},[n,l]),i=x.useMergeRefs(t,o);return e.createElement("span",{id:n,className:"text-body-2 text-on-surface",ref:i,...s},a)});f.displayName="Progress.Label";const g=Object.assign(P,{Label:f,Bar:c,Indicator:m});g.displayName="Progress",c.displayName="Progress.Bar",m.displayName="Progress.Indicator",f.displayName="Progress.Label",exports.Progress=g;
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 v, useContext as x, forwardRef as d, useState as y, useMemo as I, useCallback as h } from "react";
2
- import { ProgressIndicator as E, Progress as w } from "@radix-ui/react-progress";
3
- import { cva as L, cx as g } from "class-variance-authority";
4
- import { useId as k } from "@radix-ui/react-id";
5
- import { useMergeRefs as B } from "@spark-ui/use-merge-refs";
6
- const p = v(null), b = () => {
7
- const e = x(p);
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
- }, C = L(["h-full w-full", "bg-basic", "rounded-sm", "transition-transform duration-400"], { variants: { isIndeterminate: { true: ["absolute", "-translate-x-1/2", "animate-standalone-indeterminate-bar"], false: [] } } }), c = d(({ className: e, style: a, ...s }, r) => {
12
- const { value: t, max: n, isIndeterminate: l } = b(), m = (n - t) / n * 100;
13
- return o.createElement(E, { className: C({ isIndeterminate: l, className: e }), style: { ...a, ...!l && { transform: `translateX(-${m}%)` } }, ref: r, ...s });
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 N = d(({ className: e, value: a, max: s = 100, isIndeterminate: r = !1, children: t = o.createElement(u, null), ...n }, l) => {
19
- const [m, i] = y(), P = I(() => ({ value: a ?? 0, max: s, isIndeterminate: r, onLabelId: i }), [s, a, r, i]);
20
- return o.createElement(p.Provider, { "data-spark-component": "progress", value: P }, o.createElement(w, { ref: l, className: g("flex flex-col gap-sm", e), value: a, "aria-labelledby": m, max: s, ...n }, t));
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
- N.displayName = "Progress";
23
- const f = d(({ id: e, children: a, ...s }, r) => {
24
- const t = k(e), { onLabelId: n } = b(), l = h((i) => {
25
- n(i ? t : void 0);
26
- }, [t, n]), m = B(r, l);
27
- return o.createElement("span", { id: t, className: "text-body-2 text-on-surface", ref: m, ...s }, a);
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
- f.displayName = "Progress.Label";
30
- const M = Object.assign(N, { Label: f, Bar: u, Indicator: c });
31
- M.displayName = "Progress", u.displayName = "Progress.Bar", c.displayName = "Progress.Indicator", f.displayName = "Progress.Label";
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
- M as Progress
36
+ j as Progress
34
37
  };
@@ -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.2.0",
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": "60a8f00aef92177084ac744bc4fd56ef13bc9948"
51
+ "gitHead": "24c1a2854b821dbe54d3a7bef88468ced9552aef"
52
52
  }