@atlaskit/button 20.3.10 → 20.3.11

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/button
2
2
 
3
+ ## 20.3.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#105924](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/105924)
8
+ [`b5716d4ae35de`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b5716d4ae35de) -
9
+ Unsets internal `SplitButton` context to fix an edge-case where appearances of deeply nested
10
+ Button components were being overridden.
11
+
3
12
  ## 20.3.10
4
13
 
5
14
  ### Patch Changes
@@ -492,7 +492,9 @@ var useButtonBase = function useButtonBase(_ref) {
492
492
  // TODO: remove me once we kill color fallbacks
493
493
  isSelected && appearance === 'discovery' && selectedDiscoveryStyles, isDisabled && disabledStyles, isCircle && !isSplitButton && circleStyles, spacing === 'compact' && spacingCompactStyles, hasIconBefore && buttonIconBeforeStyles, hasIconAfter && buttonIconAfterStyles, isIconButton && iconButtonStyles, isIconButton && spacing === 'compact' && iconButtonCompactStyles, shouldFitContainer && fullWidthStyles, isLoading && loadingStyles, isSplitButton && splitButtonStyles, isNavigationSplitButton && navigationSplitButtonStyles],
494
494
  isDisabled: isEffectivelyDisabled,
495
- children: /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children, isLoading ? /*#__PURE__*/_react.default.createElement(_primitives.Box, {
495
+ children: /*#__PURE__*/_react.default.createElement(_splitButtonContext.SplitButtonContext.Provider, {
496
+ value: undefined
497
+ }, children, isLoading ? /*#__PURE__*/_react.default.createElement(_primitives.Box, {
496
498
  as: "span",
497
499
  xcss: loadingOverlayStyles
498
500
  }, (0, _loadingOverlay.default)({
@@ -133,7 +133,7 @@ var ButtonBase = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(prop
133
133
  action: 'clicked',
134
134
  componentName: 'button',
135
135
  packageName: "@atlaskit/button",
136
- packageVersion: "20.3.10",
136
+ packageVersion: "20.3.11",
137
137
  analyticsData: analyticsContext
138
138
  });
139
139
 
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useRef } from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import mergeRefs from '@atlaskit/ds-lib/merge-refs';
3
3
  import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
4
4
  import { useId } from '@atlaskit/ds-lib/use-id';
@@ -6,7 +6,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
6
6
  import { Box, xcss } from '@atlaskit/primitives';
7
7
  import * as colors from '@atlaskit/theme/colors';
8
8
  import VisuallyHidden from '@atlaskit/visually-hidden';
9
- import { useSplitButtonContext } from '../../containers/split-button/split-button-context';
9
+ import { SplitButtonContext, useSplitButtonContext } from '../../containers/split-button/split-button-context';
10
10
  import blockEvents from './block-events';
11
11
  import { LOADING_LABEL } from './constants';
12
12
  import renderLoadingOverlay from './loading-overlay';
@@ -471,7 +471,9 @@ const useButtonBase = ({
471
471
  // TODO: remove me once we kill color fallbacks
472
472
  isSelected && appearance === 'discovery' && selectedDiscoveryStyles, isDisabled && disabledStyles, isCircle && !isSplitButton && circleStyles, spacing === 'compact' && spacingCompactStyles, hasIconBefore && buttonIconBeforeStyles, hasIconAfter && buttonIconAfterStyles, isIconButton && iconButtonStyles, isIconButton && spacing === 'compact' && iconButtonCompactStyles, shouldFitContainer && fullWidthStyles, isLoading && loadingStyles, isSplitButton && splitButtonStyles, isNavigationSplitButton && navigationSplitButtonStyles],
473
473
  isDisabled: isEffectivelyDisabled,
474
- children: /*#__PURE__*/React.createElement(Fragment, null, children, isLoading ? /*#__PURE__*/React.createElement(Box, {
474
+ children: /*#__PURE__*/React.createElement(SplitButtonContext.Provider, {
475
+ value: undefined
476
+ }, children, isLoading ? /*#__PURE__*/React.createElement(Box, {
475
477
  as: "span",
476
478
  xcss: loadingOverlayStyles
477
479
  }, renderLoadingOverlay({
@@ -119,7 +119,7 @@ const ButtonBase = /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref)
119
119
  action: 'clicked',
120
120
  componentName: 'button',
121
121
  packageName: "@atlaskit/button",
122
- packageVersion: "20.3.10",
122
+ packageVersion: "20.3.11",
123
123
  analyticsData: analyticsContext
124
124
  });
125
125
 
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import React, { Fragment, useRef } from 'react';
4
+ import React, { useRef } from 'react';
5
5
  import mergeRefs from '@atlaskit/ds-lib/merge-refs';
6
6
  import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
7
7
  import { useId } from '@atlaskit/ds-lib/use-id';
@@ -9,7 +9,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { Box, xcss } from '@atlaskit/primitives';
10
10
  import * as colors from '@atlaskit/theme/colors';
11
11
  import VisuallyHidden from '@atlaskit/visually-hidden';
12
- import { useSplitButtonContext } from '../../containers/split-button/split-button-context';
12
+ import { SplitButtonContext, useSplitButtonContext } from '../../containers/split-button/split-button-context';
13
13
  import blockEvents from './block-events';
14
14
  import { LOADING_LABEL } from './constants';
15
15
  import renderLoadingOverlay from './loading-overlay';
@@ -482,7 +482,9 @@ var useButtonBase = function useButtonBase(_ref) {
482
482
  // TODO: remove me once we kill color fallbacks
483
483
  isSelected && appearance === 'discovery' && selectedDiscoveryStyles, isDisabled && disabledStyles, isCircle && !isSplitButton && circleStyles, spacing === 'compact' && spacingCompactStyles, hasIconBefore && buttonIconBeforeStyles, hasIconAfter && buttonIconAfterStyles, isIconButton && iconButtonStyles, isIconButton && spacing === 'compact' && iconButtonCompactStyles, shouldFitContainer && fullWidthStyles, isLoading && loadingStyles, isSplitButton && splitButtonStyles, isNavigationSplitButton && navigationSplitButtonStyles],
484
484
  isDisabled: isEffectivelyDisabled,
485
- children: /*#__PURE__*/React.createElement(Fragment, null, children, isLoading ? /*#__PURE__*/React.createElement(Box, {
485
+ children: /*#__PURE__*/React.createElement(SplitButtonContext.Provider, {
486
+ value: undefined
487
+ }, children, isLoading ? /*#__PURE__*/React.createElement(Box, {
486
488
  as: "span",
487
489
  xcss: loadingOverlayStyles
488
490
  }, renderLoadingOverlay({
@@ -125,7 +125,7 @@ var ButtonBase = /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
125
125
  action: 'clicked',
126
126
  componentName: 'button',
127
127
  packageName: "@atlaskit/button",
128
- packageVersion: "20.3.10",
128
+ packageVersion: "20.3.11",
129
129
  analyticsData: analyticsContext
130
130
  });
131
131
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/button",
3
- "version": "20.3.10",
3
+ "version": "20.3.11",
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/"
@@ -88,12 +88,12 @@
88
88
  "@atlaskit/ds-lib": "^3.3.0",
89
89
  "@atlaskit/focus-ring": "^2.0.0",
90
90
  "@atlaskit/icon": "^23.4.0",
91
- "@atlaskit/interaction-context": "^2.4.0",
91
+ "@atlaskit/interaction-context": "^2.5.0",
92
92
  "@atlaskit/platform-feature-flags": "^0.3.0",
93
93
  "@atlaskit/primitives": "^13.3.0",
94
94
  "@atlaskit/spinner": "^16.3.0",
95
95
  "@atlaskit/theme": "^14.0.0",
96
- "@atlaskit/tokens": "^3.1.0",
96
+ "@atlaskit/tokens": "^3.2.0",
97
97
  "@atlaskit/tooltip": "^19.0.0",
98
98
  "@atlaskit/visually-hidden": "^1.5.0",
99
99
  "@babel/runtime": "^7.0.0",
@@ -109,7 +109,7 @@
109
109
  "@atlaskit/app-provider": "^1.6.0",
110
110
  "@atlaskit/checkbox": "^15.2.0",
111
111
  "@atlaskit/docs": "*",
112
- "@atlaskit/dropdown-menu": "^12.24.0",
112
+ "@atlaskit/dropdown-menu": "^12.25.0",
113
113
  "@atlaskit/form": "^11.0.1",
114
114
  "@atlaskit/heading": "*",
115
115
  "@atlaskit/link": "*",
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
-
3
- import Button from '../src';
4
-
5
- import Example from './utils/example-runner';
6
- import { interactionTasks } from './utils/interaction-tasks';
7
-
8
- const button = () => <Example Component={Button} />;
9
-
10
- button.story = {
11
- name: 'Button',
12
- parameters: {
13
- performance: {
14
- interactions: interactionTasks,
15
- },
16
- },
17
- };
18
-
19
- export default button;
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
-
3
- import { CustomThemeButton } from '../src';
4
-
5
- import Example from './utils/example-runner';
6
- import { interactionTasks } from './utils/interaction-tasks';
7
-
8
- const customThemeButton = () => <Example Component={CustomThemeButton} />;
9
-
10
- customThemeButton.story = {
11
- name: 'CustomThemeButton',
12
- parameters: {
13
- performance: {
14
- interactions: interactionTasks,
15
- },
16
- },
17
- };
18
-
19
- export default customThemeButton;
@@ -1,10 +0,0 @@
1
- /* eslint-disable @atlaskit/design-system/no-legacy-icons -- TODO - https://product-fabric.atlassian.net/browse/DSP-20398 */
2
- import React from 'react';
3
-
4
- import AddIcon from '@atlaskit/icon/glyph/editor/add';
5
-
6
- import { CustomThemeButton } from '../src';
7
-
8
- export default () => (
9
- <CustomThemeButton iconBefore={<AddIcon label="" />}>Button</CustomThemeButton>
10
- );
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
-
3
- import Button from '../src';
4
-
5
- export default () => <Button>Default button</Button>;
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
-
3
- import { LoadingButton } from '../src';
4
-
5
- export default () => <LoadingButton isLoading>Loading button</LoadingButton>;
@@ -1,43 +0,0 @@
1
- import React, { useLayoutEffect, useRef, useState } from 'react';
2
-
3
- import { bindAll } from 'bind-event-listener';
4
-
5
- import type { ButtonProps } from '../../src';
6
-
7
- export default function Example({ Component }: { Component: ButtonProps['component'] }) {
8
- const [isSelected, setIsSelected] = useState<boolean>(false);
9
- const [isDisabled, setIsDisabled] = useState<boolean>(false);
10
- const ref = useRef<HTMLElement>(null);
11
-
12
- useLayoutEffect(() => {
13
- function toggleSelect() {
14
- setIsSelected((value) => !value);
15
- }
16
- function toggleDisabled() {
17
- setIsDisabled((value) => !value);
18
- }
19
-
20
- const el: HTMLElement | null = ref.current;
21
- if (!el) {
22
- throw new Error('Could not find button ref');
23
- }
24
-
25
- return bindAll(el, [
26
- { type: 'toggle-select', listener: toggleSelect },
27
- { type: 'toggle-disabled', listener: toggleDisabled },
28
- ]);
29
- }, []);
30
-
31
- return (
32
- // @ts-ignore
33
- <Component
34
- ref={ref}
35
- testId="my-button"
36
- isSelected={isSelected}
37
- isDisabled={isDisabled}
38
- data-is-selected={isSelected}
39
- >
40
- Hello world
41
- </Component>
42
- );
43
- }
@@ -1,77 +0,0 @@
1
- import { fireEvent } from '@testing-library/react';
2
- import { type InteractionTaskArgs, type PublicInteractionTask } from 'storybook-addon-performance';
3
-
4
- export const interactionTasks: PublicInteractionTask[] = [
5
- {
6
- name: 'Click a button',
7
- description: 'Recording how long a mousedown + click event take to be processed',
8
- run: async ({ container }: InteractionTaskArgs): Promise<void> => {
9
- const button: HTMLElement | null = container.querySelector('[data-testid="my-button"]');
10
- if (button == null) {
11
- throw new Error('Could not find button element');
12
- }
13
-
14
- fireEvent.mouseDown(button);
15
- fireEvent.click(button);
16
- },
17
- },
18
- {
19
- name: 'Focus on button',
20
- description: 'Focus on a button and wait for layout and paint to finish',
21
- run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
22
- const button: HTMLElement | null = container.querySelector('[data-testid="my-button"]');
23
- if (button == null) {
24
- throw new Error('Could not find button element');
25
- }
26
-
27
- await controls.time(async () => {
28
- fireEvent.focus(button);
29
- fireEvent.blur(button);
30
- });
31
- },
32
- },
33
- {
34
- name: 'Select button',
35
- description: 'Trigger the selection of a button',
36
- run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
37
- const button: HTMLElement | null = container.querySelector('[data-testid="my-button"]');
38
- if (button == null) {
39
- throw new Error('Could not find button element');
40
- }
41
-
42
- if (button.getAttribute('data-is-selected') !== 'false') {
43
- throw new Error('Should not start selected');
44
- }
45
-
46
- await controls.time(async () => {
47
- fireEvent(button, new Event('toggle-select'));
48
- });
49
-
50
- if (button.getAttribute('data-is-selected') !== 'true') {
51
- throw new Error('Should now be selected');
52
- }
53
- },
54
- },
55
- {
56
- name: 'Disable button',
57
- description: 'Trigger the disabling of a button',
58
- run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
59
- const button: HTMLElement | null = container.querySelector('[data-testid="my-button"]');
60
- if (button == null) {
61
- throw new Error('Could not find button element');
62
- }
63
-
64
- if (button.hasAttribute('disabled')) {
65
- throw new Error('Should not start disabled');
66
- }
67
-
68
- await controls.time(async () => {
69
- fireEvent(button, new Event('toggle-disabled'));
70
- });
71
-
72
- if (!button.hasAttribute('disabled')) {
73
- throw new Error('Should now be disabled');
74
- }
75
- },
76
- },
77
- ];