@primer/react 0.0.0-20260915162741 → 0.0.0-20260915174622

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.
@@ -1,11 +1,10 @@
1
1
  import { c } from "../utils/react-compiler-runtime.js";
2
2
  import { DEFAULT_SORT_DIRECTION, SortDirection, strategies, transition } from "./sorting.js";
3
- import { useId, useState } from "react";
3
+ import { useState } from "react";
4
4
  //#region src/DataTable/useTable.ts
5
5
  function useTable(t0) {
6
- const $ = c(29);
6
+ const $ = c(21);
7
7
  const { columns, data, initialSortColumn, initialSortDirection, externalSorting, getRowId } = t0;
8
- const tableId = useId();
9
8
  const [rowOrder, setRowOrder] = useState(data);
10
9
  const [prevData, setPrevData] = useState(data);
11
10
  const [prevColumns, setPrevColumns] = useState(columns);
@@ -30,26 +29,18 @@ function useTable(t0) {
30
29
  }
31
30
  }
32
31
  let t2;
33
- if ($[4] !== rowOrder) {
34
- t2 = rowOrder.some(isDataTableRowGroup);
35
- $[4] = rowOrder;
36
- $[5] = t2;
37
- } else t2 = $[5];
38
- const hasGroups = t2;
39
- let bodies;
40
- let headers;
41
- let sortBy;
42
- if ($[6] !== columns || $[7] !== data || $[8] !== externalSorting || $[9] !== getRowId || $[10] !== hasGroups || $[11] !== prevData || $[12] !== rowOrder || $[13] !== sortByColumn || $[14] !== tableId) {
43
- let t3;
44
- if ($[18] !== hasGroups || $[19] !== sortByColumn || $[20] !== tableId) {
45
- t3 = (column_1, index) => {
32
+ let t3;
33
+ let t4;
34
+ if ($[4] !== columns || $[5] !== data || $[6] !== externalSorting || $[7] !== getRowId || $[8] !== prevData || $[9] !== rowOrder || $[10] !== sortByColumn) {
35
+ let t5;
36
+ if ($[14] !== sortByColumn) {
37
+ t5 = (column_1) => {
46
38
  var _column_1$id;
47
39
  const id_0 = (_column_1$id = column_1.id) !== null && _column_1$id !== void 0 ? _column_1$id : column_1.field;
48
40
  if (id_0 === void 0) throw new Error("Expected either an `id` or `field` to be defined for a Column");
49
41
  const sortable = column_1.sortBy !== void 0 && column_1.sortBy !== false;
50
42
  return {
51
43
  id: id_0,
52
- domId: hasGroups ? `${tableId}-column-${index}` : void 0,
53
44
  column: column_1,
54
45
  isSortable() {
55
46
  return sortable;
@@ -60,171 +51,103 @@ function useTable(t0) {
60
51
  }
61
52
  };
62
53
  };
63
- $[18] = hasGroups;
64
- $[19] = sortByColumn;
65
- $[20] = tableId;
66
- $[21] = t3;
67
- } else t3 = $[21];
68
- headers = columns.map(t3);
54
+ $[14] = sortByColumn;
55
+ $[15] = t5;
56
+ } else t5 = $[15];
57
+ const headers = columns.map(t5);
69
58
  if (data !== prevData) {
70
59
  setPrevData(data);
71
- updateRowOrder(data, sortByColumn);
60
+ setRowOrder(data);
61
+ if (sortByColumn) sortRows(sortByColumn);
72
62
  }
73
- sortBy = function sortBy(header) {
63
+ const sortBy = function sortBy(header) {
74
64
  const sortState = {
75
65
  id: header.id,
76
66
  direction: sortByColumn && sortByColumn.id === header.id ? transition(sortByColumn.direction) : DEFAULT_SORT_DIRECTION
77
67
  };
78
68
  setSortByColumn(sortState);
79
- updateRowOrder(rowOrder, sortState);
69
+ sortRows(sortState);
80
70
  };
81
- function updateRowOrder(rows, state) {
82
- if (externalSorting || state === null) setRowOrder(rows);
83
- else {
84
- const sortedRows = getSortedRowOrder(rows, state);
85
- setRowOrder(sortedRows);
86
- }
87
- }
88
- function getSortedRowOrder(currentRowOrder, state_0) {
89
- const header_1 = headers.find((header_0) => header_0.id === state_0.id);
90
- if (!header_1) throw new Error(`Unable to find header with id: ${state_0.id}`);
71
+ function sortRows(state) {
72
+ const header_1 = headers.find((header_0) => header_0.id === state.id);
73
+ if (!header_1) throw new Error(`Unable to find header with id: ${state.id}`);
91
74
  if (header_1.column.sortBy === false || header_1.column.sortBy === void 0) throw new Error("The column for this header is not sortable");
92
- const column_2 = header_1.column;
93
- const sortMethod = column_2.sortBy === true ? strategies.basic : typeof column_2.sortBy === "string" ? strategies[column_2.sortBy] : column_2.sortBy;
94
- const sortData = function sortData(rows_0) {
95
- return rows_0.slice().sort((a, b) => {
96
- if (column_2.field === void 0) return 0;
97
- if (typeof column_2.sortBy === "function") {
98
- if (state_0.direction === SortDirection.ASC) return sortMethod(a, b);
99
- return sortMethod(b, a);
100
- }
101
- const valueA = get(a, column_2.field);
102
- const valueB = get(b, column_2.field);
103
- const valueAIsBlank = isBlankValue(valueA);
104
- const valueBIsBlank = isBlankValue(valueB);
105
- if (!valueAIsBlank && !valueBIsBlank) {
106
- if (state_0.direction === SortDirection.ASC) return sortMethod(valueA, valueB);
107
- return sortMethod(valueB, valueA);
108
- }
109
- if (!valueAIsBlank) return -1;
110
- if (!valueBIsBlank) return 1;
111
- return 0;
112
- });
113
- };
114
- const sorted = [];
115
- let ungroupedRows = [];
116
- const appendUngroupedRows = function appendUngroupedRows() {
117
- for (const row of sortData(ungroupedRows)) sorted.push(row);
118
- ungroupedRows = [];
119
- };
120
- for (const item of currentRowOrder) if (isDataTableRowGroup(item)) {
121
- appendUngroupedRows();
122
- sorted.push({
123
- ...item,
124
- rows: sortData(item.rows)
125
- });
126
- } else ungroupedRows.push(item);
127
- appendUngroupedRows();
128
- return sorted;
75
+ if (externalSorting) return;
76
+ const sortMethod = header_1.column.sortBy === true ? strategies.basic : typeof header_1.column.sortBy === "string" ? strategies[header_1.column.sortBy] : header_1.column.sortBy;
77
+ setRowOrder((rowOrder_0) => rowOrder_0.slice().sort((a, b) => {
78
+ if (header_1.column.field === void 0) return 0;
79
+ if (typeof header_1.column.sortBy === "function") {
80
+ if (state.direction === SortDirection.ASC) return sortMethod(a, b);
81
+ return sortMethod(b, a);
82
+ }
83
+ const valueA = get(a, header_1.column.field);
84
+ const valueB = get(b, header_1.column.field);
85
+ const valueAIsBlank = isBlankValue(valueA);
86
+ const valueBIsBlank = isBlankValue(valueB);
87
+ if (!valueAIsBlank && !valueBIsBlank) {
88
+ if (state.direction === SortDirection.ASC) return sortMethod(valueA, valueB);
89
+ return sortMethod(valueB, valueA);
90
+ }
91
+ if (!valueAIsBlank) return -1;
92
+ if (!valueBIsBlank) return 1;
93
+ return 0;
94
+ }));
129
95
  }
130
- const createRow = function createRow(row_0, rowIndex) {
131
- const rowId = getRowId(row_0);
132
- const rowHeaderIds = hasGroups ? headers.flatMap((header_2, index_0) => header_2.column.rowHeader ? [`${tableId}-row-${rowIndex}-header-${index_0}`] : []) : [];
96
+ t2 = headers;
97
+ t3 = rowOrder.map((row) => {
98
+ const rowId = getRowId(row);
133
99
  return {
134
- type: "row",
135
100
  id: `${rowId}`,
136
101
  getValue() {
137
- return row_0;
102
+ return row;
138
103
  },
139
104
  getCells() {
140
- return headers.map((header_3, index_1) => {
141
- var _header_3$column$rowH;
142
- const rowHeader = (_header_3$column$rowH = header_3.column.rowHeader) !== null && _header_3$column$rowH !== void 0 ? _header_3$column$rowH : false;
105
+ return headers.map((header_2) => {
106
+ var _header_2$column$rowH;
143
107
  return {
144
- id: `${rowId}:${header_3.id}`,
145
- domId: hasGroups && rowHeader ? `${tableId}-row-${rowIndex}-header-${index_1}` : void 0,
146
- headers: hasGroups ? (rowHeader ? [header_3.domId] : [...rowHeaderIds, header_3.domId]).join(" ") : void 0,
147
- column: header_3.column,
148
- rowHeader,
108
+ id: `${rowId}:${header_2.id}`,
109
+ column: header_2.column,
110
+ rowHeader: (_header_2$column$rowH = header_2.column.rowHeader) !== null && _header_2$column$rowH !== void 0 ? _header_2$column$rowH : false,
149
111
  getValue() {
150
- if (header_3.column.field !== void 0) return get(row_0, header_3.column.field);
151
- throw new Error(`Unable to get value for column header ${header_3.id}`);
112
+ if (header_2.column.field !== void 0) return get(row, header_2.column.field);
113
+ throw new Error(`Unable to get value for column header ${header_2.id}`);
152
114
  }
153
115
  };
154
116
  });
155
117
  }
156
118
  };
157
- };
158
- bodies = [];
159
- let rowIndex_0 = 0;
160
- let body = {
161
- type: "row-body",
162
- key: "rows:start",
163
- rows: []
164
- };
165
- for (const item_0 of rowOrder) if (isDataTableRowGroup(item_0)) {
166
- if (body.rows.length > 0) bodies.push(body);
167
- const groupStartIndex = rowIndex_0;
168
- bodies.push({
169
- type: "row-group",
170
- key: `group:${item_0.groupId}`,
171
- id: item_0.groupId,
172
- label: item_0.label,
173
- rows: item_0.rows.map((row_1, index_2) => createRow(row_1, groupStartIndex + index_2)),
174
- "aria-label": item_0["aria-label"]
175
- });
176
- rowIndex_0 = rowIndex_0 + item_0.rows.length;
177
- body = {
178
- type: "row-body",
179
- key: `rows:after:${item_0.groupId}`,
180
- rows: []
181
- };
182
- } else {
183
- body.rows.push(createRow(item_0, rowIndex_0));
184
- rowIndex_0 = rowIndex_0 + 1;
185
- }
186
- if (body.rows.length > 0 || bodies.length === 0) bodies.push(body);
187
- $[6] = columns;
188
- $[7] = data;
189
- $[8] = externalSorting;
190
- $[9] = getRowId;
191
- $[10] = hasGroups;
192
- $[11] = prevData;
193
- $[12] = rowOrder;
194
- $[13] = sortByColumn;
195
- $[14] = tableId;
196
- $[15] = bodies;
197
- $[16] = headers;
198
- $[17] = sortBy;
119
+ });
120
+ t4 = { sortBy };
121
+ $[4] = columns;
122
+ $[5] = data;
123
+ $[6] = externalSorting;
124
+ $[7] = getRowId;
125
+ $[8] = prevData;
126
+ $[9] = rowOrder;
127
+ $[10] = sortByColumn;
128
+ $[11] = t2;
129
+ $[12] = t3;
130
+ $[13] = t4;
199
131
  } else {
200
- bodies = $[15];
201
- headers = $[16];
202
- sortBy = $[17];
132
+ t2 = $[11];
133
+ t3 = $[12];
134
+ t4 = $[13];
203
135
  }
204
- let t3;
205
- if ($[22] !== sortBy) {
206
- t3 = { sortBy };
207
- $[22] = sortBy;
208
- $[23] = t3;
209
- } else t3 = $[23];
210
- let t4;
211
- if ($[24] !== bodies || $[25] !== gridTemplateColumns || $[26] !== headers || $[27] !== t3) {
212
- t4 = {
213
- headers,
214
- actions: t3,
215
- gridTemplateColumns,
216
- bodies
136
+ let t5;
137
+ if ($[16] !== gridTemplateColumns || $[17] !== t2 || $[18] !== t3 || $[19] !== t4) {
138
+ t5 = {
139
+ headers: t2,
140
+ rows: t3,
141
+ actions: t4,
142
+ gridTemplateColumns
217
143
  };
218
- $[24] = bodies;
219
- $[25] = gridTemplateColumns;
220
- $[26] = headers;
221
- $[27] = t3;
222
- $[28] = t4;
223
- } else t4 = $[28];
224
- return t4;
225
- }
226
- function isDataTableRowGroup(item) {
227
- return "groupId" in item && "rows" in item && Array.isArray(item.rows);
144
+ $[16] = gridTemplateColumns;
145
+ $[17] = t2;
146
+ $[18] = t3;
147
+ $[19] = t4;
148
+ $[20] = t5;
149
+ } else t5 = $[20];
150
+ return t5;
228
151
  }
229
152
  function getInitialSortState(columns, initialSortColumn, initialSortDirection) {
230
153
  if (initialSortColumn !== void 0) {
@@ -1,5 +1,4 @@
1
1
  //#region src/DataTable/utils.d.ts
2
- type IsAny<T> = 0 extends 1 & T ? true : false;
3
2
  type ArrayOfLength<Length extends number, SizedArray extends Array<unknown> = []> = SizedArray['length'] extends Length ? SizedArray : ArrayOfLength<Length, [...SizedArray, SizedArray['length']]>;
4
3
  type MaxLength = ArrayOfLength<10>[number];
5
4
  type ArrayIndex<A extends ReadonlyArray<any>, Keys extends number = never> = A extends readonly [] ? Keys : A extends readonly [infer _, ...infer Tail] ? ArrayIndex<Tail, Keys | Tail['length']> : Keys;
@@ -7,7 +6,6 @@ type ArrayWithinBounds<T> = T extends ReadonlyArray<any> & {
7
6
  length: infer Length;
8
7
  } ? Length extends MaxLength ? T : never : never;
9
8
  type ObjectPaths<T> = T extends readonly any[] & ArrayWithinBounds<T> ? `${ArrayIndex<T>}` | PrefixPath<T, ArrayIndex<T>> : T extends any[] ? never & 'Unable to determine keys of potentially boundless array' : T extends Date ? never : T extends object ? Extract<keyof T, string | number> | PrefixPath<T, Extract<keyof T, string | number>> : never;
10
- type PrefixPath<T, Prefix> = Prefix extends Extract<keyof T, number | string> ? `${Prefix}.${NestedObjectPaths<T[Prefix]>}` : never;
11
- type NestedObjectPaths<T> = IsAny<T> extends true ? string : ObjectPaths<T>;
9
+ type PrefixPath<T, Prefix> = Prefix extends Extract<keyof T, number | string> ? `${Prefix}.${ObjectPaths<T[Prefix]>}` : never;
12
10
  //#endregion
13
- export { IsAny, ObjectPaths };
11
+ export { ObjectPaths };
@@ -12,7 +12,8 @@ import { Icon } from "@primer/octicons-react";
12
12
  //#region src/NavList/NavList.d.ts
13
13
  type NavListHeadingLevels = 'h2' | 'h3';
14
14
  type NavListProps = {
15
- children: React.ReactNode;
15
+ children: React.ReactNode; /** Disable the gap between items when the item gap feature is enabled. */
16
+ disableItemGap?: boolean;
16
17
  } & React.ComponentProps<'nav'>;
17
18
  type NavListHeadingProps = {
18
19
  /** Semantic heading level for the NavList. Also sets the default level for child group headings, which render one level deeper. */as?: NavListHeadingLevels; /** Visually hide the heading while keeping it available to assistive technology. */
@@ -26,76 +26,83 @@ function levelToHeadingTag(level) {
26
26
  }
27
27
  const Root = /*#__PURE__*/ React.forwardRef((t0, ref) => {
28
28
  var _heading$props$id, _ariaLabelledby;
29
- const $ = c(24);
29
+ const $ = c(26);
30
30
  let ariaLabel;
31
31
  let ariaLabelledby;
32
32
  let children;
33
+ let disableItemGap;
33
34
  let props;
34
35
  if ($[0] !== t0) {
35
- ({children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...props} = t0);
36
+ ({children, disableItemGap, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...props} = t0);
36
37
  $[0] = t0;
37
38
  $[1] = ariaLabel;
38
39
  $[2] = ariaLabelledby;
39
40
  $[3] = children;
40
- $[4] = props;
41
+ $[4] = disableItemGap;
42
+ $[5] = props;
41
43
  } else {
42
44
  ariaLabel = $[1];
43
45
  ariaLabelledby = $[2];
44
46
  children = $[3];
45
- props = $[4];
47
+ disableItemGap = $[4];
48
+ props = $[5];
46
49
  }
47
50
  let t1;
48
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
51
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
49
52
  t1 = { heading: Heading };
50
- $[5] = t1;
51
- } else t1 = $[5];
53
+ $[6] = t1;
54
+ } else t1 = $[6];
52
55
  const [slots, childrenWithoutHeading] = useSlots(children, t1);
53
56
  const fallbackHeadingId = useId$1();
54
57
  const heading = slots.heading;
55
58
  const headingId = heading ? (_heading$props$id = heading.props.id) !== null && _heading$props$id !== void 0 ? _heading$props$id : fallbackHeadingId : void 0;
56
59
  let t2;
57
- if ($[6] !== heading) {
60
+ if ($[7] !== heading) {
58
61
  var _heading$props$as;
59
62
  t2 = heading ? headingTagToLevel((_heading$props$as = heading.props.as) !== null && _heading$props$as !== void 0 ? _heading$props$as : "h2") : null;
60
- $[6] = heading;
61
- $[7] = t2;
62
- } else t2 = $[7];
63
+ $[7] = heading;
64
+ $[8] = t2;
65
+ } else t2 = $[8];
63
66
  const headingLevel = t2;
64
67
  const navLabelledby = (_ariaLabelledby = ariaLabelledby) !== null && _ariaLabelledby !== void 0 ? _ariaLabelledby : ariaLabel ? void 0 : headingId;
65
68
  let t3;
66
- if ($[8] !== heading || $[9] !== headingId) {
69
+ if ($[9] !== heading || $[10] !== headingId) {
67
70
  t3 = heading ? /*#__PURE__*/ React.cloneElement(heading, { id: headingId }) : null;
68
- $[8] = heading;
69
- $[9] = headingId;
70
- $[10] = t3;
71
- } else t3 = $[10];
71
+ $[9] = heading;
72
+ $[10] = headingId;
73
+ $[11] = t3;
74
+ } else t3 = $[11];
72
75
  let t4;
73
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
76
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
74
77
  t4 = { container: "NavList" };
75
- $[11] = t4;
76
- } else t4 = $[11];
78
+ $[12] = t4;
79
+ } else t4 = $[12];
77
80
  let t5;
78
- if ($[12] !== childrenWithoutHeading) {
81
+ if ($[13] !== childrenWithoutHeading || $[14] !== disableItemGap) {
79
82
  t5 = /*#__PURE__*/ jsx(ActionListContainerContext.Provider, {
80
83
  value: t4,
81
- children: /*#__PURE__*/ jsx(ActionList, { children: childrenWithoutHeading })
84
+ children: /*#__PURE__*/ jsx(ActionList, {
85
+ disableItemGap,
86
+ children: childrenWithoutHeading
87
+ })
82
88
  });
83
- $[12] = childrenWithoutHeading;
84
- $[13] = t5;
85
- } else t5 = $[13];
89
+ $[13] = childrenWithoutHeading;
90
+ $[14] = disableItemGap;
91
+ $[15] = t5;
92
+ } else t5 = $[15];
86
93
  let t6;
87
- if ($[14] !== headingLevel || $[15] !== t3 || $[16] !== t5) {
94
+ if ($[16] !== headingLevel || $[17] !== t3 || $[18] !== t5) {
88
95
  t6 = /*#__PURE__*/ jsxs(NavListHeadingLevelContext.Provider, {
89
96
  value: headingLevel,
90
97
  children: [t3, t5]
91
98
  });
92
- $[14] = headingLevel;
93
- $[15] = t3;
94
- $[16] = t5;
95
- $[17] = t6;
96
- } else t6 = $[17];
99
+ $[16] = headingLevel;
100
+ $[17] = t3;
101
+ $[18] = t5;
102
+ $[19] = t6;
103
+ } else t6 = $[19];
97
104
  let t7;
98
- if ($[18] !== ariaLabel || $[19] !== navLabelledby || $[20] !== props || $[21] !== ref || $[22] !== t6) {
105
+ if ($[20] !== ariaLabel || $[21] !== navLabelledby || $[22] !== props || $[23] !== ref || $[24] !== t6) {
99
106
  t7 = /*#__PURE__*/ jsx("nav", {
100
107
  ...props,
101
108
  "aria-label": ariaLabel,
@@ -104,13 +111,13 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, ref) => {
104
111
  "data-component": "NavList",
105
112
  children: t6
106
113
  });
107
- $[18] = ariaLabel;
108
- $[19] = navLabelledby;
109
- $[20] = props;
110
- $[21] = ref;
111
- $[22] = t6;
112
- $[23] = t7;
113
- } else t7 = $[23];
114
+ $[20] = ariaLabel;
115
+ $[21] = navLabelledby;
116
+ $[22] = props;
117
+ $[23] = ref;
118
+ $[24] = t6;
119
+ $[25] = t7;
120
+ } else t7 = $[25];
114
121
  return t7;
115
122
  });
116
123
  Root.displayName = "NavList";
@@ -1,4 +1,3 @@
1
- import { reactMajorVersion } from "../utils/environment.js";
2
1
  import { useMergedRefs } from "../hooks/useMergedRefs.js";
3
2
  import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
4
3
  import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
@@ -83,14 +82,10 @@ const emptyKeybindingHints = [];
83
82
  const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
84
83
  const tooltipId = useId$1(id);
85
84
  const child = Children.only(children);
86
- const isFragmentTrigger = /*#__PURE__*/ React.isValidElement(child) && child.type === React.Fragment;
87
- warning(isFragmentTrigger, "The `Tooltip` component does not support a React Fragment as its trigger. Pass a single interactive element instead.");
88
- const elementChild = /*#__PURE__*/ React.isValidElement(child) ? child : void 0;
89
- const childRef = reactMajorVersion > 18 ? elementChild === null || elementChild === void 0 ? void 0 : elementChild.props.ref : elementChild === null || elementChild === void 0 ? void 0 : elementChild.ref;
90
85
  const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
91
86
  const triggerRef = useRef(null);
92
- const mergedTriggerRef = useMergedRefs(triggerRef, useMergedRefs(forwardedRef, childRef));
93
- const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : childRef);
87
+ const mergedTriggerRef = useMergedRefs(triggerRef, forwardedRef);
88
+ const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
94
89
  const readTriggerRef = mergedRefEnabled ? triggerRef : providedOrCreatedRef;
95
90
  const appliedTriggerRef = mergedRefEnabled ? mergedTriggerRef : providedOrCreatedRef;
96
91
  const tooltipElRef = useRef(null);
@@ -100,7 +95,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
100
95
  const { safeSetTimeout, safeClearTimeout } = useSafeTimeout();
101
96
  const openTooltip = () => {
102
97
  try {
103
- if (tooltipElRef.current && readTriggerRef.current instanceof HTMLElement && tooltipElRef.current.hasAttribute("popover") && !tooltipElRef.current.matches(":popover-open") && !_privateDisableTooltip) {
98
+ if (tooltipElRef.current && readTriggerRef.current && tooltipElRef.current.hasAttribute("popover") && !tooltipElRef.current.matches(":popover-open") && !_privateDisableTooltip) {
104
99
  const tooltip = tooltipElRef.current;
105
100
  const trigger = readTriggerRef.current;
106
101
  tooltip.showPopover();
@@ -136,19 +131,15 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
136
131
  const value = useMemo(() => ({ tooltipId }), [tooltipId]);
137
132
  useEffect(() => {
138
133
  if (!tooltipElRef.current || !readTriggerRef.current) return;
139
- const trigger = readTriggerRef.current;
140
- const isInvalidTrigger = !(trigger instanceof HTMLElement);
141
- warning(isInvalidTrigger, "The `Tooltip` component expects its trigger ref to resolve to an HTML element. Ensure the trigger forwards its ref to a single interactive element instead of a React Fragment.");
142
- if (isInvalidTrigger) return;
143
- const isTriggerInteractive = isInteractive(trigger);
144
- const triggerChildren = trigger.childNodes;
134
+ const isTriggerInteractive = isInteractive(readTriggerRef.current);
135
+ const triggerChildren = readTriggerRef.current.childNodes;
145
136
  const hasInteractiveDescendant = Array.from(triggerChildren).some((child) => {
146
137
  return child instanceof HTMLElement && isInteractive(child) || Array.from(child.childNodes).some((grandChild) => grandChild instanceof HTMLElement && isInteractive(grandChild));
147
138
  });
148
139
  !(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.");
149
140
  if (type === "label") {
150
- const hasAriaLabel = trigger.hasAttribute("aria-label");
151
- const hasAriaLabelInChildren = Array.from(trigger.childNodes).some((child) => child instanceof HTMLElement && child.hasAttribute("aria-label"));
141
+ const hasAriaLabel = readTriggerRef.current.hasAttribute("aria-label");
142
+ const hasAriaLabelInChildren = Array.from(readTriggerRef.current.childNodes).some((child) => child instanceof HTMLElement && child.hasAttribute("aria-label"));
152
143
  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.");
153
144
  }
154
145
  if (typeof window !== "undefined") {
@@ -171,7 +162,6 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
171
162
  const platform = usePlatform();
172
163
  const hasAriaLabel = "aria-label" in rest;
173
164
  const keybindingHints = Array.isArray(keybindingHint) ? keybindingHint : [keybindingHint];
174
- if (isFragmentTrigger) return child;
175
165
  return /*#__PURE__*/ jsx(TooltipContext.Provider, {
176
166
  value,
177
167
  children: /*#__PURE__*/ jsxs(Fragment$1, { children: [/*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
@@ -15,7 +15,7 @@ import { FilteredActionListProps } from "../FilteredActionList/FilteredActionLis
15
15
  import { FilteredActionListInputProps } from "../FilteredActionList/FilteredActionListInput.js";
16
16
  import { FilteredActionList } from "../FilteredActionList/index.js";
17
17
  import { ObjectPaths } from "../DataTable/utils.js";
18
- import { DataTableData, DataTableRowGroup, UniqueRow } from "../DataTable/row.js";
18
+ import { UniqueRow } from "../DataTable/row.js";
19
19
  import { CellAlignment, Column, ColumnWidth, createColumnHelper } from "../DataTable/column.js";
20
20
  import { ActionBarButtonProps, ActionBarMenuItemProps, ActionBarMenuProps, ActionBarProps } from "../ActionBar/ActionBar.js";
21
21
  import { ActionBar } from "../ActionBar/index.js";
@@ -51,4 +51,4 @@ import { useTabPanel } from "./Tabs/useTabPanel.js";
51
51
  import { TopicTagProps } from "../TopicTag/TopicTag.js";
52
52
  import { TopicTagGroupProps } from "../TopicTag/TopicTagGroup.js";
53
53
  import { TopicTag } from "../TopicTag/index.js";
54
- export { ActionBar, type ActionBarButtonProps, type ActionBarMenuItemProps, type ActionBarMenuProps, type ActionBarProps, Announce, type AnnounceProps, AriaAlert, type AriaAlertProps, AriaStatus, type AriaStatusProps, BlankslateContainer as Blankslate, type BlankslateProps, ButtonBase, type ButtonBaseProps, Card, type ActionProps as CardActionProps, type DescriptionProps as CardDescriptionProps, type HeadingProps as CardHeadingProps, type IconProps as CardIconProps, type ImageProps as CardImageProps, type MetadataProps as CardMetadataProps, type CardProps, type CellAlignment, type Column, type ColumnWidth, DataTable, type DataTableData, type DataTableProps, type DataTableRowGroup, DefaultFeatureFlags, Dialog, type DialogButtonProps, type DialogHeaderProps, type DialogHeight, type DialogProps, type DialogWidth, FeatureFlags, type FeatureFlagsProps, FilteredActionList, type FilteredActionListInputProps, FilteredActionListLoadingTypes, type FilteredActionListProps, Hidden, type HiddenProps, InlineMessage, type InlineMessageProps, IssueLabel, type IssueLabelProps, KeybindingHint, type KeybindingHintProps, NavList, type NavListDividerProps, type NavListGroupProps, type NavListItemProps, type NavListLeadingVisualProps, type NavListProps, type NavListSubNavProps, type NavListTrailingVisualProps, type ObjectPaths, PageHeader, type ActionsProps as PageHeaderActionsProps, type PageHeaderProps, type TitleProps as PageHeaderTitleProps, ScrollableRegion, type ScrollableRegionProps, SelectPanel, type SelectPanelMessageProps, type SelectPanelProps, type SelectPanelSecondaryActionProps, SkeletonAvatar, type SkeletonAvatarProps, SkeletonBox, type SkeletonBoxProps, SkeletonText, type SkeletonTextProps, SlotConfig, Stack, type StackItemProps, type StackProps, type TabListProps, type TabPanelProps, type TabProps, Table, type TableActionsProps, type TableBodyProps, type TableCellProps, type TableContainerProps, type TableGroupProps, type TableHeadProps, type TableHeaderProps, type TableProps, type TableRowProps, type TableSubtitleProps, type TableTitleProps, Tabs, type TabsProps, type TitleProps, Tooltip, type TooltipProps, TopicTag, type TopicTagGroupProps, type TopicTagProps, _default as UnderlinePanels, type PanelProps as UnderlinePanelsPanelProps, type UnderlinePanelsProps, type TabProps$1 as UnderlinePanelsTabProps, type UniqueRow, createColumnHelper, getAccessibleKeybindingHintString, useFeatureFlag, useOverflow, useSlots, useTab, useTabList, useTabPanel };
54
+ export { ActionBar, type ActionBarButtonProps, type ActionBarMenuItemProps, type ActionBarMenuProps, type ActionBarProps, Announce, type AnnounceProps, AriaAlert, type AriaAlertProps, AriaStatus, type AriaStatusProps, BlankslateContainer as Blankslate, type BlankslateProps, ButtonBase, type ButtonBaseProps, Card, type ActionProps as CardActionProps, type DescriptionProps as CardDescriptionProps, type HeadingProps as CardHeadingProps, type IconProps as CardIconProps, type ImageProps as CardImageProps, type MetadataProps as CardMetadataProps, type CardProps, type CellAlignment, type Column, type ColumnWidth, DataTable, type DataTableProps, DefaultFeatureFlags, Dialog, type DialogButtonProps, type DialogHeaderProps, type DialogHeight, type DialogProps, type DialogWidth, FeatureFlags, type FeatureFlagsProps, FilteredActionList, type FilteredActionListInputProps, FilteredActionListLoadingTypes, type FilteredActionListProps, Hidden, type HiddenProps, InlineMessage, type InlineMessageProps, IssueLabel, type IssueLabelProps, KeybindingHint, type KeybindingHintProps, NavList, type NavListDividerProps, type NavListGroupProps, type NavListItemProps, type NavListLeadingVisualProps, type NavListProps, type NavListSubNavProps, type NavListTrailingVisualProps, type ObjectPaths, PageHeader, type ActionsProps as PageHeaderActionsProps, type PageHeaderProps, type TitleProps as PageHeaderTitleProps, ScrollableRegion, type ScrollableRegionProps, SelectPanel, type SelectPanelMessageProps, type SelectPanelProps, type SelectPanelSecondaryActionProps, SkeletonAvatar, type SkeletonAvatarProps, SkeletonBox, type SkeletonBoxProps, SkeletonText, type SkeletonTextProps, SlotConfig, Stack, type StackItemProps, type StackProps, type TabListProps, type TabPanelProps, type TabProps, Table, type TableActionsProps, type TableBodyProps, type TableCellProps, type TableContainerProps, type TableGroupProps, type TableHeadProps, type TableHeaderProps, type TableProps, type TableRowProps, type TableSubtitleProps, type TableTitleProps, Tabs, type TabsProps, type TitleProps, Tooltip, type TooltipProps, TopicTag, type TopicTagGroupProps, type TopicTagProps, _default as UnderlinePanels, type PanelProps as UnderlinePanelsPanelProps, type UnderlinePanelsProps, type TabProps$1 as UnderlinePanelsTabProps, type UniqueRow, createColumnHelper, getAccessibleKeybindingHintString, useFeatureFlag, useOverflow, useSlots, useTab, useTabList, useTabPanel };
@@ -365,6 +365,12 @@
365
365
  "type": "AriaRole",
366
366
  "defaultValue": "",
367
367
  "description": "ARIA role describing the function of the list. `listbox` and `menu` are a common values."
368
+ },
369
+ {
370
+ "name": "disableItemGap",
371
+ "type": "boolean",
372
+ "description": "Disable the gap between items when this `ActionList` is rendered in a `NavList`.",
373
+ "defaultValue": "false"
368
374
  }
369
375
  ],
370
376
  "subcomponents": [
@@ -2739,15 +2745,7 @@
2739
2745
  },
2740
2746
  {
2741
2747
  "id": "experimental-components-datatable-features--with-groups",
2742
- "code": "() => {\n const titleId = React.useId()\n const [pageIndex, setPageIndex] = React.useState(0)\n const pageSize = 10\n const allRows = paginationData.flatMap((item) =>\n 'rows' in item ? item.rows : [item],\n )\n const pageRows = new Set(\n allRows\n .slice(pageIndex * pageSize, (pageIndex + 1) * pageSize)\n .map((row) => row.id),\n )\n // Count data rows, not headings, and preserve each item's position and group membership.\n const data = paginationData.flatMap(\n (item): DataTableData<PaginatedRepository> => {\n if ('rows' in item) {\n const rows = item.rows.filter((row) => pageRows.has(row.id))\n return rows.length > 0\n ? [\n {\n ...item,\n rows,\n },\n ]\n : []\n }\n return pageRows.has(item.id) ? [item] : []\n },\n )\n return (\n <Table.Container>\n <Table.Title as=\"h2\" id={titleId}>\n Paginated repositories by visibility\n </Table.Title>\n <DataTable\n aria-labelledby={titleId}\n data={data}\n columns={[\n {\n header: 'Name',\n field: 'name',\n rowHeader: true,\n sortBy: true,\n },\n {\n header: 'Visibility',\n field: 'visibility',\n },\n ]}\n />\n <Table.Pagination\n aria-label=\"Pagination for grouped repositories\"\n pageSize={pageSize}\n totalCount={allRows.length}\n onChange={({ pageIndex }) => setPageIndex(pageIndex)}\n />\n </Table.Container>\n )\n}"
2743
- },
2744
- {
2745
- "id": "experimental-components-datatable-features--with-sortable-groups",
2746
- "code": "() => (\n <Table.Container>\n <Table.Title as=\"h2\" id=\"sortable-repositories-by-visibility\">\n Sortable repositories by visibility\n </Table.Title>\n <DataTable\n aria-labelledby=\"sortable-repositories-by-visibility\"\n data={repoGroups}\n columns={sortableGroupedColumns}\n />\n </Table.Container>\n)"
2747
- },
2748
- {
2749
- "id": "experimental-components-table-features--with-groups",
2750
- "code": "() => {\n const titleId = React.useId()\n const [pageIndex, setPageIndex] = React.useState(0)\n const pageSize = 10\n const allRows = paginationData.flatMap((item) =>\n 'rows' in item ? item.rows : [item],\n )\n const pageRows = new Set(\n allRows\n .slice(pageIndex * pageSize, (pageIndex + 1) * pageSize)\n .map((row) => row.id),\n )\n // Count data rows, not headings, and preserve each item's position and group membership.\n const data = paginationData.flatMap(\n (item): DataTableData<PaginatedRepository> => {\n if ('rows' in item) {\n const rows = item.rows.filter((row) => pageRows.has(row.id))\n return rows.length > 0\n ? [\n {\n ...item,\n rows,\n },\n ]\n : []\n }\n return pageRows.has(item.id) ? [item] : []\n },\n )\n return (\n <Table.Container>\n <Table.Title as=\"h2\" id={titleId}>\n Paginated repositories by visibility\n </Table.Title>\n <DataTable\n aria-labelledby={titleId}\n data={data}\n columns={[\n {\n header: 'Name',\n field: 'name',\n rowHeader: true,\n sortBy: true,\n },\n {\n header: 'Visibility',\n field: 'visibility',\n },\n ]}\n />\n <Table.Pagination\n aria-label=\"Pagination for grouped repositories\"\n pageSize={pageSize}\n totalCount={allRows.length}\n onChange={({ pageIndex }) => setPageIndex(pageIndex)}\n />\n </Table.Container>\n )\n}"
2748
+ "code": "() => (\n <Table.Container>\n <Table.Title as=\"h2\" id=\"repositories-by-visibility\">\n Repositories by visibility\n </Table.Title>\n <Table\n aria-labelledby=\"repositories-by-visibility\"\n gridTemplateColumns=\"minmax(0, 1fr) auto\"\n >\n <Table.Head>\n <Table.Row>\n <Table.Header id={groupedColumnHeaderIds[0]}>Name</Table.Header>\n <Table.Header id={groupedColumnHeaderIds[1]}>Updated</Table.Header>\n </Table.Row>\n </Table.Head>\n {repoGroups.map((group) => (\n <Table.Group\n key={group.id}\n id={group.id}\n label={group.label}\n rowCount={group.repos.length}\n colSpan={groupedColumnHeaderIds.length}\n >\n {group.repos.map((repo) => (\n <Table.Row key={repo.id}>\n <Table.Cell scope=\"row\" headers={groupedColumnHeaderIds[0]}>\n {repo.name}\n </Table.Cell>\n <Table.Cell headers={groupedColumnHeaderIds[1]}>\n <RelativeTime date={new Date(repo.updatedAt)} />\n </Table.Cell>\n </Table.Row>\n ))}\n </Table.Group>\n ))}\n </Table>\n </Table.Container>\n)"
2751
2749
  }
2752
2750
  ],
2753
2751
  "importPath": "@primer/react/experimental",
@@ -2764,8 +2762,8 @@
2764
2762
  },
2765
2763
  {
2766
2764
  "name": "data",
2767
- "type": "Array<Data | DataTableRowGroup<Data>>",
2768
- "description": "Provide rows, row groups, or a mixture of both to render in the table, in display order."
2765
+ "type": "Array<Data>",
2766
+ "description": "Provide a collection of the rows which will be rendered inside of the table"
2769
2767
  },
2770
2768
  {
2771
2769
  "name": "columns",
@@ -4234,6 +4232,12 @@
4234
4232
  "defaultValue": "",
4235
4233
  "description": ""
4236
4234
  },
4235
+ {
4236
+ "name": "disableItemGap",
4237
+ "type": "boolean",
4238
+ "defaultValue": "false",
4239
+ "description": "Disable the gap between items when the item gap feature is enabled."
4240
+ },
4237
4241
  {
4238
4242
  "name": "ref",
4239
4243
  "type": "React.RefObject<HTMLElement>"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260915162741",
4
+ "version": "0.0.0-20260915174622",
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",