@sprocketui-react/button 1.0.0
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/LICENSE +21 -0
- package/README.md +0 -0
- package/__tests__/button.test.tsx +45 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.es.js +10 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -0
- package/src/components/Button.tsx +45 -0
- package/src/hooks/useButton.ts +195 -0
- package/src/index.ts +11 -0
- package/src/types.ts +14 -0
- package/tsconfig.json +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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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A,CAAS3B,GAAgB2B,CAGjE,CAAA,CAAA,CAEA,IAAMxE,CAASuD,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,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
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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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AW7D,CAAEA,CAAAA,CAAAA,CAAAA,CAAAA,CAAGuC,aAAEA,CAAiB5C,CAAAA,CAAAA,CAAAA,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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sprocketui-react/button",
|
|
3
|
+
"version": "1.0.0",
|
|
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
|
+
"type": "module",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=10"
|
|
11
|
+
},
|
|
12
|
+
"author": "Corinvo OSS Team",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@necto/strings": "^1.1.0",
|
|
16
|
+
"@react-aria/focus": "^3.20.2",
|
|
17
|
+
"react-aria": "^3.39.0",
|
|
18
|
+
"@necto/constants": "1.1.0",
|
|
19
|
+
"@necto-react/types": "2.0.0",
|
|
20
|
+
"@necto-react/hooks": "2.7.0",
|
|
21
|
+
"@necto-react/helpers": "2.1.0",
|
|
22
|
+
"@necto/props-merge": "1.1.0"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 };
|
|
@@ -0,0 +1,195 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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}`;
|