@primer/react 38.39.1-rc.99036c1d8 → 38.40.0-rc.37bd8a025
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 +11 -1
- package/dist/ActionList/List.js +83 -79
- package/dist/ActionList/index.d.ts +1 -0
- package/dist/ActionList/shared.d.ts +4 -0
- package/dist/DataTable/DataTable.d.ts +20 -20
- package/dist/DataTable/DataTable.js +41 -26
- package/dist/DataTable/TableGroup.js +95 -91
- package/dist/DataTable/index.d.ts +2 -2
- package/dist/DataTable/index.js +1 -1
- package/dist/DataTable/row.d.ts +24 -1
- package/dist/DataTable/useTable.js +156 -79
- package/dist/DataTable/utils.d.ts +4 -2
- package/dist/NavList/NavList.d.ts +2 -1
- package/dist/NavList/NavList.js +45 -38
- package/dist/TooltipV2/Tooltip.js +17 -7
- package/dist/experimental/index.d.ts +2 -2
- package/generated/components.json +27 -3
- package/package.json +1 -1
package/dist/NavList/NavList.js
CHANGED
|
@@ -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(
|
|
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] =
|
|
41
|
+
$[4] = disableItemGap;
|
|
42
|
+
$[5] = props;
|
|
41
43
|
} else {
|
|
42
44
|
ariaLabel = $[1];
|
|
43
45
|
ariaLabelledby = $[2];
|
|
44
46
|
children = $[3];
|
|
45
|
-
|
|
47
|
+
disableItemGap = $[4];
|
|
48
|
+
props = $[5];
|
|
46
49
|
}
|
|
47
50
|
let t1;
|
|
48
|
-
if ($[
|
|
51
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
49
52
|
t1 = { heading: Heading };
|
|
50
|
-
$[
|
|
51
|
-
} else t1 = $[
|
|
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 ($[
|
|
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
|
-
$[
|
|
61
|
-
$[
|
|
62
|
-
} else t2 = $[
|
|
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 ($[
|
|
69
|
+
if ($[9] !== heading || $[10] !== headingId) {
|
|
67
70
|
t3 = heading ? /*#__PURE__*/ React.cloneElement(heading, { id: headingId }) : null;
|
|
68
|
-
$[
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
} else t3 = $[
|
|
71
|
+
$[9] = heading;
|
|
72
|
+
$[10] = headingId;
|
|
73
|
+
$[11] = t3;
|
|
74
|
+
} else t3 = $[11];
|
|
72
75
|
let t4;
|
|
73
|
-
if ($[
|
|
76
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
74
77
|
t4 = { container: "NavList" };
|
|
75
|
-
$[
|
|
76
|
-
} else t4 = $[
|
|
78
|
+
$[12] = t4;
|
|
79
|
+
} else t4 = $[12];
|
|
77
80
|
let t5;
|
|
78
|
-
if ($[
|
|
81
|
+
if ($[13] !== childrenWithoutHeading || $[14] !== disableItemGap) {
|
|
79
82
|
t5 = /*#__PURE__*/ jsx(ActionListContainerContext.Provider, {
|
|
80
83
|
value: t4,
|
|
81
|
-
children: /*#__PURE__*/ jsx(ActionList, {
|
|
84
|
+
children: /*#__PURE__*/ jsx(ActionList, {
|
|
85
|
+
disableItemGap,
|
|
86
|
+
children: childrenWithoutHeading
|
|
87
|
+
})
|
|
82
88
|
});
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
|
|
89
|
+
$[13] = childrenWithoutHeading;
|
|
90
|
+
$[14] = disableItemGap;
|
|
91
|
+
$[15] = t5;
|
|
92
|
+
} else t5 = $[15];
|
|
86
93
|
let t6;
|
|
87
|
-
if ($[
|
|
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
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
} else t6 = $[
|
|
99
|
+
$[16] = headingLevel;
|
|
100
|
+
$[17] = t3;
|
|
101
|
+
$[18] = t5;
|
|
102
|
+
$[19] = t6;
|
|
103
|
+
} else t6 = $[19];
|
|
97
104
|
let t7;
|
|
98
|
-
if ($[
|
|
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
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
} else t7 = $[
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { reactMajorVersion } from "../utils/environment.js";
|
|
1
2
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
3
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
4
|
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
@@ -82,10 +83,14 @@ const emptyKeybindingHints = [];
|
|
|
82
83
|
const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
|
|
83
84
|
const tooltipId = useId$1(id);
|
|
84
85
|
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;
|
|
85
90
|
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
86
91
|
const triggerRef = useRef(null);
|
|
87
|
-
const mergedTriggerRef = useMergedRefs(triggerRef, forwardedRef);
|
|
88
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
92
|
+
const mergedTriggerRef = useMergedRefs(triggerRef, useMergedRefs(forwardedRef, childRef));
|
|
93
|
+
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : childRef);
|
|
89
94
|
const readTriggerRef = mergedRefEnabled ? triggerRef : providedOrCreatedRef;
|
|
90
95
|
const appliedTriggerRef = mergedRefEnabled ? mergedTriggerRef : providedOrCreatedRef;
|
|
91
96
|
const tooltipElRef = useRef(null);
|
|
@@ -95,7 +100,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
95
100
|
const { safeSetTimeout, safeClearTimeout } = useSafeTimeout();
|
|
96
101
|
const openTooltip = () => {
|
|
97
102
|
try {
|
|
98
|
-
if (tooltipElRef.current && readTriggerRef.current && tooltipElRef.current.hasAttribute("popover") && !tooltipElRef.current.matches(":popover-open") && !_privateDisableTooltip) {
|
|
103
|
+
if (tooltipElRef.current && readTriggerRef.current instanceof HTMLElement && tooltipElRef.current.hasAttribute("popover") && !tooltipElRef.current.matches(":popover-open") && !_privateDisableTooltip) {
|
|
99
104
|
const tooltip = tooltipElRef.current;
|
|
100
105
|
const trigger = readTriggerRef.current;
|
|
101
106
|
tooltip.showPopover();
|
|
@@ -131,15 +136,19 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
131
136
|
const value = useMemo(() => ({ tooltipId }), [tooltipId]);
|
|
132
137
|
useEffect(() => {
|
|
133
138
|
if (!tooltipElRef.current || !readTriggerRef.current) return;
|
|
134
|
-
const
|
|
135
|
-
const
|
|
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;
|
|
136
145
|
const hasInteractiveDescendant = Array.from(triggerChildren).some((child) => {
|
|
137
146
|
return child instanceof HTMLElement && isInteractive(child) || Array.from(child.childNodes).some((grandChild) => grandChild instanceof HTMLElement && isInteractive(grandChild));
|
|
138
147
|
});
|
|
139
148
|
!(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.");
|
|
140
149
|
if (type === "label") {
|
|
141
|
-
const hasAriaLabel =
|
|
142
|
-
const hasAriaLabelInChildren = Array.from(
|
|
150
|
+
const hasAriaLabel = trigger.hasAttribute("aria-label");
|
|
151
|
+
const hasAriaLabelInChildren = Array.from(trigger.childNodes).some((child) => child instanceof HTMLElement && child.hasAttribute("aria-label"));
|
|
143
152
|
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.");
|
|
144
153
|
}
|
|
145
154
|
if (typeof window !== "undefined") {
|
|
@@ -162,6 +171,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
162
171
|
const platform = usePlatform();
|
|
163
172
|
const hasAriaLabel = "aria-label" in rest;
|
|
164
173
|
const keybindingHints = Array.isArray(keybindingHint) ? keybindingHint : [keybindingHint];
|
|
174
|
+
if (isFragmentTrigger) return child;
|
|
165
175
|
return /*#__PURE__*/ jsx(TooltipContext.Provider, {
|
|
166
176
|
value,
|
|
167
177
|
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 { UniqueRow } from "../DataTable/row.js";
|
|
18
|
+
import { DataTableData, DataTableRowGroup, 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 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 };
|
|
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 };
|
|
@@ -212,6 +212,10 @@
|
|
|
212
212
|
"id": "components-actionlist-features--item-dividers",
|
|
213
213
|
"code": "() => (\n <ActionList showDividers>\n <ActionList.Item>Copy link</ActionList.Item>\n <ActionList.Item>Quote reply</ActionList.Item>\n <ActionList.Item>Edit comment</ActionList.Item>\n </ActionList>\n)"
|
|
214
214
|
},
|
|
215
|
+
{
|
|
216
|
+
"id": "components-actionlist-features--disable-item-gap",
|
|
217
|
+
"code": "() => (\n <FeatureFlags\n flags={{\n primer_react_action_list_item_gap: true,\n }}\n >\n <ActionList.ContainerContext.Provider\n value={{\n container: 'NavList',\n }}\n >\n <Heading as=\"h3\">Default item gap</Heading>\n <ActionList>\n <ActionList.Item>Copy link</ActionList.Item>\n <ActionList.Item>Quote reply</ActionList.Item>\n <ActionList.Item>Edit comment</ActionList.Item>\n </ActionList>\n\n <Heading as=\"h3\">Item gap disabled</Heading>\n <ActionList disableItemGap>\n <ActionList.Item>Copy link</ActionList.Item>\n <ActionList.Item>Quote reply</ActionList.Item>\n <ActionList.Item>Edit comment</ActionList.Item>\n </ActionList>\n </ActionList.ContainerContext.Provider>\n </FeatureFlags>\n)"
|
|
218
|
+
},
|
|
215
219
|
{
|
|
216
220
|
"id": "components-actionlist-features--single-divider",
|
|
217
221
|
"code": "() => (\n <ActionList>\n <ActionList.Item>Copy link</ActionList.Item>\n <ActionList.Item>Quote reply</ActionList.Item>\n <ActionList.Item>Edit comment</ActionList.Item>\n <ActionList.Divider />\n <ActionList.Item variant=\"danger\">Delete file</ActionList.Item>\n </ActionList>\n)"
|
|
@@ -365,6 +369,12 @@
|
|
|
365
369
|
"type": "AriaRole",
|
|
366
370
|
"defaultValue": "",
|
|
367
371
|
"description": "ARIA role describing the function of the list. `listbox` and `menu` are a common values."
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"name": "disableItemGap",
|
|
375
|
+
"type": "boolean",
|
|
376
|
+
"description": "Disable the gap between items when this `ActionList` is rendered in a `NavList`.",
|
|
377
|
+
"defaultValue": "false"
|
|
368
378
|
}
|
|
369
379
|
],
|
|
370
380
|
"subcomponents": [
|
|
@@ -2739,7 +2749,15 @@
|
|
|
2739
2749
|
},
|
|
2740
2750
|
{
|
|
2741
2751
|
"id": "experimental-components-datatable-features--with-groups",
|
|
2742
|
-
"code": "() =>
|
|
2752
|
+
"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}"
|
|
2753
|
+
},
|
|
2754
|
+
{
|
|
2755
|
+
"id": "experimental-components-datatable-features--with-sortable-groups",
|
|
2756
|
+
"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)"
|
|
2757
|
+
},
|
|
2758
|
+
{
|
|
2759
|
+
"id": "experimental-components-table-features--with-groups",
|
|
2760
|
+
"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
2761
|
}
|
|
2744
2762
|
],
|
|
2745
2763
|
"importPath": "@primer/react/experimental",
|
|
@@ -2756,8 +2774,8 @@
|
|
|
2756
2774
|
},
|
|
2757
2775
|
{
|
|
2758
2776
|
"name": "data",
|
|
2759
|
-
"type": "Array<Data
|
|
2760
|
-
"description": "Provide
|
|
2777
|
+
"type": "Array<Data | DataTableRowGroup<Data>>",
|
|
2778
|
+
"description": "Provide rows, row groups, or a mixture of both to render in the table, in display order."
|
|
2761
2779
|
},
|
|
2762
2780
|
{
|
|
2763
2781
|
"name": "columns",
|
|
@@ -4226,6 +4244,12 @@
|
|
|
4226
4244
|
"defaultValue": "",
|
|
4227
4245
|
"description": ""
|
|
4228
4246
|
},
|
|
4247
|
+
{
|
|
4248
|
+
"name": "disableItemGap",
|
|
4249
|
+
"type": "boolean",
|
|
4250
|
+
"defaultValue": "false",
|
|
4251
|
+
"description": "Disable the gap between items when the item gap feature is enabled."
|
|
4252
|
+
},
|
|
4229
4253
|
{
|
|
4230
4254
|
"name": "ref",
|
|
4231
4255
|
"type": "React.RefObject<HTMLElement>"
|
package/package.json
CHANGED