UNPKG

dgz-ui

Version:

Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript

8 lines (6 loc) 4.01 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),O=require("react");require("react-dom");const I=require("../chunks/index-CMEUY8i_.cjs.js"),E=require("../chunks/utils-C4d7Ql9-.cjs.js");function R(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,s.get?s:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const l=R(O);function D(e,r=[]){let o=[];function s(u,i){const t=l.createContext(i);t.displayName=u+"Context";const a=o.length;o=[...o,i];const f=p=>{var S;const{scope:d,children:g,...v}=p,m=((S=d==null?void 0:d[e])==null?void 0:S[a])||t,M=l.useMemo(()=>v,Object.values(v));return c.jsx(m.Provider,{value:M,children:g})};f.displayName=u+"Provider";function N(p,d){var m;const g=((m=d==null?void 0:d[e])==null?void 0:m[a])||t,v=l.useContext(g);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${u}\``)}return[f,N]}const n=()=>{const u=o.map(i=>l.createContext(i));return function(t){const a=(t==null?void 0:t[e])||u;return l.useMemo(()=>({[`__scope${e}`]:{...t,[e]:a}}),[t,a])}};return n.scopeName=e,[s,V(n,...r)]}function V(...e){const r=e[0];if(e.length===1)return r;const o=()=>{const s=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(u){const i=s.reduce((t,{useScope:a,scopeName:f})=>{const p=a(u)[`__scope${f}`];return{...t,...p}},{});return l.useMemo(()=>({[`__scope${r.scopeName}`]:i}),[i])}};return o.scopeName=r.scopeName,o}var q=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_=q.reduce((e,r)=>{const o=I.createSlot(`Primitive.${r}`),s=l.forwardRef((n,u)=>{const{asChild:i,...t}=n,a=i?o:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...t,ref:u})});return s.displayName=`Primitive.${r}`,{...e,[r]:s}},{}),P="Progress",b=100,[A]=D(P),[T,L]=A(P),$=l.forwardRef((e,r)=>{const{__scopeProgress:o,value:s=null,max:n,getValueLabel:u=k,...i}=e;(n||n===0)&&!h(n)&&console.error(G(`${n}`,"Progress"));const t=h(n)?n:b;s!==null&&!y(s,t)&&console.error(X(`${s}`,"Progress"));const a=y(s,t)?s:null,f=x(a)?u(a,t):void 0;return c.jsx(T,{scope:o,value:a,max:t,children:c.jsx(_.div,{"aria-valuemax":t,"aria-valuemin":0,"aria-valuenow":x(a)?a:void 0,"aria-valuetext":f,role:"progressbar","data-state":C(a,t),"data-value":a??void 0,"data-max":t,...i,ref:r})})});$.displayName=P;var j="ProgressIndicator",w=l.forwardRef((e,r)=>{const{__scopeProgress:o,...s}=e,n=L(j,o);return c.jsx(_.div,{"data-state":C(n.value,n.max),"data-value":n.value??void 0,"data-max":n.max,...s,ref:r})});w.displayName=j;function k(e,r){return`${Math.round(e/r*100)}%`}function C(e,r){return e==null?"indeterminate":e===r?"complete":"loading"}function x(e){return typeof e=="number"}function h(e){return x(e)&&!isNaN(e)&&e>0}function y(e,r){return x(e)&&!isNaN(e)&&e<=r&&e>=0}function G(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${b}\`.`}function X(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 ${b} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var z=$,B=w;function F({className:e,value:r,children:o,...s}){return c.jsxs(z,{"data-slot":"progress",className:E.cn("bg-primary/20 relative h-3 w-full overflow-hidden rounded-full",e),...s,children:[c.jsx(B,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(r||0)}%)`}}),c.jsx("div",{className:"text-body-2xs-semi-bold text-inverted absolute top-0 left-1 leading-3.5",children:o})]})}exports.Progress=F; //# sourceMappingURL=index.cjs.js.map