@primer/react 38.43.0-rc.9f4d27bc2 → 38.43.0-rc.d8a41c875
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 +8 -0
- package/dist/Token/_RemoveTokenButton.js +115 -20
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +417 -121
- package/dist/hooks/useControllableState.js +70 -19
- package/dist/hooks/useOnOutsideClick.js +48 -21
- package/dist/hooks/useSafeTimeout.js +54 -19
- package/dist/internal/hooks/useDevOnlyEffect.js +3 -8
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
- [#8545](https://github.com/primer/react/pull/8545) [`c29b6fe`](https://github.com/primer/react/commit/c29b6fec94c8b18b4f59f7935740ab7b94598ecc) Thanks [@tay1orjones](https://github.com/tay1orjones)! - TextInput and Textarea: Deprecate the `contrast` prop. Omit it to use the default background.
|
|
8
8
|
|
|
9
|
+
- [#8558](https://github.com/primer/react/pull/8558) [`6f52273`](https://github.com/primer/react/commit/6f522732b1370954fd1de47b806864c6a46886c5) Thanks [@joshblack](https://github.com/joshblack)! - useControllableState, useOnOutsideClick: Support automatic memoization with React Compiler.
|
|
10
|
+
|
|
11
|
+
- [#8555](https://github.com/primer/react/pull/8555) [`746d76a`](https://github.com/primer/react/commit/746d76ae7a21ba675ebb4282dd5771c351aeb8f3) Thanks [@joshblack](https://github.com/joshblack)! - useSafeTimeout: Support automatic memoization with React Compiler.
|
|
12
|
+
|
|
13
|
+
- [#8555](https://github.com/primer/react/pull/8555) [`746d76a`](https://github.com/primer/react/commit/746d76ae7a21ba675ebb4282dd5771c351aeb8f3) Thanks [@joshblack](https://github.com/joshblack)! - Token, IssueLabelToken: Improve rendering performance with React Compiler support.
|
|
14
|
+
|
|
15
|
+
- [#8555](https://github.com/primer/react/pull/8555) [`746d76a`](https://github.com/primer/react/commit/746d76ae7a21ba675ebb4282dd5771c351aeb8f3) Thanks [@joshblack](https://github.com/joshblack)! - UnderlinePanels: Improve rendering performance with React Compiler support.
|
|
16
|
+
|
|
9
17
|
### Patch Changes
|
|
10
18
|
|
|
11
19
|
- [#8545](https://github.com/primer/react/pull/8545) [`c29b6fe`](https://github.com/primer/react/commit/c29b6fec94c8b18b4f59f7935740ab7b94598ecc) Thanks [@tay1orjones](https://github.com/tay1orjones)! - SelectPanel: Use the default filter input background. Enable `primer_react_select_panel_legacy_contrast` to restore the previous appearance.
|
|
@@ -1,29 +1,124 @@
|
|
|
1
|
+
import { c } from "../utils/react-compiler-runtime.js";
|
|
1
2
|
import { defaultTokenSize } from "./constants.js";
|
|
2
3
|
import _RemoveTokenButton_module_css_default from "./_RemoveTokenButton.module.css.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import { clsx } from "clsx";
|
|
5
6
|
import { XIcon } from "@primer/octicons-react";
|
|
6
7
|
//#region src/Token/_RemoveTokenButton.tsx
|
|
7
|
-
const RemoveTokenButton = (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
const RemoveTokenButton = (t0) => {
|
|
9
|
+
const $ = c(32);
|
|
10
|
+
let ariaLabel;
|
|
11
|
+
let className;
|
|
12
|
+
let isParentInteractive;
|
|
13
|
+
let rest;
|
|
14
|
+
let t1;
|
|
15
|
+
let t2;
|
|
16
|
+
if ($[0] !== t0) {
|
|
17
|
+
const { "aria-label": t3, isParentInteractive: t4, size: t5, className: t6, borderOffset: t7, as: _as, children: _children, ...t8 } = t0;
|
|
18
|
+
ariaLabel = t3;
|
|
19
|
+
isParentInteractive = t4;
|
|
20
|
+
t1 = t5;
|
|
21
|
+
className = t6;
|
|
22
|
+
t2 = t7;
|
|
23
|
+
rest = t8;
|
|
24
|
+
$[0] = t0;
|
|
25
|
+
$[1] = ariaLabel;
|
|
26
|
+
$[2] = className;
|
|
27
|
+
$[3] = isParentInteractive;
|
|
28
|
+
$[4] = rest;
|
|
29
|
+
$[5] = t1;
|
|
30
|
+
$[6] = t2;
|
|
31
|
+
} else {
|
|
32
|
+
ariaLabel = $[1];
|
|
33
|
+
className = $[2];
|
|
34
|
+
isParentInteractive = $[3];
|
|
35
|
+
rest = $[4];
|
|
36
|
+
t1 = $[5];
|
|
37
|
+
t2 = $[6];
|
|
38
|
+
}
|
|
39
|
+
const size = t1 === void 0 ? defaultTokenSize : t1;
|
|
40
|
+
const borderOffset = t2 === void 0 ? 0 : t2;
|
|
41
|
+
if (isParentInteractive) {
|
|
42
|
+
let t3;
|
|
43
|
+
if ($[7] !== className) {
|
|
44
|
+
t3 = clsx(_RemoveTokenButton_module_css_default.TokenButton, className);
|
|
45
|
+
$[7] = className;
|
|
46
|
+
$[8] = t3;
|
|
47
|
+
} else t3 = $[8];
|
|
48
|
+
const t4 = `translate(${borderOffset}px, -${borderOffset}px)`;
|
|
49
|
+
let t5;
|
|
50
|
+
if ($[9] !== t4) {
|
|
51
|
+
t5 = { transform: t4 };
|
|
52
|
+
$[9] = t4;
|
|
53
|
+
$[10] = t5;
|
|
54
|
+
} else t5 = $[10];
|
|
55
|
+
const t6 = size === "small" || size === "medium" ? 12 : 16;
|
|
56
|
+
let t7;
|
|
57
|
+
if ($[11] !== t6) {
|
|
58
|
+
t7 = /* @__PURE__ */ jsx(XIcon, { size: t6 });
|
|
59
|
+
$[11] = t6;
|
|
60
|
+
$[12] = t7;
|
|
61
|
+
} else t7 = $[12];
|
|
62
|
+
let t8;
|
|
63
|
+
if ($[13] !== ariaLabel || $[14] !== rest || $[15] !== size || $[16] !== t3 || $[17] !== t5 || $[18] !== t7) {
|
|
64
|
+
t8 = /* @__PURE__ */ jsx("span", {
|
|
65
|
+
...rest,
|
|
66
|
+
tabIndex: -1,
|
|
67
|
+
"aria-label": ariaLabel,
|
|
68
|
+
"data-size": size,
|
|
69
|
+
className: t3,
|
|
70
|
+
style: t5,
|
|
71
|
+
children: t7
|
|
72
|
+
});
|
|
73
|
+
$[13] = ariaLabel;
|
|
74
|
+
$[14] = rest;
|
|
75
|
+
$[15] = size;
|
|
76
|
+
$[16] = t3;
|
|
77
|
+
$[17] = t5;
|
|
78
|
+
$[18] = t7;
|
|
79
|
+
$[19] = t8;
|
|
80
|
+
} else t8 = $[19];
|
|
81
|
+
return t8;
|
|
82
|
+
}
|
|
83
|
+
let t3;
|
|
84
|
+
if ($[20] !== className) {
|
|
85
|
+
t3 = clsx(_RemoveTokenButton_module_css_default.TokenButton, className);
|
|
86
|
+
$[20] = className;
|
|
87
|
+
$[21] = t3;
|
|
88
|
+
} else t3 = $[21];
|
|
89
|
+
const t4 = `translate(${borderOffset}px, -${borderOffset}px)`;
|
|
90
|
+
let t5;
|
|
91
|
+
if ($[22] !== t4) {
|
|
92
|
+
t5 = { transform: t4 };
|
|
93
|
+
$[22] = t4;
|
|
94
|
+
$[23] = t5;
|
|
95
|
+
} else t5 = $[23];
|
|
96
|
+
const t6 = size === "small" || size === "medium" ? 12 : 16;
|
|
97
|
+
let t7;
|
|
98
|
+
if ($[24] !== t6) {
|
|
99
|
+
t7 = /* @__PURE__ */ jsx(XIcon, { size: t6 });
|
|
100
|
+
$[24] = t6;
|
|
101
|
+
$[25] = t7;
|
|
102
|
+
} else t7 = $[25];
|
|
103
|
+
let t8;
|
|
104
|
+
if ($[26] !== rest || $[27] !== size || $[28] !== t3 || $[29] !== t5 || $[30] !== t7) {
|
|
105
|
+
t8 = /* @__PURE__ */ jsx("button", {
|
|
106
|
+
...rest,
|
|
107
|
+
"aria-label": "Remove token",
|
|
108
|
+
"data-size": size,
|
|
109
|
+
className: t3,
|
|
110
|
+
style: t5,
|
|
111
|
+
type: "button",
|
|
112
|
+
children: t7
|
|
113
|
+
});
|
|
114
|
+
$[26] = rest;
|
|
115
|
+
$[27] = size;
|
|
116
|
+
$[28] = t3;
|
|
117
|
+
$[29] = t5;
|
|
118
|
+
$[30] = t7;
|
|
119
|
+
$[31] = t8;
|
|
120
|
+
} else t8 = $[31];
|
|
121
|
+
return t8;
|
|
27
122
|
};
|
|
28
123
|
//#endregion
|
|
29
124
|
export { RemoveTokenButton as default };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c } from "../../utils/react-compiler-runtime.js";
|
|
1
2
|
import useIsomorphicLayoutEffect from "../../utils/useIsomorphicLayoutEffect.js";
|
|
2
3
|
import { useResizeObserver } from "../../hooks/useResizeObserver.js";
|
|
3
4
|
import { useId as useId$1 } from "../../hooks/useId.js";
|
|
@@ -10,7 +11,7 @@ import { useTab } from "../Tabs/useTab.js";
|
|
|
10
11
|
import { useTabList } from "../Tabs/useTabList.js";
|
|
11
12
|
import { useTabPanel } from "../Tabs/useTabPanel.js";
|
|
12
13
|
import { Tabs } from "../Tabs/Tabs.js";
|
|
13
|
-
import React, { Children, cloneElement, createContext, isValidElement, useContext,
|
|
14
|
+
import React, { Children, cloneElement, createContext, isValidElement, useContext, useRef, useState } from "react";
|
|
14
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
16
|
import { clsx } from "clsx";
|
|
16
17
|
//#region src/experimental/UnderlinePanels/UnderlinePanels.tsx
|
|
@@ -18,172 +19,460 @@ const UnderlinePanelsContext = /*#__PURE__*/ createContext({
|
|
|
18
19
|
iconsVisible: true,
|
|
19
20
|
loadingCounters: void 0
|
|
20
21
|
});
|
|
21
|
-
const UnderlinePanels = (
|
|
22
|
-
|
|
22
|
+
const UnderlinePanels = (t0) => {
|
|
23
|
+
const $ = c(75);
|
|
24
|
+
let ariaLabel;
|
|
25
|
+
let ariaLabelledBy;
|
|
26
|
+
let children;
|
|
27
|
+
let className;
|
|
28
|
+
let controlledValue;
|
|
29
|
+
let defaultValue;
|
|
30
|
+
let loadingCounters;
|
|
31
|
+
let onChange;
|
|
32
|
+
let props;
|
|
33
|
+
let t1;
|
|
34
|
+
if ($[0] !== t0) {
|
|
35
|
+
({"aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, loadingCounters, className, value: controlledValue, defaultValue, onChange, activationMode: t1, ...props} = t0);
|
|
36
|
+
$[0] = t0;
|
|
37
|
+
$[1] = ariaLabel;
|
|
38
|
+
$[2] = ariaLabelledBy;
|
|
39
|
+
$[3] = children;
|
|
40
|
+
$[4] = className;
|
|
41
|
+
$[5] = controlledValue;
|
|
42
|
+
$[6] = defaultValue;
|
|
43
|
+
$[7] = loadingCounters;
|
|
44
|
+
$[8] = onChange;
|
|
45
|
+
$[9] = props;
|
|
46
|
+
$[10] = t1;
|
|
47
|
+
} else {
|
|
48
|
+
ariaLabel = $[1];
|
|
49
|
+
ariaLabelledBy = $[2];
|
|
50
|
+
children = $[3];
|
|
51
|
+
className = $[4];
|
|
52
|
+
controlledValue = $[5];
|
|
53
|
+
defaultValue = $[6];
|
|
54
|
+
loadingCounters = $[7];
|
|
55
|
+
onChange = $[8];
|
|
56
|
+
props = $[9];
|
|
57
|
+
t1 = $[10];
|
|
58
|
+
}
|
|
59
|
+
const activationMode = t1 === void 0 ? "automatic" : t1;
|
|
23
60
|
const [iconsVisible, setIconsVisible] = useState(true);
|
|
24
61
|
const wrapperRef = useRef(null);
|
|
25
62
|
const listRef = useRef(null);
|
|
26
63
|
const parentId = useId$1(props.id);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
64
|
+
let panelValues;
|
|
65
|
+
let selectedFromProps;
|
|
66
|
+
let t2;
|
|
67
|
+
let tabPanels;
|
|
68
|
+
let tabValues;
|
|
69
|
+
let tabs;
|
|
70
|
+
if ($[11] !== children) {
|
|
71
|
+
const indices = {
|
|
72
|
+
tab: 0,
|
|
73
|
+
panel: 0
|
|
74
|
+
};
|
|
30
75
|
const childrenWithProps = Children.map(children, (child) => {
|
|
31
76
|
if (/*#__PURE__*/ isValidElement(child) && (child.type === Tab || isSlot(child, Tab))) {
|
|
32
77
|
var _child$props$value;
|
|
33
|
-
const value = (_child$props$value = child.props.value) !== null && _child$props$value !== void 0 ? _child$props$value : `${
|
|
34
|
-
|
|
78
|
+
const value = (_child$props$value = child.props.value) !== null && _child$props$value !== void 0 ? _child$props$value : `${indices.tab}`;
|
|
79
|
+
indices.tab = indices.tab + 1;
|
|
35
80
|
return /*#__PURE__*/ cloneElement(child, { value });
|
|
36
81
|
}
|
|
37
82
|
if (/*#__PURE__*/ isValidElement(child) && (child.type === Panel || isSlot(child, Panel))) {
|
|
38
83
|
var _child$props$value2;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
return /*#__PURE__*/ cloneElement(child, { value });
|
|
84
|
+
const value_0 = (_child$props$value2 = child.props.value) !== null && _child$props$value2 !== void 0 ? _child$props$value2 : `${indices.panel}`;
|
|
85
|
+
indices.panel = indices.panel + 1;
|
|
86
|
+
return /*#__PURE__*/ cloneElement(child, { value: value_0 });
|
|
42
87
|
}
|
|
43
88
|
return child;
|
|
44
89
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
tabPanels.push(child);
|
|
90
|
+
tabs = [];
|
|
91
|
+
tabPanels = [];
|
|
92
|
+
tabValues = [];
|
|
93
|
+
panelValues = [];
|
|
94
|
+
for (const child_0 of Children.toArray(childrenWithProps)) {
|
|
95
|
+
if (!/*#__PURE__*/ isValidElement(child_0)) continue;
|
|
96
|
+
if (child_0.type === Tab || isSlot(child_0, Tab)) {
|
|
97
|
+
const value_1 = child_0.props.value;
|
|
98
|
+
if (value_1 !== void 0) tabValues.push(value_1);
|
|
99
|
+
const ariaSelected = child_0.props["aria-selected"];
|
|
100
|
+
if (ariaSelected === true || ariaSelected === "true") selectedFromProps = value_1;
|
|
101
|
+
tabs.push(child_0);
|
|
102
|
+
} else if (child_0.type === Panel || isSlot(child_0, Panel)) {
|
|
103
|
+
const value_2 = child_0.props.value;
|
|
104
|
+
if (value_2 !== void 0) panelValues.push(value_2);
|
|
105
|
+
tabPanels.push(child_0);
|
|
62
106
|
}
|
|
63
107
|
}
|
|
64
|
-
|
|
108
|
+
t2 = tabs.some(_temp);
|
|
109
|
+
$[11] = children;
|
|
110
|
+
$[12] = panelValues;
|
|
111
|
+
$[13] = selectedFromProps;
|
|
112
|
+
$[14] = t2;
|
|
113
|
+
$[15] = tabPanels;
|
|
114
|
+
$[16] = tabValues;
|
|
115
|
+
$[17] = tabs;
|
|
116
|
+
} else {
|
|
117
|
+
panelValues = $[12];
|
|
118
|
+
selectedFromProps = $[13];
|
|
119
|
+
t2 = $[14];
|
|
120
|
+
tabPanels = $[15];
|
|
121
|
+
tabValues = $[16];
|
|
122
|
+
tabs = $[17];
|
|
123
|
+
}
|
|
124
|
+
const tabsHaveIcons = t2;
|
|
125
|
+
let t3;
|
|
126
|
+
if ($[18] !== panelValues || $[19] !== selectedFromProps || $[20] !== tabPanels || $[21] !== tabValues || $[22] !== tabs || $[23] !== tabsHaveIcons) {
|
|
127
|
+
t3 = [
|
|
65
128
|
tabs,
|
|
66
129
|
tabPanels,
|
|
67
|
-
|
|
130
|
+
tabsHaveIcons,
|
|
68
131
|
selectedFromProps,
|
|
69
132
|
tabValues,
|
|
70
133
|
panelValues
|
|
71
134
|
];
|
|
72
|
-
|
|
135
|
+
$[18] = panelValues;
|
|
136
|
+
$[19] = selectedFromProps;
|
|
137
|
+
$[20] = tabPanels;
|
|
138
|
+
$[21] = tabValues;
|
|
139
|
+
$[22] = tabs;
|
|
140
|
+
$[23] = tabsHaveIcons;
|
|
141
|
+
$[24] = t3;
|
|
142
|
+
} else t3 = $[24];
|
|
143
|
+
const [tabs_0, tabPanels_0, tabsHaveIcons_0, selectedFromProps_0, tabValues_0, panelValues_0] = t3;
|
|
73
144
|
const isControlled = controlledValue !== void 0;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
145
|
+
let t4;
|
|
146
|
+
if ($[25] !== defaultValue || $[26] !== selectedFromProps_0) {
|
|
147
|
+
t4 = () => {
|
|
148
|
+
var _ref;
|
|
149
|
+
return (_ref = defaultValue !== null && defaultValue !== void 0 ? defaultValue : selectedFromProps_0) !== null && _ref !== void 0 ? _ref : "0";
|
|
150
|
+
};
|
|
151
|
+
$[25] = defaultValue;
|
|
152
|
+
$[26] = selectedFromProps_0;
|
|
153
|
+
$[27] = t4;
|
|
154
|
+
} else t4 = $[27];
|
|
155
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(t4);
|
|
156
|
+
const [prevSelectedFromProps, setPrevSelectedFromProps] = useState(selectedFromProps_0);
|
|
157
|
+
if (!isControlled && selectedFromProps_0 !== prevSelectedFromProps) {
|
|
158
|
+
setPrevSelectedFromProps(selectedFromProps_0);
|
|
159
|
+
if (selectedFromProps_0 !== void 0 && selectedFromProps_0 !== uncontrolledValue) setUncontrolledValue(selectedFromProps_0);
|
|
82
160
|
}
|
|
83
161
|
const selectedValue = isControlled ? controlledValue : uncontrolledValue;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
162
|
+
let t5;
|
|
163
|
+
if ($[28] !== selectedValue || $[29] !== tabValues_0) {
|
|
164
|
+
var _tabValues_0$;
|
|
165
|
+
t5 = tabValues_0.includes(selectedValue) ? selectedValue : (_tabValues_0$ = tabValues_0[0]) !== null && _tabValues_0$ !== void 0 ? _tabValues_0$ : selectedValue;
|
|
166
|
+
$[28] = selectedValue;
|
|
167
|
+
$[29] = tabValues_0;
|
|
168
|
+
$[30] = t5;
|
|
169
|
+
} else t5 = $[30];
|
|
170
|
+
const effectiveValue = t5;
|
|
171
|
+
let t6;
|
|
172
|
+
if ($[31] !== isControlled || $[32] !== onChange) {
|
|
173
|
+
t6 = (value_3) => {
|
|
174
|
+
var _onChange;
|
|
175
|
+
if (!isControlled) setUncontrolledValue(value_3);
|
|
176
|
+
(_onChange = onChange) === null || _onChange === void 0 || _onChange({ value: value_3 });
|
|
177
|
+
};
|
|
178
|
+
$[31] = isControlled;
|
|
179
|
+
$[32] = onChange;
|
|
180
|
+
$[33] = t6;
|
|
181
|
+
} else t6 = $[33];
|
|
182
|
+
const handleValueChange = t6;
|
|
183
|
+
let t7;
|
|
184
|
+
if ($[34] !== ariaLabel || $[35] !== ariaLabelledBy) {
|
|
185
|
+
t7 = {
|
|
186
|
+
"aria-label": ariaLabel,
|
|
187
|
+
"aria-labelledby": ariaLabelledBy,
|
|
188
|
+
ref: listRef
|
|
189
|
+
};
|
|
190
|
+
$[34] = ariaLabel;
|
|
191
|
+
$[35] = ariaLabelledBy;
|
|
192
|
+
$[36] = t7;
|
|
193
|
+
} else t7 = $[36];
|
|
194
|
+
const { tabListProps } = useTabList(t7);
|
|
195
|
+
let t8;
|
|
196
|
+
if ($[37] !== iconsVisible || $[38] !== loadingCounters) {
|
|
197
|
+
t8 = {
|
|
198
|
+
iconsVisible,
|
|
199
|
+
loadingCounters
|
|
200
|
+
};
|
|
201
|
+
$[37] = iconsVisible;
|
|
202
|
+
$[38] = loadingCounters;
|
|
203
|
+
$[39] = t8;
|
|
204
|
+
} else t8 = $[39];
|
|
205
|
+
const contextValue = t8;
|
|
98
206
|
const iconsVisibleRef = useRef(iconsVisible);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
207
|
+
let t10;
|
|
208
|
+
let t9;
|
|
209
|
+
if ($[40] !== iconsVisible) {
|
|
210
|
+
t9 = () => {
|
|
211
|
+
iconsVisibleRef.current = iconsVisible;
|
|
212
|
+
};
|
|
213
|
+
t10 = [iconsVisible];
|
|
214
|
+
$[40] = iconsVisible;
|
|
215
|
+
$[41] = t10;
|
|
216
|
+
$[42] = t9;
|
|
217
|
+
} else {
|
|
218
|
+
t10 = $[41];
|
|
219
|
+
t9 = $[42];
|
|
220
|
+
}
|
|
221
|
+
useIsomorphicLayoutEffect(t9, t10);
|
|
102
222
|
const listWidthRef = useRef(0);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
223
|
+
let t11;
|
|
224
|
+
if ($[43] !== tabsHaveIcons_0) {
|
|
225
|
+
t11 = (entries) => {
|
|
226
|
+
if (!tabsHaveIcons_0) return;
|
|
227
|
+
if (!iconsVisibleRef.current) return;
|
|
228
|
+
listWidthRef.current = entries[0].contentRect.width;
|
|
229
|
+
};
|
|
230
|
+
$[43] = tabsHaveIcons_0;
|
|
231
|
+
$[44] = t11;
|
|
232
|
+
} else t11 = $[44];
|
|
233
|
+
let t12;
|
|
234
|
+
if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
|
|
235
|
+
t12 = [];
|
|
236
|
+
$[45] = t12;
|
|
237
|
+
} else t12 = $[45];
|
|
238
|
+
useResizeObserver(t11, listRef, t12);
|
|
239
|
+
let t13;
|
|
240
|
+
if ($[46] !== tabsHaveIcons_0) {
|
|
241
|
+
t13 = (resizeObserverEntries) => {
|
|
242
|
+
if (!tabsHaveIcons_0) return;
|
|
243
|
+
const wrapperWidth = resizeObserverEntries[0].contentRect.width;
|
|
244
|
+
setIconsVisible(wrapperWidth > listWidthRef.current);
|
|
245
|
+
};
|
|
246
|
+
$[46] = tabsHaveIcons_0;
|
|
247
|
+
$[47] = t13;
|
|
248
|
+
} else t13 = $[47];
|
|
249
|
+
let t14;
|
|
250
|
+
if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
|
|
251
|
+
t14 = [];
|
|
252
|
+
$[48] = t14;
|
|
253
|
+
} else t14 = $[48];
|
|
254
|
+
useResizeObserver(t13, wrapperRef, t14);
|
|
113
255
|
{
|
|
114
|
-
const selectedTabs =
|
|
115
|
-
const ariaSelected = /*#__PURE__*/ React.isValidElement(tab) && tab.props["aria-selected"];
|
|
116
|
-
return ariaSelected === true || ariaSelected === "true";
|
|
117
|
-
});
|
|
256
|
+
const selectedTabs = tabs_0.filter(_temp2);
|
|
118
257
|
!(selectedTabs.length <= 1) && invariant(false, "Only one tab can be selected at a time.");
|
|
119
|
-
|
|
120
|
-
const duplicateTabValue =
|
|
258
|
+
tabs_0.length !== tabPanels_0.length && invariant(false, `The number of tabs and panels must be equal. Counted ${tabs_0.length} tabs and ${tabPanels_0.length} panels.`);
|
|
259
|
+
const duplicateTabValue = tabValues_0.find((value_4, index) => tabValues_0.indexOf(value_4) !== index);
|
|
121
260
|
duplicateTabValue !== void 0 && invariant(false, `Every tab must have a unique \`value\`. Found duplicate "${duplicateTabValue}".`);
|
|
122
|
-
const duplicatePanelValue =
|
|
261
|
+
const duplicatePanelValue = panelValues_0.find((value_5, index_0) => panelValues_0.indexOf(value_5) !== index_0);
|
|
123
262
|
duplicatePanelValue !== void 0 && invariant(false, `Every panel must have a unique \`value\`. Found duplicate "${duplicatePanelValue}".`);
|
|
124
|
-
const unmatchedTabValue =
|
|
263
|
+
const unmatchedTabValue = tabValues_0.find((value_6) => !panelValues_0.includes(value_6));
|
|
125
264
|
unmatchedTabValue !== void 0 && invariant(false, `Tab with \`value\` "${unmatchedTabValue}" has no matching panel. Give a \`UnderlinePanels.Panel\` the same \`value\`.`);
|
|
126
265
|
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.");
|
|
127
266
|
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.");
|
|
128
267
|
const providedValue = controlledValue !== null && controlledValue !== void 0 ? controlledValue : defaultValue;
|
|
129
|
-
warning(providedValue !== void 0 &&
|
|
268
|
+
warning(providedValue !== void 0 && tabValues_0.length > 0 && !tabValues_0.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\`.`);
|
|
130
269
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
270
|
+
let t15;
|
|
271
|
+
if ($[49] !== handleValueChange) {
|
|
272
|
+
t15 = (t16) => {
|
|
273
|
+
const { value: value_7 } = t16;
|
|
274
|
+
return handleValueChange(value_7);
|
|
275
|
+
};
|
|
276
|
+
$[49] = handleValueChange;
|
|
277
|
+
$[50] = t15;
|
|
278
|
+
} else t15 = $[50];
|
|
279
|
+
let t16;
|
|
280
|
+
if ($[51] !== className) {
|
|
281
|
+
t16 = clsx(className, UnderlinePanels_module_css_default.StyledUnderlineWrapper);
|
|
282
|
+
$[51] = className;
|
|
283
|
+
$[52] = t16;
|
|
284
|
+
} else t16 = $[52];
|
|
285
|
+
const t17 = tabListProps["aria-label"];
|
|
286
|
+
const t18 = tabListProps["aria-labelledby"];
|
|
287
|
+
const t19 = tabListProps["aria-orientation"];
|
|
288
|
+
let t20;
|
|
289
|
+
if ($[53] !== t17 || $[54] !== t18 || $[55] !== t19 || $[56] !== tabListProps.onKeyDown || $[57] !== tabListProps.role || $[58] !== tabs_0) {
|
|
290
|
+
t20 = /* @__PURE__ */ jsx(UnderlineItemList, {
|
|
291
|
+
ref: listRef,
|
|
292
|
+
role: tabListProps.role,
|
|
293
|
+
"aria-label": t17,
|
|
294
|
+
"aria-labelledby": t18,
|
|
295
|
+
"aria-orientation": t19,
|
|
296
|
+
onKeyDown: tabListProps.onKeyDown,
|
|
297
|
+
children: tabs_0
|
|
298
|
+
});
|
|
299
|
+
$[53] = t17;
|
|
300
|
+
$[54] = t18;
|
|
301
|
+
$[55] = t19;
|
|
302
|
+
$[56] = tabListProps.onKeyDown;
|
|
303
|
+
$[57] = tabListProps.role;
|
|
304
|
+
$[58] = tabs_0;
|
|
305
|
+
$[59] = t20;
|
|
306
|
+
} else t20 = $[59];
|
|
307
|
+
let t21;
|
|
308
|
+
if ($[60] !== iconsVisible || $[61] !== props || $[62] !== t16 || $[63] !== t20) {
|
|
309
|
+
t21 = /* @__PURE__ */ jsx(UnderlineWrapper, {
|
|
310
|
+
ref: wrapperRef,
|
|
311
|
+
"data-icons-visible": iconsVisible,
|
|
312
|
+
className: t16,
|
|
313
|
+
...props,
|
|
314
|
+
children: t20
|
|
315
|
+
});
|
|
316
|
+
$[60] = iconsVisible;
|
|
317
|
+
$[61] = props;
|
|
318
|
+
$[62] = t16;
|
|
319
|
+
$[63] = t20;
|
|
320
|
+
$[64] = t21;
|
|
321
|
+
} else t21 = $[64];
|
|
322
|
+
let t22;
|
|
323
|
+
if ($[65] !== activationMode || $[66] !== effectiveValue || $[67] !== parentId || $[68] !== t15 || $[69] !== t21 || $[70] !== tabPanels_0) {
|
|
324
|
+
t22 = /* @__PURE__ */ jsxs(Tabs, {
|
|
134
325
|
id: parentId,
|
|
135
326
|
value: effectiveValue,
|
|
136
327
|
activationMode,
|
|
137
|
-
onValueChange:
|
|
138
|
-
children: [
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
})
|
|
154
|
-
|
|
328
|
+
onValueChange: t15,
|
|
329
|
+
children: [t21, tabPanels_0]
|
|
330
|
+
});
|
|
331
|
+
$[65] = activationMode;
|
|
332
|
+
$[66] = effectiveValue;
|
|
333
|
+
$[67] = parentId;
|
|
334
|
+
$[68] = t15;
|
|
335
|
+
$[69] = t21;
|
|
336
|
+
$[70] = tabPanels_0;
|
|
337
|
+
$[71] = t22;
|
|
338
|
+
} else t22 = $[71];
|
|
339
|
+
let t23;
|
|
340
|
+
if ($[72] !== contextValue || $[73] !== t22) {
|
|
341
|
+
t23 = /* @__PURE__ */ jsx(UnderlinePanelsContext.Provider, {
|
|
342
|
+
value: contextValue,
|
|
343
|
+
children: t22
|
|
344
|
+
});
|
|
345
|
+
$[72] = contextValue;
|
|
346
|
+
$[73] = t22;
|
|
347
|
+
$[74] = t23;
|
|
348
|
+
} else t23 = $[74];
|
|
349
|
+
return t23;
|
|
155
350
|
};
|
|
156
|
-
const TabImpl = (
|
|
351
|
+
const TabImpl = (t0) => {
|
|
352
|
+
const $ = c(24);
|
|
353
|
+
let itemProps;
|
|
354
|
+
let onSelect;
|
|
355
|
+
let value;
|
|
356
|
+
if ($[0] !== t0) {
|
|
357
|
+
({onSelect, value, ...itemProps} = t0);
|
|
358
|
+
$[0] = t0;
|
|
359
|
+
$[1] = itemProps;
|
|
360
|
+
$[2] = onSelect;
|
|
361
|
+
$[3] = value;
|
|
362
|
+
} else {
|
|
363
|
+
itemProps = $[1];
|
|
364
|
+
onSelect = $[2];
|
|
365
|
+
value = $[3];
|
|
366
|
+
}
|
|
157
367
|
const { loadingCounters } = useContext(UnderlinePanelsContext);
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
368
|
+
const t1 = value !== null && value !== void 0 ? value : "";
|
|
369
|
+
let t2;
|
|
370
|
+
if ($[4] !== t1) {
|
|
371
|
+
t2 = { value: t1 };
|
|
372
|
+
$[4] = t1;
|
|
373
|
+
$[5] = t2;
|
|
374
|
+
} else t2 = $[5];
|
|
375
|
+
const { tabProps } = useTab(t2);
|
|
376
|
+
let restTabProps;
|
|
377
|
+
let tabOnFocus;
|
|
378
|
+
let tabOnKeyDown;
|
|
379
|
+
let tabOnMouseDown;
|
|
380
|
+
if ($[6] !== tabProps) {
|
|
381
|
+
({onKeyDown: tabOnKeyDown, onMouseDown: tabOnMouseDown, onFocus: tabOnFocus, ...restTabProps} = tabProps);
|
|
382
|
+
$[6] = tabProps;
|
|
383
|
+
$[7] = restTabProps;
|
|
384
|
+
$[8] = tabOnFocus;
|
|
385
|
+
$[9] = tabOnKeyDown;
|
|
386
|
+
$[10] = tabOnMouseDown;
|
|
387
|
+
} else {
|
|
388
|
+
restTabProps = $[7];
|
|
389
|
+
tabOnFocus = $[8];
|
|
390
|
+
tabOnKeyDown = $[9];
|
|
391
|
+
tabOnMouseDown = $[10];
|
|
392
|
+
}
|
|
393
|
+
let t3;
|
|
394
|
+
if ($[11] !== onSelect) {
|
|
395
|
+
t3 = (event) => {
|
|
166
396
|
if (!event.defaultPrevented && typeof onSelect === "function") onSelect(event);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
397
|
+
};
|
|
398
|
+
$[11] = onSelect;
|
|
399
|
+
$[12] = t3;
|
|
400
|
+
} else t3 = $[12];
|
|
401
|
+
let t4;
|
|
402
|
+
if ($[13] !== onSelect || $[14] !== tabOnKeyDown) {
|
|
403
|
+
t4 = (event_0) => {
|
|
404
|
+
var _tabOnKeyDown;
|
|
405
|
+
(_tabOnKeyDown = tabOnKeyDown) === null || _tabOnKeyDown === void 0 || _tabOnKeyDown(event_0);
|
|
406
|
+
if ((event_0.key === " " || event_0.key === "Enter") && !event_0.defaultPrevented && typeof onSelect === "function") onSelect(event_0);
|
|
407
|
+
};
|
|
408
|
+
$[13] = onSelect;
|
|
409
|
+
$[14] = tabOnKeyDown;
|
|
410
|
+
$[15] = t4;
|
|
411
|
+
} else t4 = $[15];
|
|
412
|
+
let t5;
|
|
413
|
+
if ($[16] !== itemProps || $[17] !== loadingCounters || $[18] !== restTabProps || $[19] !== t3 || $[20] !== t4 || $[21] !== tabOnFocus || $[22] !== tabOnMouseDown) {
|
|
414
|
+
t5 = /* @__PURE__ */ jsx(UnderlineItem, {
|
|
415
|
+
as: "button",
|
|
416
|
+
...itemProps,
|
|
417
|
+
...restTabProps,
|
|
418
|
+
type: "button",
|
|
419
|
+
onClick: t3,
|
|
420
|
+
onKeyDown: t4,
|
|
421
|
+
onMouseDown: tabOnMouseDown,
|
|
422
|
+
onFocus: tabOnFocus,
|
|
423
|
+
loadingCounters
|
|
424
|
+
});
|
|
425
|
+
$[16] = itemProps;
|
|
426
|
+
$[17] = loadingCounters;
|
|
427
|
+
$[18] = restTabProps;
|
|
428
|
+
$[19] = t3;
|
|
429
|
+
$[20] = t4;
|
|
430
|
+
$[21] = tabOnFocus;
|
|
431
|
+
$[22] = tabOnMouseDown;
|
|
432
|
+
$[23] = t5;
|
|
433
|
+
} else t5 = $[23];
|
|
434
|
+
return t5;
|
|
176
435
|
};
|
|
177
436
|
TabImpl.displayName = "UnderlinePanels.Tab";
|
|
178
437
|
const Tab = /*#__PURE__*/ React.memo(TabImpl);
|
|
179
438
|
Tab.displayName = "UnderlinePanels.Tab";
|
|
180
|
-
const PanelImpl = (
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
439
|
+
const PanelImpl = (t0) => {
|
|
440
|
+
const $ = c(10);
|
|
441
|
+
let children;
|
|
442
|
+
let panelRest;
|
|
443
|
+
let value;
|
|
444
|
+
if ($[0] !== t0) {
|
|
445
|
+
({children, value, ...panelRest} = t0);
|
|
446
|
+
$[0] = t0;
|
|
447
|
+
$[1] = children;
|
|
448
|
+
$[2] = panelRest;
|
|
449
|
+
$[3] = value;
|
|
450
|
+
} else {
|
|
451
|
+
children = $[1];
|
|
452
|
+
panelRest = $[2];
|
|
453
|
+
value = $[3];
|
|
454
|
+
}
|
|
455
|
+
const t1 = value !== null && value !== void 0 ? value : "";
|
|
456
|
+
let t2;
|
|
457
|
+
if ($[4] !== t1) {
|
|
458
|
+
t2 = { value: t1 };
|
|
459
|
+
$[4] = t1;
|
|
460
|
+
$[5] = t2;
|
|
461
|
+
} else t2 = $[5];
|
|
462
|
+
const { tabPanelProps } = useTabPanel(t2);
|
|
463
|
+
let t3;
|
|
464
|
+
if ($[6] !== children || $[7] !== panelRest || $[8] !== tabPanelProps) {
|
|
465
|
+
t3 = /* @__PURE__ */ jsx("div", {
|
|
466
|
+
...panelRest,
|
|
467
|
+
...tabPanelProps,
|
|
468
|
+
children
|
|
469
|
+
});
|
|
470
|
+
$[6] = children;
|
|
471
|
+
$[7] = panelRest;
|
|
472
|
+
$[8] = tabPanelProps;
|
|
473
|
+
$[9] = t3;
|
|
474
|
+
} else t3 = $[9];
|
|
475
|
+
return t3;
|
|
187
476
|
};
|
|
188
477
|
PanelImpl.displayName = "UnderlinePanels.Panel";
|
|
189
478
|
const Panel = PanelImpl;
|
|
@@ -194,5 +483,12 @@ var UnderlinePanels_default = Object.assign(UnderlinePanels, {
|
|
|
194
483
|
});
|
|
195
484
|
Tab.__SLOT__ = Symbol("UnderlinePanels.Tab");
|
|
196
485
|
Panel.__SLOT__ = Symbol("UnderlinePanels.Panel");
|
|
486
|
+
function _temp(tab) {
|
|
487
|
+
return /*#__PURE__*/ React.isValidElement(tab) && tab.props.icon;
|
|
488
|
+
}
|
|
489
|
+
function _temp2(tab_0) {
|
|
490
|
+
const ariaSelected_0 = /*#__PURE__*/ React.isValidElement(tab_0) && tab_0.props["aria-selected"];
|
|
491
|
+
return ariaSelected_0 === true || ariaSelected_0 === "true";
|
|
492
|
+
}
|
|
197
493
|
//#endregion
|
|
198
494
|
export { UnderlinePanels_default as default };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c } from "../utils/react-compiler-runtime.js";
|
|
1
2
|
import { warning } from "../utils/warning.js";
|
|
2
3
|
import React from "react";
|
|
3
4
|
//#region src/hooks/useControllableState.ts
|
|
@@ -11,27 +12,77 @@ import React from "react";
|
|
|
11
12
|
* Note: This hook will warn if a component is switching from controlled to
|
|
12
13
|
* uncontrolled, or vice-versa.
|
|
13
14
|
*/
|
|
14
|
-
function useControllableState(
|
|
15
|
+
function useControllableState(t0) {
|
|
16
|
+
const $ = c(16);
|
|
17
|
+
const { name: t1, defaultValue, value, onChange } = t0;
|
|
18
|
+
const name = t1 === void 0 ? "custom" : t1;
|
|
15
19
|
const [state, internalSetState] = React.useState(value !== null && value !== void 0 ? value : defaultValue);
|
|
16
|
-
const controlled = React.
|
|
20
|
+
const [controlled] = React.useState(value !== void 0);
|
|
17
21
|
const stableOnChange = React.useRef(onChange);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
let t2;
|
|
23
|
+
if ($[0] !== onChange) {
|
|
24
|
+
t2 = () => {
|
|
25
|
+
stableOnChange.current = onChange;
|
|
26
|
+
};
|
|
27
|
+
$[0] = onChange;
|
|
28
|
+
$[1] = t2;
|
|
29
|
+
} else t2 = $[1];
|
|
30
|
+
React.useEffect(t2);
|
|
31
|
+
let t3;
|
|
32
|
+
if ($[2] !== controlled || $[3] !== state) {
|
|
33
|
+
t3 = (stateOrUpdater) => {
|
|
34
|
+
var _stableOnChange$curre;
|
|
35
|
+
const value_0 = typeof stateOrUpdater === "function" ? stateOrUpdater(state) : stateOrUpdater;
|
|
36
|
+
if (controlled === false) internalSetState(value_0);
|
|
37
|
+
(_stableOnChange$curre = stableOnChange.current) === null || _stableOnChange$curre === void 0 || _stableOnChange$curre.call(stableOnChange, value_0);
|
|
38
|
+
};
|
|
39
|
+
$[2] = controlled;
|
|
40
|
+
$[3] = state;
|
|
41
|
+
$[4] = t3;
|
|
42
|
+
} else t3 = $[4];
|
|
43
|
+
const setState = t3;
|
|
44
|
+
let t4;
|
|
45
|
+
let t5;
|
|
46
|
+
if ($[5] !== controlled || $[6] !== name || $[7] !== value) {
|
|
47
|
+
t4 = () => {
|
|
48
|
+
const controlledValue = value !== void 0;
|
|
49
|
+
if (controlled === false && controlledValue) warning(true, "A component is changing an uncontrolled %s component to be controlled. This is likely caused by the value changing to a defined value from undefined. Decide between using a controlled or uncontrolled value for the lifetime of the component. More info: https://reactjs.org/link/controlled-components", name);
|
|
50
|
+
if (controlled === true && !controlledValue) warning(true, "A component is changing a controlled %s component to be uncontrolled. This is likely caused by the value changing to an undefined value from a defined one. Decide between using a controlled or uncontrolled value for the lifetime of the component. More info: https://reactjs.org/link/controlled-components", name);
|
|
51
|
+
};
|
|
52
|
+
t5 = [
|
|
53
|
+
name,
|
|
54
|
+
value,
|
|
55
|
+
controlled
|
|
56
|
+
];
|
|
57
|
+
$[5] = controlled;
|
|
58
|
+
$[6] = name;
|
|
59
|
+
$[7] = value;
|
|
60
|
+
$[8] = t4;
|
|
61
|
+
$[9] = t5;
|
|
62
|
+
} else {
|
|
63
|
+
t4 = $[8];
|
|
64
|
+
t5 = $[9];
|
|
65
|
+
}
|
|
66
|
+
React.useEffect(t4, t5);
|
|
67
|
+
if (controlled === true) {
|
|
68
|
+
const t6 = value;
|
|
69
|
+
let t7;
|
|
70
|
+
if ($[10] !== setState || $[11] !== t6) {
|
|
71
|
+
t7 = [t6, setState];
|
|
72
|
+
$[10] = setState;
|
|
73
|
+
$[11] = t6;
|
|
74
|
+
$[12] = t7;
|
|
75
|
+
} else t7 = $[12];
|
|
76
|
+
return t7;
|
|
77
|
+
}
|
|
78
|
+
let t6;
|
|
79
|
+
if ($[13] !== setState || $[14] !== state) {
|
|
80
|
+
t6 = [state, setState];
|
|
81
|
+
$[13] = setState;
|
|
82
|
+
$[14] = state;
|
|
83
|
+
$[15] = t6;
|
|
84
|
+
} else t6 = $[15];
|
|
85
|
+
return t6;
|
|
35
86
|
}
|
|
36
87
|
//#endregion
|
|
37
88
|
export { useControllableState };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c } from "../utils/react-compiler-runtime.js";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
2
3
|
//#region src/hooks/useOnOutsideClick.tsx
|
|
3
4
|
const stopPropagation = true;
|
|
4
5
|
/**
|
|
@@ -18,27 +19,53 @@ function deregister(id) {
|
|
|
18
19
|
delete registry[id];
|
|
19
20
|
}
|
|
20
21
|
let handlerId = 0;
|
|
21
|
-
const useOnOutsideClick = (
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
register(id, handler);
|
|
37
|
-
return () => {
|
|
38
|
-
deregister(id);
|
|
39
|
-
if (Object.keys(registry).length === 0) document.removeEventListener("mousedown", handleClick, { capture: true });
|
|
22
|
+
const useOnOutsideClick = (t0) => {
|
|
23
|
+
const $ = c(8);
|
|
24
|
+
const { containerRef, ignoreClickRefs, onClickOutside } = t0;
|
|
25
|
+
const [id_0] = useState(_temp);
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[0] !== containerRef || $[1] !== ignoreClickRefs || $[2] !== onClickOutside) {
|
|
28
|
+
t1 = (event) => {
|
|
29
|
+
var _containerRef$current;
|
|
30
|
+
if (event instanceof MouseEvent && event.button > 0) return stopPropagation;
|
|
31
|
+
if ((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(event.target)) return stopPropagation;
|
|
32
|
+
if (ignoreClickRefs && ignoreClickRefs.some((t2) => {
|
|
33
|
+
const { current } = t2;
|
|
34
|
+
return current === null || current === void 0 ? void 0 : current.contains(event.target);
|
|
35
|
+
})) return stopPropagation;
|
|
36
|
+
onClickOutside(event);
|
|
40
37
|
};
|
|
41
|
-
|
|
38
|
+
$[0] = containerRef;
|
|
39
|
+
$[1] = ignoreClickRefs;
|
|
40
|
+
$[2] = onClickOutside;
|
|
41
|
+
$[3] = t1;
|
|
42
|
+
} else t1 = $[3];
|
|
43
|
+
const handler = t1;
|
|
44
|
+
let t2;
|
|
45
|
+
let t3;
|
|
46
|
+
if ($[4] !== handler || $[5] !== id_0) {
|
|
47
|
+
t2 = () => {
|
|
48
|
+
if (Object.keys(registry).length === 0) document.addEventListener("mousedown", handleClick, { capture: true });
|
|
49
|
+
register(id_0, handler);
|
|
50
|
+
return () => {
|
|
51
|
+
deregister(id_0);
|
|
52
|
+
if (Object.keys(registry).length === 0) document.removeEventListener("mousedown", handleClick, { capture: true });
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
t3 = [id_0, handler];
|
|
56
|
+
$[4] = handler;
|
|
57
|
+
$[5] = id_0;
|
|
58
|
+
$[6] = t2;
|
|
59
|
+
$[7] = t3;
|
|
60
|
+
} else {
|
|
61
|
+
t2 = $[6];
|
|
62
|
+
t3 = $[7];
|
|
63
|
+
}
|
|
64
|
+
useEffect(t2, t3);
|
|
42
65
|
};
|
|
66
|
+
function _temp() {
|
|
67
|
+
handlerId = handlerId + 1;
|
|
68
|
+
return handlerId;
|
|
69
|
+
}
|
|
43
70
|
//#endregion
|
|
44
71
|
export { useOnOutsideClick };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c } from "../utils/react-compiler-runtime.js";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
2
3
|
//#region src/hooks/useSafeTimeout.ts
|
|
3
4
|
/**
|
|
4
5
|
* Safely call `setTimeout` and `clearTimeout` within a component.
|
|
@@ -6,25 +7,59 @@ import { useCallback, useEffect, useRef } from "react";
|
|
|
6
7
|
* This hook ensures that all timeouts are cleared when the component unmounts.
|
|
7
8
|
*/
|
|
8
9
|
function useSafeTimeout() {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
const $ = c(6);
|
|
11
|
+
let t0;
|
|
12
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
13
|
+
t0 = /* @__PURE__ */ new Set();
|
|
14
|
+
$[0] = t0;
|
|
15
|
+
} else t0 = $[0];
|
|
16
|
+
const timers = useRef(t0);
|
|
17
|
+
let t1;
|
|
18
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
19
|
+
t1 = (handler, timeout, ...t2) => {
|
|
20
|
+
const args = t2;
|
|
21
|
+
const id = window.setTimeout(handler, timeout, ...args);
|
|
22
|
+
timers.current.add(id);
|
|
23
|
+
return id;
|
|
22
24
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
$[1] = t1;
|
|
26
|
+
} else t1 = $[1];
|
|
27
|
+
const safeSetTimeout = t1;
|
|
28
|
+
let t2;
|
|
29
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
30
|
+
t2 = (id_0) => {
|
|
31
|
+
clearTimeout(id_0);
|
|
32
|
+
timers.current.delete(id_0);
|
|
33
|
+
};
|
|
34
|
+
$[2] = t2;
|
|
35
|
+
} else t2 = $[2];
|
|
36
|
+
const safeClearTimeout = t2;
|
|
37
|
+
let t3;
|
|
38
|
+
let t4;
|
|
39
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
40
|
+
t3 = () => {
|
|
41
|
+
const timerSet = timers.current;
|
|
42
|
+
return () => {
|
|
43
|
+
for (const id_1 of timerSet) clearTimeout(id_1);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
t4 = [];
|
|
47
|
+
$[3] = t3;
|
|
48
|
+
$[4] = t4;
|
|
49
|
+
} else {
|
|
50
|
+
t3 = $[3];
|
|
51
|
+
t4 = $[4];
|
|
52
|
+
}
|
|
53
|
+
useEffect(t3, t4);
|
|
54
|
+
let t5;
|
|
55
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
56
|
+
t5 = {
|
|
57
|
+
safeSetTimeout,
|
|
58
|
+
safeClearTimeout
|
|
59
|
+
};
|
|
60
|
+
$[5] = t5;
|
|
61
|
+
} else t5 = $[5];
|
|
62
|
+
return t5;
|
|
28
63
|
}
|
|
29
64
|
//#endregion
|
|
30
65
|
export { useSafeTimeout as default };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
//#region src/internal/hooks/useDevOnlyEffect.ts
|
|
3
3
|
/**
|
|
4
|
-
* Runs an effect only in development.
|
|
5
|
-
*
|
|
6
|
-
* call is dropped by the consumer's `process.env.NODE_ENV` replacement) while
|
|
7
|
-
* centralising the `eslint-disable react-hooks/rules-of-hooks` to one place
|
|
8
|
-
* instead of every call site.
|
|
4
|
+
* Runs an effect only in development. Selecting the implementation at module
|
|
5
|
+
* initialization avoids conditional Hook calls and uses a no-op in production.
|
|
9
6
|
*
|
|
10
7
|
* `exhaustive-deps` is wired up to also check call sites of this hook via
|
|
11
8
|
* `additionalEffectHooks` in `eslint.config.mjs`, so callers get the same
|
|
@@ -14,8 +11,6 @@ import { useEffect } from "react";
|
|
|
14
11
|
* @param effect The effect callback to run in development.
|
|
15
12
|
* @param deps Dependency list, same semantics as `useEffect`.
|
|
16
13
|
*/
|
|
17
|
-
const useDevOnlyEffect =
|
|
18
|
-
useEffect(effect, deps);
|
|
19
|
-
};
|
|
14
|
+
const useDevOnlyEffect = useEffect;
|
|
20
15
|
//#endregion
|
|
21
16
|
export { useDevOnlyEffect };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "38.43.0-rc.
|
|
4
|
+
"version": "38.43.0-rc.d8a41c875",
|
|
5
5
|
"description": "An implementation of GitHub's Primer Design System using React",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -95,14 +95,14 @@
|
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@actions/core": "1.11.1",
|
|
97
97
|
"@babel/cli": "8.0.6",
|
|
98
|
-
"@babel/core": "8.0.
|
|
98
|
+
"@babel/core": "8.0.7",
|
|
99
99
|
"@babel/generator": "8.0.6",
|
|
100
|
-
"@babel/parser": "8.0.
|
|
100
|
+
"@babel/parser": "8.0.7",
|
|
101
101
|
"@babel/plugin-transform-nullish-coalescing-operator": "8.0.1",
|
|
102
102
|
"@babel/plugin-transform-optional-chaining": "8.0.5",
|
|
103
103
|
"@babel/plugin-transform-modules-commonjs": "8.0.1",
|
|
104
104
|
"@babel/preset-react": "8.0.1",
|
|
105
|
-
"@babel/preset-typescript": "8.0.
|
|
105
|
+
"@babel/preset-typescript": "8.0.7",
|
|
106
106
|
"@babel/types": "8.0.6",
|
|
107
107
|
"@figma/code-connect": "1.3.2",
|
|
108
108
|
"@primer/css": "^21.5.1",
|