@primer/react 38.32.0-rc.3ce9543fd → 38.32.0-rc.4bb4bba69

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.
@@ -6,7 +6,6 @@ import { isSlot } from "../../utils/is-slot.js";
6
6
  import { createComponent } from "../../utils/create-component.js";
7
7
  import { UnderlineItem, UnderlineItemList, UnderlineWrapper } from "../../internal/components/UnderlineTabbedInterface.js";
8
8
  import UnderlinePanels_module_css_default from "./UnderlinePanels.module.css.js";
9
- import { c } from "react-compiler-runtime";
10
9
  import { clsx } from "clsx";
11
10
  import { jsx, jsxs } from "react/jsx-runtime";
12
11
  import React, { Children, cloneElement, createContext, isValidElement, useContext, useMemo, useRef, useState } from "react";
@@ -22,7 +21,7 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
22
21
  const wrapperRef = useRef(null);
23
22
  const listRef = useRef(null);
24
23
  const parentId = useId$1(props.id);
25
- const [tabs_0, tabPanels_0, tabsHaveIcons_0] = useMemo(() => {
24
+ const [tabs, tabPanels, tabsHaveIcons] = useMemo(() => {
26
25
  let tabIndex = 0;
27
26
  let panelIndex = 0;
28
27
  const childrenWithProps = Children.map(children, (child) => {
@@ -32,10 +31,10 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
32
31
  });
33
32
  const tabs = [];
34
33
  const tabPanels = [];
35
- for (const child_0 of Children.toArray(childrenWithProps)) {
36
- if (!/*#__PURE__*/ isValidElement(child_0)) continue;
37
- if (child_0.type === Tab || isSlot(child_0, Tab)) tabs.push(child_0);
38
- else if (child_0.type === Panel || isSlot(child_0, Panel)) tabPanels.push(child_0);
34
+ for (const child of Children.toArray(childrenWithProps)) {
35
+ if (!/*#__PURE__*/ isValidElement(child)) continue;
36
+ if (child.type === Tab || isSlot(child, Tab)) tabs.push(child);
37
+ else if (child.type === Panel || isSlot(child, Panel)) tabPanels.push(child);
39
38
  }
40
39
  return [
41
40
  tabs,
@@ -53,20 +52,20 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
53
52
  }, [iconsVisible]);
54
53
  const listWidthRef = useRef(0);
55
54
  useResizeObserver((entries) => {
56
- if (!tabsHaveIcons_0) return;
55
+ if (!tabsHaveIcons) return;
57
56
  if (!iconsVisibleRef.current) return;
58
57
  listWidthRef.current = entries[0].contentRect.width;
59
58
  }, listRef, []);
60
59
  useResizeObserver((resizeObserverEntries) => {
61
- if (!tabsHaveIcons_0) return;
60
+ if (!tabsHaveIcons) return;
62
61
  const wrapperWidth = resizeObserverEntries[0].contentRect.width;
63
62
  setIconsVisible(wrapperWidth > listWidthRef.current);
64
63
  }, wrapperRef, []);
65
- !(tabs_0.filter((tab_0) => {
66
- const ariaSelected = /*#__PURE__*/ React.isValidElement(tab_0) && tab_0.props["aria-selected"];
64
+ !(tabs.filter((tab) => {
65
+ const ariaSelected = /*#__PURE__*/ React.isValidElement(tab) && tab.props["aria-selected"];
67
66
  return ariaSelected === true || ariaSelected === "true";
68
67
  }).length <= 1) && invariant(false, "Only one tab can be selected at a time.");
69
- !(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.`);
68
+ !(tabs.length === tabPanels.length) && invariant(false, `The number of tabs and panels must be equal. Counted ${tabs.length} tabs and ${tabPanels.length} panels.`);
70
69
  return /*#__PURE__*/ jsx(UnderlinePanelsContext.Provider, {
71
70
  value: contextValue,
72
71
  children: /*#__PURE__*/ jsxs(TabContainerComponent, { children: [/*#__PURE__*/ jsx(UnderlineWrapper, {
@@ -80,100 +79,44 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
80
79
  "aria-label": ariaLabel,
81
80
  "aria-labelledby": ariaLabelledBy,
82
81
  role: "tablist",
83
- children: tabs_0
82
+ children: tabs
84
83
  })
85
- }), tabPanels_0] })
84
+ }), tabPanels] })
86
85
  });
87
86
  };
88
87
  UnderlinePanels.displayName = "UnderlinePanels";
89
- const TabImpl = (t0) => {
90
- const $ = c(15);
91
- let ariaSelected;
92
- let onSelect;
93
- let props;
94
- if ($[0] !== t0) {
95
- ({"aria-selected": ariaSelected, onSelect, ...props} = t0);
96
- $[0] = t0;
97
- $[1] = ariaSelected;
98
- $[2] = onSelect;
99
- $[3] = props;
100
- } else {
101
- ariaSelected = $[1];
102
- onSelect = $[2];
103
- props = $[3];
104
- }
88
+ const TabImpl = ({ "aria-selected": ariaSelected, onSelect, ...props }) => {
105
89
  const { loadingCounters } = useContext(UnderlinePanelsContext);
106
- let t1;
107
- if ($[4] !== onSelect) {
108
- t1 = (event) => {
109
- if (!event.defaultPrevented && typeof onSelect === "function") onSelect(event);
110
- };
111
- $[4] = onSelect;
112
- $[5] = t1;
113
- } else t1 = $[5];
114
- const clickHandler = t1;
115
- let t2;
116
- if ($[6] !== onSelect) {
117
- t2 = (event_0) => {
118
- if ((event_0.key === " " || event_0.key === "Enter") && !event_0.defaultPrevented && typeof onSelect === "function") onSelect(event_0);
119
- };
120
- $[6] = onSelect;
121
- $[7] = t2;
122
- } else t2 = $[7];
123
- const keyDownHandler = t2;
124
- const t3 = ariaSelected ? 0 : -1;
125
- let t4;
126
- if ($[8] !== ariaSelected || $[9] !== clickHandler || $[10] !== keyDownHandler || $[11] !== loadingCounters || $[12] !== props || $[13] !== t3) {
127
- t4 = /*#__PURE__*/ jsx(UnderlineItem, {
128
- as: "button",
129
- role: "tab",
130
- tabIndex: t3,
131
- "aria-selected": ariaSelected,
132
- type: "button",
133
- onClick: clickHandler,
134
- onKeyDown: keyDownHandler,
135
- loadingCounters,
136
- ...props
137
- });
138
- $[8] = ariaSelected;
139
- $[9] = clickHandler;
140
- $[10] = keyDownHandler;
141
- $[11] = loadingCounters;
142
- $[12] = props;
143
- $[13] = t3;
144
- $[14] = t4;
145
- } else t4 = $[14];
146
- return t4;
90
+ const clickHandler = React.useCallback((event) => {
91
+ if (!event.defaultPrevented && typeof onSelect === "function") onSelect(event);
92
+ }, [onSelect]);
93
+ const keyDownHandler = React.useCallback((event) => {
94
+ if ((event.key === " " || event.key === "Enter") && !event.defaultPrevented && typeof onSelect === "function") onSelect(event);
95
+ }, [onSelect]);
96
+ return /*#__PURE__*/ jsx(UnderlineItem, {
97
+ as: "button",
98
+ role: "tab",
99
+ tabIndex: ariaSelected ? 0 : -1,
100
+ "aria-selected": ariaSelected,
101
+ type: "button",
102
+ onClick: clickHandler,
103
+ onKeyDown: keyDownHandler,
104
+ loadingCounters,
105
+ ...props
106
+ });
147
107
  };
108
+ TabImpl.displayName = "TabImpl";
148
109
  TabImpl.displayName = "UnderlinePanels.Tab";
149
110
  const Tab = /*#__PURE__*/ React.memo(TabImpl);
150
111
  Tab.displayName = "UnderlinePanels.Tab";
151
- const Panel = (t0) => {
152
- const $ = c(6);
153
- let children;
154
- let rest;
155
- if ($[0] !== t0) {
156
- ({children, ...rest} = t0);
157
- $[0] = t0;
158
- $[1] = children;
159
- $[2] = rest;
160
- } else {
161
- children = $[1];
162
- rest = $[2];
163
- }
164
- let t1;
165
- if ($[3] !== children || $[4] !== rest) {
166
- t1 = /*#__PURE__*/ jsx("div", {
167
- role: "tabpanel",
168
- ...rest,
169
- children
170
- });
171
- $[3] = children;
172
- $[4] = rest;
173
- $[5] = t1;
174
- } else t1 = $[5];
175
- return t1;
112
+ const Panel = ({ children, ...rest }) => {
113
+ return /*#__PURE__*/ jsx("div", {
114
+ role: "tabpanel",
115
+ ...rest,
116
+ children
117
+ });
176
118
  };
119
+ Panel.displayName = "Panel";
177
120
  Panel.displayName = "UnderlinePanels.Panel";
178
121
  var UnderlinePanels_default = Object.assign(UnderlinePanels, {
179
122
  Panel,
@@ -21,9 +21,9 @@ function useControllableState({ name = "custom", defaultValue, value, onChange }
21
21
  if (controlled.current === null) controlled.current = value !== void 0;
22
22
  const setState = React.useCallback((stateOrUpdater) => {
23
23
  var _stableOnChange$curre;
24
- const value_0 = typeof stateOrUpdater === "function" ? stateOrUpdater(state) : stateOrUpdater;
25
- if (controlled.current === false) internalSetState(value_0);
26
- (_stableOnChange$curre = stableOnChange.current) === null || _stableOnChange$curre === void 0 || _stableOnChange$curre.call(stableOnChange, value_0);
24
+ const value = typeof stateOrUpdater === "function" ? stateOrUpdater(state) : stateOrUpdater;
25
+ if (controlled.current === false) internalSetState(value);
26
+ (_stableOnChange$curre = stableOnChange.current) === null || _stableOnChange$curre === void 0 || _stableOnChange$curre.call(stableOnChange, value);
27
27
  }, [state]);
28
28
  React.useEffect(() => {
29
29
  const controlledValue = value !== void 0;
@@ -1,40 +1,44 @@
1
1
  import ValidationAnimationContainer_module_css_default from "./ValidationAnimationContainer.module.css.js";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { jsx } from "react/jsx-runtime";
4
- import { useEffect, useState } from "react";
4
+ import { useState } from "react";
5
5
  //#region src/internal/components/ValidationAnimationContainer.tsx
6
6
  const ValidationAnimationContainer = (t0) => {
7
- const $ = c(10);
8
- const { show, children } = t0;
9
- const [shouldRender, setRender] = useState(show);
10
- let t1;
11
- let t2;
12
- if ($[0] !== show) {
13
- t1 = () => {
14
- if (show) setRender(true);
15
- };
16
- t2 = [show];
17
- $[0] = show;
18
- $[1] = t1;
19
- $[2] = t2;
7
+ const $ = c(14);
8
+ let children;
9
+ let rest;
10
+ let show;
11
+ let style;
12
+ if ($[0] !== t0) {
13
+ ({show, children, style, ...rest} = t0);
14
+ $[0] = t0;
15
+ $[1] = children;
16
+ $[2] = rest;
17
+ $[3] = show;
18
+ $[4] = style;
20
19
  } else {
21
- t1 = $[1];
22
- t2 = $[2];
20
+ children = $[1];
21
+ rest = $[2];
22
+ show = $[3];
23
+ style = $[4];
23
24
  }
24
- useEffect(t1, t2);
25
- let t3;
26
- if ($[3] !== show) {
27
- t3 = () => {
25
+ const [shouldRender, setRender] = useState(Boolean(show));
26
+ if (show && !shouldRender) setRender(true);
27
+ let t1;
28
+ if ($[5] !== show) {
29
+ t1 = () => {
28
30
  if (!show) setRender(false);
29
31
  };
30
- $[3] = show;
31
- $[4] = t3;
32
- } else t3 = $[4];
33
- const onAnimationEnd = t3;
34
- let t4;
35
- if ($[5] !== children || $[6] !== onAnimationEnd || $[7] !== shouldRender || $[8] !== show) {
36
- t4 = shouldRender ? /*#__PURE__*/ jsx("div", {
32
+ $[5] = show;
33
+ $[6] = t1;
34
+ } else t1 = $[6];
35
+ const onAnimationEnd = t1;
36
+ let t2;
37
+ if ($[7] !== children || $[8] !== onAnimationEnd || $[9] !== rest || $[10] !== shouldRender || $[11] !== show || $[12] !== style) {
38
+ t2 = shouldRender ? /*#__PURE__*/ jsx("div", {
39
+ ...rest,
37
40
  style: {
41
+ ...style,
38
42
  height: show ? "auto" : 0,
39
43
  overflow: "hidden"
40
44
  },
@@ -45,13 +49,15 @@ const ValidationAnimationContainer = (t0) => {
45
49
  children
46
50
  })
47
51
  }) : null;
48
- $[5] = children;
49
- $[6] = onAnimationEnd;
50
- $[7] = shouldRender;
51
- $[8] = show;
52
- $[9] = t4;
53
- } else t4 = $[9];
54
- return t4;
52
+ $[7] = children;
53
+ $[8] = onAnimationEnd;
54
+ $[9] = rest;
55
+ $[10] = shouldRender;
56
+ $[11] = show;
57
+ $[12] = style;
58
+ $[13] = t2;
59
+ } else t2 = $[13];
60
+ return t2;
55
61
  };
56
62
  //#endregion
57
63
  export { ValidationAnimationContainer as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "38.32.0-rc.3ce9543fd",
4
+ "version": "38.32.0-rc.4bb4bba69",
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",
@@ -47,6 +47,7 @@
47
47
  "build:hooks.json": "tsx script/hooks-json/build.ts",
48
48
  "build:precompile-color-schemes": "tsx script/precompile-color-schemes.ts",
49
49
  "lint:npm": "publint --types",
50
+ "lint:react-compiler": "node script/lint-react-compiler.ts",
50
51
  "storybook": "storybook",
51
52
  "type-check": "tsc --noEmit",
52
53
  "type-css-modules": "tcm -p src/**/*.module.css"
@@ -108,6 +109,7 @@
108
109
  "@figma/code-connect": "1.3.2",
109
110
  "@primer/css": "^21.5.1",
110
111
  "@primer/doc-gen": "^0.0.1",
112
+ "@primer/react-compiler-check": "^0.0.0",
111
113
  "@rolldown/plugin-babel": "^0.2.3",
112
114
  "@storybook/addon-a11y": "^10.4.6",
113
115
  "@storybook/addon-docs": "^10.4.6",