@kaizen/components 1.64.13 → 1.65.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/dist/cjs/Filter/FilterSelect/FilterSelect.cjs +2 -0
- package/dist/cjs/__future__/Select/subcomponents/ListBox/ListBox.cjs +46 -2
- package/dist/cjs/__future__/Select/subcomponents/Overlay/Overlay.cjs +1 -1
- package/dist/cjs/__future__/Tabs/Tabs.cjs +23 -0
- package/dist/cjs/__future__/Tabs/subcomponents/Tab/Tab.cjs +39 -0
- package/dist/cjs/__future__/Tabs/subcomponents/Tab/Tab.module.css.cjs +7 -0
- package/dist/cjs/__future__/Tabs/subcomponents/TabList/TabList.cjs +31 -0
- package/dist/cjs/__future__/Tabs/subcomponents/TabList/TabList.module.css.cjs +7 -0
- package/dist/cjs/__future__/Tabs/subcomponents/TabPanel/TabPanel.cjs +24 -0
- package/dist/cjs/__utilities__/useIsClientReady/useIsClientReady.cjs +20 -0
- package/dist/cjs/future.cjs +8 -0
- package/dist/esm/Filter/FilterSelect/FilterSelect.mjs +2 -0
- package/dist/esm/__future__/Select/subcomponents/ListBox/ListBox.mjs +47 -3
- package/dist/esm/__future__/Select/subcomponents/Overlay/Overlay.mjs +1 -1
- package/dist/esm/__future__/Tabs/Tabs.mjs +15 -0
- package/dist/esm/__future__/Tabs/subcomponents/Tab/Tab.mjs +30 -0
- package/dist/esm/__future__/Tabs/subcomponents/Tab/Tab.module.css.mjs +5 -0
- package/dist/esm/__future__/Tabs/subcomponents/TabList/TabList.mjs +22 -0
- package/dist/esm/__future__/Tabs/subcomponents/TabList/TabList.module.css.mjs +5 -0
- package/dist/esm/__future__/Tabs/subcomponents/TabPanel/TabPanel.mjs +16 -0
- package/dist/esm/__utilities__/useIsClientReady/useIsClientReady.mjs +18 -0
- package/dist/esm/future.mjs +4 -0
- package/dist/styles.css +244 -127
- package/dist/types/Tabs/subcomponents/index.d.ts +0 -1
- package/dist/types/__future__/Select/subcomponents/ListBox/ListBox.d.ts +2 -2
- package/dist/types/__future__/Tabs/Tabs.d.ts +11 -0
- package/dist/types/__future__/Tabs/index.d.ts +2 -0
- package/dist/types/__future__/Tabs/subcomponents/Tab/Tab.d.ts +12 -0
- package/dist/types/__future__/Tabs/subcomponents/Tab/index.d.ts +1 -0
- package/dist/types/__future__/Tabs/subcomponents/TabList/TabList.d.ts +17 -0
- package/dist/types/__future__/Tabs/subcomponents/TabList/index.d.ts +1 -0
- package/dist/types/__future__/Tabs/subcomponents/TabPanel/TabPanel.d.ts +6 -0
- package/dist/types/__future__/Tabs/subcomponents/TabPanel/index.d.ts +1 -0
- package/dist/types/__future__/Tabs/subcomponents/index.d.ts +3 -0
- package/dist/types/__future__/index.d.ts +1 -0
- package/dist/types/__utilities__/useIsClientReady/index.d.ts +1 -0
- package/dist/types/__utilities__/useIsClientReady/useIsClientReady.d.ts +5 -0
- package/package.json +2 -2
- package/src/Filter/FilterSelect/FilterSelect.spec.tsx +97 -2
- package/src/Filter/FilterSelect/FilterSelect.tsx +3 -0
- package/src/Tabs/subcomponents/index.ts +0 -1
- package/src/__future__/Select/Select.spec.tsx +5 -3
- package/src/__future__/Select/_docs/Select.mdx +1 -3
- package/src/__future__/Select/_docs/Select.stories.tsx +33 -17
- package/src/__future__/Select/subcomponents/ListBox/ListBox.tsx +56 -4
- package/src/__future__/Select/subcomponents/Overlay/Overlay.tsx +1 -1
- package/src/__future__/Tabs/Tabs.tsx +18 -0
- package/src/__future__/Tabs/_docs/Tabs--api-specification.mdx +43 -0
- package/src/__future__/Tabs/_docs/Tabs--migration-guide.mdx +93 -0
- package/src/__future__/Tabs/_docs/Tabs.stories.tsx +74 -0
- package/src/__future__/Tabs/index.ts +2 -0
- package/src/__future__/Tabs/subcomponents/Tab/Tab.module.css +94 -0
- package/src/__future__/Tabs/subcomponents/Tab/Tab.tsx +58 -0
- package/src/__future__/Tabs/subcomponents/Tab/index.ts +1 -0
- package/src/__future__/Tabs/subcomponents/TabList/TabList.module.css +8 -0
- package/src/__future__/Tabs/subcomponents/TabList/TabList.tsx +45 -0
- package/src/__future__/Tabs/subcomponents/TabList/index.ts +1 -0
- package/src/__future__/Tabs/subcomponents/TabPanel/TabPanel.module.css +12 -0
- package/src/__future__/Tabs/subcomponents/TabPanel/TabPanel.tsx +20 -0
- package/src/__future__/Tabs/subcomponents/TabPanel/index.ts +1 -0
- package/src/__future__/Tabs/subcomponents/index.ts +3 -0
- package/src/__future__/index.ts +1 -0
- package/src/__utilities__/useIsClientReady/index.ts +1 -0
- package/src/__utilities__/useIsClientReady/useIsClientReady.tsx +17 -0
|
@@ -57,6 +57,8 @@ var FilterSelect = function (_a) {
|
|
|
57
57
|
triggerProps = _c.triggerProps,
|
|
58
58
|
menuProps = _c.menuProps;
|
|
59
59
|
var buttonProps = button.useButton(triggerProps, triggerRef).buttonProps;
|
|
60
|
+
// `aria-labelledby` and `aria-controls` are being remapped because the `buttonProps` ids generated by React Aria point to nothing.
|
|
61
|
+
// This should ideally be refactored but for now the `aria-controls` is set to the Filter's Listbox (menuProps.id) and the `aria-labelledby` to undefined so the accessible name is derived from the buttons content.
|
|
60
62
|
var renderTriggerButtonProps = tslib.__assign(tslib.__assign({}, buttonProps), {
|
|
61
63
|
"aria-labelledby": undefined,
|
|
62
64
|
"aria-controls": menuProps.id
|
|
@@ -4,6 +4,7 @@ var tslib = require('tslib');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var listbox = require('@react-aria/listbox');
|
|
6
6
|
var classnames = require('classnames');
|
|
7
|
+
var useIsClientReady = require('../../../../__utilities__/useIsClientReady/useIsClientReady.cjs');
|
|
7
8
|
var SelectContext = require('../../context/SelectContext.cjs');
|
|
8
9
|
var ListBox_module = require('./ListBox.module.scss.cjs');
|
|
9
10
|
function _interopDefault(e) {
|
|
@@ -13,16 +14,59 @@ function _interopDefault(e) {
|
|
|
13
14
|
}
|
|
14
15
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
15
16
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
17
|
+
|
|
18
|
+
/** A util to retrieve the key of the correct focusable items based of the focus strategy
|
|
19
|
+
* This is used to determine which element from the collection to focus to on open base on the keyboard event
|
|
20
|
+
* ie: UpArrow will set the focusStrategy to "last"
|
|
21
|
+
*/
|
|
22
|
+
var getOptionKeyFromCollection = function (state) {
|
|
23
|
+
if (state.selectedItem) {
|
|
24
|
+
return state.selectedItem.key;
|
|
25
|
+
} else if (state.focusStrategy === "last") {
|
|
26
|
+
return state.collection.getLastKey();
|
|
27
|
+
}
|
|
28
|
+
return state.collection.getFirstKey();
|
|
29
|
+
};
|
|
30
|
+
/** This makes the use of query selector less brittle in instances where a failed selector is passed in
|
|
31
|
+
*/
|
|
32
|
+
var safeQuerySelector = function (selector) {
|
|
33
|
+
try {
|
|
34
|
+
return document.querySelector(selector);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.error("Kaizen querySelector failed:", error);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
16
41
|
var ListBox = function (_a) {
|
|
17
42
|
var children = _a.children,
|
|
18
43
|
menuProps = _a.menuProps,
|
|
19
44
|
classNameOverride = _a.classNameOverride,
|
|
20
45
|
restProps = tslib.__rest(_a, ["children", "menuProps", "classNameOverride"]);
|
|
46
|
+
var isClientReady = useIsClientReady.useIsClientReady();
|
|
21
47
|
var state = SelectContext.useSelectContext().state;
|
|
22
|
-
var ref =
|
|
48
|
+
var ref = React.useRef(null);
|
|
23
49
|
var listBoxProps = listbox.useListBox(tslib.__assign(tslib.__assign({}, menuProps), {
|
|
24
|
-
disallowEmptySelection: true
|
|
50
|
+
disallowEmptySelection: true,
|
|
51
|
+
// This is to ensure that the listbox doesn't use React Aria's auto focus feature for Listbox, which creates a visual bug
|
|
52
|
+
autoFocus: false
|
|
25
53
|
}), state, ref).listBoxProps;
|
|
54
|
+
/**
|
|
55
|
+
* This uses the new useIsClientReady to ensure document exists before trying to querySelector and give the time to focus to the correct element
|
|
56
|
+
*/
|
|
57
|
+
React.useEffect(function () {
|
|
58
|
+
var _a;
|
|
59
|
+
if (isClientReady) {
|
|
60
|
+
var optionKey = getOptionKeyFromCollection(state);
|
|
61
|
+
var focusToElement = safeQuerySelector("[data-key='".concat(optionKey, "']"));
|
|
62
|
+
if (focusToElement) {
|
|
63
|
+
focusToElement.focus();
|
|
64
|
+
} else {
|
|
65
|
+
// If an element is not found, focus on the listbox. This ensures the list can still be navigated to via keyboard if the keys do not align to the data attributes of the list items.
|
|
66
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, [isClientReady]);
|
|
26
70
|
return React__default.default.createElement("ul", tslib.__assign({
|
|
27
71
|
ref: ref,
|
|
28
72
|
className: classnames__default.default(ListBox_module.listBox, classNameOverride)
|
|
@@ -32,7 +32,7 @@ var Overlay = function (_a) {
|
|
|
32
32
|
ref: overlayRef,
|
|
33
33
|
className: classNameOverride
|
|
34
34
|
}, overlayProps, restProps), React__default.default.createElement(focus.FocusScope, {
|
|
35
|
-
autoFocus:
|
|
35
|
+
autoFocus: false,
|
|
36
36
|
restoreFocus: true
|
|
37
37
|
}, React__default.default.createElement(overlays.DismissButton, {
|
|
38
38
|
onDismiss: state.close
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactAriaComponents = require('react-aria-components');
|
|
6
|
+
function _interopDefault(e) {
|
|
7
|
+
return e && e.__esModule ? e : {
|
|
8
|
+
default: e
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081929117/Tabs Guidance} |
|
|
15
|
+
* {@link https://cultureamp.design/?path=/docs/components-tabs--controlled Storybook}
|
|
16
|
+
*
|
|
17
|
+
* Wrapper around all of the tab subcomponents
|
|
18
|
+
* Holds a TabList and TabPanels
|
|
19
|
+
*/
|
|
20
|
+
var Tabs = function (props) {
|
|
21
|
+
return React__default.default.createElement(reactAriaComponents.Tabs, tslib.__assign({}, props));
|
|
22
|
+
};
|
|
23
|
+
exports.Tabs = Tabs;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var classnames = require('classnames');
|
|
6
|
+
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var Badge = require('../../../../Badge/Badge.cjs');
|
|
8
|
+
var Tab_module = require('./Tab.module.css.cjs');
|
|
9
|
+
function _interopDefault(e) {
|
|
10
|
+
return e && e.__esModule ? e : {
|
|
11
|
+
default: e
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
15
|
+
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A tab button
|
|
19
|
+
*/
|
|
20
|
+
var Tab = function (props) {
|
|
21
|
+
var badge = props.badge,
|
|
22
|
+
children = props.children,
|
|
23
|
+
className = props.className,
|
|
24
|
+
restProps = tslib.__rest(props, ["badge", "children", "className"]);
|
|
25
|
+
var tabProps = tslib.__assign({
|
|
26
|
+
className: classnames__default.default(Tab_module.tab, className)
|
|
27
|
+
}, restProps);
|
|
28
|
+
return React__default.default.createElement(reactAriaComponents.Tab, tslib.__assign({}, tabProps), function (_a) {
|
|
29
|
+
var isSelected = _a.isSelected,
|
|
30
|
+
isFocusVisible = _a.isFocusVisible,
|
|
31
|
+
isHovered = _a.isHovered;
|
|
32
|
+
return React__default.default.createElement(React__default.default.Fragment, null, children, badge && React__default.default.createElement("span", {
|
|
33
|
+
className: Tab_module.badge
|
|
34
|
+
}, React__default.default.createElement(Badge.Badge, {
|
|
35
|
+
variant: isSelected || isFocusVisible || isHovered ? "active" : "default"
|
|
36
|
+
}, badge)));
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.Tab = Tab;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var classnames = require('classnames');
|
|
6
|
+
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var TabList_module = require('./TabList.module.css.cjs');
|
|
8
|
+
function _interopDefault(e) {
|
|
9
|
+
return e && e.__esModule ? e : {
|
|
10
|
+
default: e
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
|
+
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper for the tabs themselves
|
|
18
|
+
*/
|
|
19
|
+
var TabList = function (props) {
|
|
20
|
+
var ariaLabel = props["aria-label"],
|
|
21
|
+
_a = props.noPadding,
|
|
22
|
+
noPadding = _a === void 0 ? false : _a,
|
|
23
|
+
children = props.children,
|
|
24
|
+
className = props.className,
|
|
25
|
+
restProps = tslib.__rest(props, ["aria-label", "noPadding", "children", "className"]);
|
|
26
|
+
return React__default.default.createElement(reactAriaComponents.TabList, tslib.__assign({
|
|
27
|
+
"aria-label": ariaLabel,
|
|
28
|
+
className: classnames__default.default(TabList_module.tabList, className, noPadding && TabList_module.noPadding)
|
|
29
|
+
}, restProps), children);
|
|
30
|
+
};
|
|
31
|
+
exports.TabList = TabList;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactAriaComponents = require('react-aria-components');
|
|
6
|
+
function _interopDefault(e) {
|
|
7
|
+
return e && e.__esModule ? e : {
|
|
8
|
+
default: e
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Wrapper for the content that shows when tab is active
|
|
15
|
+
*/
|
|
16
|
+
var TabPanel = function (props) {
|
|
17
|
+
var className = props.className,
|
|
18
|
+
children = props.children,
|
|
19
|
+
restProps = tslib.__rest(props, ["className", "children"]);
|
|
20
|
+
return React__default.default.createElement(reactAriaComponents.TabPanel, tslib.__assign({
|
|
21
|
+
className: className
|
|
22
|
+
}, restProps), children);
|
|
23
|
+
};
|
|
24
|
+
exports.TabPanel = TabPanel;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A hook that returns a truthy value indicating if the code can be run on client side.
|
|
7
|
+
* This is a useful hook for determining if the `document` or `window` objects are available.
|
|
8
|
+
*/
|
|
9
|
+
var useIsClientReady = function () {
|
|
10
|
+
var _a = React.useState(false),
|
|
11
|
+
isClientReady = _a[0],
|
|
12
|
+
setIsClientReady = _a[1];
|
|
13
|
+
React.useEffect(function () {
|
|
14
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
15
|
+
setIsClientReady(true);
|
|
16
|
+
}
|
|
17
|
+
}, []);
|
|
18
|
+
return isClientReady;
|
|
19
|
+
};
|
|
20
|
+
exports.useIsClientReady = useIsClientReady;
|
package/dist/cjs/future.cjs
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
var Select = require('./__future__/Select/Select.cjs');
|
|
4
4
|
var RemovableTag = require('./__future__/Tag/RemovableTag/RemovableTag.cjs');
|
|
5
5
|
var Tag = require('./__future__/Tag/Tag/Tag.cjs');
|
|
6
|
+
var Tabs = require('./__future__/Tabs/Tabs.cjs');
|
|
7
|
+
var Tab = require('./__future__/Tabs/subcomponents/Tab/Tab.cjs');
|
|
8
|
+
var TabList = require('./__future__/Tabs/subcomponents/TabList/TabList.cjs');
|
|
9
|
+
var TabPanel = require('./__future__/Tabs/subcomponents/TabPanel/TabPanel.cjs');
|
|
6
10
|
exports.Select = Select.Select;
|
|
7
11
|
exports.RemovableTag = RemovableTag.RemovableTag;
|
|
8
12
|
exports.Tag = Tag.Tag;
|
|
13
|
+
exports.Tabs = Tabs.Tabs;
|
|
14
|
+
exports.Tab = Tab.Tab;
|
|
15
|
+
exports.TabList = TabList.TabList;
|
|
16
|
+
exports.TabPanel = TabPanel.TabPanel;
|
|
@@ -50,6 +50,8 @@ const FilterSelect = /*#__PURE__*/function () {
|
|
|
50
50
|
triggerProps = _c.triggerProps,
|
|
51
51
|
menuProps = _c.menuProps;
|
|
52
52
|
var buttonProps = useButton(triggerProps, triggerRef).buttonProps;
|
|
53
|
+
// `aria-labelledby` and `aria-controls` are being remapped because the `buttonProps` ids generated by React Aria point to nothing.
|
|
54
|
+
// This should ideally be refactored but for now the `aria-controls` is set to the Filter's Listbox (menuProps.id) and the `aria-labelledby` to undefined so the accessible name is derived from the buttons content.
|
|
53
55
|
var renderTriggerButtonProps = __assign(__assign({}, buttonProps), {
|
|
54
56
|
"aria-labelledby": undefined,
|
|
55
57
|
"aria-controls": menuProps.id
|
|
@@ -1,20 +1,64 @@
|
|
|
1
1
|
import { __rest, __assign } from 'tslib';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useRef, useEffect } from 'react';
|
|
3
3
|
import { useListBox } from '@react-aria/listbox';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
+
import { useIsClientReady } from '../../../../__utilities__/useIsClientReady/useIsClientReady.mjs';
|
|
5
6
|
import { useSelectContext } from '../../context/SelectContext.mjs';
|
|
6
7
|
import styles from './ListBox.module.scss.mjs';
|
|
8
|
+
|
|
9
|
+
/** A util to retrieve the key of the correct focusable items based of the focus strategy
|
|
10
|
+
* This is used to determine which element from the collection to focus to on open base on the keyboard event
|
|
11
|
+
* ie: UpArrow will set the focusStrategy to "last"
|
|
12
|
+
*/
|
|
13
|
+
var getOptionKeyFromCollection = function (state) {
|
|
14
|
+
if (state.selectedItem) {
|
|
15
|
+
return state.selectedItem.key;
|
|
16
|
+
} else if (state.focusStrategy === "last") {
|
|
17
|
+
return state.collection.getLastKey();
|
|
18
|
+
}
|
|
19
|
+
return state.collection.getFirstKey();
|
|
20
|
+
};
|
|
21
|
+
/** This makes the use of query selector less brittle in instances where a failed selector is passed in
|
|
22
|
+
*/
|
|
23
|
+
var safeQuerySelector = function (selector) {
|
|
24
|
+
try {
|
|
25
|
+
return document.querySelector(selector);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.error("Kaizen querySelector failed:", error);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
7
32
|
const ListBox = /*#__PURE__*/function () {
|
|
8
33
|
const ListBox = function (_a) {
|
|
9
34
|
var children = _a.children,
|
|
10
35
|
menuProps = _a.menuProps,
|
|
11
36
|
classNameOverride = _a.classNameOverride,
|
|
12
37
|
restProps = __rest(_a, ["children", "menuProps", "classNameOverride"]);
|
|
38
|
+
var isClientReady = useIsClientReady();
|
|
13
39
|
var state = useSelectContext().state;
|
|
14
|
-
var ref =
|
|
40
|
+
var ref = useRef(null);
|
|
15
41
|
var listBoxProps = useListBox(__assign(__assign({}, menuProps), {
|
|
16
|
-
disallowEmptySelection: true
|
|
42
|
+
disallowEmptySelection: true,
|
|
43
|
+
// This is to ensure that the listbox doesn't use React Aria's auto focus feature for Listbox, which creates a visual bug
|
|
44
|
+
autoFocus: false
|
|
17
45
|
}), state, ref).listBoxProps;
|
|
46
|
+
/**
|
|
47
|
+
* This uses the new useIsClientReady to ensure document exists before trying to querySelector and give the time to focus to the correct element
|
|
48
|
+
*/
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
var _a;
|
|
51
|
+
if (isClientReady) {
|
|
52
|
+
var optionKey = getOptionKeyFromCollection(state);
|
|
53
|
+
var focusToElement = safeQuerySelector("[data-key='".concat(optionKey, "']"));
|
|
54
|
+
if (focusToElement) {
|
|
55
|
+
focusToElement.focus();
|
|
56
|
+
} else {
|
|
57
|
+
// If an element is not found, focus on the listbox. This ensures the list can still be navigated to via keyboard if the keys do not align to the data attributes of the list items.
|
|
58
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, [isClientReady]);
|
|
18
62
|
return /*#__PURE__*/React.createElement("ul", __assign({
|
|
19
63
|
ref: ref,
|
|
20
64
|
className: classnames(styles.listBox, classNameOverride)
|
|
@@ -25,7 +25,7 @@ const Overlay = /*#__PURE__*/function () {
|
|
|
25
25
|
ref: overlayRef,
|
|
26
26
|
className: classNameOverride
|
|
27
27
|
}, overlayProps, restProps), /*#__PURE__*/React.createElement(FocusScope, {
|
|
28
|
-
autoFocus:
|
|
28
|
+
autoFocus: false,
|
|
29
29
|
restoreFocus: true
|
|
30
30
|
}, /*#__PURE__*/React.createElement(DismissButton, {
|
|
31
31
|
onDismiss: state.close
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Tabs as Tabs$1 } from 'react-aria-components';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081929117/Tabs Guidance} |
|
|
7
|
+
* {@link https://cultureamp.design/?path=/docs/components-tabs--controlled Storybook}
|
|
8
|
+
*
|
|
9
|
+
* Wrapper around all of the tab subcomponents
|
|
10
|
+
* Holds a TabList and TabPanels
|
|
11
|
+
*/
|
|
12
|
+
var Tabs = function (props) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(Tabs$1, __assign({}, props));
|
|
14
|
+
};
|
|
15
|
+
export { Tabs };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { Tab as Tab$1 } from 'react-aria-components';
|
|
5
|
+
import { Badge } from '../../../../Badge/Badge.mjs';
|
|
6
|
+
import styles from './Tab.module.css.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A tab button
|
|
10
|
+
*/
|
|
11
|
+
var Tab = function (props) {
|
|
12
|
+
var badge = props.badge,
|
|
13
|
+
children = props.children,
|
|
14
|
+
className = props.className,
|
|
15
|
+
restProps = __rest(props, ["badge", "children", "className"]);
|
|
16
|
+
var tabProps = __assign({
|
|
17
|
+
className: classnames(styles.tab, className)
|
|
18
|
+
}, restProps);
|
|
19
|
+
return /*#__PURE__*/React.createElement(Tab$1, __assign({}, tabProps), function (_a) {
|
|
20
|
+
var isSelected = _a.isSelected,
|
|
21
|
+
isFocusVisible = _a.isFocusVisible,
|
|
22
|
+
isHovered = _a.isHovered;
|
|
23
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children, badge && ( /*#__PURE__*/React.createElement("span", {
|
|
24
|
+
className: styles.badge
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Badge, {
|
|
26
|
+
variant: isSelected || isFocusVisible || isHovered ? "active" : "default"
|
|
27
|
+
}, badge))));
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
export { Tab };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { TabList as TabList$1 } from 'react-aria-components';
|
|
5
|
+
import styles from './TabList.module.css.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wrapper for the tabs themselves
|
|
9
|
+
*/
|
|
10
|
+
var TabList = function (props) {
|
|
11
|
+
var ariaLabel = props["aria-label"],
|
|
12
|
+
_a = props.noPadding,
|
|
13
|
+
noPadding = _a === void 0 ? false : _a,
|
|
14
|
+
children = props.children,
|
|
15
|
+
className = props.className,
|
|
16
|
+
restProps = __rest(props, ["aria-label", "noPadding", "children", "className"]);
|
|
17
|
+
return /*#__PURE__*/React.createElement(TabList$1, __assign({
|
|
18
|
+
"aria-label": ariaLabel,
|
|
19
|
+
className: classnames(styles.tabList, className, noPadding && styles.noPadding)
|
|
20
|
+
}, restProps), children);
|
|
21
|
+
};
|
|
22
|
+
export { TabList };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TabPanel as TabPanel$1 } from 'react-aria-components';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wrapper for the content that shows when tab is active
|
|
7
|
+
*/
|
|
8
|
+
var TabPanel = function (props) {
|
|
9
|
+
var className = props.className,
|
|
10
|
+
children = props.children,
|
|
11
|
+
restProps = __rest(props, ["className", "children"]);
|
|
12
|
+
return /*#__PURE__*/React.createElement(TabPanel$1, __assign({
|
|
13
|
+
className: className
|
|
14
|
+
}, restProps), children);
|
|
15
|
+
};
|
|
16
|
+
export { TabPanel };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A hook that returns a truthy value indicating if the code can be run on client side.
|
|
5
|
+
* This is a useful hook for determining if the `document` or `window` objects are available.
|
|
6
|
+
*/
|
|
7
|
+
var useIsClientReady = function () {
|
|
8
|
+
var _a = useState(false),
|
|
9
|
+
isClientReady = _a[0],
|
|
10
|
+
setIsClientReady = _a[1];
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
13
|
+
setIsClientReady(true);
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
return isClientReady;
|
|
17
|
+
};
|
|
18
|
+
export { useIsClientReady };
|
package/dist/esm/future.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export { Select } from './__future__/Select/Select.mjs';
|
|
2
2
|
export { RemovableTag } from './__future__/Tag/RemovableTag/RemovableTag.mjs';
|
|
3
3
|
export { Tag } from './__future__/Tag/Tag/Tag.mjs';
|
|
4
|
+
export { Tabs } from './__future__/Tabs/Tabs.mjs';
|
|
5
|
+
export { Tab } from './__future__/Tabs/subcomponents/Tab/Tab.mjs';
|
|
6
|
+
export { TabList } from './__future__/Tabs/subcomponents/TabList/TabList.mjs';
|
|
7
|
+
export { TabPanel } from './__future__/Tabs/subcomponents/TabPanel/TabPanel.mjs';
|