@primer/react 38.32.0-rc.4bb4bba69 → 38.32.0-rc.55b6eaf9c

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,6 +6,7 @@ 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";
9
10
  import { clsx } from "clsx";
10
11
  import { jsx, jsxs } from "react/jsx-runtime";
11
12
  import React, { Children, cloneElement, createContext, isValidElement, useContext, useMemo, useRef, useState } from "react";
@@ -21,7 +22,7 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
21
22
  const wrapperRef = useRef(null);
22
23
  const listRef = useRef(null);
23
24
  const parentId = useId$1(props.id);
24
- const [tabs, tabPanels, tabsHaveIcons] = useMemo(() => {
25
+ const [tabs_0, tabPanels_0, tabsHaveIcons_0] = useMemo(() => {
25
26
  let tabIndex = 0;
26
27
  let panelIndex = 0;
27
28
  const childrenWithProps = Children.map(children, (child) => {
@@ -31,10 +32,10 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
31
32
  });
32
33
  const tabs = [];
33
34
  const tabPanels = [];
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);
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);
38
39
  }
39
40
  return [
40
41
  tabs,
@@ -52,20 +53,20 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
52
53
  }, [iconsVisible]);
53
54
  const listWidthRef = useRef(0);
54
55
  useResizeObserver((entries) => {
55
- if (!tabsHaveIcons) return;
56
+ if (!tabsHaveIcons_0) return;
56
57
  if (!iconsVisibleRef.current) return;
57
58
  listWidthRef.current = entries[0].contentRect.width;
58
59
  }, listRef, []);
59
60
  useResizeObserver((resizeObserverEntries) => {
60
- if (!tabsHaveIcons) return;
61
+ if (!tabsHaveIcons_0) return;
61
62
  const wrapperWidth = resizeObserverEntries[0].contentRect.width;
62
63
  setIconsVisible(wrapperWidth > listWidthRef.current);
63
64
  }, wrapperRef, []);
64
- !(tabs.filter((tab) => {
65
- const ariaSelected = /*#__PURE__*/ React.isValidElement(tab) && tab.props["aria-selected"];
65
+ !(tabs_0.filter((tab_0) => {
66
+ const ariaSelected = /*#__PURE__*/ React.isValidElement(tab_0) && tab_0.props["aria-selected"];
66
67
  return ariaSelected === true || ariaSelected === "true";
67
68
  }).length <= 1) && invariant(false, "Only one tab can be selected at a time.");
68
- !(tabs.length === tabPanels.length) && invariant(false, `The number of tabs and panels must be equal. Counted ${tabs.length} tabs and ${tabPanels.length} panels.`);
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.`);
69
70
  return /*#__PURE__*/ jsx(UnderlinePanelsContext.Provider, {
70
71
  value: contextValue,
71
72
  children: /*#__PURE__*/ jsxs(TabContainerComponent, { children: [/*#__PURE__*/ jsx(UnderlineWrapper, {
@@ -79,44 +80,100 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
79
80
  "aria-label": ariaLabel,
80
81
  "aria-labelledby": ariaLabelledBy,
81
82
  role: "tablist",
82
- children: tabs
83
+ children: tabs_0
83
84
  })
84
- }), tabPanels] })
85
+ }), tabPanels_0] })
85
86
  });
86
87
  };
87
88
  UnderlinePanels.displayName = "UnderlinePanels";
88
- const TabImpl = ({ "aria-selected": ariaSelected, onSelect, ...props }) => {
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
+ }
89
105
  const { loadingCounters } = useContext(UnderlinePanelsContext);
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
- });
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;
107
147
  };
108
- TabImpl.displayName = "TabImpl";
109
148
  TabImpl.displayName = "UnderlinePanels.Tab";
110
149
  const Tab = /*#__PURE__*/ React.memo(TabImpl);
111
150
  Tab.displayName = "UnderlinePanels.Tab";
112
- const Panel = ({ children, ...rest }) => {
113
- return /*#__PURE__*/ jsx("div", {
114
- role: "tabpanel",
115
- ...rest,
116
- children
117
- });
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;
118
176
  };
119
- Panel.displayName = "Panel";
120
177
  Panel.displayName = "UnderlinePanels.Panel";
121
178
  var UnderlinePanels_default = Object.assign(UnderlinePanels, {
122
179
  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 = 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);
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);
27
27
  }, [state]);
28
28
  React.useEffect(() => {
29
29
  const controlledValue = value !== void 0;
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.4bb4bba69",
4
+ "version": "38.32.0-rc.55b6eaf9c",
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,7 +47,6 @@
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",
51
50
  "storybook": "storybook",
52
51
  "type-check": "tsc --noEmit",
53
52
  "type-css-modules": "tcm -p src/**/*.module.css"
@@ -109,7 +108,6 @@
109
108
  "@figma/code-connect": "1.3.2",
110
109
  "@primer/css": "^21.5.1",
111
110
  "@primer/doc-gen": "^0.0.1",
112
- "@primer/react-compiler-check": "^0.0.0",
113
111
  "@rolldown/plugin-babel": "^0.2.3",
114
112
  "@storybook/addon-a11y": "^10.4.6",
115
113
  "@storybook/addon-docs": "^10.4.6",