UNPKG

@stanfordspezi/spezi-web-design-system

Version:

Stanford Biodesign Digital Health Spezi Web Design System

7 lines (5 loc) 3.11 kB
"use strict";const l=require("react/jsx-runtime"),h=require("./index-DTLvoP6e.js"),$=require("./index-DwV9MiDB.js"),j=require("./misc-yOvtbcCM.js"),w=require("react"),_=require("./index-DO-atGp-.js");require("react-dom");const R=require("./index-CajSSBH7.js");function S(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const t=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,t.get?t:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const d=S(w);var I=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],g=I.reduce((e,r)=>{const o=R.createSlot(`Primitive.${r}`),t=d.forwardRef((a,i)=>{const{asChild:u,...s}=a,n=u?o:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(n,{...s,ref:i})});return t.displayName=`Primitive.${r}`,{...e,[r]:t}},{}),v="Progress",f=100,[M]=_.createContextScope(v),[O,q]=M(v),x=d.forwardRef((e,r)=>{const{__scopeProgress:o,value:t=null,max:a,getValueLabel:i=D,...u}=e;(a||a===0)&&!m(a)&&console.error(E(`${a}`,"Progress"));const s=m(a)?a:f;t!==null&&!p(t,s)&&console.error(V(`${t}`,"Progress"));const n=p(t,s)?t:null,y=c(n)?i(n,s):void 0;return l.jsx(O,{scope:o,value:n,max:s,children:l.jsx(g.div,{"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":c(n)?n:void 0,"aria-valuetext":y,role:"progressbar","data-state":N(n,s),"data-value":n??void 0,"data-max":s,...u,ref:r})})});x.displayName=v;var b="ProgressIndicator",P=d.forwardRef((e,r)=>{const{__scopeProgress:o,...t}=e,a=q(b,o);return l.jsx(g.div,{"data-state":N(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...t,ref:r})});P.displayName=b;function D(e,r){return`${Math.round(e/r*100)}%`}function N(e,r){return e==null?"indeterminate":e===r?"complete":"loading"}function c(e){return typeof e=="number"}function m(e){return c(e)&&!isNaN(e)&&e>0}function p(e,r){return c(e)&&!isNaN(e)&&e<=r&&e>=0}function E(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${f}\`.`}function V(e,r){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${r}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${f} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var C=x,A=P;const L=h.cva("relative h-1 w-full overflow-hidden rounded-full",{variants:{color:{primary:"bg-primary/10",foreground:"bg-foreground/10",destructive:"bg-destructive/10"}}}),T=({className:e,value:r,max:o=100,color:t="foreground",...a})=>{const i=Number.isFinite(o)&&o>0?o:100,u=Math.min(Math.max(r??0,0),i),s=u/i*100;return l.jsx(C,{"data-slot":"progress","data-color":t,className:L({color:t,className:e}),value:u,max:i,...a,children:l.jsx(A,{"data-slot":"progress-indicator",className:$.cn("size-full flex-1 transition",j.strategy({primary:"bg-primary",foreground:"bg-foreground",destructive:"bg-destructive"},t)),style:{transform:`translateX(-${100-s}%)`}})})};exports.Progress=T;