@primer/react 0.0.0-20260831205533 → 0.0.0-20260915162741

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.
Files changed (218) hide show
  1. package/CHANGELOG.md +39 -3
  2. package/dist/ActionBar/ActionBar.js +2 -2
  3. package/dist/ActionList/Description.js +3 -3
  4. package/dist/ActionList/Divider.js +2 -2
  5. package/dist/ActionList/Group.js +4 -4
  6. package/dist/ActionList/GroupHeadingTrailingAction.js +2 -2
  7. package/dist/ActionList/Heading.js +3 -3
  8. package/dist/ActionList/Item.js +4 -4
  9. package/dist/ActionList/List.js +3 -3
  10. package/dist/ActionList/Selection.js +2 -2
  11. package/dist/ActionList/TrailingAction.js +3 -3
  12. package/dist/ActionList/Visuals.js +3 -3
  13. package/dist/ActionMenu/ActionMenu.js +2 -2
  14. package/dist/AnchoredOverlay/AnchoredOverlay.js +3 -3
  15. package/dist/Autocomplete/Autocomplete.js +2 -2
  16. package/dist/Autocomplete/AutocompleteInput.js +1 -1
  17. package/dist/Autocomplete/AutocompleteMenu.js +3 -3
  18. package/dist/Autocomplete/AutocompleteOverlay.js +3 -3
  19. package/dist/Avatar/Avatar.js +3 -3
  20. package/dist/AvatarStack/AvatarStack.js +3 -3
  21. package/dist/Banner/Banner.js +3 -3
  22. package/dist/BaseStyles.js +2 -2
  23. package/dist/Blankslate/Blankslate.js +3 -3
  24. package/dist/BranchName/BranchName.js +2 -2
  25. package/dist/Breadcrumbs/Breadcrumbs.js +3 -3
  26. package/dist/Button/Button.js +2 -2
  27. package/dist/Button/{ButtonBase-b44e29d1.css → ButtonBase-faef2674.css} +2 -2
  28. package/dist/Button/ButtonBase-faef2674.css.map +1 -0
  29. package/dist/Button/ButtonBase.js +4 -4
  30. package/dist/Button/ButtonBase.module.css.js +1 -1
  31. package/dist/Button/IconButton.js +3 -3
  32. package/dist/Button/LinkButton.js +2 -2
  33. package/dist/ButtonGroup/ButtonGroup.js +3 -3
  34. package/dist/Card/Card.js +3 -3
  35. package/dist/Checkbox/Checkbox.js +2 -2
  36. package/dist/CheckboxGroup/CheckboxGroup.js +2 -2
  37. package/dist/CircleBadge/CircleBadge.js +2 -2
  38. package/dist/ConfirmationDialog/ConfirmationDialog.js +2 -2
  39. package/dist/CounterLabel/CounterLabel.js +3 -3
  40. package/dist/DataTable/DataTable.d.ts +20 -20
  41. package/dist/DataTable/DataTable.js +42 -27
  42. package/dist/DataTable/ErrorDialog.js +1 -1
  43. package/dist/DataTable/Pagination.js +5 -5
  44. package/dist/DataTable/Table-50e68700.css +2 -0
  45. package/dist/DataTable/Table-50e68700.css.map +1 -0
  46. package/dist/DataTable/Table.d.ts +1 -0
  47. package/dist/DataTable/Table.js +74 -44
  48. package/dist/DataTable/Table.module.css.js +7 -2
  49. package/dist/DataTable/TableGroup.d.ts +41 -0
  50. package/dist/DataTable/TableGroup.js +159 -0
  51. package/dist/DataTable/TableGroupContext.js +5 -0
  52. package/dist/DataTable/index.d.ts +4 -2
  53. package/dist/DataTable/index.js +2 -0
  54. package/dist/DataTable/row.d.ts +24 -1
  55. package/dist/DataTable/useTable.js +157 -80
  56. package/dist/DataTable/utils.d.ts +4 -2
  57. package/dist/Details/Details.js +3 -3
  58. package/dist/Dialog/Dialog.js +3 -3
  59. package/dist/FeatureFlags/DefaultFeatureFlags.js +1 -2
  60. package/dist/FeatureFlags/FeatureFlags.js +2 -2
  61. package/dist/FeatureFlags/useFeatureFlag.js +1 -1
  62. package/dist/FilteredActionList/FilteredActionList.js +2 -2
  63. package/dist/FilteredActionList/FilteredActionListInput.js +2 -2
  64. package/dist/FilteredActionList/FilteredActionListLoaders.js +1 -1
  65. package/dist/Flash/Flash.js +3 -3
  66. package/dist/FormControl/FormControl.js +4 -4
  67. package/dist/FormControl/FormControlCaption.js +2 -2
  68. package/dist/FormControl/FormControlLabel.js +1 -1
  69. package/dist/FormControl/FormControlLeadingVisual.js +1 -1
  70. package/dist/FormControl/_FormControlContext.js +1 -1
  71. package/dist/FormControl/_FormControlValidation.js +1 -1
  72. package/dist/Header/Header.js +3 -3
  73. package/dist/Heading/Heading.js +3 -3
  74. package/dist/Hidden/Hidden.js +2 -2
  75. package/dist/InlineMessage/InlineMessage.js +2 -2
  76. package/dist/KeybindingHint/KeybindingHint.js +3 -3
  77. package/dist/KeybindingHint/components/Chord.js +4 -4
  78. package/dist/KeybindingHint/components/Key.js +1 -1
  79. package/dist/KeybindingHint/components/Sequence.js +3 -3
  80. package/dist/Label/Label.js +3 -3
  81. package/dist/LabelGroup/LabelGroup.js +2 -2
  82. package/dist/Link/Link.js +3 -3
  83. package/dist/NavList/NavList.js +6 -6
  84. package/dist/Octicon/Octicon.js +2 -2
  85. package/dist/Overlay/Overlay.js +2 -2
  86. package/dist/PageHeader/PageHeader.js +4 -4
  87. package/dist/PageLayout/DragHandle.js +2 -2
  88. package/dist/PageLayout/PageLayout.js +3 -3
  89. package/dist/PageLayout/usePaneWidth.js +1 -1
  90. package/dist/Pagehead/Pagehead.js +2 -2
  91. package/dist/Pagination/Pagination.js +4 -4
  92. package/dist/Popover/Popover.js +3 -3
  93. package/dist/Portal/Portal.js +1 -1
  94. package/dist/ProgressBar/ProgressBar.js +3 -3
  95. package/dist/Radio/Radio.js +3 -3
  96. package/dist/RadioGroup/RadioGroup.js +1 -1
  97. package/dist/RelativeTime/RelativeTime.js +1 -1
  98. package/dist/ScrollableRegion/ScrollableRegion.js +3 -3
  99. package/dist/SegmentedControl/SegmentedControl-e68d4197.css +2 -0
  100. package/dist/SegmentedControl/SegmentedControl-e68d4197.css.map +1 -0
  101. package/dist/SegmentedControl/SegmentedControl.d.ts +5 -1
  102. package/dist/SegmentedControl/SegmentedControl.js +204 -167
  103. package/dist/SegmentedControl/SegmentedControl.module.css.js +8 -4
  104. package/dist/SegmentedControl/SegmentedControlAction.d.ts +12 -0
  105. package/dist/SegmentedControl/SegmentedControlAction.js +111 -0
  106. package/dist/SegmentedControl/SegmentedControlActionContext.js +5 -0
  107. package/dist/SegmentedControl/SegmentedControlButton.js +2 -2
  108. package/dist/SegmentedControl/SegmentedControlDivider.d.ts +9 -0
  109. package/dist/SegmentedControl/SegmentedControlDivider.js +24 -0
  110. package/dist/SegmentedControl/SegmentedControlIconButton.js +2 -2
  111. package/dist/SegmentedControl/index.d.ts +3 -1
  112. package/dist/Select/Select.js +3 -3
  113. package/dist/SelectPanel/SelectPanel.js +3 -3
  114. package/dist/SelectPanel/SelectPanelMessage.js +2 -2
  115. package/dist/SideNav.js +2 -2
  116. package/dist/Skeleton/SkeletonBox.js +3 -3
  117. package/dist/SkeletonAvatar/SkeletonAvatar.js +2 -2
  118. package/dist/SkeletonText/SkeletonText.js +2 -2
  119. package/dist/Spinner/Spinner.js +3 -3
  120. package/dist/SplitPageLayout/SplitPageLayout.js +1 -1
  121. package/dist/Stack/Stack.js +3 -3
  122. package/dist/StateLabel/StateLabel.js +3 -3
  123. package/dist/SubNav/SubNav.js +3 -3
  124. package/dist/TabNav/TabNav.js +3 -3
  125. package/dist/Text/Text.js +2 -2
  126. package/dist/TextInput/TextInput.js +5 -5
  127. package/dist/TextInputWithTokens/TextInputWithTokens.js +3 -3
  128. package/dist/Textarea/Textarea.js +4 -4
  129. package/dist/ThemeProvider.js +2 -2
  130. package/dist/Timeline/Timeline.js +3 -3
  131. package/dist/ToggleSwitch/ToggleSwitch.js +4 -4
  132. package/dist/Token/IssueLabelToken.js +3 -3
  133. package/dist/Token/Token.js +3 -3
  134. package/dist/Token/TokenBase.js +3 -3
  135. package/dist/Token/_RemoveTokenButton.js +1 -1
  136. package/dist/Token/_TokenTextContainer.js +2 -2
  137. package/dist/Tooltip/Tooltip.js +2 -2
  138. package/dist/TooltipV2/Tooltip.js +21 -11
  139. package/dist/TopicTag/TopicTag.js +2 -2
  140. package/dist/TopicTag/TopicTagGroup.js +2 -2
  141. package/dist/TreeView/TreeView.js +9 -9
  142. package/dist/TreeView/useRovingTabIndex.js +1 -1
  143. package/dist/TreeView/useTreeItemCache.js +1 -1
  144. package/dist/TreeView/useTypeahead.js +1 -1
  145. package/dist/Truncate/Truncate.js +2 -2
  146. package/dist/UnderlineNav/UnderlineNav.js +3 -3
  147. package/dist/UnderlineNav/UnderlineNavItem.js +2 -2
  148. package/dist/VisuallyHidden/VisuallyHidden.js +2 -2
  149. package/dist/_VisuallyHidden.js +2 -2
  150. package/dist/deprecated/ActionList/Divider.js +1 -1
  151. package/dist/deprecated/ActionList/Group.js +1 -1
  152. package/dist/deprecated/ActionList/Header.js +2 -2
  153. package/dist/deprecated/ActionList/Item.js +4 -4
  154. package/dist/deprecated/ActionList/List.js +3 -3
  155. package/dist/deprecated/ActionMenu.js +2 -2
  156. package/dist/deprecated/DialogV1/Dialog.js +4 -4
  157. package/dist/deprecated/FilteredSearch/FilteredSearch.js +2 -2
  158. package/dist/deprecated/UnderlineNav/UnderlineNav.js +3 -3
  159. package/dist/experimental/IssueLabel/IssueLabel.js +2 -2
  160. package/dist/experimental/SelectPanel2/SelectPanel.js +5 -5
  161. package/dist/experimental/Tabs/Tabs.js +23 -26
  162. package/dist/experimental/Tabs/useTab.js +1 -1
  163. package/dist/experimental/Tabs/useTabList.js +17 -21
  164. package/dist/experimental/Tabs/useTabPanel.js +1 -1
  165. package/dist/experimental/UnderlinePanels/UnderlinePanels.js +10 -15
  166. package/dist/experimental/index.d.ts +6 -5
  167. package/dist/experimental/index.js +1 -1
  168. package/dist/hooks/useDetails.js +1 -1
  169. package/dist/hooks/useDialog.js +1 -1
  170. package/dist/hooks/useMedia.js +1 -1
  171. package/dist/hooks/useMenuInitialFocus.js +1 -1
  172. package/dist/hooks/useMenuKeyboardNavigation.js +1 -1
  173. package/dist/hooks/useMergedRefs.js +1 -1
  174. package/dist/hooks/useMnemonics.js +1 -1
  175. package/dist/hooks/useOpenAndCloseFocus.js +1 -1
  176. package/dist/hooks/useOverflow.js +5 -5
  177. package/dist/hooks/useOverlay.js +1 -1
  178. package/dist/hooks/useProvidedStateOrCreate.js +1 -1
  179. package/dist/hooks/useRefObjectAsForwardedRef.js +1 -1
  180. package/dist/hooks/useRenderForcingRef.js +1 -1
  181. package/dist/hooks/useScrollFlash.js +1 -1
  182. package/dist/hooks/useSyncedState.js +1 -1
  183. package/dist/index.d.ts +5 -1
  184. package/dist/index.js +3 -1
  185. package/dist/internal/components/ButtonReset.js +2 -2
  186. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +4 -4
  187. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupCaption.js +3 -3
  188. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.js +3 -3
  189. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupValidation.js +2 -2
  190. package/dist/internal/components/ConditionalWrapper.js +1 -1
  191. package/dist/internal/components/InputLabel.js +2 -2
  192. package/dist/internal/components/InputValidation.js +2 -2
  193. package/dist/internal/components/OverflowObserverProvider.js +2 -2
  194. package/dist/internal/components/TextInputInnerAction.js +4 -4
  195. package/dist/internal/components/TextInputInnerVisualSlot.js +2 -2
  196. package/dist/internal/components/TextInputWrapper.js +3 -3
  197. package/dist/internal/components/ThemeProviderBase.js +1 -1
  198. package/dist/internal/components/UnderlineTabbedInterface.js +3 -3
  199. package/dist/internal/components/UnstyledTextInput.js +3 -3
  200. package/dist/internal/components/ValidationAnimationContainer.js +2 -2
  201. package/dist/internal/hooks/useEffectCallback.js +1 -1
  202. package/dist/internal/hooks/useEffectOnce.js +1 -1
  203. package/dist/internal/hooks/useOverflowObserver.js +1 -1
  204. package/dist/internal/hooks/useThemeProvider.js +1 -1
  205. package/dist/live-region/Announce.js +2 -2
  206. package/dist/live-region/AriaAlert.d.ts +1 -1
  207. package/dist/live-region/AriaAlert.js +1 -1
  208. package/dist/live-region/AriaStatus.js +1 -1
  209. package/dist/next/ThemeProvider.js +1 -1
  210. package/dist/utils/descendant-registry.js +2 -2
  211. package/dist/utils/react-compiler-runtime.js +32 -0
  212. package/generated/components.json +185 -10
  213. package/package.json +8 -8
  214. package/dist/Button/ButtonBase-b44e29d1.css.map +0 -1
  215. package/dist/DataTable/Table-7f5cb3e4.css +0 -2
  216. package/dist/DataTable/Table-7f5cb3e4.css.map +0 -1
  217. package/dist/SegmentedControl/SegmentedControl-4ef72733.css +0 -2
  218. package/dist/SegmentedControl/SegmentedControl-4ef72733.css.map +0 -1
@@ -1,18 +1,23 @@
1
+ import { c } from "../utils/react-compiler-runtime.js";
2
+ import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
1
3
  import { isSlot } from "../utils/is-slot.js";
4
+ import { useSlots } from "../hooks/useSlots.js";
2
5
  import { getResponsiveAttributes } from "../internal/utils/getResponsiveAttributes.js";
3
6
  import { ActionList } from "../ActionList/index.js";
4
7
  import { ActionMenu } from "../ActionMenu/ActionMenu.js";
5
8
  import SegmentedControl_module_css_default from "./SegmentedControl.module.css.js";
6
9
  import SegmentedControlButton from "./SegmentedControlButton.js";
7
10
  import { SegmentedControlIconButton } from "./SegmentedControlIconButton.js";
8
- import { c } from "react-compiler-runtime";
9
- import { clsx } from "clsx";
10
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ import { SegmentedControlActionContext } from "./SegmentedControlActionContext.js";
12
+ import SegmentedControlAction from "./SegmentedControlAction.js";
13
+ import SegmentedControlDivider from "./SegmentedControlDivider.js";
11
14
  import React, { useRef, useState } from "react";
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ import { clsx } from "clsx";
12
17
  import { isElement } from "react-is";
13
18
  //#region src/SegmentedControl/SegmentedControl.tsx
14
19
  const Root = (t0) => {
15
- const $ = c(54);
20
+ const $ = c(39);
16
21
  let ariaLabel;
17
22
  let ariaLabelledby;
18
23
  let children;
@@ -48,207 +53,239 @@ const Root = (t0) => {
48
53
  const variant = t1 === void 0 ? "default" : t1;
49
54
  const segmentedControlContainerRef = useRef(null);
50
55
  let t2;
51
- if ($[10] !== children || $[11] !== onChange) {
52
- t2 = onChange === void 0 || React.Children.toArray(children).some(_temp);
53
- $[10] = children;
54
- $[11] = onChange;
55
- $[12] = t2;
56
- } else t2 = $[12];
57
- const isUncontrolled = t2;
58
- let t3;
59
- if ($[13] !== children) {
60
- const selectedSegments = React.Children.toArray(children).map(_temp2);
61
- t3 = selectedSegments.some(_temp3) ? selectedSegments.indexOf(true) : 0;
62
- $[13] = children;
63
- $[14] = t3;
64
- } else t3 = $[14];
65
- const selectedIndexExternal = t3;
56
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
57
+ t2 = { action: SegmentedControlAction };
58
+ $[10] = t2;
59
+ } else t2 = $[10];
60
+ const [slots, segmentChildren] = useSlots(children, t2);
61
+ const actionChild = slots.action;
62
+ const segments = segmentChildren.filter(_temp);
63
+ const segmentIndices = new Map(segments.map(_temp2));
64
+ const segmentCount = segments.length;
65
+ const previousSegmentCount = useRef(segmentCount);
66
+ useIsomorphicLayoutEffect(() => {
67
+ if (previousSegmentCount.current === segmentCount) return;
68
+ const segmentedControl = segmentedControlContainerRef.current;
69
+ segmentedControl === null || segmentedControl === void 0 || segmentedControl.setAttribute("data-disable-knob-transition", "");
70
+ previousSegmentCount.current = segmentCount;
71
+ const animationFrame = requestAnimationFrame(() => {
72
+ segmentedControl === null || segmentedControl === void 0 || segmentedControl.removeAttribute("data-disable-knob-transition");
73
+ });
74
+ return () => cancelAnimationFrame(animationFrame);
75
+ }, [segmentCount]);
76
+ const isUncontrolled = onChange === void 0 || segments.some(_temp3);
77
+ const selectedSegments = segments.map(_temp4);
78
+ const selectedIndexExternal = selectedSegments.some(_temp5) ? selectedSegments.indexOf(true) : 0;
66
79
  const [selectedIndexInternalState, setSelectedIndexInternalState] = useState(selectedIndexExternal);
67
80
  const selectedIndex = isUncontrolled ? selectedIndexInternalState : selectedIndexExternal;
68
- let hasDropdownVariant;
81
+ const selectedChild = /*#__PURE__*/ React.isValidElement(segments[selectedIndex]) ? segments[selectedIndex] : void 0;
82
+ const getChildIcon = _temp6;
83
+ const getChildText = _temp7;
84
+ if (!ariaLabel && !ariaLabelledby) console.warn("Use the `aria-label` or `aria-labelledby` prop to provide an accessible label for assistive technologies");
85
+ const responsiveVariant = typeof variant === "object" ? variant : void 0;
86
+ let t3;
87
+ if ($[11] !== responsiveVariant) {
88
+ t3 = responsiveVariant ? Object.values(responsiveVariant).includes("dropdown") : false;
89
+ $[11] = responsiveVariant;
90
+ $[12] = t3;
91
+ } else t3 = $[12];
92
+ const hasDropdownVariant = t3;
93
+ const dropdownContent = hasDropdownVariant && /*#__PURE__*/ jsx("div", {
94
+ className: SegmentedControl_module_css_default.DropdownContainer,
95
+ ...getResponsiveAttributes("variant", variant),
96
+ children: /*#__PURE__*/ jsxs(ActionMenu, { children: [/*#__PURE__*/ jsx(ActionMenu.Button, {
97
+ "aria-label": ariaLabel && `${getChildText(selectedChild)}, ${ariaLabel}`,
98
+ leadingVisual: getChildIcon(selectedChild),
99
+ children: getChildText(selectedChild)
100
+ }), /*#__PURE__*/ jsx(ActionMenu.Overlay, {
101
+ "aria-labelledby": ariaLabelledby,
102
+ children: /*#__PURE__*/ jsxs(ActionList, {
103
+ selectionVariant: "single",
104
+ children: [segmentChildren.map((child_2, index_0) => {
105
+ var _segmentIndices$get;
106
+ if (/*#__PURE__*/ React.isValidElement(child_2) && isSlot(child_2, SegmentedControlDivider)) {
107
+ var _child_2$key;
108
+ return /*#__PURE__*/ jsx(ActionList.Divider, {
109
+ className: child_2.props.className,
110
+ style: child_2.props.style
111
+ }, (_child_2$key = child_2.key) !== null && _child_2$key !== void 0 ? _child_2$key : `segmented-control-divider-${index_0}`);
112
+ }
113
+ const ChildIcon = getChildIcon(child_2);
114
+ if (!/*#__PURE__*/ React.isValidElement(child_2)) return null;
115
+ const segmentIndex = (_segmentIndices$get = segmentIndices.get(child_2)) !== null && _segmentIndices$get !== void 0 ? _segmentIndices$get : -1;
116
+ return /*#__PURE__*/ jsxs(ActionList.Item, {
117
+ selected: segmentIndex === selectedIndex,
118
+ onSelect: (event) => {
119
+ isUncontrolled && setSelectedIndexInternalState(segmentIndex);
120
+ onChange && onChange(segmentIndex);
121
+ child_2.props.onClick && child_2.props.onClick(event);
122
+ },
123
+ children: [
124
+ ChildIcon,
125
+ " ",
126
+ getChildText(child_2)
127
+ ]
128
+ }, `segmented-control-action-btn-${index_0}`);
129
+ }), actionChild && /*#__PURE__*/ jsx(SegmentedControlActionContext.Provider, {
130
+ value: "menu",
131
+ children: actionChild
132
+ })]
133
+ })
134
+ })] })
135
+ });
69
136
  let t4;
70
- if ($[15] !== ariaLabel || $[16] !== ariaLabelledby || $[17] !== children || $[18] !== isUncontrolled || $[19] !== onChange || $[20] !== selectedIndex || $[21] !== variant) {
71
- const selectedChild = /*#__PURE__*/ React.isValidElement(React.Children.toArray(children)[selectedIndex]) ? React.Children.toArray(children)[selectedIndex] : void 0;
72
- const getChildIcon = _temp4;
73
- const getChildText = _temp5;
74
- if (!ariaLabel && !ariaLabelledby) console.warn("Use the `aria-label` or `aria-labelledby` prop to provide an accessible label for assistive technologies");
75
- const responsiveVariant = typeof variant === "object" ? variant : void 0;
76
- let t5;
77
- if ($[24] !== responsiveVariant) {
78
- t5 = responsiveVariant ? Object.values(responsiveVariant).includes("dropdown") : false;
79
- $[24] = responsiveVariant;
80
- $[25] = t5;
81
- } else t5 = $[25];
82
- hasDropdownVariant = t5;
83
- t4 = hasDropdownVariant && /*#__PURE__*/ jsx("div", {
84
- className: SegmentedControl_module_css_default.DropdownContainer,
85
- ...getResponsiveAttributes("variant", variant),
86
- children: /*#__PURE__*/ jsxs(ActionMenu, { children: [/*#__PURE__*/ jsx(ActionMenu.Button, {
87
- "aria-label": ariaLabel && `${getChildText(selectedChild)}, ${ariaLabel}`,
88
- leadingVisual: getChildIcon(selectedChild),
89
- children: getChildText(selectedChild)
90
- }), /*#__PURE__*/ jsx(ActionMenu.Overlay, {
91
- "aria-labelledby": ariaLabelledby,
92
- children: /*#__PURE__*/ jsx(ActionList, {
93
- selectionVariant: "single",
94
- children: React.Children.map(children, (child_1, index) => {
95
- const ChildIcon = getChildIcon(child_1);
96
- if (!/*#__PURE__*/ React.isValidElement(child_1)) return null;
97
- return /*#__PURE__*/ jsxs(ActionList.Item, {
98
- selected: index === selectedIndex,
99
- onSelect: (event) => {
100
- isUncontrolled && setSelectedIndexInternalState(index);
101
- onChange && onChange(index);
102
- child_1.props.onClick && child_1.props.onClick(event);
103
- },
104
- children: [
105
- ChildIcon,
106
- " ",
107
- getChildText(child_1)
108
- ]
109
- }, `segmented-control-action-btn-${index}`);
110
- })
111
- })
112
- })] })
113
- });
114
- $[15] = ariaLabel;
115
- $[16] = ariaLabelledby;
116
- $[17] = children;
117
- $[18] = isUncontrolled;
118
- $[19] = onChange;
119
- $[20] = selectedIndex;
120
- $[21] = variant;
121
- $[22] = hasDropdownVariant;
122
- $[23] = t4;
123
- } else {
124
- hasDropdownVariant = $[22];
125
- t4 = $[23];
126
- }
127
- const dropdownContent = t4;
137
+ if ($[13] !== className) {
138
+ t4 = clsx(SegmentedControl_module_css_default.SegmentedControl, className);
139
+ $[13] = className;
140
+ $[14] = t4;
141
+ } else t4 = $[14];
128
142
  let t5;
129
- if ($[26] !== className) {
130
- t5 = clsx(SegmentedControl_module_css_default.SegmentedControl, className);
131
- $[26] = className;
132
- $[27] = t5;
133
- } else t5 = $[27];
143
+ if ($[15] !== fullWidth) {
144
+ t5 = getResponsiveAttributes("full-width", fullWidth);
145
+ $[15] = fullWidth;
146
+ $[16] = t5;
147
+ } else t5 = $[16];
134
148
  let t6;
135
- if ($[28] !== fullWidth) {
136
- t6 = getResponsiveAttributes("full-width", fullWidth);
137
- $[28] = fullWidth;
138
- $[29] = t6;
139
- } else t6 = $[29];
140
- let t7;
141
- if ($[30] !== variant) {
142
- t7 = getResponsiveAttributes("variant", variant);
143
- $[30] = variant;
144
- $[31] = t7;
145
- } else t7 = $[31];
146
- let t8;
147
- if ($[32] !== children || $[33] !== isUncontrolled || $[34] !== onChange || $[35] !== selectedIndex) {
148
- let t9;
149
- if ($[37] !== isUncontrolled || $[38] !== onChange || $[39] !== selectedIndex) {
150
- t9 = (child_2, index_0) => {
151
- if (!/*#__PURE__*/ React.isValidElement(child_2)) return null;
152
- const sharedChildProps = {
153
- onClick: onChange ? (event_0) => {
154
- if (!(child_2.props.disabled === true || child_2.props["aria-disabled"] === "true" || child_2.props["aria-disabled"] === true)) {
155
- onChange(index_0);
156
- isUncontrolled && setSelectedIndexInternalState(index_0);
157
- child_2.props.onClick && child_2.props.onClick(event_0);
158
- }
159
- } : (event_1) => {
160
- if (!(child_2.props.disabled === true || child_2.props["aria-disabled"] === "true" || child_2.props["aria-disabled"] === true)) {
161
- child_2.props.onClick && child_2.props.onClick(event_1);
162
- isUncontrolled && setSelectedIndexInternalState(index_0);
163
- }
164
- },
165
- selected: index_0 === selectedIndex,
166
- style: {
167
- "--separator-color": index_0 === selectedIndex || index_0 === selectedIndex - 1 ? "transparent" : "var(--borderColor-default)",
168
- ...child_2.props.style
169
- }
170
- };
171
- return /*#__PURE__*/ React.cloneElement(child_2, sharedChildProps);
172
- };
173
- $[37] = isUncontrolled;
174
- $[38] = onChange;
175
- $[39] = selectedIndex;
176
- $[40] = t9;
177
- } else t9 = $[40];
178
- t8 = React.Children.map(children, t9);
179
- $[32] = children;
180
- $[33] = isUncontrolled;
181
- $[34] = onChange;
182
- $[35] = selectedIndex;
183
- $[36] = t8;
184
- } else t8 = $[36];
149
+ if ($[17] !== variant) {
150
+ t6 = getResponsiveAttributes("variant", variant);
151
+ $[17] = variant;
152
+ $[18] = t6;
153
+ } else t6 = $[18];
154
+ const t7 = "SegmentedControl";
155
+ const t8 = segmentChildren.map((child_3, index_1) => {
156
+ var _segmentIndices$get2, _child_3$key2;
157
+ if (/*#__PURE__*/ React.isValidElement(child_3) && isSlot(child_3, SegmentedControlDivider)) {
158
+ var _child_3$key;
159
+ return /*#__PURE__*/ React.cloneElement(child_3, { key: (_child_3$key = child_3.key) !== null && _child_3$key !== void 0 ? _child_3$key : `segmented-control-divider-${index_1}` });
160
+ }
161
+ if (!/*#__PURE__*/ React.isValidElement(child_3)) return null;
162
+ const segmentIndex_0 = (_segmentIndices$get2 = segmentIndices.get(child_3)) !== null && _segmentIndices$get2 !== void 0 ? _segmentIndices$get2 : -1;
163
+ const sharedChildProps = {
164
+ onClick: onChange ? (event_0) => {
165
+ if (!(child_3.props.disabled === true || child_3.props["aria-disabled"] === "true" || child_3.props["aria-disabled"] === true)) {
166
+ onChange(segmentIndex_0);
167
+ isUncontrolled && setSelectedIndexInternalState(segmentIndex_0);
168
+ child_3.props.onClick && child_3.props.onClick(event_0);
169
+ }
170
+ } : (event_1) => {
171
+ if (!(child_3.props.disabled === true || child_3.props["aria-disabled"] === "true" || child_3.props["aria-disabled"] === true)) {
172
+ child_3.props.onClick && child_3.props.onClick(event_1);
173
+ isUncontrolled && setSelectedIndexInternalState(segmentIndex_0);
174
+ }
175
+ },
176
+ selected: segmentIndex_0 === selectedIndex,
177
+ style: {
178
+ "--separator-color": segmentIndex_0 === selectedIndex || segmentIndex_0 === selectedIndex - 1 ? "transparent" : "var(--borderColor-default)",
179
+ ...child_3.props.style
180
+ }
181
+ };
182
+ return /*#__PURE__*/ React.cloneElement(child_3, {
183
+ key: (_child_3$key2 = child_3.key) !== null && _child_3$key2 !== void 0 ? _child_3$key2 : `segmented-control-item-${index_1}`,
184
+ ...sharedChildProps
185
+ });
186
+ });
185
187
  let t9;
186
- if ($[41] !== ariaLabel || $[42] !== ariaLabelledby || $[43] !== rest || $[44] !== size || $[45] !== t5 || $[46] !== t6 || $[47] !== t7 || $[48] !== t8) {
188
+ if ($[19] !== ariaLabel || $[20] !== ariaLabelledby || $[21] !== rest || $[22] !== size || $[23] !== t4 || $[24] !== t5 || $[25] !== t6 || $[26] !== t8) {
187
189
  t9 = /*#__PURE__*/ jsx("ul", {
188
190
  "aria-label": ariaLabel,
189
191
  "aria-labelledby": ariaLabelledby,
190
192
  ref: segmentedControlContainerRef,
191
- className: t5,
193
+ className: t4,
194
+ ...t5,
192
195
  ...t6,
193
- ...t7,
194
196
  "data-size": size,
195
197
  ...rest,
196
- "data-component": "SegmentedControl",
198
+ "data-component": t7,
197
199
  children: t8
198
200
  });
199
- $[41] = ariaLabel;
200
- $[42] = ariaLabelledby;
201
- $[43] = rest;
202
- $[44] = size;
203
- $[45] = t5;
204
- $[46] = t6;
205
- $[47] = t7;
206
- $[48] = t8;
207
- $[49] = t9;
208
- } else t9 = $[49];
201
+ $[19] = ariaLabel;
202
+ $[20] = ariaLabelledby;
203
+ $[21] = rest;
204
+ $[22] = size;
205
+ $[23] = t4;
206
+ $[24] = t5;
207
+ $[25] = t6;
208
+ $[26] = t8;
209
+ $[27] = t9;
210
+ } else t9 = $[27];
209
211
  const segmentedControlContent = t9;
210
212
  let t10;
211
- if ($[50] !== dropdownContent || $[51] !== hasDropdownVariant || $[52] !== segmentedControlContent) {
212
- t10 = hasDropdownVariant ? /*#__PURE__*/ jsxs(Fragment, { children: [dropdownContent, segmentedControlContent] }) : segmentedControlContent;
213
- $[50] = dropdownContent;
214
- $[51] = hasDropdownVariant;
215
- $[52] = segmentedControlContent;
216
- $[53] = t10;
217
- } else t10 = $[53];
218
- return t10;
213
+ if ($[28] !== actionChild || $[29] !== variant) {
214
+ t10 = actionChild && /*#__PURE__*/ jsx("div", {
215
+ className: SegmentedControl_module_css_default.InlineAction,
216
+ ...getResponsiveAttributes("variant", variant),
217
+ children: /*#__PURE__*/ jsx(SegmentedControlActionContext.Provider, {
218
+ value: "inline",
219
+ children: actionChild
220
+ })
221
+ });
222
+ $[28] = actionChild;
223
+ $[29] = variant;
224
+ $[30] = t10;
225
+ } else t10 = $[30];
226
+ const inlineActionContent = t10;
227
+ let t11;
228
+ if ($[31] !== actionChild || $[32] !== dropdownContent || $[33] !== fullWidth || $[34] !== hasDropdownVariant || $[35] !== inlineActionContent || $[36] !== segmentedControlContent || $[37] !== size) {
229
+ t11 = hasDropdownVariant || actionChild ? /*#__PURE__*/ jsxs("div", {
230
+ className: SegmentedControl_module_css_default.DropdownGroup,
231
+ "data-size": size,
232
+ ...getResponsiveAttributes("full-width", fullWidth),
233
+ children: [
234
+ dropdownContent,
235
+ segmentedControlContent,
236
+ inlineActionContent
237
+ ]
238
+ }) : segmentedControlContent;
239
+ $[31] = actionChild;
240
+ $[32] = dropdownContent;
241
+ $[33] = fullWidth;
242
+ $[34] = hasDropdownVariant;
243
+ $[35] = inlineActionContent;
244
+ $[36] = segmentedControlContent;
245
+ $[37] = size;
246
+ $[38] = t11;
247
+ } else t11 = $[38];
248
+ return t11;
219
249
  };
220
250
  Root.displayName = "SegmentedControl";
221
251
  const SegmentedControl = Object.assign(Root, {
222
252
  Button: SegmentedControlButton,
223
- IconButton: SegmentedControlIconButton
253
+ IconButton: SegmentedControlIconButton,
254
+ Divider: SegmentedControlDivider,
255
+ Action: SegmentedControlAction
224
256
  });
225
257
  function _temp(child) {
226
- return /*#__PURE__*/ React.isValidElement(child) && child.props.defaultSelected !== void 0;
258
+ return /*#__PURE__*/ React.isValidElement(child) && !isSlot(child, SegmentedControlDivider);
259
+ }
260
+ function _temp2(segment, index) {
261
+ return [segment, index];
227
262
  }
228
- function _temp2(child_0) {
229
- return /*#__PURE__*/ React.isValidElement(child_0) && (child_0.props.defaultSelected || child_0.props.selected);
263
+ function _temp3(child_0) {
264
+ return /*#__PURE__*/ React.isValidElement(child_0) && child_0.props.defaultSelected !== void 0;
230
265
  }
231
- function _temp3(isSelected) {
266
+ function _temp4(child_1) {
267
+ return /*#__PURE__*/ React.isValidElement(child_1) && (child_1.props.defaultSelected || child_1.props.selected);
268
+ }
269
+ function _temp5(isSelected) {
232
270
  return isSelected;
233
271
  }
234
- function _temp4(childArg) {
272
+ function _temp6(childArg) {
235
273
  if (/*#__PURE__*/ React.isValidElement(childArg) && (childArg.type === SegmentedControlButton || isSlot(childArg, SegmentedControlButton))) {
236
274
  var _childArg$props$leadi;
237
275
  const leadingVisual = (_childArg$props$leadi = childArg.props.leadingVisual) !== null && _childArg$props$leadi !== void 0 ? _childArg$props$leadi : childArg.props.leadingIcon;
238
276
  if (leadingVisual) {
239
277
  if (isElement(leadingVisual)) return leadingVisual;
240
- else return /*#__PURE__*/ jsx(leadingVisual, {});
278
+ return /*#__PURE__*/ jsx(leadingVisual, {});
241
279
  }
242
280
  }
243
281
  if (/*#__PURE__*/ React.isValidElement(childArg) && (childArg.type === SegmentedControlIconButton || isSlot(childArg, SegmentedControlIconButton))) {
244
- if (isElement(childArg.props.icon)) {} else {
245
- const Icon = childArg.props.icon;
246
- return /*#__PURE__*/ jsx(Icon, {});
247
- }
282
+ if (isElement(childArg.props.icon)) return childArg.props.icon;
283
+ const Icon = childArg.props.icon;
284
+ return /*#__PURE__*/ jsx(Icon, {});
248
285
  }
249
286
  return null;
250
287
  }
251
- function _temp5(childArg_0) {
288
+ function _temp7(childArg_0) {
252
289
  if (/*#__PURE__*/ React.isValidElement(childArg_0) && (childArg_0.type === SegmentedControlButton || isSlot(childArg_0, SegmentedControlButton))) return childArg_0.props.children;
253
290
  return /*#__PURE__*/ React.isValidElement(childArg_0) ? childArg_0.props["aria-label"] : null;
254
291
  }
@@ -1,14 +1,18 @@
1
- import "./SegmentedControl-4ef72733.css";
1
+ import "./SegmentedControl-e68d4197.css";
2
2
  //#region src/SegmentedControl/SegmentedControl.module.css.js
3
3
  var SegmentedControl_module_css_default = {
4
4
  "SegmentedControl": "prc-SegmentedControl-SegmentedControl-lqIXp",
5
+ "Item": "prc-SegmentedControl-Item-tSCQh",
6
+ "Button": "prc-SegmentedControl-Button-E48xz",
7
+ "Content": "prc-SegmentedControl-Content-1COlk",
5
8
  "Text": "prc-SegmentedControl-Text-7S2y2",
9
+ "DropdownGroup": "prc-SegmentedControl-DropdownGroup-9SmpX",
10
+ "InlineAction": "prc-SegmentedControl-InlineAction-4qmw0",
6
11
  "DropdownContainer": "prc-SegmentedControl-DropdownContainer-ZaPMn",
7
- "Item": "prc-SegmentedControl-Item-tSCQh",
8
12
  "Counter": "prc-SegmentedControl-Counter-GmZOI",
9
- "Button": "prc-SegmentedControl-Button-E48xz",
13
+ "ActionItem": "prc-SegmentedControl-ActionItem-2V1ou",
14
+ "ActionButton": "prc-SegmentedControl-ActionButton-Q5fnw",
10
15
  "IconButton": "prc-SegmentedControl-IconButton-tlzDE",
11
- "Content": "prc-SegmentedControl-Content-1COlk",
12
16
  "LeadingIcon": "prc-SegmentedControl-LeadingIcon-74n5s"
13
17
  };
14
18
  //#endregion
@@ -0,0 +1,12 @@
1
+ import { ElementType } from "react";
2
+
3
+ //#region src/SegmentedControl/SegmentedControlAction.d.ts
4
+ interface SegmentedControlActionProps {
5
+ label: string;
6
+ icon: ElementType;
7
+ onClick?: () => void;
8
+ disabled?: boolean;
9
+ loading?: boolean;
10
+ }
11
+ //#endregion
12
+ export { SegmentedControlActionProps };
@@ -0,0 +1,111 @@
1
+ import { c } from "../utils/react-compiler-runtime.js";
2
+ import { IconButton } from "../Button/IconButton.js";
3
+ import { ActionList } from "../ActionList/index.js";
4
+ import SegmentedControl_module_css_default from "./SegmentedControl.module.css.js";
5
+ import { SegmentedControlActionContext } from "./SegmentedControlActionContext.js";
6
+ import { useContext } from "react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/SegmentedControl/SegmentedControlAction.tsx
9
+ const SegmentedControlMenuAction = (t0) => {
10
+ const $ = c(6);
11
+ let children;
12
+ let props;
13
+ if ($[0] !== t0) {
14
+ ({children, ...props} = t0);
15
+ $[0] = t0;
16
+ $[1] = children;
17
+ $[2] = props;
18
+ } else {
19
+ children = $[1];
20
+ props = $[2];
21
+ }
22
+ let t1;
23
+ if ($[3] !== children || $[4] !== props) {
24
+ t1 = /*#__PURE__*/ jsx("div", {
25
+ ...props,
26
+ "data-component": "SegmentedControl.Action",
27
+ children
28
+ });
29
+ $[3] = children;
30
+ $[4] = props;
31
+ $[5] = t1;
32
+ } else t1 = $[5];
33
+ return t1;
34
+ };
35
+ const SegmentedControlAction = (props) => {
36
+ const $ = c(19);
37
+ const { disabled, icon: Icon, label, loading, onClick } = props;
38
+ if (useContext(SegmentedControlActionContext) === "menu") {
39
+ let t0;
40
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
41
+ t0 = /*#__PURE__*/ jsx(ActionList.Divider, {});
42
+ $[0] = t0;
43
+ } else t0 = $[0];
44
+ let t1;
45
+ if ($[1] !== onClick) {
46
+ t1 = (event) => {
47
+ event.preventDefault();
48
+ onClick === null || onClick === void 0 || onClick();
49
+ };
50
+ $[1] = onClick;
51
+ $[2] = t1;
52
+ } else t1 = $[2];
53
+ let t2;
54
+ if ($[3] !== Icon) {
55
+ t2 = /*#__PURE__*/ jsx(ActionList.LeadingVisual, { children: /*#__PURE__*/ jsx(Icon, {}) });
56
+ $[3] = Icon;
57
+ $[4] = t2;
58
+ } else t2 = $[4];
59
+ let t3;
60
+ if ($[5] !== disabled || $[6] !== label || $[7] !== loading || $[8] !== t1 || $[9] !== t2) {
61
+ t3 = /*#__PURE__*/ jsxs(Fragment$1, { children: [t0, /*#__PURE__*/ jsxs(ActionList.Item, {
62
+ role: "menuitem",
63
+ disabled,
64
+ loading,
65
+ _PrivateItemWrapper: SegmentedControlMenuAction,
66
+ onSelect: t1,
67
+ children: [t2, label]
68
+ })] });
69
+ $[5] = disabled;
70
+ $[6] = label;
71
+ $[7] = loading;
72
+ $[8] = t1;
73
+ $[9] = t2;
74
+ $[10] = t3;
75
+ } else t3 = $[10];
76
+ return t3;
77
+ }
78
+ let t0;
79
+ if ($[11] !== onClick) {
80
+ t0 = () => onClick === null || onClick === void 0 ? void 0 : onClick();
81
+ $[11] = onClick;
82
+ $[12] = t0;
83
+ } else t0 = $[12];
84
+ let t1;
85
+ if ($[13] !== Icon || $[14] !== disabled || $[15] !== label || $[16] !== loading || $[17] !== t0) {
86
+ t1 = /*#__PURE__*/ jsx("div", {
87
+ className: SegmentedControl_module_css_default.ActionItem,
88
+ "data-component": "SegmentedControl.Action",
89
+ children: /*#__PURE__*/ jsx(IconButton, {
90
+ "aria-label": label,
91
+ className: SegmentedControl_module_css_default.ActionButton,
92
+ disabled,
93
+ icon: Icon,
94
+ loading,
95
+ onClick: t0,
96
+ variant: "invisible"
97
+ })
98
+ });
99
+ $[13] = Icon;
100
+ $[14] = disabled;
101
+ $[15] = label;
102
+ $[16] = loading;
103
+ $[17] = t0;
104
+ $[18] = t1;
105
+ } else t1 = $[18];
106
+ return t1;
107
+ };
108
+ SegmentedControlAction.displayName = "SegmentedControl.Action";
109
+ SegmentedControlAction.__SLOT__ = Symbol("SegmentedControl.Action");
110
+ //#endregion
111
+ export { SegmentedControlAction as default };
@@ -0,0 +1,5 @@
1
+ import { createContext } from "react";
2
+ //#region src/SegmentedControl/SegmentedControlActionContext.ts
3
+ const SegmentedControlActionContext = /*#__PURE__*/ createContext("inline");
4
+ //#endregion
5
+ export { SegmentedControlActionContext };
@@ -1,8 +1,8 @@
1
+ import { c } from "../utils/react-compiler-runtime.js";
1
2
  import CounterLabel from "../CounterLabel/CounterLabel.js";
2
3
  import SegmentedControl_module_css_default from "./SegmentedControl.module.css.js";
3
- import { c } from "react-compiler-runtime";
4
- import { clsx } from "clsx";
5
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { clsx } from "clsx";
6
6
  import { isElement } from "react-is";
7
7
  //#region src/SegmentedControl/SegmentedControlButton.tsx
8
8
  const SegmentedControlButton = (t0) => {
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+
3
+ //#region src/SegmentedControl/SegmentedControlDivider.d.ts
4
+ type SegmentedControlDividerProps = {
5
+ className?: string;
6
+ style?: React.CSSProperties;
7
+ };
8
+ //#endregion
9
+ export { SegmentedControlDividerProps };
@@ -0,0 +1,24 @@
1
+ import { c } from "../utils/react-compiler-runtime.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/SegmentedControl/SegmentedControlDivider.tsx
4
+ const SegmentedControlDivider = (t0) => {
5
+ const $ = c(3);
6
+ const { className, style } = t0;
7
+ let t1;
8
+ if ($[0] !== className || $[1] !== style) {
9
+ t1 = /*#__PURE__*/ jsx("li", {
10
+ "aria-hidden": "true",
11
+ className,
12
+ "data-component": "SegmentedControl.Divider",
13
+ style
14
+ });
15
+ $[0] = className;
16
+ $[1] = style;
17
+ $[2] = t1;
18
+ } else t1 = $[2];
19
+ return t1;
20
+ };
21
+ SegmentedControlDivider.displayName = "SegmentedControl.Divider";
22
+ SegmentedControlDivider.__SLOT__ = Symbol("SegmentedControl.Divider");
23
+ //#endregion
24
+ export { SegmentedControlDivider as default };
@@ -1,8 +1,8 @@
1
+ import { c } from "../utils/react-compiler-runtime.js";
1
2
  import { Tooltip } from "../TooltipV2/Tooltip.js";
2
3
  import SegmentedControl_module_css_default from "./SegmentedControl.module.css.js";
3
- import { c } from "react-compiler-runtime";
4
- import { clsx } from "clsx";
5
4
  import { jsx } from "react/jsx-runtime";
5
+ import { clsx } from "clsx";
6
6
  import { isElement } from "react-is";
7
7
  //#region src/SegmentedControl/SegmentedControlIconButton.tsx
8
8
  const SegmentedControlIconButton = (t0) => {
@@ -1,4 +1,6 @@
1
+ import { SegmentedControlDividerProps } from "./SegmentedControlDivider.js";
2
+ import { SegmentedControlActionProps } from "./SegmentedControlAction.js";
1
3
  import { SegmentedControlButtonProps } from "./SegmentedControlButton.js";
2
4
  import { SegmentedControlIconButtonProps } from "./SegmentedControlIconButton.js";
3
5
  import { SegmentedControl, SegmentedControlProps } from "./SegmentedControl.js";
4
- export { SegmentedControl, type SegmentedControlButtonProps, type SegmentedControlIconButtonProps, SegmentedControlProps };
6
+ export { SegmentedControl, type SegmentedControlActionProps, type SegmentedControlButtonProps, type SegmentedControlDividerProps, type SegmentedControlIconButtonProps, SegmentedControlProps };