@spark-web/button 1.5.4-poc-simple.0 → 2.0.0-rc.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/CHANGELOG.md +36 -0
- package/dist/declarations/src/base-button.d.ts +10 -0
- package/dist/declarations/src/button-link.d.ts +9 -0
- package/dist/declarations/src/button.d.ts +28 -0
- package/dist/declarations/src/index.d.ts +9 -0
- package/dist/declarations/src/types.d.ts +37 -0
- package/dist/declarations/src/use-button-styles.d.ts +88 -0
- package/dist/declarations/src/utils.d.ts +43 -0
- package/dist/spark-web-button.cjs.d.ts +2 -2
- package/dist/spark-web-button.cjs.dev.js +492 -0
- package/dist/spark-web-button.cjs.js +6 -15
- package/dist/spark-web-button.cjs.prod.js +492 -0
- package/dist/spark-web-button.esm.js +485 -0
- package/package.json +10 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @spark-web/button
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- rc
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies []:
|
|
12
|
+
- @spark-web/spinner@2.0.0-rc.1
|
|
13
|
+
- @spark-web/theme@4.0.0-rc.1
|
|
14
|
+
- @spark-web/utils@2.0.0-rc.1
|
|
15
|
+
- @spark-web/a11y@2.0.0-rc.1
|
|
16
|
+
- @spark-web/icon@2.0.0-rc.1
|
|
17
|
+
- @spark-web/link@2.0.0-rc.1
|
|
18
|
+
- @spark-web/text@2.0.0-rc.1
|
|
19
|
+
- @spark-web/box@2.0.0-rc.1
|
|
20
|
+
|
|
21
|
+
## 2.0.0-rc.0
|
|
22
|
+
|
|
23
|
+
### Major Changes
|
|
24
|
+
|
|
25
|
+
- rc versio
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies []:
|
|
30
|
+
- @spark-web/spinner@2.0.0-rc.0
|
|
31
|
+
- @spark-web/theme@4.0.0-rc.0
|
|
32
|
+
- @spark-web/a11y@2.0.0-rc.0
|
|
33
|
+
- @spark-web/icon@2.0.0-rc.0
|
|
34
|
+
- @spark-web/text@2.0.0-rc.0
|
|
35
|
+
- @spark-web/box@2.0.0-rc.0
|
|
36
|
+
- @spark-web/link@2.0.0-rc.0
|
|
37
|
+
- @spark-web/utils@2.0.0-rc.0
|
|
38
|
+
|
|
3
39
|
## 1.5.3
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BoxProps } from '@spark-web/box';
|
|
2
|
+
import type { MouseEvent as ReactMouseEvent } from 'react';
|
|
3
|
+
import type { NativeButtonProps } from "./types.js";
|
|
4
|
+
export declare type BaseButtonProps = NativeButtonProps & Partial<BoxProps>;
|
|
5
|
+
export declare const BaseButton: import("react").ForwardRefExoticComponent<NativeButtonProps & Partial<BoxProps> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
/**
|
|
7
|
+
* handle "disabled" behaviour w/o disabling buttons
|
|
8
|
+
* @see https://axesslab.com/disabled-buttons-suck/
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPreventableClickHandler(onClick: BaseButtonProps['onClick'], disabled: boolean): (event: ReactMouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { LinkComponentProps } from '@spark-web/link';
|
|
3
|
+
import type { CommonButtonProps } from "./types.js";
|
|
4
|
+
export declare type ButtonLinkProps = LinkComponentProps & CommonButtonProps;
|
|
5
|
+
/** The appearance of a `Button`, with the semantics of a link. */
|
|
6
|
+
export declare const ButtonLink: <Comp extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "a">(props: {
|
|
7
|
+
as?: Comp | undefined;
|
|
8
|
+
ref?: import("react").Ref<Comp extends "symbol" | "clipPath" | "filter" | "mask" | "marker" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "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" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | keyof HTMLElementTagNameMap ? (HTMLElementTagNameMap & Pick<SVGElementTagNameMap, "symbol" | "clipPath" | "filter" | "mask" | "marker" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "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" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">)[Comp] : Comp extends new (...args: any) => any ? InstanceType<Comp> : undefined> | undefined;
|
|
9
|
+
} & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<Comp>>, "as"> & ButtonLinkProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CommonButtonProps, NativeButtonProps } from "./types.js";
|
|
3
|
+
export declare type ButtonProps = CommonButtonProps & {
|
|
4
|
+
/**
|
|
5
|
+
* Identifies the element (or elements) whose contents or presence
|
|
6
|
+
* are controlled by the current element.
|
|
7
|
+
*/
|
|
8
|
+
'aria-controls'?: NativeButtonProps['aria-controls'];
|
|
9
|
+
/** Identifies the element (or elements) that describes the object. */
|
|
10
|
+
'aria-describedby'?: NativeButtonProps['aria-describedby'];
|
|
11
|
+
/** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
|
|
12
|
+
'aria-expanded'?: NativeButtonProps['aria-expanded'];
|
|
13
|
+
/** When true, prevents onClick from firing. */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** When true, the button will display a loading spinner. */
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
/** Function to be fired following a click event of the button. Only applicable for Button. */
|
|
18
|
+
onClick?: NativeButtonProps['onClick'];
|
|
19
|
+
/** The size of the button. */
|
|
20
|
+
size?: CommonButtonProps['size'];
|
|
21
|
+
/** Provide an alternate type if the button is within a form. */
|
|
22
|
+
type?: 'button' | 'submit' | 'reset';
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Buttons are used to initialize an action, their label should express what
|
|
26
|
+
* action will occur when the user interacts with it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { BaseButton } from "./base-button.js";
|
|
2
|
+
export { Button } from "./button.js";
|
|
3
|
+
export { ButtonLink } from "./button-link.js";
|
|
4
|
+
export { useButtonStyles } from "./use-button-styles.js";
|
|
5
|
+
export type { BaseButtonProps } from "./base-button.js";
|
|
6
|
+
export type { ButtonProps } from "./button.js";
|
|
7
|
+
export type { ButtonLinkProps } from "./button-link.js";
|
|
8
|
+
export type { ButtonChildrenProps, ButtonProminence, ButtonSize, ButtonTone, } from "./types.js";
|
|
9
|
+
export type { UseButtonStylesProps } from "./use-button-styles.js";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BackgroundTone } from '@spark-web/a11y';
|
|
2
|
+
import type { IconProps } from '@spark-web/icon';
|
|
3
|
+
import type { DataAttributeMap } from '@spark-web/utils/internal';
|
|
4
|
+
import type { ButtonHTMLAttributes, ReactElement } from 'react';
|
|
5
|
+
import type { mapTokens } from "./utils.js";
|
|
6
|
+
export declare type ButtonSize = keyof (typeof mapTokens)[keyof typeof mapTokens];
|
|
7
|
+
export declare type ButtonProminence = 'high' | 'low' | 'none';
|
|
8
|
+
export declare type ButtonTone = Exclude<BackgroundTone, 'disabled'>;
|
|
9
|
+
declare type ChildrenWithText = {
|
|
10
|
+
label?: never;
|
|
11
|
+
children: string | number | [ReactElement<IconProps>, string | number] | [string | number, ReactElement<IconProps>];
|
|
12
|
+
};
|
|
13
|
+
declare type IconOnly = {
|
|
14
|
+
/**
|
|
15
|
+
* Implicit label for buttons only required for icon-only buttons
|
|
16
|
+
* for accessibility reasons.
|
|
17
|
+
*/
|
|
18
|
+
label: string;
|
|
19
|
+
children: ReactElement<IconProps>;
|
|
20
|
+
};
|
|
21
|
+
export declare type ButtonChildrenProps = ChildrenWithText | IconOnly;
|
|
22
|
+
export declare type NativeButtonProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
23
|
+
export declare type CommonButtonProps = {
|
|
24
|
+
/** Sets data attributes for the element. */
|
|
25
|
+
data?: DataAttributeMap;
|
|
26
|
+
/** Unique identifier for the underlying element. */
|
|
27
|
+
id?: string;
|
|
28
|
+
} & ButtonChildrenProps & ButtonStyleProps;
|
|
29
|
+
export declare type ButtonStyleProps = {
|
|
30
|
+
/** Sets the visual prominence of the button. */
|
|
31
|
+
prominence?: ButtonProminence;
|
|
32
|
+
/** Sets the size of the button. */
|
|
33
|
+
size?: ButtonSize;
|
|
34
|
+
/** Sets the tone of the button. */
|
|
35
|
+
tone?: ButtonTone;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ButtonProminence, ButtonSize, ButtonTone } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* useButtonStyles
|
|
4
|
+
*
|
|
5
|
+
* Custom hook for styling buttons and certain links.
|
|
6
|
+
* Returns a tuple where the first item is an object of props to spread onto the
|
|
7
|
+
* underlying `Box` component, and the second item is a CSS object that can be
|
|
8
|
+
* passed to Emotion's `css` function.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useButtonStyles({ iconOnly, prominence, size, tone, }: UseButtonStylesProps): readonly [{
|
|
11
|
+
readonly alignItems: "center";
|
|
12
|
+
readonly background: "body" | "input" | "disabled" | "infoLight" | "criticalLight" | "positiveLight" | "cautionLight" | "muted" | "backdrop" | "surface" | "surfaceMuted" | "surfacePressed" | "fieldAccent" | "inputPressed" | "inputDisabled" | "accent" | "accentMuted" | "neutral" | "neutralLow" | "primary" | "primaryLow" | "primaryMuted" | "secondary" | "secondaryLow" | "secondaryMuted" | "caution" | "cautionLow" | "cautionMuted" | "critical" | "criticalLow" | "criticalMuted" | "info" | "infoLow" | "infoMuted" | "positive" | "positiveLow" | "positiveMuted" | undefined;
|
|
13
|
+
readonly border: import("@spark-web/theme").ResponsiveProp<"standard" | "fieldAccent" | "accent" | "accentMuted" | "neutral" | "primary" | "secondary" | "caution" | "cautionMuted" | "critical" | "criticalMuted" | "info" | "infoMuted" | "positive" | "positiveMuted" | "primaryHover" | "primaryActive" | "secondaryHover" | "secondaryActive" | "standardInverted" | "field" | "fieldHover" | "fieldDisabled"> | undefined;
|
|
14
|
+
readonly borderWidth: import("@spark-web/theme").ResponsiveProp<"standard" | "large"> | undefined;
|
|
15
|
+
readonly borderRadius: "small" | "medium";
|
|
16
|
+
readonly cursor: "pointer";
|
|
17
|
+
readonly display: "inline-flex";
|
|
18
|
+
readonly gap: "small";
|
|
19
|
+
readonly height: "large" | "medium";
|
|
20
|
+
readonly justifyContent: "center";
|
|
21
|
+
readonly paddingX: "medium" | "xlarge" | undefined;
|
|
22
|
+
readonly position: "relative";
|
|
23
|
+
readonly width: "large" | "medium" | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
readonly '&:not([aria-disabled=true])': {
|
|
26
|
+
readonly ':hover': {
|
|
27
|
+
readonly borderColor: string | undefined;
|
|
28
|
+
readonly backgroundColor: string | undefined;
|
|
29
|
+
readonly '> *': {
|
|
30
|
+
readonly color: string | undefined;
|
|
31
|
+
readonly stroke: string | undefined;
|
|
32
|
+
readonly transitionProperty: string;
|
|
33
|
+
readonly transitionTimingFunction: string;
|
|
34
|
+
readonly transitionDuration: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
readonly ':active': {
|
|
38
|
+
readonly borderColor: string | undefined;
|
|
39
|
+
readonly backgroundColor: string | undefined;
|
|
40
|
+
readonly transform: "scale(0.98)";
|
|
41
|
+
readonly '> *': {
|
|
42
|
+
readonly color: string | undefined;
|
|
43
|
+
readonly stroke: string | undefined;
|
|
44
|
+
readonly transitionProperty: string;
|
|
45
|
+
readonly transitionTimingFunction: string;
|
|
46
|
+
readonly transitionDuration: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly ':focus': {
|
|
50
|
+
boxShadow: string;
|
|
51
|
+
outline: string;
|
|
52
|
+
outlineOffset: string;
|
|
53
|
+
} | {
|
|
54
|
+
outline: string;
|
|
55
|
+
outlineOffset: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
readonly '&[aria-disabled=true]': {
|
|
59
|
+
readonly backgroundColor: string | undefined;
|
|
60
|
+
readonly borderColor: string | undefined;
|
|
61
|
+
readonly cursor: "default";
|
|
62
|
+
readonly '*': {
|
|
63
|
+
readonly color: string | undefined;
|
|
64
|
+
readonly stroke: string | undefined;
|
|
65
|
+
};
|
|
66
|
+
readonly ':focus': {
|
|
67
|
+
boxShadow: string;
|
|
68
|
+
outline: string;
|
|
69
|
+
outlineOffset: string;
|
|
70
|
+
} | {
|
|
71
|
+
outline: string;
|
|
72
|
+
outlineOffset: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
readonly transitionProperty: string;
|
|
76
|
+
readonly transitionTimingFunction: string;
|
|
77
|
+
readonly transitionDuration: string;
|
|
78
|
+
}];
|
|
79
|
+
export declare type UseButtonStylesProps = {
|
|
80
|
+
/** Whether the children of the button is a single icon or not. */
|
|
81
|
+
iconOnly: boolean;
|
|
82
|
+
/** Sets the visual prominence of the button. */
|
|
83
|
+
prominence: ButtonProminence;
|
|
84
|
+
/** Sets the size of the button. */
|
|
85
|
+
size: ButtonSize;
|
|
86
|
+
/** Sets the tone of the button. */
|
|
87
|
+
tone: ButtonTone;
|
|
88
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BoxProps } from '@spark-web/box';
|
|
2
|
+
import type { ForegroundTone } from '@spark-web/text';
|
|
3
|
+
import type { BrighteTheme } from '@spark-web/theme';
|
|
4
|
+
import type { ButtonProminence, ButtonTone } from "./types.js";
|
|
5
|
+
declare type BaseButtonStyles = {
|
|
6
|
+
background: BoxProps['background'];
|
|
7
|
+
border?: BoxProps['border'];
|
|
8
|
+
borderWidth?: BoxProps['borderWidth'];
|
|
9
|
+
textTone?: ForegroundTone;
|
|
10
|
+
};
|
|
11
|
+
declare type HoverButtonStyles = {
|
|
12
|
+
backgroundHover: keyof BrighteTheme['backgroundInteractions'];
|
|
13
|
+
borderHover?: keyof BrighteTheme['border']['color'];
|
|
14
|
+
textToneHover?: keyof BrighteTheme['color']['foreground'];
|
|
15
|
+
};
|
|
16
|
+
declare type ActiveButtonStyles = {
|
|
17
|
+
backgroundActive: keyof BrighteTheme['backgroundInteractions'];
|
|
18
|
+
borderActive?: keyof BrighteTheme['border']['color'];
|
|
19
|
+
textToneActive?: keyof BrighteTheme['color']['foreground'];
|
|
20
|
+
};
|
|
21
|
+
declare type DisabledButtonStyles = {
|
|
22
|
+
backgroundDisabled: keyof BrighteTheme['color']['background'];
|
|
23
|
+
borderDisabled?: keyof BrighteTheme['border']['color'];
|
|
24
|
+
textToneDisabled: keyof BrighteTheme['color']['foreground'];
|
|
25
|
+
};
|
|
26
|
+
declare type ButtonStyles = BaseButtonStyles & HoverButtonStyles & ActiveButtonStyles & DisabledButtonStyles;
|
|
27
|
+
declare type Variants = Record<ButtonProminence, Record<ButtonTone, ButtonStyles | undefined>>;
|
|
28
|
+
export declare const variants: Variants;
|
|
29
|
+
export declare const mapTokens: {
|
|
30
|
+
readonly fontSize: {
|
|
31
|
+
readonly medium: "small";
|
|
32
|
+
readonly large: "standard";
|
|
33
|
+
};
|
|
34
|
+
readonly size: {
|
|
35
|
+
readonly medium: "medium";
|
|
36
|
+
readonly large: "large";
|
|
37
|
+
};
|
|
38
|
+
readonly spacing: {
|
|
39
|
+
readonly medium: "medium";
|
|
40
|
+
readonly large: "xlarge";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "
|
|
2
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
1
|
+
export * from "./declarations/src/index";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhcmstd2ViLWJ1dHRvbi5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|