@atlaskit/button 16.10.2 → 16.12.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/CHANGELOG.md +16 -0
- package/dist/cjs/entry-points/new.js +8 -1
- package/dist/cjs/entry-points/unsafe.js +40 -1
- package/dist/cjs/new-button/containers/split-button/index.js +50 -0
- package/dist/cjs/new-button/containers/split-button/split-button-context.js +37 -0
- package/dist/cjs/new-button/containers/split-button/split-button.js +137 -0
- package/dist/cjs/new-button/containers/split-button/types.js +5 -0
- package/dist/cjs/new-button/containers/split-button/utils.js +23 -0
- package/dist/cjs/new-button/variants/default/link.js +47 -42
- package/dist/cjs/new-button/variants/icon/link.js +47 -42
- package/dist/cjs/new-button/variants/shared/use-button-base.js +19 -6
- package/dist/cjs/new-button/variants/shared/xcss.js +52 -10
- package/dist/cjs/old-button/shared/button-base.js +1 -1
- package/dist/cjs/utils/variants.js +73 -8
- package/dist/es2019/entry-points/new.js +2 -1
- package/dist/es2019/entry-points/unsafe.js +4 -1
- package/dist/es2019/new-button/containers/split-button/index.js +3 -0
- package/dist/es2019/new-button/containers/split-button/split-button-context.js +31 -0
- package/dist/es2019/new-button/containers/split-button/split-button.js +129 -0
- package/dist/es2019/new-button/containers/split-button/types.js +1 -0
- package/dist/es2019/new-button/containers/split-button/utils.js +12 -0
- package/dist/es2019/new-button/variants/default/button.js +0 -1
- package/dist/es2019/new-button/variants/default/link.js +45 -44
- package/dist/es2019/new-button/variants/icon/button.js +0 -1
- package/dist/es2019/new-button/variants/icon/link.js +45 -44
- package/dist/es2019/new-button/variants/shared/use-button-base.js +19 -6
- package/dist/es2019/new-button/variants/shared/xcss.js +54 -10
- package/dist/es2019/old-button/shared/button-base.js +1 -1
- package/dist/es2019/utils/variants.js +69 -6
- package/dist/esm/entry-points/new.js +2 -1
- package/dist/esm/entry-points/unsafe.js +4 -1
- package/dist/esm/new-button/containers/split-button/index.js +3 -0
- package/dist/esm/new-button/containers/split-button/split-button-context.js +31 -0
- package/dist/esm/new-button/containers/split-button/split-button.js +131 -0
- package/dist/esm/new-button/containers/split-button/types.js +1 -0
- package/dist/esm/new-button/containers/split-button/utils.js +16 -0
- package/dist/esm/new-button/variants/default/link.js +44 -42
- package/dist/esm/new-button/variants/icon/link.js +44 -42
- package/dist/esm/new-button/variants/shared/use-button-base.js +19 -6
- package/dist/esm/new-button/variants/shared/xcss.js +51 -10
- package/dist/esm/old-button/shared/button-base.js +1 -1
- package/dist/esm/utils/variants.js +75 -6
- package/dist/types/entry-points/new.d.ts +1 -0
- package/dist/types/entry-points/unsafe.d.ts +3 -0
- package/dist/types/new-button/containers/split-button/index.d.ts +3 -0
- package/dist/types/new-button/containers/split-button/split-button-context.d.ts +47 -0
- package/dist/types/new-button/containers/split-button/split-button.d.ts +47 -0
- package/dist/types/new-button/containers/split-button/types.d.ts +4 -0
- package/dist/types/new-button/containers/split-button/utils.d.ts +5 -0
- package/dist/types/new-button/variants/default/button.d.ts +3 -5
- package/dist/types/new-button/variants/default/link.d.ts +10 -7
- package/dist/types/new-button/variants/icon/button.d.ts +3 -5
- package/dist/types/new-button/variants/icon/link.d.ts +11 -8
- package/dist/types/new-button/variants/shared/use-button-base.d.ts +1 -1
- package/dist/types/new-button/variants/shared/xcss.d.ts +14 -1
- package/dist/types/new-button/variants/types.d.ts +11 -1
- package/dist/types/old-button/types.d.ts +2 -2
- package/dist/types/utils/variants.d.ts +25 -3
- package/dist/types-ts4.5/containers/button-group.d.ts +12 -0
- package/dist/types-ts4.5/entry-points/button-group.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/custom-theme-button.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/loading-button.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/new.d.ts +6 -0
- package/dist/types-ts4.5/entry-points/standard-button.d.ts +7 -0
- package/dist/types-ts4.5/entry-points/types.d.ts +4 -0
- package/dist/types-ts4.5/entry-points/unsafe.d.ts +4 -0
- package/dist/types-ts4.5/index.d.ts +8 -0
- package/dist/types-ts4.5/new-button/containers/split-button/index.d.ts +3 -0
- package/dist/types-ts4.5/new-button/containers/split-button/split-button-context.d.ts +47 -0
- package/dist/types-ts4.5/new-button/containers/split-button/split-button.d.ts +47 -0
- package/dist/types-ts4.5/new-button/containers/split-button/types.d.ts +4 -0
- package/dist/types-ts4.5/new-button/containers/split-button/utils.d.ts +5 -0
- package/dist/types-ts4.5/new-button/variants/default/button.d.ts +17 -0
- package/dist/types-ts4.5/new-button/variants/default/link.d.ts +20 -0
- package/dist/types-ts4.5/new-button/variants/default/types.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/default/use-default-button.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +20 -0
- package/dist/types-ts4.5/new-button/variants/icon/types.d.ts +8 -0
- package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/shared/block-events.d.ts +2 -0
- package/dist/types-ts4.5/new-button/variants/shared/colors.d.ts +18 -0
- package/dist/types-ts4.5/new-button/variants/shared/content.d.ts +13 -0
- package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +37 -0
- package/dist/types-ts4.5/new-button/variants/shared/xcss.d.ts +31 -0
- package/dist/types-ts4.5/new-button/variants/types.d.ts +79 -0
- package/dist/types-ts4.5/old-button/button.d.ts +15 -0
- package/dist/types-ts4.5/old-button/custom-theme-button/custom-theme-button-types.d.ts +22 -0
- package/dist/types-ts4.5/old-button/custom-theme-button/custom-theme-button.d.ts +10 -0
- package/dist/types-ts4.5/old-button/custom-theme-button/index.d.ts +2 -0
- package/dist/types-ts4.5/old-button/custom-theme-button/theme.d.ts +21 -0
- package/dist/types-ts4.5/old-button/loading-button.d.ts +15 -0
- package/dist/types-ts4.5/old-button/shared/block-events.d.ts +4 -0
- package/dist/types-ts4.5/old-button/shared/button-base.d.ts +10 -0
- package/dist/types-ts4.5/old-button/shared/colors.d.ts +23 -0
- package/dist/types-ts4.5/old-button/shared/css.d.ts +22 -0
- package/dist/types-ts4.5/old-button/shared/get-if-visually-hidden-children.d.ts +2 -0
- package/dist/types-ts4.5/old-button/shared/get-is-only-single-icon.d.ts +2 -0
- package/dist/types-ts4.5/old-button/shared/loading-spinner.d.ts +5 -0
- package/dist/types-ts4.5/old-button/types.d.ts +94 -0
- package/dist/types-ts4.5/utils/appearances.d.ts +3 -0
- package/dist/types-ts4.5/utils/spacing.d.ts +3 -0
- package/dist/types-ts4.5/utils/variants.d.ts +37 -0
- package/package.json +4 -3
- package/tmp/api-report-tmp.d.ts +133 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type
|
|
2
|
+
import { type CommonButtonVariantProps } from '../types';
|
|
3
3
|
import { type CommonDefaultButtonProps } from './types';
|
|
4
|
-
type
|
|
5
|
-
type AdditionalHTMLElementProps = AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<Element>>;
|
|
6
|
-
export type ButtonProps = CommonDefaultButtonProps & CombinedButtonProps<Element, AdditionalHTMLElementProps>;
|
|
4
|
+
export type ButtonProps = CommonDefaultButtonProps & CommonButtonVariantProps;
|
|
7
5
|
/**
|
|
8
6
|
* __Button__
|
|
9
7
|
*
|
|
@@ -15,5 +13,5 @@ export type ButtonProps = CommonDefaultButtonProps & CombinedButtonProps<Element
|
|
|
15
13
|
* - [Code](https://atlassian.design/components/button/code)
|
|
16
14
|
* - [Usage](https://atlassian.design/components/button/usage)
|
|
17
15
|
*/
|
|
18
|
-
declare const Button: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonDefaultButtonProps & Omit<
|
|
16
|
+
declare const Button: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonDefaultButtonProps & Omit<import("../types").AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<HTMLButtonElement>>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>>;
|
|
19
17
|
export default Button;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type
|
|
1
|
+
import React, { type Ref } from 'react';
|
|
2
|
+
import { type CommonLinkVariantProps } from '../types';
|
|
3
3
|
import { type CommonDefaultButtonProps } from './types';
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
export type LinkButtonProps = CommonDefaultButtonProps & CombinedButtonProps<Element, AdditionalHTMLElementProps>;
|
|
4
|
+
export type LinkButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonDefaultButtonProps & CommonLinkVariantProps<RouterLinkConfig>;
|
|
5
|
+
declare const LinkButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, autoFocus, appearance, spacing, isDisabled, isSelected, iconBefore, iconAfter, children, shouldFitContainer, interactionName, overlay, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, testId, href, ...rest }: LinkButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
|
|
7
6
|
/**
|
|
8
7
|
* __Link Button__
|
|
9
8
|
*
|
|
10
|
-
*
|
|
9
|
+
* Renders a link in the style of a button.
|
|
11
10
|
*
|
|
12
11
|
* - [Examples](https://atlassian.design/components/button/examples)
|
|
13
12
|
* - [Code](https://atlassian.design/components/button/code)
|
|
14
13
|
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
14
|
*/
|
|
16
|
-
declare const LinkButton:
|
|
15
|
+
declare const LinkButton: <RouterLinkConfig extends Record<string, any> = never>(props: CommonDefaultButtonProps & {
|
|
16
|
+
href: string | RouterLinkConfig;
|
|
17
|
+
} & Omit<import("../types").AdditionalHTMLElementPropsExtender<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href">>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLAnchorElement> & {
|
|
18
|
+
ref?: React.Ref<HTMLAnchorElement> | undefined;
|
|
19
|
+
}) => ReturnType<typeof LinkButtonBase>;
|
|
17
20
|
export default LinkButton;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type
|
|
2
|
+
import { type CommonButtonVariantProps } from '../types';
|
|
3
3
|
import { type CommonIconButtonProps } from './types';
|
|
4
|
-
type
|
|
5
|
-
type AdditionalHTMLElementProps = AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<Element>>;
|
|
6
|
-
export type IconButtonProps = CommonIconButtonProps & CombinedButtonProps<Element, AdditionalHTMLElementProps>;
|
|
4
|
+
export type IconButtonProps = CommonIconButtonProps & CommonButtonVariantProps;
|
|
7
5
|
/**
|
|
8
6
|
* __Icon Button__
|
|
9
7
|
*
|
|
@@ -13,5 +11,5 @@ export type IconButtonProps = CommonIconButtonProps & CombinedButtonProps<Elemen
|
|
|
13
11
|
* - [Code](https://atlassian.design/components/button/code)
|
|
14
12
|
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
13
|
*/
|
|
16
|
-
declare const IconButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonIconButtonProps & Omit<
|
|
14
|
+
declare const IconButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonIconButtonProps & Omit<import("../types").AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<HTMLButtonElement>>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>>;
|
|
17
15
|
export default IconButton;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type
|
|
1
|
+
import React, { type Ref } from 'react';
|
|
2
|
+
import { type CommonLinkVariantProps } from '../types';
|
|
3
3
|
import { type CommonIconButtonProps } from './types';
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
export type LinkIconButtonProps = CommonIconButtonProps & CombinedButtonProps<Element, AdditionalHTMLElementProps>;
|
|
4
|
+
export type LinkIconButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonIconButtonProps & CommonLinkVariantProps<RouterLinkConfig>;
|
|
5
|
+
declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, autoFocus, appearance, spacing, isDisabled, isSelected, icon, children, interactionName, overlay, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, testId, href, ...rest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
|
|
7
6
|
/**
|
|
8
|
-
* __Link Button__
|
|
7
|
+
* __Link Icon Button__
|
|
9
8
|
*
|
|
10
|
-
*
|
|
9
|
+
* Renders a link in the style of an icon button.
|
|
11
10
|
*
|
|
12
11
|
* - [Examples](https://atlassian.design/components/button/examples)
|
|
13
12
|
* - [Code](https://atlassian.design/components/button/code)
|
|
14
13
|
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
14
|
*/
|
|
16
|
-
declare const LinkIconButton:
|
|
15
|
+
declare const LinkIconButton: <RouterLinkConfig extends Record<string, any> = never>(props: CommonIconButtonProps & {
|
|
16
|
+
href: string | RouterLinkConfig;
|
|
17
|
+
} & Omit<import("../types").AdditionalHTMLElementPropsExtender<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href">>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLAnchorElement> & {
|
|
18
|
+
ref?: React.Ref<HTMLAnchorElement> | undefined;
|
|
19
|
+
}) => ReturnType<typeof LinkIconButtonBase>;
|
|
17
20
|
export default LinkIconButton;
|
|
@@ -33,5 +33,5 @@ export type UseButtonBaseReturn<TagName extends HTMLElement> = {
|
|
|
33
33
|
*
|
|
34
34
|
* @private
|
|
35
35
|
*/
|
|
36
|
-
declare const useButtonBase: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, interactionName, isDisabled, isSelected, isIconButton, hasIconBefore, hasIconAfter, children, onClick: providedOnClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
|
|
36
|
+
declare const useButtonBase: <TagName extends HTMLElement>({ analyticsContext, appearance: propAppearance, autoFocus, buttonType, interactionName, isDisabled: propIsDisabled, isSelected, isIconButton, hasIconBefore, hasIconAfter, children, onClick: providedOnClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing: propSpacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
|
|
37
37
|
export default useButtonBase;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { xcss } from '@atlaskit/primitives';
|
|
2
2
|
import { type Appearance, type Spacing } from '../types';
|
|
3
|
+
export declare const heights: {
|
|
4
|
+
[key in Spacing]: string;
|
|
5
|
+
};
|
|
3
6
|
export type GetXCSSArgs = {
|
|
4
7
|
appearance: Appearance;
|
|
5
8
|
spacing: Spacing;
|
|
6
9
|
isDisabled: boolean;
|
|
7
10
|
isSelected: boolean;
|
|
11
|
+
isHighlighted: boolean;
|
|
12
|
+
isActiveOverSelected: boolean;
|
|
8
13
|
shouldFitContainer: boolean;
|
|
9
14
|
hasOverlay: boolean;
|
|
10
15
|
isIconButton: boolean;
|
|
@@ -14,5 +19,13 @@ export type GetXCSSArgs = {
|
|
|
14
19
|
* If the button is a LinkButton
|
|
15
20
|
*/
|
|
16
21
|
isLink: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* If the button is a SplitButton
|
|
24
|
+
*/
|
|
25
|
+
isSplit: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* If the button is a PrimarySplitButton used in atlassian-navigation
|
|
28
|
+
*/
|
|
29
|
+
isNavigationSplit: boolean;
|
|
17
30
|
};
|
|
18
|
-
export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isIconButton, shouldFitContainer, isLink, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
|
|
31
|
+
export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, shouldFitContainer, isLink, isSplit, isNavigationSplit, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
|
|
@@ -63,7 +63,17 @@ export type AdditionalHTMLElementPropsExtender<Props extends SupportedElementAtt
|
|
|
63
63
|
'data-testid'?: never;
|
|
64
64
|
}>;
|
|
65
65
|
/**
|
|
66
|
-
* Combines common
|
|
66
|
+
* Combines common button props with additional HTML attributes.
|
|
67
67
|
*/
|
|
68
68
|
export type CombinedButtonProps<TagName extends HTMLElement, HTMLAttributes extends SupportedElementAttributes> = Combine<HTMLAttributes, CommonButtonProps<TagName>>;
|
|
69
|
+
/**
|
|
70
|
+
* Common props for Button `<button>` variants
|
|
71
|
+
*/
|
|
72
|
+
export type CommonButtonVariantProps = CombinedButtonProps<HTMLButtonElement, AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<HTMLButtonElement>>>;
|
|
73
|
+
/**
|
|
74
|
+
* Common props for Link `<a>` Button variants
|
|
75
|
+
*/
|
|
76
|
+
export type CommonLinkVariantProps<RouterLinkConfig extends Record<string, any> = never> = {
|
|
77
|
+
href: string | RouterLinkConfig;
|
|
78
|
+
} & CombinedButtonProps<HTMLAnchorElement, AdditionalHTMLElementPropsExtender<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>>>;
|
|
69
79
|
export {};
|
|
@@ -78,8 +78,8 @@ export type BaseOwnProps = {
|
|
|
78
78
|
testId?: string;
|
|
79
79
|
component?: React.ComponentType<React.AllHTMLAttributes<HTMLElement>> | React.ElementType;
|
|
80
80
|
/**
|
|
81
|
-
* An optional name used to identify this component to press listeners.
|
|
82
|
-
*
|
|
81
|
+
* An optional name used to identify this component to press listeners. For example, interaction tracing. For more information,
|
|
82
|
+
* see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration)
|
|
83
83
|
*/
|
|
84
84
|
interactionName?: string;
|
|
85
85
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Button from '../new-button/variants/default/button';
|
|
3
|
+
import { LinkButtonProps } from '../new-button/variants/default/link';
|
|
4
|
+
import { LinkIconButtonProps } from '../new-button/variants/icon/link';
|
|
3
5
|
export type Variant = {
|
|
4
6
|
name: string;
|
|
5
7
|
Component: typeof Button | typeof LinkButtonRender;
|
|
@@ -8,8 +10,28 @@ export type Variant = {
|
|
|
8
10
|
*/
|
|
9
11
|
elementType: typeof HTMLButtonElement | typeof HTMLAnchorElement;
|
|
10
12
|
};
|
|
11
|
-
declare const LinkButtonRender: React.ForwardRefExoticComponent<
|
|
12
|
-
|
|
13
|
-
}
|
|
13
|
+
declare const LinkButtonRender: React.ForwardRefExoticComponent<Omit<LinkButtonProps<never>, "href"> & {
|
|
14
|
+
href?: string | undefined;
|
|
15
|
+
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
14
16
|
export declare const variants: Variant[];
|
|
15
17
|
export default variants;
|
|
18
|
+
export declare const linkButtonVariants: ({
|
|
19
|
+
name: string;
|
|
20
|
+
Component: React.ForwardRefExoticComponent<Omit<LinkButtonProps<never>, "href"> & {
|
|
21
|
+
href?: string | undefined;
|
|
22
|
+
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
23
|
+
elementType: {
|
|
24
|
+
new (): HTMLAnchorElement;
|
|
25
|
+
prototype: HTMLAnchorElement;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
name: string;
|
|
29
|
+
Component: React.ForwardRefExoticComponent<Omit<LinkIconButtonProps<never>, "href" | "icon"> & {
|
|
30
|
+
href?: string | undefined;
|
|
31
|
+
icon?: React.ReactChild | undefined;
|
|
32
|
+
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
33
|
+
elementType: {
|
|
34
|
+
new (): HTMLAnchorElement;
|
|
35
|
+
prototype: HTMLAnchorElement;
|
|
36
|
+
};
|
|
37
|
+
})[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { Appearance } from '../old-button/types';
|
|
5
|
+
export type ButtonGroupProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The appearance to apply to all buttons.
|
|
8
|
+
*/
|
|
9
|
+
appearance?: Appearance;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export default function ButtonGroup({ appearance, children, }: ButtonGroupProps): jsx.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../containers/button-group';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default, type ButtonProps, } from '../new-button/variants/default/button';
|
|
2
|
+
export { default as LinkButton, type LinkButtonProps, } from '../new-button/variants/default/link';
|
|
3
|
+
export { default as IconButton, type IconButtonProps, } from '../new-button/variants/icon/button';
|
|
4
|
+
export { default as LinkIconButton, type LinkIconButtonProps, } from '../new-button/variants/icon/link';
|
|
5
|
+
export { SplitButton } from '../new-button/containers/split-button';
|
|
6
|
+
export type { Appearance, Spacing } from '../new-button/variants/types';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { Appearance, Spacing, BaseOwnProps, BaseProps, } from '../old-button/types';
|
|
2
|
+
export type { ButtonProps } from './standard-button';
|
|
3
|
+
export type { LoadingButtonProps, LoadingButtonOwnProps, } from './loading-button';
|
|
4
|
+
export type { ThemeTokens, ThemeProps, InteractionState, CustomThemeButtonProps, CustomThemeButtonOwnProps, } from './custom-theme-button';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as UNSAFE_BUTTON } from '../new-button/variants/default/button';
|
|
2
|
+
export { default as UNSAFE_ICON_BUTTON } from '../new-button/variants/icon/button';
|
|
3
|
+
export { SplitButton as UNSAFE_SPLIT_BUTTON, SplitButtonContainer as UNSAFE_SPLIT_BUTTON_CONTAINER, Divider as UNSAFE_DIVIDER, getActions as UNSAFE_GET_ACTIONS, } from '../new-button/containers/split-button';
|
|
4
|
+
export { SplitButtonContext as UNSAFE_SPLIT_BUTTON_CONTEXT } from '../new-button/containers/split-button/split-button-context';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { Appearance, Spacing, BaseOwnProps, BaseProps, } from './entry-points/types';
|
|
2
|
+
export { default, } from './entry-points/standard-button';
|
|
3
|
+
export type { ButtonProps } from './entry-points/standard-button';
|
|
4
|
+
export { default as LoadingButton } from './entry-points/loading-button';
|
|
5
|
+
export type { LoadingButtonProps, LoadingButtonOwnProps, } from './entry-points/loading-button';
|
|
6
|
+
export { default as CustomThemeButton, Theme, } from './entry-points/custom-theme-button';
|
|
7
|
+
export type { ThemeTokens, ThemeProps, InteractionState, CustomThemeButtonProps, CustomThemeButtonOwnProps, } from './entry-points/custom-theme-button';
|
|
8
|
+
export { default as ButtonGroup } from './entry-points/button-group';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SplitButtonAppearance, SplitButtonSpacing } from './types';
|
|
3
|
+
type NavigationSplitButtonContextProps = {
|
|
4
|
+
appearance: 'navigation';
|
|
5
|
+
isHighlighted: boolean;
|
|
6
|
+
};
|
|
7
|
+
type MainSplitButtonContextProps = {
|
|
8
|
+
appearance: SplitButtonAppearance;
|
|
9
|
+
spacing: SplitButtonSpacing;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
type SplitButtonContextProps = NavigationSplitButtonContextProps | MainSplitButtonContextProps;
|
|
13
|
+
/**
|
|
14
|
+
* TODO: Add jsdoc
|
|
15
|
+
*/
|
|
16
|
+
export declare const SplitButtonContext: import("react").Context<SplitButtonContextProps | undefined>;
|
|
17
|
+
type UseSplitButtonContext = {
|
|
18
|
+
appearance: SplitButtonAppearance | 'subtle';
|
|
19
|
+
spacing: SplitButtonSpacing;
|
|
20
|
+
isDisabled: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* isSelected state has limited relevance (e.g. dropdown-menu trigger button).
|
|
23
|
+
* There is no isSelected state for color variants (e.g. primary, danger, warning).
|
|
24
|
+
* Hens we provide ability to override the isSelected state with isActiveOverSelected to display `active` state instead of `selected` state.
|
|
25
|
+
*/
|
|
26
|
+
isActiveOverSelected: boolean;
|
|
27
|
+
isNavigationSplitButton: boolean;
|
|
28
|
+
isHighlighted: boolean;
|
|
29
|
+
};
|
|
30
|
+
type NavigationSplitButtonContext = UseSplitButtonContext & {
|
|
31
|
+
appearance: 'subtle';
|
|
32
|
+
spacing: 'default';
|
|
33
|
+
isDisabled: false;
|
|
34
|
+
isActiveOverSelected: false;
|
|
35
|
+
isNavigationSplitButton: true;
|
|
36
|
+
isHighlighted: boolean;
|
|
37
|
+
};
|
|
38
|
+
type MainSplitButtonContext = UseSplitButtonContext & {
|
|
39
|
+
appearance: SplitButtonAppearance;
|
|
40
|
+
spacing: SplitButtonSpacing;
|
|
41
|
+
isDisabled: boolean;
|
|
42
|
+
isActiveOverSelected: true;
|
|
43
|
+
isNavigationSplitButton: false;
|
|
44
|
+
isHighlighted: false;
|
|
45
|
+
};
|
|
46
|
+
export declare const useSplitButtonContext: () => NavigationSplitButtonContext | MainSplitButtonContext | undefined;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { SplitButtonAppearance, SplitButtonContextAppearance, SplitButtonSpacing } from './types';
|
|
5
|
+
type DividerProps = {
|
|
6
|
+
appearance: SplitButtonContextAppearance;
|
|
7
|
+
spacing: SplitButtonSpacing;
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* TODO: Add JSDoc
|
|
12
|
+
*/
|
|
13
|
+
export declare const Divider: ({ appearance, spacing, isDisabled, }: DividerProps) => jsx.JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* TODO: Add JSdoc
|
|
16
|
+
*/
|
|
17
|
+
export declare const SplitButtonContainer: ({ children }: {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}) => jsx.JSX.Element;
|
|
20
|
+
type SplitButtonProps = {
|
|
21
|
+
/**
|
|
22
|
+
* Only two children are allowed.
|
|
23
|
+
* First child is the primary action, second child is the secondary action.
|
|
24
|
+
* The assumption is that for both children trees there is a button reading the context.
|
|
25
|
+
*/
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
appearance?: SplitButtonAppearance;
|
|
28
|
+
spacing?: SplitButtonSpacing;
|
|
29
|
+
isDisabled?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* TODO: Add description when adding docs
|
|
33
|
+
*/
|
|
34
|
+
export declare const SplitButton: ({ children, appearance, spacing, isDisabled, }: SplitButtonProps) => jsx.JSX.Element;
|
|
35
|
+
type SplitButtonWithSlotsProps = {
|
|
36
|
+
primaryAction: ReactNode;
|
|
37
|
+
secondaryAction: ReactNode;
|
|
38
|
+
appearance?: SplitButtonAppearance;
|
|
39
|
+
spacing?: SplitButtonSpacing;
|
|
40
|
+
isDisabled?: boolean;
|
|
41
|
+
isSelected?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* TODO: Decide on API
|
|
45
|
+
*/
|
|
46
|
+
export declare const SplitButtonWithSlots: ({ primaryAction, secondaryAction, appearance, spacing, isDisabled, }: SplitButtonWithSlotsProps) => jsx.JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Appearance, Spacing } from '../../variants/types';
|
|
2
|
+
export type SplitButtonAppearance = Extract<Appearance, 'default' | 'primary' | 'danger' | 'warning'>;
|
|
3
|
+
export type SplitButtonContextAppearance = SplitButtonAppearance | 'navigation';
|
|
4
|
+
export type SplitButtonSpacing = Extract<Spacing, 'default' | 'compact'>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export declare const getActions: (children: ReactNode) => {
|
|
3
|
+
PrimaryAction: import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal;
|
|
4
|
+
SecondaryAction: import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal;
|
|
5
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type CommonButtonVariantProps } from '../types';
|
|
3
|
+
import { type CommonDefaultButtonProps } from './types';
|
|
4
|
+
export type ButtonProps = CommonDefaultButtonProps & CommonButtonVariantProps;
|
|
5
|
+
/**
|
|
6
|
+
* __Button__
|
|
7
|
+
*
|
|
8
|
+
* @warning __UNSAFE__ Button is not yet safe for production use.
|
|
9
|
+
*
|
|
10
|
+
* A button triggers an event or action.
|
|
11
|
+
*
|
|
12
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
13
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
14
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
|
+
*/
|
|
16
|
+
declare const Button: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonDefaultButtonProps & Omit<import("../types").AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<HTMLButtonElement>>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>>;
|
|
17
|
+
export default Button;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { type Ref } from 'react';
|
|
2
|
+
import { type CommonLinkVariantProps } from '../types';
|
|
3
|
+
import { type CommonDefaultButtonProps } from './types';
|
|
4
|
+
export type LinkButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonDefaultButtonProps & CommonLinkVariantProps<RouterLinkConfig>;
|
|
5
|
+
declare const LinkButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, autoFocus, appearance, spacing, isDisabled, isSelected, iconBefore, iconAfter, children, shouldFitContainer, interactionName, overlay, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, testId, href, ...rest }: LinkButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
|
|
6
|
+
/**
|
|
7
|
+
* __Link Button__
|
|
8
|
+
*
|
|
9
|
+
* Renders a link in the style of a button.
|
|
10
|
+
*
|
|
11
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
12
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
13
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
14
|
+
*/
|
|
15
|
+
declare const LinkButton: <RouterLinkConfig extends Record<string, any> = never>(props: CommonDefaultButtonProps & {
|
|
16
|
+
href: string | RouterLinkConfig;
|
|
17
|
+
} & Omit<import("../types").AdditionalHTMLElementPropsExtender<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href">>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLAnchorElement> & {
|
|
18
|
+
ref?: React.Ref<HTMLAnchorElement> | undefined;
|
|
19
|
+
}) => ReturnType<typeof LinkButtonBase>;
|
|
20
|
+
export default LinkButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type CommonDefaultButtonProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Places an icon within the button, after the button's text
|
|
5
|
+
*/
|
|
6
|
+
iconAfter?: React.ReactChild;
|
|
7
|
+
/**
|
|
8
|
+
* Places an icon within the button, before the button's text
|
|
9
|
+
*/
|
|
10
|
+
iconBefore?: React.ReactChild;
|
|
11
|
+
/**
|
|
12
|
+
* Option to fit button width to its parent width
|
|
13
|
+
*/
|
|
14
|
+
shouldFitContainer?: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type UseButtonBaseArgs, type UseButtonBaseReturn } from '../shared/use-button-base';
|
|
2
|
+
import { type CommonDefaultButtonProps } from './types';
|
|
3
|
+
type UseDefaultButtonArgs<TagName extends HTMLElement> = UseButtonBaseArgs<TagName> & CommonDefaultButtonProps;
|
|
4
|
+
type UseButtonReturn<TagName extends HTMLElement> = UseButtonBaseReturn<TagName>;
|
|
5
|
+
/**
|
|
6
|
+
* __Use default button base__
|
|
7
|
+
*
|
|
8
|
+
* A React hook that accepts a set of default Button props,
|
|
9
|
+
* and processes them to return consistent base props for usage
|
|
10
|
+
* across Button and LinkButton variants.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
declare const useDefaultButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, iconBefore, iconAfter, interactionName, isDisabled, isSelected, children, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseDefaultButtonArgs<TagName>) => UseButtonReturn<TagName>;
|
|
15
|
+
export default useDefaultButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type CommonButtonVariantProps } from '../types';
|
|
3
|
+
import { type CommonIconButtonProps } from './types';
|
|
4
|
+
export type IconButtonProps = CommonIconButtonProps & CommonButtonVariantProps;
|
|
5
|
+
/**
|
|
6
|
+
* __Icon Button__
|
|
7
|
+
*
|
|
8
|
+
* TODO: Description
|
|
9
|
+
*
|
|
10
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
11
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
12
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
|
+
*/
|
|
14
|
+
declare const IconButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonIconButtonProps & Omit<import("../types").AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<HTMLButtonElement>>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>>;
|
|
15
|
+
export default IconButton;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { type Ref } from 'react';
|
|
2
|
+
import { type CommonLinkVariantProps } from '../types';
|
|
3
|
+
import { type CommonIconButtonProps } from './types';
|
|
4
|
+
export type LinkIconButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonIconButtonProps & CommonLinkVariantProps<RouterLinkConfig>;
|
|
5
|
+
declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, autoFocus, appearance, spacing, isDisabled, isSelected, icon, children, interactionName, overlay, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, testId, href, ...rest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
|
|
6
|
+
/**
|
|
7
|
+
* __Link Icon Button__
|
|
8
|
+
*
|
|
9
|
+
* Renders a link in the style of an icon button.
|
|
10
|
+
*
|
|
11
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
12
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
13
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
14
|
+
*/
|
|
15
|
+
declare const LinkIconButton: <RouterLinkConfig extends Record<string, any> = never>(props: CommonIconButtonProps & {
|
|
16
|
+
href: string | RouterLinkConfig;
|
|
17
|
+
} & Omit<import("../types").AdditionalHTMLElementPropsExtender<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href">>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLAnchorElement> & {
|
|
18
|
+
ref?: React.Ref<HTMLAnchorElement> | undefined;
|
|
19
|
+
}) => ReturnType<typeof LinkIconButtonBase>;
|
|
20
|
+
export default LinkIconButton;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type CommonIconButtonProps = {
|
|
3
|
+
/**
|
|
4
|
+
* TODO: Consider locking-down icon props by converting from slot props to component props
|
|
5
|
+
* Places an icon within the button, after the button's text
|
|
6
|
+
*/
|
|
7
|
+
icon: React.ReactChild;
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type UseButtonBaseArgs, type UseButtonBaseReturn } from '../shared/use-button-base';
|
|
2
|
+
import { type CommonIconButtonProps } from './types';
|
|
3
|
+
type UseIconButtonArgs<TagName extends HTMLElement> = UseButtonBaseArgs<TagName> & CommonIconButtonProps;
|
|
4
|
+
type UseIconButtonReturn<TagName extends HTMLElement> = UseButtonBaseReturn<TagName>;
|
|
5
|
+
/**
|
|
6
|
+
* __Use icon button__
|
|
7
|
+
*
|
|
8
|
+
* A React hook that accepts a set of icon Button props,
|
|
9
|
+
* and processes them to return consistent base props for usage
|
|
10
|
+
* across IconButton and LinkIconButton variants.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
declare const useIconButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, icon, interactionName, isDisabled, isSelected, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseIconButtonArgs<TagName>) => UseIconButtonReturn<TagName>;
|
|
15
|
+
export default useIconButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type BackgroundColor, type TextColor } from '@atlaskit/primitives';
|
|
2
|
+
import { type Appearance } from '../types';
|
|
3
|
+
export type ColorGroup<T extends BackgroundColor | TextColor> = {
|
|
4
|
+
default: T;
|
|
5
|
+
hover?: T;
|
|
6
|
+
active?: T;
|
|
7
|
+
disabled?: T;
|
|
8
|
+
selected?: T;
|
|
9
|
+
};
|
|
10
|
+
export type ColorPreset<T extends BackgroundColor | TextColor> = {
|
|
11
|
+
[key in Appearance]: ColorGroup<T>;
|
|
12
|
+
};
|
|
13
|
+
type Values = {
|
|
14
|
+
background: ColorPreset<BackgroundColor>;
|
|
15
|
+
color: ColorPreset<TextColor>;
|
|
16
|
+
};
|
|
17
|
+
declare const values: Values;
|
|
18
|
+
export default values;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ContentProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
type?: 'text' | 'icon';
|
|
5
|
+
hasOverlay: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* __Content__
|
|
9
|
+
*
|
|
10
|
+
* Used for slots within a Button, including icons and text content.
|
|
11
|
+
*/
|
|
12
|
+
declare const Content: ({ children, type, hasOverlay }: ContentProps) => JSX.Element;
|
|
13
|
+
export default Content;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { xcss } from '@atlaskit/primitives';
|
|
3
|
+
import { type CommonButtonProps } from '../types';
|
|
4
|
+
export type ControlledEvents<TagName extends HTMLElement> = Pick<React.DOMAttributes<TagName>, 'onMouseDownCapture' | 'onMouseUpCapture' | 'onKeyDownCapture' | 'onKeyUpCapture' | 'onTouchStartCapture' | 'onTouchEndCapture' | 'onPointerDownCapture' | 'onPointerUpCapture' | 'onClickCapture' | 'onClick'>;
|
|
5
|
+
export type ControlledEventsPassed<TagName extends HTMLElement> = Omit<ControlledEvents<TagName>, 'onClick'> & Pick<CommonButtonProps<TagName>, 'onClick'>;
|
|
6
|
+
export type UseButtonBaseArgs<TagName extends HTMLElement> = {
|
|
7
|
+
ref: React.Ref<TagName>;
|
|
8
|
+
/**
|
|
9
|
+
* The type of button. Used to pass action subject context to analytics.
|
|
10
|
+
*/
|
|
11
|
+
buttonType: 'button' | 'link';
|
|
12
|
+
isIconButton?: boolean;
|
|
13
|
+
hasIconBefore?: boolean;
|
|
14
|
+
hasIconAfter?: boolean;
|
|
15
|
+
shouldFitContainer?: boolean;
|
|
16
|
+
} & Pick<CommonButtonProps<TagName>, 'analyticsContext' | 'appearance' | 'autoFocus' | 'children' | 'interactionName' | 'isDisabled' | 'isSelected' | 'overlay' | 'spacing'> & ControlledEventsPassed<TagName>;
|
|
17
|
+
export type UseButtonBaseReturn<TagName extends HTMLElement> = {
|
|
18
|
+
xcss: ReturnType<typeof xcss>;
|
|
19
|
+
ref(node: TagName | null): void;
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
isDisabled: boolean;
|
|
22
|
+
} & ControlledEvents<TagName>;
|
|
23
|
+
/**
|
|
24
|
+
* __Use button base__
|
|
25
|
+
*
|
|
26
|
+
* A React hook that accepts a set of common Button props,
|
|
27
|
+
* and processes them to return consistent base props for usage
|
|
28
|
+
* across various Button components.
|
|
29
|
+
*
|
|
30
|
+
* It also:
|
|
31
|
+
* - Implements auto focus when enabled.
|
|
32
|
+
* - Appends the `onClick` event with UFO analytics tracking.
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
declare const useButtonBase: <TagName extends HTMLElement>({ analyticsContext, appearance: propAppearance, autoFocus, buttonType, interactionName, isDisabled: propIsDisabled, isSelected, isIconButton, hasIconBefore, hasIconAfter, children, onClick: providedOnClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing: propSpacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
|
|
37
|
+
export default useButtonBase;
|