@primer/react 0.0.0-20260819151913 → 0.0.0-20260824175215
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 +12 -4
- package/dist/ActionBar/ActionBar.d.ts +5 -9
- package/dist/ActionBar/ActionBar.js +164 -551
- package/dist/ActionBar/index.d.ts +2 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.d.ts +1 -2
- package/dist/AnchoredOverlay/AnchoredOverlay.js +61 -84
- package/dist/Button/ButtonBase-b44e29d1.css +2 -0
- package/dist/Button/ButtonBase-b44e29d1.css.map +1 -0
- package/dist/Button/ButtonBase.d.ts +5 -2
- package/dist/Button/ButtonBase.js +4 -2
- package/dist/Button/ButtonBase.module.css.js +3 -2
- package/dist/Button/types.d.ts +15 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.js +2 -1
- package/dist/Flash/Flash.d.ts +6 -0
- package/dist/Flash/Flash.js +6 -0
- package/dist/SelectPanel/SelectPanel.d.ts +1 -0
- package/dist/SelectPanel/SelectPanel.js +2 -2
- package/dist/deprecated/ActionMenu.js +2 -2
- package/dist/deprecated/index.d.ts +2 -1
- package/dist/deprecated/index.js +2 -1
- package/dist/experimental/SelectPanel2/SelectPanel.d.ts +1 -0
- package/dist/experimental/Tabs/Tabs.js +33 -19
- package/dist/experimental/Tabs/types.d.ts +6 -0
- package/dist/experimental/Tabs/useTab.js +6 -1
- package/dist/experimental/Tabs/useTabList.js +29 -22
- package/dist/experimental/UnderlinePanels/UnderlinePanels.d.ts +38 -1
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +69 -18
- package/dist/hooks/useOpenAndCloseFocus.js +2 -5
- package/generated/components.json +66 -25
- package/package.json +1 -1
- package/dist/Button/ButtonBase-311501b9.css +0 -2
- package/dist/Button/ButtonBase-311501b9.css.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import useIsomorphicLayoutEffect from "../../utils/useIsomorphicLayoutEffect.js";
|
|
2
|
+
import { useFeatureFlag } from "../../FeatureFlags/useFeatureFlag.js";
|
|
2
3
|
import { useControllableState } from "../../hooks/useControllableState.js";
|
|
3
4
|
import { TabsContext } from "./TabsContext.js";
|
|
4
5
|
import { c } from "react-compiler-runtime";
|
|
@@ -13,11 +14,13 @@ import React, { useId } from "react";
|
|
|
13
14
|
* The `Tab`, `TabList`, and `TabPanel` components are provided for convenience to showcase the API & implementation.
|
|
14
15
|
*/
|
|
15
16
|
function Tabs(props) {
|
|
16
|
-
var _props$id, _props$defaultValue;
|
|
17
|
-
const $ = c(
|
|
17
|
+
var _props$id, _props$activationMode, _props$defaultValue;
|
|
18
|
+
const $ = c(16);
|
|
18
19
|
const { children, onValueChange } = props;
|
|
19
20
|
const generatedId = useId();
|
|
20
21
|
const groupId = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : generatedId;
|
|
22
|
+
const controlledApiEnabled = useFeatureFlag("primer_react_underline_panels_controlled");
|
|
23
|
+
const activationMode = controlledApiEnabled ? (_props$activationMode = props.activationMode) !== null && _props$activationMode !== void 0 ? _props$activationMode : "automatic" : "automatic";
|
|
21
24
|
const t0 = (_props$defaultValue = props.defaultValue) !== null && _props$defaultValue !== void 0 ? _props$defaultValue : props.value;
|
|
22
25
|
let t1;
|
|
23
26
|
if ($[0] !== props.value || $[1] !== t0) {
|
|
@@ -31,49 +34,60 @@ function Tabs(props) {
|
|
|
31
34
|
$[2] = t1;
|
|
32
35
|
} else t1 = $[2];
|
|
33
36
|
const [selectedValue, setSelectedValue] = useControllableState(t1);
|
|
37
|
+
const [focusedValue, setFocusedValue] = React.useState();
|
|
34
38
|
const savedOnValueChange = React.useRef(onValueChange);
|
|
35
39
|
let t2;
|
|
36
|
-
if ($[3] !==
|
|
40
|
+
if ($[3] !== activationMode || $[4] !== controlledApiEnabled || $[5] !== focusedValue || $[6] !== groupId || $[7] !== selectedValue || $[8] !== setSelectedValue) {
|
|
37
41
|
t2 = {
|
|
38
42
|
groupId,
|
|
39
43
|
selectedValue,
|
|
44
|
+
activationMode,
|
|
45
|
+
focusedValue,
|
|
40
46
|
selectTab(value) {
|
|
41
47
|
var _savedOnValueChange$c;
|
|
48
|
+
setFocusedValue(void 0);
|
|
49
|
+
if (controlledApiEnabled && value === selectedValue) return;
|
|
42
50
|
setSelectedValue(value);
|
|
43
51
|
(_savedOnValueChange$c = savedOnValueChange.current) === null || _savedOnValueChange$c === void 0 || _savedOnValueChange$c.call(savedOnValueChange, { value });
|
|
52
|
+
},
|
|
53
|
+
focusTab(value_0) {
|
|
54
|
+
setFocusedValue(value_0);
|
|
44
55
|
}
|
|
45
56
|
};
|
|
46
|
-
$[3] =
|
|
47
|
-
$[4] =
|
|
48
|
-
$[5] =
|
|
49
|
-
$[6] =
|
|
50
|
-
|
|
57
|
+
$[3] = activationMode;
|
|
58
|
+
$[4] = controlledApiEnabled;
|
|
59
|
+
$[5] = focusedValue;
|
|
60
|
+
$[6] = groupId;
|
|
61
|
+
$[7] = selectedValue;
|
|
62
|
+
$[8] = setSelectedValue;
|
|
63
|
+
$[9] = t2;
|
|
64
|
+
} else t2 = $[9];
|
|
51
65
|
const contextValue = t2;
|
|
52
66
|
let t3;
|
|
53
67
|
let t4;
|
|
54
|
-
if ($[
|
|
68
|
+
if ($[10] !== onValueChange) {
|
|
55
69
|
t3 = () => {
|
|
56
70
|
savedOnValueChange.current = onValueChange;
|
|
57
71
|
};
|
|
58
72
|
t4 = [onValueChange];
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
73
|
+
$[10] = onValueChange;
|
|
74
|
+
$[11] = t3;
|
|
75
|
+
$[12] = t4;
|
|
62
76
|
} else {
|
|
63
|
-
t3 = $[
|
|
64
|
-
t4 = $[
|
|
77
|
+
t3 = $[11];
|
|
78
|
+
t4 = $[12];
|
|
65
79
|
}
|
|
66
80
|
useIsomorphicLayoutEffect(t3, t4);
|
|
67
81
|
let t5;
|
|
68
|
-
if ($[
|
|
82
|
+
if ($[13] !== children || $[14] !== contextValue) {
|
|
69
83
|
t5 = /*#__PURE__*/ jsx(TabsContext.Provider, {
|
|
70
84
|
value: contextValue,
|
|
71
85
|
children
|
|
72
86
|
});
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
} else t5 = $[
|
|
87
|
+
$[13] = children;
|
|
88
|
+
$[14] = contextValue;
|
|
89
|
+
$[15] = t5;
|
|
90
|
+
} else t5 = $[15];
|
|
77
91
|
return t5;
|
|
78
92
|
}
|
|
79
93
|
//#endregion
|
|
@@ -51,6 +51,12 @@ type CommonTabsProps = {
|
|
|
51
51
|
* unique id is generated automatically.
|
|
52
52
|
*/
|
|
53
53
|
id?: string;
|
|
54
|
+
/**
|
|
55
|
+
* `'automatic'` (default) selects on focus, so Arrow/Home/End keys select immediately. `'manual'`
|
|
56
|
+
* only moves focus; selection commits on Enter/Space/click. Prefer `'manual'` when displaying a
|
|
57
|
+
* panel is not instant (e.g. it triggers a network request).
|
|
58
|
+
*/
|
|
59
|
+
activationMode?: 'automatic' | 'manual';
|
|
54
60
|
};
|
|
55
61
|
type TabsProps = PropsWithChildren<(ControlledTabsProps | UncontrolledTabsProps) & CommonTabsProps>;
|
|
56
62
|
type Label = {
|
|
@@ -12,6 +12,7 @@ function useTab(props) {
|
|
|
12
12
|
const selected = tabs.selectedValue === value;
|
|
13
13
|
const id = `${tabs.groupId}-tab-${value}`;
|
|
14
14
|
const panelId = `${tabs.groupId}-panel-${value}`;
|
|
15
|
+
const isTabStop = tabs.activationMode === "manual" && tabs.focusedValue !== void 0 ? tabs.focusedValue === value : selected;
|
|
15
16
|
let t0;
|
|
16
17
|
if ($[0] !== tabs || $[1] !== value) {
|
|
17
18
|
t0 = function onKeyDown(event) {
|
|
@@ -37,6 +38,10 @@ function useTab(props) {
|
|
|
37
38
|
let t2;
|
|
38
39
|
if ($[7] !== disabled || $[8] !== selected || $[9] !== tabs || $[10] !== value) {
|
|
39
40
|
t2 = function onFocus() {
|
|
41
|
+
if (tabs.activationMode === "manual") {
|
|
42
|
+
if (!disabled) tabs.focusTab(value);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
40
45
|
if (!selected && !disabled) tabs.selectTab(value);
|
|
41
46
|
};
|
|
42
47
|
$[7] = disabled;
|
|
@@ -47,7 +52,7 @@ function useTab(props) {
|
|
|
47
52
|
} else t2 = $[11];
|
|
48
53
|
const onFocus = t2;
|
|
49
54
|
const t3 = disabled ? true : void 0;
|
|
50
|
-
const t4 =
|
|
55
|
+
const t4 = isTabStop ? 0 : -1;
|
|
51
56
|
let t5;
|
|
52
57
|
if ($[12] !== id || $[13] !== onFocus || $[14] !== onKeyDown || $[15] !== onMouseDown || $[16] !== panelId || $[17] !== selected || $[18] !== t3 || $[19] !== t4) {
|
|
53
58
|
t5 = { tabProps: {
|
|
@@ -5,20 +5,29 @@ import { c } from "react-compiler-runtime";
|
|
|
5
5
|
import { useRef } from "react";
|
|
6
6
|
//#region src/experimental/Tabs/useTabList.ts
|
|
7
7
|
function useTabList(props) {
|
|
8
|
-
const $ = c(
|
|
8
|
+
const $ = c(10);
|
|
9
9
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-orientation": ariaOrientation } = props;
|
|
10
10
|
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
11
|
+
const controlledApiEnabled = useFeatureFlag("primer_react_underline_panels_controlled");
|
|
11
12
|
const tabListRef = useRef(null);
|
|
12
13
|
const mergedRef = useMergedRefs(tabListRef, props.ref);
|
|
13
14
|
const providedOrCreatedRef = useProvidedRefOrCreate(props.ref);
|
|
14
15
|
const readRef = mergedRefEnabled ? tabListRef : providedOrCreatedRef;
|
|
15
16
|
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
16
17
|
let t0;
|
|
17
|
-
if ($[0] !== ariaOrientation || $[1] !== readRef) {
|
|
18
|
+
if ($[0] !== ariaOrientation || $[1] !== controlledApiEnabled || $[2] !== readRef) {
|
|
18
19
|
t0 = (event) => {
|
|
19
20
|
const { current: tablist } = readRef;
|
|
20
21
|
if (tablist === null) return;
|
|
21
22
|
const tabs = getFocusableTabs(tablist);
|
|
23
|
+
const getCurrentIndex = () => {
|
|
24
|
+
if (controlledApiEnabled) {
|
|
25
|
+
const activeElement = tablist.ownerDocument.activeElement;
|
|
26
|
+
const focusedIndex = activeElement instanceof HTMLElement ? tabs.indexOf(activeElement) : -1;
|
|
27
|
+
if (focusedIndex !== -1) return focusedIndex;
|
|
28
|
+
}
|
|
29
|
+
return tabs.findIndex(_temp);
|
|
30
|
+
};
|
|
22
31
|
const isVertical = ariaOrientation === "vertical";
|
|
23
32
|
const nextKey = isVertical ? "ArrowDown" : "ArrowRight";
|
|
24
33
|
const prevKey = isVertical ? "ArrowUp" : "ArrowLeft";
|
|
@@ -27,13 +36,13 @@ function useTabList(props) {
|
|
|
27
36
|
event.stopPropagation();
|
|
28
37
|
}
|
|
29
38
|
if (event.key === nextKey) {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
tabs[(
|
|
39
|
+
const currentTabIndex = getCurrentIndex();
|
|
40
|
+
if (currentTabIndex === -1) return;
|
|
41
|
+
tabs[(currentTabIndex + 1) % tabs.length].focus();
|
|
33
42
|
} else if (event.key === prevKey) {
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
tabs[(tabs.length +
|
|
43
|
+
const currentTabIndex_0 = getCurrentIndex();
|
|
44
|
+
if (currentTabIndex_0 === -1) return;
|
|
45
|
+
tabs[(tabs.length + currentTabIndex_0 - 1) % tabs.length].focus();
|
|
37
46
|
} else if (event.key === "Home") {
|
|
38
47
|
if (tabs[0]) tabs[0].focus();
|
|
39
48
|
} else if (event.key === "End") {
|
|
@@ -41,13 +50,14 @@ function useTabList(props) {
|
|
|
41
50
|
}
|
|
42
51
|
};
|
|
43
52
|
$[0] = ariaOrientation;
|
|
44
|
-
$[1] =
|
|
45
|
-
$[2] =
|
|
46
|
-
|
|
53
|
+
$[1] = controlledApiEnabled;
|
|
54
|
+
$[2] = readRef;
|
|
55
|
+
$[3] = t0;
|
|
56
|
+
} else t0 = $[3];
|
|
47
57
|
const onKeyDown = t0;
|
|
48
58
|
const t1 = ariaOrientation !== null && ariaOrientation !== void 0 ? ariaOrientation : "horizontal";
|
|
49
59
|
let t2;
|
|
50
|
-
if ($[
|
|
60
|
+
if ($[4] !== appliedRef || $[5] !== ariaLabel || $[6] !== ariaLabelledby || $[7] !== onKeyDown || $[8] !== t1) {
|
|
51
61
|
t2 = { tabListProps: {
|
|
52
62
|
ref: appliedRef,
|
|
53
63
|
"aria-label": ariaLabel,
|
|
@@ -56,18 +66,15 @@ function useTabList(props) {
|
|
|
56
66
|
role: "tablist",
|
|
57
67
|
onKeyDown
|
|
58
68
|
} };
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
62
|
-
$[
|
|
63
|
-
$[
|
|
64
|
-
$[
|
|
65
|
-
} else t2 = $[
|
|
69
|
+
$[4] = appliedRef;
|
|
70
|
+
$[5] = ariaLabel;
|
|
71
|
+
$[6] = ariaLabelledby;
|
|
72
|
+
$[7] = onKeyDown;
|
|
73
|
+
$[8] = t1;
|
|
74
|
+
$[9] = t2;
|
|
75
|
+
} else t2 = $[9];
|
|
66
76
|
return t2;
|
|
67
77
|
}
|
|
68
|
-
function _temp2(tab_0) {
|
|
69
|
-
return tab_0.getAttribute("aria-selected") === "true";
|
|
70
|
-
}
|
|
71
78
|
function _temp(tab) {
|
|
72
79
|
return tab.getAttribute("aria-selected") === "true";
|
|
73
80
|
}
|
|
@@ -16,6 +16,31 @@ type UnderlinePanelsProps = {
|
|
|
16
16
|
* ID of the element containing the name for the tab list
|
|
17
17
|
*/
|
|
18
18
|
'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
|
|
19
|
+
/**
|
|
20
|
+
* The value of the selected tab, keyed to each `UnderlinePanels.Tab`/`UnderlinePanels.Panel`
|
|
21
|
+
* `value`. Provide this (with `onChange`) for a controlled component where the selected tab is
|
|
22
|
+
* the single source of truth.
|
|
23
|
+
*/
|
|
24
|
+
value?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The value of the tab that should be selected by default, keyed to each tab's `value`. Use this
|
|
27
|
+
* for an uncontrolled component. Cannot be combined with `value`.
|
|
28
|
+
*/
|
|
29
|
+
defaultValue?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Fires whenever the selected tab changes, for every selection method including arrow keys.
|
|
32
|
+
* Unlike `UnderlinePanels.Tab`'s `onSelect`, which only fires on click and Enter/Space.
|
|
33
|
+
*/
|
|
34
|
+
onChange?: ({
|
|
35
|
+
value
|
|
36
|
+
}: {
|
|
37
|
+
value: string;
|
|
38
|
+
}) => void;
|
|
39
|
+
/**
|
|
40
|
+
* `'automatic'` (default) selects on focus/arrow keys; `'manual'` only moves focus until
|
|
41
|
+
* Enter/Space/click. Prefer `'manual'` when displaying a panel is not instant.
|
|
42
|
+
*/
|
|
43
|
+
activationMode?: 'automatic' | 'manual';
|
|
19
44
|
/**
|
|
20
45
|
* Custom string to use when generating the IDs of tabs and `aria-labelledby` for the panels
|
|
21
46
|
*/
|
|
@@ -34,6 +59,12 @@ type UnderlinePanelsProps = {
|
|
|
34
59
|
as?: React.ElementType;
|
|
35
60
|
};
|
|
36
61
|
type TabProps = PropsWithChildren<{
|
|
62
|
+
/**
|
|
63
|
+
* A value that uniquely identifies this tab, paired with the `UnderlinePanels.Panel` of the same
|
|
64
|
+
* `value`. Provide this to use domain values (e.g. `'branch'`) with the container's controlled
|
|
65
|
+
* `value`/`onChange` API. When omitted, tabs and panels are paired by their DOM order.
|
|
66
|
+
*/
|
|
67
|
+
value?: string;
|
|
37
68
|
/**
|
|
38
69
|
* Whether this is the selected tab
|
|
39
70
|
*/
|
|
@@ -51,7 +82,13 @@ type TabProps = PropsWithChildren<{
|
|
|
51
82
|
*/
|
|
52
83
|
icon?: FC<IconProps>;
|
|
53
84
|
}>;
|
|
54
|
-
type PanelProps = React.HTMLAttributes<HTMLDivElement
|
|
85
|
+
type PanelProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
86
|
+
/**
|
|
87
|
+
* A value that uniquely identifies this panel, paired with the `UnderlinePanels.Tab` of the same
|
|
88
|
+
* `value`. When omitted, tabs and panels are paired by their DOM order.
|
|
89
|
+
*/
|
|
90
|
+
value?: string;
|
|
91
|
+
};
|
|
55
92
|
declare const _default: React.FC<UnderlinePanelsProps> & SlotMarker & {
|
|
56
93
|
Panel: FCWithSlotMarker<PanelProps>;
|
|
57
94
|
Tab: FCWithSlotMarker<TabProps>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import useIsomorphicLayoutEffect from "../../utils/useIsomorphicLayoutEffect.js";
|
|
2
2
|
import { useResizeObserver } from "../../hooks/useResizeObserver.js";
|
|
3
3
|
import { useId as useId$1 } from "../../hooks/useId.js";
|
|
4
|
+
import { warning } from "../../utils/warning.js";
|
|
4
5
|
import { isSlot } from "../../utils/is-slot.js";
|
|
6
|
+
import { useFeatureFlag } from "../../FeatureFlags/useFeatureFlag.js";
|
|
5
7
|
import { invariant } from "../../utils/invariant.js";
|
|
6
8
|
import { UnderlineItem, UnderlineItemList, UnderlineWrapper } from "../../internal/components/UnderlineTabbedInterface.js";
|
|
7
9
|
import UnderlinePanels_module_css_default from "./UnderlinePanels.module.css.js";
|
|
@@ -17,43 +19,78 @@ const UnderlinePanelsContext = /*#__PURE__*/ createContext({
|
|
|
17
19
|
iconsVisible: true,
|
|
18
20
|
loadingCounters: void 0
|
|
19
21
|
});
|
|
20
|
-
const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, loadingCounters, className, ...props }) => {
|
|
22
|
+
const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, loadingCounters, className, value: valueProp, defaultValue: defaultValueProp, onChange: onChangeProp, activationMode = "automatic", ...props }) => {
|
|
23
|
+
var _tabValues$;
|
|
24
|
+
const controlledApiEnabled = useFeatureFlag("primer_react_underline_panels_controlled");
|
|
25
|
+
const controlledValue = controlledApiEnabled ? valueProp : void 0;
|
|
26
|
+
const defaultValue = controlledApiEnabled ? defaultValueProp : void 0;
|
|
27
|
+
const onChange = controlledApiEnabled ? onChangeProp : void 0;
|
|
21
28
|
const [iconsVisible, setIconsVisible] = useState(true);
|
|
22
29
|
const wrapperRef = useRef(null);
|
|
23
30
|
const listRef = useRef(null);
|
|
24
31
|
const parentId = useId$1(props.id);
|
|
25
|
-
const [tabs, tabPanels, tabsHaveIcons, selectedFromProps] = useMemo(() => {
|
|
32
|
+
const [tabs, tabPanels, tabsHaveIcons, selectedFromProps, tabValues, panelValues] = useMemo(() => {
|
|
26
33
|
let tabIndex = 0;
|
|
27
34
|
let panelIndex = 0;
|
|
28
35
|
const childrenWithProps = Children.map(children, (child) => {
|
|
29
|
-
if (/*#__PURE__*/ isValidElement(child) && (child.type === Tab || isSlot(child, Tab)))
|
|
30
|
-
|
|
36
|
+
if (/*#__PURE__*/ isValidElement(child) && (child.type === Tab || isSlot(child, Tab))) {
|
|
37
|
+
var _ref;
|
|
38
|
+
const value = (_ref = controlledApiEnabled ? child.props.value : void 0) !== null && _ref !== void 0 ? _ref : `${tabIndex}`;
|
|
39
|
+
tabIndex++;
|
|
40
|
+
return /*#__PURE__*/ cloneElement(child, { value });
|
|
41
|
+
}
|
|
42
|
+
if (/*#__PURE__*/ isValidElement(child) && (child.type === Panel || isSlot(child, Panel))) {
|
|
43
|
+
var _ref2;
|
|
44
|
+
const value = (_ref2 = controlledApiEnabled ? child.props.value : void 0) !== null && _ref2 !== void 0 ? _ref2 : `${panelIndex}`;
|
|
45
|
+
panelIndex++;
|
|
46
|
+
return /*#__PURE__*/ cloneElement(child, { value });
|
|
47
|
+
}
|
|
31
48
|
return child;
|
|
32
49
|
});
|
|
33
50
|
const tabs = [];
|
|
34
51
|
const tabPanels = [];
|
|
52
|
+
const tabValues = [];
|
|
53
|
+
const panelValues = [];
|
|
35
54
|
let selectedFromProps;
|
|
36
55
|
for (const child of Children.toArray(childrenWithProps)) {
|
|
37
56
|
if (!/*#__PURE__*/ isValidElement(child)) continue;
|
|
38
57
|
if (child.type === Tab || isSlot(child, Tab)) {
|
|
58
|
+
const value = child.props.value;
|
|
59
|
+
if (value !== void 0) tabValues.push(value);
|
|
39
60
|
const ariaSelected = child.props["aria-selected"];
|
|
40
|
-
if (ariaSelected === true || ariaSelected === "true") selectedFromProps =
|
|
61
|
+
if (ariaSelected === true || ariaSelected === "true") selectedFromProps = value;
|
|
41
62
|
tabs.push(child);
|
|
42
|
-
} else if (child.type === Panel || isSlot(child, Panel))
|
|
63
|
+
} else if (child.type === Panel || isSlot(child, Panel)) {
|
|
64
|
+
const value = child.props.value;
|
|
65
|
+
if (value !== void 0) panelValues.push(value);
|
|
66
|
+
tabPanels.push(child);
|
|
67
|
+
}
|
|
43
68
|
}
|
|
44
69
|
return [
|
|
45
70
|
tabs,
|
|
46
71
|
tabPanels,
|
|
47
72
|
tabs.some((tab) => /*#__PURE__*/ React.isValidElement(tab) && tab.props.icon),
|
|
48
|
-
selectedFromProps
|
|
73
|
+
selectedFromProps,
|
|
74
|
+
tabValues,
|
|
75
|
+
panelValues
|
|
49
76
|
];
|
|
50
|
-
}, [children]);
|
|
51
|
-
const
|
|
77
|
+
}, [children, controlledApiEnabled]);
|
|
78
|
+
const isControlled = controlledValue !== void 0;
|
|
79
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(() => {
|
|
80
|
+
var _ref3;
|
|
81
|
+
return (_ref3 = defaultValue !== null && defaultValue !== void 0 ? defaultValue : selectedFromProps) !== null && _ref3 !== void 0 ? _ref3 : "0";
|
|
82
|
+
});
|
|
52
83
|
const [prevSelectedFromProps, setPrevSelectedFromProps] = useState(selectedFromProps);
|
|
53
|
-
if (selectedFromProps !== prevSelectedFromProps) {
|
|
84
|
+
if (!isControlled && selectedFromProps !== prevSelectedFromProps) {
|
|
54
85
|
setPrevSelectedFromProps(selectedFromProps);
|
|
55
|
-
if (selectedFromProps !== void 0 && selectedFromProps !==
|
|
86
|
+
if (selectedFromProps !== void 0 && selectedFromProps !== uncontrolledValue) setUncontrolledValue(selectedFromProps);
|
|
56
87
|
}
|
|
88
|
+
const selectedValue = isControlled ? controlledValue : uncontrolledValue;
|
|
89
|
+
const effectiveValue = tabValues.includes(selectedValue) ? selectedValue : (_tabValues$ = tabValues[0]) !== null && _tabValues$ !== void 0 ? _tabValues$ : selectedValue;
|
|
90
|
+
const handleValueChange = (value) => {
|
|
91
|
+
if (!isControlled) setUncontrolledValue(value);
|
|
92
|
+
onChange === null || onChange === void 0 || onChange({ value });
|
|
93
|
+
};
|
|
57
94
|
const { tabListProps } = useTabList({
|
|
58
95
|
"aria-label": ariaLabel,
|
|
59
96
|
"aria-labelledby": ariaLabelledBy,
|
|
@@ -78,17 +115,31 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
|
|
|
78
115
|
const wrapperWidth = resizeObserverEntries[0].contentRect.width;
|
|
79
116
|
setIconsVisible(wrapperWidth > listWidthRef.current);
|
|
80
117
|
}, wrapperRef, []);
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
118
|
+
{
|
|
119
|
+
const selectedTabs = tabs.filter((tab) => {
|
|
120
|
+
const ariaSelected = /*#__PURE__*/ React.isValidElement(tab) && tab.props["aria-selected"];
|
|
121
|
+
return ariaSelected === true || ariaSelected === "true";
|
|
122
|
+
});
|
|
123
|
+
!(selectedTabs.length <= 1) && invariant(false, "Only one tab can be selected at a time.");
|
|
124
|
+
!(tabs.length === tabPanels.length) && invariant(false, `The number of tabs and panels must be equal. Counted ${tabs.length} tabs and ${tabPanels.length} panels.`);
|
|
125
|
+
const duplicateTabValue = tabValues.find((value, index) => tabValues.indexOf(value) !== index);
|
|
126
|
+
!(duplicateTabValue === void 0) && invariant(false, `Every tab must have a unique \`value\`. Found duplicate "${duplicateTabValue}".`);
|
|
127
|
+
const duplicatePanelValue = panelValues.find((value, index) => panelValues.indexOf(value) !== index);
|
|
128
|
+
!(duplicatePanelValue === void 0) && invariant(false, `Every panel must have a unique \`value\`. Found duplicate "${duplicatePanelValue}".`);
|
|
129
|
+
const unmatchedTabValue = tabValues.find((value) => !panelValues.includes(value));
|
|
130
|
+
!(unmatchedTabValue === void 0) && invariant(false, `Tab with \`value\` "${unmatchedTabValue}" has no matching panel. Give a \`UnderlinePanels.Panel\` the same \`value\`.`);
|
|
131
|
+
warning(isControlled && selectedTabs.length > 0, "UnderlinePanels: do not combine the controlled `value` prop with `aria-selected` on a tab. `value` takes precedence; use `value`/`onChange` (or `defaultValue`) to drive selection.");
|
|
132
|
+
warning(controlledValue !== void 0 && defaultValue !== void 0, "UnderlinePanels: do not combine the controlled `value` prop with `defaultValue`. `value` takes precedence; use one or the other.");
|
|
133
|
+
const providedValue = controlledValue !== null && controlledValue !== void 0 ? controlledValue : defaultValue;
|
|
134
|
+
warning(providedValue !== void 0 && tabValues.length > 0 && !tabValues.includes(providedValue), `UnderlinePanels: the selected value "${providedValue}" does not match any tab, so the first tab is selected instead. Provide a \`value\`/\`defaultValue\` that matches a \`UnderlinePanels.Tab\` \`value\`.`);
|
|
135
|
+
}
|
|
86
136
|
return /*#__PURE__*/ jsx(UnderlinePanelsContext.Provider, {
|
|
87
137
|
value: contextValue,
|
|
88
138
|
children: /*#__PURE__*/ jsxs(Tabs, {
|
|
89
139
|
id: parentId,
|
|
90
|
-
value:
|
|
91
|
-
|
|
140
|
+
value: effectiveValue,
|
|
141
|
+
activationMode,
|
|
142
|
+
onValueChange: ({ value }) => handleValueChange(value),
|
|
92
143
|
children: [/*#__PURE__*/ jsx(UnderlineWrapper, {
|
|
93
144
|
ref: wrapperRef,
|
|
94
145
|
"data-icons-visible": iconsVisible,
|
|
@@ -2,10 +2,6 @@ import { c } from "react-compiler-runtime";
|
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { iterateFocusableElements } from "@primer/behaviors/utils";
|
|
4
4
|
//#region src/hooks/useOpenAndCloseFocus.ts
|
|
5
|
-
function focusCurrentTarget(ref) {
|
|
6
|
-
var _ref$current;
|
|
7
|
-
(_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
|
|
8
|
-
}
|
|
9
5
|
function useOpenAndCloseFocus(t0) {
|
|
10
6
|
const $ = c(6);
|
|
11
7
|
const { initialFocusRef, returnFocusRef, containerRef, preventFocusOnOpen } = t0;
|
|
@@ -20,8 +16,9 @@ function useOpenAndCloseFocus(t0) {
|
|
|
20
16
|
firstItem === null || firstItem === void 0 || firstItem.focus();
|
|
21
17
|
}
|
|
22
18
|
}
|
|
19
|
+
const returnFocusRefCurrent = returnFocusRef.current;
|
|
23
20
|
return function() {
|
|
24
|
-
|
|
21
|
+
returnFocusRefCurrent === null || returnFocusRefCurrent === void 0 || returnFocusRefCurrent.focus();
|
|
25
22
|
};
|
|
26
23
|
};
|
|
27
24
|
t2 = [
|
|
@@ -91,12 +91,6 @@
|
|
|
91
91
|
"type": "boolean",
|
|
92
92
|
"defaultValue": "",
|
|
93
93
|
"description": "Provides a disabled state for the button. The button will remain focusable, and have `aria-disabled` applied."
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"name": "activeAnchorRef",
|
|
97
|
-
"type": "React.Ref<HTMLButtonElement>",
|
|
98
|
-
"required": false,
|
|
99
|
-
"description": "Receives the visible trigger representing this action. Points to this button while inline and the ActionBar overflow button while this action is overflowing."
|
|
100
94
|
}
|
|
101
95
|
],
|
|
102
96
|
"passthrough": {
|
|
@@ -125,12 +119,6 @@
|
|
|
125
119
|
"type": "boolean",
|
|
126
120
|
"defaultValue": "",
|
|
127
121
|
"description": "Provides a disabled state for the button. The button will remain focusable, and have `aria-disabled` applied."
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
"name": "activeAnchorRef",
|
|
131
|
-
"type": "React.Ref<HTMLButtonElement>",
|
|
132
|
-
"required": false,
|
|
133
|
-
"description": "Receives the visible trigger representing this action. Points to this button while inline and the ActionBar overflow button while this action is overflowing."
|
|
134
122
|
}
|
|
135
123
|
],
|
|
136
124
|
"passthrough": {
|
|
@@ -918,9 +906,9 @@
|
|
|
918
906
|
},
|
|
919
907
|
{
|
|
920
908
|
"name": "renderAnchor",
|
|
921
|
-
"type": "<T extends React.HTMLAttributes<HTMLElement>>(props: T
|
|
909
|
+
"type": "<T extends React.HTMLAttributes<HTMLElement>>(props: T) => JSX.Element",
|
|
922
910
|
"defaultValue": "",
|
|
923
|
-
"description": "A custom function component used to render the anchor element.
|
|
911
|
+
"description": "A custom function component used to render the anchor element. When renderAnchor is null, an anchorRef is required."
|
|
924
912
|
},
|
|
925
913
|
{
|
|
926
914
|
"name": "anchorRef",
|
|
@@ -3406,39 +3394,39 @@
|
|
|
3406
3394
|
"source": "https://github.com/primer/react/tree/main/packages/react/src/Flash",
|
|
3407
3395
|
"id": "flash",
|
|
3408
3396
|
"name": "Flash",
|
|
3409
|
-
"status": "
|
|
3397
|
+
"status": "deprecated",
|
|
3410
3398
|
"a11yReviewed": "2025-01-08",
|
|
3411
3399
|
"stories": [
|
|
3412
3400
|
{
|
|
3413
|
-
"id": "components-flash--default",
|
|
3401
|
+
"id": "deprecated-components-flash--default",
|
|
3414
3402
|
"code": "() => <Flash>Default</Flash>"
|
|
3415
3403
|
},
|
|
3416
3404
|
{
|
|
3417
|
-
"id": "components-flash-features--success",
|
|
3405
|
+
"id": "deprecated-components-flash-features--success",
|
|
3418
3406
|
"code": "() => (\n <Flash\n variant=\"success\"\n style={{\n display: 'grid',\n gridTemplateColumns: 'min-content 1fr minmax(0, auto)',\n gridTemplateAreas: `'visual message actions'`,\n }}\n >\n <div className={classes.Visual}>\n <CheckCircleIcon aria-label=\"Success\" />\n </div>\n <div className={classes.Message}>Success</div>\n </Flash>\n)"
|
|
3419
3407
|
},
|
|
3420
3408
|
{
|
|
3421
|
-
"id": "components-flash-features--danger",
|
|
3409
|
+
"id": "deprecated-components-flash-features--danger",
|
|
3422
3410
|
"code": "() => (\n <Flash\n variant=\"danger\"\n style={{\n display: 'grid',\n gridTemplateColumns: 'min-content 1fr minmax(0, auto)',\n gridTemplateAreas: `'visual message actions'`,\n }}\n >\n <div className={classes.Visual}>\n <InfoIcon aria-label=\"Danger\" />\n </div>\n <div className={classes.Message}>Danger</div>\n </Flash>\n)"
|
|
3423
3411
|
},
|
|
3424
3412
|
{
|
|
3425
|
-
"id": "components-flash-features--warning",
|
|
3413
|
+
"id": "deprecated-components-flash-features--warning",
|
|
3426
3414
|
"code": "() => (\n <Flash\n variant=\"warning\"\n style={{\n display: 'grid',\n gridTemplateColumns: 'min-content 1fr minmax(0, auto)',\n gridTemplateAreas: `'visual message actions'`,\n }}\n >\n <div className={classes.Visual}>\n <AlertIcon aria-label=\"Warning\" />\n </div>\n <div className={classes.Message}>Warning</div>\n </Flash>\n)"
|
|
3427
3415
|
},
|
|
3428
3416
|
{
|
|
3429
|
-
"id": "components-flash-features--full",
|
|
3417
|
+
"id": "deprecated-components-flash-features--full",
|
|
3430
3418
|
"code": "() => (\n <Flash\n full\n style={{\n display: 'grid',\n gridTemplateColumns: 'min-content 1fr minmax(0, auto)',\n gridTemplateAreas: `'visual message actions'`,\n }}\n >\n <div className={classes.Visual}>\n <InfoIcon aria-label=\"Info\" />\n </div>\n <div className={classes.Message}>Full</div>\n </Flash>\n)"
|
|
3431
3419
|
},
|
|
3432
3420
|
{
|
|
3433
|
-
"id": "components-flash-features--with-icon-and-action",
|
|
3421
|
+
"id": "deprecated-components-flash-features--with-icon-and-action",
|
|
3434
3422
|
"code": "() => (\n <Flash className={classes.WithIconAndAction}>\n <div className={classes.Visual}>\n <InfoIcon aria-label=\"Info\" />\n </div>\n <div className={classes.Message}>\n This is a flash message with an icon and an action.\n <Link href=\"/\"> Learn more.</Link>\n </div>\n <div className={classes.ActionsResponsive}>\n <Button>Join waitlist</Button>\n </div>\n </Flash>\n)"
|
|
3435
3423
|
},
|
|
3436
3424
|
{
|
|
3437
|
-
"id": "components-flash-features--with-icon-action-dismiss",
|
|
3425
|
+
"id": "deprecated-components-flash-features--with-icon-action-dismiss",
|
|
3438
3426
|
"code": "() => (\n <Flash className={classes.WithIconActionDismiss}>\n <div className={classes.Visual}>\n <InfoIcon aria-label=\"Info\" />\n </div>\n <div className={classes.Message}>\n This is a flash message with an icon and an action.\n <Link href=\"/\"> Learn more.</Link>\n </div>\n <div className={classes.ActionsResponsive}>\n <Button>Join waitlist</Button>\n </div>\n <div className={classes.Close}>\n <IconButton variant=\"invisible\" icon={XIcon} aria-label=\"Dismiss\" />\n </div>\n </Flash>\n)"
|
|
3439
3427
|
}
|
|
3440
3428
|
],
|
|
3441
|
-
"importPath": "@primer/react",
|
|
3429
|
+
"importPath": "@primer/react/deprecated",
|
|
3442
3430
|
"props": [
|
|
3443
3431
|
{
|
|
3444
3432
|
"name": "full",
|
|
@@ -9617,6 +9605,22 @@
|
|
|
9617
9605
|
{
|
|
9618
9606
|
"id": "experimental-components-underlinepanels-features--with-icons-hidden-on-narrow-screen",
|
|
9619
9607
|
"code": "() => (\n <UnderlinePanels aria-label=\"Tabs with icons\">\n <UnderlinePanels.Tab icon={CodeIcon}>Tab 1</UnderlinePanels.Tab>\n <UnderlinePanels.Tab icon={EyeIcon}>Tab 2</UnderlinePanels.Tab>\n <UnderlinePanels.Tab icon={GitPullRequestIcon}>Tab 3</UnderlinePanels.Tab>\n <UnderlinePanels.Tab icon={CommentDiscussionIcon}>\n Tab 4\n </UnderlinePanels.Tab>\n <UnderlinePanels.Tab icon={PlayIcon}>Tab 5</UnderlinePanels.Tab>\n <UnderlinePanels.Tab icon={ProjectIcon}>Tab 6</UnderlinePanels.Tab>\n <UnderlinePanels.Tab icon={GraphIcon}>Tab 7</UnderlinePanels.Tab>\n <UnderlinePanels.Tab icon={GearIcon}>Tab 8</UnderlinePanels.Tab>\n <UnderlinePanels.Tab icon={ShieldLockIcon}>Tab 9</UnderlinePanels.Tab>\n <UnderlinePanels.Panel>Panel 1</UnderlinePanels.Panel>\n <UnderlinePanels.Panel>Panel 2</UnderlinePanels.Panel>\n <UnderlinePanels.Panel>Panel 3</UnderlinePanels.Panel>\n <UnderlinePanels.Panel>Panel 4</UnderlinePanels.Panel>\n <UnderlinePanels.Panel>Panel 5</UnderlinePanels.Panel>\n <UnderlinePanels.Panel>Panel 6</UnderlinePanels.Panel>\n <UnderlinePanels.Panel>Panel 7</UnderlinePanels.Panel>\n <UnderlinePanels.Panel>Panel 8</UnderlinePanels.Panel>\n <UnderlinePanels.Panel>Panel 9</UnderlinePanels.Panel>\n </UnderlinePanels>\n)"
|
|
9608
|
+
},
|
|
9609
|
+
{
|
|
9610
|
+
"id": "experimental-components-underlinepanels-features--controlled",
|
|
9611
|
+
"code": "() => {\n const [refType, setRefType] = useState('branch')\n return (\n <>\n <FlagState />\n <UnderlinePanels\n aria-label=\"Ref type\"\n value={refType}\n onChange={({ value }) => {\n action('onChange')({\n value,\n })\n setRefType(value)\n }}\n >\n <UnderlinePanels.Tab value=\"branch\" icon={GitBranchIcon}>\n Branches\n </UnderlinePanels.Tab>\n <UnderlinePanels.Tab value=\"tag\" icon={TagIcon}>\n Tags\n </UnderlinePanels.Tab>\n <UnderlinePanels.Panel value=\"branch\">\n Find or create a branch…\n </UnderlinePanels.Panel>\n <UnderlinePanels.Panel value=\"tag\">\n Search or create a new tag…\n </UnderlinePanels.Panel>\n </UnderlinePanels>\n <p>\n Selected ref type: <strong>{refType}</strong>\n </p>\n </>\n )\n}"
|
|
9612
|
+
},
|
|
9613
|
+
{
|
|
9614
|
+
"id": "experimental-components-underlinepanels-features--uncontrolled",
|
|
9615
|
+
"code": "() => (\n <>\n <FlagState />\n <UnderlinePanels\n aria-label=\"Ref type\"\n defaultValue=\"tag\"\n onChange={({ value }) => {\n action('onChange')({\n value,\n })\n }}\n >\n <UnderlinePanels.Tab value=\"branch\">Branches</UnderlinePanels.Tab>\n <UnderlinePanels.Tab value=\"tag\">Tags</UnderlinePanels.Tab>\n <UnderlinePanels.Panel value=\"branch\">\n Find or create a branch…\n </UnderlinePanels.Panel>\n <UnderlinePanels.Panel value=\"tag\">\n Search or create a new tag…\n </UnderlinePanels.Panel>\n </UnderlinePanels>\n </>\n)"
|
|
9616
|
+
},
|
|
9617
|
+
{
|
|
9618
|
+
"id": "experimental-components-underlinepanels-features--manual-activation",
|
|
9619
|
+
"code": "() => {\n const [refType, setRefType] = useState('branch')\n return (\n <>\n <FlagState />\n <p>\n With <code>activationMode="manual"</code>, arrow keys only\n move focus; press Enter or Space (or click) to commit selection. Prefer\n this when switching tabs triggers async work like a fetch.\n </p>\n <UnderlinePanels\n aria-label=\"Ref type\"\n value={refType}\n activationMode=\"manual\"\n onChange={({ value }) => {\n action('onChange')({\n value,\n })\n setRefType(value)\n }}\n >\n <UnderlinePanels.Tab value=\"branch\">Branches</UnderlinePanels.Tab>\n <UnderlinePanels.Tab value=\"tag\">Tags</UnderlinePanels.Tab>\n <UnderlinePanels.Panel value=\"branch\">\n Find or create a branch…\n </UnderlinePanels.Panel>\n <UnderlinePanels.Panel value=\"tag\">\n Search or create a new tag…\n </UnderlinePanels.Panel>\n </UnderlinePanels>\n </>\n )\n}"
|
|
9620
|
+
},
|
|
9621
|
+
{
|
|
9622
|
+
"id": "experimental-components-underlinepanels-features--in-overlay",
|
|
9623
|
+
"code": "() => {\n const [open, setOpen] = useState(false)\n const [refType, setRefType] = useState('branch')\n return (\n <>\n <FlagState />\n <AnchoredOverlay\n open={open}\n onOpen={() => setOpen(true)}\n onClose={() => setOpen(false)}\n renderAnchor={(props) => <Button {...props}>Select ref type</Button>}\n overlayProps={{\n role: 'dialog',\n 'aria-modal': true,\n 'aria-label': 'Select a ref type',\n style: {\n width: '320px',\n },\n }}\n focusZoneSettings={{\n disabled: true,\n }}\n >\n <UnderlinePanels\n aria-label=\"Ref type\"\n value={refType}\n onChange={({ value }) => {\n action('onChange')({\n value,\n })\n setRefType(value)\n }}\n >\n <UnderlinePanels.Tab value=\"branch\">Branches</UnderlinePanels.Tab>\n <UnderlinePanels.Tab value=\"tag\">Tags</UnderlinePanels.Tab>\n <UnderlinePanels.Panel value=\"branch\">\n Find or create a branch…\n </UnderlinePanels.Panel>\n <UnderlinePanels.Panel value=\"tag\">\n Search or create a new tag…\n </UnderlinePanels.Panel>\n </UnderlinePanels>\n </AnchoredOverlay>\n </>\n )\n}"
|
|
9620
9624
|
}
|
|
9621
9625
|
],
|
|
9622
9626
|
"importPath": "@primer/react/experimental",
|
|
@@ -9633,6 +9637,30 @@
|
|
|
9633
9637
|
"defaultValue": "",
|
|
9634
9638
|
"description": "ID of the element containing the name for the tab list"
|
|
9635
9639
|
},
|
|
9640
|
+
{
|
|
9641
|
+
"name": "value",
|
|
9642
|
+
"type": "string",
|
|
9643
|
+
"defaultValue": "",
|
|
9644
|
+
"description": "The value of the selected tab, keyed to each `UnderlinePanels.Tab`/`UnderlinePanels.Panel` `value`. Provide this (with `onChange`) for a controlled component where the selected tab is the single source of truth. Requires the `primer_react_underline_panels_controlled` feature flag."
|
|
9645
|
+
},
|
|
9646
|
+
{
|
|
9647
|
+
"name": "defaultValue",
|
|
9648
|
+
"type": "string",
|
|
9649
|
+
"defaultValue": "",
|
|
9650
|
+
"description": "The value of the tab selected by default, for an uncontrolled component. Cannot be combined with `value`."
|
|
9651
|
+
},
|
|
9652
|
+
{
|
|
9653
|
+
"name": "onChange",
|
|
9654
|
+
"type": "({value}: {value: string}) => void",
|
|
9655
|
+
"defaultValue": "",
|
|
9656
|
+
"description": "Callback fired whenever the selected tab changes, for every selection method — pointer, Enter/Space, and Arrow/Home/End keys. Unlike `UnderlinePanels.Tab`'s `onSelect` (which only fires on click and Enter/Space), this makes the selected value usable as a single source of truth for data-driven tabs."
|
|
9657
|
+
},
|
|
9658
|
+
{
|
|
9659
|
+
"name": "activationMode",
|
|
9660
|
+
"type": "'automatic' | 'manual'",
|
|
9661
|
+
"defaultValue": "'automatic'",
|
|
9662
|
+
"description": "Controls how tabs are activated with the keyboard. `'automatic'` selects on focus (Arrow/Home/End select immediately); `'manual'` moves focus only and commits selection on Enter, Space, or click. Prefer `'manual'` when displaying a panel is not instant (e.g. it triggers a network request). Requires the `primer_react_underline_panels_controlled` feature flag."
|
|
9663
|
+
},
|
|
9636
9664
|
{
|
|
9637
9665
|
"name": "children",
|
|
9638
9666
|
"type": "Array<UnderlinePanels.Tab | UnderlinePanels.Panel>",
|
|
@@ -9663,6 +9691,12 @@
|
|
|
9663
9691
|
{
|
|
9664
9692
|
"name": "UnderlinePanels.Tab",
|
|
9665
9693
|
"props": [
|
|
9694
|
+
{
|
|
9695
|
+
"name": "value",
|
|
9696
|
+
"type": "string",
|
|
9697
|
+
"defaultValue": "",
|
|
9698
|
+
"description": "A value that uniquely identifies this tab, paired with the `UnderlinePanels.Panel` of the same `value`. Provide this to use domain values (e.g. `'branch'`) with the container's controlled `value`/`onChange` API. When omitted, tabs and panels are paired by DOM order."
|
|
9699
|
+
},
|
|
9666
9700
|
{
|
|
9667
9701
|
"name": "aria-selected",
|
|
9668
9702
|
"type": "| boolean | 'true' | 'false'",
|
|
@@ -9673,7 +9707,7 @@
|
|
|
9673
9707
|
"name": "onSelect",
|
|
9674
9708
|
"type": "(event) => void",
|
|
9675
9709
|
"defaultValue": "",
|
|
9676
|
-
"description": "The handler that gets called when the tab is selected"
|
|
9710
|
+
"description": "The handler that gets called when the tab is selected. Note: this fires only on click and Enter/Space — not on arrow-key navigation. For a callback that fires for every selection method, use the container's `onChange` prop instead."
|
|
9677
9711
|
},
|
|
9678
9712
|
{
|
|
9679
9713
|
"name": "counter",
|
|
@@ -9691,7 +9725,14 @@
|
|
|
9691
9725
|
},
|
|
9692
9726
|
{
|
|
9693
9727
|
"name": "UnderlinePanels.Panel",
|
|
9694
|
-
"props": [
|
|
9728
|
+
"props": [
|
|
9729
|
+
{
|
|
9730
|
+
"name": "value",
|
|
9731
|
+
"type": "string",
|
|
9732
|
+
"defaultValue": "",
|
|
9733
|
+
"description": "A value that uniquely identifies this panel, paired with the `UnderlinePanels.Tab` of the same `value`. When omitted, tabs and panels are paired by DOM order."
|
|
9734
|
+
}
|
|
9735
|
+
],
|
|
9695
9736
|
"passthrough": {
|
|
9696
9737
|
"element": "div",
|
|
9697
9738
|
"url": "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#Attributes"
|