@sprocketui-react/button 1.0.0 → 1.0.1
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/README.md +19 -0
- package/dist/vue/index.cjs +1 -0
- package/dist/vue/index.d.cts +93 -0
- package/dist/vue/index.d.ts +93 -0
- package/dist/vue/index.global.js +18 -0
- package/dist/vue/index.js +1 -0
- package/package.json +40 -12
- package/LICENSE +0 -21
- package/__tests__/button.test.tsx +0 -45
- package/dist/index.d.ts +0 -67
- package/dist/index.es.js +0 -10
- package/dist/index.es.js.map +0 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +0 -1
- package/src/components/Button.tsx +0 -45
- package/src/hooks/useButton.ts +0 -195
- package/src/index.ts +0 -11
- package/src/types.ts +0 -14
- package/tsconfig.json +0 -8
package/README.md
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://sprocketui.com">
|
|
3
|
+
<img alt="Necto Logo" src="https://avatars.githubusercontent.com/u/206497492?s=100&v=4">
|
|
4
|
+
<a>
|
|
5
|
+
|
|
6
|
+
<h2>Sprocket UI React - Button</h2>
|
|
7
|
+
|
|
8
|
+
<p>Sprocket's standalone button component for React based projects.</p>
|
|
9
|
+
|
|
10
|
+
<a aria-label="Corinvo" href="https://corinvo.github.io">
|
|
11
|
+
<img src="https://img.shields.io/badge/Made%20by-Corinvo-black.svg?style=for-the-badge&color=black">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@sprocketui-react/button">
|
|
14
|
+
<img alt="NPM version" src="https://img.shields.io/npm/v/@sprocketui-react/button.svg?style=for-the-badge">
|
|
15
|
+
</a>
|
|
16
|
+
<a aria-label="License" href="https://github.com/sprocketui/NodeKit/blob/main/LICENSE">
|
|
17
|
+
<img src="https://img.shields.io/badge/License-MIT-97CA25.svg?style=for-the-badge">
|
|
18
|
+
</a>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var O=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var Z=(t,e)=>{for(var r in e)O(t,r,{get:e[r],enumerable:!0})},tt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Q(e))!Y.call(t,n)&&n!==r&&O(t,n,{get:()=>e[n],enumerable:!(i=K(e,n))||i.enumerable});return t};var et=t=>tt(O({},"__esModule",{value:!0}),t);var ot={};Z(ot,{Button:()=>C,ButtonContext:()=>p,SprocketButton:()=>C,SprocketButtonContext:()=>p,useButton:()=>B,useButtonContext:()=>w,useSprocketButton:()=>B,useSprocketButtonContext:()=>w});module.exports=et(ot);var a=require("@necto-react/hooks"),u=require("@necto/dom"),g=require("@necto/mergers"),S=require("@necto-react/helpers"),E=require("shared"),L=u.HTMLElements.Button;function B(t,e){let{rel:r,href:i,target:n,autoFocus:m,focusDisabled:d,preventFocusOnPress:k,isDisabled:o=!1,type:b=L,as:x=L,elementType:s=x||L,onClick:l,onPress:y,onPressStart:T,onPressEnd:R,onPressUp:c,onPressChange:j}=t,A;s===u.HTMLElements.Button?A={type:b,disabled:o}:A={role:"button",href:s===u.HTMLElements.A&&!o?i:void 0,target:s===u.HTMLElements.A?n:void 0,type:s===u.HTMLElements.Input?b:void 0,disabled:s===u.HTMLElements.Input?o:void 0,"aria-disabled":!o||s===u.HTMLElements.Input?void 0:o,rel:s===u.HTMLElements.A?r:void 0};let{hoverProps:V,isHovered:G}=(0,a.useHover)({...t,isDisabled:o}),{focusProps:W,isFocused:X,isFocusVisible:$}=(0,a.useFocusRing)({autoFocus:m}),{focusableProps:F}=(0,a.useFocusable)(t,e),{pressProps:q,isPressed:z}=(0,a.usePress)({ref:e,isDisabled:o,preventFocusOnPress:k,onPressStart:T,onPressEnd:R,onPressChange:j,onPress:y,onPressUp:c,onClick:l});d&&(F.tabIndex=o?-1:F.tabIndex);let J=(0,g.mergeProps)(F,q,V,W,(0,S.filterDOMProps)(t,{allowLabelableProps:!0,allowedLabelableProps:new Set([]),allowedLinkProps:new Set(E.ANCHOR_ELEMENT_PROPS),extraAllowedProps:new Set(E.ALLOWED_EXTERNAL_PROPS)}));return{isFocused:X,isPressed:z,isHovered:G,isDisabled:o,isFocusVisible:$,elementType:s,buttonProps:(0,g.mergeProps)(J,A)}}var M=require("react"),p=(0,M.createContext)(null);var U=require("react");function w(){return(0,U.useContext)(p)}var H=require("@necto/strings"),I=require("@necto/mergers"),P=require("react"),N=require("shared"),D=require("@necto-react/components");var f=require("@necto-react/hooks"),h=require("react/jsx-runtime"),_="Button";function v(t,e){[t,e]=(0,f.useContextProps)({props:t,ref:e,context:p});let{buttonProps:r,isHovered:i,isPressed:n,isFocused:m,isDisabled:d,elementType:k,isFocusVisible:o}=B(t,e),b=(0,f.useId)({defaultId:r.id}),x=(0,f.useRenderer)({...t,values:{isHovered:i,isPressed:n,isFocused:m,isFocusVisible:o,isDisabled:d},defaultClassName:(0,N.buildInternalIdentifier)({component:_}),style:l=>({...t.style instanceof Function?t.style(l):t.style})}),s=(0,P.useMemo)(()=>{let l={hover:i,focus:m,focusVisible:o,disabled:d,pressed:n},y={},T=[];for(let[R,c]of Object.entries(l))typeof c=="boolean"&&(y[`data-${(0,H.kebabCase)(R)}`]=c?"true":void 0,c&&T.push((0,H.kebabCase)(R)));return{...y,"data-sprocket-state":T.join(" ")}},[i,m,o,d,n]);return(0,h.jsx)(D.Primitive,{ref:e,as:k,...x,...(0,I.mergeProps)(r,s),id:b,slot:t.slot||void 0,children:x.children})}var C=Object.assign((0,P.forwardRef)((t,e)=>v(t,e)),{Root:(0,P.forwardRef)((t,e)=>v(t,e))});C.displayName=_;0&&(module.exports={Button,ButtonContext,SprocketButton,SprocketButtonContext,useButton,useButtonContext,useSprocketButton,useSprocketButtonContext});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ElementType, HTMLAttributes, RefObject, Context, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
import { ButtonOptions } from '@sprocketui-types/button';
|
|
3
|
+
import { RenderProps } from '@necto-react/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface UseButtonProps<T extends ElementType> extends ButtonOptions<T> {
|
|
14
|
+
elementType?: string;
|
|
15
|
+
preventFocusOnPress?: boolean;
|
|
16
|
+
href?: string;
|
|
17
|
+
target?: string;
|
|
18
|
+
rel?: string;
|
|
19
|
+
isDisabled?: boolean;
|
|
20
|
+
onClick?: (e: any) => void;
|
|
21
|
+
onPress?: (e: any) => void;
|
|
22
|
+
onPressStart?: (e: any) => void;
|
|
23
|
+
onPressEnd?: (e: any) => void;
|
|
24
|
+
onPressUp?: (e: any) => void;
|
|
25
|
+
onPressChange?: (isPressed: boolean) => void;
|
|
26
|
+
}
|
|
27
|
+
type ButtonHookReturn<T extends ElementType> = Readonly<{
|
|
28
|
+
elementType: T;
|
|
29
|
+
buttonProps: HTMLAttributes<any>;
|
|
30
|
+
isPressed: boolean;
|
|
31
|
+
isHovered: boolean;
|
|
32
|
+
isFocused: boolean;
|
|
33
|
+
isDisabled: boolean;
|
|
34
|
+
isFocusVisible: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
declare const DEFAULT_BUTTON_TAG: keyof HTMLElementTagNameMap;
|
|
38
|
+
/**
|
|
39
|
+
* React hook that provides all necessary props and state for a headless button component.
|
|
40
|
+
*
|
|
41
|
+
* @template T The element type to render as (e.g., 'button', 'a', 'input').
|
|
42
|
+
* @param {UseButtonProps<T>} props - The props for configuring the button's behavior and accessibility.
|
|
43
|
+
* @param {RefObject<any>} ref - The ref to the button element.
|
|
44
|
+
* @returns {ButtonHookReturn<T>} An object containing readonly state and props for the button element.
|
|
45
|
+
*/
|
|
46
|
+
declare function useButton<T extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: UseButtonProps<T>, ref: RefObject<any>): ButtonHookReturn<T>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
50
|
+
*
|
|
51
|
+
* This source code is licensed under the MIT license found in the
|
|
52
|
+
* LICENSE file in the root directory of this source tree.
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
declare const ButtonContext: Context<any>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
60
|
+
*
|
|
61
|
+
* This source code is licensed under the MIT license found in the
|
|
62
|
+
* LICENSE file in the root directory of this source tree.
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
declare function useButtonContext(): any;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the MIT license found in the
|
|
71
|
+
* LICENSE file in the root directory of this source tree.
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Props for the Button component.
|
|
77
|
+
*/
|
|
78
|
+
interface ButtonProps extends ButtonOptions<ElementType>, RenderProps<any>, UseButtonProps<ElementType> {
|
|
79
|
+
slot?: string | null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The public Button component for Sprocket UI.
|
|
84
|
+
*
|
|
85
|
+
* @param {ButtonProps} props - The props for the Button component.
|
|
86
|
+
* @param {ForwardedRef<HTMLButtonElement>} ref - The forwarded ref for the button element.
|
|
87
|
+
* @returns {ReactElement | null} The rendered button element or null.
|
|
88
|
+
*/
|
|
89
|
+
declare const Button: ForwardRefExoticComponent<Omit<ButtonProps, 'ref'> & RefAttributes<HTMLButtonElement>> & {
|
|
90
|
+
Root: ForwardRefExoticComponent<Omit<ButtonProps, 'ref'> & RefAttributes<HTMLButtonElement>>;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { Button, ButtonContext, type ButtonProps, Button as SprocketButton, ButtonContext as SprocketButtonContext, type ButtonProps as SprocketButtonProps, type UseButtonProps, type UseButtonProps as UseSprocketButtonProps, useButton, useButtonContext, useButton as useSprocketButton, useButtonContext as useSprocketButtonContext };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ElementType, HTMLAttributes, RefObject, Context, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
import { ButtonOptions } from '@sprocketui-types/button';
|
|
3
|
+
import { RenderProps } from '@necto-react/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface UseButtonProps<T extends ElementType> extends ButtonOptions<T> {
|
|
14
|
+
elementType?: string;
|
|
15
|
+
preventFocusOnPress?: boolean;
|
|
16
|
+
href?: string;
|
|
17
|
+
target?: string;
|
|
18
|
+
rel?: string;
|
|
19
|
+
isDisabled?: boolean;
|
|
20
|
+
onClick?: (e: any) => void;
|
|
21
|
+
onPress?: (e: any) => void;
|
|
22
|
+
onPressStart?: (e: any) => void;
|
|
23
|
+
onPressEnd?: (e: any) => void;
|
|
24
|
+
onPressUp?: (e: any) => void;
|
|
25
|
+
onPressChange?: (isPressed: boolean) => void;
|
|
26
|
+
}
|
|
27
|
+
type ButtonHookReturn<T extends ElementType> = Readonly<{
|
|
28
|
+
elementType: T;
|
|
29
|
+
buttonProps: HTMLAttributes<any>;
|
|
30
|
+
isPressed: boolean;
|
|
31
|
+
isHovered: boolean;
|
|
32
|
+
isFocused: boolean;
|
|
33
|
+
isDisabled: boolean;
|
|
34
|
+
isFocusVisible: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
declare const DEFAULT_BUTTON_TAG: keyof HTMLElementTagNameMap;
|
|
38
|
+
/**
|
|
39
|
+
* React hook that provides all necessary props and state for a headless button component.
|
|
40
|
+
*
|
|
41
|
+
* @template T The element type to render as (e.g., 'button', 'a', 'input').
|
|
42
|
+
* @param {UseButtonProps<T>} props - The props for configuring the button's behavior and accessibility.
|
|
43
|
+
* @param {RefObject<any>} ref - The ref to the button element.
|
|
44
|
+
* @returns {ButtonHookReturn<T>} An object containing readonly state and props for the button element.
|
|
45
|
+
*/
|
|
46
|
+
declare function useButton<T extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: UseButtonProps<T>, ref: RefObject<any>): ButtonHookReturn<T>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
50
|
+
*
|
|
51
|
+
* This source code is licensed under the MIT license found in the
|
|
52
|
+
* LICENSE file in the root directory of this source tree.
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
declare const ButtonContext: Context<any>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
60
|
+
*
|
|
61
|
+
* This source code is licensed under the MIT license found in the
|
|
62
|
+
* LICENSE file in the root directory of this source tree.
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
declare function useButtonContext(): any;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the MIT license found in the
|
|
71
|
+
* LICENSE file in the root directory of this source tree.
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Props for the Button component.
|
|
77
|
+
*/
|
|
78
|
+
interface ButtonProps extends ButtonOptions<ElementType>, RenderProps<any>, UseButtonProps<ElementType> {
|
|
79
|
+
slot?: string | null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The public Button component for Sprocket UI.
|
|
84
|
+
*
|
|
85
|
+
* @param {ButtonProps} props - The props for the Button component.
|
|
86
|
+
* @param {ForwardedRef<HTMLButtonElement>} ref - The forwarded ref for the button element.
|
|
87
|
+
* @returns {ReactElement | null} The rendered button element or null.
|
|
88
|
+
*/
|
|
89
|
+
declare const Button: ForwardRefExoticComponent<Omit<ButtonProps, 'ref'> & RefAttributes<HTMLButtonElement>> & {
|
|
90
|
+
Root: ForwardRefExoticComponent<Omit<ButtonProps, 'ref'> & RefAttributes<HTMLButtonElement>>;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { Button, ButtonContext, type ButtonProps, Button as SprocketButton, ButtonContext as SprocketButtonContext, type ButtonProps as SprocketButtonProps, type UseButtonProps, type UseButtonProps as UseSprocketButtonProps, useButton, useButtonContext, useButton as useSprocketButton, useButtonContext as useSprocketButtonContext };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";(()=>{var qn=Object.create;var Jt=Object.defineProperty;var Qn=Object.getOwnPropertyDescriptor;var Xn=Object.getOwnPropertyNames;var Zn=Object.getPrototypeOf,Jn=Object.prototype.hasOwnProperty;var Re=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var eo=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of Xn(r))!Jn.call(e,u)&&u!==n&&Jt(e,u,{get:()=>r[u],enumerable:!(o=Qn(r,u))||o.enumerable});return e};var L=(e,r,n)=>(n=e!=null?qn(Zn(e)):{},eo(r||!e||!e.__esModule?Jt(n,"default",{value:e,enumerable:!0}):n,e));var fr=Re(_=>{"use strict";var Tt=Symbol.for("react.transitional.element"),to=Symbol.for("react.portal"),ro=Symbol.for("react.fragment"),no=Symbol.for("react.strict_mode"),oo=Symbol.for("react.profiler"),so=Symbol.for("react.consumer"),uo=Symbol.for("react.context"),ao=Symbol.for("react.forward_ref"),io=Symbol.for("react.suspense"),co=Symbol.for("react.memo"),sr=Symbol.for("react.lazy"),er=Symbol.iterator;function lo(e){return e===null||typeof e!="object"?null:(e=er&&e[er]||e["@@iterator"],typeof e=="function"?e:null)}var ur={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ar=Object.assign,ir={};function Le(e,r,n){this.props=e,this.context=r,this.refs=ir,this.updater=n||ur}Le.prototype.isReactComponent={};Le.prototype.setState=function(e,r){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,r,"setState")};Le.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function cr(){}cr.prototype=Le.prototype;function ht(e,r,n){this.props=e,this.context=r,this.refs=ir,this.updater=n||ur}var bt=ht.prototype=new cr;bt.constructor=ht;ar(bt,Le.prototype);bt.isPureReactComponent=!0;var tr=Array.isArray,B={H:null,A:null,T:null,S:null,V:null},lr=Object.prototype.hasOwnProperty;function _t(e,r,n,o,u,i){return n=i.ref,{$$typeof:Tt,type:e,key:r,ref:n!==void 0?n:null,props:i}}function fo(e,r){return _t(e.type,r,void 0,void 0,void 0,e.props)}function Rt(e){return typeof e=="object"&&e!==null&&e.$$typeof===Tt}function po(e){var r={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return r[n]})}var rr=/\/+/g;function gt(e,r){return typeof e=="object"&&e!==null&&e.key!=null?po(""+e.key):r.toString(36)}function nr(){}function mo(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(nr,nr):(e.status="pending",e.then(function(r){e.status==="pending"&&(e.status="fulfilled",e.value=r)},function(r){e.status==="pending"&&(e.status="rejected",e.reason=r)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function Pe(e,r,n,o,u){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var c=!1;if(e===null)c=!0;else switch(i){case"bigint":case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case Tt:case to:c=!0;break;case sr:return c=e._init,Pe(c(e._payload),r,n,o,u)}}if(c)return u=u(e),c=o===""?"."+gt(e,0):o,tr(u)?(n="",c!=null&&(n=c.replace(rr,"$&/")+"/"),Pe(u,r,n,"",function(E){return E})):u!=null&&(Rt(u)&&(u=fo(u,n+(u.key==null||e&&e.key===u.key?"":(""+u.key).replace(rr,"$&/")+"/")+c)),r.push(u)),1;c=0;var f=o===""?".":o+":";if(tr(e))for(var a=0;a<e.length;a++)o=e[a],i=f+gt(o,a),c+=Pe(o,r,n,i,u);else if(a=lo(e),typeof a=="function")for(e=a.call(e),a=0;!(o=e.next()).done;)o=o.value,i=f+gt(o,a++),c+=Pe(o,r,n,i,u);else if(i==="object"){if(typeof e.then=="function")return Pe(mo(e),r,n,o,u);throw r=String(e),Error("Objects are not valid as a React child (found: "+(r==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.")}return c}function Qe(e,r,n){if(e==null)return e;var o=[],u=0;return Pe(e,o,"","",function(i){return r.call(n,i,u++)}),o}function Eo(e){if(e._status===-1){var r=e._result;r=r(),r.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=r)}if(e._status===1)return e._result.default;throw e._result}var or=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)};function vo(){}_.Children={map:Qe,forEach:function(e,r,n){Qe(e,function(){r.apply(this,arguments)},n)},count:function(e){var r=0;return Qe(e,function(){r++}),r},toArray:function(e){return Qe(e,function(r){return r})||[]},only:function(e){if(!Rt(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};_.Component=Le;_.Fragment=ro;_.Profiler=oo;_.PureComponent=ht;_.StrictMode=no;_.Suspense=io;_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B;_.__COMPILER_RUNTIME={__proto__:null,c:function(e){return B.H.useMemoCache(e)}};_.cache=function(e){return function(){return e.apply(null,arguments)}};_.cloneElement=function(e,r,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=ar({},e.props),u=e.key,i=void 0;if(r!=null)for(c in r.ref!==void 0&&(i=void 0),r.key!==void 0&&(u=""+r.key),r)!lr.call(r,c)||c==="key"||c==="__self"||c==="__source"||c==="ref"&&r.ref===void 0||(o[c]=r[c]);var c=arguments.length-2;if(c===1)o.children=n;else if(1<c){for(var f=Array(c),a=0;a<c;a++)f[a]=arguments[a+2];o.children=f}return _t(e.type,u,void 0,void 0,i,o)};_.createContext=function(e){return e={$$typeof:uo,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:so,_context:e},e};_.createElement=function(e,r,n){var o,u={},i=null;if(r!=null)for(o in r.key!==void 0&&(i=""+r.key),r)lr.call(r,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(u[o]=r[o]);var c=arguments.length-2;if(c===1)u.children=n;else if(1<c){for(var f=Array(c),a=0;a<c;a++)f[a]=arguments[a+2];u.children=f}if(e&&e.defaultProps)for(o in c=e.defaultProps,c)u[o]===void 0&&(u[o]=c[o]);return _t(e,i,void 0,void 0,null,u)};_.createRef=function(){return{current:null}};_.forwardRef=function(e){return{$$typeof:ao,render:e}};_.isValidElement=Rt;_.lazy=function(e){return{$$typeof:sr,_payload:{_status:-1,_result:e},_init:Eo}};_.memo=function(e,r){return{$$typeof:co,type:e,compare:r===void 0?null:r}};_.startTransition=function(e){var r=B.T,n={};B.T=n;try{var o=e(),u=B.S;u!==null&&u(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(vo,or)}catch(i){or(i)}finally{B.T=r}};_.unstable_useCacheRefresh=function(){return B.H.useCacheRefresh()};_.use=function(e){return B.H.use(e)};_.useActionState=function(e,r,n){return B.H.useActionState(e,r,n)};_.useCallback=function(e,r){return B.H.useCallback(e,r)};_.useContext=function(e){return B.H.useContext(e)};_.useDebugValue=function(){};_.useDeferredValue=function(e,r){return B.H.useDeferredValue(e,r)};_.useEffect=function(e,r,n){var o=B.H;if(typeof n=="function")throw Error("useEffect CRUD overload is not enabled in this build of React.");return o.useEffect(e,r)};_.useId=function(){return B.H.useId()};_.useImperativeHandle=function(e,r,n){return B.H.useImperativeHandle(e,r,n)};_.useInsertionEffect=function(e,r){return B.H.useInsertionEffect(e,r)};_.useLayoutEffect=function(e,r){return B.H.useLayoutEffect(e,r)};_.useMemo=function(e,r){return B.H.useMemo(e,r)};_.useOptimistic=function(e,r){return B.H.useOptimistic(e,r)};_.useReducer=function(e,r,n){return B.H.useReducer(e,r,n)};_.useRef=function(e){return B.H.useRef(e)};_.useState=function(e){return B.H.useState(e)};_.useSyncExternalStore=function(e,r,n){return B.H.useSyncExternalStore(e,r,n)};_.useTransition=function(){return B.H.useTransition()};_.version="19.1.0"});var dr=Re((b,Xe)=>{"use strict";process.env.NODE_ENV!=="production"&&function(){function e(t,s){Object.defineProperty(o.prototype,t,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",s[0],s[1])}})}function r(t){return t===null||typeof t!="object"?null:(t=ae&&t[ae]||t["@@iterator"],typeof t=="function"?t:null)}function n(t,s){t=(t=t.constructor)&&(t.displayName||t.name)||"ReactClass";var d=t+"."+s;Se[d]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",s,t),Se[d]=!0)}function o(t,s,d){this.props=t,this.context=s,this.refs=vt,this.updater=d||$e}function u(){}function i(t,s,d){this.props=t,this.context=s,this.refs=vt,this.updater=d||$e}function c(t){return""+t}function f(t){try{c(t);var s=!1}catch{s=!0}if(s){s=console;var d=s.error,m=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return d.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",m),c(t)}}function a(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===$n?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Ae:return"Fragment";case l:return"Profiler";case xe:return"StrictMode";case ee:return"Suspense";case q:return"SuspenseList";case F:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case De:return"Portal";case D:return(t.displayName||"Context")+".Provider";case h:return(t._context.displayName||"Context")+".Consumer";case H:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case _e:return s=t.displayName||null,s!==null?s:a(t.type)||"Memo";case de:s=t._payload,t=t._init;try{return a(t(s))}catch{}}return null}function E(t){if(t===Ae)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===de)return"<...>";try{var s=a(t);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function S(){var t=C.A;return t===null?null:t.getOwner()}function y(){return Error("react-stack-top-frame")}function O(t){if(Ve.call(t,"key")){var s=Object.getOwnPropertyDescriptor(t,"key").get;if(s&&s.isReactWarning)return!1}return t.key!==void 0}function P(t,s){function d(){Gt||(Gt=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s))}d.isReactWarning=!0,Object.defineProperty(t,"key",{get:d,configurable:!0})}function N(){var t=a(this.type);return Kt[t]||(Kt[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function T(t,s,d,m,g,A,R,k){return d=A.ref,t={$$typeof:oe,type:t,key:s,props:A,_owner:g},(d!==void 0?d:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:N}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:R}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:k}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function v(t,s){return s=T(t.type,s,void 0,void 0,t._owner,t.props,t._debugStack,t._debugTask),t._store&&(s._store.validated=t._store.validated),s}function j(t){return typeof t=="object"&&t!==null&&t.$$typeof===oe}function re(t){var s={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(d){return s[d]})}function ne(t,s){return typeof t=="object"&&t!==null&&t.key!=null?(f(t.key),re(""+t.key)):s.toString(36)}function ue(){}function ce(t){switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:switch(typeof t.status=="string"?t.then(ue,ue):(t.status="pending",t.then(function(s){t.status==="pending"&&(t.status="fulfilled",t.value=s)},function(s){t.status==="pending"&&(t.status="rejected",t.reason=s)})),t.status){case"fulfilled":return t.value;case"rejected":throw t.reason}}throw t}function Y(t,s,d,m,g){var A=typeof t;(A==="undefined"||A==="boolean")&&(t=null);var R=!1;if(t===null)R=!0;else switch(A){case"bigint":case"string":case"number":R=!0;break;case"object":switch(t.$$typeof){case oe:case De:R=!0;break;case de:return R=t._init,Y(R(t._payload),s,d,m,g)}}if(R){R=t,g=g(R);var k=m===""?"."+ne(R,0):m;return Yt(g)?(d="",k!=null&&(d=k.replace(qt,"$&/")+"/"),Y(g,s,d,"",function(pe){return pe})):g!=null&&(j(g)&&(g.key!=null&&(R&&R.key===g.key||f(g.key)),d=v(g,d+(g.key==null||R&&R.key===g.key?"":(""+g.key).replace(qt,"$&/")+"/")+k),m!==""&&R!=null&&j(R)&&R.key==null&&R._store&&!R._store.validated&&(d._store.validated=2),g=d),s.push(g)),1}if(R=0,k=m===""?".":m+":",Yt(t))for(var w=0;w<t.length;w++)m=t[w],A=k+ne(m,w),R+=Y(m,s,d,A,g);else if(w=r(t),typeof w=="function")for(w===t.entries&&(zt||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),zt=!0),t=w.call(t),w=0;!(m=t.next()).done;)m=m.value,A=k+ne(m,w++),R+=Y(m,s,d,A,g);else if(A==="object"){if(typeof t.then=="function")return Y(ce(t),s,d,m,g);throw s=String(t),Error("Objects are not valid as a React child (found: "+(s==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":s)+"). If you meant to render a collection of children, use an array instead.")}return R}function K(t,s,d){if(t==null)return t;var m=[],g=0;return Y(t,m,"","",function(A){return s.call(d,A,g++)}),m}function Z(t){if(t._status===-1){var s=t._result;s=s(),s.then(function(d){(t._status===0||t._status===-1)&&(t._status=1,t._result=d)},function(d){(t._status===0||t._status===-1)&&(t._status=2,t._result=d)}),t._status===-1&&(t._status=0,t._result=s)}if(t._status===1)return s=t._result,s===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
2
|
+
|
|
3
|
+
Your code should look like:
|
|
4
|
+
const MyComponent = lazy(() => import('./MyComponent'))
|
|
5
|
+
|
|
6
|
+
Did you accidentally put curly braces around the import?`,s),"default"in s||console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
7
|
+
|
|
8
|
+
Your code should look like:
|
|
9
|
+
const MyComponent = lazy(() => import('./MyComponent'))`,s),s.default;throw t._result}function M(){var t=C.H;return t===null&&console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
|
|
10
|
+
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
11
|
+
2. You might be breaking the Rules of Hooks
|
|
12
|
+
3. You might have more than one copy of React in the same app
|
|
13
|
+
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),t}function le(){}function z(t){if(Ke===null)try{var s=("require"+Math.random()).slice(0,7);Ke=(Xe&&Xe[s]).call(Xe,"timers").setImmediate}catch{Ke=function(m){Xt===!1&&(Xt=!0,typeof MessageChannel>"u"&&console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var g=new MessageChannel;g.port1.onmessage=m,g.port2.postMessage(void 0)}}return Ke(t)}function J(t){return 1<t.length&&typeof AggregateError=="function"?new AggregateError(t):t[0]}function fe(t,s){s!==ze-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),ze=s}function p(t,s,d){var m=C.actQueue;if(m!==null)if(m.length!==0)try{U(m),z(function(){return p(t,s,d)});return}catch(g){C.thrownErrors.push(g)}else C.actQueue=null;0<C.thrownErrors.length?(m=J(C.thrownErrors),C.thrownErrors.length=0,d(m)):s(t)}function U(t){if(!yt){yt=!0;var s=0;try{for(;s<t.length;s++){var d=t[s];do{C.didUsePromise=!1;var m=d(!1);if(m!==null){if(C.didUsePromise){t[s]=d,t.splice(0,s);return}d=m}else break}while(!0)}t.length=0}catch(g){t.splice(0,s+1),C.thrownErrors.push(g)}finally{yt=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var oe=Symbol.for("react.transitional.element"),De=Symbol.for("react.portal"),Ae=Symbol.for("react.fragment"),xe=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler");Symbol.for("react.provider");var h=Symbol.for("react.consumer"),D=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),ee=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),_e=Symbol.for("react.memo"),de=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),ae=Symbol.iterator,Se={},$e={isMounted:function(){return!1},enqueueForceUpdate:function(t){n(t,"forceUpdate")},enqueueReplaceState:function(t){n(t,"replaceState")},enqueueSetState:function(t){n(t,"setState")}},Wt=Object.assign,vt={};Object.freeze(vt),o.prototype.isReactComponent={},o.prototype.setState=function(t,s){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,s,"setState")},o.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};var Q={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]},Ge;for(Ge in Q)Q.hasOwnProperty(Ge)&&e(Ge,Q[Ge]);u.prototype=o.prototype,Q=i.prototype=new u,Q.constructor=i,Wt(Q,o.prototype),Q.isPureReactComponent=!0;var Yt=Array.isArray,$n=Symbol.for("react.client.reference"),C={H:null,A:null,T:null,S:null,V:null,actQueue:null,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},Ve=Object.prototype.hasOwnProperty,$t=console.createTask?console.createTask:function(){return null};Q={"react-stack-bottom-frame":function(t){return t()}};var Gt,Vt,Kt={},Gn=Q["react-stack-bottom-frame"].bind(Q,y)(),Vn=$t(E(y)),zt=!1,qt=/\/+/g,Qt=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},Xt=!1,Ke=null,ze=0,qe=!1,yt=!1,Zt=typeof queueMicrotask=="function"?function(t){queueMicrotask(function(){return queueMicrotask(t)})}:z;Q=Object.freeze({__proto__:null,c:function(t){return M().useMemoCache(t)}}),b.Children={map:K,forEach:function(t,s,d){K(t,function(){s.apply(this,arguments)},d)},count:function(t){var s=0;return K(t,function(){s++}),s},toArray:function(t){return K(t,function(s){return s})||[]},only:function(t){if(!j(t))throw Error("React.Children.only expected to receive a single React element child.");return t}},b.Component=o,b.Fragment=Ae,b.Profiler=l,b.PureComponent=i,b.StrictMode=xe,b.Suspense=ee,b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,b.__COMPILER_RUNTIME=Q,b.act=function(t){var s=C.actQueue,d=ze;ze++;var m=C.actQueue=s!==null?s:[],g=!1;try{var A=t()}catch(w){C.thrownErrors.push(w)}if(0<C.thrownErrors.length)throw fe(s,d),t=J(C.thrownErrors),C.thrownErrors.length=0,t;if(A!==null&&typeof A=="object"&&typeof A.then=="function"){var R=A;return Zt(function(){g||qe||(qe=!0,console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),{then:function(w,pe){g=!0,R.then(function(Oe){if(fe(s,d),d===0){try{U(m),z(function(){return p(Oe,w,pe)})}catch(zn){C.thrownErrors.push(zn)}if(0<C.thrownErrors.length){var Kn=J(C.thrownErrors);C.thrownErrors.length=0,pe(Kn)}}else w(Oe)},function(Oe){fe(s,d),0<C.thrownErrors.length&&(Oe=J(C.thrownErrors),C.thrownErrors.length=0),pe(Oe)})}}}var k=A;if(fe(s,d),d===0&&(U(m),m.length!==0&&Zt(function(){g||qe||(qe=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),C.actQueue=null),0<C.thrownErrors.length)throw t=J(C.thrownErrors),C.thrownErrors.length=0,t;return{then:function(w,pe){g=!0,d===0?(C.actQueue=m,z(function(){return p(k,w,pe)})):w(k)}}},b.cache=function(t){return function(){return t.apply(null,arguments)}},b.captureOwnerStack=function(){var t=C.getCurrentStack;return t===null?null:t()},b.cloneElement=function(t,s,d){if(t==null)throw Error("The argument must be a React element, but you passed "+t+".");var m=Wt({},t.props),g=t.key,A=t._owner;if(s!=null){var R;e:{if(Ve.call(s,"ref")&&(R=Object.getOwnPropertyDescriptor(s,"ref").get)&&R.isReactWarning){R=!1;break e}R=s.ref!==void 0}R&&(A=S()),O(s)&&(f(s.key),g=""+s.key);for(k in s)!Ve.call(s,k)||k==="key"||k==="__self"||k==="__source"||k==="ref"&&s.ref===void 0||(m[k]=s[k])}var k=arguments.length-2;if(k===1)m.children=d;else if(1<k){R=Array(k);for(var w=0;w<k;w++)R[w]=arguments[w+2];m.children=R}for(m=T(t.type,g,void 0,void 0,A,m,t._debugStack,t._debugTask),g=2;g<arguments.length;g++)A=arguments[g],j(A)&&A._store&&(A._store.validated=1);return m},b.createContext=function(t){return t={$$typeof:D,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null},t.Provider=t,t.Consumer={$$typeof:h,_context:t},t._currentRenderer=null,t._currentRenderer2=null,t},b.createElement=function(t,s,d){for(var m=2;m<arguments.length;m++){var g=arguments[m];j(g)&&g._store&&(g._store.validated=1)}if(m={},g=null,s!=null)for(w in Vt||!("__self"in s)||"key"in s||(Vt=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),O(s)&&(f(s.key),g=""+s.key),s)Ve.call(s,w)&&w!=="key"&&w!=="__self"&&w!=="__source"&&(m[w]=s[w]);var A=arguments.length-2;if(A===1)m.children=d;else if(1<A){for(var R=Array(A),k=0;k<A;k++)R[k]=arguments[k+2];Object.freeze&&Object.freeze(R),m.children=R}if(t&&t.defaultProps)for(w in A=t.defaultProps,A)m[w]===void 0&&(m[w]=A[w]);g&&P(m,typeof t=="function"?t.displayName||t.name||"Unknown":t);var w=1e4>C.recentlyCreatedOwnerStacks++;return T(t,g,void 0,void 0,S(),m,w?Error("react-stack-top-frame"):Gn,w?$t(E(t)):Vn)},b.createRef=function(){var t={current:null};return Object.seal(t),t},b.forwardRef=function(t){t!=null&&t.$$typeof===_e?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof t!="function"?console.error("forwardRef requires a render function but was given %s.",t===null?"null":typeof t):t.length!==0&&t.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",t.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),t!=null&&t.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var s={$$typeof:H,render:t},d;return Object.defineProperty(s,"displayName",{enumerable:!1,configurable:!0,get:function(){return d},set:function(m){d=m,t.name||t.displayName||(Object.defineProperty(t,"name",{value:m}),t.displayName=m)}}),s},b.isValidElement=j,b.lazy=function(t){return{$$typeof:de,_payload:{_status:-1,_result:t},_init:Z}},b.memo=function(t,s){t==null&&console.error("memo: The first argument must be a component. Instead received: %s",t===null?"null":typeof t),s={$$typeof:_e,type:t,compare:s===void 0?null:s};var d;return Object.defineProperty(s,"displayName",{enumerable:!1,configurable:!0,get:function(){return d},set:function(m){d=m,t.name||t.displayName||(Object.defineProperty(t,"name",{value:m}),t.displayName=m)}}),s},b.startTransition=function(t){var s=C.T,d={};C.T=d,d._updatedFibers=new Set;try{var m=t(),g=C.S;g!==null&&g(d,m),typeof m=="object"&&m!==null&&typeof m.then=="function"&&m.then(le,Qt)}catch(A){Qt(A)}finally{s===null&&d._updatedFibers&&(t=d._updatedFibers.size,d._updatedFibers.clear(),10<t&&console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")),C.T=s}},b.unstable_useCacheRefresh=function(){return M().useCacheRefresh()},b.use=function(t){return M().use(t)},b.useActionState=function(t,s,d){return M().useActionState(t,s,d)},b.useCallback=function(t,s){return M().useCallback(t,s)},b.useContext=function(t){var s=M();return t.$$typeof===h&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),s.useContext(t)},b.useDebugValue=function(t,s){return M().useDebugValue(t,s)},b.useDeferredValue=function(t,s){return M().useDeferredValue(t,s)},b.useEffect=function(t,s,d){t==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?");var m=M();if(typeof d=="function")throw Error("useEffect CRUD overload is not enabled in this build of React.");return m.useEffect(t,s)},b.useId=function(){return M().useId()},b.useImperativeHandle=function(t,s,d){return M().useImperativeHandle(t,s,d)},b.useInsertionEffect=function(t,s){return t==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),M().useInsertionEffect(t,s)},b.useLayoutEffect=function(t,s){return t==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),M().useLayoutEffect(t,s)},b.useMemo=function(t,s){return M().useMemo(t,s)},b.useOptimistic=function(t,s){return M().useOptimistic(t,s)},b.useReducer=function(t,s,d){return M().useReducer(t,s,d)},b.useRef=function(t){return M().useRef(t)},b.useState=function(t){return M().useState(t)},b.useSyncExternalStore=function(t,s,d){return M().useSyncExternalStore(t,s,d)},b.useTransition=function(){return M().useTransition()},b.version="19.1.0",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()});var I=Re((Ls,wt)=>{"use strict";process.env.NODE_ENV==="production"?wt.exports=fr():wt.exports=dr()});var At=Re((ks,Er)=>{"use strict";var Ct=Object.defineProperty,yo=Object.getOwnPropertyDescriptor,go=Object.getOwnPropertyNames,To=Object.prototype.hasOwnProperty,ho=(e,r)=>{for(var n in r)Ct(e,n,{get:r[n],enumerable:!0})},bo=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of go(r))!To.call(e,u)&&u!==n&&Ct(e,u,{get:()=>r[u],enumerable:!(o=yo(r,u))||o.enumerable});return e},_o=e=>bo(Ct({},"__esModule",{value:!0}),e),pr={};ho(pr,{DisabledContext:()=>mr,DisabledProvider:()=>Co,FocusableContext:()=>So});Er.exports=_o(pr);var Ro=I(),mr=(0,Ro.createContext)(new Object),wo=I();function Co({value:e,children:r}){return(0,wo.createElement)(mr.Provider,{value:e||new Object},r)}var Ao=I(),So=(0,Ao.createContext)(null)});var xn=Re(pt=>{"use strict";var Cs=Symbol.for("react.transitional.element"),As=Symbol.for("react.fragment");function Dn(e,r,n){var o=null;if(n!==void 0&&(o=""+n),r.key!==void 0&&(o=""+r.key),"key"in r){n={};for(var u in r)u!=="key"&&(n[u]=r[u])}else n=r;return r=n.ref,{$$typeof:Cs,type:e,key:o,ref:r!==void 0?r:null,props:n}}pt.Fragment=As;pt.jsx=Dn;pt.jsxs=Dn});var Bn=Re(mt=>{"use strict";process.env.NODE_ENV!=="production"&&function(){function e(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===le?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case T:return"Fragment";case j:return"Profiler";case v:return"StrictMode";case ce:return"Suspense";case Y:return"SuspenseList";case M:return"Activity"}if(typeof l=="object")switch(typeof l.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),l.$$typeof){case N:return"Portal";case ne:return(l.displayName||"Context")+".Provider";case re:return(l._context.displayName||"Context")+".Consumer";case ue:var h=l.render;return l=l.displayName,l||(l=h.displayName||h.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case K:return h=l.displayName||null,h!==null?h:e(l.type)||"Memo";case Z:h=l._payload,l=l._init;try{return e(l(h))}catch{}}return null}function r(l){return""+l}function n(l){try{r(l);var h=!1}catch{h=!0}if(h){h=console;var D=h.error,H=typeof Symbol=="function"&&Symbol.toStringTag&&l[Symbol.toStringTag]||l.constructor.name||"Object";return D.call(h,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",H),r(l)}}function o(l){if(l===T)return"<>";if(typeof l=="object"&&l!==null&&l.$$typeof===Z)return"<...>";try{var h=e(l);return h?"<"+h+">":"<...>"}catch{return"<...>"}}function u(){var l=z.A;return l===null?null:l.getOwner()}function i(){return Error("react-stack-top-frame")}function c(l){if(J.call(l,"key")){var h=Object.getOwnPropertyDescriptor(l,"key").get;if(h&&h.isReactWarning)return!1}return l.key!==void 0}function f(l,h){function D(){U||(U=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",h))}D.isReactWarning=!0,Object.defineProperty(l,"key",{get:D,configurable:!0})}function a(){var l=e(this.type);return oe[l]||(oe[l]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),l=this.props.ref,l!==void 0?l:null}function E(l,h,D,H,ee,q,_e,de){return D=q.ref,l={$$typeof:P,type:l,key:h,props:q,_owner:ee},(D!==void 0?D:null)!==null?Object.defineProperty(l,"ref",{enumerable:!1,get:a}):Object.defineProperty(l,"ref",{enumerable:!1,value:null}),l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(l,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(l,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:_e}),Object.defineProperty(l,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:de}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}function S(l,h,D,H,ee,q,_e,de){var F=h.children;if(F!==void 0)if(H)if(fe(F)){for(H=0;H<F.length;H++)y(F[H]);Object.freeze&&Object.freeze(F)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(F);if(J.call(h,"key")){F=e(l);var ae=Object.keys(h).filter(function($e){return $e!=="key"});H=0<ae.length?"{key: someKey, "+ae.join(": ..., ")+": ...}":"{key: someKey}",xe[F+H]||(ae=0<ae.length?"{"+ae.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
14
|
+
let props = %s;
|
|
15
|
+
<%s {...props} />
|
|
16
|
+
React keys must be passed directly to JSX without using spread:
|
|
17
|
+
let props = %s;
|
|
18
|
+
<%s key={someKey} {...props} />`,H,F,ae,F),xe[F+H]=!0)}if(F=null,D!==void 0&&(n(D),F=""+D),c(h)&&(n(h.key),F=""+h.key),"key"in h){D={};for(var Se in h)Se!=="key"&&(D[Se]=h[Se])}else D=h;return F&&f(D,typeof l=="function"?l.displayName||l.name||"Unknown":l),E(l,F,q,ee,u(),D,_e,de)}function y(l){typeof l=="object"&&l!==null&&l.$$typeof===P&&l._store&&(l._store.validated=1)}var O=I(),P=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler");Symbol.for("react.provider");var re=Symbol.for("react.consumer"),ne=Symbol.for("react.context"),ue=Symbol.for("react.forward_ref"),ce=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),K=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),le=Symbol.for("react.client.reference"),z=O.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=Object.prototype.hasOwnProperty,fe=Array.isArray,p=console.createTask?console.createTask:function(){return null};O={"react-stack-bottom-frame":function(l){return l()}};var U,oe={},De=O["react-stack-bottom-frame"].bind(O,i)(),Ae=p(o(i)),xe={};mt.Fragment=T,mt.jsx=function(l,h,D,H,ee){var q=1e4>z.recentlyCreatedOwnerStacks++;return S(l,h,D,!1,H,ee,q?Error("react-stack-top-frame"):De,q?p(o(l)):Ae)},mt.jsxs=function(l,h,D,H,ee){var q=1e4>z.recentlyCreatedOwnerStacks++;return S(l,h,D,!0,H,ee,q?Error("react-stack-top-frame"):De,q?p(o(l)):Ae)}}()});var Et=Re((Mu,Ht)=>{"use strict";process.env.NODE_ENV==="production"?Ht.exports=xn():Ht.exports=Bn()});var it=L(I(),1);function se(...e){if(e.length===0)return{};if(e.length===1)return typeof e[0]=="object"&&e[0]!==null?e[0]:{};let r={},n={};for(let o of e)if(!(typeof o!="object"||o===null)){for(let u in o)if(Object.hasOwn(o,u)){if(u==="children")continue;let i=o[u];u.startsWith("on")&&typeof i=="function"?(n[u]??=[],n[u].push(i)):r[u]=i}}for(let o in n)Object.hasOwn(n,o)&&n[o].length>0&&(r[o]=(...u)=>{for(let i of n[o])i?.(...u)});for(let o=e.length-1;o>=0;o--){let u=e[o];if(typeof u=="object"&&u!==null&&"children"in u){r.children=u.children;break}}return r}var ls=L(I(),1),fs=L(At(),1),ds=L(I(),1),ct=L(I(),1),ut=L(I(),1);var Oo=Object.defineProperty,Ze=(e,r)=>{for(var n in r)Oo(e,n,{get:r[n],enumerable:!0})},Be={};Ze(Be,{HTML_TAGS:()=>yr,PRIMITIVE_TAGS:()=>vr,default:()=>Po});var vr=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],yr=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","math","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],Po={PRIMITIVE_TAGS:vr,HTML_TAGS:yr},Lo={};Ze(Lo,{NUMERIC_DIGITS:()=>gr,default:()=>Io});var gr=["1","2","3","4","5","6","7","8","9","0"],Io={NUMERIC_DIGITS:gr},ko={};Ze(ko,{AMPERSAND:()=>Or,ASTERISK:()=>Lr,BACKSLASH:()=>Fr,BOM:()=>Tr,CARRIAGE_RETURN:()=>_r,COLON:()=>Dr,COMMA:()=>kr,COMMERCIAL_AT:()=>Ur,DOT:()=>Mr,DOUBLE_QUOTE:()=>Cr,EXCLAMATION:()=>wr,GRAVE_ACCENT:()=>Yr,GREATER_THAN:()=>Br,LEFT_CURLY_BRACKET:()=>$r,LEFT_SQUARE_BRACKET:()=>Hr,LINE_FEED:()=>br,MINUS:()=>Nr,PERCENT:()=>Sr,PLUS:()=>Ir,QUESTION:()=>jr,RIGHT_CURLY_BRACKET:()=>Vr,RIGHT_SQUARE_BRACKET:()=>Wr,SHARP:()=>Ar,SINGLE_QUOTE:()=>Pr,SMALLER_THAN:()=>xr,SPACE:()=>Rr,TAB:()=>hr,VERTICAL_LINE:()=>Gr,default:()=>No});var Tr=65279,hr=9,br=10,_r=13,Rr=32,wr=33,Cr=34,Ar=35,Sr=37,Or=38,Pr=39,Lr=42,Ir=43,kr=44,Nr=45,Mr=46,Dr=58,xr=60,Br=62,jr=63,Ur=64,Hr=91,Fr=92,Wr=93,Yr=96,$r=123,Gr=124,Vr=125,No={BOM:Tr,TAB:hr,LINE_FEED:br,CARRIAGE_RETURN:_r,SPACE:Rr,EXCLAMATION:wr,DOUBLE_QUOTE:Cr,SHARP:Ar,PERCENT:Sr,AMPERSAND:Or,SINGLE_QUOTE:Pr,ASTERISK:Lr,PLUS:Ir,COMMA:kr,MINUS:Nr,DOT:Mr,COLON:Dr,SMALLER_THAN:xr,GREATER_THAN:Br,QUESTION:jr,COMMERCIAL_AT:Ur,LEFT_SQUARE_BRACKET:Hr,BACKSLASH:Fr,RIGHT_SQUARE_BRACKET:Wr,GRAVE_ACCENT:Yr,LEFT_CURLY_BRACKET:$r,VERTICAL_LINE:Gr,RIGHT_CURLY_BRACKET:Vr},Mo={};Ze(Mo,{CAPITALIZED:()=>Kr,LOWERCASE:()=>zr,VOWELS:()=>qr,default:()=>Do});var Kr=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],zr=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],qr=["A","E","I","O","U","a","e","i","o","u"],Do={CAPITALIZED:Kr,LOWERCASE:zr,VOWELS:qr};function xo(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):!1}var Bo=()=>xo(/^Mac/i);function Qr(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):!1}var jo=()=>Qr(/^iPhone/i),Uo=()=>Qr(/^iPad/i)||Bo()&&navigator.maxTouchPoints>1,St=()=>jo()||Uo();function Ho(e){return Fo(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function Fo(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function et(e,r,n=!0){if(!e||!r)return!1;if(!n)return e.contains(r);let o=r;for(;o;){if(o===e)return!0;o=o instanceof Element&&o.tagName==="SLOT"&&o.assignedSlot?o.assignedSlot.parentNode:Ho(o)?o.host:o.parentNode}return!1}var Ee=(e=document,r=!0)=>{if(!r)return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&n.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return n};function tt(e,r=!0){return r&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}var W=e=>e?.ownerDocument??document,ve=e=>e&&"window"in e&&e.window===e?e:W(e).defaultView||window,Je=null;function Wo(){if(Je==null){Je=!1;try{document.createElement("div").focus({get preventScroll(){return Je=!0,!0}})}catch{}}return Je}function Lt(e){if(Wo())e.focus({preventScroll:!0});else{let r=Yo(e);e.focus();for(let{element:n,scrollTop:o,scrollLeft:u}of r)n.scrollTop=o,n.scrollLeft=u}}function Yo(e){let r=e.parentNode,n=Array.from({length:0}),o=document.scrollingElement||document.documentElement;for(;r instanceof HTMLElement&&r!==o;)(r.offsetHeight<r.scrollHeight||r.offsetWidth<r.scrollWidth)&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),r=r.parentNode;return o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),n}var me=new Map,Ot=new Set;function $o(e){if(!("propertyName"in e)||!e.target)return;let r=me.get(e.target);r||(r=new Set,me.set(e.target,r),e.target.addEventListener("transitioncancel",It,{once:!0})),r.add(e.propertyName)}function It(e){if(!("propertyName"in e)||!e.target)return;let r=me.get(e.target);if(r&&(r.delete(e.propertyName),r.size===0&&(e.target.removeEventListener("transitioncancel",It),me.delete(e.target)),me.size===0)){for(let n of Ot)n();Ot.clear()}}if(typeof window<"u"&&typeof document<"u"){let e=()=>{let r=document.body;r&&(r.addEventListener("transitionrun",$o),r.addEventListener("transitionend",It))};document.readyState!=="loading"?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function kt(e){requestAnimationFrame(()=>{for(let[r]of me)"isConnected"in r&&!r.isConnected&&me.delete(r);me.size===0?e():Ot.add(e)})}var te=Be.HTML_TAGS.reduce((e,r)=>{var n;return e[n=r,n.charAt(0).toUpperCase()+n.slice(1)]=r,e},{}),Ie="default",Pt="",je=new WeakMap;function rt(e){if(St()){if(Ie==="default"){let r=W(e);r?.documentElement?.style.webkitUserSelect!==void 0&&(Pt=r.documentElement.style.webkitUserSelect,r.documentElement.style.webkitUserSelect="none",Ie="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){let r=e.style,n="userSelect"in r?"userSelect":"webkitUserSelect";je.has(e)||(je.set(e,r[n]??""),r[n]="none")}}function ye(e){if(St()){if(Ie!=="disabled")return;Ie="restoring",setTimeout(()=>{kt(()=>{if(Ie==="restoring"){let r=W(e);r?.documentElement?.style.webkitUserSelect==="none"&&(r.documentElement.style.webkitUserSelect=Pt||""),Pt="",Ie="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&je.has(e)){let r=je.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";n[o]==="none"&&(n[o]=r),e.getAttribute("style")?.trim()===""&&e.removeAttribute("style"),je.delete(e)}}var ke=L(I(),1),dn=L(At(),1),he=L(I(),1),ms=L(I(),1);var us={},nt=Object.create(null),Ue=e=>globalThis.process?.env||us.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?nt:globalThis),ge=new Proxy(nt,{get(e,r){return Ue()[r]??nt[r]},has(e,r){let n=Ue();return r in n||r in nt},set(e,r,n){let o=Ue(!0);return o[r]=n,!0},deleteProperty(e,r){if(!r)return!1;let n=Ue(!0);return delete n[r],!0},ownKeys(){let e=Ue(!0);return Object.keys(e)}}),Zr=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",Go=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CLOUDFLARE_WORKERS","WORKERS_CI",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["CODESANDBOX","CODESANDBOX_HOST",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]];function Vo(){if(globalThis.process?.env)for(let e of Go){let r=e[1]||e[0];if(globalThis.process?.env[r])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}var Jr=Vo(),js=Jr.name;function we(e){return e?e!=="false":!1}var Nt=globalThis.process?.platform||"",en=we(ge.CI)||Jr.ci!==!1,tn=we(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY);var Us=we(ge.DEBUG),Ce=Zr==="test"||we(ge.TEST),rn=Zr==="production";var Hs=we(ge.MINIMAL)||en||Ce||!tn,Ko=/^win/i.test(Nt),Fs=/^linux/i.test(Nt),nn=/^darwin/i.test(Nt),Ws=!we(ge.NO_COLOR)&&(we(ge.FORCE_COLOR)||(tn||Ko)&&ge.TERM!=="dumb"||en),zo=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null,Ys=Number(zo?.split(".")[0])||null,qo=globalThis.process||Object.create(null),Xr={versions:{}},$s=new Proxy(qo,{get(e,r){if(r==="env")return ge;if(r in e)return e[r];if(r in Xr)return Xr[r]}}),Qo=globalThis.process?.release?.name==="node",Xo=!!globalThis.Bun||!!globalThis.process?.versions?.bun,Zo=!!globalThis.Deno,Jo=!!globalThis.fastly,es=!!globalThis.Netlify,ts=!!globalThis.EdgeRuntime,rs=globalThis.navigator?.userAgent==="Cloudflare-Workers",ns=[[es,"netlify"],[ts,"edge-light"],[rs,"workerd"],[Jo,"fastly"],[Zo,"deno"],[Xo,"bun"],[Qo,"node"]];function os(){let e=ns.find(r=>r[0]);if(e)return{name:e[1]}}var ss=os(),Gs=ss?.name||"";var En=L(I(),1);var as=new Set(["id"]);function on(e,r){let{allowLabelableProps:n=!1,allowLinkProps:o=!1,extraAllowedProps:u,allowedLabelableProps:i=new Set,allowedLinkProps:c=new Set}=r,f={};for(let a in e)Object.hasOwn(e,a)&&(as.has(a)||n&&i.has(a)||o&&c.has(a)||u?.has(a)||new RegExp(/^(data-.*)$/).test(a))&&(f[a]=e[a]);return f}function Mt(e){if(!e)return;let r=!0;return n=>{let o={...n,preventDefault(){n.preventDefault()},isDefaultPrevented(){return n.isDefaultPrevented()},stopPropagation(){r&&rn?console.error("stopPropagation is now the default behavior for events in Necto. You can use continuePropagation() to revert this behavior."):r=!0},continuePropagation(){r=!1},isPropagationStopped(){return r}};e(o),r&&n.stopPropagation()}}function ot(e){let r=e;return Object.assign(r,{nativeEvent:e,isDefaultPrevented:()=>r.defaultPrevented,isPropagationStopped:()=>r.cancelBubble,persist:()=>{}}),r}var is=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),cs={Tab:!0,Escape:!0};function sn(e,r,n){if(!n||!("target"in n)||!n.target)return!1;let o=W(n.target),u=ve(n.target),i=typeof window<"u"?u.HTMLInputElement:HTMLInputElement,c=typeof window<"u"?u.HTMLTextAreaElement:HTMLTextAreaElement,f=typeof window<"u"?u.HTMLElement:HTMLElement,a=typeof window<"u"?u.KeyboardEvent:KeyboardEvent,E=o.activeElement;return e=e||E instanceof i&&!is.has(E.type)||E instanceof c||E instanceof f&&E.isContentEditable,!(e&&r==="keyboard"&&n instanceof a&&!cs[n.key])}var Fe=L(I(),1);var Te=L(I(),1);var V=L(I(),1);var X=L(I(),1);var lt=L(I(),1);var x=L(I(),1),Rn=L(I(),1),Cn=L(I(),1),An=L(I(),1);var Ne=L(I(),1),be=L(I(),1),On=L(I(),1);function ln({props:e,ref:r,context:n}){let o=_s({context:n,slot:e.slot})||{},{ref:u=null,...i}=o,c=(0,it.useRef)(null),f=(0,it.useCallback)(E=>{c.current=E,typeof r=="function"?r(E):r&&(r.current=E),typeof u=="function"?u(E):u&&typeof u=="object"&&(u.current=E)},[r,u]),a=se(i,e);return"style"in i&&i.style&&"style"in e&&e.style&&(typeof i.style=="function"||typeof e.style=="function"?a.style=E=>{let S=typeof i.style=="function"?i.style(E):i.style,y={...E.defaultStyle,...S},O=typeof e.style=="function"?e.style({...E,defaultStyle:y}):e.style;return{...y,...O}}:a.style={...i.style,...e.style}),[a,f]}function fn(e={}){let{isDisabled:r,onFocus:n,onBlur:o,onFocusChange:u}=e,i=(0,ut.useCallback)((E,S)=>{E?(n?.(S),u?.(!0)):(o?.(S),u?.(!1))},[n,o,u]),c=(0,ut.useCallback)(E=>{E.target===E.currentTarget&&i(!1,E)},[i]),f=Sn({onBlur:c}),a=(0,ut.useCallback)(E=>{let S=W(E.target),y=S?Ee(S):Ee();E.target===E.currentTarget&&y===tt(E.nativeEvent)&&(i(!0,E),f(E))},[i,f]);return{focusProps:{...r?{}:{onFocus:a,onBlur:c}}}}function pn(e,r){let{autoFocus:n,isDisabled:o,excludeFromTabOrder:u}=e,{focusProps:i}=fn(e),{keyboardProps:c}=bs(e),f=(0,ke.useContext)(dn.FocusableContext)||{},a=(0,ke.useRef)(n);Rs({context:f,ref:r});let{ref:E,...S}=f,y=W(r.current),O=Ee(y);(0,ke.useEffect)(()=>{if(a.current&&r.current)if(Es()==="virtual"){let N=O;kt(()=>{Ee(y)===N&&r.current?.isConnected&&Lt(r.current)})}else Lt(r.current);a.current=!1},[r]);let P=u?-1:0;return o&&(P=void 0),{focusableProps:se({...se(i??{},c),tabIndex:P},o?{}:S)}}var ps=null;function mn(e={}){let{within:r=!1,isTextInput:n=!1,autoFocus:o=!1}=e,u=(0,he.useRef)({isFocused:o,isFocusVisible:o||ps!=="pointer"}),[i,c]=(0,he.useState)(o),[f,a]=(0,he.useState)(()=>u.current.isFocused&&u.current.isFocusVisible),E=(0,he.useCallback)(()=>{a(u.current.isFocused&&u.current.isFocusVisible)},[]),S=(0,he.useCallback)(P=>{u.current.isFocused=P,c(P),E()},[E]);Ts({fn:P=>{u.current.isFocusVisible=P,E()},deps:[],opts:{isTextInput:n}});let{focusProps:y={}}=fn({isDisabled:r,onFocusChange:S})||{},{focusWithinProps:O={}}=hs({isDisabled:!r,onFocusWithinChange:S})||{};return{isFocused:i,isFocusVisible:f,focusProps:r?O:y}}var He=new Map,Dt=new Set,un=!1,xt=null,an=!1,G={get hasEventBeforeFocus(){return un},set hasEventBeforeFocus(e){un=e},get hasBlurredWindowRecently(){return an},set hasBlurredWindowRecently(e){an=e},get currentModality(){return xt},set currentModality(e){xt=e}};function Es(){return xt}function jt(e,r){Dt.forEach(n=>n(e,r))}function vs(e){return!(e.metaKey||nn&&e.altKey||e.ctrlKey||["Control","Shift","Meta"].includes(e.key))}function vn(e){vs(e)&&(G.hasEventBeforeFocus=!0,G.currentModality="keyboard",jt("keyboard",e))}function Bt(e){["mousedown","pointerdown"].includes(e.type)&&(G.hasEventBeforeFocus=!0,G.currentModality="pointer",jt("pointer",e))}function yn(e){[window,document].includes(e.target)||!e.isTrusted||!G.hasEventBeforeFocus&&!G.hasBlurredWindowRecently||(!G.hasEventBeforeFocus&&!G.hasBlurredWindowRecently&&(G.currentModality="virtual",jt("virtual",e)),G.hasEventBeforeFocus=!1,G.hasBlurredWindowRecently=!1)}function gn(){G.hasEventBeforeFocus=!1,G.hasBlurredWindowRecently=!0}function ys(e){let r=ve(e),n=W(e);if(typeof window>"u"||typeof document>"u"||He.has(r))return;let o=r.HTMLElement.prototype.focus;r.HTMLElement.prototype.focus=function(...u){G.hasEventBeforeFocus=!0,o.apply(this,u)},n.addEventListener("keydown",vn,!0),n.addEventListener("click",Bt,!0),r.addEventListener("focus",yn,!0),r.addEventListener("blur",gn,!1),typeof PointerEvent<"u"&&n.addEventListener("pointerdown",Bt,!0),He.set(r,{focus:o})}function gs(e){let r=ve(e),n=W(e);if(!He.has(r))return;let{focus:o}=He.get(r);r.HTMLElement.prototype.focus=o,n.removeEventListener("keydown",vn,!0),n.removeEventListener("click",Bt,!0),r.removeEventListener("focus",yn,!0),r.removeEventListener("blur",gn,!1),He.delete(r)}function Ts(e){let{fn:r,deps:n,opts:o}=e;typeof window>"u"||typeof document>"u"||(ys(),(0,En.useEffect)(()=>{let u=(i,c)=>{sn(!!o?.isTextInput,i,c)&&r(G.currentModality!=="pointer")};return Dt.add(u),()=>{Dt.delete(u),gs()}},n))}function hs(e){let{isDisabled:r,onFocusWithin:n,onBlurWithin:o,onFocusWithinChange:u}=e,i=(0,Fe.useRef)({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:f}=Tn(),a=(0,Fe.useCallback)(y=>{y.currentTarget.contains(y.target)&&i.current.isFocusWithin&&!y.currentTarget.contains(y.relatedTarget)&&(i.current.isFocusWithin=!1,f(),o&&o(y),u&&u(!1))},[o,u,f]),E=Sn({onBlur:a}),S=(0,Fe.useCallback)(y=>{if(!y.currentTarget.contains(y.target))return;let O=W(y.target),P=Ee(O);if(!i.current.isFocusWithin&&P===tt(y.nativeEvent)){n&&n(y),u&&u(!0),i.current.isFocusWithin=!0,E(y);let N=y.currentTarget;c(O,"focus",T=>{if(i.current.isFocusWithin&&!et(N,T.target)&&O.defaultView&&typeof O.defaultView.FocusEvent=="function"){let v=new O.defaultView.FocusEvent("blur",{relatedTarget:T.target});Object.defineProperty(v,"target",{value:N}),Object.defineProperty(v,"currentTarget",{value:N});let j=ot(v);a(j)}},{capture:!0})}},[n,u,E,c,a]);return r?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:S,onBlur:a}}}function Tn(){let e=(0,Te.useRef)(new Map),r=(0,Te.useCallback)((u,i,c,f)=>{let a=typeof f=="object"&&f?.once?(...E)=>{e.current.delete(c),c(...E)}:c;e.current.set(c,{type:i,eventTarget:u,options:f}),u.addEventListener(i,a,f)},[]),n=(0,Te.useCallback)((u,i,c,f)=>{let a=e.current.get(c),E=a?.options?.once?a.fn:c;u.removeEventListener(i,E,f),e.current.delete(c)},[]),o=(0,Te.useCallback)(()=>{e.current.forEach((u,i)=>{u.eventTarget.removeEventListener(u.type,i,u.options)}),e.current.clear()},[]);return(0,Te.useEffect)(()=>()=>o(),[o]),{addGlobalListener:r,removeGlobalListener:n,removeAllGlobalListeners:o}}function hn(e={}){let{onHoverStart:r,onHoverChange:n,onHoverEnd:o,isDisabled:u}=e,[i,c]=(0,V.useState)(!1),f=(0,V.useRef)({hoverCount:0,ignoreEmulated:!1}),a=(0,V.useRef)({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current,{addGlobalListener:E,removeAllGlobalListeners:S}=Tn(),y=(0,V.useCallback)(()=>{f.current.ignoreEmulated=!0,setTimeout(()=>{f.current.ignoreEmulated=!1},50)},[]);(0,V.useEffect)(()=>{let T=j=>{j.pointerType==="touch"&&y()};if(typeof document>"u")return;let v=f.current;return v.hoverCount++,typeof PointerEvent<"u"?document.addEventListener("pointerup",T):Ce&&document.addEventListener("touchend",y),()=>{v.hoverCount--,v.hoverCount===0&&(typeof PointerEvent<"u"?document.removeEventListener("pointerup",T):Ce&&document.removeEventListener("touchend",y))}},[y]);let O=(0,V.useCallback)((T,v)=>{u||v==="touch"||a.isHovered||!(T.currentTarget&&T.currentTarget.contains(T.target))||(a.isHovered=!0,a.pointerType=v,a.target=T.currentTarget,E(W(T.target instanceof Element?T.target:null),"pointerover",j=>{a.isHovered&&a.target&&!et(a.target,j.target)&&P(j,j.pointerType)},{capture:!0}),r?.({type:"hoverstart",target:T.currentTarget,pointerType:v}),n?.(!0),c(!0))},[u,r,n,E,a]),P=(0,V.useCallback)((T,v)=>{v==="touch"||!a.isHovered||!a.target||(a.isHovered=!1,a.pointerType="",a.target=null,S(),o?.({type:"hoverend",target:T.currentTarget,pointerType:v}),n?.(!1),c(!1))},[o,n,S,a.target,a]),N=(0,V.useMemo)(()=>{let T={};return typeof PointerEvent<"u"?(T.onPointerEnter=v=>{f.current.ignoreEmulated&&v.pointerType==="mouse"||O(v,v.pointerType)},T.onPointerLeave=v=>{!u&&v.currentTarget instanceof Element&&v.currentTarget.contains(v.target)&&P(v,v.pointerType)}):Ce&&(T.onTouchStart=()=>{a.ignoreEmulatedMouseEvents=!0},T.onMouseEnter=v=>{!a.ignoreEmulatedMouseEvents&&!f.current.ignoreEmulated&&O(v.nativeEvent,"mouse"),a.ignoreEmulatedMouseEvents=!1},T.onMouseLeave=v=>{!u&&v.currentTarget.contains(v.target)&&P(v.nativeEvent,"mouse")}),T},[u,O,P,a]);return(0,V.useEffect)(()=>{u&&a.isHovered&&P({currentTarget:a.target},a.pointerType)},[u,P,a.isHovered,a.pointerType,a.target]),{hoverProps:N,isHovered:i}}var cn={prefix:String(Math.round(Math.random()*1e10)),current:0},at=new Map,st=typeof FinalizationRegistry<"u"?new FinalizationRegistry(e=>{at.delete(e)}):null;function bn(e={}){let{prefix:r="necto",defaultId:n}=e,[o,u]=(0,X.useState)(()=>n),i=(0,X.useRef)(null),c=(0,X.useRef)({}),f=(()=>{if(n)return n;let a=typeof X.default.useId=="function"?(0,X.useId)():String(++cn.current);return`${Ce?r:`${r}${cn.prefix}`}-${a}`})();return(0,X.useEffect)(()=>{if(typeof window<"u"&&window.document?.createElement){let a=at.get(f)||[],E={current:i.current};a.some(S=>S===E)||at.set(f,[...a,E])}return st&&st.register(c.current,f),()=>{st&&st.unregister(c.current),at.delete(f)}},[f]),(0,X.useEffect)(()=>{let a=i.current;a&&(u(a),i.current=null)},[]),f}function bs(e){return{keyboardProps:e.isDisabled?{}:{onKeyDown:e.onKeyDown?Mt(r=>e.onKeyDown?.(r.nativeEvent)):void 0,onKeyUp:e.onKeyUp?Mt(r=>e.onKeyUp?.(r.nativeEvent)):void 0}}}function $(e,r,n){return{type:e,pointerType:r,target:n.currentTarget??n.target,shiftKey:n.shiftKey,ctrlKey:n.ctrlKey,metaKey:n.metaKey,altKey:n.altKey}}function _n(e={}){let{isDisabled:r,preventFocusOnPress:n,allowTextSelectionOnPress:o,ref:u,onPress:i,onPressStart:c,onPressEnd:f,onPressChange:a,onPressUp:E,onClick:S}=e,[y,O]=(0,x.useState)(!1),P=(0,x.useRef)(!1),N=(0,x.useRef)(null),T=(0,x.useRef)(!1),v=(0,x.useCallback)(p=>{y!==p&&(O(p),a?.(p))},[y,a]),j=(0,x.useCallback)(p=>{if(!T.current)return;let U=N.current&&N.current instanceof Node&&p.target instanceof Node&&N.current.contains(p.target);if(T.current=!1,v(!1),!o&&N.current instanceof HTMLElement&&ye(N.current),p.target){let oe={...$("pressend","mouse",p),target:p.target};f?.(oe),E?.(oe),U&&i?.(oe)}},[f,E,i,v,o]),re=(0,x.useCallback)(p=>{if(r||p.button!==0||P.current)return;n&&p.preventDefault(),o||rt(p.currentTarget),T.current=!0,N.current=p.currentTarget,v(!0);let U=$("pressstart","mouse",p);c?.(U),window.addEventListener("mouseup",j,{once:!0})},[r,n,o,c,v,j]),ne=(0,x.useCallback)(p=>{if(r||p.button!==0||!T.current)return;T.current=!1,v(!1),!o&&p.currentTarget instanceof HTMLElement&&ye(p.currentTarget);let U=$("pressend","mouse",p);f?.(U),E?.(U),p.currentTarget instanceof Node&&p.currentTarget.contains(p.target)&&i?.($("press","mouse",p))},[r,i,f,E,v,o]),ue=(0,x.useCallback)(p=>{y&&(v(!1),f?.($("pressend","mouse",p)),!o&&p.currentTarget instanceof HTMLElement&&ye(p.currentTarget))},[y,v,f,o]),ce=(0,x.useCallback)(p=>{T.current&&!y&&(v(!0),c?.($("pressstart","mouse",p)))},[y,c,v]),Y=(0,x.useCallback)(p=>{if(!T.current)return;T.current=!1,v(!1),!o&&N.current instanceof HTMLElement&&ye(N.current);let U={...$("pressend","touch",p),target:p.target};f?.(U),E?.(U)},[f,E,v,o]),K=(0,x.useCallback)(p=>{if(!T.current)return;T.current=!1,v(!1),!o&&N.current instanceof HTMLElement&&ye(N.current);let U={...$("pressend","touch",p),target:p.target};f?.(U)},[f,v,o]),Z=(0,x.useCallback)(p=>{r||(o||rt(p.currentTarget),P.current=!0,setTimeout(()=>{P.current=!1},100),T.current=!0,N.current=p.currentTarget,v(!0),c?.($("pressstart","touch",p)),window.addEventListener("touchend",Y,{once:!0}),window.addEventListener("touchcancel",K,{once:!0}))},[r,c,v,o,Y,K]),M=(0,x.useCallback)(p=>{if(r||!T.current)return;T.current=!1,v(!1),!o&&p.currentTarget instanceof HTMLElement&&ye(p.currentTarget);let U=$("pressend","touch",p);f?.(U),E?.(U),p.currentTarget instanceof Node&&p.currentTarget.contains(p.target)&&i?.($("press","touch",p))},[r,i,f,E,v,o]),le=(0,x.useCallback)(p=>{r||(p.key==="Enter"||p.key===" ")&&!y&&(p.key===" "&&p.preventDefault(),o||rt(),v(!0),T.current=!0,c?.($("pressstart","keyboard",p)))},[r,y,c,v,o]),z=(0,x.useCallback)(p=>{if(!r&&(p.key==="Enter"||p.key===" ")&&y){v(!1),T.current=!1,o||ye();let U=$("pressend","keyboard",p);f?.(U),E?.($("pressup","keyboard",p)),i?.($("press","keyboard",p))}},[r,y,i,f,E,v,o]),J=(0,x.useCallback)(p=>{if(r){p.preventDefault();return}P.current||S?.(p)},[r,S]);(0,x.useEffect)(()=>()=>{window.removeEventListener("mouseup",j),window.removeEventListener("touchend",Y),window.removeEventListener("touchcancel",K)},[j,Y,K]);let fe=(0,x.useMemo)(()=>({onMouseDown:re,onMouseUp:ne,onMouseLeave:ue,onMouseEnter:ce,onTouchStart:Z,onTouchEnd:M,onKeyDown:le,onKeyUp:z,onClick:J}),[re,ne,ue,ce,Z,M,le,z,J]);return(0,x.useEffect)(()=>{let p=u?.current;p&&p instanceof ve(p).Element&&ve(p).getComputedStyle(p).touchAction==="auto"&&(p.style.touchAction="pan-x pan-y pinch-zoom")},[u]),{pressProps:fe,isPressed:y}}function wn(e){let{className:r,style:n,children:o,defaultClassName:u="necto",defaultChildren:i,defaultStyle:c,values:f}=e;return(0,Rn.useMemo)(()=>{let a=typeof r=="function"?r({...f,defaultClassName:u}):`${u} ${r}`,E=typeof n=="function"?n({...f,defaultStyle:c||{}}):{...c,...n},S=typeof o=="function"?o({...f,defaultChildren:i}):o??i;return{className:a,style:E,children:S}},[r,n,o,u,i,c,f])}function _s(e){let{context:r,slot:n}=e,o=(0,Cn.useContext)(r);if(n===null)return null;if(o&&typeof o=="object"&&"slots"in o&&o.slots){let u=n||Symbol("default");if(!o.slots[u]){let i=new Intl.ListFormat().format(Object.keys(o.slots).map(f=>`"${f}"`)),c=n?`Invalid slot name: "${n}". This slot is not recognized. Please refer to the component's documentation for valid slot names.`:"A slot prop is required. You must provide a valid slot name to render content in this area.";throw new Error(`${c} Valid slot names are ${i}.`)}return o.slots[u]}return o}function Rs(e={}){let{ref:r,context:n}=e;(typeof document<"u"?An.useLayoutEffect:()=>{})(()=>{if(n&&n.ref&&r)return n.ref.current=r.current,()=>{n.ref&&(n.ref.current=null)}})}function Sn(e){let{onBlur:r}=e,n=(0,Ne.useRef)({isFocused:!1,observer:null});(0,Ne.useLayoutEffect)(()=>{let u=n.current;return()=>{u.observer&&(u.observer.disconnect(),u.observer=null)}},[]);let o=ws(u=>{r?.(u)});return(0,Ne.useCallback)(u=>{if(u.target instanceof HTMLButtonElement||u.target instanceof HTMLInputElement||u.target instanceof HTMLTextAreaElement||u.target instanceof HTMLSelectElement){n.current.isFocused=!0;let i=u.target,c=f=>{if(n.current.isFocused=!1,i.disabled){let a=ot(f);o(a)}n.current.observer&&(n.current.observer.disconnect(),n.current.observer=null)};i.addEventListener("focusout",c,{once:!0}),n.current.observer=new MutationObserver(()=>{if(n.current.isFocused&&i.disabled){n.current.observer?.disconnect();let f=i===document.activeElement?null:document.activeElement;i.dispatchEvent(new FocusEvent("blur",{relatedTarget:f})),i.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:f}))}}),n.current.observer.observe(i,{attributes:!0,attributeFilter:["disabled"]})}},[o])}function ws(e){let r=(0,be.useRef)(e);return(typeof window<"u"?be.useLayoutEffect:be.useEffect)(()=>{r.current=e},[e]),(0,be.useCallback)((...n)=>r.current(...n),[])}function We(e,r=!1){let n=e.replace(/\p{Lu}/gu,o=>`-${o.toLowerCase()}`);return r?n:n.startsWith("-")?n.slice(1):n}We.reverse=e=>e.replace(/-\p{Ll}/gu,r=>r.slice(1).toUpperCase());var Pn=["rel","href","ping","target","download","hrefLang","referrerPolicy"],Ln=["id","form","name","value","formAction","formEncType","formMethod","formTarget","formNoValidate"];function In({prefix:e=":sprocket:=",component:r,variant:n,state:o,unique:u,obscure:i}){if(!r)throw new Error("Component context is required!");let c=[e+We(r,!1)];return n&&c.push(We(n,!1)),Array.isArray(o)&&o.length&&c.push(...o.map(f=>We(f,!1))),u&&c.push(Math.random().toString(36).slice(2,8)),i&&c.push(Math.random().toString(36).slice(2,16)),c.join("--")}var Ut=te.Button;function ft(e,r){let{rel:n,href:o,target:u,autoFocus:i,focusDisabled:c,preventFocusOnPress:f,isDisabled:a=!1,type:E=Ut,as:S=Ut,elementType:y=S||Ut,onClick:O,onPress:P,onPressStart:N,onPressEnd:T,onPressUp:v,onPressChange:j}=e,re;y===te.Button?re={type:E,disabled:a}:re={role:"button",href:y===te.A&&!a?o:void 0,target:y===te.A?u:void 0,type:y===te.Input?E:void 0,disabled:y===te.Input?a:void 0,"aria-disabled":!a||y===te.Input?void 0:a,rel:y===te.A?n:void 0};let{hoverProps:ne,isHovered:ue}=hn({...e,isDisabled:a}),{focusProps:ce,isFocused:Y,isFocusVisible:K}=mn({autoFocus:i}),{focusableProps:Z}=pn(e,r),{pressProps:M,isPressed:le}=_n({ref:r,isDisabled:a,preventFocusOnPress:f,onPressStart:N,onPressEnd:T,onPressChange:j,onPress:P,onPressUp:v,onClick:O});c&&(Z.tabIndex=a?-1:Z.tabIndex);let z=se(Z,M,ne,ce,on(e,{allowLabelableProps:!0,allowedLabelableProps:new Set([]),allowedLinkProps:new Set(Pn),extraAllowedProps:new Set(Ln)}));return{isFocused:Y,isPressed:le,isHovered:ue,isDisabled:a,isFocusVisible:K,elementType:y,buttonProps:se(z,re)}}var kn=L(I(),1),Me=(0,kn.createContext)(null);var Nn=L(I(),1);function Mn(){return(0,Nn.useContext)(Me)}function dt(e,r=!0){let n=e.replace(/\p{Lu}/gu,o=>`-${o.toLowerCase()}`);return r?n:n.startsWith("-")?n.slice(1):n}dt.reverse=e=>e.replace(/-\p{Ll}/gu,r=>r.slice(1).toUpperCase());var Ye=L(I(),1);var ie=L(I(),1),Un=L(Et(),1),Ss=te.Div,jn=({as:e,asChild:r,children:n,...o},u)=>{let i=e??Ss;if(r){let c=ie.Children.only(n);return(0,ie.isValidElement)(c)?(0,ie.cloneElement)(c,{...o,ref:c.ref??u}):null}return(0,Un.jsx)(i,{ref:u,...o,children:n})},Hn=Object.assign((0,ie.forwardRef)(jn),Be.HTML_TAGS.reduce((e,r)=>(e[r]=(0,ie.forwardRef)((n,o)=>jn({...n,as:r},o)),e),{}));var Yn=L(Et(),1),Wn="Button";function Fn(e,r){[e,r]=ln({props:e,ref:r,context:Me});let{buttonProps:n,isHovered:o,isPressed:u,isFocused:i,isDisabled:c,elementType:f,isFocusVisible:a}=ft(e,r),E=bn({defaultId:n.id}),S=wn({...e,values:{isHovered:o,isPressed:u,isFocused:i,isFocusVisible:a,isDisabled:c},defaultClassName:In({component:Wn}),style:O=>({...e.style instanceof Function?e.style(O):e.style})}),y=(0,Ye.useMemo)(()=>{let O={hover:o,focus:i,focusVisible:a,disabled:c,pressed:u},P={},N=[];for(let[T,v]of Object.entries(O))typeof v=="boolean"&&(P[`data-${dt(T)}`]=v?"true":void 0,v&&N.push(dt(T)));return{...P,"data-sprocket-state":N.join(" ")}},[o,i,a,c,u]);return(0,Yn.jsx)(Hn,{ref:r,as:f,...S,...se(n,y),id:E,slot:e.slot||void 0,children:S.children})}var Ft=Object.assign((0,Ye.forwardRef)((e,r)=>Fn(e,r)),{Root:(0,Ye.forwardRef)((e,r)=>Fn(e,r))});Ft.displayName=Wn;})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useHover as _,usePress as h,useFocusRing as j,useFocusable as V}from"@necto-react/hooks";import{HTMLElements as s}from"@necto/dom";import{mergeProps as k}from"@necto/mergers";import{filterDOMProps as G}from"@necto-react/helpers";import{ANCHOR_ELEMENT_PROPS as W,ALLOWED_EXTERNAL_PROPS as X}from"shared";var E=s.Button;function x(t,o){let{rel:d,href:u,target:i,autoFocus:a,focusDisabled:p,preventFocusOnPress:y,isDisabled:e=!1,type:l=E,as:c=E,elementType:n=c||E,onClick:f,onPress:B,onPressStart:P,onPressEnd:b,onPressUp:m,onPressChange:w}=t,T;n===s.Button?T={type:l,disabled:e}:T={role:"button",href:n===s.A&&!e?u:void 0,target:n===s.A?i:void 0,type:n===s.Input?l:void 0,disabled:n===s.Input?e:void 0,"aria-disabled":!e||n===s.Input?void 0:e,rel:n===s.A?d:void 0};let{hoverProps:H,isHovered:S}=_({...t,isDisabled:e}),{focusProps:M,isFocused:U,isFocusVisible:v}=j({autoFocus:a}),{focusableProps:R}=V(t,o),{pressProps:I,isPressed:N}=h({ref:o,isDisabled:e,preventFocusOnPress:y,onPressStart:P,onPressEnd:b,onPressChange:w,onPress:B,onPressUp:m,onClick:f});p&&(R.tabIndex=e?-1:R.tabIndex);let D=k(R,I,H,M,G(t,{allowLabelableProps:!0,allowedLabelableProps:new Set([]),allowedLinkProps:new Set(W),extraAllowedProps:new Set(X)}));return{isFocused:U,isPressed:N,isHovered:S,isDisabled:e,isFocusVisible:v,elementType:n,buttonProps:k(D,T)}}import{createContext as $}from"react";var r=$(null);import{useContext as q}from"react";function A(){return q(r)}import{kebabCase as F}from"@necto/strings";import{mergeProps as z}from"@necto/mergers";import{forwardRef as O,useMemo as J}from"react";import{buildInternalIdentifier as K}from"shared";import{Primitive as Q}from"@necto-react/components";import{useContextProps as Y,useRenderer as Z,useId as tt}from"@necto-react/hooks";import{jsx as et}from"react/jsx-runtime";var g="Button";function L(t,o){[t,o]=Y({props:t,ref:o,context:r});let{buttonProps:d,isHovered:u,isPressed:i,isFocused:a,isDisabled:p,elementType:y,isFocusVisible:e}=x(t,o),l=tt({defaultId:d.id}),c=Z({...t,values:{isHovered:u,isPressed:i,isFocused:a,isFocusVisible:e,isDisabled:p},defaultClassName:K({component:g}),style:f=>({...t.style instanceof Function?t.style(f):t.style})}),n=J(()=>{let f={hover:u,focus:a,focusVisible:e,disabled:p,pressed:i},B={},P=[];for(let[b,m]of Object.entries(f))typeof m=="boolean"&&(B[`data-${F(b)}`]=m?"true":void 0,m&&P.push(F(b)));return{...B,"data-sprocket-state":P.join(" ")}},[u,a,e,p,i]);return et(Q,{ref:o,as:y,...c,...z(d,n),id:l,slot:t.slot||void 0,children:c.children})}var C=Object.assign(O((t,o)=>L(t,o)),{Root:O((t,o)=>L(t,o))});C.displayName=g;export{C as Button,r as ButtonContext,C as SprocketButton,r as SprocketButtonContext,x as useButton,A as useButtonContext,x as useSprocketButton,A as useSprocketButtonContext};
|
package/package.json
CHANGED
|
@@ -1,24 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprocketui-react/button",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Sprocket's standalone React button component.",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.es.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
5
|
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Corinvo OSS Team",
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
9
15
|
"engines": {
|
|
10
16
|
"node": ">=10"
|
|
11
17
|
},
|
|
12
|
-
"
|
|
13
|
-
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup",
|
|
20
|
+
"test": "vitest",
|
|
21
|
+
"dev": "tsup --watch"
|
|
22
|
+
},
|
|
14
23
|
"dependencies": {
|
|
24
|
+
"@necto-react/components": "workspace:*",
|
|
25
|
+
"@necto-react/helpers": "workspace:*",
|
|
26
|
+
"@necto-react/hooks": "workspace:*",
|
|
27
|
+
"@necto-react/types": "workspace:*",
|
|
28
|
+
"@necto/constants": "workspace:*",
|
|
29
|
+
"@necto/dom": "workspace:*",
|
|
30
|
+
"@necto/mergers": "workspace:*",
|
|
15
31
|
"@necto/strings": "^1.1.0",
|
|
16
32
|
"@react-aria/focus": "^3.20.2",
|
|
33
|
+
"@sprocketui-types/button": "workspace:*",
|
|
17
34
|
"react-aria": "^3.39.0",
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
35
|
+
"shared": "workspace:*"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
39
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
43
|
+
"@testing-library/react": "^16.3.0",
|
|
44
|
+
"@types/react": "^19.1.2",
|
|
45
|
+
"@types/react-dom": "^19.1.2",
|
|
46
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
47
|
+
"react": "^19.1.0",
|
|
48
|
+
"react-dom": "^19.1.0",
|
|
49
|
+
"tsup": "^8.4.0",
|
|
50
|
+
"vitest": "^3.2.4"
|
|
23
51
|
}
|
|
24
|
-
}
|
|
52
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Corinvo
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '@testing-library/jest-dom';
|
|
3
|
-
import { describe, it, expect } from 'vitest';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import { Button } from '../../src/components/Button/Button';
|
|
6
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
7
|
-
|
|
8
|
-
describe('Button Component - Data Attribute Tests', () => {
|
|
9
|
-
it('renders with default data attributes', () => {
|
|
10
|
-
render(<Button>Test Button</Button>);
|
|
11
|
-
const button = screen.getByRole('button');
|
|
12
|
-
|
|
13
|
-
expect(button).not.toHaveAttribute('data-disabled');
|
|
14
|
-
expect(button).not.toHaveAttribute('data-focus');
|
|
15
|
-
expect(button).not.toHaveAttribute('data-hover');
|
|
16
|
-
expect(button).toHaveAttribute('data-sprocket-state', '');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('applies data-disabled attribute when disabled prop is true', () => {
|
|
20
|
-
render(<Button disabled>Test Button</Button>);
|
|
21
|
-
const button = screen.getByRole('button');
|
|
22
|
-
|
|
23
|
-
expect(button).toHaveAttribute('data-disabled', 'true');
|
|
24
|
-
expect(button).not.toHaveAttribute('data-focus');
|
|
25
|
-
expect(button).not.toHaveAttribute('data-hover');
|
|
26
|
-
expect(button).toHaveAttribute('data-sprocket-state', 'disabled');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('applies data-hover attribute on mouseenter and removes on mouseleave', () => {
|
|
30
|
-
render(<Button>Test Button</Button>);
|
|
31
|
-
const button = screen.getByRole('button');
|
|
32
|
-
|
|
33
|
-
fireEvent.mouseEnter(button);
|
|
34
|
-
expect(button).toHaveAttribute('data-hover', 'true');
|
|
35
|
-
expect(button).not.toHaveAttribute('data-focus');
|
|
36
|
-
expect(button).not.toHaveAttribute('data-disabled');
|
|
37
|
-
expect(button).toHaveAttribute('data-sprocket-state', 'hover');
|
|
38
|
-
|
|
39
|
-
fireEvent.mouseLeave(button);
|
|
40
|
-
expect(button).not.toHaveAttribute('data-hover');
|
|
41
|
-
expect(button).not.toHaveAttribute('data-focus');
|
|
42
|
-
expect(button).not.toHaveAttribute('data-disabled');
|
|
43
|
-
expect(button).toHaveAttribute('data-sprocket-state', '');
|
|
44
|
-
});
|
|
45
|
-
});
|
package/dist/index.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import * as react from 'react';
|
|
10
|
-
import { ElementType, ComponentPropsWithoutRef, RefObject, HTMLAttributes } from 'react';
|
|
11
|
-
|
|
12
|
-
declare enum ButtonTypeValues {
|
|
13
|
-
Button = "button",
|
|
14
|
-
Submit = "submit",
|
|
15
|
-
Reset = "reset"
|
|
16
|
-
}
|
|
17
|
-
type ButtonTypes = `${ButtonTypeValues}`;
|
|
18
|
-
|
|
19
|
-
declare const DEFAULT_BUTTON_TAG$1: "button";
|
|
20
|
-
type ButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG$1> = ComponentPropsWithoutRef<TTag> & {
|
|
21
|
-
as?: TTag;
|
|
22
|
-
type?: ButtonTypes;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
autoFocus?: boolean;
|
|
25
|
-
slot?: Record<string, any>;
|
|
26
|
-
};
|
|
27
|
-
declare const Button: react.ForwardRefExoticComponent<Omit<ButtonProps<ElementType>, "ref"> & react.RefAttributes<"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "center" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noindex" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "search" | "slot" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "template" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | react.ComponentClass<any, any> | react.FunctionComponent<any>>> & {
|
|
28
|
-
Root: react.ForwardRefExoticComponent<Omit<ButtonProps<ElementType>, "ref"> & react.RefAttributes<"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "center" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noindex" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "search" | "slot" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "template" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | react.ComponentClass<any, any> | react.FunctionComponent<any>>>;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
declare const DEFAULT_BUTTON_TAG: "button";
|
|
32
|
-
interface UseButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> {
|
|
33
|
-
as?: TTag;
|
|
34
|
-
type?: ButtonTypes;
|
|
35
|
-
disabled?: boolean;
|
|
36
|
-
isDisabled?: boolean;
|
|
37
|
-
autoFocus?: boolean;
|
|
38
|
-
slot?: Record<string, any>;
|
|
39
|
-
elementType?: string;
|
|
40
|
-
preventFocusOnPress?: boolean;
|
|
41
|
-
allowFocusWhenDisabled?: boolean;
|
|
42
|
-
href?: string;
|
|
43
|
-
target?: string;
|
|
44
|
-
rel?: string;
|
|
45
|
-
onClick?: (e: any) => void;
|
|
46
|
-
onPress?: (e: any) => void;
|
|
47
|
-
onPressStart?: (e: any) => void;
|
|
48
|
-
onPressEnd?: (e: any) => void;
|
|
49
|
-
onPressUp?: (e: any) => void;
|
|
50
|
-
onPressChange?: (isPressed: boolean) => void;
|
|
51
|
-
[key: string]: any;
|
|
52
|
-
}
|
|
53
|
-
interface UseButtonResult<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> {
|
|
54
|
-
buttonProps: HTMLAttributes<HTMLElement>;
|
|
55
|
-
Tag: TTag;
|
|
56
|
-
combinedSlot: Record<string, any>;
|
|
57
|
-
isPressed: boolean;
|
|
58
|
-
isHovered: boolean;
|
|
59
|
-
isFocused: boolean;
|
|
60
|
-
isFocusVisible: boolean;
|
|
61
|
-
isDisabled: boolean;
|
|
62
|
-
id: string;
|
|
63
|
-
}
|
|
64
|
-
declare function useButton<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: UseButtonProps<TTag>, ref: RefObject<HTMLElement> | undefined): UseButtonResult<TTag>;
|
|
65
|
-
|
|
66
|
-
export { Button, ButtonTypeValues, useButton };
|
|
67
|
-
export type { ButtonTypes };
|
package/dist/index.es.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import{jsx as e}from"react/jsx-runtime";import{kebabCase as o}from"@necto/strings";import{useFocusable as t}from"react-aria";import{mergeReactProps as s}from"@necto/props-merge";import{filterDOMProps as r}from"@necto-react/helpers";import{ANCHOR_ELEMENT_PROPS as i}from"@necto/constants";import{useMemo as n,forwardRef as a}from"react";import{useId as l,useDisabled as d,useFocusRing as p,useHover as u,usePress as c}from"@necto-react/hooks";var b,f=((b={}).Button="button",b.Submit="submit",b.Reset="reset",b);let m="button",P=f.Button;function v(e,a){let b,{as:f=m,elementType:v=f,disabled:h,isDisabled:g,autoFocus:S,slot:y={},preventFocusOnPress:F,allowFocusWhenDisabled:k,href:w,target:D,rel:j,type:x=P,onClick:B,onPress:C,onPressStart:O,onPressEnd:T,onPressUp:V,onPressChange:E,...H}=e,I=l(),N=d("general",h||g)||!1,{focusProps:R,isFocused:U,isFocusVisible:A}=p({autoFocus:S}),{isHovered:L,hoverProps:W}=u({...e,isDisabled:N}),{pressProps:$,isPressed:q}=c({onPressStart:O,onPressEnd:T,onPressChange:E,onPress:C,onPressUp:V,onClick:B,isDisabled:N,preventFocusOnPress:F,ref:a});b="button"===v?{type:x,disabled:N}:{role:"button",href:"a"!==v||N?void 0:w,target:"a"===v?D:void 0,type:"input"===v?x:void 0,disabled:"input"===v?N:void 0,"aria-disabled":N&&"input"!==v?N:void 0,rel:"a"===v?j:void 0};let{focusableProps:z}=t(e,a);k&&(z.tabIndex=N?-1:z.tabIndex);let G=n((()=>({...y,hover:L,focus:U,focusVisible:A,disabled:N,pressed:q})),[y,L,U,A,N,q]),J=n((()=>{let e={};for(let[t,s]of Object.entries(G))"boolean"==typeof s&&(e[`data-${o(t)}`]=s?"true":void 0);return e}),[G]),K=s(z,$,r(e,{includeLabelableProps:!0,labelablePropsSet:new Set([]),linkPropsSet:new Set(i),additionalAllowedProps:new Set(["id","className","style","data-*","aria-*"])})),M=n((()=>s({id:I,"data-sprocket-state":[L&&"hover",U&&"focus",q&&"pressed",N&&"disabled"].filter(Boolean).join(" ")||"",...J,disabled:N},b,K,R,W,"button"!==f&&f!==m?{role:"button"}:{type:x})),[L,U,q,N,J,b,K,R,W,f,x,I]);return{Tag:f,buttonProps:M,combinedSlot:G,isPressed:q,isHovered:L,isFocused:U,isFocusVisible:A,isDisabled:N,id:I}}function h(o,t){let{children:s,...r}=o,{buttonProps:i,Tag:n,combinedSlot:a}=v(r,t);return e(n,{ref:t,...i,children:"function"==typeof s?s(a):s})}let g=Object.assign(a(h),{Root:a(h)});g.displayName="Button";export{g as Button,v as useButton};
|
|
10
|
-
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/types.ts","../src/hooks/useButton.ts","../src/components/Button.tsx"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport enum ButtonTypeValues {\n Button = 'button',\n Submit = 'submit',\n Reset = 'reset',\n};\nexport type ButtonTypes = `${ButtonTypeValues}`;\n","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n'use client';\n\nimport { kebabCase } from \"@necto/strings\";\nimport { useFocusable } from \"react-aria\"; // Temp use, will be removed in later version\nimport { ButtonTypeValues } from \"../types\";\nimport { mergeReactProps } from \"@necto/props-merge\";\nimport { filterDOMProps } from \"@necto-react/helpers\";\nimport { ANCHOR_ELEMENT_PROPS } from \"@necto/constants\";\nimport { HTMLAttributes, ElementType, Ref, useMemo } from \"react\";\nimport { usePress, useHover, useDisabled, useFocusRing, useId } from '@necto-react/hooks';\n\nimport type { RefObject } from \"react\";\nimport type { ButtonTypes } from \"../types\";\nimport type { FocusableElement } from \"@necto-react/types\";\n\nconst DEFAULT_BUTTON_TAG = 'button' as const;\nconst DEFAULT_BUTTON_TYPE = ButtonTypeValues.Button as const;\n\nexport interface UseButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> {\n as?: TTag;\n type?: ButtonTypes;\n disabled?: boolean;\n isDisabled?: boolean;\n autoFocus?: boolean;\n slot?: Record<string, any>;\n elementType?: string;\n preventFocusOnPress?: boolean;\n allowFocusWhenDisabled?: boolean;\n href?: string;\n target?: string;\n rel?: string;\n onClick?: (e: any) => void;\n onPress?: (e: any) => void;\n onPressStart?: (e: any) => void;\n onPressEnd?: (e: any) => void;\n onPressUp?: (e: any) => void;\n onPressChange?: (isPressed: boolean) => void;\n [key: string]: any;\n}\n\nexport interface UseButtonResult<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> {\n buttonProps: HTMLAttributes<HTMLElement>;\n Tag: TTag;\n combinedSlot: Record<string, any>;\n isPressed: boolean;\n isHovered: boolean;\n isFocused: boolean;\n isFocusVisible: boolean;\n isDisabled: boolean;\n id: string;\n}\n\nexport function useButton<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(\n props: UseButtonProps<TTag>,\n ref: RefObject<HTMLElement> | undefined\n): UseButtonResult<TTag> {\n const {\n as: Tag = DEFAULT_BUTTON_TAG as TTag,\n elementType = Tag as string,\n disabled: propDisabled,\n isDisabled: propIsDisabled,\n autoFocus,\n slot = {},\n preventFocusOnPress,\n allowFocusWhenDisabled,\n href,\n target,\n rel,\n type = DEFAULT_BUTTON_TYPE,\n onClick,\n onPress,\n onPressStart,\n onPressEnd,\n onPressUp,\n onPressChange,\n ...restProps\n } = props;\n\n const id = useId();\n const isDisabled = useDisabled('general', propDisabled || propIsDisabled) || false;\n const { focusProps, isFocused, isFocusVisible } = useFocusRing({ autoFocus });\n const { isHovered, hoverProps } = useHover({ ...props, isDisabled });\n const { pressProps, isPressed } = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick,\n isDisabled,\n preventFocusOnPress,\n ref: ref as any // Temp type error remediation\n });\n\n // Additional props based on element type\n let additionalProps;\n if (elementType === 'button') {\n additionalProps = {\n type,\n disabled: isDisabled\n };\n } else {\n additionalProps = {\n role: 'button',\n href: elementType === 'a' && !isDisabled ? href : undefined,\n target: elementType === 'a' ? target : undefined,\n type: elementType === 'input' ? type : undefined,\n disabled: elementType === 'input' ? isDisabled : undefined,\n 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,\n rel: elementType === 'a' ? rel : undefined\n };\n }\n\n // Handle focusable props\n const { focusableProps } = useFocusable(props, ref as RefObject<FocusableElement>);\n if (allowFocusWhenDisabled) {\n focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;\n }\n\n // Combine slot props\n const combinedSlot = useMemo(() => ({\n ...slot,\n hover: isHovered,\n focus: isFocused,\n focusVisible: isFocusVisible,\n disabled: isDisabled,\n pressed: isPressed\n }), [slot, isHovered, isFocused, isFocusVisible, isDisabled, isPressed]);\n\n // Generate data attributes\n const dataAttributes = useMemo(() => {\n const attributes: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(combinedSlot)) {\n if (typeof value === 'boolean') {\n attributes[`data-${kebabCase(key)}`] = value ? 'true' : undefined;\n }\n }\n\n return attributes;\n }, [combinedSlot]);\n\n let baseButtonProps = mergeReactProps(focusableProps, pressProps, filterDOMProps(props, {\n includeLabelableProps: true,\n labelablePropsSet: new Set([ ]), // Keep this empty for now,\n linkPropsSet: new Set(ANCHOR_ELEMENT_PROPS),\n additionalAllowedProps: new Set(['id', 'className', 'style', 'data-*', 'aria-*'])\n }));\n\n const buttonProps = useMemo(() =>\n mergeReactProps(\n {\n id,\n 'data-sprocket-state': [\n isHovered && 'hover',\n isFocused && 'focus',\n isPressed && 'pressed',\n isDisabled && 'disabled',\n ]\n .filter(Boolean)\n .join(' ') || '',\n ...dataAttributes,\n disabled: isDisabled,\n },\n additionalProps,\n baseButtonProps,\n focusProps,\n hoverProps,\n Tag !== 'button' && Tag !== DEFAULT_BUTTON_TAG\n ? { role: 'button' }\n : { type: type as any }\n ),\n [isHovered, isFocused, isPressed, isDisabled, dataAttributes, additionalProps, baseButtonProps, focusProps, hoverProps, Tag, type, id]\n );\n\n return {\n Tag,\n buttonProps,\n combinedSlot,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n id\n };\n}\n","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n'use client';\n\nimport { useButton } from '../hooks/useButton';\nimport { forwardRef, ElementType, ComponentPropsWithoutRef, Ref } from 'react';\n\nimport type { ButtonTypes } from \"../types\";\n\nconst BUTTON_NAME = 'Button' as const;\nconst DEFAULT_BUTTON_TAG = 'button' as const;\n\ntype ButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = ComponentPropsWithoutRef<TTag> & {\n as?: TTag;\n type?: ButtonTypes;\n disabled?: boolean;\n autoFocus?: boolean;\n slot?: Record<string, any>;\n};\n\nfunction ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(\n props: ButtonProps<TTag>,\n ref: Ref<TTag>\n) {\n const { children, ...restProps } = props;\n const { buttonProps, Tag, combinedSlot } = useButton(restProps, ref as any);\n\n return (\n <Tag ref={ref} {...buttonProps}>\n {typeof children === 'function' ? children(combinedSlot) : children}\n </Tag>\n );\n}\n\nconst Button = Object.assign(forwardRef(ButtonFn), { Root: forwardRef(ButtonFn) });\n\nButton.displayName = BUTTON_NAME;\n\nexport { Button };"],"names":["ButtonTypeValues","ButtonTypeValues1","DEFAULT_BUTTON_TAG","DEFAULT_BUTTON_TYPE","Button","useButton","props","ref","additionalProps","as","Tag","elementType","disabled","propDisabled","isDisabled","propIsDisabled","autoFocus","slot","preventFocusOnPress","allowFocusWhenDisabled","href","target","rel","type","onClick","onPress","onPressStart","onPressEnd","onPressUp","onPressChange","restProps","id","useId","useDisabled","focusProps","isFocused","isFocusVisible","useFocusRing","isHovered","hoverProps","useHover","pressProps","isPressed","usePress","role","undefined","focusableProps","useFocusable","tabIndex","combinedSlot","useMemo","hover","focus","focusVisible","pressed","dataAttributes","attributes","key","value","Object","entries","kebabCase","baseButtonProps","mergeReactProps","filterDOMProps","includeLabelableProps","labelablePropsSet","Set","linkPropsSet","ANCHOR_ELEMENT_PROPS","additionalAllowedProps","buttonProps","filter","Boolean","join","ButtonFn","children","_jsx","assign","forwardRef","Root","displayName"],"mappings":";;;;;;;;8bAQYA,CAALC,CAAAA,CAAAA,CAAAA,CAAAA,CAAKD,EAAAA,CAAAA,CAAAA,CAAAA,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,MAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CCeZ,IAAME,CAAqB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACrBC,EAAsBH,CAAiBI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAoCtC,SAASC,CACdC,CAAAA,CAAAA,CACAC,CAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAuCIC,GAtCFC,CAAIC,CAAAA,CAAAA,CAAAA,CAAMR,EAA0BS,CACpCA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAcD,EACdE,CAAUC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CACVC,WAAYC,CAAcC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAC1BA,EAASC,CACTA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,CAAE,CAAAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAA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A,CAAAA,CAAOmB,OAAOC,CAAWJ,CAAAA,CAAAA,CAAAA,CAAW,CAAEK,CAAMD,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAWJ,KAEtEvE,CAAO6E,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CA3Ba"}
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
"use strict";var e,s=require("react/jsx-runtime"),t=require("@necto/strings"),o=require("react-aria"),r=require("@necto/props-merge"),i=require("@necto-react/helpers"),n=require("@necto/constants"),a=require("react"),u=require("@necto-react/hooks"),l=((e={}).Button="button",e.Submit="submit",e.Reset="reset",e);let d="button",c=l.Button;function b(e,s){let l,{as:b=d,elementType:p=b,disabled:P,isDisabled:f,autoFocus:v,slot:m={},preventFocusOnPress:g,allowFocusWhenDisabled:h,href:F,target:S,rel:y,type:R=c,onClick:q,onPress:w,onPressStart:D,onPressEnd:O,onPressUp:k,onPressChange:x,...B}=e,C=u.useId(),j=u.useDisabled("general",P||f)||!1,{focusProps:E,isFocused:M,isFocusVisible:H}=u.useFocusRing({autoFocus:v}),{isHovered:N,hoverProps:T}=u.useHover({...e,isDisabled:j}),{pressProps:I,isPressed:V}=u.usePress({onPressStart:D,onPressEnd:O,onPressChange:x,onPress:w,onPressUp:k,onClick:q,isDisabled:j,preventFocusOnPress:g,ref:s});l="button"===p?{type:R,disabled:j}:{role:"button",href:"a"!==p||j?void 0:F,target:"a"===p?S:void 0,type:"input"===p?R:void 0,disabled:"input"===p?j:void 0,"aria-disabled":j&&"input"!==p?j:void 0,rel:"a"===p?y:void 0};let{focusableProps:A}=o.useFocusable(e,s);h&&(A.tabIndex=j?-1:A.tabIndex);let L=a.useMemo((()=>({...m,hover:N,focus:M,focusVisible:H,disabled:j,pressed:V})),[m,N,M,H,j,V]),U=a.useMemo((()=>{let e={};for(let[s,o]of Object.entries(L))"boolean"==typeof o&&(e[`data-${t.kebabCase(s)}`]=o?"true":void 0);return e}),[L]),_=r.mergeReactProps(A,I,i.filterDOMProps(e,{includeLabelableProps:!0,labelablePropsSet:new Set([]),linkPropsSet:new Set(n.ANCHOR_ELEMENT_PROPS),additionalAllowedProps:new Set(["id","className","style","data-*","aria-*"])})),W=a.useMemo((()=>r.mergeReactProps({id:C,"data-sprocket-state":[N&&"hover",M&&"focus",V&&"pressed",j&&"disabled"].filter(Boolean).join(" ")||"",...U,disabled:j},l,_,E,T,"button"!==b&&b!==d?{role:"button"}:{type:R})),[N,M,V,j,U,l,_,E,T,b,R,C]);return{Tag:b,buttonProps:W,combinedSlot:L,isPressed:V,isHovered:N,isFocused:M,isFocusVisible:H,isDisabled:j,id:C}}function p(e,t){let{children:o,...r}=e,{buttonProps:i,Tag:n,combinedSlot:a}=b(r,t);return s.jsx(n,{ref:t,...i,children:"function"==typeof o?o(a):o})}let P=Object.assign(a.forwardRef(p),{Root:a.forwardRef(p)});P.displayName="Button",exports.Button=P,exports.useButton=b;
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/types.ts","../src/hooks/useButton.ts","../src/components/Button.tsx"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport enum ButtonTypeValues {\n Button = 'button',\n Submit = 'submit',\n Reset = 'reset',\n};\nexport type ButtonTypes = `${ButtonTypeValues}`;\n","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n'use client';\n\nimport { kebabCase } from \"@necto/strings\";\nimport { useFocusable } from \"react-aria\"; // Temp use, will be removed in later version\nimport { ButtonTypeValues } from \"../types\";\nimport { mergeReactProps } from \"@necto/props-merge\";\nimport { filterDOMProps } from \"@necto-react/helpers\";\nimport { ANCHOR_ELEMENT_PROPS } from \"@necto/constants\";\nimport { HTMLAttributes, ElementType, Ref, useMemo } from \"react\";\nimport { usePress, useHover, useDisabled, useFocusRing, useId } from '@necto-react/hooks';\n\nimport type { RefObject } from \"react\";\nimport type { ButtonTypes } from \"../types\";\nimport type { FocusableElement } from \"@necto-react/types\";\n\nconst DEFAULT_BUTTON_TAG = 'button' as const;\nconst DEFAULT_BUTTON_TYPE = ButtonTypeValues.Button as const;\n\nexport interface UseButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> {\n as?: TTag;\n type?: ButtonTypes;\n disabled?: boolean;\n isDisabled?: boolean;\n autoFocus?: boolean;\n slot?: Record<string, any>;\n elementType?: string;\n preventFocusOnPress?: boolean;\n allowFocusWhenDisabled?: boolean;\n href?: string;\n target?: string;\n rel?: string;\n onClick?: (e: any) => void;\n onPress?: (e: any) => void;\n onPressStart?: (e: any) => void;\n onPressEnd?: (e: any) => void;\n onPressUp?: (e: any) => void;\n onPressChange?: (isPressed: boolean) => void;\n [key: string]: any;\n}\n\nexport interface UseButtonResult<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> {\n buttonProps: HTMLAttributes<HTMLElement>;\n Tag: TTag;\n combinedSlot: Record<string, any>;\n isPressed: boolean;\n isHovered: boolean;\n isFocused: boolean;\n isFocusVisible: boolean;\n isDisabled: boolean;\n id: string;\n}\n\nexport function useButton<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(\n props: UseButtonProps<TTag>,\n ref: RefObject<HTMLElement> | undefined\n): UseButtonResult<TTag> {\n const {\n as: Tag = DEFAULT_BUTTON_TAG as TTag,\n elementType = Tag as string,\n disabled: propDisabled,\n isDisabled: propIsDisabled,\n autoFocus,\n slot = {},\n preventFocusOnPress,\n allowFocusWhenDisabled,\n href,\n target,\n rel,\n type = DEFAULT_BUTTON_TYPE,\n onClick,\n onPress,\n onPressStart,\n onPressEnd,\n onPressUp,\n onPressChange,\n ...restProps\n } = props;\n\n const id = useId();\n const isDisabled = useDisabled('general', propDisabled || propIsDisabled) || false;\n const { focusProps, isFocused, isFocusVisible } = useFocusRing({ autoFocus });\n const { isHovered, hoverProps } = useHover({ ...props, isDisabled });\n const { pressProps, isPressed } = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick,\n isDisabled,\n preventFocusOnPress,\n ref: ref as any // Temp type error remediation\n });\n\n // Additional props based on element type\n let additionalProps;\n if (elementType === 'button') {\n additionalProps = {\n type,\n disabled: isDisabled\n };\n } else {\n additionalProps = {\n role: 'button',\n href: elementType === 'a' && !isDisabled ? href : undefined,\n target: elementType === 'a' ? target : undefined,\n type: elementType === 'input' ? type : undefined,\n disabled: elementType === 'input' ? isDisabled : undefined,\n 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,\n rel: elementType === 'a' ? rel : undefined\n };\n }\n\n // Handle focusable props\n const { focusableProps } = useFocusable(props, ref as RefObject<FocusableElement>);\n if (allowFocusWhenDisabled) {\n focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;\n }\n\n // Combine slot props\n const combinedSlot = useMemo(() => ({\n ...slot,\n hover: isHovered,\n focus: isFocused,\n focusVisible: isFocusVisible,\n disabled: isDisabled,\n pressed: isPressed\n }), [slot, isHovered, isFocused, isFocusVisible, isDisabled, isPressed]);\n\n // Generate data attributes\n const dataAttributes = useMemo(() => {\n const attributes: Record<string, string | undefined> = {};\n\n for (const [key, value] of Object.entries(combinedSlot)) {\n if (typeof value === 'boolean') {\n attributes[`data-${kebabCase(key)}`] = value ? 'true' : undefined;\n }\n }\n\n return attributes;\n }, [combinedSlot]);\n\n let baseButtonProps = mergeReactProps(focusableProps, pressProps, filterDOMProps(props, {\n includeLabelableProps: true,\n labelablePropsSet: new Set([ ]), // Keep this empty for now,\n linkPropsSet: new Set(ANCHOR_ELEMENT_PROPS),\n additionalAllowedProps: new Set(['id', 'className', 'style', 'data-*', 'aria-*'])\n }));\n\n const buttonProps = useMemo(() =>\n mergeReactProps(\n {\n id,\n 'data-sprocket-state': [\n isHovered && 'hover',\n isFocused && 'focus',\n isPressed && 'pressed',\n isDisabled && 'disabled',\n ]\n .filter(Boolean)\n .join(' ') || '',\n ...dataAttributes,\n disabled: isDisabled,\n },\n additionalProps,\n baseButtonProps,\n focusProps,\n hoverProps,\n Tag !== 'button' && Tag !== DEFAULT_BUTTON_TAG\n ? { role: 'button' }\n : { type: type as any }\n ),\n [isHovered, isFocused, isPressed, isDisabled, dataAttributes, additionalProps, baseButtonProps, focusProps, hoverProps, Tag, type, id]\n );\n\n return {\n Tag,\n buttonProps,\n combinedSlot,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n id\n };\n}\n","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n'use client';\n\nimport { useButton } from '../hooks/useButton';\nimport { forwardRef, ElementType, ComponentPropsWithoutRef, Ref } from 'react';\n\nimport type { ButtonTypes } from \"../types\";\n\nconst BUTTON_NAME = 'Button' as const;\nconst DEFAULT_BUTTON_TAG = 'button' as const;\n\ntype ButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = ComponentPropsWithoutRef<TTag> & {\n as?: TTag;\n type?: ButtonTypes;\n disabled?: boolean;\n autoFocus?: boolean;\n slot?: Record<string, any>;\n};\n\nfunction ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(\n props: ButtonProps<TTag>,\n ref: Ref<TTag>\n) {\n const { children, ...restProps } = props;\n const { buttonProps, Tag, combinedSlot } = useButton(restProps, ref as any);\n\n return (\n <Tag ref={ref} {...buttonProps}>\n {typeof children === 'function' ? children(combinedSlot) : children}\n </Tag>\n );\n}\n\nconst Button = Object.assign(forwardRef(ButtonFn), { Root: forwardRef(ButtonFn) });\n\nButton.displayName = BUTTON_NAME;\n\nexport { Button };"],"names":["ButtonTypeValues","ButtonTypeValues1","DEFAULT_BUTTON_TAG","DEFAULT_BUTTON_TYPE","Button","useButton","props","ref","additionalProps","as","Tag","elementType","disabled","propDisabled","isDisabled","propIsDisabled","autoFocus","slot","preventFocusOnPress","allowFocusWhenDisabled","href","target","rel","type","onClick","onPress","onPressStart","onPressEnd","onPressUp","onPressChange","restProps","id","useId","useDisabled","focusProps","isFocused","isFocusVisible","useFocusRing","isHovered","hoverProps","useHover","pressProps","isPressed","usePress","role","undefined","focusableProps","useFocusable","tabIndex","combinedSlot","useMemo","hover","focus","focusVisible","pressed","dataAttributes","attributes","key","value","Object","entries","kebabCase","baseButtonProps","mergeReactProps","filterDOMProps","includeLabelableProps","labelablePropsSet","Set","linkPropsSet","ANCHOR_ELEMENT_PROPS","additionalAllowedProps","buttonProps","filter","Boolean","join","ButtonFn","children","_jsx","assign","forwardRef","Root","displayName"],"mappings":";;;;;;;;iBAQYA,wOAALC,CAAKD,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,SAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,SAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,QAAAA,CCeZ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAME,EAAqB,CACrBC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAsBH,CAAiBI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAoCtC,CAASC,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AAAA,CAAUyB,EAAWvB,CAEhE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACEsE,EAAAA,CAACnE,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAIH,CAAKA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAASgE,CAAWK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAC3B,CAAOA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAA0BA,EAAS3B,CAAgB2B,CAAAA,CAAAA,CAAAA,CAAAA,CAGjE,CAEA,CAAMxE,CAAAA,CAAAA,CAAAA,CAAAA,CAASuD,OAAOmB,CAAOC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAWJ,WAAAA,CAAW,CAAA,CAAA,CAAEK,KAAMD,aAAWJ,KAEtEvE,CAAO6E,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CA3Ba"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
'use client';
|
|
10
|
-
|
|
11
|
-
import { useButton } from '../hooks/useButton';
|
|
12
|
-
import { forwardRef, ElementType, ComponentPropsWithoutRef, Ref } from 'react';
|
|
13
|
-
|
|
14
|
-
import type { ButtonTypes } from "../types";
|
|
15
|
-
|
|
16
|
-
const BUTTON_NAME = 'Button' as const;
|
|
17
|
-
const DEFAULT_BUTTON_TAG = 'button' as const;
|
|
18
|
-
|
|
19
|
-
type ButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = ComponentPropsWithoutRef<TTag> & {
|
|
20
|
-
as?: TTag;
|
|
21
|
-
type?: ButtonTypes;
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
autoFocus?: boolean;
|
|
24
|
-
slot?: Record<string, any>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(
|
|
28
|
-
props: ButtonProps<TTag>,
|
|
29
|
-
ref: Ref<TTag>
|
|
30
|
-
) {
|
|
31
|
-
const { children, ...restProps } = props;
|
|
32
|
-
const { buttonProps, Tag, combinedSlot } = useButton(restProps, ref as any);
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<Tag ref={ref} {...buttonProps}>
|
|
36
|
-
{typeof children === 'function' ? children(combinedSlot) : children}
|
|
37
|
-
</Tag>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const Button = Object.assign(forwardRef(ButtonFn), { Root: forwardRef(ButtonFn) });
|
|
42
|
-
|
|
43
|
-
Button.displayName = BUTTON_NAME;
|
|
44
|
-
|
|
45
|
-
export { Button };
|
package/src/hooks/useButton.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
'use client';
|
|
10
|
-
|
|
11
|
-
import { kebabCase } from "@necto/strings";
|
|
12
|
-
import { useFocusable } from "react-aria"; // Temp use, will be removed in later version
|
|
13
|
-
import { ButtonTypeValues } from "../types";
|
|
14
|
-
import { mergeReactProps } from "@necto/props-merge";
|
|
15
|
-
import { filterDOMProps } from "@necto-react/helpers";
|
|
16
|
-
import { ANCHOR_ELEMENT_PROPS } from "@necto/constants";
|
|
17
|
-
import { HTMLAttributes, ElementType, Ref, useMemo } from "react";
|
|
18
|
-
import { usePress, useHover, useDisabled, useFocusRing, useId } from '@necto-react/hooks';
|
|
19
|
-
|
|
20
|
-
import type { RefObject } from "react";
|
|
21
|
-
import type { ButtonTypes } from "../types";
|
|
22
|
-
import type { FocusableElement } from "@necto-react/types";
|
|
23
|
-
|
|
24
|
-
const DEFAULT_BUTTON_TAG = 'button' as const;
|
|
25
|
-
const DEFAULT_BUTTON_TYPE = ButtonTypeValues.Button as const;
|
|
26
|
-
|
|
27
|
-
export interface UseButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> {
|
|
28
|
-
as?: TTag;
|
|
29
|
-
type?: ButtonTypes;
|
|
30
|
-
disabled?: boolean;
|
|
31
|
-
isDisabled?: boolean;
|
|
32
|
-
autoFocus?: boolean;
|
|
33
|
-
slot?: Record<string, any>;
|
|
34
|
-
elementType?: string;
|
|
35
|
-
preventFocusOnPress?: boolean;
|
|
36
|
-
allowFocusWhenDisabled?: boolean;
|
|
37
|
-
href?: string;
|
|
38
|
-
target?: string;
|
|
39
|
-
rel?: string;
|
|
40
|
-
onClick?: (e: any) => void;
|
|
41
|
-
onPress?: (e: any) => void;
|
|
42
|
-
onPressStart?: (e: any) => void;
|
|
43
|
-
onPressEnd?: (e: any) => void;
|
|
44
|
-
onPressUp?: (e: any) => void;
|
|
45
|
-
onPressChange?: (isPressed: boolean) => void;
|
|
46
|
-
[key: string]: any;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface UseButtonResult<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> {
|
|
50
|
-
buttonProps: HTMLAttributes<HTMLElement>;
|
|
51
|
-
Tag: TTag;
|
|
52
|
-
combinedSlot: Record<string, any>;
|
|
53
|
-
isPressed: boolean;
|
|
54
|
-
isHovered: boolean;
|
|
55
|
-
isFocused: boolean;
|
|
56
|
-
isFocusVisible: boolean;
|
|
57
|
-
isDisabled: boolean;
|
|
58
|
-
id: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function useButton<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(
|
|
62
|
-
props: UseButtonProps<TTag>,
|
|
63
|
-
ref: RefObject<HTMLElement> | undefined
|
|
64
|
-
): UseButtonResult<TTag> {
|
|
65
|
-
const {
|
|
66
|
-
as: Tag = DEFAULT_BUTTON_TAG as TTag,
|
|
67
|
-
elementType = Tag as string,
|
|
68
|
-
disabled: propDisabled,
|
|
69
|
-
isDisabled: propIsDisabled,
|
|
70
|
-
autoFocus,
|
|
71
|
-
slot = {},
|
|
72
|
-
preventFocusOnPress,
|
|
73
|
-
allowFocusWhenDisabled,
|
|
74
|
-
href,
|
|
75
|
-
target,
|
|
76
|
-
rel,
|
|
77
|
-
type = DEFAULT_BUTTON_TYPE,
|
|
78
|
-
onClick,
|
|
79
|
-
onPress,
|
|
80
|
-
onPressStart,
|
|
81
|
-
onPressEnd,
|
|
82
|
-
onPressUp,
|
|
83
|
-
onPressChange,
|
|
84
|
-
...restProps
|
|
85
|
-
} = props;
|
|
86
|
-
|
|
87
|
-
const id = useId();
|
|
88
|
-
const isDisabled = useDisabled('general', propDisabled || propIsDisabled) || false;
|
|
89
|
-
const { focusProps, isFocused, isFocusVisible } = useFocusRing({ autoFocus });
|
|
90
|
-
const { isHovered, hoverProps } = useHover({ ...props, isDisabled });
|
|
91
|
-
const { pressProps, isPressed } = usePress({
|
|
92
|
-
onPressStart,
|
|
93
|
-
onPressEnd,
|
|
94
|
-
onPressChange,
|
|
95
|
-
onPress,
|
|
96
|
-
onPressUp,
|
|
97
|
-
onClick,
|
|
98
|
-
isDisabled,
|
|
99
|
-
preventFocusOnPress,
|
|
100
|
-
ref: ref as any // Temp type error remediation
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// Additional props based on element type
|
|
104
|
-
let additionalProps;
|
|
105
|
-
if (elementType === 'button') {
|
|
106
|
-
additionalProps = {
|
|
107
|
-
type,
|
|
108
|
-
disabled: isDisabled
|
|
109
|
-
};
|
|
110
|
-
} else {
|
|
111
|
-
additionalProps = {
|
|
112
|
-
role: 'button',
|
|
113
|
-
href: elementType === 'a' && !isDisabled ? href : undefined,
|
|
114
|
-
target: elementType === 'a' ? target : undefined,
|
|
115
|
-
type: elementType === 'input' ? type : undefined,
|
|
116
|
-
disabled: elementType === 'input' ? isDisabled : undefined,
|
|
117
|
-
'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
|
|
118
|
-
rel: elementType === 'a' ? rel : undefined
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Handle focusable props
|
|
123
|
-
const { focusableProps } = useFocusable(props, ref as RefObject<FocusableElement>);
|
|
124
|
-
if (allowFocusWhenDisabled) {
|
|
125
|
-
focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Combine slot props
|
|
129
|
-
const combinedSlot = useMemo(() => ({
|
|
130
|
-
...slot,
|
|
131
|
-
hover: isHovered,
|
|
132
|
-
focus: isFocused,
|
|
133
|
-
focusVisible: isFocusVisible,
|
|
134
|
-
disabled: isDisabled,
|
|
135
|
-
pressed: isPressed
|
|
136
|
-
}), [slot, isHovered, isFocused, isFocusVisible, isDisabled, isPressed]);
|
|
137
|
-
|
|
138
|
-
// Generate data attributes
|
|
139
|
-
const dataAttributes = useMemo(() => {
|
|
140
|
-
const attributes: Record<string, string | undefined> = {};
|
|
141
|
-
|
|
142
|
-
for (const [key, value] of Object.entries(combinedSlot)) {
|
|
143
|
-
if (typeof value === 'boolean') {
|
|
144
|
-
attributes[`data-${kebabCase(key)}`] = value ? 'true' : undefined;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return attributes;
|
|
149
|
-
}, [combinedSlot]);
|
|
150
|
-
|
|
151
|
-
let baseButtonProps = mergeReactProps(focusableProps, pressProps, filterDOMProps(props, {
|
|
152
|
-
includeLabelableProps: true,
|
|
153
|
-
labelablePropsSet: new Set([ ]), // Keep this empty for now,
|
|
154
|
-
linkPropsSet: new Set(ANCHOR_ELEMENT_PROPS),
|
|
155
|
-
additionalAllowedProps: new Set(['id', 'className', 'style', 'data-*', 'aria-*'])
|
|
156
|
-
}));
|
|
157
|
-
|
|
158
|
-
const buttonProps = useMemo(() =>
|
|
159
|
-
mergeReactProps(
|
|
160
|
-
{
|
|
161
|
-
id,
|
|
162
|
-
'data-sprocket-state': [
|
|
163
|
-
isHovered && 'hover',
|
|
164
|
-
isFocused && 'focus',
|
|
165
|
-
isPressed && 'pressed',
|
|
166
|
-
isDisabled && 'disabled',
|
|
167
|
-
]
|
|
168
|
-
.filter(Boolean)
|
|
169
|
-
.join(' ') || '',
|
|
170
|
-
...dataAttributes,
|
|
171
|
-
disabled: isDisabled,
|
|
172
|
-
},
|
|
173
|
-
additionalProps,
|
|
174
|
-
baseButtonProps,
|
|
175
|
-
focusProps,
|
|
176
|
-
hoverProps,
|
|
177
|
-
Tag !== 'button' && Tag !== DEFAULT_BUTTON_TAG
|
|
178
|
-
? { role: 'button' }
|
|
179
|
-
: { type: type as any }
|
|
180
|
-
),
|
|
181
|
-
[isHovered, isFocused, isPressed, isDisabled, dataAttributes, additionalProps, baseButtonProps, focusProps, hoverProps, Tag, type, id]
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
Tag,
|
|
186
|
-
buttonProps,
|
|
187
|
-
combinedSlot,
|
|
188
|
-
isPressed,
|
|
189
|
-
isHovered,
|
|
190
|
-
isFocused,
|
|
191
|
-
isFocusVisible,
|
|
192
|
-
isDisabled,
|
|
193
|
-
id
|
|
194
|
-
};
|
|
195
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export type * from './types';
|
|
10
|
-
export { Button } from './components/Button';
|
|
11
|
-
export { useButton } from './hooks/useButton';
|
package/src/types.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export enum ButtonTypeValues {
|
|
10
|
-
Button = 'button',
|
|
11
|
-
Submit = 'submit',
|
|
12
|
-
Reset = 'reset',
|
|
13
|
-
};
|
|
14
|
-
export type ButtonTypes = `${ButtonTypeValues}`;
|