@itwin/itwinui-react 3.15.5 → 3.16.1

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 (143) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/DEV-cjs/core/Breadcrumbs/Breadcrumbs.js +2 -2
  3. package/DEV-cjs/core/Checkbox/Checkbox.js +4 -6
  4. package/DEV-cjs/core/ComboBox/ComboBox.js +10 -6
  5. package/DEV-cjs/core/DatePicker/DatePicker.js +9 -1
  6. package/DEV-cjs/core/Dialog/Dialog.js +1 -1
  7. package/DEV-cjs/core/Header/HeaderDropdownButton.js +1 -7
  8. package/DEV-cjs/core/Panels/Panels.js +322 -0
  9. package/DEV-cjs/core/Panels/helpers.js +62 -0
  10. package/DEV-cjs/core/Radio/Radio.js +4 -6
  11. package/DEV-cjs/core/RadioTiles/RadioTileGroup.js +9 -2
  12. package/DEV-cjs/core/Select/SelectTag.js +9 -11
  13. package/DEV-cjs/core/Select/SelectTagContainer.js +2 -2
  14. package/DEV-cjs/core/Stepper/Stepper.js +1 -0
  15. package/DEV-cjs/core/Stepper/StepperStep.js +2 -1
  16. package/DEV-cjs/core/Table/Table.js +3 -4
  17. package/DEV-cjs/core/Table/TablePaginator.js +15 -3
  18. package/DEV-cjs/core/Table/actionHandlers/selectHandler.js +10 -7
  19. package/DEV-cjs/core/Table/columns/selectionColumn.js +6 -1
  20. package/DEV-cjs/core/Tree/Tree.js +1 -0
  21. package/DEV-cjs/index.js +4 -0
  22. package/DEV-cjs/styles.js +1 -1
  23. package/DEV-cjs/utils/components/MiddleTextTruncation.js +22 -4
  24. package/DEV-cjs/utils/components/OverflowContainer.js +170 -27
  25. package/DEV-cjs/utils/hooks/index.js +1 -1
  26. package/DEV-cjs/utils/hooks/useInstance.js +38 -0
  27. package/DEV-esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
  28. package/DEV-esm/core/Checkbox/Checkbox.js +5 -10
  29. package/DEV-esm/core/ComboBox/ComboBox.js +10 -6
  30. package/DEV-esm/core/DatePicker/DatePicker.js +11 -1
  31. package/DEV-esm/core/Dialog/Dialog.js +1 -1
  32. package/DEV-esm/core/Header/HeaderDropdownButton.js +1 -3
  33. package/DEV-esm/core/Panels/Panels.js +304 -0
  34. package/DEV-esm/core/Panels/helpers.js +42 -0
  35. package/DEV-esm/core/Radio/Radio.js +4 -9
  36. package/DEV-esm/core/RadioTiles/RadioTileGroup.js +8 -2
  37. package/DEV-esm/core/Select/SelectTag.js +9 -11
  38. package/DEV-esm/core/Select/SelectTagContainer.js +2 -2
  39. package/DEV-esm/core/Stepper/Stepper.js +1 -0
  40. package/DEV-esm/core/Stepper/StepperStep.js +2 -1
  41. package/DEV-esm/core/Table/Table.js +1 -5
  42. package/DEV-esm/core/Table/TablePaginator.js +16 -3
  43. package/DEV-esm/core/Table/actionHandlers/selectHandler.js +10 -7
  44. package/DEV-esm/core/Table/columns/selectionColumn.js +6 -1
  45. package/DEV-esm/core/Tree/Tree.js +1 -0
  46. package/DEV-esm/index.js +1 -0
  47. package/DEV-esm/styles.js +1 -1
  48. package/DEV-esm/utils/components/MiddleTextTruncation.js +22 -4
  49. package/DEV-esm/utils/components/OverflowContainer.js +143 -4
  50. package/DEV-esm/utils/hooks/index.js +1 -1
  51. package/DEV-esm/utils/hooks/useInstance.js +18 -0
  52. package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -2
  53. package/cjs/core/Checkbox/Checkbox.js +4 -6
  54. package/cjs/core/ComboBox/ComboBox.d.ts +13 -0
  55. package/cjs/core/ComboBox/ComboBox.js +10 -6
  56. package/cjs/core/DatePicker/DatePicker.d.ts +2 -2
  57. package/cjs/core/DatePicker/DatePicker.js +2 -1
  58. package/cjs/core/Dialog/Dialog.js +1 -1
  59. package/cjs/core/Dialog/DialogContext.d.ts +6 -2
  60. package/cjs/core/Header/HeaderDropdownButton.js +1 -7
  61. package/cjs/core/Panels/Panels.d.ts +174 -0
  62. package/cjs/core/Panels/Panels.js +315 -0
  63. package/cjs/core/Panels/helpers.d.ts +23 -0
  64. package/cjs/core/Panels/helpers.js +61 -0
  65. package/cjs/core/ProgressIndicators/ProgressLinear.d.ts +1 -1
  66. package/cjs/core/Radio/Radio.js +4 -6
  67. package/cjs/core/RadioTiles/RadioTileGroup.d.ts +3 -1
  68. package/cjs/core/RadioTiles/RadioTileGroup.js +9 -2
  69. package/cjs/core/Select/SelectTag.d.ts +3 -1
  70. package/cjs/core/Select/SelectTag.js +9 -11
  71. package/cjs/core/Select/SelectTagContainer.js +2 -2
  72. package/cjs/core/Stepper/Stepper.d.ts +4 -0
  73. package/cjs/core/Stepper/Stepper.js +1 -0
  74. package/cjs/core/Stepper/StepperStep.d.ts +4 -0
  75. package/cjs/core/Stepper/StepperStep.js +2 -1
  76. package/cjs/core/Table/Table.d.ts +1 -0
  77. package/cjs/core/Table/Table.js +3 -4
  78. package/cjs/core/Table/TablePaginator.js +15 -3
  79. package/cjs/core/Table/actionHandlers/selectHandler.js +10 -7
  80. package/cjs/core/Table/columns/selectionColumn.js +6 -1
  81. package/cjs/core/Tree/Tree.d.ts +2 -1
  82. package/cjs/core/Tree/Tree.js +1 -0
  83. package/cjs/index.d.ts +1 -0
  84. package/cjs/index.js +4 -0
  85. package/cjs/styles.js +1 -1
  86. package/cjs/utils/components/MiddleTextTruncation.d.ts +5 -7
  87. package/cjs/utils/components/MiddleTextTruncation.js +22 -4
  88. package/cjs/utils/components/OverflowContainer.d.ts +1 -0
  89. package/cjs/utils/components/OverflowContainer.js +170 -27
  90. package/cjs/utils/hooks/index.d.ts +1 -1
  91. package/cjs/utils/hooks/index.js +1 -1
  92. package/cjs/utils/hooks/useInstance.d.ts +22 -0
  93. package/cjs/utils/hooks/useInstance.js +38 -0
  94. package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
  95. package/esm/core/Checkbox/Checkbox.js +5 -10
  96. package/esm/core/ComboBox/ComboBox.d.ts +13 -0
  97. package/esm/core/ComboBox/ComboBox.js +10 -6
  98. package/esm/core/DatePicker/DatePicker.d.ts +2 -2
  99. package/esm/core/DatePicker/DatePicker.js +4 -1
  100. package/esm/core/Dialog/Dialog.js +1 -1
  101. package/esm/core/Dialog/DialogContext.d.ts +6 -2
  102. package/esm/core/Header/HeaderDropdownButton.js +1 -3
  103. package/esm/core/Panels/Panels.d.ts +174 -0
  104. package/esm/core/Panels/Panels.js +297 -0
  105. package/esm/core/Panels/helpers.d.ts +23 -0
  106. package/esm/core/Panels/helpers.js +41 -0
  107. package/esm/core/ProgressIndicators/ProgressLinear.d.ts +1 -1
  108. package/esm/core/Radio/Radio.js +4 -9
  109. package/esm/core/RadioTiles/RadioTileGroup.d.ts +3 -1
  110. package/esm/core/RadioTiles/RadioTileGroup.js +8 -2
  111. package/esm/core/Select/SelectTag.d.ts +3 -1
  112. package/esm/core/Select/SelectTag.js +9 -11
  113. package/esm/core/Select/SelectTagContainer.js +2 -2
  114. package/esm/core/Stepper/Stepper.d.ts +4 -0
  115. package/esm/core/Stepper/Stepper.js +1 -0
  116. package/esm/core/Stepper/StepperStep.d.ts +4 -0
  117. package/esm/core/Stepper/StepperStep.js +2 -1
  118. package/esm/core/Table/Table.d.ts +1 -0
  119. package/esm/core/Table/Table.js +1 -5
  120. package/esm/core/Table/TablePaginator.js +16 -3
  121. package/esm/core/Table/actionHandlers/selectHandler.js +10 -7
  122. package/esm/core/Table/columns/selectionColumn.js +6 -1
  123. package/esm/core/Tree/Tree.d.ts +2 -1
  124. package/esm/core/Tree/Tree.js +1 -0
  125. package/esm/index.d.ts +1 -0
  126. package/esm/index.js +1 -0
  127. package/esm/styles.js +1 -1
  128. package/esm/utils/components/MiddleTextTruncation.d.ts +5 -7
  129. package/esm/utils/components/MiddleTextTruncation.js +22 -4
  130. package/esm/utils/components/OverflowContainer.d.ts +1 -0
  131. package/esm/utils/components/OverflowContainer.js +143 -4
  132. package/esm/utils/hooks/index.d.ts +1 -1
  133. package/esm/utils/hooks/index.js +1 -1
  134. package/esm/utils/hooks/useInstance.d.ts +22 -0
  135. package/esm/utils/hooks/useInstance.js +18 -0
  136. package/package.json +2 -2
  137. package/styles.css +8 -8
  138. package/DEV-cjs/utils/hooks/useOverflow.js +0 -76
  139. package/DEV-esm/utils/hooks/useOverflow.js +0 -63
  140. package/cjs/utils/hooks/useOverflow.d.ts +0 -23
  141. package/cjs/utils/hooks/useOverflow.js +0 -76
  142. package/esm/utils/hooks/useOverflow.d.ts +0 -23
  143. package/esm/utils/hooks/useOverflow.js +0 -63
@@ -11,7 +11,7 @@ import { Transition } from 'react-transition-group';
11
11
  let DialogComponent = React.forwardRef((props, ref) => {
12
12
  let {
13
13
  trapFocus = false,
14
- setFocus = false,
14
+ setFocus = trapFocus,
15
15
  preventDocumentScroll = false,
16
16
  isOpen = false,
17
17
  isDismissible = true,
@@ -30,13 +30,17 @@ export type DialogContextProps = {
30
30
  */
31
31
  closeOnEsc?: boolean;
32
32
  /**
33
- * Traps the focus inside the dialog. This is useful when the dialog is modal.
33
+ * Prevents focus from leaving the dialog. This is useful when the dialog is modal.
34
+ *
35
+ * Setting this prop to `true` will also set `setFocus` to `true`.
36
+ *
34
37
  * @default false
35
38
  */
36
39
  trapFocus?: boolean;
37
40
  /**
38
41
  * If true, focuses the dialog.
39
- * @default false
42
+ *
43
+ * Defaults to `true` if `trapFocus` is set to `true`, otherwise defaults to `false`.
40
44
  */
41
45
  setFocus?: boolean;
42
46
  /**
@@ -1,4 +1,3 @@
1
- import cx from 'classnames';
2
1
  import * as React from 'react';
3
2
  import { DropdownMenu } from '../DropdownMenu/DropdownMenu.js';
4
3
  import {
@@ -8,7 +7,7 @@ import {
8
7
  } from '../../utils/index.js';
9
8
  import { HeaderBasicButton } from './HeaderBasicButton.js';
10
9
  export const HeaderDropdownButton = React.forwardRef((props, ref) => {
11
- let { menuItems, className, children, ...rest } = props;
10
+ let { menuItems, children, ...rest } = props;
12
11
  let [isMenuOpen, setIsMenuOpen] = React.useState(false);
13
12
  let [menuWidth, setMenuWidth] = React.useState(0);
14
13
  let buttonRef = React.useRef(null);
@@ -28,7 +27,6 @@ export const HeaderDropdownButton = React.forwardRef((props, ref) => {
28
27
  React.createElement(
29
28
  HeaderBasicButton,
30
29
  {
31
- className: cx('iui-header-breadcrumb-button', className),
32
30
  ref: refs,
33
31
  'aria-label': 'Dropdown',
34
32
  endIcon: isMenuOpen
@@ -0,0 +1,174 @@
1
+ import * as React from 'react';
2
+ import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
3
+ import { Text } from '../Typography/Text.js';
4
+ import type { FocusEntry, PanelsInstance, TriggerMapEntry } from './helpers.js';
5
+ type PanelsWrapperProps = {
6
+ /**
7
+ * Function that gets called when the active panel is changed.
8
+ */
9
+ onActiveIdChange?: (newActiveId: string) => void;
10
+ children: React.ReactNode;
11
+ /**
12
+ * Pass an instance created by `useInstance` to control the panels imperatively.
13
+ *
14
+ * @example
15
+ * const panels = Panels.useInstance();
16
+ * <Panels instance={panels} />
17
+ */
18
+ instance?: PanelsInstance;
19
+ };
20
+ export declare const PanelsWrapper: PolymorphicForwardRefComponent<"div", PanelsWrapperProps>;
21
+ export declare const PanelsWrapperContext: React.Context<{
22
+ activePanelId: string | undefined;
23
+ setActivePanelId: React.Dispatch<React.SetStateAction<string>>;
24
+ /**
25
+ * Simpler alternative to a full history stack.
26
+ *
27
+ * ```
28
+ * Record<
29
+ * string, // Id of a panel
30
+ * {
31
+ * triggerId: string, // Id of the trigger element that points to this panel
32
+ * panelId: string, // Id of the panel element in which the trigger is present
33
+ * }
34
+ * >
35
+ * ```
36
+ */
37
+ triggers: Record<string, TriggerMapEntry>;
38
+ setTriggers: React.Dispatch<React.SetStateAction<Record<string, TriggerMapEntry>>>;
39
+ changeActivePanel: (newActiveId: string) => void;
40
+ shouldFocus: FocusEntry;
41
+ setShouldFocus: React.Dispatch<React.SetStateAction<FocusEntry>>;
42
+ panels: React.MutableRefObject<Set<string>>;
43
+ } | undefined>;
44
+ type PanelProps = {
45
+ id: string;
46
+ };
47
+ type PanelTriggerProps = {
48
+ for: string;
49
+ children: React.ReactElement;
50
+ };
51
+ type PanelHeaderProps = {
52
+ titleProps?: React.ComponentProps<typeof Text>;
53
+ };
54
+ export declare const Panels: {
55
+ /**
56
+ * Component that manages the logic for layered panels.
57
+ * It can be used anywhere to create layers. E.g. `Menu`, `InformationPanel`, `Popover`, etc.
58
+ *
59
+ * Requirements:
60
+ * - The initial displayed Panel should be the first `Panel` in the `Panels.Wrapper`.
61
+ * - A panel can have only one trigger pointing to it. i.e. out of all the triggers across all panels,
62
+ * only one can point to a particular panel.
63
+ * - The `Panels.Panel`s within the wrapper should be in the order of the navigation. E.g.:
64
+ * ```jsx
65
+ * <Panels.Wrapper>
66
+ * <Panels.Panel id={root} /> // Must come before moreDetails since it contains the trigger to moreDetails
67
+ * <Panels.Panel id={moreDetails}> // Must come after root since it is navigated to from root
68
+ * </Panels.Wrapper>
69
+ * ```
70
+ *
71
+ * @example
72
+ * <Panels.Wrapper as={Surface}>
73
+ * <Panels.Panel
74
+ * id={panelIdRoot}
75
+ * as={Surface}
76
+ * border={false}
77
+ * elevation={0}
78
+ * >
79
+ * <Surface.Header as={Panels.Header}>Root</Surface.Header>
80
+ * <Surface.Body as={List}>
81
+ * <ListItem>
82
+ * <Panels.Trigger for={panelIdMoreInfo}>
83
+ * <ListItem.Action>More details</ListItem.Action>
84
+ * </Panels.Trigger>
85
+ * </ListItem>
86
+ * </Surface.Body>
87
+ * </Panels.Panel>
88
+ *
89
+ * <Panels.Panel
90
+ * id={panelIdMoreInfo}
91
+ * as={Surface}
92
+ * border={false}
93
+ * elevation={0}
94
+ * >
95
+ * <Surface.Header as={Panels.Header}>More details</Surface.Header>
96
+ * <Surface.Body isPadded>
97
+ * <Text>Content</Text>
98
+ * </Surface.Body>
99
+ * </Panels.Panel>
100
+ * </Panels.Wrapper>
101
+ */
102
+ Wrapper: PolymorphicForwardRefComponent<"div", PanelsWrapperProps>;
103
+ /**
104
+ * Takes an `id` and the panel content.
105
+ * Match this `id` with a `Panels.Triggers`'s `for` prop to create a link between them.
106
+ *
107
+ * @example
108
+ * <Panels.Panel id={panelIdRoot} as={Surface} border={false} elevation={0}>
109
+ * <Surface.Header as={Panels.Header}>Root</Surface.Header>
110
+ * <Surface.Body as={List}>
111
+ * <ListItem>
112
+ * <Panels.Trigger for={panelIdMoreInfo}>
113
+ * <ListItem.Action>More details</ListItem.Action>
114
+ * </Panels.Trigger>
115
+ * </ListItem>
116
+ * </Surface.Body>
117
+ * </Panels.Panel>
118
+ */
119
+ Panel: PolymorphicForwardRefComponent<"div", PanelProps>;
120
+ /**
121
+ * Wraps the clickable element and appends an `onClick` to change the active panel to the one specified in the `for`
122
+ * prop. Also appends some attributes for accessibility.
123
+ *
124
+ * @example
125
+ * <Panels.Trigger for={nextPanelId}>
126
+ * <Button>go to next panel</Button>
127
+ * </Panels.Trigger>
128
+ *
129
+ * @example
130
+ * <ListItem>
131
+ * <Panels.Trigger for={panelIdMoreInfo}>
132
+ * <ListItem.Action>More details</ListItem.Action>
133
+ * </Panels.Trigger>
134
+ * </ListItem>
135
+ */
136
+ Trigger: {
137
+ (props: PanelTriggerProps): string | number | true | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null;
138
+ displayName: string;
139
+ };
140
+ /**
141
+ * Required component to add an accessible name and also a back button (if previous panel exists) to the panel.
142
+ *
143
+ * @example
144
+ * <Panels.Panel id={panelIdRoot}>
145
+ * <Panels.Header>Root</Panels.Header>
146
+ * …
147
+ * </Panels.Panel>
148
+ *
149
+ * @example
150
+ * <Panels.Panel
151
+ * id={panelIdMoreInfo}
152
+ * as={Surface}
153
+ * border={false}
154
+ * elevation={0}
155
+ * >
156
+ * <Surface.Header as={Panels.Header}>More details</Surface.Header>
157
+ * <Surface.Body isPadded>
158
+ * <Text>Content</Text>
159
+ * </Surface.Body>
160
+ * </Panels.Panel>
161
+ */
162
+ Header: PolymorphicForwardRefComponent<"div", PanelHeaderProps>;
163
+ /**
164
+ * You can use methods from `Panels.useInstance()` to control the state programmatically.
165
+ *
166
+ * @example
167
+ * const panels = Panels.useInstance();
168
+ *
169
+ * <Button onClick={() => panels.goBack()}>Go back</Button>
170
+ * <Panels.Wrapper instance={panels}>{…}</Panels.Wrapper>;
171
+ */
172
+ useInstance: () => PanelsInstance;
173
+ };
174
+ export {};
@@ -0,0 +1,297 @@
1
+ import * as React from 'react';
2
+ import * as ReactDOM from 'react-dom';
3
+ import {
4
+ Box,
5
+ cloneElementWithRef,
6
+ mergeEventHandlers,
7
+ SvgChevronLeft,
8
+ useInstance,
9
+ useMergedRefs,
10
+ useSafeContext,
11
+ useMediaQuery,
12
+ useWarningLogger,
13
+ useLayoutEffect,
14
+ useLatestRef,
15
+ } from '../../utils/index.js';
16
+ import { IconButton } from '../Buttons/IconButton.js';
17
+ import { Flex } from '../Flex/Flex.js';
18
+ import { Text } from '../Typography/Text.js';
19
+ import cx from 'classnames';
20
+ import { PanelsInstanceContext, PanelsInstanceProvider } from './helpers.js';
21
+ export const PanelsWrapper = React.forwardRef((props, forwardedRef) => {
22
+ let {
23
+ children,
24
+ className,
25
+ onActiveIdChange: onActiveIdChangeProp,
26
+ instance,
27
+ ...rest
28
+ } = props;
29
+ let onActiveIdChange = useLatestRef(onActiveIdChangeProp);
30
+ let ref = React.useRef(null);
31
+ let [activePanelId, setActivePanelId] = React.useState(void 0);
32
+ let [triggers, setTriggers] = React.useState({});
33
+ let panels = React.useRef(new Set());
34
+ let [shouldFocus, setShouldFocus] = React.useState(void 0);
35
+ let motionOk = useMediaQuery('(prefers-reduced-motion: no-preference)');
36
+ let changeActivePanel = React.useCallback(
37
+ (newActiveId) => {
38
+ if (!panels.current.has(newActiveId) || newActiveId === activePanelId)
39
+ return;
40
+ ReactDOM.flushSync(() => setActivePanelId(newActiveId));
41
+ onActiveIdChange.current?.(newActiveId);
42
+ ref.current
43
+ ?.getRootNode()
44
+ .getElementById(newActiveId)
45
+ ?.scrollIntoView({
46
+ block: 'nearest',
47
+ inline: 'center',
48
+ behavior: motionOk ? 'smooth' : 'instant',
49
+ });
50
+ },
51
+ [activePanelId, motionOk, onActiveIdChange],
52
+ );
53
+ return React.createElement(
54
+ PanelsWrapperContext.Provider,
55
+ {
56
+ value: React.useMemo(
57
+ () => ({
58
+ activePanelId,
59
+ setActivePanelId,
60
+ changeActivePanel,
61
+ triggers,
62
+ setTriggers,
63
+ shouldFocus,
64
+ setShouldFocus,
65
+ panels,
66
+ }),
67
+ [
68
+ activePanelId,
69
+ changeActivePanel,
70
+ setActivePanelId,
71
+ setTriggers,
72
+ shouldFocus,
73
+ triggers,
74
+ ],
75
+ ),
76
+ },
77
+ React.createElement(
78
+ PanelsInstanceProvider,
79
+ {
80
+ instance: instance,
81
+ },
82
+ React.createElement(
83
+ Box,
84
+ {
85
+ ref: useMergedRefs(ref, forwardedRef),
86
+ ...rest,
87
+ className: cx('iui-panel-wrapper', className),
88
+ },
89
+ children,
90
+ ),
91
+ ),
92
+ );
93
+ });
94
+ export const PanelsWrapperContext = React.createContext(void 0);
95
+ let Panel = React.forwardRef((props, forwardedRef) => {
96
+ let { id, children, className, ...rest } = props;
97
+ let { activePanelId, triggers, panels, setActivePanelId } =
98
+ useSafeContext(PanelsWrapperContext);
99
+ let associatedTrigger = React.useMemo(() => triggers[id], [id, triggers]);
100
+ let previousActivePanelId = useDelayed(activePanelId) || activePanelId;
101
+ let isMounted = [activePanelId, previousActivePanelId].includes(id);
102
+ let isTransitioning =
103
+ activePanelId === id && activePanelId !== previousActivePanelId;
104
+ let isInert = previousActivePanelId === id && activePanelId !== id;
105
+ useLayoutEffect(() => {
106
+ let isFirstPanel = null == activePanelId && 0 === panels.current.size;
107
+ if (isFirstPanel) setActivePanelId(id);
108
+ let panelsCurrent = panels.current;
109
+ if (!panelsCurrent.has(id)) panelsCurrent.add(id);
110
+ return () => {
111
+ panelsCurrent.delete(id);
112
+ };
113
+ }, [activePanelId, id, panels, setActivePanelId]);
114
+ return React.createElement(
115
+ PanelContext.Provider,
116
+ {
117
+ value: React.useMemo(
118
+ () => ({
119
+ id,
120
+ associatedTrigger,
121
+ }),
122
+ [associatedTrigger, id],
123
+ ),
124
+ },
125
+ isMounted &&
126
+ React.createElement(
127
+ Box,
128
+ {
129
+ ref: forwardedRef,
130
+ id: id,
131
+ className: cx('iui-panel', className),
132
+ 'aria-labelledby': `${id}-header-title`,
133
+ role: 'group',
134
+ inert: isInert ? '' : void 0,
135
+ 'data-iui-transitioning': isTransitioning ? 'true' : void 0,
136
+ ...rest,
137
+ },
138
+ children,
139
+ ),
140
+ );
141
+ });
142
+ let PanelContext = React.createContext(void 0);
143
+ let PanelTrigger = (props) => {
144
+ let { children, for: forProp } = props;
145
+ let {
146
+ changeActivePanel,
147
+ triggers,
148
+ setTriggers,
149
+ activePanelId: activePanel,
150
+ shouldFocus,
151
+ setShouldFocus,
152
+ panels,
153
+ } = useSafeContext(PanelsWrapperContext);
154
+ let { id: panelId } = useSafeContext(PanelContext);
155
+ let fallbackId = React.useId();
156
+ let triggerId = children.props.id || fallbackId;
157
+ let onClick = React.useCallback(() => {
158
+ if (null == activePanel) return;
159
+ setShouldFocus({
160
+ fromPanelId: activePanel,
161
+ toPanelId: forProp,
162
+ direction: 'forward',
163
+ });
164
+ changeActivePanel?.(forProp);
165
+ }, [activePanel, changeActivePanel, forProp, setShouldFocus]);
166
+ let focusRef = React.useCallback(
167
+ (el) => {
168
+ if (
169
+ shouldFocus?.direction === 'backward' &&
170
+ shouldFocus?.toPanelId === panelId &&
171
+ shouldFocus?.fromPanelId === forProp
172
+ ) {
173
+ el?.focus({
174
+ preventScroll: true,
175
+ });
176
+ setShouldFocus(void 0);
177
+ }
178
+ },
179
+ [forProp, panelId, setShouldFocus, shouldFocus],
180
+ );
181
+ let logWarning = useWarningLogger();
182
+ React.useEffect(() => {
183
+ if (!panels.current.has(forProp))
184
+ logWarning(
185
+ `Panels.Trigger's \`for\` prop ("${forProp}") corresponds to no Panel.`,
186
+ );
187
+ }, [forProp, logWarning, panels, triggers]);
188
+ React.useEffect(() => {
189
+ setTriggers((oldTriggers) => {
190
+ let triggersMatch = oldTriggers[forProp];
191
+ if (
192
+ null == triggersMatch ||
193
+ panelId !== triggersMatch.panelId ||
194
+ triggerId !== triggersMatch.triggerId
195
+ )
196
+ return {
197
+ ...oldTriggers,
198
+ [forProp]: {
199
+ panelId,
200
+ triggerId,
201
+ },
202
+ };
203
+ return oldTriggers;
204
+ });
205
+ }, [forProp, panelId, setTriggers, triggerId]);
206
+ return cloneElementWithRef(children, (children) => ({
207
+ ...children.props,
208
+ id: triggerId,
209
+ ref: focusRef,
210
+ onClick: mergeEventHandlers(children.props.onClick, onClick),
211
+ 'aria-expanded': activePanel === forProp,
212
+ 'aria-controls': forProp,
213
+ }));
214
+ };
215
+ let PanelHeader = React.forwardRef((props, forwardedRef) => {
216
+ let { titleProps, children, ...rest } = props;
217
+ let { shouldFocus, setShouldFocus } = useSafeContext(PanelsWrapperContext);
218
+ let { id: panelId, associatedTrigger: panelAssociatedTrigger } =
219
+ useSafeContext(PanelContext);
220
+ let focusRef = React.useCallback(
221
+ (el) => {
222
+ if (
223
+ shouldFocus?.direction === 'forward' &&
224
+ shouldFocus.toPanelId === panelId
225
+ ) {
226
+ el?.focus({
227
+ preventScroll: true,
228
+ });
229
+ setShouldFocus(void 0);
230
+ }
231
+ },
232
+ [panelId, setShouldFocus, shouldFocus?.direction, shouldFocus?.toPanelId],
233
+ );
234
+ return React.createElement(
235
+ Flex,
236
+ {
237
+ ref: forwardedRef,
238
+ ...rest,
239
+ },
240
+ panelAssociatedTrigger && React.createElement(PanelBackButton, null),
241
+ React.createElement(
242
+ Text,
243
+ {
244
+ id: `${panelId}-header-title`,
245
+ as: 'h2',
246
+ tabIndex: -1,
247
+ ref: focusRef,
248
+ ...titleProps,
249
+ },
250
+ children,
251
+ ),
252
+ );
253
+ });
254
+ let PanelBackButton = React.forwardRef((props, forwardedRef) => {
255
+ let { children, onClick, ...rest } = props;
256
+ let { instance: panelInstance } = useSafeContext(PanelsInstanceContext);
257
+ return React.createElement(
258
+ IconButton,
259
+ {
260
+ ref: forwardedRef,
261
+ 'aria-label': 'Previous panel',
262
+ styleType: 'borderless',
263
+ size: 'small',
264
+ 'data-iui-shift': 'left',
265
+ ...rest,
266
+ onClick: mergeEventHandlers(
267
+ React.useCallback(() => panelInstance?.goBack(), [panelInstance]),
268
+ onClick,
269
+ ),
270
+ },
271
+ children || React.createElement(SvgChevronLeft, null),
272
+ );
273
+ });
274
+ export const Panels = {
275
+ Wrapper: PanelsWrapper,
276
+ Panel,
277
+ Trigger: PanelTrigger,
278
+ Header: PanelHeader,
279
+ useInstance: useInstance,
280
+ };
281
+ function useDelayed(
282
+ value,
283
+ { delay } = {
284
+ delay: 500,
285
+ },
286
+ ) {
287
+ let [delayed, setDelayed] = React.useState(void 0);
288
+ let timeout = React.useRef(void 0);
289
+ React.useEffect(() => {
290
+ if (0 === delay) setDelayed(value);
291
+ else timeout.current = setTimeout(() => setDelayed(value), delay);
292
+ return () => {
293
+ clearTimeout(timeout.current);
294
+ };
295
+ }, [value, delay]);
296
+ return delayed;
297
+ }
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ export type PanelsInstance = {
3
+ /** Go back to the panel that has a trigger that points to the current panel. */
4
+ goBack: () => void;
5
+ };
6
+ export type TriggerMapEntry = {
7
+ triggerId: string;
8
+ panelId: string;
9
+ };
10
+ export type FocusEntry = {
11
+ fromPanelId: string;
12
+ toPanelId: string;
13
+ direction: 'forward' | 'backward';
14
+ } | undefined;
15
+ export declare const PanelsInstanceContext: React.Context<{
16
+ instance: PanelsInstance;
17
+ } | undefined>;
18
+ type PanelInstanceProviderProps = {
19
+ children: React.ReactNode;
20
+ instance: PanelsInstance | undefined;
21
+ };
22
+ export declare const PanelsInstanceProvider: (props: PanelInstanceProviderProps) => React.JSX.Element;
23
+ export {};
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+ import { useSafeContext, useSynchronizeInstance } from '../../utils/index.js';
3
+ import { Panels, PanelsWrapperContext } from './Panels.js';
4
+ export const PanelsInstanceContext = React.createContext(void 0);
5
+ export const PanelsInstanceProvider = (props) => {
6
+ let { children, instance: instanceProp } = props;
7
+ let instanceBackup = Panels.useInstance();
8
+ let instance = instanceProp || instanceBackup;
9
+ let { activePanelId, changeActivePanel, triggers, setShouldFocus } =
10
+ useSafeContext(PanelsWrapperContext);
11
+ let goBack = React.useCallback(async () => {
12
+ if (null == activePanelId) return;
13
+ let trigger = triggers[activePanelId];
14
+ if (null != trigger.triggerId) {
15
+ setShouldFocus({
16
+ fromPanelId: activePanelId,
17
+ toPanelId: trigger.panelId,
18
+ direction: 'backward',
19
+ });
20
+ changeActivePanel(trigger.panelId);
21
+ }
22
+ }, [activePanelId, changeActivePanel, setShouldFocus, triggers]);
23
+ useSynchronizeInstance(
24
+ instance,
25
+ React.useMemo(
26
+ () => ({
27
+ goBack,
28
+ }),
29
+ [goBack],
30
+ ),
31
+ );
32
+ return React.createElement(
33
+ PanelsInstanceContext.Provider,
34
+ {
35
+ value: {
36
+ instance,
37
+ },
38
+ },
39
+ children,
40
+ );
41
+ };
@@ -8,7 +8,7 @@ type ProgressLinearProps = {
8
8
  /**
9
9
  * Progress variant. If true, `value` will be ignored.
10
10
  *
11
- * Defaults to true if `value` is passed, otherwise false.
11
+ * Defaults to false if `value` is passed, otherwise true.
12
12
  */
13
13
  indeterminate?: boolean;
14
14
  /**
@@ -16,7 +16,7 @@ export const Radio = React.forwardRef((props, ref) => {
16
16
  let refs = useMergedRefs(inputElementRef, ref);
17
17
  let radio = React.createElement(Box, {
18
18
  as: 'input',
19
- className: cx('iui-radio', className),
19
+ className: cx('iui-checkbox', 'iui-radio', className),
20
20
  style: style,
21
21
  disabled: disabled,
22
22
  type: 'radio',
@@ -29,14 +29,9 @@ export const Radio = React.forwardRef((props, ref) => {
29
29
  {
30
30
  as: 'label',
31
31
  ...wrapperProps,
32
- className: cx(
33
- 'iui-radio-wrapper',
34
- {
35
- 'iui-disabled': disabled,
36
- [`iui-${status}`]: !!status,
37
- },
38
- wrapperProps?.className,
39
- ),
32
+ className: cx('iui-checkbox-wrapper', wrapperProps?.className),
33
+ 'data-iui-status': status,
34
+ 'data-iui-disabled': disabled ? 'true' : void 0,
40
35
  },
41
36
  radio,
42
37
  label &&
@@ -1,7 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { InputGroup } from '../InputGroup/InputGroup.js';
3
3
  import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
4
- type RadioTileGroupProps = Omit<React.ComponentProps<typeof InputGroup>, 'displayStyle' | 'disabled'>;
4
+ type RadioTileGroupProps = {
5
+ tileContainerProps?: React.ComponentProps<'div'>;
6
+ } & Omit<React.ComponentProps<typeof InputGroup>, 'displayStyle' | 'disabled'>;
5
7
  /**
6
8
  * RadioTileGroup component to group RadioTile components together
7
9
  * @example
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { InputGroup } from '../InputGroup/InputGroup.js';
3
3
  import { Box } from '../../utils/index.js';
4
+ import cx from 'classnames';
4
5
  export const RadioTileGroup = React.forwardRef((props, forwardedRef) => {
5
- let { children, label, ...rest } = props;
6
+ let { children, label, tileContainerProps, ...rest } = props;
6
7
  return React.createElement(
7
8
  InputGroup,
8
9
  {
@@ -13,7 +14,12 @@ export const RadioTileGroup = React.forwardRef((props, forwardedRef) => {
13
14
  React.createElement(
14
15
  Box,
15
16
  {
16
- className: 'iui-radio-tile-container',
17
+ as: 'div',
18
+ ...tileContainerProps,
19
+ className: cx(
20
+ 'iui-radio-tile-container',
21
+ tileContainerProps?.className,
22
+ ),
17
23
  },
18
24
  children,
19
25
  ),
@@ -1,10 +1,12 @@
1
+ import * as React from 'react';
2
+ import { Tag } from '../Tag/Tag.js';
1
3
  import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
2
4
  type SelectTagProps = {
3
5
  /**
4
6
  * Text inside the tag.
5
7
  */
6
8
  label: string;
7
- };
9
+ } & Pick<React.ComponentProps<typeof Tag>, 'onClick' | 'onRemove'>;
8
10
  /**
9
11
  * Tag for showing selected value in `Select`.
10
12
  * @private