@sprocketui-react/button 1.0.0 → 1.0.2
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/index.cjs +1 -0
- package/dist/index.d.cts +93 -0
- package/dist/index.d.ts +71 -45
- package/dist/index.global.js +666 -0
- package/dist/index.js +1 -10
- package/package.json +39 -12
- package/__tests__/button.test.tsx +0 -45
- package/dist/index.es.js +0 -10
- package/dist/index.es.js.map +0 -1
- 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/dist/index.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
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
|
|
1
|
+
import{useHover as _,usePress as h,useFocusRing as j,useFocusable as V}from"@necto-react/hooks";import{HTMLElements as r}from"@necto/dom";import{mergeProps as C}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 k=r.Button;function x(t,o){let{rel:d,href:u,target:i,autoFocus:p,focusDisabled:a,preventFocusOnPress:R,isDisabled:e=!1,type:l="button",as:c=k,elementType:n=c||k,onClick:m,onPress:B,onPressStart:P,onPressEnd:b,onPressUp:f,onPressChange:w}=t,y;n===r.Button?y={type:l,disabled:e}:y={role:"button",href:n===r.A&&!e?u:void 0,target:n===r.A?i:void 0,type:n===r.Input?l:void 0,disabled:n===r.Input?e:void 0,"aria-disabled":!e||n===r.Input?void 0:e,rel:n===r.A?d:void 0};let{hoverProps:H,isHovered:M}=_({...t,isDisabled:e}),{focusProps:S,isFocused:U,isFocusVisible:v}=j({autoFocus:p}),{focusableProps:T}=V(t,o),{pressProps:I,isPressed:N}=h({ref:o,isDisabled:e,preventFocusOnPress:R,onPressStart:P,onPressEnd:b,onPressChange:w,onPress:B,onPressUp:f,onClick:m});a&&(T.tabIndex=e?-1:T.tabIndex);let D=C(T,I,H,S,G(t,{allowLabelableProps:!0,allowedLabelableProps:new Set([]),allowedLinkProps:new Set(W),extraAllowedProps:new Set(X)}));return{isFocused:U,isPressed:N,isHovered:M,isDisabled:e,isFocusVisible:v,elementType:n,buttonProps:C(D,y)}}import{createContext as $}from"react";var s=$(null);import{useContext as q}from"react";function F(){return q(s)}import{kebabCase as O}from"@necto/strings";import{mergeProps as z}from"@necto/mergers";import{forwardRef as L,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{jsxs as et}from"react/jsx-runtime";var g="Button";function A(t,o){[t,o]=Y({props:t,ref:o,context:s});let{buttonProps:d,isHovered:u,isPressed:i,isFocused:p,isDisabled:a,elementType:R,isFocusVisible:e}=x(t,o),l=tt({defaultId:d.id}),c=Z({...t,values:{isHovered:u,isPressed:i,isFocused:p,isFocusVisible:e,isDisabled:a},defaultClassName:K({component:g}),style:m=>({...t.style instanceof Function?t.style(m):t.style})}),n=J(()=>{let m={hover:u,focus:p,focusVisible:e,disabled:a,pressed:i},B={},P=[];for(let[b,f]of Object.entries(m))typeof f=="boolean"&&(B[`data-${O(b)}`]=f?String(!0):void 0,f&&P.push(O(b)));return{...B,"data-sprocket-state":P.join(" ")}},[u,p,e,a,i]);return et(Q,{ref:o,as:R,...c,...z(d,n),id:l,slot:t.slot||void 0,children:["''",c.children]})}var E=Object.assign(L((t,o)=>A(t,o)),{Root:L((t,o)=>A(t,o))});E.displayName=g;export{E as Button,s as ButtonContext,E as SprocketButton,s as SprocketButtonContext,x as useButton,F as useButtonContext,x as useSprocketButton,F as useSprocketButtonContext};
|
package/package.json
CHANGED
|
@@ -1,24 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprocketui-react/button",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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
|
-
"author": "Corinvo OSS Team",
|
|
13
|
-
"license": "MIT",
|
|
14
18
|
"dependencies": {
|
|
15
|
-
"@necto/
|
|
19
|
+
"@necto-react/components": "^1.2.14",
|
|
20
|
+
"@necto-react/helpers": "^2.4.5",
|
|
21
|
+
"@necto-react/hooks": "^2.12.5",
|
|
22
|
+
"@necto-react/types": "^2.3.0",
|
|
23
|
+
"@necto/dom": "^1.4.5",
|
|
24
|
+
"@necto/mergers": "^1.4.0",
|
|
25
|
+
"@necto/strings": "^1.4.0",
|
|
16
26
|
"@react-aria/focus": "^3.20.2",
|
|
17
27
|
"react-aria": "^3.39.0",
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
28
|
+
"@sprocketui-types/button": "1.0.1",
|
|
29
|
+
"shared": "1.0.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
33
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
37
|
+
"@testing-library/react": "^16.3.0",
|
|
38
|
+
"@types/react": "^19.1.2",
|
|
39
|
+
"@types/react-dom": "^19.1.2",
|
|
40
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
41
|
+
"react": "^19.1.0",
|
|
42
|
+
"react-dom": "^19.1.0",
|
|
43
|
+
"tsup": "^8.4.0",
|
|
44
|
+
"vitest": "^3.2.4"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"test": "vitest",
|
|
49
|
+
"dev": "tsup --watch"
|
|
23
50
|
}
|
|
24
51
|
}
|
|
@@ -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.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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CAC3B,mBAAOA,CAA0BA,CAAAA,CAAAA,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.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,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CACdC,EACAC,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,CAAA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,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}`;
|