Skip to content

Commit 5752d14

Browse files
chore: remove redundant string type (#10351)
1 parent 63b697d commit 5752d14

File tree

5 files changed

+44
-26
lines changed

5 files changed

+44
-26
lines changed

packages/react-core/src/components/NotificationDrawer/NotificationDrawerGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface NotificationDrawerGroupProps extends Omit<React.HTMLProps<HTMLD
2222
/** Callback for when group button is clicked to expand */
2323
onExpand?: (event: any, value: boolean) => void;
2424
/** Notification drawer group title */
25-
title: string | React.ReactNode;
25+
title: React.ReactNode;
2626
/** Truncate title to number of lines */
2727
truncateTitle?: number;
2828
/** Position of the tooltip which is displayed if text is truncated */

packages/react-core/src/deprecated/components/OptionsMenu/OptionsMenuItemGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface OptionsMenuItemGroupProps extends React.HTMLProps<HTMLElement>
1111
/** Provides an accessible name for the options menu items group */
1212
'aria-label'?: string;
1313
/** Optional title for the options menu items group */
14-
groupTitle?: string | React.ReactNode;
14+
groupTitle?: React.ReactNode;
1515
/** Flag indicating this options menu items group will be followed by a horizontal separator */
1616
hasSeparator?: boolean;
1717
}

packages/react-core/src/deprecated/components/Select/Select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export interface SelectProps
8686
/** Text displayed in typeahead select to prompt the user to create an item */
8787
createText?: string;
8888
/** Title text of Select */
89-
placeholderText?: string | React.ReactNode;
89+
placeholderText?: React.ReactNode;
9090
/** Text to display in typeahead select when no results are found */
9191
noResultsFoundText?: string;
9292
/** Array of selected items for multi select variants. */

packages/react-table/src/components/Table/TableTypes.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export interface IExtra extends IExtraData {
138138
}
139139

140140
export type IFormatterValueType = formatterValueType & {
141-
title?: string | React.ReactNode;
141+
title?: React.ReactNode;
142142
props?: any;
143143
};
144144

@@ -157,7 +157,7 @@ export interface IAction extends Omit<DropdownItemProps, 'title' | 'onClick'>, P
157157
/** Key of actions menu item */
158158
itemKey?: string;
159159
/** Content to display in the actions menu item */
160-
title?: string | React.ReactNode;
160+
title?: React.ReactNode;
161161
/** Render item as aria-disabled option */
162162
isAriaDisabled?: boolean;
163163
/** Props for adding a tooltip to a menu item. This is used to display tooltip when hovered over the item */
@@ -191,7 +191,7 @@ export interface decoratorReturnType {
191191
textCenter?: boolean;
192192
component?: string;
193193
isVisible?: boolean;
194-
title?: string | React.ReactNode;
194+
title?: React.ReactNode;
195195
props?: any;
196196
scope?: string;
197197
parentId?: number;
@@ -205,7 +205,7 @@ export type IFormatter = (data?: IFormatterValueType, extra?: IExtra) => formatt
205205

206206
export interface ICell {
207207
/* cell contents */
208-
title?: string | React.ReactNode;
208+
title?: React.ReactNode;
209209
/** transformations applied to the header cell */
210210
transforms?: ITransform[];
211211
/** transformations applied to the cells within the column's body */
@@ -229,7 +229,7 @@ export interface ICell {
229229
export type RowCellContent<T = any> = (value?: string, rowIndex?: number, cellIndex?: number, props?: T) => void;
230230

231231
export interface IRowCell<T = any> {
232-
title?: string | React.ReactNode | RowCellContent<T>;
232+
title?: React.ReactNode | RowCellContent<T>;
233233
props?: T;
234234
formatters?: IFormatter[];
235235
}

packages/react-table/src/deprecated/components/Table/examples/Table.md

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ import FolderIcon from '@patternfly/react-icons/dist/esm/icons/folder-icon';
2222
import FolderOpenIcon from '@patternfly/react-icons/dist/esm/icons/folder-open-icon';
2323
import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
2424
import { SelectOption as SelectOptionDeprecated } from '@patternfly/react-core/deprecated';
25-
import {
26-
Select as NewSelect,
27-
SelectGroup as NewSelectGroup,
28-
SelectList as NewSelectList,
29-
SelectOption as NewSelectOption,
25+
import {
26+
Select as NewSelect,
27+
SelectGroup as NewSelectGroup,
28+
SelectList as NewSelectList,
29+
SelectOption as NewSelectOption,
3030
} from '@patternfly/react-core/dist/esm/components/Select';
3131

32-
3332
import { css } from '@patternfly/react-styles';
3433
import styles from '@patternfly/react-styles/css/components/Table/table';
3534
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
@@ -48,7 +47,7 @@ cells: (ICell | string)[];
4847
```
4948
interface ICell {
5049
/* cell contents */
51-
title?: string | React.ReactNode;
50+
title?: React.ReactNode;
5251
/** transformations applied to the header cell */
5352
transforms?: ITransform[];
5453
/** transformations applied to the cells within the column's body */
@@ -111,7 +110,7 @@ interface IRow extends RowType {
111110
noPadding?: boolean;
112111
}
113112
interface IRowCell {
114-
title?: string | React.ReactNode | RowCellContent;
113+
title?: React.ReactNode | RowCellContent;
115114
props?: any;
116115
formatters?: IFormatter[];
117116
}
@@ -122,6 +121,7 @@ interface IRowCell {
122121
### Basic
123122

124123
```ts file="LegacyTableBasic.tsx"
124+
125125
```
126126

127127
### Custom row wrapper
@@ -152,6 +152,7 @@ interface RowWrapperProps {
152152
```
153153

154154
```ts file="LegacyTableMisc.tsx"
155+
155156
```
156157

157158
### Sortable & wrapping column headers
@@ -169,13 +170,15 @@ Note: If you want to add a tooltip/popover to a sortable header, in the `transfo
169170
The built in display for sorting is not fully responsive, as the column headers will be displayed per row when the screen size is small. The example below showcases how sorting may have a custom control display that can be used for small screen sizes.
170171

171172
```ts file="LegacyTableSortable.tsx"
173+
172174
```
173175

174176
### Sortable - custom control
175177

176178
Sorting a table may also be controlled with a toolbar. This toolbar item may also be hidden at large screen sizes and only displayed when the screen size is small to support responsive tables.
177179

178180
```ts file="LegacyTableSortableCustom.tsx"
181+
179182
```
180183

181184
### Selectable with checkbox
@@ -196,6 +199,7 @@ of using `td` elements, the cells in that column use `th` elements.
196199
checking checkboxes will check intermediate rows' checkboxes.
197200

198201
```ts file="LegacyTableSelectable.tsx"
202+
199203
```
200204

201205
### Selectable radio input
@@ -206,13 +210,15 @@ To enable row radio selection, set the `onSelect` callback prop on the Table, an
206210
To disable selection for a row, set `disableSelection: true` on the row definition.
207211

208212
```ts file="LegacyTableSelectableRadio.tsx"
213+
209214
```
210215

211216
### Clickable rows, selectable rows, and header cell tooltips/popovers
212217

213218
This selectable rows feature is intended for use when a table is used to present a list of objects in a Primary-detail view.
214219

215220
```ts file="LegacyTableClickable.tsx"
221+
216222
```
217223

218224
### Actions and first cell in body rows as th
@@ -222,6 +228,7 @@ To use actions you can either specify an array of actions and pass that into the
222228
If actions menus are getting clipped by other items on the page, such as sticky columns or rows, the `Table` can be passed a `actionsMenuAppendTo` prop to adjust where the actions menu is appended.
223229

224230
```ts file="LegacyTableActions.tsx"
231+
225232
```
226233

227234
### Expandable
@@ -232,6 +239,7 @@ The parent row can have an `isOpen` field for managing the expanded state of the
232239
Also, pass an `onCollapse` event handler via the prop on the Table
233240

234241
```ts file="LegacyTableExpandable.tsx"
242+
235243
```
236244

237245
### Compound expandable
@@ -248,26 +256,31 @@ To build a compound expandable table:
248256
4. An `onExpand` event handler prop should be passed to the Table.
249257

250258
```ts file="LegacyTableCompoundExpandable.tsx"
259+
251260
```
252261

253262
### With width and breakpoint visibility modifiers
254263

255264
```ts file="LegacyTableCellWidth.tsx"
265+
256266
```
257267

258268
### Controlling text
259269

260270
```ts file="LegacyTableControllingText.tsx"
271+
261272
```
262273

263274
### Modifiers with table text
264275

265276
```ts file="LegacyTableTextModifiers.tsx"
277+
266278
```
267279

268280
### Empty state
269281

270282
```ts file="LegacyTableEmptyState.tsx"
283+
271284
```
272285

273286
### Editable rows
@@ -330,13 +343,13 @@ class EditableRowsTable extends React.Component {
330343
],
331344
rows: [
332345
{
333-
rowEditBtnAriaLabel: idx => `Edit row ${idx}`,
334-
rowSaveBtnAriaLabel: idx => `Save edits for row ${idx}`,
335-
rowCancelBtnAriaLabel: idx => `Cancel edits for row ${idx}`,
346+
rowEditBtnAriaLabel: (idx) => `Edit row ${idx}`,
347+
rowSaveBtnAriaLabel: (idx) => `Save edits for row ${idx}`,
348+
rowCancelBtnAriaLabel: (idx) => `Cancel edits for row ${idx}`,
336349
rowEditValidationRules: [
337350
{
338351
name: 'required',
339-
validator: value => value.trim() !== '',
352+
validator: (value) => value.trim() !== '',
340353
errorText: 'This field is required'
341354
}
342355
],
@@ -537,22 +550,22 @@ class EditableRowsTable extends React.Component {
537550
rowEditValidationRules: [
538551
{
539552
name: 'required',
540-
validator: value => value.trim() !== '',
553+
validator: (value) => value.trim() !== '',
541554
errorText: 'This field is required'
542555
},
543556
{
544557
name: 'notFoo',
545-
validator: value => value.trim().toLowerCase() !== 'foo',
558+
validator: (value) => value.trim().toLowerCase() !== 'foo',
546559
errorText: 'Value cannot be "foo"'
547560
},
548561
{
549562
name: 'minLength',
550-
validator: value => value.trim().length >= 7,
563+
validator: (value) => value.trim().length >= 7,
551564
errorText: 'Value must be at least 7 characters'
552565
},
553566
{
554567
name: 'notXyz',
555-
validator: value => value.trim().toLowerCase() !== 'xyz',
568+
validator: (value) => value.trim().toLowerCase() !== 'xyz',
556569
errorText: 'Value cannot be xyz'
557570
}
558571
],
@@ -703,7 +716,7 @@ class EditableRowsTable extends React.Component {
703716
if (!newSelected.includes(newValue)) {
704717
newSelected.push(newValue);
705718
} else {
706-
newSelected = newSelected.filter(el => el !== newValue);
719+
newSelected = newSelected.filter((el) => el !== newValue);
707720
}
708721
newSelectOpen = true;
709722
break;
@@ -734,7 +747,7 @@ class EditableRowsTable extends React.Component {
734747
};
735748

736749
this.onToggle = (isOpen, rowIndex, cellIndex) => {
737-
console.log("isOpen", isOpen);
750+
console.log('isOpen', isOpen);
738751
let newRows = Array.from(this.state.rows);
739752
newRows[rowIndex].cells[cellIndex].props.isSelectOpen = isOpen;
740753
this.setState({
@@ -774,6 +787,7 @@ When you also pass a sort callback through the `onSort` prop, favorites sorting
774787
If you want to exclude favorites from sorting, set `canSortFavorites={false}` on the Table.
775788

776789
```ts file="LegacyTableFavoritable.tsx"
790+
777791
```
778792

779793
### Tree table
@@ -803,25 +817,29 @@ aria-posinset, and aria-setsize as violations. This is an intentional choice at
803817
the voice over technologies will recognize the flat table structure as a tree.
804818

805819
```ts file="LegacyTableTree.tsx"
820+
806821
```
807822

808823
### Striped
809824

810825
To apply striping to a basic table, add the `isStriped` property to `Table`.
811826

812827
```ts file="LegacyTableStriped.tsx"
828+
813829
```
814830

815831
### Striped expandable
816832

817833
To apply striping to an expandable table, add the `isStriped` and `isExpandable` properties to `Table`.
818834

819835
```ts file="LegacyTableStripedExpandable.tsx"
836+
820837
```
821838

822839
### Striped custom tr
823840

824841
To manually control striping, use a custom row wrapper that applies the `pf-m-striped` css class for each desired row.
825842

826843
```ts file="LegacyTableStripedCustomTr.tsx"
844+
827845
```

0 commit comments

Comments
 (0)