@xjur-ui/react 4.0.2 → 4.0.3

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
@@ -1,5 +1,11 @@
1
1
  # @xjur-ui/react
2
2
 
3
+ ## 4.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 43f43fc: Correção da mudança de Step controlada no componente de Steps
8
+
3
9
  ## 4.0.2
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- import{twMerge as V}from"@xjur-ui/util";import{createContext as z,useCallback as u,useContext as L,useMemo as y,useState as M}from"react";import{jsx as h}from"react/jsx-runtime";var S=z({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function P({steps:e,currentStepIndex:a=0,onStepChange:r,children:o,className:n,...p}){let[t,s]=M(a),i=u(c=>{s(c),r?.(c)},[r]),d=u(()=>{t!==e.length-1&&(s(B=>B+1),r?.(t+1))},[t,r,e]),g=u(()=>{t!==0&&(s(c=>c-1),r?.(t-1))},[t,r]),x=y(()=>t===e.length-1,[t,e]),f=y(()=>({steps:e,currentStepIndex:t,isLastStep:x,setCurrentStepIndex:s,handleStepChange:i,handleNextStep:d,handlePreviousStep:g}),[e,t,x,s,i,d,g]);return h(S.Provider,{value:f,children:h("div",{className:V("h-full w-full",n),"data-slot":"steps-root",...p,children:typeof o=="function"?o(f):o})})}function l(){let e=L(S);if(!e)throw new Error("useSteps must be used within a StepsContext.Provider");return e}import{jsx as I}from"react/jsx-runtime";function U({className:e,...a}){return I(P,{className:e,...a})}import{Fragment as k,useCallback as C}from"react";import{twMerge as v}from"@xjur-ui/util";import{jsx as m,jsxs as N}from"react/jsx-runtime";function ee({className:e,...a}){let{steps:r,currentStepIndex:o}=l(),n=C(t=>t===r.length-1,[r]),p=C(t=>{let s=t===o;return t<o?"disabled":s?"active":"normal"},[o]);return m("div",{className:v("gap-small flex items-center",e),"data-slot":"steps-navigation",...a,children:r.map((t,s)=>{let i=p(s);return N(k,{children:[N("div",{className:"group gap-small flex items-center","data-disabled":i==="disabled","data-slot":"step-trigger","data-state":i,...a,children:[m("div",{className:v("size-large-4x rounded-circle border-border-layer-2 text-size-label-sm bg-layer-2-idle flex items-center justify-center border","group-data-[state=active]:border-primary-active group-data-[state=active]:bg-primary-alt-active group-data-[state=active]:text-primary-label-active","group-data-[state=disabled]:bg-layer-1-idle group-data-[state=disabled]:border-border-layer-2 group-data-[state=disabled]:text-neutral-light"),"data-slot":"step-number",children:s+1}),m("span",{className:"text-size-label-sm group-data-[state=active]:text-primary-label-active group-data-[state=disabled]:text-neutral-light font-medium","data-slot":"step-title",children:t})]}),!n(s)&&m("div",{className:v("bg-border-layer-2 mx-2 h-px flex-1",e)})]},`${t}-${s}`)})})}import{twMerge as E}from"@xjur-ui/util";import{jsx as T}from"react/jsx-runtime";function oe({className:e,...a}){return T("div",{className:E("h-full w-full",e),"data-slot":"steps-content",...a})}import{twMerge as _}from"@xjur-ui/util";import{jsx as A}from"react/jsx-runtime";function le({stepIndex:e,className:a,...r}){let{currentStepIndex:o}=l();return o!==e?null:A("div",{className:_("h-full w-full",a),"data-slot":"step-item",...r})}import{useCallback as w}from"react";import{Slot as D}from"@radix-ui/react-slot";import{cva as F,cx as H}from"@xjur-ui/util";import{jsx as $}from"react/jsx-runtime";var O=F(["outline-none inline-flex items-center justify-center rounded-circle gap-small cursor-pointer disabled:opacity-38 disabled:pointer-events-none transition-colors"],{variants:{size:{md:"py-small_1x-alt px-medium text-size-body-md",sm:"py-small-1x px-small text-size-label-sm",icon_md:"p-small text-size-body-md h-large-4x w-large-4x",icon_sm:"p-small-1x text-size-label-sm h-large-2x w-large-2x"},variant:{primary:"",secondary:"",tertiary:"",destructive:"",outlined:"bg-layer-2-idle border border-border-layer-2 hover:bg-layer-2-hover active:bg-layer-2-pressed"},appearance:{solid:"",ghost:"bg-transparent"}},compoundVariants:[{variant:"primary",appearance:"solid",class:"bg-primary-idle text-neutral-label hover:bg-primary-hover active:bg-primary-pressed"},{variant:"primary",appearance:"ghost",class:"text-primary-idle hover:bg-primary-alt-idle active:bg-primary-alt-pressed"},{variant:"secondary",appearance:"solid",class:"bg-layer-1-hover text-neutral-dark hover:bg-layer-1-pressed active:bg-layer-1-active"},{variant:"secondary",appearance:"ghost",class:"hover:bg-layer-1-hover active:bg-layer-1-pressed"},{variant:"tertiary",appearance:"solid",class:"bg-layer-2-hover text-neutral-dark hover:bg-layer-2-pressed active:bg-layer-2-active"},{variant:"tertiary",appearance:"ghost",class:"hover:bg-layer-2-hover active:bg-layer-2-pressed"},{variant:"destructive",appearance:"solid",class:"bg-danger-idle text-neutral-label hover:bg-danger-hover active:bg-danger-pressed"},{variant:"destructive",appearance:"ghost",class:"text-danger-label-idle hover:bg-danger-alt-idle active:bg-danger-alt-pressed"}],defaultVariants:{size:"md",variant:"primary",appearance:"solid"}});function b({asChild:e,className:a,variant:r="primary",size:o="md",appearance:n="solid",...p}){return $(e?D:"button",{className:H(O({variant:r,appearance:n,size:o}),a),...p})}import{jsx as R}from"react/jsx-runtime";function ye({children:e="Pr\xF3ximo",type:a,onClick:r,...o}){let{handleNextStep:n,currentStepIndex:p,isLastStep:t}=l(),s=w(d=>{r?r(d):(d.preventDefault(),n())},[r,n]),i=a||(t?"submit":"button");return R(b,{type:i,...i==="button"?{onClick:s}:{},...o,children:typeof e=="function"?e(p):e})}function he({appearance:e="ghost",children:a="Anterior",onClick:r,...o}){let{handlePreviousStep:n}=l(),p=w(t=>{r?r(t):(t.preventDefault(),n())},[r,n]);return R(b,{appearance:e,onClick:p,...o,children:a})}export{ye as NextStep,he as PreviousStep,le as Step,oe as Steps,S as StepsContext,ee as StepsNavigation,P as StepsProvider,U as StepsRoot,l as useSteps};
1
+ import{twMerge as V}from"@xjur-ui/util";import{createContext as z,useCallback as u,useContext as L,useEffect as M,useMemo as y,useState as k}from"react";import{jsx as h}from"react/jsx-runtime";var S=z({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function C({steps:e,currentStepIndex:a=0,onStepChange:r,children:o,className:n,...i}){let[t,s]=k(a),p=u(c=>{s(c),r?.(c)},[r]),d=u(()=>{t!==e.length-1&&(s(B=>B+1),r?.(t+1))},[t,r,e]),g=u(()=>{t!==0&&(s(c=>c-1),r?.(t-1))},[t,r]),f=y(()=>t===e.length-1,[t,e]),x=y(()=>({steps:e,currentStepIndex:t,isLastStep:f,setCurrentStepIndex:s,handleStepChange:p,handleNextStep:d,handlePreviousStep:g}),[e,t,f,s,p,d,g]);return M(()=>{s(a)},[a]),h(S.Provider,{value:x,children:h("div",{className:V("h-full w-full",n),"data-slot":"steps-root",...i,children:typeof o=="function"?o(x):o})})}function l(){let e=L(S);if(!e)throw new Error("useSteps must be used within a StepsContext.Provider");return e}import{jsx as E}from"react/jsx-runtime";function W({className:e,...a}){return E(C,{className:e,...a})}import{Fragment as I,useCallback as P}from"react";import{twMerge as v}from"@xjur-ui/util";import{jsx as m,jsxs as N}from"react/jsx-runtime";function te({className:e,...a}){let{steps:r,currentStepIndex:o}=l(),n=P(t=>t===r.length-1,[r]),i=P(t=>{let s=t===o;return t<o?"disabled":s?"active":"normal"},[o]);return m("div",{className:v("gap-small flex items-center",e),"data-slot":"steps-navigation",...a,children:r.map((t,s)=>{let p=i(s);return N(I,{children:[N("div",{className:"group gap-small flex items-center","data-disabled":p==="disabled","data-slot":"step-trigger","data-state":p,...a,children:[m("div",{className:v("size-large-4x rounded-circle border-border-layer-2 text-size-label-sm bg-layer-2-idle flex items-center justify-center border","group-data-[state=active]:border-primary-active group-data-[state=active]:bg-primary-alt-active group-data-[state=active]:text-primary-label-active","group-data-[state=disabled]:bg-layer-1-idle group-data-[state=disabled]:border-border-layer-2 group-data-[state=disabled]:text-neutral-light"),"data-slot":"step-number",children:s+1}),m("span",{className:"text-size-label-sm group-data-[state=active]:text-primary-label-active group-data-[state=disabled]:text-neutral-light font-medium","data-slot":"step-title",children:t})]}),!n(s)&&m("div",{className:v("bg-border-layer-2 mx-2 h-px flex-1",e)})]},`${t}-${s}`)})})}import{twMerge as T}from"@xjur-ui/util";import{jsx as _}from"react/jsx-runtime";function se({className:e,...a}){return _("div",{className:T("h-full w-full",e),"data-slot":"steps-content",...a})}import{twMerge as A}from"@xjur-ui/util";import{jsx as D}from"react/jsx-runtime";function de({stepIndex:e,className:a,...r}){let{currentStepIndex:o}=l();return o!==e?null:D("div",{className:A("h-full w-full",a),"data-slot":"step-item",...r})}import{useCallback as w}from"react";import{Slot as F}from"@radix-ui/react-slot";import{cva as H,cx as O}from"@xjur-ui/util";import{jsx as q}from"react/jsx-runtime";var $=H(["outline-none inline-flex items-center justify-center rounded-circle gap-small cursor-pointer disabled:opacity-38 disabled:pointer-events-none transition-colors"],{variants:{size:{md:"py-small_1x-alt px-medium text-size-body-md",sm:"py-small-1x px-small text-size-label-sm",icon_md:"p-small text-size-body-md h-large-4x w-large-4x",icon_sm:"p-small-1x text-size-label-sm h-large-2x w-large-2x"},variant:{primary:"",secondary:"",tertiary:"",destructive:"",outlined:"bg-layer-2-idle border border-border-layer-2 hover:bg-layer-2-hover active:bg-layer-2-pressed"},appearance:{solid:"",ghost:"bg-transparent"}},compoundVariants:[{variant:"primary",appearance:"solid",class:"bg-primary-idle text-neutral-label hover:bg-primary-hover active:bg-primary-pressed"},{variant:"primary",appearance:"ghost",class:"text-primary-idle hover:bg-primary-alt-idle active:bg-primary-alt-pressed"},{variant:"secondary",appearance:"solid",class:"bg-layer-1-hover text-neutral-dark hover:bg-layer-1-pressed active:bg-layer-1-active"},{variant:"secondary",appearance:"ghost",class:"hover:bg-layer-1-hover active:bg-layer-1-pressed"},{variant:"tertiary",appearance:"solid",class:"bg-layer-2-hover text-neutral-dark hover:bg-layer-2-pressed active:bg-layer-2-active"},{variant:"tertiary",appearance:"ghost",class:"hover:bg-layer-2-hover active:bg-layer-2-pressed"},{variant:"destructive",appearance:"solid",class:"bg-danger-idle text-neutral-label hover:bg-danger-hover active:bg-danger-pressed"},{variant:"destructive",appearance:"ghost",class:"text-danger-label-idle hover:bg-danger-alt-idle active:bg-danger-alt-pressed"}],defaultVariants:{size:"md",variant:"primary",appearance:"solid"}});function b({asChild:e,className:a,variant:r="primary",size:o="md",appearance:n="solid",...i}){return q(e?F:"button",{className:O($({variant:r,appearance:n,size:o}),a),...i})}import{jsx as R}from"react/jsx-runtime";function he({children:e="Pr\xF3ximo",type:a,onClick:r,...o}){let{handleNextStep:n,currentStepIndex:i,isLastStep:t}=l(),s=w(d=>{r?r(d):(d.preventDefault(),n())},[r,n]),p=a||(t?"submit":"button");return R(b,{type:p,...p==="button"?{onClick:s}:{},...o,children:typeof e=="function"?e(i):e})}function Se({appearance:e="ghost",children:a="Anterior",onClick:r,...o}){let{handlePreviousStep:n}=l(),i=w(t=>{r?r(t):(t.preventDefault(),n())},[r,n]);return R(b,{appearance:e,onClick:i,...o,children:a})}export{he as NextStep,Se as PreviousStep,de as Step,se as Steps,S as StepsContext,te as StepsNavigation,C as StepsProvider,W as StepsRoot,l as useSteps};
@@ -1 +1 @@
1
- import{twMerge as i}from"@xjur-ui/util";import{twMerge as l}from"@xjur-ui/util";import{createContext as s,useCallback as S,useContext as p,useMemo as x,useState as m}from"react";import{jsx as v}from"react/jsx-runtime";var u=s({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function t(){let e=p(u);if(!e)throw new Error("useSteps must be used within a StepsContext.Provider");return e}import{jsx as a}from"react/jsx-runtime";function b({stepIndex:e,className:n,...r}){let{currentStepIndex:o}=t();return o!==e?null:a("div",{className:i("h-full w-full",n),"data-slot":"step-item",...r})}export{b as Step};
1
+ import{twMerge as i}from"@xjur-ui/util";import{twMerge as l}from"@xjur-ui/util";import{createContext as s,useCallback as S,useContext as p,useEffect as m,useMemo as x,useState as f}from"react";import{jsx as h}from"react/jsx-runtime";var u=s({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function t(){let e=p(u);if(!e)throw new Error("useSteps must be used within a StepsContext.Provider");return e}import{jsx as a}from"react/jsx-runtime";function w({stepIndex:e,className:n,...o}){let{currentStepIndex:r}=t();return r!==e?null:a("div",{className:i("h-full w-full",n),"data-slot":"step-item",...o})}export{w as Step};
@@ -1 +1 @@
1
- import{useCallback as c}from"react";import{Slot as v}from"@radix-ui/react-slot";import{cva as b,cx as x}from"@xjur-ui/util";import{jsx as g}from"react/jsx-runtime";var y=b(["outline-none inline-flex items-center justify-center rounded-circle gap-small cursor-pointer disabled:opacity-38 disabled:pointer-events-none transition-colors"],{variants:{size:{md:"py-small_1x-alt px-medium text-size-body-md",sm:"py-small-1x px-small text-size-label-sm",icon_md:"p-small text-size-body-md h-large-4x w-large-4x",icon_sm:"p-small-1x text-size-label-sm h-large-2x w-large-2x"},variant:{primary:"",secondary:"",tertiary:"",destructive:"",outlined:"bg-layer-2-idle border border-border-layer-2 hover:bg-layer-2-hover active:bg-layer-2-pressed"},appearance:{solid:"",ghost:"bg-transparent"}},compoundVariants:[{variant:"primary",appearance:"solid",class:"bg-primary-idle text-neutral-label hover:bg-primary-hover active:bg-primary-pressed"},{variant:"primary",appearance:"ghost",class:"text-primary-idle hover:bg-primary-alt-idle active:bg-primary-alt-pressed"},{variant:"secondary",appearance:"solid",class:"bg-layer-1-hover text-neutral-dark hover:bg-layer-1-pressed active:bg-layer-1-active"},{variant:"secondary",appearance:"ghost",class:"hover:bg-layer-1-hover active:bg-layer-1-pressed"},{variant:"tertiary",appearance:"solid",class:"bg-layer-2-hover text-neutral-dark hover:bg-layer-2-pressed active:bg-layer-2-active"},{variant:"tertiary",appearance:"ghost",class:"hover:bg-layer-2-hover active:bg-layer-2-pressed"},{variant:"destructive",appearance:"solid",class:"bg-danger-idle text-neutral-label hover:bg-danger-hover active:bg-danger-pressed"},{variant:"destructive",appearance:"ghost",class:"text-danger-label-idle hover:bg-danger-alt-idle active:bg-danger-alt-pressed"}],defaultVariants:{size:"md",variant:"primary",appearance:"solid"}});function p({asChild:e,className:a,variant:t="primary",size:o="md",appearance:r="solid",...n}){return g(e?v:"button",{className:x(y({variant:t,appearance:r,size:o}),a),...n})}import{twMerge as V}from"@xjur-ui/util";import{createContext as h,useCallback as L,useContext as f,useMemo as w,useState as z}from"react";import{jsx as E}from"react/jsx-runtime";var S=h({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function i(){let e=f(S);if(!e)throw new Error("useSteps must be used within a StepsContext.Provider");return e}import{jsx as u}from"react/jsx-runtime";function H({children:e="Pr\xF3ximo",type:a,onClick:t,...o}){let{handleNextStep:r,currentStepIndex:n,isLastStep:s}=i(),m=c(d=>{t?t(d):(d.preventDefault(),r())},[t,r]),l=a||(s?"submit":"button");return u(p,{type:l,...l==="button"?{onClick:m}:{},...o,children:typeof e=="function"?e(n):e})}function O({appearance:e="ghost",children:a="Anterior",onClick:t,...o}){let{handlePreviousStep:r}=i(),n=c(s=>{t?t(s):(s.preventDefault(),r())},[t,r]);return u(p,{appearance:e,onClick:n,...o,children:a})}export{H as NextStep,O as PreviousStep};
1
+ import{useCallback as c}from"react";import{Slot as v}from"@radix-ui/react-slot";import{cva as b,cx as x}from"@xjur-ui/util";import{jsx as g}from"react/jsx-runtime";var y=b(["outline-none inline-flex items-center justify-center rounded-circle gap-small cursor-pointer disabled:opacity-38 disabled:pointer-events-none transition-colors"],{variants:{size:{md:"py-small_1x-alt px-medium text-size-body-md",sm:"py-small-1x px-small text-size-label-sm",icon_md:"p-small text-size-body-md h-large-4x w-large-4x",icon_sm:"p-small-1x text-size-label-sm h-large-2x w-large-2x"},variant:{primary:"",secondary:"",tertiary:"",destructive:"",outlined:"bg-layer-2-idle border border-border-layer-2 hover:bg-layer-2-hover active:bg-layer-2-pressed"},appearance:{solid:"",ghost:"bg-transparent"}},compoundVariants:[{variant:"primary",appearance:"solid",class:"bg-primary-idle text-neutral-label hover:bg-primary-hover active:bg-primary-pressed"},{variant:"primary",appearance:"ghost",class:"text-primary-idle hover:bg-primary-alt-idle active:bg-primary-alt-pressed"},{variant:"secondary",appearance:"solid",class:"bg-layer-1-hover text-neutral-dark hover:bg-layer-1-pressed active:bg-layer-1-active"},{variant:"secondary",appearance:"ghost",class:"hover:bg-layer-1-hover active:bg-layer-1-pressed"},{variant:"tertiary",appearance:"solid",class:"bg-layer-2-hover text-neutral-dark hover:bg-layer-2-pressed active:bg-layer-2-active"},{variant:"tertiary",appearance:"ghost",class:"hover:bg-layer-2-hover active:bg-layer-2-pressed"},{variant:"destructive",appearance:"solid",class:"bg-danger-idle text-neutral-label hover:bg-danger-hover active:bg-danger-pressed"},{variant:"destructive",appearance:"ghost",class:"text-danger-label-idle hover:bg-danger-alt-idle active:bg-danger-alt-pressed"}],defaultVariants:{size:"md",variant:"primary",appearance:"solid"}});function i({asChild:e,className:a,variant:t="primary",size:o="md",appearance:r="solid",...n}){return g(e?v:"button",{className:x(y({variant:t,appearance:r,size:o}),a),...n})}import{twMerge as V}from"@xjur-ui/util";import{createContext as h,useCallback as w,useContext as f,useEffect as z,useMemo as E,useState as I}from"react";import{jsx as k}from"react/jsx-runtime";var S=h({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function p(){let e=f(S);if(!e)throw new Error("useSteps must be used within a StepsContext.Provider");return e}import{jsx as u}from"react/jsx-runtime";function O({children:e="Pr\xF3ximo",type:a,onClick:t,...o}){let{handleNextStep:r,currentStepIndex:n,isLastStep:s}=p(),m=c(d=>{t?t(d):(d.preventDefault(),r())},[t,r]),l=a||(s?"submit":"button");return u(i,{type:l,...l==="button"?{onClick:m}:{},...o,children:typeof e=="function"?e(n):e})}function A({appearance:e="ghost",children:a="Anterior",onClick:t,...o}){let{handlePreviousStep:r}=p(),n=c(s=>{t?t(s):(s.preventDefault(),r())},[t,r]);return u(i,{appearance:e,onClick:n,...o,children:a})}export{O as NextStep,A as PreviousStep};
@@ -1 +1 @@
1
- import{twMerge as C}from"@xjur-ui/util";import{createContext as P,useCallback as p,useContext as b,useMemo as l,useState as I}from"react";import{jsx as S}from"react/jsx-runtime";var x=P({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function L({steps:t,currentStepIndex:v=0,onStepChange:n,children:s,className:m,...f}){let[e,r]=I(v),u=p(o=>{r(o),n?.(o)},[n]),i=p(()=>{e!==t.length-1&&(r(h=>h+1),n?.(e+1))},[e,n,t]),a=p(()=>{e!==0&&(r(o=>o-1),n?.(e-1))},[e,n]),d=l(()=>e===t.length-1,[e,t]),c=l(()=>({steps:t,currentStepIndex:e,isLastStep:d,setCurrentStepIndex:r,handleStepChange:u,handleNextStep:i,handlePreviousStep:a}),[t,e,d,r,u,i,a]);return S(x.Provider,{value:c,children:S("div",{className:C("h-full w-full",m),"data-slot":"steps-root",...f,children:typeof s=="function"?s(c):s})})}function g(){let t=b(x);if(!t)throw new Error("useSteps must be used within a StepsContext.Provider");return t}export{x as StepsContext,L as StepsProvider,g as useSteps};
1
+ import{twMerge as C}from"@xjur-ui/util";import{createContext as b,useCallback as u,useContext as P,useEffect as N,useMemo as S,useState as w}from"react";import{jsx as x}from"react/jsx-runtime";var v=b({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function I({steps:t,currentStepIndex:s=0,onStepChange:n,children:i,className:f,...m}){let[e,o]=w(s),a=u(r=>{o(r),n?.(r)},[n]),p=u(()=>{e!==t.length-1&&(o(h=>h+1),n?.(e+1))},[e,n,t]),d=u(()=>{e!==0&&(o(r=>r-1),n?.(e-1))},[e,n]),l=S(()=>e===t.length-1,[e,t]),c=S(()=>({steps:t,currentStepIndex:e,isLastStep:l,setCurrentStepIndex:o,handleStepChange:a,handleNextStep:p,handlePreviousStep:d}),[t,e,l,o,a,p,d]);return N(()=>{o(s)},[s]),x(v.Provider,{value:c,children:x("div",{className:C("h-full w-full",f),"data-slot":"steps-root",...m,children:typeof i=="function"?i(c):i})})}function R(){let t=P(v);if(!t)throw new Error("useSteps must be used within a StepsContext.Provider");return t}export{v as StepsContext,I as StepsProvider,R as useSteps};
@@ -1 +1 @@
1
- import{Fragment as S,useCallback as p}from"react";import{twMerge as i}from"@xjur-ui/util";import{twMerge as f}from"@xjur-ui/util";import{createContext as v,useCallback as y,useContext as b,useMemo as C,useState as P}from"react";import{jsx as w}from"react/jsx-runtime";var x=v({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function l(){let a=b(x);if(!a)throw new Error("useSteps must be used within a StepsContext.Provider");return a}import{jsx as r,jsxs as u}from"react/jsx-runtime";function z({className:a,...d}){let{steps:s,currentStepIndex:o}=l(),c=p(e=>e===s.length-1,[s]),m=p(e=>{let t=e===o;return e<o?"disabled":t?"active":"normal"},[o]);return r("div",{className:i("gap-small flex items-center",a),"data-slot":"steps-navigation",...d,children:s.map((e,t)=>{let n=m(t);return u(S,{children:[u("div",{className:"group gap-small flex items-center","data-disabled":n==="disabled","data-slot":"step-trigger","data-state":n,...d,children:[r("div",{className:i("size-large-4x rounded-circle border-border-layer-2 text-size-label-sm bg-layer-2-idle flex items-center justify-center border","group-data-[state=active]:border-primary-active group-data-[state=active]:bg-primary-alt-active group-data-[state=active]:text-primary-label-active","group-data-[state=disabled]:bg-layer-1-idle group-data-[state=disabled]:border-border-layer-2 group-data-[state=disabled]:text-neutral-light"),"data-slot":"step-number",children:t+1}),r("span",{className:"text-size-label-sm group-data-[state=active]:text-primary-label-active group-data-[state=disabled]:text-neutral-light font-medium","data-slot":"step-title",children:e})]}),!c(t)&&r("div",{className:i("bg-border-layer-2 mx-2 h-px flex-1",a)})]},`${e}-${t}`)})})}export{z as StepsNavigation};
1
+ import{Fragment as g,useCallback as p}from"react";import{twMerge as i}from"@xjur-ui/util";import{twMerge as f}from"@xjur-ui/util";import{createContext as v,useCallback as y,useContext as b,useEffect as C,useMemo as N,useState as P}from"react";import{jsx as L}from"react/jsx-runtime";var x=v({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function l(){let a=b(x);if(!a)throw new Error("useSteps must be used within a StepsContext.Provider");return a}import{jsx as r,jsxs as u}from"react/jsx-runtime";function M({className:a,...d}){let{steps:s,currentStepIndex:o}=l(),c=p(e=>e===s.length-1,[s]),m=p(e=>{let t=e===o;return e<o?"disabled":t?"active":"normal"},[o]);return r("div",{className:i("gap-small flex items-center",a),"data-slot":"steps-navigation",...d,children:s.map((e,t)=>{let n=m(t);return u(g,{children:[u("div",{className:"group gap-small flex items-center","data-disabled":n==="disabled","data-slot":"step-trigger","data-state":n,...d,children:[r("div",{className:i("size-large-4x rounded-circle border-border-layer-2 text-size-label-sm bg-layer-2-idle flex items-center justify-center border","group-data-[state=active]:border-primary-active group-data-[state=active]:bg-primary-alt-active group-data-[state=active]:text-primary-label-active","group-data-[state=disabled]:bg-layer-1-idle group-data-[state=disabled]:border-border-layer-2 group-data-[state=disabled]:text-neutral-light"),"data-slot":"step-number",children:t+1}),r("span",{className:"text-size-label-sm group-data-[state=active]:text-primary-label-active group-data-[state=disabled]:text-neutral-light font-medium","data-slot":"step-title",children:e})]}),!c(t)&&r("div",{className:i("bg-border-layer-2 mx-2 h-px flex-1",a)})]},`${e}-${t}`)})})}export{M as StepsNavigation};
@@ -1 +1 @@
1
- import{twMerge as C}from"@xjur-ui/util";import{createContext as P,useCallback as i,useContext as R,useMemo as l,useState as b}from"react";import{jsx as x}from"react/jsx-runtime";var N=P({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function m({steps:t,currentStepIndex:s=0,onStepChange:o,children:p,className:v,...f}){let[e,n]=b(s),u=i(r=>{n(r),o?.(r)},[o]),a=i(()=>{e!==t.length-1&&(n(h=>h+1),o?.(e+1))},[e,o,t]),d=i(()=>{e!==0&&(n(r=>r-1),o?.(e-1))},[e,o]),S=l(()=>e===t.length-1,[e,t]),c=l(()=>({steps:t,currentStepIndex:e,isLastStep:S,setCurrentStepIndex:n,handleStepChange:u,handleNextStep:a,handlePreviousStep:d}),[t,e,S,n,u,a,d]);return x(N.Provider,{value:c,children:x("div",{className:C("h-full w-full",v),"data-slot":"steps-root",...f,children:typeof p=="function"?p(c):p})})}import{jsx as I}from"react/jsx-runtime";function M({className:t,...s}){return I(m,{className:t,...s})}export{M as StepsRoot};
1
+ import{twMerge as C}from"@xjur-ui/util";import{createContext as P,useCallback as i,useContext as y,useEffect as b,useMemo as S,useState as N}from"react";import{jsx as x}from"react/jsx-runtime";var w=P({steps:[],currentStepIndex:0,isLastStep:!1,handleStepChange:()=>{},handleNextStep:()=>{},handlePreviousStep:()=>{}});function m({steps:t,currentStepIndex:r=0,onStepChange:o,children:p,className:f,...v}){let[e,n]=N(r),a=i(s=>{n(s),o?.(s)},[o]),u=i(()=>{e!==t.length-1&&(n(h=>h+1),o?.(e+1))},[e,o,t]),d=i(()=>{e!==0&&(n(s=>s-1),o?.(e-1))},[e,o]),c=S(()=>e===t.length-1,[e,t]),l=S(()=>({steps:t,currentStepIndex:e,isLastStep:c,setCurrentStepIndex:n,handleStepChange:a,handleNextStep:u,handlePreviousStep:d}),[t,e,c,n,a,u,d]);return b(()=>{n(r)},[r]),x(w.Provider,{value:l,children:x("div",{className:C("h-full w-full",f),"data-slot":"steps-root",...v,children:typeof p=="function"?p(l):p})})}import{jsx as L}from"react/jsx-runtime";function M({className:t,...r}){return L(m,{className:t,...r})}export{M as StepsRoot};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xjur-ui/react",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "type": "module",
5
5
  "description": "React components for XJur Design System",
6
6
  "types": "dist/index.d.ts",