@atlaskit/button 20.4.1 → 20.5.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +17 -58
  2. package/dist/cjs/new-button/containers/split-button/split-button.js +23 -1
  3. package/dist/cjs/new-button/variants/shared/use-button-base.js +55 -2
  4. package/dist/cjs/old-button/shared/button-base.js +1 -1
  5. package/dist/es2019/new-button/containers/split-button/split-button.js +23 -1
  6. package/dist/es2019/new-button/variants/shared/use-button-base.js +55 -2
  7. package/dist/es2019/old-button/shared/button-base.js +1 -1
  8. package/dist/esm/new-button/containers/split-button/split-button.js +23 -1
  9. package/dist/esm/new-button/variants/shared/use-button-base.js +55 -2
  10. package/dist/esm/old-button/shared/button-base.js +1 -1
  11. package/dist/types/new-button/containers/split-button/utils.d.ts +2 -2
  12. package/dist/types/new-button/variants/default/link.d.ts +2 -2
  13. package/dist/types/new-button/variants/icon/link.d.ts +2 -2
  14. package/dist/types/new-button/variants/shared/content.d.ts +1 -1
  15. package/dist/types/new-button/variants/shared/icon-renderer.d.ts +2 -2
  16. package/dist/types/new-button/variants/shared/loading-overlay.d.ts +2 -2
  17. package/dist/types/old-button/shared/loading-spinner.d.ts +2 -2
  18. package/dist/types-ts4.5/new-button/containers/split-button/utils.d.ts +2 -2
  19. package/dist/types-ts4.5/new-button/variants/default/link.d.ts +2 -2
  20. package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +2 -2
  21. package/dist/types-ts4.5/new-button/variants/shared/content.d.ts +1 -1
  22. package/dist/types-ts4.5/new-button/variants/shared/icon-renderer.d.ts +2 -2
  23. package/dist/types-ts4.5/new-button/variants/shared/loading-overlay.d.ts +2 -2
  24. package/dist/types-ts4.5/old-button/shared/loading-spinner.d.ts +2 -2
  25. package/package.json +4 -3
  26. package/codemods/15.0.0-lite-mode.tsx +0 -45
  27. package/codemods/__tests__/15.0.0-lite-mode/optimistic.tsx +0 -638
  28. package/codemods/__tests__/15.0.0-lite-mode/safe.tsx +0 -223
  29. package/codemods/__tests__/15.0.0-lite-mode/shared.tsx +0 -255
  30. package/codemods/helpers/15.0.0-runner.tsx +0 -167
  31. package/codemods/optimistic-15.0.0-lite-mode.tsx +0 -263
@@ -1,8 +1,8 @@
1
- import { type Ref } from 'react';
1
+ import React, { type Ref } from 'react';
2
2
  import { type AdditionalDefaultLinkVariantProps, type CommonLinkVariantProps } from '../types';
3
3
  import { type CommonDefaultButtonProps } from './types';
4
4
  export type LinkButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonDefaultButtonProps & CommonLinkVariantProps<RouterLinkConfig> & AdditionalDefaultLinkVariantProps;
5
- declare const LinkButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, appearance, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, autoFocus, children, href, iconAfter, iconBefore, interactionName, isDisabled, isSelected, onClick, onClickCapture, onKeyDownCapture, onKeyUpCapture, onMouseDownCapture, onMouseUpCapture, onPointerDownCapture, onPointerUpCapture, onTouchEndCapture, onTouchStartCapture, shouldFitContainer, spacing, testId, ...unsafeRest }: LinkButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
5
+ declare const LinkButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, appearance, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, autoFocus, children, href, iconAfter, iconBefore, interactionName, isDisabled, isSelected, onClick, onClickCapture, onKeyDownCapture, onKeyUpCapture, onMouseDownCapture, onMouseUpCapture, onPointerDownCapture, onPointerUpCapture, onTouchEndCapture, onTouchStartCapture, shouldFitContainer, spacing, testId, ...unsafeRest }: LinkButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => React.JSX.Element;
6
6
  /**
7
7
  * __Link Button__
8
8
  *
@@ -1,8 +1,8 @@
1
- import { type Ref } from 'react';
1
+ import React, { type Ref } from 'react';
2
2
  import { type CommonLinkVariantProps } from '../types';
3
3
  import { type CommonIconButtonProps } from './types';
4
4
  export type LinkIconButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonIconButtonProps & CommonLinkVariantProps<RouterLinkConfig>;
5
- declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ "aria-label": preventedAriaLabel, "aria-labelledby": ariaLabelledBy, analyticsContext, appearance, autoFocus, href, icon, interactionName, isDisabled, isSelected, isTooltipDisabled, label, onClick, onClickCapture, onKeyDownCapture, onKeyUpCapture, onMouseDownCapture, onMouseUpCapture, onPointerDownCapture, onPointerUpCapture, onTouchEndCapture, onTouchStartCapture, shape, spacing, testId, tooltip, ...unsafeRest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
5
+ declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ "aria-label": preventedAriaLabel, "aria-labelledby": ariaLabelledBy, analyticsContext, appearance, autoFocus, href, icon, interactionName, isDisabled, isSelected, isTooltipDisabled, label, onClick, onClickCapture, onKeyDownCapture, onKeyUpCapture, onMouseDownCapture, onMouseUpCapture, onPointerDownCapture, onPointerUpCapture, onTouchEndCapture, onTouchStartCapture, shape, spacing, testId, tooltip, ...unsafeRest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => React.JSX.Element;
6
6
  /**
7
7
  * __Link Icon Button__
8
8
  *
@@ -10,5 +10,5 @@ type ContentProps = {
10
10
  *
11
11
  * Used for slots within a Button, including icons and text content.
12
12
  */
13
- declare const Content: ({ children, type, isLoading, position }: ContentProps) => JSX.Element;
13
+ declare const Content: ({ children, type, isLoading, position }: ContentProps) => React.JSX.Element;
14
14
  export default Content;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { type IconProp } from '../types';
3
3
  /**
4
4
  * __Icon renderer__
@@ -8,5 +8,5 @@ import { type IconProp } from '../types';
8
8
  */
9
9
  declare const IconRenderer: ({ icon: Icon }: {
10
10
  icon: IconProp;
11
- }) => JSX.Element;
11
+ }) => React.JSX.Element;
12
12
  export default IconRenderer;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { type Appearance, type ButtonSpacing } from '../types';
3
3
  export default function renderLoadingOverlay({ appearance, spacing, isDisabled, isSelected, testId, }: {
4
4
  spacing?: ButtonSpacing;
@@ -6,4 +6,4 @@ export default function renderLoadingOverlay({ appearance, spacing, isDisabled,
6
6
  isDisabled?: boolean;
7
7
  isSelected?: boolean;
8
8
  testId?: string;
9
- }): JSX.Element;
9
+ }): React.JSX.Element;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { type BaseProps } from '../types';
3
3
  type LoadingSpinnerProps = Pick<BaseProps, 'appearance' | 'isDisabled' | 'isSelected' | 'spacing'>;
4
- export default function LoadingSpinner({ appearance, isDisabled, isSelected, spacing, }: LoadingSpinnerProps): JSX.Element;
4
+ export default function LoadingSpinner({ appearance, isDisabled, isSelected, spacing, }: LoadingSpinnerProps): React.JSX.Element;
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from 'react';
2
2
  export declare const getActions: (children: ReactNode) => {
3
- PrimaryAction: string | number | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactFragment | import("react").ReactPortal;
4
- SecondaryAction: string | number | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactFragment | import("react").ReactPortal;
3
+ PrimaryAction: string | number | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | import("react").ReactPortal;
4
+ SecondaryAction: string | number | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | import("react").ReactPortal;
5
5
  };
@@ -1,8 +1,8 @@
1
- import { type Ref } from 'react';
1
+ import React, { type Ref } from 'react';
2
2
  import { type AdditionalDefaultLinkVariantProps, type CommonLinkVariantProps } from '../types';
3
3
  import { type CommonDefaultButtonProps } from './types';
4
4
  export type LinkButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonDefaultButtonProps & CommonLinkVariantProps<RouterLinkConfig> & AdditionalDefaultLinkVariantProps;
5
- declare const LinkButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, appearance, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, autoFocus, children, href, iconAfter, iconBefore, interactionName, isDisabled, isSelected, onClick, onClickCapture, onKeyDownCapture, onKeyUpCapture, onMouseDownCapture, onMouseUpCapture, onPointerDownCapture, onPointerUpCapture, onTouchEndCapture, onTouchStartCapture, shouldFitContainer, spacing, testId, ...unsafeRest }: LinkButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
5
+ declare const LinkButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, appearance, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, autoFocus, children, href, iconAfter, iconBefore, interactionName, isDisabled, isSelected, onClick, onClickCapture, onKeyDownCapture, onKeyUpCapture, onMouseDownCapture, onMouseUpCapture, onPointerDownCapture, onPointerUpCapture, onTouchEndCapture, onTouchStartCapture, shouldFitContainer, spacing, testId, ...unsafeRest }: LinkButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => React.JSX.Element;
6
6
  /**
7
7
  * __Link Button__
8
8
  *
@@ -1,8 +1,8 @@
1
- import { type Ref } from 'react';
1
+ import React, { type Ref } from 'react';
2
2
  import { type CommonLinkVariantProps } from '../types';
3
3
  import { type CommonIconButtonProps } from './types';
4
4
  export type LinkIconButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonIconButtonProps & CommonLinkVariantProps<RouterLinkConfig>;
5
- declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ "aria-label": preventedAriaLabel, "aria-labelledby": ariaLabelledBy, analyticsContext, appearance, autoFocus, href, icon, interactionName, isDisabled, isSelected, isTooltipDisabled, label, onClick, onClickCapture, onKeyDownCapture, onKeyUpCapture, onMouseDownCapture, onMouseUpCapture, onPointerDownCapture, onPointerUpCapture, onTouchEndCapture, onTouchStartCapture, shape, spacing, testId, tooltip, ...unsafeRest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
5
+ declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ "aria-label": preventedAriaLabel, "aria-labelledby": ariaLabelledBy, analyticsContext, appearance, autoFocus, href, icon, interactionName, isDisabled, isSelected, isTooltipDisabled, label, onClick, onClickCapture, onKeyDownCapture, onKeyUpCapture, onMouseDownCapture, onMouseUpCapture, onPointerDownCapture, onPointerUpCapture, onTouchEndCapture, onTouchStartCapture, shape, spacing, testId, tooltip, ...unsafeRest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => React.JSX.Element;
6
6
  /**
7
7
  * __Link Icon Button__
8
8
  *
@@ -10,5 +10,5 @@ type ContentProps = {
10
10
  *
11
11
  * Used for slots within a Button, including icons and text content.
12
12
  */
13
- declare const Content: ({ children, type, isLoading, position }: ContentProps) => JSX.Element;
13
+ declare const Content: ({ children, type, isLoading, position }: ContentProps) => React.JSX.Element;
14
14
  export default Content;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { type IconProp } from '../types';
3
3
  /**
4
4
  * __Icon renderer__
@@ -8,5 +8,5 @@ import { type IconProp } from '../types';
8
8
  */
9
9
  declare const IconRenderer: ({ icon: Icon }: {
10
10
  icon: IconProp;
11
- }) => JSX.Element;
11
+ }) => React.JSX.Element;
12
12
  export default IconRenderer;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { type Appearance, type ButtonSpacing } from '../types';
3
3
  export default function renderLoadingOverlay({ appearance, spacing, isDisabled, isSelected, testId, }: {
4
4
  spacing?: ButtonSpacing;
@@ -6,4 +6,4 @@ export default function renderLoadingOverlay({ appearance, spacing, isDisabled,
6
6
  isDisabled?: boolean;
7
7
  isSelected?: boolean;
8
8
  testId?: string;
9
- }): JSX.Element;
9
+ }): React.JSX.Element;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { type BaseProps } from '../types';
3
3
  type LoadingSpinnerProps = Pick<BaseProps, 'appearance' | 'isDisabled' | 'isSelected' | 'spacing'>;
4
- export default function LoadingSpinner({ appearance, isDisabled, isSelected, spacing, }: LoadingSpinnerProps): JSX.Element;
4
+ export default function LoadingSpinner({ appearance, isDisabled, isSelected, spacing, }: LoadingSpinnerProps): React.JSX.Element;
5
5
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/button",
3
- "version": "20.4.1",
3
+ "version": "20.5.0",
4
4
  "description": "A button triggers an event or action. They let users know what will happen next.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -123,17 +123,18 @@
123
123
  "@testing-library/react": "^13.4.0",
124
124
  "@testing-library/user-event": "^14.4.3",
125
125
  "ast-types": "^0.13.3",
126
- "bind-event-listener": "^3.0.0",
127
126
  "jscodeshift": "^0.13.0",
128
127
  "lodash": "^4.17.21",
129
128
  "react-dom": "^18.2.0",
130
- "storybook-addon-performance": "^0.17.3",
131
129
  "typescript": "~5.4.2"
132
130
  },
133
131
  "homepage": "https://atlassian.design/components/button/",
134
132
  "platform-feature-flags": {
135
133
  "platform-component-visual-refresh": {
136
134
  "type": "boolean"
135
+ },
136
+ "platform_dst_button_replace_em_with_rem": {
137
+ "type": "boolean"
137
138
  }
138
139
  }
139
140
  }
@@ -1,45 +0,0 @@
1
- import { type API, type FileInfo, type Options } from 'jscodeshift';
2
- import { type Collection } from 'jscodeshift/src/Collection';
3
-
4
- import { changeType, transformButton } from './helpers/15.0.0-runner';
5
- import {
6
- getDefaultSpecifierName,
7
- type Nullable,
8
- shiftDefaultImport,
9
- } from './helpers/helpers-generic';
10
-
11
- export default function transformer(file: FileInfo, { jscodeshift: j }: API, options: Options) {
12
- return transformButton({
13
- file,
14
- j,
15
- custom: (base: Collection<any>) => {
16
- changeType({
17
- j,
18
- base,
19
- oldName: 'ButtonProps',
20
- newName: 'CustomThemeButtonProps',
21
- fallbackNameAlias: 'DSCustomThemeButtonProps',
22
- });
23
-
24
- const defaultName: Nullable<string> = getDefaultSpecifierName({
25
- j,
26
- base,
27
- packageName: '@atlaskit/button',
28
- });
29
- if (defaultName == null) {
30
- return;
31
- }
32
-
33
- shiftDefaultImport({
34
- j,
35
- base,
36
- defaultName,
37
- oldPackagePath: '@atlaskit/button',
38
- newPackagePath: '@atlaskit/button/custom-theme-button',
39
- });
40
- },
41
- });
42
- }
43
-
44
- // Note: not exporting a 'parser' because doing so
45
- // will prevent consumers overriding it