@kaizen/components 1.79.1 → 1.79.3
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/dist/cjs/src/__next__/Select/Select.cjs +2 -1
- package/dist/cjs/src/__next__/Select/subcomponents/Overlay/Overlay.cjs +3 -3
- package/dist/cjs/src/__next__/Select/subcomponents/SelectPopoverContents/SelectPopoverContents.cjs +5 -2
- package/dist/cjs/src/__next__/Tabs/subcomponents/TabList/TabList.cjs +3 -3
- package/dist/esm/src/__next__/Select/Select.mjs +2 -1
- package/dist/esm/src/__next__/Select/subcomponents/Overlay/Overlay.mjs +3 -3
- package/dist/esm/src/__next__/Select/subcomponents/SelectPopoverContents/SelectPopoverContents.mjs +5 -2
- package/dist/esm/src/__next__/Tabs/subcomponents/TabList/TabList.mjs +3 -3
- package/dist/styles.css +8 -0
- package/dist/types/__next__/Select/subcomponents/Overlay/Overlay.d.ts +2 -1
- package/dist/types/__next__/Select/subcomponents/SelectPopoverContents/SelectPopoverContents.d.ts +2 -1
- package/package.json +1 -1
- package/src/Modal/GenericModal/GenericModal.module.scss +2 -0
- package/src/Modal/GenericModal/_docs/GenericModal.spec.stories.tsx +6 -1
- package/src/__next__/Button/_docs/Button--migration-guide.mdx +12 -5
- package/src/__next__/Icon/_docs/Icon--migration-guide.mdx +11 -3
- package/src/__next__/Select/Select.tsx +3 -1
- package/src/__next__/Select/subcomponents/Overlay/Overlay.tsx +4 -2
- package/src/__next__/Select/subcomponents/SelectPopoverContents/SelectPopoverContents.tsx +3 -1
- package/src/__next__/Tabs/_docs/Tabs--migration-guide.mdx +10 -2
- package/src/__next__/Tabs/_docs/Tabs.spec.stories.tsx +48 -3
- package/src/__next__/Tabs/_docs/Tabs.stories.tsx +13 -2
- package/src/__next__/Tabs/subcomponents/TabList/TabList.tsx +3 -3
- package/src/__next__/Tooltip/_docs/Tooltip--migration-guide.mdx +62 -0
|
@@ -132,7 +132,8 @@ var Select = function (_a) {
|
|
|
132
132
|
}, React__default.default.createElement(SelectContext.SelectProvider, {
|
|
133
133
|
state: state
|
|
134
134
|
}, React__default.default.createElement(SelectPopoverContents.SelectPopoverContents, {
|
|
135
|
-
menuProps: menuProps
|
|
135
|
+
menuProps: menuProps,
|
|
136
|
+
popoverRef: refs.floating
|
|
136
137
|
}, children)))), validationMessage && React__default.default.createElement(FieldMessage.FieldMessage, tslib.__assign({}, errorMessageProps, {
|
|
137
138
|
id: validationId,
|
|
138
139
|
message: validationMessage,
|
|
@@ -14,7 +14,8 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
14
14
|
var Overlay = function (_a) {
|
|
15
15
|
var children = _a.children,
|
|
16
16
|
classNameOverride = _a.classNameOverride,
|
|
17
|
-
|
|
17
|
+
popoverRef = _a.popoverRef,
|
|
18
|
+
restProps = tslib.__rest(_a, ["children", "classNameOverride", "popoverRef"]);
|
|
18
19
|
var state = SelectContext.useSelectContext().state;
|
|
19
20
|
// Handle events that should cause the menu to close,
|
|
20
21
|
// e.g. blur, clicking outside, or pressing the escape key.
|
|
@@ -23,13 +24,12 @@ var Overlay = function (_a) {
|
|
|
23
24
|
isDismissable: true,
|
|
24
25
|
isOpen: state.isOpen,
|
|
25
26
|
onClose: state.close
|
|
26
|
-
}, overlayRef).overlayProps;
|
|
27
|
+
}, popoverRef !== null && popoverRef !== void 0 ? popoverRef : overlayRef).overlayProps;
|
|
27
28
|
// Wrap in <FocusScope> so that focus is restored back to the trigger when the menu is closed
|
|
28
29
|
// and auto focus on the first focusable item after loading. (disable eslint no-autofocus error for it)
|
|
29
30
|
// In addition, add hidden <DismissButton> components at the start and end of the list
|
|
30
31
|
// to allow screen reader users to dismiss the popup easily.
|
|
31
32
|
return React__default.default.createElement("div", tslib.__assign({
|
|
32
|
-
ref: overlayRef,
|
|
33
33
|
className: classNameOverride
|
|
34
34
|
}, overlayProps, restProps), React__default.default.createElement(focus.FocusScope, {
|
|
35
35
|
autoFocus: false,
|
package/dist/cjs/src/__next__/Select/subcomponents/SelectPopoverContents/SelectPopoverContents.cjs
CHANGED
|
@@ -14,7 +14,8 @@ function _interopDefault(e) {
|
|
|
14
14
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
15
15
|
var SelectPopoverContents = function (_a) {
|
|
16
16
|
var children = _a.children,
|
|
17
|
-
menuProps = _a.menuProps
|
|
17
|
+
menuProps = _a.menuProps,
|
|
18
|
+
popoverRef = _a.popoverRef;
|
|
18
19
|
var state = SelectContext.useSelectContext().state;
|
|
19
20
|
// The collection structure is set by useSelectState's `children`
|
|
20
21
|
// which we have used a util to ensure the following structure
|
|
@@ -23,7 +24,9 @@ var SelectPopoverContents = function (_a) {
|
|
|
23
24
|
var itemNodes = Array.from(state.collection);
|
|
24
25
|
return React__default.default.createElement("div", {
|
|
25
26
|
className: SelectPopoverContents_module.selectPopoverContents
|
|
26
|
-
}, React__default.default.createElement(Overlay.Overlay,
|
|
27
|
+
}, React__default.default.createElement(Overlay.Overlay, {
|
|
28
|
+
popoverRef: popoverRef
|
|
29
|
+
}, React__default.default.createElement(ListBox.ListBox, {
|
|
27
30
|
menuProps: menuProps
|
|
28
31
|
}, children ? children({
|
|
29
32
|
items: itemNodes
|
|
@@ -70,7 +70,7 @@ var TabList = function (props) {
|
|
|
70
70
|
}
|
|
71
71
|
setLeftArrowEnabled(false);
|
|
72
72
|
}, {
|
|
73
|
-
threshold: 0.
|
|
73
|
+
threshold: 0.8,
|
|
74
74
|
root: containerElement
|
|
75
75
|
});
|
|
76
76
|
firstTabObserver.observe(isRTL$1 ? tabs[tabs.length - 1] : tabs[0]);
|
|
@@ -81,7 +81,7 @@ var TabList = function (props) {
|
|
|
81
81
|
}
|
|
82
82
|
setRightArrowEnabled(false);
|
|
83
83
|
}, {
|
|
84
|
-
threshold: 0.
|
|
84
|
+
threshold: 0.8,
|
|
85
85
|
root: containerElement
|
|
86
86
|
});
|
|
87
87
|
lastTabObserver.observe(isRTL$1 ? tabs[0] : tabs[tabs.length - 1]);
|
|
@@ -89,7 +89,7 @@ var TabList = function (props) {
|
|
|
89
89
|
firstTabObserver.disconnect();
|
|
90
90
|
lastTabObserver.disconnect();
|
|
91
91
|
};
|
|
92
|
-
}, [isDocumentReady, containerElement, isRTL$1]);
|
|
92
|
+
}, [isDocumentReady, containerElement, isRTL$1, tabListContext === null || tabListContext === void 0 ? void 0 : tabListContext.collection.size]);
|
|
93
93
|
React.useEffect(function () {
|
|
94
94
|
var _a;
|
|
95
95
|
if (!isDocumentReady) {
|
|
@@ -124,7 +124,8 @@ const Select = /*#__PURE__*/function () {
|
|
|
124
124
|
}, /*#__PURE__*/React.createElement(SelectProvider, {
|
|
125
125
|
state: state
|
|
126
126
|
}, /*#__PURE__*/React.createElement(SelectPopoverContents, {
|
|
127
|
-
menuProps: menuProps
|
|
127
|
+
menuProps: menuProps,
|
|
128
|
+
popoverRef: refs.floating
|
|
128
129
|
}, children))))), validationMessage && (/*#__PURE__*/React.createElement(FieldMessage, __assign({}, errorMessageProps, {
|
|
129
130
|
id: validationId,
|
|
130
131
|
message: validationMessage,
|
|
@@ -7,7 +7,8 @@ const Overlay = /*#__PURE__*/function () {
|
|
|
7
7
|
const Overlay = function (_a) {
|
|
8
8
|
var children = _a.children,
|
|
9
9
|
classNameOverride = _a.classNameOverride,
|
|
10
|
-
|
|
10
|
+
popoverRef = _a.popoverRef,
|
|
11
|
+
restProps = __rest(_a, ["children", "classNameOverride", "popoverRef"]);
|
|
11
12
|
var state = useSelectContext().state;
|
|
12
13
|
// Handle events that should cause the menu to close,
|
|
13
14
|
// e.g. blur, clicking outside, or pressing the escape key.
|
|
@@ -16,13 +17,12 @@ const Overlay = /*#__PURE__*/function () {
|
|
|
16
17
|
isDismissable: true,
|
|
17
18
|
isOpen: state.isOpen,
|
|
18
19
|
onClose: state.close
|
|
19
|
-
}, overlayRef).overlayProps;
|
|
20
|
+
}, popoverRef !== null && popoverRef !== void 0 ? popoverRef : overlayRef).overlayProps;
|
|
20
21
|
// Wrap in <FocusScope> so that focus is restored back to the trigger when the menu is closed
|
|
21
22
|
// and auto focus on the first focusable item after loading. (disable eslint no-autofocus error for it)
|
|
22
23
|
// In addition, add hidden <DismissButton> components at the start and end of the list
|
|
23
24
|
// to allow screen reader users to dismiss the popup easily.
|
|
24
25
|
return /*#__PURE__*/React.createElement("div", __assign({
|
|
25
|
-
ref: overlayRef,
|
|
26
26
|
className: classNameOverride
|
|
27
27
|
}, overlayProps, restProps), /*#__PURE__*/React.createElement(FocusScope, {
|
|
28
28
|
autoFocus: false,
|
package/dist/esm/src/__next__/Select/subcomponents/SelectPopoverContents/SelectPopoverContents.mjs
CHANGED
|
@@ -7,7 +7,8 @@ import styles from './SelectPopoverContents.module.scss.mjs';
|
|
|
7
7
|
const SelectPopoverContents = /*#__PURE__*/function () {
|
|
8
8
|
const SelectPopoverContents = function (_a) {
|
|
9
9
|
var children = _a.children,
|
|
10
|
-
menuProps = _a.menuProps
|
|
10
|
+
menuProps = _a.menuProps,
|
|
11
|
+
popoverRef = _a.popoverRef;
|
|
11
12
|
var state = useSelectContext().state;
|
|
12
13
|
// The collection structure is set by useSelectState's `children`
|
|
13
14
|
// which we have used a util to ensure the following structure
|
|
@@ -16,7 +17,9 @@ const SelectPopoverContents = /*#__PURE__*/function () {
|
|
|
16
17
|
var itemNodes = Array.from(state.collection);
|
|
17
18
|
return /*#__PURE__*/React.createElement("div", {
|
|
18
19
|
className: styles.selectPopoverContents
|
|
19
|
-
}, /*#__PURE__*/React.createElement(Overlay,
|
|
20
|
+
}, /*#__PURE__*/React.createElement(Overlay, {
|
|
21
|
+
popoverRef: popoverRef
|
|
22
|
+
}, /*#__PURE__*/React.createElement(ListBox, {
|
|
20
23
|
menuProps: menuProps
|
|
21
24
|
}, children ? children({
|
|
22
25
|
items: itemNodes
|
|
@@ -61,7 +61,7 @@ var TabList = function (props) {
|
|
|
61
61
|
}
|
|
62
62
|
setLeftArrowEnabled(false);
|
|
63
63
|
}, {
|
|
64
|
-
threshold: 0.
|
|
64
|
+
threshold: 0.8,
|
|
65
65
|
root: containerElement
|
|
66
66
|
});
|
|
67
67
|
firstTabObserver.observe(isRTL$1 ? tabs[tabs.length - 1] : tabs[0]);
|
|
@@ -72,7 +72,7 @@ var TabList = function (props) {
|
|
|
72
72
|
}
|
|
73
73
|
setRightArrowEnabled(false);
|
|
74
74
|
}, {
|
|
75
|
-
threshold: 0.
|
|
75
|
+
threshold: 0.8,
|
|
76
76
|
root: containerElement
|
|
77
77
|
});
|
|
78
78
|
lastTabObserver.observe(isRTL$1 ? tabs[0] : tabs[tabs.length - 1]);
|
|
@@ -80,7 +80,7 @@ var TabList = function (props) {
|
|
|
80
80
|
firstTabObserver.disconnect();
|
|
81
81
|
lastTabObserver.disconnect();
|
|
82
82
|
};
|
|
83
|
-
}, [isDocumentReady, containerElement, isRTL$1]);
|
|
83
|
+
}, [isDocumentReady, containerElement, isRTL$1, tabListContext === null || tabListContext === void 0 ? void 0 : tabListContext.collection.size]);
|
|
84
84
|
useEffect(function () {
|
|
85
85
|
var _a;
|
|
86
86
|
if (!isDocumentReady) {
|
package/dist/styles.css
CHANGED
|
@@ -6329,6 +6329,8 @@
|
|
|
6329
6329
|
.GenericModal-module_transitionLayer__zTH-C {
|
|
6330
6330
|
transition: opacity var(--animation-duration-fast, 300ms) ease-in-out;
|
|
6331
6331
|
opacity: 1;
|
|
6332
|
+
position: relative;
|
|
6333
|
+
z-index: 1050;
|
|
6332
6334
|
}
|
|
6333
6335
|
.GenericModal-module_transitionLayer__zTH-C .GenericModal-module_backdropLayer__RNQ-U {
|
|
6334
6336
|
/*
|
|
@@ -6720,6 +6722,8 @@
|
|
|
6720
6722
|
.ConfirmationModal-module_transitionLayer__Ue95T {
|
|
6721
6723
|
transition: opacity var(--animation-duration-fast, 300ms) ease-in-out;
|
|
6722
6724
|
opacity: 1;
|
|
6725
|
+
position: relative;
|
|
6726
|
+
z-index: 1050;
|
|
6723
6727
|
}
|
|
6724
6728
|
.ConfirmationModal-module_transitionLayer__Ue95T .ConfirmationModal-module_backdropLayer__wvXnl {
|
|
6725
6729
|
/*
|
|
@@ -7070,6 +7074,8 @@
|
|
|
7070
7074
|
.ContextModal-module_transitionLayer__IjJem {
|
|
7071
7075
|
transition: opacity var(--animation-duration-fast, 300ms) ease-in-out;
|
|
7072
7076
|
opacity: 1;
|
|
7077
|
+
position: relative;
|
|
7078
|
+
z-index: 1050;
|
|
7073
7079
|
}
|
|
7074
7080
|
.ContextModal-module_transitionLayer__IjJem .ContextModal-module_backdropLayer__wuj3B {
|
|
7075
7081
|
/*
|
|
@@ -7394,6 +7400,8 @@
|
|
|
7394
7400
|
.InputEditModal-module_transitionLayer__1B3VI {
|
|
7395
7401
|
transition: opacity var(--animation-duration-fast, 300ms) ease-in-out;
|
|
7396
7402
|
opacity: 1;
|
|
7403
|
+
position: relative;
|
|
7404
|
+
z-index: 1050;
|
|
7397
7405
|
}
|
|
7398
7406
|
.InputEditModal-module_transitionLayer__1B3VI .InputEditModal-module_backdropLayer__aVLSb {
|
|
7399
7407
|
/*
|
|
@@ -3,8 +3,9 @@ import { type OverrideClassName } from "../../../../types/OverrideClassName";
|
|
|
3
3
|
import { type SelectOption } from '../../types';
|
|
4
4
|
export type OverlayProps = OverrideClassName<HTMLAttributes<HTMLDivElement>> & {
|
|
5
5
|
children: React.ReactNode;
|
|
6
|
+
popoverRef?: React.RefObject<Element | null>;
|
|
6
7
|
};
|
|
7
8
|
export declare const Overlay: {
|
|
8
|
-
<Option extends SelectOption>({ children, classNameOverride, ...restProps }: OverlayProps): JSX.Element;
|
|
9
|
+
<Option extends SelectOption>({ children, classNameOverride, popoverRef, ...restProps }: OverlayProps): JSX.Element;
|
|
9
10
|
displayName: string;
|
|
10
11
|
};
|
package/dist/types/__next__/Select/subcomponents/SelectPopoverContents/SelectPopoverContents.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export type SelectPopoverContentsProps<Option extends SelectOption> = {
|
|
|
6
6
|
items: SelectItemNode<Option>[];
|
|
7
7
|
}) => React.ReactNode;
|
|
8
8
|
menuProps: AriaListBoxOptions<SelectItem<Option>>;
|
|
9
|
+
popoverRef?: React.RefObject<Element | null>;
|
|
9
10
|
};
|
|
10
11
|
export declare const SelectPopoverContents: {
|
|
11
|
-
<Option extends SelectOption>({ children, menuProps, }: SelectPopoverContentsProps<Option>): JSX.Element;
|
|
12
|
+
<Option extends SelectOption>({ children, menuProps, popoverRef, }: SelectPopoverContentsProps<Option>): JSX.Element;
|
|
12
13
|
displayName: string;
|
|
13
14
|
};
|
package/package.json
CHANGED
|
@@ -21,7 +21,11 @@ export const TestBase: Story = {
|
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
23
|
<>
|
|
24
|
-
<button
|
|
24
|
+
<button
|
|
25
|
+
type="button"
|
|
26
|
+
className="border border-gray-500 relative z-10"
|
|
27
|
+
onClick={() => setIsOpen(true)}
|
|
28
|
+
>
|
|
25
29
|
Open Modal
|
|
26
30
|
</button>
|
|
27
31
|
<GenericModal
|
|
@@ -30,6 +34,7 @@ export const TestBase: Story = {
|
|
|
30
34
|
onOutsideModalClick={handleDismiss}
|
|
31
35
|
onEscapeKeyup={handleDismiss}
|
|
32
36
|
id="GenericModalTestId"
|
|
37
|
+
className="will-change-[opacity]"
|
|
33
38
|
>
|
|
34
39
|
<ModalHeader>
|
|
35
40
|
<ModalAccessibleLabel>Test Modal</ModalAccessibleLabel>
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ResourceLinks, KAIOInstallation } from '~storybook/components'
|
|
1
|
+
import { Meta } from '@storybook/blocks'
|
|
3
2
|
|
|
4
|
-
<Meta title="Components/Button/Migration
|
|
3
|
+
<Meta title="Components/Button/Migration guide" />
|
|
5
4
|
|
|
6
|
-
# Button
|
|
5
|
+
# Button migration guide
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Audience
|
|
8
|
+
|
|
9
|
+
This guide is relevant for Kaizen All-In-One (KAIO) v1 consumers.
|
|
10
|
+
|
|
11
|
+
## Purpose
|
|
12
|
+
|
|
13
|
+
This guide provides instructions for migrating button usage from `deprecated` (`@kaizen/components`) `Button` and `IconButton` components to `next` (`@kaizen/components/next`) `Button` and `LinkButton` components.
|
|
14
|
+
|
|
15
|
+
This migration is a prerequisite for [migrating to KAIO v2](/docs/releases-upcoming-major-releases--docs).
|
|
9
16
|
|
|
10
17
|
## Key API differences
|
|
11
18
|
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Meta, Story } from '@storybook/blocks'
|
|
2
|
+
import { LinkTo } from '~storybook/components'
|
|
3
3
|
import * as IconStories from './Icon.docs.stories'
|
|
4
4
|
|
|
5
5
|
<Meta title="Components/Icon/Migration guide" />
|
|
6
6
|
|
|
7
7
|
# Icon migration guide
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Audience
|
|
10
|
+
|
|
11
|
+
This guide is relevant for Kaizen All-In-One (KAIO) v1 consumers.
|
|
12
|
+
|
|
13
|
+
## Purpose
|
|
14
|
+
|
|
15
|
+
This guide provides instructions for migrating icon usage from the `deprecated` (`@kaizen/components`) `*Icon` components to the `next` (`@kaizen/components/next`) `Icon` component.
|
|
16
|
+
|
|
17
|
+
This migration is a prerequisite for [migrating to KAIO v2](/docs/releases-upcoming-major-releases--docs).
|
|
10
18
|
|
|
11
19
|
## Codemod
|
|
12
20
|
|
|
@@ -183,7 +183,9 @@ export const Select = <Option extends SelectOption = SelectOption>({
|
|
|
183
183
|
{state.isOpen && (
|
|
184
184
|
<Popover id={popoverId} portalContainer={portalContainer} refs={refs}>
|
|
185
185
|
<SelectProvider<Option> state={state}>
|
|
186
|
-
<SelectPopoverContents menuProps={menuProps}
|
|
186
|
+
<SelectPopoverContents menuProps={menuProps} popoverRef={refs.floating}>
|
|
187
|
+
{children}
|
|
188
|
+
</SelectPopoverContents>
|
|
187
189
|
</SelectProvider>
|
|
188
190
|
</Popover>
|
|
189
191
|
)}
|
|
@@ -7,11 +7,13 @@ import { type SelectOption } from '../../types'
|
|
|
7
7
|
|
|
8
8
|
export type OverlayProps = OverrideClassName<HTMLAttributes<HTMLDivElement>> & {
|
|
9
9
|
children: React.ReactNode
|
|
10
|
+
popoverRef?: React.RefObject<Element | null>
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export const Overlay = <Option extends SelectOption>({
|
|
13
14
|
children,
|
|
14
15
|
classNameOverride,
|
|
16
|
+
popoverRef,
|
|
15
17
|
...restProps
|
|
16
18
|
}: OverlayProps): JSX.Element => {
|
|
17
19
|
const { state } = useSelectContext<Option>()
|
|
@@ -21,7 +23,7 @@ export const Overlay = <Option extends SelectOption>({
|
|
|
21
23
|
const overlayRef = React.useRef<HTMLDivElement>(null)
|
|
22
24
|
const { overlayProps } = useOverlay(
|
|
23
25
|
{ isDismissable: true, isOpen: state.isOpen, onClose: state.close },
|
|
24
|
-
overlayRef,
|
|
26
|
+
popoverRef ?? overlayRef,
|
|
25
27
|
)
|
|
26
28
|
|
|
27
29
|
// Wrap in <FocusScope> so that focus is restored back to the trigger when the menu is closed
|
|
@@ -29,7 +31,7 @@ export const Overlay = <Option extends SelectOption>({
|
|
|
29
31
|
// In addition, add hidden <DismissButton> components at the start and end of the list
|
|
30
32
|
// to allow screen reader users to dismiss the popup easily.
|
|
31
33
|
return (
|
|
32
|
-
<div
|
|
34
|
+
<div className={classNameOverride} {...overlayProps} {...restProps}>
|
|
33
35
|
{/* eslint-disable-next-line jsx-a11y/no-autofocus */}
|
|
34
36
|
<FocusScope autoFocus={false} restoreFocus>
|
|
35
37
|
<DismissButton onDismiss={state.close} />
|
|
@@ -10,11 +10,13 @@ import styles from './SelectPopoverContents.module.scss'
|
|
|
10
10
|
export type SelectPopoverContentsProps<Option extends SelectOption> = {
|
|
11
11
|
children?: (args: { items: SelectItemNode<Option>[] }) => React.ReactNode
|
|
12
12
|
menuProps: AriaListBoxOptions<SelectItem<Option>>
|
|
13
|
+
popoverRef?: React.RefObject<Element | null>
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export const SelectPopoverContents = <Option extends SelectOption>({
|
|
16
17
|
children,
|
|
17
18
|
menuProps,
|
|
19
|
+
popoverRef,
|
|
18
20
|
}: SelectPopoverContentsProps<Option>): JSX.Element => {
|
|
19
21
|
const { state } = useSelectContext<Option>()
|
|
20
22
|
|
|
@@ -26,7 +28,7 @@ export const SelectPopoverContents = <Option extends SelectOption>({
|
|
|
26
28
|
|
|
27
29
|
return (
|
|
28
30
|
<div className={styles.selectPopoverContents}>
|
|
29
|
-
<Overlay<Option
|
|
31
|
+
<Overlay<Option> popoverRef={popoverRef}>
|
|
30
32
|
<ListBox<Option> menuProps={menuProps}>
|
|
31
33
|
{children ? children({ items: itemNodes }) : <ListItems<Option> items={itemNodes} />}
|
|
32
34
|
</ListBox>
|
|
@@ -2,9 +2,17 @@ import { Meta } from '@storybook/blocks'
|
|
|
2
2
|
|
|
3
3
|
<Meta title="Components/Tabs/Migration guide" />
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Tabs migration guide
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Audience
|
|
8
|
+
|
|
9
|
+
This guide is relevant for Kaizen All-In-One (KAIO) v1 consumers.
|
|
10
|
+
|
|
11
|
+
## Purpose
|
|
12
|
+
|
|
13
|
+
This guide provides instructions for migrating tabs usage from the `deprecated` (`@kaizen/components`) `Tabs` component to the `next` (`@kaizen/components/next`) `Tabs` component.
|
|
14
|
+
|
|
15
|
+
This migration is a prerequisite for [migrating to KAIO v2](/docs/releases-upcoming-major-releases--docs).
|
|
8
16
|
|
|
9
17
|
## Why the change?
|
|
10
18
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
2
|
import { type Meta, type StoryObj } from '@storybook/react'
|
|
3
|
-
import { expect, userEvent, within } from '@storybook/test'
|
|
3
|
+
import { expect, userEvent, waitFor, within } from '@storybook/test'
|
|
4
4
|
import { Text } from '~components/Text'
|
|
5
|
-
import { Tab, TabList, TabPanel, Tabs } from '../index'
|
|
5
|
+
import { Tab, TabList, TabPanel, Tabs, type Key } from '../index'
|
|
6
6
|
|
|
7
7
|
const meta = {
|
|
8
8
|
title: 'Components/Tabs/Tabs (next)/Tabs (next) tests',
|
|
@@ -116,3 +116,48 @@ export const ArrowsShowingAndHidingRTL: Story = {
|
|
|
116
116
|
expect(leftArrow).not.toBeInTheDocument()
|
|
117
117
|
},
|
|
118
118
|
}
|
|
119
|
+
|
|
120
|
+
export const AsyncLoaded: Story = {
|
|
121
|
+
render: () => {
|
|
122
|
+
const [selectedKey, setSelectedKey] = useState<Key>(0)
|
|
123
|
+
|
|
124
|
+
const [showSecondTab, setShowSecondTab] = React.useState(false)
|
|
125
|
+
React.useEffect(() => {
|
|
126
|
+
const timer = setTimeout(() => setShowSecondTab(true), 1000)
|
|
127
|
+
return () => clearTimeout(timer)
|
|
128
|
+
}, [])
|
|
129
|
+
return (
|
|
130
|
+
<div style={{ maxWidth: '300px' }}>
|
|
131
|
+
<Tabs selectedKey={selectedKey} onSelectionChange={setSelectedKey}>
|
|
132
|
+
<TabList aria-label="Tabs" data-testid="sb-arrows">
|
|
133
|
+
<Tab id="one">Conversation</Tab>
|
|
134
|
+
{showSecondTab && <Tab id="two">Personal notes</Tab>}
|
|
135
|
+
</TabList>
|
|
136
|
+
<TabPanel id="one" className="p-24">
|
|
137
|
+
<Text variant="body">Content 1</Text>
|
|
138
|
+
</TabPanel>
|
|
139
|
+
<TabPanel id="two" className="p-24">
|
|
140
|
+
<Text variant="body">Content 2</Text>
|
|
141
|
+
</TabPanel>
|
|
142
|
+
</Tabs>
|
|
143
|
+
</div>
|
|
144
|
+
)
|
|
145
|
+
},
|
|
146
|
+
play: async ({ canvasElement, step }) => {
|
|
147
|
+
const canvas = within(canvasElement.parentElement!)
|
|
148
|
+
expect(canvas.queryByTestId('kz-tablist-right-arrow')).not.toBeInTheDocument()
|
|
149
|
+
await waitFor(() => userEvent.click(canvasElement))
|
|
150
|
+
await new Promise((r) => setTimeout(r, 2000))
|
|
151
|
+
|
|
152
|
+
await step('Check if second tab is loaded', async () => {
|
|
153
|
+
await waitFor(() => {
|
|
154
|
+
expect(canvas.queryByText('Personal notes')).toBeInTheDocument()
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
await waitFor(async () => {
|
|
158
|
+
const rightTab = await canvas.findByTestId('sb-arrows-kz-tablist-right-arrow')
|
|
159
|
+
expect(rightTab).toBeInTheDocument()
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
},
|
|
163
|
+
}
|
|
@@ -66,11 +66,22 @@ export const Playground: Story = {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export const Controlled: Story = {
|
|
69
|
-
render: (
|
|
69
|
+
render: () => {
|
|
70
70
|
const [selectedKey, setSelectedKey] = useState<Key>(0)
|
|
71
71
|
return (
|
|
72
72
|
<>
|
|
73
|
-
<Tabs
|
|
73
|
+
<Tabs selectedKey={selectedKey} onSelectionChange={setSelectedKey}>
|
|
74
|
+
<TabList aria-label="Tabs">
|
|
75
|
+
<Tab id="one">Tab 1</Tab>
|
|
76
|
+
<Tab id="two">Tab 2</Tab>
|
|
77
|
+
</TabList>
|
|
78
|
+
<TabPanel id="one" className="p-24">
|
|
79
|
+
<Text variant="body">Content 1</Text>
|
|
80
|
+
</TabPanel>
|
|
81
|
+
<TabPanel id="two" className="p-24">
|
|
82
|
+
<Text variant="body">Content 2</Text>
|
|
83
|
+
</TabPanel>
|
|
84
|
+
</Tabs>
|
|
74
85
|
<Button label="Switch to tab 2" onClick={(): void => setSelectedKey('two')} />
|
|
75
86
|
</>
|
|
76
87
|
)
|
|
@@ -75,7 +75,7 @@ export const TabList = (props: TabListProps): JSX.Element => {
|
|
|
75
75
|
setLeftArrowEnabled(false)
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
|
-
threshold: 0.
|
|
78
|
+
threshold: 0.8,
|
|
79
79
|
root: containerElement,
|
|
80
80
|
},
|
|
81
81
|
)
|
|
@@ -90,7 +90,7 @@ export const TabList = (props: TabListProps): JSX.Element => {
|
|
|
90
90
|
setRightArrowEnabled(false)
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
|
-
threshold: 0.
|
|
93
|
+
threshold: 0.8,
|
|
94
94
|
root: containerElement,
|
|
95
95
|
},
|
|
96
96
|
)
|
|
@@ -100,7 +100,7 @@ export const TabList = (props: TabListProps): JSX.Element => {
|
|
|
100
100
|
firstTabObserver.disconnect()
|
|
101
101
|
lastTabObserver.disconnect()
|
|
102
102
|
}
|
|
103
|
-
}, [isDocumentReady, containerElement, isRTL])
|
|
103
|
+
}, [isDocumentReady, containerElement, isRTL, tabListContext?.collection.size])
|
|
104
104
|
|
|
105
105
|
useEffect(() => {
|
|
106
106
|
if (!isDocumentReady) {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title="Components/Tooltip/Migration guide" />
|
|
4
|
+
|
|
5
|
+
# Tooltip migration guide
|
|
6
|
+
|
|
7
|
+
## Audience
|
|
8
|
+
|
|
9
|
+
This guide is relevant for Kaizen All-In-One (KAIO) v1 consumers.
|
|
10
|
+
|
|
11
|
+
## Purpose
|
|
12
|
+
|
|
13
|
+
This guide provides instructions for migrating tooltip usage from the `deprecated` (`@kaizen/components`) `Tooltip` component to the `next` (`@kaizen/components/next`) `Tooltip` component.
|
|
14
|
+
|
|
15
|
+
This migration is a prerequisite for [migrating to KAIO v2](/docs/releases-upcoming-major-releases--docs).
|
|
16
|
+
|
|
17
|
+
## Key API changes
|
|
18
|
+
|
|
19
|
+
The `next` tooltip separates its functionality into two distinct components:
|
|
20
|
+
|
|
21
|
+
- `TooltipTrigger` component wraps the `Tooltip` component and its trigger element, and controls open and close interactions.
|
|
22
|
+
- `Tooltip` component provides the tooltip's content and controls its placement.
|
|
23
|
+
|
|
24
|
+
Other notable changes:
|
|
25
|
+
|
|
26
|
+
- `animationDuration` prop is retired
|
|
27
|
+
- `children` prop becomes `TooltipTrigger.Children`
|
|
28
|
+
- `display` prop is retired
|
|
29
|
+
- `isInitiallyVisible` prop becomes `Tooltip.defaultOpen`
|
|
30
|
+
- `mood` prop is retired
|
|
31
|
+
- This change aligns with a broader move towards more judicious use of colour
|
|
32
|
+
- `portalSelector` prop is retired
|
|
33
|
+
- Where needed, [PortalProvider](https://react-spectrum.adobe.com/react-aria/PortalProvider.html) can be used to control portalling behaviour
|
|
34
|
+
- `position` prop becomes `Tooltip.placement`, and values are mapped as follows:
|
|
35
|
+
- `above` becomes `top`
|
|
36
|
+
- `below` becomes `bottom`
|
|
37
|
+
- `left` becomes `start`
|
|
38
|
+
- `right` becomes `end`
|
|
39
|
+
- `text` prop becomes `Tooltip.Children`
|
|
40
|
+
|
|
41
|
+
## Migration example
|
|
42
|
+
|
|
43
|
+
### Before
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
<Tooltip text="Content" position="above">
|
|
47
|
+
<Button>Trigger</Button>
|
|
48
|
+
</Tooltip>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### After
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
<TooltipTrigger>
|
|
55
|
+
<Button>Trigger</Button>
|
|
56
|
+
<Tooltip placement="top">Content</Tooltip>
|
|
57
|
+
</TooltipTrigger>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## More information
|
|
61
|
+
|
|
62
|
+
More information about the `next` `Tooltip` component can be found at [API Specification](/docs/components-tooltip-tooltip-next-api-specification--docs) and [Usage Guidelines](/docs/components-tooltip-tooltip-next-usage-guidelines--docs).
|