@patternfly/react-core 6.3.0-prerelease.17 → 6.3.0-prerelease.19
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 +12 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/Content/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/Chip/package.json +1 -1
- package/dist/dynamic/deprecated/components/DragDrop/package.json +1 -1
- package/dist/dynamic/deprecated/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/Modal/package.json +1 -1
- package/dist/dynamic/deprecated/components/Tile/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/styles/package.json +1 -1
- package/dist/esm/components/Button/Button.d.ts +4 -0
- package/dist/esm/components/Button/Button.d.ts.map +1 -1
- package/dist/esm/components/Button/Button.js +20 -3
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/Form/FormFieldGroupExpandable.d.ts +5 -0
- package/dist/esm/components/Form/FormFieldGroupExpandable.d.ts.map +1 -1
- package/dist/esm/components/Form/FormFieldGroupExpandable.js +2 -2
- package/dist/esm/components/Form/FormFieldGroupExpandable.js.map +1 -1
- package/dist/esm/components/Form/InternalFormFieldGroup.d.ts +5 -0
- package/dist/esm/components/Form/InternalFormFieldGroup.d.ts.map +1 -1
- package/dist/esm/components/Form/InternalFormFieldGroup.js +2 -2
- package/dist/esm/components/Form/InternalFormFieldGroup.js.map +1 -1
- package/dist/js/components/Button/Button.d.ts +4 -0
- package/dist/js/components/Button/Button.d.ts.map +1 -1
- package/dist/js/components/Button/Button.js +20 -3
- package/dist/js/components/Button/Button.js.map +1 -1
- package/dist/js/components/Form/FormFieldGroupExpandable.d.ts +5 -0
- package/dist/js/components/Form/FormFieldGroupExpandable.d.ts.map +1 -1
- package/dist/js/components/Form/FormFieldGroupExpandable.js +2 -2
- package/dist/js/components/Form/FormFieldGroupExpandable.js.map +1 -1
- package/dist/js/components/Form/InternalFormFieldGroup.d.ts +5 -0
- package/dist/js/components/Form/InternalFormFieldGroup.d.ts.map +1 -1
- package/dist/js/components/Form/InternalFormFieldGroup.js +2 -2
- package/dist/js/components/Form/InternalFormFieldGroup.js.map +1 -1
- package/dist/umd/assets/{output-RbEqNocC.css → output-BA_GjePx.css} +19337 -19287
- package/dist/umd/react-core.min.js +1 -1
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +6 -6
- package/src/components/Button/Button.tsx +48 -5
- package/src/components/Button/__tests__/Button.test.tsx +25 -0
- package/src/components/Button/examples/Button.md +8 -1
- package/src/components/Button/examples/ButtonFavorite.tsx +18 -0
- package/src/components/Form/FormFieldGroupExpandable.tsx +7 -0
- package/src/components/Form/InternalFormFieldGroup.tsx +19 -3
- package/src/components/Form/__tests__/FormFieldGroupExpandable.test.tsx +55 -0
- package/src/components/Form/examples/FormFieldGroups.tsx +7 -1
package/helpers/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"6.3.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"6.3.0-prerelease.18","private":true}
|
package/layouts/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"6.3.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"6.3.0-prerelease.18","private":true}
|
package/next/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"6.3.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"6.3.0-prerelease.18","private":true}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "6.3.0-prerelease.
|
|
3
|
+
"version": "6.3.0-prerelease.19",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
"subpaths": "node ../../scripts/exportSubpaths.mjs --config subpaths.config.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@patternfly/react-icons": "^6.3.0-prerelease.
|
|
50
|
-
"@patternfly/react-styles": "^6.3.0-prerelease.
|
|
51
|
-
"@patternfly/react-tokens": "^6.3.0-prerelease.
|
|
49
|
+
"@patternfly/react-icons": "^6.3.0-prerelease.4",
|
|
50
|
+
"@patternfly/react-styles": "^6.3.0-prerelease.4",
|
|
51
|
+
"@patternfly/react-tokens": "^6.3.0-prerelease.4",
|
|
52
52
|
"focus-trap": "7.6.4",
|
|
53
53
|
"react-dropzone": "^14.3.5",
|
|
54
54
|
"tslib": "^2.8.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@patternfly/patternfly": "6.3.0-prerelease.
|
|
57
|
+
"@patternfly/patternfly": "6.3.0-prerelease.24",
|
|
58
58
|
"case-anything": "^3.1.2",
|
|
59
59
|
"css": "^3.0.0",
|
|
60
60
|
"fs-extra": "^11.3.0"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"react": "^17 || ^18 || ^19",
|
|
64
64
|
"react-dom": "^17 || ^18 || ^19"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "e53720b71b9d2fc075e476f5f1b3a5f7b7c3055c"
|
|
67
67
|
}
|
|
@@ -4,6 +4,8 @@ import { css } from '@patternfly/react-styles';
|
|
|
4
4
|
import { Spinner, spinnerSize } from '../Spinner';
|
|
5
5
|
import { useOUIAProps, OUIAProps } from '../../helpers/OUIA/ouia';
|
|
6
6
|
import { Badge } from '../Badge';
|
|
7
|
+
import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon';
|
|
8
|
+
import OutlinedStarIcon from '@patternfly/react-icons/dist/esm/icons/outlined-star-icon';
|
|
7
9
|
|
|
8
10
|
export enum ButtonVariant {
|
|
9
11
|
primary = 'primary',
|
|
@@ -71,6 +73,10 @@ export interface ButtonProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'r
|
|
|
71
73
|
inoperableEvents?: string[];
|
|
72
74
|
/** Adds inline styling to a link button */
|
|
73
75
|
isInline?: boolean;
|
|
76
|
+
/** Adds favorite styling to a button */
|
|
77
|
+
isFavorite?: boolean;
|
|
78
|
+
/** Flag indicating whether the button is favorited or not, only when isFavorite is true. */
|
|
79
|
+
isFavorited?: boolean;
|
|
74
80
|
/** Adds styling which affects the size of the button */
|
|
75
81
|
size?: 'default' | 'sm' | 'lg';
|
|
76
82
|
/** Sets button type */
|
|
@@ -117,6 +123,8 @@ const ButtonBase: React.FunctionComponent<ButtonProps> = ({
|
|
|
117
123
|
size = ButtonSize.default,
|
|
118
124
|
inoperableEvents = ['onClick', 'onKeyPress'],
|
|
119
125
|
isInline = false,
|
|
126
|
+
isFavorite = false,
|
|
127
|
+
isFavorited = false,
|
|
120
128
|
type = ButtonType.button,
|
|
121
129
|
variant = ButtonVariant.primary,
|
|
122
130
|
state = ButtonState.unread,
|
|
@@ -132,11 +140,19 @@ const ButtonBase: React.FunctionComponent<ButtonProps> = ({
|
|
|
132
140
|
countOptions,
|
|
133
141
|
...props
|
|
134
142
|
}: ButtonProps) => {
|
|
143
|
+
if (isFavorite && !ariaLabel && !props['aria-labelledby']) {
|
|
144
|
+
// eslint-disable-next-line no-console
|
|
145
|
+
console.error(
|
|
146
|
+
'Button: Each favorite button must have a unique accessible name provided via aria-label or aria-labelledby'
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
135
150
|
const ouiaProps = useOUIAProps(Button.displayName, ouiaId, ouiaSafe, variant);
|
|
136
151
|
const Component = component as any;
|
|
137
152
|
const isButtonElement = Component === 'button';
|
|
138
153
|
const isInlineSpan = isInline && Component === 'span';
|
|
139
154
|
const isIconAlignedAtEnd = iconPosition === 'end' || iconPosition === 'right';
|
|
155
|
+
const shouldOverrideIcon = isFavorite;
|
|
140
156
|
|
|
141
157
|
const preventedEvents = inoperableEvents.reduce(
|
|
142
158
|
(handlers, eventToPrevent) => ({
|
|
@@ -158,11 +174,36 @@ const ButtonBase: React.FunctionComponent<ButtonProps> = ({
|
|
|
158
174
|
}
|
|
159
175
|
};
|
|
160
176
|
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
177
|
+
const renderIcon = () => {
|
|
178
|
+
let iconContent;
|
|
179
|
+
|
|
180
|
+
if (isFavorite) {
|
|
181
|
+
iconContent = (
|
|
182
|
+
<>
|
|
183
|
+
<span className={css('pf-v6-c-button__icon-favorite')}>
|
|
184
|
+
<OutlinedStarIcon />
|
|
185
|
+
</span>
|
|
186
|
+
<span className={css('pf-v6-c-button__icon-favorited')}>
|
|
187
|
+
<StarIcon />
|
|
188
|
+
</span>
|
|
189
|
+
</>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (icon && !shouldOverrideIcon) {
|
|
194
|
+
iconContent = icon;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
iconContent && (
|
|
199
|
+
<span className={css(styles.buttonIcon, children && styles.modifiers[isIconAlignedAtEnd ? 'end' : 'start'])}>
|
|
200
|
+
{iconContent}
|
|
201
|
+
</span>
|
|
202
|
+
)
|
|
203
|
+
);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const _icon = renderIcon();
|
|
166
207
|
const _children = children && <span className={css('pf-v6-c-button__text')}>{children}</span>;
|
|
167
208
|
// We only want to render the aria-disabled attribute when true, similar to the disabled attribute natively.
|
|
168
209
|
const shouldRenderAriaDisabled = isAriaDisabled || (!isButtonElement && isDisabled);
|
|
@@ -181,6 +222,8 @@ const ButtonBase: React.FunctionComponent<ButtonProps> = ({
|
|
|
181
222
|
isAriaDisabled && styles.modifiers.ariaDisabled,
|
|
182
223
|
isClicked && styles.modifiers.clicked,
|
|
183
224
|
isInline && variant === ButtonVariant.link && styles.modifiers.inline,
|
|
225
|
+
isFavorite && styles.modifiers.favorite,
|
|
226
|
+
isFavorite && isFavorited && styles.modifiers.favorited,
|
|
184
227
|
isDanger && (variant === ButtonVariant.secondary || variant === ButtonVariant.link) && styles.modifiers.danger,
|
|
185
228
|
isLoading !== null && variant !== ButtonVariant.plain && styles.modifiers.progress,
|
|
186
229
|
isLoading && styles.modifiers.inProgress,
|
|
@@ -248,3 +248,28 @@ test(`Renders basic button`, () => {
|
|
|
248
248
|
const { asFragment } = render(<Button aria-label="basic button">Basic Button</Button>);
|
|
249
249
|
expect(asFragment()).toMatchSnapshot();
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
test(`Renders with class ${styles.modifiers.favorite} when isFavorite is true`, () => {
|
|
253
|
+
render(<Button isFavorite />);
|
|
254
|
+
expect(screen.getByRole('button')).toHaveClass(styles.modifiers.favorite);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test(`Renders with class ${styles.modifiers.favorited} when isFavorite is true and isFavorited is true`, () => {
|
|
258
|
+
render(<Button isFavorite isFavorited />);
|
|
259
|
+
expect(screen.getByRole('button')).toHaveClass(styles.modifiers.favorited);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test(`Does not render with class ${styles.modifiers.favorite} when isFavorite is false`, () => {
|
|
263
|
+
render(<Button />);
|
|
264
|
+
expect(screen.getByRole('button')).not.toHaveClass(styles.modifiers.favorite);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test(`Does not render with class ${styles.modifiers.favorited} when isFavorite is true and isFavorited is false`, () => {
|
|
268
|
+
render(<Button isFavorite />);
|
|
269
|
+
expect(screen.getByRole('button')).not.toHaveClass(styles.modifiers.favorited);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test('Overrides icon prop when isFavorite is true', () => {
|
|
273
|
+
render(<Button isFavorite icon={<div>Icon content</div>} />);
|
|
274
|
+
expect(screen.queryByText('Icon content')).not.toBeInTheDocument();
|
|
275
|
+
});
|
|
@@ -125,6 +125,13 @@ Stateful buttons are ideal for displaying the state of notifications. Use `varia
|
|
|
125
125
|
```ts file="./ButtonStateful.tsx"
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
+
### Favorite
|
|
129
|
+
|
|
130
|
+
You can pass both the `isFavorite` and `variant="plain"` properties into the `<Button>` to create a favorite button. Passing the `isFavorited` property will determine the current favorited state and update styling accordingly.
|
|
131
|
+
|
|
132
|
+
```ts file = "./ButtonFavorite.tsx"
|
|
133
|
+
```
|
|
134
|
+
|
|
128
135
|
## Using router links
|
|
129
136
|
|
|
130
137
|
Router links can be used for in-app linking in React environments to prevent page reloading. To use a `Link` component from a router package, you can follow our [custom component example](#custom-component) and pass a callback to the `component` property of the `Button`:
|
|
@@ -133,4 +140,4 @@ Router links can be used for in-app linking in React environments to prevent pag
|
|
|
133
140
|
<Button variant="link" component={(props: any) => <Link {...props} to="#" />}>
|
|
134
141
|
Router link
|
|
135
142
|
</Button>
|
|
136
|
-
```
|
|
143
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ButtonFavorite: React.FunctionComponent = () => {
|
|
5
|
+
const [isFavorited, setIsFavorited] = useState(false);
|
|
6
|
+
const toggleFavorite = () => {
|
|
7
|
+
setIsFavorited(!isFavorited);
|
|
8
|
+
};
|
|
9
|
+
return (
|
|
10
|
+
<Button
|
|
11
|
+
variant="plain"
|
|
12
|
+
aria-label={isFavorited ? 'Favorite example favorited' : 'Favorite example not favorited'}
|
|
13
|
+
isFavorite
|
|
14
|
+
isFavorited={isFavorited}
|
|
15
|
+
onClick={toggleFavorite}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -12,6 +12,11 @@ export interface FormFieldGroupExpandableProps extends Omit<React.HTMLProps<HTML
|
|
|
12
12
|
isExpanded?: boolean;
|
|
13
13
|
/** Aria-label to use on the form field group toggle button */
|
|
14
14
|
toggleAriaLabel?: string;
|
|
15
|
+
/** Flag indicating whether an expandable form field group has animations. This will always render
|
|
16
|
+
* nested field group content rather than dynamically rendering them. This prop will be removed in
|
|
17
|
+
* the next breaking change release in favor of defaulting to always-rendered items.
|
|
18
|
+
*/
|
|
19
|
+
hasAnimations?: boolean;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export const FormFieldGroupExpandable: React.FunctionComponent<FormFieldGroupExpandableProps> = ({
|
|
@@ -20,6 +25,7 @@ export const FormFieldGroupExpandable: React.FunctionComponent<FormFieldGroupExp
|
|
|
20
25
|
header,
|
|
21
26
|
isExpanded = false,
|
|
22
27
|
toggleAriaLabel,
|
|
28
|
+
hasAnimations,
|
|
23
29
|
...props
|
|
24
30
|
}: FormFieldGroupExpandableProps) => {
|
|
25
31
|
const [localIsExpanded, setIsExpanded] = useState(isExpanded);
|
|
@@ -32,6 +38,7 @@ export const FormFieldGroupExpandable: React.FunctionComponent<FormFieldGroupExp
|
|
|
32
38
|
isExpanded={localIsExpanded}
|
|
33
39
|
toggleAriaLabel={toggleAriaLabel}
|
|
34
40
|
onToggle={() => setIsExpanded(!localIsExpanded)}
|
|
41
|
+
hasAnimations={hasAnimations}
|
|
35
42
|
{...props}
|
|
36
43
|
>
|
|
37
44
|
{children}
|
|
@@ -18,6 +18,11 @@ export interface InternalFormFieldGroupProps extends Omit<React.HTMLProps<HTMLDi
|
|
|
18
18
|
onToggle?: () => void;
|
|
19
19
|
/** Aria-label to use on the form field group toggle button */
|
|
20
20
|
toggleAriaLabel?: string;
|
|
21
|
+
/** Flag indicating whether an expandable form field group has animations. This will always render
|
|
22
|
+
* nested field group content rather than dynamically rendering them. This prop will be removed in
|
|
23
|
+
* the next breaking change release in favor of defaulting to always-rendered items.
|
|
24
|
+
*/
|
|
25
|
+
hasAnimations?: boolean;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
export const InternalFormFieldGroup: React.FunctionComponent<InternalFormFieldGroupProps> = ({
|
|
@@ -28,6 +33,7 @@ export const InternalFormFieldGroup: React.FunctionComponent<InternalFormFieldGr
|
|
|
28
33
|
isExpanded,
|
|
29
34
|
onToggle,
|
|
30
35
|
toggleAriaLabel,
|
|
36
|
+
hasAnimations,
|
|
31
37
|
...props
|
|
32
38
|
}: InternalFormFieldGroupProps) => {
|
|
33
39
|
const headerTitleText = header ? header.props.titleText : null;
|
|
@@ -40,7 +46,12 @@ export const InternalFormFieldGroup: React.FunctionComponent<InternalFormFieldGr
|
|
|
40
46
|
}
|
|
41
47
|
return (
|
|
42
48
|
<div
|
|
43
|
-
className={css(
|
|
49
|
+
className={css(
|
|
50
|
+
styles.formFieldGroup,
|
|
51
|
+
isExpanded && isExpandable && styles.modifiers.expanded,
|
|
52
|
+
hasAnimations && isExpandable && styles.modifiers.expandable,
|
|
53
|
+
className
|
|
54
|
+
)}
|
|
44
55
|
role="group"
|
|
45
56
|
{...(headerTitleText && { 'aria-labelledby': `${header.props.titleText.id}` })}
|
|
46
57
|
{...props}
|
|
@@ -59,8 +70,13 @@ export const InternalFormFieldGroup: React.FunctionComponent<InternalFormFieldGr
|
|
|
59
70
|
</GenerateId>
|
|
60
71
|
)}
|
|
61
72
|
{header && header}
|
|
62
|
-
{(!isExpandable || (isExpandable && isExpanded)) && (
|
|
63
|
-
<div
|
|
73
|
+
{(!isExpandable || (isExpandable && isExpanded) || (hasAnimations && isExpandable)) && (
|
|
74
|
+
<div
|
|
75
|
+
className={css(styles.formFieldGroupBody)}
|
|
76
|
+
{...(hasAnimations && isExpandable && !isExpanded && { inert: '' })}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</div>
|
|
64
80
|
)}
|
|
65
81
|
</div>
|
|
66
82
|
);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { FormFieldGroupExpandable } from '../FormFieldGroupExpandable';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/Form/form';
|
|
4
|
+
|
|
5
|
+
test('Does not render children by default', () => {
|
|
6
|
+
render(<FormFieldGroupExpandable toggleAriaLabel="Toggle label">Child content</FormFieldGroupExpandable>);
|
|
7
|
+
|
|
8
|
+
expect(screen.queryByText('Child content')).not.toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('Renders children when isExpanded is true', () => {
|
|
12
|
+
render(
|
|
13
|
+
<FormFieldGroupExpandable isExpanded toggleAriaLabel="Toggle label">
|
|
14
|
+
Child content
|
|
15
|
+
</FormFieldGroupExpandable>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect(screen.getByText('Child content')).toBeInTheDocument();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('Renders children with inert attribute by default when hasAnimations is true', () => {
|
|
22
|
+
render(
|
|
23
|
+
<FormFieldGroupExpandable hasAnimations toggleAriaLabel="Toggle label">
|
|
24
|
+
Child content
|
|
25
|
+
</FormFieldGroupExpandable>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(screen.getByText('Child content')).toHaveAttribute('inert', '');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('Does not render children with inert attribute when hasAnimations and isExpanded are true', () => {
|
|
32
|
+
render(
|
|
33
|
+
<FormFieldGroupExpandable hasAnimations isExpanded toggleAriaLabel="Toggle label">
|
|
34
|
+
Child content
|
|
35
|
+
</FormFieldGroupExpandable>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(screen.getByText('Child content')).not.toHaveAttribute('inert');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test(`Does not render with class ${styles.modifiers.expandable} by default`, () => {
|
|
42
|
+
render(<FormFieldGroupExpandable toggleAriaLabel="Toggle label">Child content</FormFieldGroupExpandable>);
|
|
43
|
+
|
|
44
|
+
expect(screen.getByRole('group')).not.toHaveClass(styles.modifiers.expandable);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test(`Renders with class ${styles.modifiers.expandable} when hasAnimations is true`, () => {
|
|
48
|
+
render(
|
|
49
|
+
<FormFieldGroupExpandable hasAnimations toggleAriaLabel="Toggle label">
|
|
50
|
+
Child content
|
|
51
|
+
</FormFieldGroupExpandable>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
expect(screen.getByRole('group')).toHaveClass(styles.modifiers.expandable);
|
|
55
|
+
});
|
|
@@ -52,6 +52,7 @@ export const FormFieldGroups: React.FunctionComponent = () => {
|
|
|
52
52
|
<TextInput isRequired id="0-label2" name="0-label2" value={inputValues['0-label2']} onChange={handleChange} />
|
|
53
53
|
</FormGroup>
|
|
54
54
|
<FormFieldGroupExpandable
|
|
55
|
+
hasAnimations
|
|
55
56
|
isExpanded
|
|
56
57
|
toggleAriaLabel="Details"
|
|
57
58
|
header={
|
|
@@ -67,6 +68,7 @@ export const FormFieldGroups: React.FunctionComponent = () => {
|
|
|
67
68
|
}
|
|
68
69
|
>
|
|
69
70
|
<FormFieldGroupExpandable
|
|
71
|
+
hasAnimations
|
|
70
72
|
isExpanded
|
|
71
73
|
toggleAriaLabel="Details"
|
|
72
74
|
header={
|
|
@@ -97,6 +99,7 @@ export const FormFieldGroups: React.FunctionComponent = () => {
|
|
|
97
99
|
</FormGroup>
|
|
98
100
|
</FormFieldGroupExpandable>
|
|
99
101
|
<FormFieldGroupExpandable
|
|
102
|
+
hasAnimations
|
|
100
103
|
toggleAriaLabel="Details"
|
|
101
104
|
header={
|
|
102
105
|
<FormFieldGroupHeader
|
|
@@ -125,6 +128,7 @@ export const FormFieldGroups: React.FunctionComponent = () => {
|
|
|
125
128
|
</FormGroup>
|
|
126
129
|
</FormFieldGroupExpandable>
|
|
127
130
|
<FormFieldGroupExpandable
|
|
131
|
+
hasAnimations
|
|
128
132
|
toggleAriaLabel="Details"
|
|
129
133
|
header={
|
|
130
134
|
<FormFieldGroupHeader
|
|
@@ -173,6 +177,7 @@ export const FormFieldGroups: React.FunctionComponent = () => {
|
|
|
173
177
|
</FormGroup>
|
|
174
178
|
</FormFieldGroupExpandable>
|
|
175
179
|
<FormFieldGroupExpandable
|
|
180
|
+
hasAnimations
|
|
176
181
|
toggleAriaLabel="Details"
|
|
177
182
|
header={
|
|
178
183
|
<FormFieldGroupHeader
|
|
@@ -194,6 +199,7 @@ export const FormFieldGroups: React.FunctionComponent = () => {
|
|
|
194
199
|
</FormGroup>
|
|
195
200
|
</FormFieldGroupExpandable>
|
|
196
201
|
<FormFieldGroupExpandable
|
|
202
|
+
hasAnimations
|
|
197
203
|
isExpanded
|
|
198
204
|
toggleAriaLabel="Details"
|
|
199
205
|
header={
|
|
@@ -273,7 +279,7 @@ export const FormFieldGroups: React.FunctionComponent = () => {
|
|
|
273
279
|
header={
|
|
274
280
|
<FormFieldGroupHeader
|
|
275
281
|
titleText={{ text: 'Field group 4 (non-expandable)', id: 'field-group4-non-expandable-titleText-id' }}
|
|
276
|
-
titleDescription="Field group 4 description text."
|
|
282
|
+
titleDescription="Field group 4 description text fdgsdg."
|
|
277
283
|
actions={
|
|
278
284
|
<>
|
|
279
285
|
<Button variant="link">Delete all</Button> <Button variant="secondary">Add parameter</Button>
|