@primer/react 38.34.0-rc.9bc993c30 → 38.34.0-rc.ac0faffd6
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 +0 -6
- package/dist/ActionList/Group.js +1 -1
- package/dist/ActionList/List.js +14 -20
- package/dist/AnchoredOverlay/AnchoredOverlay.js +3 -6
- package/dist/Autocomplete/AutocompleteInput.js +7 -10
- package/dist/ButtonGroup/ButtonGroup.js +8 -15
- package/dist/Checkbox/Checkbox.js +9 -16
- package/dist/Dialog/Dialog.js +5 -12
- package/dist/FeatureFlags/DefaultFeatureFlags.js +1 -2
- package/dist/FilteredActionList/FilteredActionList.js +20 -31
- package/dist/FilteredActionList/FilteredActionListInput.d.ts +1 -1
- package/dist/Link/Link.js +33 -33
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/PageHeader/PageHeader.js +21 -30
- package/dist/SegmentedControl/{SegmentedControl-de65527b.css → SegmentedControl-a004561f.css} +2 -2
- package/dist/SegmentedControl/{SegmentedControl-de65527b.css.map → SegmentedControl-a004561f.css.map} +1 -1
- package/dist/SegmentedControl/SegmentedControl.module.css.js +1 -1
- package/dist/SegmentedControl/SegmentedControlButton.js +1 -1
- package/dist/SegmentedControl/SegmentedControlIconButton.js +1 -1
- package/dist/SelectPanel/SelectPanel.js +1 -1
- package/dist/TextInput/TextInput.js +6 -13
- package/dist/TooltipV2/Tooltip.js +11 -18
- package/dist/experimental/Tabs/Tabs.js +2 -3
- package/dist/experimental/Tabs/types.d.ts +3 -10
- package/dist/experimental/Tabs/useTabList.js +10 -18
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +42 -69
- package/dist/experimental/index.js +5 -5
- package/dist/hooks/useMergedRefs.d.ts +4 -4
- package/dist/hooks/useMergedRefs.js +5 -8
- package/dist/hooks/useProvidedRefOrCreate.d.ts +10 -7
- package/dist/hooks/useProvidedRefOrCreate.js +10 -7
- package/generated/components.json +5 -5
- package/package.json +2 -1
package/dist/Link/Link.js
CHANGED
|
@@ -8,74 +8,74 @@ import { jsx } from "react/jsx-runtime";
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
//#region src/Link/Link.tsx
|
|
10
10
|
const UnwrappedLink = (props, ref) => {
|
|
11
|
-
const $ = c(
|
|
11
|
+
const $ = c(19);
|
|
12
12
|
let className;
|
|
13
|
+
let hoverColor;
|
|
13
14
|
let inline;
|
|
14
15
|
let muted;
|
|
15
16
|
let restProps;
|
|
16
17
|
let t0;
|
|
17
18
|
if ($[0] !== props) {
|
|
18
|
-
|
|
19
|
-
t0 = t1;
|
|
20
|
-
className = t2;
|
|
21
|
-
inline = t3;
|
|
22
|
-
muted = t4;
|
|
23
|
-
restProps = t5;
|
|
19
|
+
({as: t0, className, inline, muted, hoverColor, ...restProps} = props);
|
|
24
20
|
$[0] = props;
|
|
25
21
|
$[1] = className;
|
|
26
|
-
$[2] =
|
|
27
|
-
$[3] =
|
|
28
|
-
$[4] =
|
|
29
|
-
$[5] =
|
|
22
|
+
$[2] = hoverColor;
|
|
23
|
+
$[3] = inline;
|
|
24
|
+
$[4] = muted;
|
|
25
|
+
$[5] = restProps;
|
|
26
|
+
$[6] = t0;
|
|
30
27
|
} else {
|
|
31
28
|
className = $[1];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
hoverColor = $[2];
|
|
30
|
+
inline = $[3];
|
|
31
|
+
muted = $[4];
|
|
32
|
+
restProps = $[5];
|
|
33
|
+
t0 = $[6];
|
|
36
34
|
}
|
|
37
35
|
const Component = t0 === void 0 ? "a" : t0;
|
|
38
36
|
const innerRef = React.useRef(null);
|
|
39
37
|
const mergedRef = useMergedRefs(ref, innerRef);
|
|
40
38
|
let t1;
|
|
41
39
|
let t2;
|
|
42
|
-
if ($[
|
|
40
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
43
41
|
t1 = () => {
|
|
44
42
|
if (innerRef.current && !(innerRef.current instanceof HTMLButtonElement) && !(innerRef.current instanceof HTMLAnchorElement)) console.error("Error: Found `Link` component that renders an inaccessible element", innerRef.current, "Please ensure `Link` always renders as <a> or <button>");
|
|
45
43
|
};
|
|
46
44
|
t2 = [innerRef];
|
|
47
|
-
$[
|
|
48
|
-
$[
|
|
45
|
+
$[7] = t1;
|
|
46
|
+
$[8] = t2;
|
|
49
47
|
} else {
|
|
50
|
-
t1 = $[
|
|
51
|
-
t2 = $[
|
|
48
|
+
t1 = $[7];
|
|
49
|
+
t2 = $[8];
|
|
52
50
|
}
|
|
53
51
|
useDevOnlyEffect(t1, t2);
|
|
54
52
|
let t3;
|
|
55
|
-
if ($[
|
|
53
|
+
if ($[9] !== className) {
|
|
56
54
|
t3 = clsx(className, Link_module_css_default.Link);
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
} else t3 = $[
|
|
55
|
+
$[9] = className;
|
|
56
|
+
$[10] = t3;
|
|
57
|
+
} else t3 = $[10];
|
|
60
58
|
const t4 = mergedRef;
|
|
61
59
|
let t5;
|
|
62
|
-
if ($[
|
|
60
|
+
if ($[11] !== Component || $[12] !== hoverColor || $[13] !== inline || $[14] !== muted || $[15] !== restProps || $[16] !== t3 || $[17] !== t4) {
|
|
63
61
|
t5 = /*#__PURE__*/ jsx(Component, {
|
|
64
62
|
className: t3,
|
|
65
63
|
"data-component": "Link",
|
|
66
64
|
"data-muted": muted,
|
|
67
65
|
"data-inline": inline,
|
|
66
|
+
"data-hover-color": hoverColor,
|
|
68
67
|
...restProps,
|
|
69
68
|
ref: t4
|
|
70
69
|
});
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
78
|
-
|
|
70
|
+
$[11] = Component;
|
|
71
|
+
$[12] = hoverColor;
|
|
72
|
+
$[13] = inline;
|
|
73
|
+
$[14] = muted;
|
|
74
|
+
$[15] = restProps;
|
|
75
|
+
$[16] = t3;
|
|
76
|
+
$[17] = t4;
|
|
77
|
+
$[18] = t5;
|
|
78
|
+
} else t5 = $[18];
|
|
79
79
|
return t5;
|
|
80
80
|
};
|
|
81
81
|
const LinkComponent = fixedForwardRef(UnwrappedLink);
|
package/dist/Overlay/Overlay.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
2
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
3
3
|
import { useOverlay } from "../hooks/useOverlay.js";
|
|
4
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
4
|
import Portal_default from "../Portal/index.js";
|
|
5
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
6
6
|
import Overlay_module_css_default from "./Overlay.module.css.js";
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
2
|
import { warning } from "../utils/warning.js";
|
|
4
3
|
import { isSlot } from "../utils/is-slot.js";
|
|
5
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
6
4
|
import { isResponsiveValue } from "../hooks/useResponsiveValue.js";
|
|
7
5
|
import { getResponsiveAttributes } from "../internal/utils/getResponsiveAttributes.js";
|
|
8
6
|
import Heading from "../Heading/Heading.js";
|
|
@@ -12,7 +10,7 @@ import PageHeader_module_css_default from "./PageHeader.module.css.js";
|
|
|
12
10
|
import { c } from "react-compiler-runtime";
|
|
13
11
|
import { clsx } from "clsx";
|
|
14
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import React, { useEffect
|
|
13
|
+
import React, { useEffect } from "react";
|
|
16
14
|
import { ArrowLeftIcon } from "@primer/octicons-react";
|
|
17
15
|
//#region src/PageHeader/PageHeader.tsx
|
|
18
16
|
const hiddenOnRegularAndWide = {
|
|
@@ -29,12 +27,7 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
29
27
|
const $ = c(17);
|
|
30
28
|
const { children, className, as: t1, "aria-label": ariaLabel, role, hasBorder } = t0;
|
|
31
29
|
const BaseComponent = t1 === void 0 ? "div" : t1;
|
|
32
|
-
const
|
|
33
|
-
const rootRef = useRef(null);
|
|
34
|
-
const mergedRef = useMergedRefs(rootRef, forwardedRef);
|
|
35
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
36
|
-
const readRef = mergedRefEnabled ? rootRef : providedOrCreatedRef;
|
|
37
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
30
|
+
const rootRef = useProvidedRefOrCreate(forwardedRef);
|
|
38
31
|
const hoistChildState = (nodes) => {
|
|
39
32
|
const result = { hasNavigation: false };
|
|
40
33
|
for (const child of React.Children.toArray(nodes)) {
|
|
@@ -61,12 +54,12 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
61
54
|
const isInteractive = _temp;
|
|
62
55
|
let t2;
|
|
63
56
|
let t3;
|
|
64
|
-
if ($[0] !== children || $[1] !==
|
|
57
|
+
if ($[0] !== children || $[1] !== rootRef) {
|
|
65
58
|
t2 = function validateInteractiveElementsInTitle() {
|
|
66
59
|
let hasContextArea = false;
|
|
67
60
|
let hasLeadingAction = false;
|
|
68
|
-
if (!
|
|
69
|
-
const titleArea = Array.from(
|
|
61
|
+
if (!rootRef.current || rootRef.current.children.length <= 0) return;
|
|
62
|
+
const titleArea = Array.from(rootRef.current.children).find(_temp2);
|
|
70
63
|
if (!titleArea) return;
|
|
71
64
|
for (const child_1 of React.Children.toArray(children)) {
|
|
72
65
|
if (/*#__PURE__*/ React.isValidElement(child_1) && (child_1.type === ContextArea || isSlot(child_1, ContextArea))) hasContextArea = true;
|
|
@@ -74,9 +67,9 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
74
67
|
}
|
|
75
68
|
warning(Array.from(titleArea.childNodes).some((child_2) => child_2 instanceof HTMLElement && isInteractive(child_2) || Array.from(child_2.childNodes).some((child_3) => child_3 instanceof HTMLElement && isInteractive(child_3))) && (hasContextArea || hasLeadingAction), "When PageHeader.ContextArea or PageHeader.LeadingAction is present, we recommended not to include any interactive items in the PageHeader.TitleArea to make sure the focus order is logical.");
|
|
76
69
|
};
|
|
77
|
-
t3 = [children,
|
|
70
|
+
t3 = [children, rootRef];
|
|
78
71
|
$[0] = children;
|
|
79
|
-
$[1] =
|
|
72
|
+
$[1] = rootRef;
|
|
80
73
|
$[2] = t2;
|
|
81
74
|
$[3] = t3;
|
|
82
75
|
} else {
|
|
@@ -96,9 +89,9 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
96
89
|
const t8 = getResponsiveAttributes("title-size-variant", titleVariant);
|
|
97
90
|
const t9 = getNavHiddenDataAttributes(navigationHidden);
|
|
98
91
|
let t10;
|
|
99
|
-
if ($[6] !== BaseComponent || $[7] !==
|
|
92
|
+
if ($[6] !== BaseComponent || $[7] !== ariaLabel || $[8] !== children || $[9] !== role || $[10] !== rootRef || $[11] !== t4 || $[12] !== t6 || $[13] !== t7 || $[14] !== t8 || $[15] !== t9) {
|
|
100
93
|
t10 = /*#__PURE__*/ jsx(BaseComponent, {
|
|
101
|
-
ref:
|
|
94
|
+
ref: rootRef,
|
|
102
95
|
className: t4,
|
|
103
96
|
"data-component": t5,
|
|
104
97
|
"data-has-border": t6,
|
|
@@ -110,10 +103,10 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
110
103
|
children
|
|
111
104
|
});
|
|
112
105
|
$[6] = BaseComponent;
|
|
113
|
-
$[7] =
|
|
114
|
-
$[8] =
|
|
115
|
-
$[9] =
|
|
116
|
-
$[10] =
|
|
106
|
+
$[7] = ariaLabel;
|
|
107
|
+
$[8] = children;
|
|
108
|
+
$[9] = role;
|
|
109
|
+
$[10] = rootRef;
|
|
117
110
|
$[11] = t4;
|
|
118
111
|
$[12] = t6;
|
|
119
112
|
$[13] = t7;
|
|
@@ -302,9 +295,7 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
302
295
|
const { children, className, hidden: t1, variant: t2 } = t0;
|
|
303
296
|
const hidden = t1 === void 0 ? false : t1;
|
|
304
297
|
const variant = t2 === void 0 ? "medium" : t2;
|
|
305
|
-
const
|
|
306
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
307
|
-
const appliedRef = mergedRefEnabled ? forwardedRef : providedOrCreatedRef;
|
|
298
|
+
const titleAreaRef = useProvidedRefOrCreate(forwardedRef);
|
|
308
299
|
let t3;
|
|
309
300
|
if ($[0] !== className) {
|
|
310
301
|
t3 = clsx(PageHeader_module_css_default.TitleArea, className);
|
|
@@ -324,20 +315,20 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
324
315
|
$[5] = t5;
|
|
325
316
|
} else t5 = $[5];
|
|
326
317
|
let t6;
|
|
327
|
-
if ($[6] !==
|
|
318
|
+
if ($[6] !== children || $[7] !== t3 || $[8] !== t4 || $[9] !== t5 || $[10] !== titleAreaRef) {
|
|
328
319
|
t6 = /*#__PURE__*/ jsx("div", {
|
|
329
320
|
className: t3,
|
|
330
|
-
ref:
|
|
321
|
+
ref: titleAreaRef,
|
|
331
322
|
"data-component": "TitleArea",
|
|
332
323
|
...t4,
|
|
333
324
|
...t5,
|
|
334
325
|
children
|
|
335
326
|
});
|
|
336
|
-
$[6] =
|
|
337
|
-
$[7] =
|
|
338
|
-
$[8] =
|
|
339
|
-
$[9] =
|
|
340
|
-
$[10] =
|
|
327
|
+
$[6] = children;
|
|
328
|
+
$[7] = t3;
|
|
329
|
+
$[8] = t4;
|
|
330
|
+
$[9] = t5;
|
|
331
|
+
$[10] = titleAreaRef;
|
|
341
332
|
$[11] = t6;
|
|
342
333
|
} else t6 = $[11];
|
|
343
334
|
return t6;
|
package/dist/SegmentedControl/{SegmentedControl-de65527b.css → SegmentedControl-a004561f.css}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.prc-SegmentedControl-SegmentedControl-lqIXp{--segmented-control-icon-width:32px;background-color:var(--controlTrack-bgColor-rest,#e6eaef);border:var(--borderWidth-thin,.0625rem) solid var(--controlTrack-borderColor-rest,transparent);border-radius:var(--borderRadius-medium,.375rem);display:inline-flex;font-size:var(--text-body-size-medium,.875rem);height:32px;margin:0;padding:0}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-narrow=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-narrow=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}@media (min-width:48rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}@media (min-width:87.5rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-wide=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=true]:not([data-full-width-wide=true]),.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-wide=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-narrow=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-narrow=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}@media (min-width:48rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-regular=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-regular=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}@media (min-width:87.5rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-wide=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-wide=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}.prc-SegmentedControl-SegmentedControl-lqIXp:where([data-size=small]){font-size:var(--text-body-size-small,.75rem);height:28px}.prc-SegmentedControl-DropdownContainer-ZaPMn{display:none}.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant=dropdown]{display:block}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-narrow=dropdown]{display:block}}@media (min-width:48rem){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-regular=dropdown]{display:block}}@media (min-width:87.5rem){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-wide=dropdown]{display:block}}.prc-SegmentedControl-Item-tSCQh{display:block;flex-grow:1;margin-bottom:-1px;margin-top:-1px;position:relative}.prc-SegmentedControl-Item-tSCQh:not(:last-child){margin-right:1px}.prc-SegmentedControl-Item-tSCQh:not(:last-child):after{background-color:var(--borderColor-default,#d1d9e0);bottom:var(--base-size-8,.5rem);content:"";position:absolute;right:calc(var(--base-size-2,.125rem)*-1);top:var(--base-size-8,.5rem);width:1px}.prc-SegmentedControl-Item-tSCQh:not(:last-child):has(+[data-selected]):after,.prc-SegmentedControl-Item-tSCQh:not(:last-child):where([data-selected]):after{background-color:transparent}.prc-SegmentedControl-Item-tSCQh:first-child{margin-left:-1px}.prc-SegmentedControl-Item-tSCQh:last-child{margin-right:-1px}.prc-SegmentedControl-Item-tSCQh .prc-SegmentedControl-Counter-GmZOI{align-items:center;display:flex;margin-inline-start:var(--base-size-8,.5rem)}.prc-SegmentedControl-Button-E48xz{--segmented-control-button-inner-padding:12px;--segmented-control-button-bg-inset:4px;--segmented-control-outer-radius:var(--borderRadius-medium,0.375rem);background-color:transparent;border-color:transparent;border-radius:var(--segmented-control-outer-radius);border-width:0;color:currentColor;cursor:pointer;font-family:inherit;font-size:inherit;font-weight:var(--base-text-weight-normal,400);height:100%;padding:var(--segmented-control-button-bg-inset);width:100%}.prc-SegmentedControl-Button-E48xz svg{fill:var(--fgColor-muted,#59636e);color:var(--fgColor-muted,#59636e)}.prc-SegmentedControl-Button-E48xz:focus:not(:disabled){box-shadow:none;outline:var(--base-size-2,.125rem) solid var(--fgColor-accent,#0969da);outline-offset:-1px}.prc-SegmentedControl-Button-E48xz:focus:not(:disabled):not(:focus-visible){outline:1px solid transparent}.prc-SegmentedControl-Button-E48xz:focus-visible:not(:disabled){box-shadow:none;outline:var(--base-size-2,.125rem) solid var(--fgColor-accent,#0969da);outline-offset:-1px}.prc-SegmentedControl-Button-E48xz:focus:focus-visible:not(:last-child):after{width:0}.prc-SegmentedControl-Button-E48xz[aria-disabled=true]:not([aria-
|
|
2
|
-
/*# sourceMappingURL=SegmentedControl-
|
|
1
|
+
.prc-SegmentedControl-SegmentedControl-lqIXp{--segmented-control-icon-width:32px;background-color:var(--controlTrack-bgColor-rest,#e6eaef);border:var(--borderWidth-thin,.0625rem) solid var(--controlTrack-borderColor-rest,transparent);border-radius:var(--borderRadius-medium,.375rem);display:inline-flex;font-size:var(--text-body-size-medium,.875rem);height:32px;margin:0;padding:0}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-narrow=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-narrow=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}@media (min-width:48rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}@media (min-width:87.5rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-wide=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=true]:not([data-full-width-wide=true]),.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-wide=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-narrow=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-narrow=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}@media (min-width:48rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-regular=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-regular=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}@media (min-width:87.5rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-wide=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-wide=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}.prc-SegmentedControl-SegmentedControl-lqIXp:where([data-size=small]){font-size:var(--text-body-size-small,.75rem);height:28px}.prc-SegmentedControl-DropdownContainer-ZaPMn{display:none}.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant=dropdown]{display:block}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-narrow=dropdown]{display:block}}@media (min-width:48rem){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-regular=dropdown]{display:block}}@media (min-width:87.5rem){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-wide=dropdown]{display:block}}.prc-SegmentedControl-Item-tSCQh{display:block;flex-grow:1;margin-bottom:-1px;margin-top:-1px;position:relative}.prc-SegmentedControl-Item-tSCQh:not(:last-child){margin-right:1px}.prc-SegmentedControl-Item-tSCQh:not(:last-child):after{background-color:var(--borderColor-default,#d1d9e0);bottom:var(--base-size-8,.5rem);content:"";position:absolute;right:calc(var(--base-size-2,.125rem)*-1);top:var(--base-size-8,.5rem);width:1px}.prc-SegmentedControl-Item-tSCQh:not(:last-child):has(+[data-selected]):after,.prc-SegmentedControl-Item-tSCQh:not(:last-child):where([data-selected]):after{background-color:transparent}.prc-SegmentedControl-Item-tSCQh:first-child{margin-left:-1px}.prc-SegmentedControl-Item-tSCQh:last-child{margin-right:-1px}.prc-SegmentedControl-Item-tSCQh .prc-SegmentedControl-Counter-GmZOI{align-items:center;display:flex;margin-inline-start:var(--base-size-8,.5rem)}.prc-SegmentedControl-Button-E48xz{--segmented-control-button-inner-padding:12px;--segmented-control-button-bg-inset:4px;--segmented-control-outer-radius:var(--borderRadius-medium,0.375rem);background-color:transparent;border-color:transparent;border-radius:var(--segmented-control-outer-radius);border-width:0;color:currentColor;cursor:pointer;font-family:inherit;font-size:inherit;font-weight:var(--base-text-weight-normal,400);height:100%;padding:var(--segmented-control-button-bg-inset);width:100%}.prc-SegmentedControl-Button-E48xz svg{fill:var(--fgColor-muted,#59636e);color:var(--fgColor-muted,#59636e)}.prc-SegmentedControl-Button-E48xz:focus:not(:disabled){box-shadow:none;outline:var(--base-size-2,.125rem) solid var(--fgColor-accent,#0969da);outline-offset:-1px}.prc-SegmentedControl-Button-E48xz:focus:not(:disabled):not(:focus-visible){outline:1px solid transparent}.prc-SegmentedControl-Button-E48xz:focus-visible:not(:disabled){box-shadow:none;outline:var(--base-size-2,.125rem) solid var(--fgColor-accent,#0969da);outline-offset:-1px}.prc-SegmentedControl-Button-E48xz:focus:focus-visible:not(:last-child):after{width:0}.prc-SegmentedControl-Button-E48xz[aria-disabled=true]:not([aria-current=true]){background-color:transparent;color:var(--fgColor-disabled,#818b98);cursor:not-allowed}.prc-SegmentedControl-Button-E48xz[aria-disabled=true]:not([aria-current=true]) svg{fill:var(--fgColor-disabled,#818b98);color:var(--fgColor-disabled,#818b98)}@media (pointer:coarse){.prc-SegmentedControl-Button-E48xz:before{content:"";left:0;min-height:44px;position:absolute;right:0;top:50%;transform:translateY(-50%)}}.prc-SegmentedControl-IconButton-tlzDE{width:var(--segmented-control-icon-width,32px)}.prc-SegmentedControl-Content-1COlk{align-items:center;border-color:transparent;border-radius:calc(var(--segmented-control-outer-radius) - var(--segmented-control-button-bg-inset)/2);border-style:solid;border-width:var(--borderWidth-thin,.0625rem);display:flex;height:100%;justify-content:center;padding-left:calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));padding-right:calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset))}.prc-SegmentedControl-Button-E48xz[aria-current=true]{font-weight:var(--base-text-weight-semibold,600);padding:0}.prc-SegmentedControl-Button-E48xz[aria-current=true] .prc-SegmentedControl-Content-1COlk{background-color:var(--controlKnob-bgColor-rest,#fff);border-color:var(--controlKnob-borderColor-rest,#d1d9e0);border-radius:var(--segmented-control-outer-radius);padding-left:var(--segmented-control-button-inner-padding);padding-right:var(--segmented-control-button-inner-padding)}.prc-SegmentedControl-Button-E48xz:not([aria-current=true],[aria-disabled=true]):hover .prc-SegmentedControl-Content-1COlk{background-color:var(--controlTrack-bgColor-hover,#e0e6eb)}.prc-SegmentedControl-Button-E48xz:not([aria-current=true],[aria-disabled=true]):active .prc-SegmentedControl-Content-1COlk{background-color:var(--controlTrack-bgColor-active,#dae0e7)}.prc-SegmentedControl-Text-7S2y2:after{content:attr(data-text);display:block;font-weight:var(--base-text-weight-semibold,600);height:0;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none;visibility:hidden}.prc-SegmentedControl-LeadingIcon-74n5s{margin-right:var(--base-size-4,.25rem)}
|
|
2
|
+
/*# sourceMappingURL=SegmentedControl-a004561f.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/SegmentedControl/SegmentedControl.module.css.js"],"names":[],"mappings":"AAAA,6CAEE,mCAAoC,CASpC,yDAAkD,CAClD,8FAAuF,CACvF,gDAAyC,CATzC,mBAAoB,CAMpB,8CAAuC,CAHvC,WAAY,CAEZ,QAAS,CADT,SA0HF,CAlHE,mEACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,oEACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CAEA,wCACE,0EACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,2EACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAEA,yBACE,2EACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,4EACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAEA,2BACE,wEACE,YAAa,CACb,UAAW,CAEX,mCACF,CASA,qLACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAQA,2KACE,YACF,CAEA,wCAKE,yLACE,YACF,CACF,CAEA,yBAKE,2LACE,YACF,CACF,CAEA,2BAKE,qLACE,YACF,CACF,CAEA,sEAGE,4CAAsC,CADtC,WAEF,CAGF,8CACE,YAwBF,CArBE,qEACE,aACF,CAEA,wCACE,4EACE,aACF,CACF,CAEA,yBACE,6EACE,aACF,CACF,CAEA,2BACE,0EACE,aACF,CACF,CAGF,iCAEE,aAAc,CAKd,WAAY,CADZ,kBAAmB,CAFnB,eAAgB,CAHhB,iBA6CF,CArCE,kDAEE,gBAkBF,CAhBE,wDAQE,mDAA4C,CAJ5C,+BAA0B,CAE1B,UAAW,CALX,iBAAkB,CAElB,yCAAoC,CADpC,4BAAuB,CAGvB,SAIF,CAGA,6JAEE,4BACF,CAGF,6CAEE,gBACF,CAEA,4CAEE,iBACF,CAEA,qEAGE,kBAAmB,CADnB,YAAa,CADb,4CAGF,CAGF,mCAEE,6CAA8C,CAC9C,uCAAwC,CACxC,oEAA4D,CAW5D,4BAA6B,CAC7B,wBAAyB,CAGzB,mDAAoD,CAFpD,cAAe,CAJf,kBAAmB,CACnB,cAAe,CAJf,mBAAoB,CACpB,iBAAkB,CAClB,8CAA2C,CAL3C,WAAY,CAEZ,gDAAiD,CAHjD,UAmEF,CApDE,uCACE,iCAA0B,CAC1B,kCACF,CAGA,wDAGE,eAAgB,CAFhB,sEAAuD,CACvD,mBAOF,CAHE,4EACE,6BACF,CAIF,gEAGE,eAAgB,CAFhB,sEAAuD,CACvD,mBAEF,CAGA,8EAEE,OACF,CAEA,gFAGE,4BAA6B,CAD7B,qCAA8B,CAD9B,kBAQF,CAJE,oFACE,oCAA6B,CAC7B,qCACF,CAGF,wBACE,0CAME,UAAW,CAFX,MAAO,CACP,eAAgB,CAJhB,iBAAkB,CAElB,OAAQ,CADR,OAAQ,CAKR,0BACF,CACF,CAGF,uCACE,8CACF,CAEA,oCAiBE,kBAAmB,CAVnB,wBAAyB,CASzB,sGAAyG,CARzG,kBAAmB,CACnB,6CAAqC,CARrC,YAAa,CACb,WAAY,CAgBZ,sBAAuB,CAZvB,2GAA4G,CAF5G,4GAeF,CAEA,sDAEE,gDAA6C,CAD7C,SAaF,CAVE,0FAKE,qDAAiD,CACjD,wDAAiD,CAEjD,mDAAoD,CAJpD,0DAA2D,CAF3D,2DAOF,CAIA,2HACE,0DACF,CAEA,4HACE,2DACF,CAGF,uCAOE,uBAAwB,CANxB,aAAc,CAGd,gDAA6C,CAF7C,QAAS,CACT,eAAgB,CAEhB,mBAAoB,CAGpB,wBAAiB,CAAjB,gBAAiB,CAFjB,iBAGF,CAEA,wCACE,sCACF","file":"SegmentedControl-de65527b.css","sourcesContent":[".SegmentedControl {\n /* TODO: use primitive `control.medium.size` when it is available instead of '32px' */\n --segmented-control-icon-width: 32px;\n\n display: inline-flex;\n\n /* TODO: use primitive `control.{small|medium}.size` when it is available */\n height: 32px;\n padding: 0;\n margin: 0;\n font-size: var(--text-body-size-medium);\n background-color: var(--controlTrack-bgColor-rest);\n border: var(--borderWidth-thin) solid var(--controlTrack-borderColor-rest, transparent);\n border-radius: var(--borderRadius-medium);\n\n /* Responsive full-width */\n &[data-full-width='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n\n @media (--viewportRange-narrow) {\n &[data-full-width-narrow='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-narrow='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-full-width-regular='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-regular='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-full-width-wide='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-wide='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n\n &[data-full-width-regular='true']:not([data-full-width-wide='true']) {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n /* Hide when dropdown variant is active */\n &[data-variant='dropdown'] {\n display: none;\n }\n\n /* Handle hideLabels variant - hide button text */\n &[data-variant='hideLabels'] .Text {\n display: none;\n }\n\n @media (--viewportRange-narrow) {\n &[data-variant-narrow='dropdown'] {\n display: none;\n }\n\n &[data-variant-narrow='hideLabels'] .Text {\n display: none;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-variant-regular='dropdown'] {\n display: none;\n }\n\n &[data-variant-regular='hideLabels'] .Text {\n display: none;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-variant-wide='dropdown'] {\n display: none;\n }\n\n &[data-variant-wide='hideLabels'] .Text {\n display: none;\n }\n }\n\n &:where([data-size='small']) {\n /* TODO: use primitive `control.{small|medium}.size` when it is available */\n height: 28px;\n font-size: var(--text-body-size-small);\n }\n}\n\n.DropdownContainer {\n display: none;\n\n /* Show when dropdown variant is active */\n &[data-variant='dropdown'] {\n display: block;\n }\n\n @media (--viewportRange-narrow) {\n &[data-variant-narrow='dropdown'] {\n display: block;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-variant-regular='dropdown'] {\n display: block;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-variant-wide='dropdown'] {\n display: block;\n }\n }\n}\n\n.Item {\n position: relative;\n display: block;\n /* stylelint-disable-next-line primer/spacing */\n margin-top: -1px;\n /* stylelint-disable-next-line primer/spacing */\n margin-bottom: -1px;\n flex-grow: 1;\n\n &:not(:last-child) {\n /* stylelint-disable-next-line primer/spacing */\n margin-right: 1px;\n\n &::after {\n position: absolute;\n top: var(--base-size-8);\n right: calc(-1 * var(--base-size-2));\n bottom: var(--base-size-8);\n width: 1px;\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--borderColor-default);\n }\n\n /* stylelint-disable-next-line selector-pseudo-class-disallowed-list -- scoped to CSS Module, audited (github/github-ui#17224) */\n &:has(+ [data-selected])::after,\n &:where([data-selected])::after {\n background-color: transparent;\n }\n }\n\n &:first-child {\n /* stylelint-disable-next-line primer/spacing */\n margin-left: -1px;\n }\n\n &:last-child {\n /* stylelint-disable-next-line primer/spacing */\n margin-right: -1px;\n }\n\n .Counter {\n margin-inline-start: var(--base-size-8);\n display: flex;\n align-items: center;\n }\n}\n\n.Button {\n /* TODO: use primitive `primer.control.medium.paddingInline.normal` when it is available */\n --segmented-control-button-inner-padding: 12px;\n --segmented-control-button-bg-inset: 4px;\n --segmented-control-outer-radius: var(--borderRadius-medium);\n\n width: 100%;\n height: 100%;\n /* stylelint-disable-next-line primer/spacing */\n padding: var(--segmented-control-button-bg-inset);\n font-family: inherit;\n font-size: inherit;\n font-weight: var(--base-text-weight-normal);\n color: currentColor;\n cursor: pointer;\n background-color: transparent;\n border-color: transparent;\n border-width: 0;\n /* stylelint-disable-next-line primer/borders */\n border-radius: var(--segmented-control-outer-radius);\n\n & svg {\n fill: var(--fgColor-muted);\n color: var(--fgColor-muted);\n }\n\n /* fallback :focus state */\n &:focus:not(:disabled) {\n outline: var(--base-size-2) solid var(--fgColor-accent);\n outline-offset: -1px;\n box-shadow: none;\n\n /* remove fallback :focus if :focus-visible is supported */\n &:not(:focus-visible) {\n outline: solid 1px transparent;\n }\n }\n\n /* default focus state */\n &:focus-visible:not(:disabled) {\n outline: var(--base-size-2) solid var(--fgColor-accent);\n outline-offset: -1px;\n box-shadow: none;\n }\n\n /* stylelint-disable-next-line selector-max-specificity */\n &:focus:focus-visible:not(:last-child)::after {\n /* fixes an issue where the focus outline shows over the pseudo-element */\n width: 0;\n }\n\n &[aria-disabled='true']:not([aria-pressed='true']) {\n cursor: not-allowed;\n color: var(--fgColor-disabled);\n background-color: transparent;\n\n & svg {\n fill: var(--fgColor-disabled);\n color: var(--fgColor-disabled);\n }\n }\n\n @media (pointer: coarse) {\n &::before {\n position: absolute;\n top: 50%;\n right: 0;\n left: 0;\n min-height: 44px;\n content: '';\n transform: translateY(-50%);\n }\n }\n}\n\n.IconButton {\n width: var(--segmented-control-icon-width, 32px);\n}\n\n.Content {\n display: flex;\n height: 100%;\n /* stylelint-disable-next-line primer/spacing */\n padding-right: calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));\n /* stylelint-disable-next-line primer/spacing */\n padding-left: calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));\n border-color: transparent;\n border-style: solid;\n border-width: var(--borderWidth-thin);\n\n /*\n innerRadius = outerRadius - distance/2\n https://stackoverflow.com/questions/2932146/math-problem-determine-the-corner-radius-of-an-inner-border-based-on-outer-corn\n */\n /* stylelint-disable-next-line primer/borders */\n border-radius: calc(var(--segmented-control-outer-radius) - var(--segmented-control-button-bg-inset) / 2);\n align-items: center;\n justify-content: center;\n}\n\n.Button[aria-pressed='true'] {\n padding: 0;\n font-weight: var(--base-text-weight-semibold);\n\n .Content {\n /* stylelint-disable-next-line primer/spacing */\n padding-right: var(--segmented-control-button-inner-padding);\n /* stylelint-disable-next-line primer/spacing */\n padding-left: var(--segmented-control-button-inner-padding);\n background-color: var(--controlKnob-bgColor-rest);\n border-color: var(--controlKnob-borderColor-rest);\n /* stylelint-disable-next-line primer/borders */\n border-radius: var(--segmented-control-outer-radius);\n }\n}\n\n.Button:not([aria-pressed='true'], [aria-disabled='true']) {\n &:hover .Content {\n background-color: var(--controlTrack-bgColor-hover);\n }\n\n &:active .Content {\n background-color: var(--controlTrack-bgColor-active);\n }\n}\n\n.Text::after {\n display: block;\n height: 0;\n overflow: hidden;\n font-weight: var(--base-text-weight-semibold);\n pointer-events: none;\n visibility: hidden;\n content: attr(data-text);\n user-select: none;\n}\n\n.LeadingIcon {\n margin-right: var(--base-size-4);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/SegmentedControl/SegmentedControl.module.css.js"],"names":[],"mappings":"AAAA,6CAEE,mCAAoC,CASpC,yDAAkD,CAClD,8FAAuF,CACvF,gDAAyC,CATzC,mBAAoB,CAMpB,8CAAuC,CAHvC,WAAY,CAEZ,QAAS,CADT,SA0HF,CAlHE,mEACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,oEACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CAEA,wCACE,0EACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,2EACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAEA,yBACE,2EACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,4EACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAEA,2BACE,wEACE,YAAa,CACb,UAAW,CAEX,mCACF,CASA,qLACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAQA,2KACE,YACF,CAEA,wCAKE,yLACE,YACF,CACF,CAEA,yBAKE,2LACE,YACF,CACF,CAEA,2BAKE,qLACE,YACF,CACF,CAEA,sEAGE,4CAAsC,CADtC,WAEF,CAGF,8CACE,YAwBF,CArBE,qEACE,aACF,CAEA,wCACE,4EACE,aACF,CACF,CAEA,yBACE,6EACE,aACF,CACF,CAEA,2BACE,0EACE,aACF,CACF,CAGF,iCAEE,aAAc,CAKd,WAAY,CADZ,kBAAmB,CAFnB,eAAgB,CAHhB,iBA6CF,CArCE,kDAEE,gBAkBF,CAhBE,wDAQE,mDAA4C,CAJ5C,+BAA0B,CAE1B,UAAW,CALX,iBAAkB,CAElB,yCAAoC,CADpC,4BAAuB,CAGvB,SAIF,CAGA,6JAEE,4BACF,CAGF,6CAEE,gBACF,CAEA,4CAEE,iBACF,CAEA,qEAGE,kBAAmB,CADnB,YAAa,CADb,4CAGF,CAGF,mCAEE,6CAA8C,CAC9C,uCAAwC,CACxC,oEAA4D,CAW5D,4BAA6B,CAC7B,wBAAyB,CAGzB,mDAAoD,CAFpD,cAAe,CAJf,kBAAmB,CACnB,cAAe,CAJf,mBAAoB,CACpB,iBAAkB,CAClB,8CAA2C,CAL3C,WAAY,CAEZ,gDAAiD,CAHjD,UAmEF,CApDE,uCACE,iCAA0B,CAC1B,kCACF,CAGA,wDAGE,eAAgB,CAFhB,sEAAuD,CACvD,mBAOF,CAHE,4EACE,6BACF,CAIF,gEAGE,eAAgB,CAFhB,sEAAuD,CACvD,mBAEF,CAGA,8EAEE,OACF,CAEA,gFAGE,4BAA6B,CAD7B,qCAA8B,CAD9B,kBAQF,CAJE,oFACE,oCAA6B,CAC7B,qCACF,CAGF,wBACE,0CAME,UAAW,CAFX,MAAO,CACP,eAAgB,CAJhB,iBAAkB,CAElB,OAAQ,CADR,OAAQ,CAKR,0BACF,CACF,CAGF,uCACE,8CACF,CAEA,oCAiBE,kBAAmB,CAVnB,wBAAyB,CASzB,sGAAyG,CARzG,kBAAmB,CACnB,6CAAqC,CARrC,YAAa,CACb,WAAY,CAgBZ,sBAAuB,CAZvB,2GAA4G,CAF5G,4GAeF,CAEA,sDAEE,gDAA6C,CAD7C,SAaF,CAVE,0FAKE,qDAAiD,CACjD,wDAAiD,CAEjD,mDAAoD,CAJpD,0DAA2D,CAF3D,2DAOF,CAIA,2HACE,0DACF,CAEA,4HACE,2DACF,CAGF,uCAOE,uBAAwB,CANxB,aAAc,CAGd,gDAA6C,CAF7C,QAAS,CACT,eAAgB,CAEhB,mBAAoB,CAGpB,wBAAiB,CAAjB,gBAAiB,CAFjB,iBAGF,CAEA,wCACE,sCACF","file":"SegmentedControl-a004561f.css","sourcesContent":[".SegmentedControl {\n /* TODO: use primitive `control.medium.size` when it is available instead of '32px' */\n --segmented-control-icon-width: 32px;\n\n display: inline-flex;\n\n /* TODO: use primitive `control.{small|medium}.size` when it is available */\n height: 32px;\n padding: 0;\n margin: 0;\n font-size: var(--text-body-size-medium);\n background-color: var(--controlTrack-bgColor-rest);\n border: var(--borderWidth-thin) solid var(--controlTrack-borderColor-rest, transparent);\n border-radius: var(--borderRadius-medium);\n\n /* Responsive full-width */\n &[data-full-width='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n\n @media (--viewportRange-narrow) {\n &[data-full-width-narrow='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-narrow='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-full-width-regular='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-regular='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-full-width-wide='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-wide='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n\n &[data-full-width-regular='true']:not([data-full-width-wide='true']) {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n /* Hide when dropdown variant is active */\n &[data-variant='dropdown'] {\n display: none;\n }\n\n /* Handle hideLabels variant - hide button text */\n &[data-variant='hideLabels'] .Text {\n display: none;\n }\n\n @media (--viewportRange-narrow) {\n &[data-variant-narrow='dropdown'] {\n display: none;\n }\n\n &[data-variant-narrow='hideLabels'] .Text {\n display: none;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-variant-regular='dropdown'] {\n display: none;\n }\n\n &[data-variant-regular='hideLabels'] .Text {\n display: none;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-variant-wide='dropdown'] {\n display: none;\n }\n\n &[data-variant-wide='hideLabels'] .Text {\n display: none;\n }\n }\n\n &:where([data-size='small']) {\n /* TODO: use primitive `control.{small|medium}.size` when it is available */\n height: 28px;\n font-size: var(--text-body-size-small);\n }\n}\n\n.DropdownContainer {\n display: none;\n\n /* Show when dropdown variant is active */\n &[data-variant='dropdown'] {\n display: block;\n }\n\n @media (--viewportRange-narrow) {\n &[data-variant-narrow='dropdown'] {\n display: block;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-variant-regular='dropdown'] {\n display: block;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-variant-wide='dropdown'] {\n display: block;\n }\n }\n}\n\n.Item {\n position: relative;\n display: block;\n /* stylelint-disable-next-line primer/spacing */\n margin-top: -1px;\n /* stylelint-disable-next-line primer/spacing */\n margin-bottom: -1px;\n flex-grow: 1;\n\n &:not(:last-child) {\n /* stylelint-disable-next-line primer/spacing */\n margin-right: 1px;\n\n &::after {\n position: absolute;\n top: var(--base-size-8);\n right: calc(-1 * var(--base-size-2));\n bottom: var(--base-size-8);\n width: 1px;\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--borderColor-default);\n }\n\n /* stylelint-disable-next-line selector-pseudo-class-disallowed-list -- scoped to CSS Module, audited (github/github-ui#17224) */\n &:has(+ [data-selected])::after,\n &:where([data-selected])::after {\n background-color: transparent;\n }\n }\n\n &:first-child {\n /* stylelint-disable-next-line primer/spacing */\n margin-left: -1px;\n }\n\n &:last-child {\n /* stylelint-disable-next-line primer/spacing */\n margin-right: -1px;\n }\n\n .Counter {\n margin-inline-start: var(--base-size-8);\n display: flex;\n align-items: center;\n }\n}\n\n.Button {\n /* TODO: use primitive `primer.control.medium.paddingInline.normal` when it is available */\n --segmented-control-button-inner-padding: 12px;\n --segmented-control-button-bg-inset: 4px;\n --segmented-control-outer-radius: var(--borderRadius-medium);\n\n width: 100%;\n height: 100%;\n /* stylelint-disable-next-line primer/spacing */\n padding: var(--segmented-control-button-bg-inset);\n font-family: inherit;\n font-size: inherit;\n font-weight: var(--base-text-weight-normal);\n color: currentColor;\n cursor: pointer;\n background-color: transparent;\n border-color: transparent;\n border-width: 0;\n /* stylelint-disable-next-line primer/borders */\n border-radius: var(--segmented-control-outer-radius);\n\n & svg {\n fill: var(--fgColor-muted);\n color: var(--fgColor-muted);\n }\n\n /* fallback :focus state */\n &:focus:not(:disabled) {\n outline: var(--base-size-2) solid var(--fgColor-accent);\n outline-offset: -1px;\n box-shadow: none;\n\n /* remove fallback :focus if :focus-visible is supported */\n &:not(:focus-visible) {\n outline: solid 1px transparent;\n }\n }\n\n /* default focus state */\n &:focus-visible:not(:disabled) {\n outline: var(--base-size-2) solid var(--fgColor-accent);\n outline-offset: -1px;\n box-shadow: none;\n }\n\n /* stylelint-disable-next-line selector-max-specificity */\n &:focus:focus-visible:not(:last-child)::after {\n /* fixes an issue where the focus outline shows over the pseudo-element */\n width: 0;\n }\n\n &[aria-disabled='true']:not([aria-current='true']) {\n cursor: not-allowed;\n color: var(--fgColor-disabled);\n background-color: transparent;\n\n & svg {\n fill: var(--fgColor-disabled);\n color: var(--fgColor-disabled);\n }\n }\n\n @media (pointer: coarse) {\n &::before {\n position: absolute;\n top: 50%;\n right: 0;\n left: 0;\n min-height: 44px;\n content: '';\n transform: translateY(-50%);\n }\n }\n}\n\n.IconButton {\n width: var(--segmented-control-icon-width, 32px);\n}\n\n.Content {\n display: flex;\n height: 100%;\n /* stylelint-disable-next-line primer/spacing */\n padding-right: calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));\n /* stylelint-disable-next-line primer/spacing */\n padding-left: calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));\n border-color: transparent;\n border-style: solid;\n border-width: var(--borderWidth-thin);\n\n /*\n innerRadius = outerRadius - distance/2\n https://stackoverflow.com/questions/2932146/math-problem-determine-the-corner-radius-of-an-inner-border-based-on-outer-corn\n */\n /* stylelint-disable-next-line primer/borders */\n border-radius: calc(var(--segmented-control-outer-radius) - var(--segmented-control-button-bg-inset) / 2);\n align-items: center;\n justify-content: center;\n}\n\n.Button[aria-current='true'] {\n padding: 0;\n font-weight: var(--base-text-weight-semibold);\n\n .Content {\n /* stylelint-disable-next-line primer/spacing */\n padding-right: var(--segmented-control-button-inner-padding);\n /* stylelint-disable-next-line primer/spacing */\n padding-left: var(--segmented-control-button-inner-padding);\n background-color: var(--controlKnob-bgColor-rest);\n border-color: var(--controlKnob-borderColor-rest);\n /* stylelint-disable-next-line primer/borders */\n border-radius: var(--segmented-control-outer-radius);\n }\n}\n\n.Button:not([aria-current='true'], [aria-disabled='true']) {\n &:hover .Content {\n background-color: var(--controlTrack-bgColor-hover);\n }\n\n &:active .Content {\n background-color: var(--controlTrack-bgColor-active);\n }\n}\n\n.Text::after {\n display: block;\n height: 0;\n overflow: hidden;\n font-weight: var(--base-text-weight-semibold);\n pointer-events: none;\n visibility: hidden;\n content: attr(data-text);\n user-select: none;\n}\n\n.LeadingIcon {\n margin-right: var(--base-size-4);\n}\n"]}
|
|
@@ -126,7 +126,7 @@ const SegmentedControlButton = (t0) => {
|
|
|
126
126
|
let t11;
|
|
127
127
|
if ($[27] !== rest || $[28] !== selected || $[29] !== t10 || $[30] !== t3 || $[31] !== t4) {
|
|
128
128
|
t11 = /*#__PURE__*/ jsx("button", {
|
|
129
|
-
"aria-
|
|
129
|
+
"aria-current": selected,
|
|
130
130
|
"aria-disabled": t3,
|
|
131
131
|
className: t4,
|
|
132
132
|
type: "button",
|
|
@@ -87,7 +87,7 @@ const SegmentedControlIconButton = (t0) => {
|
|
|
87
87
|
if ($[20] !== rest || $[21] !== selected || $[22] !== t10 || $[23] !== t5 || $[24] !== t6) {
|
|
88
88
|
t11 = /*#__PURE__*/ jsx("button", {
|
|
89
89
|
type: "button",
|
|
90
|
-
"aria-
|
|
90
|
+
"aria-current": selected,
|
|
91
91
|
"aria-label": t5,
|
|
92
92
|
"aria-disabled": t6,
|
|
93
93
|
className: t7,
|
|
@@ -2,13 +2,13 @@ import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
|
2
2
|
import { useProvidedStateOrCreate } from "../hooks/useProvidedStateOrCreate.js";
|
|
3
3
|
import { isAlphabetKey } from "../hooks/useMnemonics.js";
|
|
4
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
5
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
6
5
|
import useSafeTimeout from "../hooks/useSafeTimeout.js";
|
|
7
6
|
import { IconButton } from "../Button/IconButton.js";
|
|
8
7
|
import { LinkButton } from "../Button/LinkButton.js";
|
|
9
8
|
import { ButtonComponent } from "../Button/Button.js";
|
|
10
9
|
import { useResponsiveValue } from "../hooks/useResponsiveValue.js";
|
|
11
10
|
import Heading from "../Heading/Heading.js";
|
|
11
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
12
12
|
import { AnchoredOverlay } from "../AnchoredOverlay/AnchoredOverlay.js";
|
|
13
13
|
import { Banner } from "../Banner/index.js";
|
|
14
14
|
import { useFormControlContext } from "../FormControl/_FormControlContext.js";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
2
|
import { AriaStatus } from "../live-region/AriaStatus.js";
|
|
4
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
3
|
import Text_default from "../Text/Text.js";
|
|
6
4
|
import _VisuallyHidden_module_css_default from "../_VisuallyHidden.module.css.js";
|
|
7
5
|
import VisuallyHidden from "../_VisuallyHidden.js";
|
|
@@ -13,19 +11,14 @@ import UnstyledTextInput from "../internal/components/UnstyledTextInput.js";
|
|
|
13
11
|
import { getCharacterCountState } from "../utils/character-counter.js";
|
|
14
12
|
import { clsx } from "clsx";
|
|
15
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
-
import React, { useCallback, useId,
|
|
14
|
+
import React, { useCallback, useId, useState } from "react";
|
|
17
15
|
import { isValidElementType } from "react-is";
|
|
18
16
|
import { AlertFillIcon } from "@primer/octicons-react";
|
|
19
17
|
//#region src/TextInput/TextInput.tsx
|
|
20
18
|
const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, trailingAction, block, className, contrast, disabled, loading, loaderPosition = "auto", loaderText = "Loading", monospace, validationStatus, size: sizeProp, onFocus, onBlur, variant: variantProp, width: widthProp, minWidth: minWidthProp, maxWidth: maxWidthProp, type = "text", required, characterLimit, onChange, value, defaultValue, "data-component": dataComponent, ...inputProps }, ref) => {
|
|
21
19
|
var _counter$isOverLimit;
|
|
22
20
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
23
|
-
const
|
|
24
|
-
const inputRef = useRef(null);
|
|
25
|
-
const mergedRef = useMergedRefs(inputRef, ref);
|
|
26
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(ref);
|
|
27
|
-
const readRef = mergedRefEnabled ? inputRef : providedOrCreatedRef;
|
|
28
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
21
|
+
const inputRef = useProvidedRefOrCreate(ref);
|
|
29
22
|
const isControlled = value !== void 0;
|
|
30
23
|
const [uncontrolledLength, setUncontrolledLength] = useState(() => defaultValue !== void 0 ? String(defaultValue).length : 0);
|
|
31
24
|
const currentLength = isControlled ? String(value).length : uncontrolledLength;
|
|
@@ -36,9 +29,9 @@ const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leading
|
|
|
36
29
|
const showTrailingLoadingIndicator = loading && (loaderPosition === "trailing" || Boolean(loaderPosition === "auto" && !LeadingVisual));
|
|
37
30
|
const isSegmentedInputType = type === "date" || type === "time" || type === "datetime-local";
|
|
38
31
|
const focusInput = (e) => {
|
|
39
|
-
if (e.target !==
|
|
40
|
-
var
|
|
41
|
-
(
|
|
32
|
+
if (e.target !== inputRef.current || !isSegmentedInputType) {
|
|
33
|
+
var _inputRef$current;
|
|
34
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
42
35
|
}
|
|
43
36
|
};
|
|
44
37
|
const leadingVisualId = useId();
|
|
@@ -95,7 +88,7 @@ const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leading
|
|
|
95
88
|
children: typeof LeadingVisual !== "string" && isValidElementType(LeadingVisual) ? /*#__PURE__*/ jsx(LeadingVisual, {}) : LeadingVisual
|
|
96
89
|
}),
|
|
97
90
|
/*#__PURE__*/ jsx(UnstyledTextInput, {
|
|
98
|
-
ref:
|
|
91
|
+
ref: inputRef,
|
|
99
92
|
disabled,
|
|
100
93
|
onFocus: handleInputFocus,
|
|
101
94
|
onBlur: handleInputBlur,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
2
|
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
4
3
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
5
4
|
import { warning } from "../utils/warning.js";
|
|
6
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
7
5
|
import { invariant } from "../utils/invariant.js";
|
|
8
6
|
import Tooltip_module_css_default from "./Tooltip.module.css.js";
|
|
9
7
|
import VisuallyHidden from "../_VisuallyHidden.js";
|
|
@@ -82,12 +80,7 @@ const emptyKeybindingHints = [];
|
|
|
82
80
|
const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
|
|
83
81
|
const tooltipId = useId$1(id);
|
|
84
82
|
const child = Children.only(children);
|
|
85
|
-
const
|
|
86
|
-
const triggerRef = useRef(null);
|
|
87
|
-
const mergedTriggerRef = useMergedRefs(triggerRef, forwardedRef);
|
|
88
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
89
|
-
const readTriggerRef = mergedRefEnabled ? triggerRef : providedOrCreatedRef;
|
|
90
|
-
const appliedTriggerRef = mergedRefEnabled ? mergedTriggerRef : providedOrCreatedRef;
|
|
83
|
+
const triggerRef = useProvidedRefOrCreate(forwardedRef);
|
|
91
84
|
const tooltipElRef = useRef(null);
|
|
92
85
|
const [calculatedDirection, setCalculatedDirection] = useState(direction);
|
|
93
86
|
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
|
@@ -95,9 +88,9 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
95
88
|
const { safeSetTimeout, safeClearTimeout } = useSafeTimeout();
|
|
96
89
|
const openTooltip = () => {
|
|
97
90
|
try {
|
|
98
|
-
if (tooltipElRef.current &&
|
|
91
|
+
if (tooltipElRef.current && triggerRef.current && tooltipElRef.current.hasAttribute("popover") && !tooltipElRef.current.matches(":popover-open") && !_privateDisableTooltip) {
|
|
99
92
|
const tooltip = tooltipElRef.current;
|
|
100
|
-
const trigger =
|
|
93
|
+
const trigger = triggerRef.current;
|
|
101
94
|
tooltip.showPopover();
|
|
102
95
|
setIsPopoverOpen(true);
|
|
103
96
|
const { top, left, anchorAlign, anchorSide } = getAnchoredPosition(tooltip, trigger, {
|
|
@@ -119,7 +112,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
119
112
|
openTimeoutRef.current = null;
|
|
120
113
|
}
|
|
121
114
|
try {
|
|
122
|
-
if (tooltipElRef.current &&
|
|
115
|
+
if (tooltipElRef.current && triggerRef.current && tooltipElRef.current.hasAttribute("popover") && tooltipElRef.current.matches(":popover-open")) {
|
|
123
116
|
tooltipElRef.current.hidePopover();
|
|
124
117
|
setIsPopoverOpen(false);
|
|
125
118
|
} else setIsPopoverOpen(false);
|
|
@@ -129,16 +122,16 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
129
122
|
};
|
|
130
123
|
const value = useMemo(() => ({ tooltipId }), [tooltipId]);
|
|
131
124
|
useEffect(() => {
|
|
132
|
-
if (!tooltipElRef.current || !
|
|
133
|
-
const isTriggerInteractive = isInteractive(
|
|
134
|
-
const triggerChildren =
|
|
125
|
+
if (!tooltipElRef.current || !triggerRef.current) return;
|
|
126
|
+
const isTriggerInteractive = isInteractive(triggerRef.current);
|
|
127
|
+
const triggerChildren = triggerRef.current.childNodes;
|
|
135
128
|
const hasInteractiveDescendant = Array.from(triggerChildren).some((child) => {
|
|
136
129
|
return child instanceof HTMLElement && isInteractive(child) || Array.from(child.childNodes).some((grandChild) => grandChild instanceof HTMLElement && isInteractive(grandChild));
|
|
137
130
|
});
|
|
138
131
|
!(isTriggerInteractive || hasInteractiveDescendant) && invariant(false, "The `Tooltip` component expects a single React element that contains interactive content. Consider using a `<button>` or equivalent interactive element instead.");
|
|
139
132
|
if (type === "label") {
|
|
140
|
-
const hasAriaLabel =
|
|
141
|
-
const hasAriaLabelInChildren = Array.from(
|
|
133
|
+
const hasAriaLabel = triggerRef.current.hasAttribute("aria-label");
|
|
134
|
+
const hasAriaLabelInChildren = Array.from(triggerRef.current.childNodes).some((child) => child instanceof HTMLElement && child.hasAttribute("aria-label"));
|
|
142
135
|
warning(hasAriaLabel || hasAriaLabelInChildren, "The label type `Tooltip` is going to be used here to label the trigger element. Please remove the aria-label from the trigger element.");
|
|
143
136
|
}
|
|
144
137
|
if (typeof window !== "undefined") {
|
|
@@ -147,7 +140,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
147
140
|
tooltipElRef.current.setAttribute("popover", "auto");
|
|
148
141
|
}, [
|
|
149
142
|
tooltipElRef,
|
|
150
|
-
|
|
143
|
+
triggerRef,
|
|
151
144
|
direction,
|
|
152
145
|
type
|
|
153
146
|
]);
|
|
@@ -164,7 +157,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
164
157
|
return /*#__PURE__*/ jsx(TooltipContext.Provider, {
|
|
165
158
|
value,
|
|
166
159
|
children: /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
|
|
167
|
-
ref:
|
|
160
|
+
ref: triggerRef,
|
|
168
161
|
"aria-describedby": (() => {
|
|
169
162
|
if (type !== "description") return child.props["aria-describedby"];
|
|
170
163
|
const existingDescribedBy = child.props["aria-describedby"];
|
|
@@ -13,11 +13,10 @@ import React, { useId } from "react";
|
|
|
13
13
|
* The `Tab`, `TabList`, and `TabPanel` components are provided for convenience to showcase the API & implementation.
|
|
14
14
|
*/
|
|
15
15
|
function Tabs(props) {
|
|
16
|
-
var _props$
|
|
16
|
+
var _props$defaultValue;
|
|
17
17
|
const $ = c(13);
|
|
18
18
|
const { children, onValueChange } = props;
|
|
19
|
-
const
|
|
20
|
-
const groupId = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : generatedId;
|
|
19
|
+
const groupId = useId();
|
|
21
20
|
const t0 = (_props$defaultValue = props.defaultValue) !== null && _props$defaultValue !== void 0 ? _props$defaultValue : props.value;
|
|
22
21
|
let t1;
|
|
23
22
|
if ($[0] !== props.value || $[1] !== t0) {
|
|
@@ -45,14 +45,7 @@ type UncontrolledTabsProps = {
|
|
|
45
45
|
value: string;
|
|
46
46
|
}) => void;
|
|
47
47
|
};
|
|
48
|
-
type
|
|
49
|
-
/**
|
|
50
|
-
* Optional id used as the base for generated tab and panel ids. If omitted, a
|
|
51
|
-
* unique id is generated automatically.
|
|
52
|
-
*/
|
|
53
|
-
id?: string;
|
|
54
|
-
};
|
|
55
|
-
type TabsProps = PropsWithChildren<(ControlledTabsProps | UncontrolledTabsProps) & CommonTabsProps>;
|
|
48
|
+
type TabsProps = PropsWithChildren<ControlledTabsProps | UncontrolledTabsProps>;
|
|
56
49
|
type Label = {
|
|
57
50
|
'aria-label': string;
|
|
58
51
|
};
|
|
@@ -80,7 +73,7 @@ type TabPanelProps = {
|
|
|
80
73
|
value: string;
|
|
81
74
|
};
|
|
82
75
|
type TabListHookProps<T extends HTMLElement> = TabListProps & {
|
|
83
|
-
/** Optional ref to use for the tablist. If none is provided, one will be generated automatically */ref?: React.
|
|
76
|
+
/** Optional ref to use for the tablist. If none is provided, one will be generated automatically */ref?: React.RefObject<T>;
|
|
84
77
|
};
|
|
85
78
|
type TabListHookResult<T extends HTMLElement> = {
|
|
86
79
|
/** Props to be spread onto the tablist element */tabListProps: {
|
|
@@ -88,7 +81,7 @@ type TabListHookResult<T extends HTMLElement> = {
|
|
|
88
81
|
'aria-orientation': AriaAttributes['aria-orientation'];
|
|
89
82
|
'aria-label': AriaAttributes['aria-label'];
|
|
90
83
|
'aria-labelledby': AriaAttributes['aria-labelledby'];
|
|
91
|
-
ref: React.
|
|
84
|
+
ref: React.RefObject<T | null>;
|
|
92
85
|
role: 'tablist';
|
|
93
86
|
};
|
|
94
87
|
};
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import { useMergedRefs } from "../../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../../hooks/useProvidedRefOrCreate.js";
|
|
3
|
-
import { useFeatureFlag } from "../../FeatureFlags/useFeatureFlag.js";
|
|
4
2
|
import { c } from "react-compiler-runtime";
|
|
5
|
-
import { useRef } from "react";
|
|
6
3
|
//#region src/experimental/Tabs/useTabList.ts
|
|
7
4
|
function useTabList(props) {
|
|
8
5
|
const $ = c(9);
|
|
9
6
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-orientation": ariaOrientation } = props;
|
|
10
|
-
const
|
|
11
|
-
const tabListRef = useRef(null);
|
|
12
|
-
const mergedRef = useMergedRefs(tabListRef, props.ref);
|
|
13
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(props.ref);
|
|
14
|
-
const readRef = mergedRefEnabled ? tabListRef : providedOrCreatedRef;
|
|
15
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
7
|
+
const ref = useProvidedRefOrCreate(props.ref);
|
|
16
8
|
let t0;
|
|
17
|
-
if ($[0] !== ariaOrientation || $[1] !==
|
|
9
|
+
if ($[0] !== ariaOrientation || $[1] !== ref) {
|
|
18
10
|
t0 = (event) => {
|
|
19
|
-
const { current: tablist } =
|
|
11
|
+
const { current: tablist } = ref;
|
|
20
12
|
if (tablist === null) return;
|
|
21
13
|
const tabs = getFocusableTabs(tablist);
|
|
22
14
|
const isVertical = ariaOrientation === "vertical";
|
|
@@ -41,25 +33,25 @@ function useTabList(props) {
|
|
|
41
33
|
}
|
|
42
34
|
};
|
|
43
35
|
$[0] = ariaOrientation;
|
|
44
|
-
$[1] =
|
|
36
|
+
$[1] = ref;
|
|
45
37
|
$[2] = t0;
|
|
46
38
|
} else t0 = $[2];
|
|
47
39
|
const onKeyDown = t0;
|
|
48
40
|
const t1 = ariaOrientation !== null && ariaOrientation !== void 0 ? ariaOrientation : "horizontal";
|
|
49
41
|
let t2;
|
|
50
|
-
if ($[3] !==
|
|
42
|
+
if ($[3] !== ariaLabel || $[4] !== ariaLabelledby || $[5] !== onKeyDown || $[6] !== ref || $[7] !== t1) {
|
|
51
43
|
t2 = { tabListProps: {
|
|
52
|
-
ref
|
|
44
|
+
ref,
|
|
53
45
|
"aria-label": ariaLabel,
|
|
54
46
|
"aria-labelledby": ariaLabelledby,
|
|
55
47
|
"aria-orientation": t1,
|
|
56
48
|
role: "tablist",
|
|
57
49
|
onKeyDown
|
|
58
50
|
} };
|
|
59
|
-
$[3] =
|
|
60
|
-
$[4] =
|
|
61
|
-
$[5] =
|
|
62
|
-
$[6] =
|
|
51
|
+
$[3] = ariaLabel;
|
|
52
|
+
$[4] = ariaLabelledby;
|
|
53
|
+
$[5] = onKeyDown;
|
|
54
|
+
$[6] = ref;
|
|
63
55
|
$[7] = t1;
|
|
64
56
|
$[8] = t2;
|
|
65
57
|
} else t2 = $[8];
|