@jamsrui/button 0.0.12 → 0.0.14

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.
@@ -0,0 +1,34 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { PropGetter, UIProps } from '@jamsrui/utils';
3
+ import { ButtonVariantProps } from './styles.mjs';
4
+
5
+ declare const useButton: (props: useButton.Props) => {
6
+ getButtonProps: PropGetter<ButtonRoot.Props>;
7
+ isLoading: boolean;
8
+ };
9
+ declare namespace useButton {
10
+ interface VariantProps extends ButtonRoot.VariantProps {
11
+ }
12
+ interface Props extends VariantProps, UIProps<"button"> {
13
+ /**
14
+ * If `true`, the button will show a spinner and be non-interactive.
15
+ * Useful for indicating a loading state during async operations.
16
+ */
17
+ isLoading?: boolean;
18
+ /**
19
+ * If `true`, disables all animations on the button.
20
+ * Useful for performance-sensitive environments or reduced motion settings.
21
+ */
22
+ disableAnimation?: boolean;
23
+ }
24
+ }
25
+
26
+ declare const ButtonRoot: (props: ButtonRoot.Props) => react_jsx_runtime.JSX.Element;
27
+ declare namespace ButtonRoot {
28
+ interface VariantProps extends ButtonVariantProps {
29
+ }
30
+ interface Props extends useButton.Props {
31
+ }
32
+ }
33
+
34
+ export { ButtonRoot as B, useButton as u };
@@ -1,7 +1,6 @@
1
- import { B as Button } from './button-B-pIo-1o.mjs';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
2
  import { GlobalConfigProps } from '@jamsrui/core';
4
- import 'react';
3
+ import { B as ButtonRoot } from './button-BmD5-D8o.mjs';
5
4
  import '@jamsrui/utils';
6
5
  import './styles.mjs';
7
6
 
@@ -11,7 +10,7 @@ declare const ButtonConfig: (props: Omit<Partial<ButtonConfig.Props>, "children"
11
10
  children: React.ReactNode;
12
11
  }) => react_jsx_runtime.JSX.Element;
13
12
  declare namespace ButtonConfig {
14
- interface Props extends Button.Props, GlobalConfigProps<Button.Props> {
13
+ interface Props extends ButtonRoot.Props, GlobalConfigProps<ButtonRoot.Props> {
15
14
  }
16
15
  }
17
16
 
@@ -1 +1 @@
1
- import{a,b}from"./chunk-YO2JOETJ.mjs";export{a as ButtonConfig,b as useButtonConfig};
1
+ "use client";import{createConfigContext as o}from"@jamsrui/utils";const[n,e]=o({displayName:"ButtonConfigContext"});export{n as ButtonConfig,e as useButtonConfig};
@@ -0,0 +1,14 @@
1
+ import * as react from 'react';
2
+ import { u as useButton } from './button-BmD5-D8o.mjs';
3
+ import 'react/jsx-runtime';
4
+ import '@jamsrui/utils';
5
+ import './styles.mjs';
6
+
7
+ declare const useButtonContext: () => ButtonContext.Props;
8
+ declare const ButtonContext: react.Context<ButtonContext.Props | null>;
9
+ declare namespace ButtonContext {
10
+ interface Props extends ReturnType<typeof useButton> {
11
+ }
12
+ }
13
+
14
+ export { ButtonContext, useButtonContext };
@@ -0,0 +1 @@
1
+ "use client";import{createContext as e,use as o}from"react";const n=e(null),x=()=>{const t=o(n);if(!t)throw new Error("useButtonContext must be used within a ButtonContext");return t};export{n as ButtonContext,x as useButtonContext};
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare const ButtonLoading: (props: ButtonLoading.Props) => react_jsx_runtime.JSX.Element;
4
+ declare namespace ButtonLoading {
5
+ interface Props {
6
+ children?: React.ReactNode;
7
+ }
8
+ }
9
+
10
+ export { ButtonLoading };
@@ -0,0 +1 @@
1
+ "use client";import{jsx as o}from"react/jsx-runtime";import{useButtonContext as a}from"./button-context.mjs";import{LoadingSpinner as i}from"./spinner.mjs";const p=t=>{const{children:e=o(i,{})}=t,{isLoading:n}=a();return o("span",{className:n?"":"hidden",children:n?e:null})};export{p as ButtonLoading};
package/dist/button.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import 'react';
2
- export { B as Button } from './button-B-pIo-1o.mjs';
1
+ import 'react/jsx-runtime';
2
+ export { B as ButtonRoot } from './button-BmD5-D8o.mjs';
3
3
  import './styles.mjs';
4
4
  import '@jamsrui/utils';
package/dist/button.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-72WBLLXF.mjs";import"./chunk-YO2JOETJ.mjs";import"./chunk-642ZKQLN.mjs";import"./chunk-ESS3M7QC.mjs";import"./chunk-JWKZTEGE.mjs";export{a as Button};
1
+ "use client";import{jsx as f}from"react/jsx-runtime";import{useRenderElement as p}from"@jamsrui/hooks";import{mergeConfigProps as u}from"@jamsrui/utils";import{useButtonConfig as i}from"./button-config.mjs";import{buttonVariant as m}from"./styles.mjs";import{useButton as a}from"./use-button.mjs";import{ButtonContext as c}from"./button-context.mjs";const V=t=>{const n=i(),r=u(m.defaultVariants,n,t),o=a(r),{getButtonProps:e}=o,s=p("button",{props:[e({}),{children:t.children}]});return f(c,{value:o,children:s})};export{V as ButtonRoot};
package/dist/index.d.mts CHANGED
@@ -1,7 +1,18 @@
1
- export { B as Button } from './button-B-pIo-1o.mjs';
2
- export { ButtonConfig, useButtonConfig } from './button-config.mjs';
3
- import 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { B as ButtonRoot } from './button-BmD5-D8o.mjs';
3
+ import { ButtonConfig } from './button-config.mjs';
4
+ export { useButtonConfig } from './button-config.mjs';
5
+ import { ButtonLoading } from './button-loading.mjs';
4
6
  import '@jamsrui/utils';
5
7
  import './styles.mjs';
6
- import 'react/jsx-runtime';
7
8
  import '@jamsrui/core';
9
+
10
+ declare const Button: ((props: ButtonRoot.Props) => react_jsx_runtime.JSX.Element) & {
11
+ Config: (props: Omit<Partial<ButtonConfig.Props>, "children"> & {
12
+ merge?: boolean;
13
+ children: React.ReactNode;
14
+ }) => react_jsx_runtime.JSX.Element;
15
+ Loading: (props: ButtonLoading.Props) => react_jsx_runtime.JSX.Element;
16
+ };
17
+
18
+ export { Button, ButtonConfig };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- "use client";import{a as n}from"./chunk-72WBLLXF.mjs";import{a as o,b as t}from"./chunk-YO2JOETJ.mjs";import"./chunk-642ZKQLN.mjs";import"./chunk-ESS3M7QC.mjs";import"./chunk-JWKZTEGE.mjs";export{n as Button,o as ButtonConfig,t as useButtonConfig};
1
+ import{ButtonRoot as o}from"./button.mjs";import{ButtonConfig as t}from"./button-config.mjs";import{ButtonLoading as n}from"./button-loading.mjs";import{ButtonConfig as B,useButtonConfig as p}from"./button-config.mjs";const g=Object.assign(o,{Config:t,Loading:n});export{g as Button,B as ButtonConfig,p as useButtonConfig};
package/dist/spinner.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-642ZKQLN.mjs";export{a as LoadingSpinner};
1
+ import{jsx as t,jsxs as i}from"react/jsx-runtime";const o=e=>{const{size:r=20}=e;return t("svg",{fill:"currentColor",height:r,viewBox:"0 0 24 24",width:r,xmlns:"http://www.w3.org/2000/svg",children:i("g",{children:[t("rect",{height:5,opacity:".14",width:2,x:11,y:1}),t("rect",{height:5,opacity:".29",transform:"rotate(30 12 12)",width:2,x:11,y:1}),t("rect",{height:5,opacity:".43",transform:"rotate(60 12 12)",width:2,x:11,y:1}),t("rect",{height:5,opacity:".57",transform:"rotate(90 12 12)",width:2,x:11,y:1}),t("rect",{height:5,opacity:".71",transform:"rotate(120 12 12)",width:2,x:11,y:1}),t("rect",{height:5,opacity:".86",transform:"rotate(150 12 12)",width:2,x:11,y:1}),t("rect",{height:5,transform:"rotate(180 12 12)",width:2,x:11,y:1}),t("animateTransform",{attributeName:"transform",calcMode:"discrete",dur:"0.75s",repeatCount:"indefinite",type:"rotate",values:"0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12;360 12 12"})]})})};export{o as LoadingSpinner};
package/dist/styles.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-JWKZTEGE.mjs";export{a as buttonVariant};
1
+ import{allColors as i,allVariants as s,colorVariants as e,radiusBaseVariant as n,tv as o}from"@jamsrui/utils";const l=o({base:["button relative inline-flex py-2 px-4 rounded-full justify-center items-center gap-2 shrink-0","data-loading:cursor-progress","disabled:cursor-not-allowed disabled:opacity-70","focus-visible:outline-2 focus-visible:outline-primary focus-visible:outline-offset-2"],variants:{color:{default:"button--default",primary:"button--primary",secondary:"button--secondary",success:"button--success",warning:"button--warning",danger:"button--danger"},variant:{solid:"button--solid ring-1 ring-inset",bordered:"button--bordered border",light:"button--light",text:"button--text",flat:"button--flat"},isFullWidth:{true:"w-full"},size:{xs:"button--xs px-2 py-1 text-xs",sm:"button--sm min-w-16 gap-1 px-3 py-1.5 text-xs",md:"button--md min-w-20 gap-2 px-4 py-1.5 text-sm",lg:"button--lg min-w-30 gap-2 px-5 py-1.5 text-base"},radius:n,disableAnimation:{true:"",false:"transition-[scale] duration-300 data-pressed:scale-98"}},compoundVariants:[...s.flatMap(t=>i.map(a=>({variant:t,color:a,className:e[t][a]})))],defaultVariants:{variant:"solid",color:"default",size:"md",radius:"md",disableAnimation:!1,isFullWidth:!1}});export{l as buttonVariant};
@@ -1,4 +1,4 @@
1
- import 'react';
2
1
  import '@jamsrui/utils';
3
- export { u as useButton } from './button-B-pIo-1o.mjs';
2
+ export { u as useButton } from './button-BmD5-D8o.mjs';
3
+ import 'react/jsx-runtime';
4
4
  import './styles.mjs';
@@ -1 +1 @@
1
- import{a}from"./chunk-ESS3M7QC.mjs";import"./chunk-JWKZTEGE.mjs";export{a as useButton};
1
+ import{useCallback as R,useMemo as g}from"react";import{useHover as v,useMergeRefs as x,usePress as y}from"@jamsrui/hooks";import{cn as V,dataAttr as o,mapPropsVariants as h}from"@jamsrui/utils";import{buttonVariant as u}from"./styles.mjs";const K=d=>{const[f,c]=h(d,u.variantKeys),{disabled:l=!1,isLoading:t=!1,className:s,ref:P,...r}=f,e=l||t,a=u(c),{isHovered:n,ref:b}=v({isDisabled:e}),{isPressed:i,ref:B}=y({isDisabled:e}),p=x([P,b,B]),m=R(()=>({...r,ref:p,disabled:e,className:V(a,s),"data-loading":o(t),"data-pressed":o(i),"data-hover":o(n)}),[s,e,n,t,i,p,r,a]);return g(()=>({getButtonProps:m,isLoading:t}),[m,t])};export{K as useButton};
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jamsrui/button",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "peerDependencies": {
5
5
  "react": ">=19",
6
6
  "react-dom": ">=19"
7
7
  },
8
8
  "dependencies": {
9
- "@jamsrui/core": "^0.0.10",
10
- "@jamsrui/utils": "^0.0.12",
11
- "@jamsrui/hooks": "^0.0.12"
9
+ "@jamsrui/hooks": "^0.0.14",
10
+ "@jamsrui/core": "^0.0.12",
11
+ "@jamsrui/utils": "^0.0.14"
12
12
  },
13
13
  "exports": {
14
14
  ".": {
@@ -1,68 +0,0 @@
1
- import * as react from 'react';
2
- import { PropGetter, UIProps } from '@jamsrui/utils';
3
- import { ButtonVariantProps } from './styles.mjs';
4
-
5
- declare const useButton: (props: useButton.Props) => {
6
- getButtonProps: PropGetter<Button.Props>;
7
- startContent: react.ReactNode;
8
- endContent: react.ReactNode;
9
- isLoading: boolean;
10
- spinner: react.ReactNode;
11
- spinnerPlacement: "start" | "end";
12
- disableRipple: boolean | undefined;
13
- };
14
- declare namespace useButton {
15
- interface VariantProps extends Button.VariantProps {
16
- }
17
- interface Props extends VariantProps, UIProps<"button"> {
18
- /**
19
- * If `true`, the button will show a spinner and be non-interactive.
20
- * Useful for indicating a loading state during async operations.
21
- */
22
- isLoading?: boolean;
23
- /**
24
- * If `true`, the button will be disabled.
25
- * Takes precedence over `isLoading`.
26
- */
27
- isDisabled?: boolean;
28
- /**
29
- * Element to be rendered at the **start** of the button content.
30
- * Commonly used for icons or prepended text.
31
- */
32
- startContent?: React.ReactNode;
33
- /**
34
- * Element to be rendered at the **end** of the button content.
35
- * Commonly used for icons or appended text.
36
- */
37
- endContent?: React.ReactNode;
38
- /**
39
- * Determines where the spinner appears when `isLoading` is true.
40
- * Can be `"start"` or `"end"`. Defaults to `"start"`.
41
- */
42
- spinnerPlacement?: "start" | "end";
43
- /**
44
- * If `true`, disables the ripple effect on click.
45
- * Recommended for a more minimal or static UI feel.
46
- */
47
- disableRipple?: boolean;
48
- /**
49
- * If `true`, disables all animations on the button.
50
- * Useful for performance-sensitive environments or reduced motion settings.
51
- */
52
- disableAnimation?: boolean;
53
- /**
54
- * A custom spinner element to replace the default loading indicator.
55
- */
56
- spinner?: React.ReactNode;
57
- }
58
- }
59
-
60
- declare const Button: (props: Button.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
61
- declare namespace Button {
62
- interface VariantProps extends ButtonVariantProps {
63
- }
64
- interface Props extends useButton.Props {
65
- }
66
- }
67
-
68
- export { Button as B, useButton as u };
@@ -1 +0,0 @@
1
- import{jsx as t,jsxs as i}from"react/jsx-runtime";var o=e=>{let{size:r=20}=e;return t("svg",{fill:"currentColor",height:r,viewBox:"0 0 24 24",width:r,xmlns:"http://www.w3.org/2000/svg",children:i("g",{children:[t("rect",{height:5,opacity:".14",width:2,x:11,y:1}),t("rect",{height:5,opacity:".29",transform:"rotate(30 12 12)",width:2,x:11,y:1}),t("rect",{height:5,opacity:".43",transform:"rotate(60 12 12)",width:2,x:11,y:1}),t("rect",{height:5,opacity:".57",transform:"rotate(90 12 12)",width:2,x:11,y:1}),t("rect",{height:5,opacity:".71",transform:"rotate(120 12 12)",width:2,x:11,y:1}),t("rect",{height:5,opacity:".86",transform:"rotate(150 12 12)",width:2,x:11,y:1}),t("rect",{height:5,transform:"rotate(180 12 12)",width:2,x:11,y:1}),t("animateTransform",{attributeName:"transform",calcMode:"discrete",dur:"0.75s",repeatCount:"indefinite",type:"rotate",values:"0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12;360 12 12"})]})})};export{o as a};
@@ -1 +0,0 @@
1
- import{b as s}from"./chunk-YO2JOETJ.mjs";import{a as i}from"./chunk-642ZKQLN.mjs";import{a}from"./chunk-ESS3M7QC.mjs";import{a as p}from"./chunk-JWKZTEGE.mjs";import{useRenderElement as l}from"@jamsrui/hooks";import{mergeConfigProps as B}from"@jamsrui/utils";import{Fragment as x,jsx as g,jsxs as b}from"react/jsx-runtime";var S=t=>{let m=s(),o=B(p.defaultVariants,m,t),{size:u}=o,{getButtonProps:c,startContent:d,endContent:f,isLoading:n,spinner:e=g(i,{size:u==="xs"?14:20}),disableRipple:C,spinnerPlacement:r}=a(o),P=b(x,{children:[n&&r==="start"?e:d,t.children,n&&r==="end"?e:f]});return l("button",{props:[c({}),{children:P}]})};export{S as a};
@@ -1 +0,0 @@
1
- import{a as s}from"./chunk-JWKZTEGE.mjs";import{useCallback as N,useMemo as V}from"react";import{useHover as D,useMergeRefs as h,usePress as A}from"@jamsrui/hooks";import{cn as G,dataAttr as o,mapPropsVariants as H}from"@jamsrui/utils";var U=b=>{let[R,B]=H(b,s.variantKeys),{isDisabled:g=!1,disableRipple:r,endContent:a,spinner:n,spinnerPlacement:i="start",startContent:p,disabled:v=!1,isLoading:e=!1,className:d,ref:x,...l}=R,t=v||g||e,c=s(B),{isHovered:m,ref:y}=D({isDisabled:t}),{isPressed:u,ref:C}=A({isDisabled:t}),f=h([x,y,C]),P=N(()=>({...l,ref:f,disabled:t,className:G(c,d),"data-loading":o(e),"data-pressed":o(u),"data-hover":o(m)}),[d,t,m,e,u,f,l,c]);return V(()=>({getButtonProps:P,startContent:p,endContent:a,isLoading:e,spinner:n,spinnerPlacement:i,disableRipple:r}),[P,p,a,e,n,i,r])};export{U as a};
@@ -1 +0,0 @@
1
- import{allColors as i,allVariants as s,colorVariants as e,radiusBaseVariant as n,tv as o}from"@jamsrui/utils";var l=o({base:["button relative inline-flex py-2 px-4 rounded-full justify-center items-center gap-2 shrink-0","data-loading:cursor-progress","disabled:cursor-not-allowed disabled:opacity-70","focus-visible:outline-2 focus-visible:outline-primary focus-visible:outline-offset-2"],variants:{color:{default:"button--default",primary:"button--primary",secondary:"button--secondary",success:"button--success",warning:"button--warning",danger:"button--danger"},variant:{solid:"button--solid ring-1 ring-inset",bordered:"button--bordered border",light:"button--light",text:"button--text",flat:"button--flat"},isFullWidth:{true:"w-full"},size:{xs:"button--xs px-2 py-1 text-xs",sm:"button--sm min-w-16 gap-1 px-3 py-1.5 text-xs",md:"button--md min-w-20 gap-2 px-4 py-1.5 text-sm",lg:"button--lg min-w-30 gap-2 px-5 py-1.5 text-base"},radius:n,disableAnimation:{true:"",false:"transition-[scale] duration-300 data-pressed:scale-98"}},compoundVariants:[...s.flatMap(t=>i.map(a=>({variant:t,color:a,className:e[t][a]})))],defaultVariants:{variant:"solid",color:"default",size:"md",radius:"md",disableAnimation:!1,isFullWidth:!1}});export{l as a};
@@ -1 +0,0 @@
1
- import{createConfigContext as o}from"@jamsrui/utils";var[n,r]=o({displayName:"ButtonConfigContext"});export{n as a,r as b};