@patternfly/react-core 4.174.0 → 4.174.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.
- package/CHANGELOG.md +8 -0
- package/dist/esm/components/Pagination/Navigation.d.ts +2 -0
- package/dist/esm/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Navigation.js +4 -4
- package/dist/esm/components/Pagination/Navigation.js.map +1 -1
- package/dist/esm/components/Pagination/OptionsToggle.js +3 -3
- package/dist/esm/components/Pagination/OptionsToggle.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.d.ts +1 -1
- package/dist/esm/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js +27 -18
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.js +3 -14
- package/dist/esm/components/Pagination/PaginationOptionsMenu.js.map +1 -1
- package/dist/js/components/Pagination/Navigation.d.ts +2 -0
- package/dist/js/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/js/components/Pagination/Navigation.js +4 -4
- package/dist/js/components/Pagination/Navigation.js.map +1 -1
- package/dist/js/components/Pagination/OptionsToggle.js +3 -3
- package/dist/js/components/Pagination/OptionsToggle.js.map +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/js/components/Pagination/Pagination.js +30 -21
- package/dist/js/components/Pagination/Pagination.js.map +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.js +3 -14
- package/dist/js/components/Pagination/PaginationOptionsMenu.js.map +1 -1
- package/dist/umd/react-core.css +343 -87
- package/dist/umd/react-core.js +45 -46
- package/dist/umd/react-core.min.css +343 -87
- package/dist/umd/react-core.min.js +4 -4
- package/package.json +6 -6
- package/src/components/Pagination/Navigation.tsx +11 -4
- package/src/components/Pagination/OptionsToggle.tsx +3 -3
- package/src/components/Pagination/Pagination.tsx +40 -23
- package/src/components/Pagination/PaginationOptionsMenu.tsx +4 -15
- package/src/components/Pagination/__tests__/Generated/__snapshots__/Navigation.test.tsx.snap +0 -7
- package/src/components/Pagination/__tests__/Generated/__snapshots__/OptionsToggle.test.tsx.snap +1 -1
- package/src/components/Pagination/__tests__/Generated/__snapshots__/Pagination.test.tsx.snap +3 -8
- package/src/components/Pagination/__tests__/Pagination.test.tsx +24 -0
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +187 -157
- package/src/components/Pagination/examples/Pagination.md +35 -0
- package/src/components/TextInputGroup/examples/TextInputGroup.md +4 -4
- package/src/demos/TextInputGroupDemo.md +278 -0
package/dist/umd/react-core.js
CHANGED
|
@@ -4477,13 +4477,14 @@
|
|
|
4477
4477
|
"menu": "pf-c-menu",
|
|
4478
4478
|
"modifiers": {
|
|
4479
4479
|
"fullHeight": "pf-m-full-height",
|
|
4480
|
+
"expanded": "pf-m-expanded",
|
|
4480
4481
|
"action": "pf-m-action",
|
|
4481
4482
|
"disabled": "pf-m-disabled",
|
|
4482
4483
|
"plain": "pf-m-plain",
|
|
4483
4484
|
"splitButton": "pf-m-split-button",
|
|
4484
|
-
"active": "pf-m-active",
|
|
4485
|
-
"expanded": "pf-m-expanded",
|
|
4486
4485
|
"primary": "pf-m-primary",
|
|
4486
|
+
"active": "pf-m-active",
|
|
4487
|
+
"secondary": "pf-m-secondary",
|
|
4487
4488
|
"top": "pf-m-top",
|
|
4488
4489
|
"alignRight": "pf-m-align-right",
|
|
4489
4490
|
"alignLeft": "pf-m-align-left",
|
|
@@ -14583,9 +14584,10 @@
|
|
|
14583
14584
|
"menuToggleToggleIcon": "pf-c-menu-toggle__toggle-icon",
|
|
14584
14585
|
"modifiers": {
|
|
14585
14586
|
"primary": "pf-m-primary",
|
|
14587
|
+
"secondary": "pf-m-secondary",
|
|
14588
|
+
"expanded": "pf-m-expanded",
|
|
14586
14589
|
"plain": "pf-m-plain",
|
|
14587
14590
|
"text": "pf-m-text",
|
|
14588
|
-
"expanded": "pf-m-expanded",
|
|
14589
14591
|
"fullHeight": "pf-m-full-height"
|
|
14590
14592
|
}
|
|
14591
14593
|
};
|
|
@@ -14887,9 +14889,14 @@
|
|
|
14887
14889
|
var _default$v = {
|
|
14888
14890
|
"divider": "pf-c-divider",
|
|
14889
14891
|
"menu": "pf-c-menu",
|
|
14892
|
+
"menuContent": "pf-c-menu__content",
|
|
14890
14893
|
"menuItem": "pf-c-menu__item",
|
|
14891
14894
|
"menuListItem": "pf-c-menu__list-item",
|
|
14892
14895
|
"modifiers": {
|
|
14896
|
+
"flyout": "pf-m-flyout",
|
|
14897
|
+
"top": "pf-m-top",
|
|
14898
|
+
"left": "pf-m-left",
|
|
14899
|
+
"current": "pf-m-current",
|
|
14893
14900
|
"horizontal": "pf-m-horizontal",
|
|
14894
14901
|
"tertiary": "pf-m-tertiary",
|
|
14895
14902
|
"horizontalSubnav": "pf-m-horizontal-subnav",
|
|
@@ -14898,11 +14905,7 @@
|
|
|
14898
14905
|
"overflowHidden": "pf-m-overflow-hidden",
|
|
14899
14906
|
"expandable": "pf-m-expandable",
|
|
14900
14907
|
"expanded": "pf-m-expanded",
|
|
14901
|
-
"flyout": "pf-m-flyout",
|
|
14902
|
-
"top": "pf-m-top",
|
|
14903
|
-
"left": "pf-m-left",
|
|
14904
14908
|
"drilldown": "pf-m-drilldown",
|
|
14905
|
-
"current": "pf-m-current",
|
|
14906
14909
|
"start": "pf-m-start"
|
|
14907
14910
|
},
|
|
14908
14911
|
"nav": "pf-c-nav",
|
|
@@ -16225,7 +16228,7 @@
|
|
|
16225
16228
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16226
16229
|
perPage,
|
|
16227
16230
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16228
|
-
onSetPage, isDisabled, lastPage, firstPage, pagesTitle, toLastPage, toNextPage, toFirstPage, toPreviousPage, currPage, paginationTitle, ofWord, onNextClick, onPreviousClick, onFirstClick, onLastClick, onPageInput, className, isCompact } = _a, props = __rest$1(_a, ["page", "perPage", "onSetPage", "isDisabled", "lastPage", "firstPage", "pagesTitle", "toLastPage", "toNextPage", "toFirstPage", "toPreviousPage", "currPage", "paginationTitle", "ofWord", "onNextClick", "onPreviousClick", "onFirstClick", "onLastClick", "onPageInput", "className", "isCompact"]);
|
|
16231
|
+
onSetPage, isDisabled, itemCount, lastPage, firstPage, pagesTitle, toLastPage, toNextPage, toFirstPage, toPreviousPage, currPage, paginationTitle, ofWord, onNextClick, onPreviousClick, onFirstClick, onLastClick, onPageInput, className, isCompact } = _a, props = __rest$1(_a, ["page", "perPage", "onSetPage", "isDisabled", "itemCount", "lastPage", "firstPage", "pagesTitle", "toLastPage", "toNextPage", "toFirstPage", "toPreviousPage", "currPage", "paginationTitle", "ofWord", "onNextClick", "onPreviousClick", "onFirstClick", "onLastClick", "onPageInput", "className", "isCompact"]);
|
|
16229
16232
|
const { userInputPage } = this.state;
|
|
16230
16233
|
return (React__namespace.createElement("nav", Object.assign({ className: css(_default$p.paginationNav, className), "aria-label": paginationTitle }, props),
|
|
16231
16234
|
!isCompact && (React__namespace.createElement("div", { className: css(_default$p.paginationNavControl, _default$p.modifiers.first) },
|
|
@@ -16244,11 +16247,11 @@
|
|
|
16244
16247
|
}, "aria-label": toPreviousPage },
|
|
16245
16248
|
React__namespace.createElement(AngleLeftIcon$1, null))),
|
|
16246
16249
|
!isCompact && (React__namespace.createElement("div", { className: _default$p.paginationNavPageSelect },
|
|
16247
|
-
React__namespace.createElement("input", { className: css(_default$p.formControl), "aria-label": currPage, type: "number", disabled: isDisabled || (page === firstPage && page === lastPage) || page === 0, min: lastPage <= 0 && firstPage <= 0 ? 0 : 1, max: lastPage, value: userInputPage, onKeyDown: event => this.onKeyDown(event, page, lastPage, onPageInput), onChange: event => this.onChange(event, lastPage) }),
|
|
16248
|
-
React__namespace.createElement("span", { "aria-hidden": "true" },
|
|
16250
|
+
React__namespace.createElement("input", { className: css(_default$p.formControl), "aria-label": currPage, type: "number", disabled: isDisabled || (itemCount && page === firstPage && page === lastPage && itemCount >= 0) || page === 0, min: lastPage <= 0 && firstPage <= 0 ? 0 : 1, max: lastPage, value: userInputPage, onKeyDown: event => this.onKeyDown(event, page, lastPage, onPageInput), onChange: event => this.onChange(event, lastPage) }),
|
|
16251
|
+
(itemCount || itemCount === 0) && (React__namespace.createElement("span", { "aria-hidden": "true" },
|
|
16249
16252
|
ofWord,
|
|
16250
16253
|
" ",
|
|
16251
|
-
pagesTitle ? pluralize(lastPage, pagesTitle) : lastPage))),
|
|
16254
|
+
pagesTitle ? pluralize(lastPage, pagesTitle) : lastPage)))),
|
|
16252
16255
|
React__namespace.createElement("div", { className: _default$p.paginationNavControl },
|
|
16253
16256
|
React__namespace.createElement(Button, { variant: exports.ButtonVariant.plain, isDisabled: isDisabled || page === lastPage, "aria-label": toNextPage, "data-action": "next", onClick: event => {
|
|
16254
16257
|
const newPage = page + 1 <= lastPage ? page + 1 : lastPage;
|
|
@@ -16291,11 +16294,11 @@
|
|
|
16291
16294
|
let toggleId = 0;
|
|
16292
16295
|
const OptionsToggle = ({ itemsTitle = 'items', optionsToggle = 'Items per page',
|
|
16293
16296
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16294
|
-
itemsPerPageTitle = 'Items per page', ofWord = 'of', firstIndex = 0, lastIndex = 0, itemCount
|
|
16297
|
+
itemsPerPageTitle = 'Items per page', ofWord = 'of', firstIndex = 0, lastIndex = 0, itemCount, widgetId = '', showToggle = true,
|
|
16295
16298
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16296
|
-
onToggle = (_isOpen) => undefined, isOpen = false, isDisabled = false, parentRef = null, toggleTemplate: ToggleTemplate
|
|
16299
|
+
onToggle = (_isOpen) => undefined, isOpen = false, isDisabled = false, parentRef = null, toggleTemplate: ToggleTemplate, onEnter = null }) => (React__namespace.createElement("div", { className: css(_default$r.optionsMenuToggle, isDisabled && _default$r.modifiers.disabled, _default$r.modifiers.plain, _default$r.modifiers.text) }, showToggle && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
16297
16300
|
React__namespace.createElement("span", { className: css(_default$r.optionsMenuToggleText) }, typeof ToggleTemplate === 'string' ? (fillTemplate(ToggleTemplate, { firstIndex, lastIndex, ofWord, itemCount, itemsTitle })) : (React__namespace.createElement(ToggleTemplate, { firstIndex: firstIndex, lastIndex: lastIndex, ofWord: ofWord, itemCount: itemCount, itemsTitle: itemsTitle }))),
|
|
16298
|
-
React__namespace.createElement(DropdownToggle, { onEnter: onEnter, "aria-label": optionsToggle, onToggle: onToggle, isDisabled: isDisabled || itemCount <= 0, isOpen: isOpen, id: `${widgetId}-toggle-${toggleId++}`, className: _default$r.optionsMenuToggleButton, parentRef: parentRef })))));
|
|
16301
|
+
React__namespace.createElement(DropdownToggle, { onEnter: onEnter, "aria-label": optionsToggle, onToggle: onToggle, isDisabled: isDisabled || (itemCount && itemCount <= 0), isOpen: isOpen, id: `${widgetId}-toggle-${toggleId++}`, className: _default$r.optionsMenuToggleButton, parentRef: parentRef })))));
|
|
16299
16302
|
OptionsToggle.displayName = 'OptionsToggle';
|
|
16300
16303
|
|
|
16301
16304
|
class PaginationOptionsMenu extends React__namespace.Component {
|
|
@@ -16354,19 +16357,7 @@
|
|
|
16354
16357
|
baseComponent: 'div',
|
|
16355
16358
|
ouiaComponentType: PaginationOptionsMenu.displayName
|
|
16356
16359
|
} },
|
|
16357
|
-
React__namespace.createElement(DropdownWithContext, { direction: dropDirection, isOpen: isOpen, toggle: React__namespace.createElement(OptionsToggle, { optionsToggle: optionsToggle, itemsPerPageTitle: itemsPerPageTitle, showToggle: perPageOptions && perPageOptions.length > 0, onToggle: this.onToggle, isOpen: isOpen, widgetId: widgetId, firstIndex: firstIndex, lastIndex: lastIndex, itemCount: itemCount, itemsTitle: itemsTitle, ofWord: ofWord, toggleTemplate: toggleTemplate
|
|
16358
|
-
? toggleTemplate
|
|
16359
|
-
: ({ firstIndex, lastIndex, itemCount, ofWord, itemsTitle }) => (React__namespace.createElement(React__namespace.Fragment, null,
|
|
16360
|
-
React__namespace.createElement("b", null,
|
|
16361
|
-
firstIndex,
|
|
16362
|
-
" - ",
|
|
16363
|
-
lastIndex),
|
|
16364
|
-
' ',
|
|
16365
|
-
ofWord,
|
|
16366
|
-
" ",
|
|
16367
|
-
React__namespace.createElement("b", null, itemCount),
|
|
16368
|
-
" ",
|
|
16369
|
-
itemsTitle)), parentRef: this.parentRef.current, isDisabled: isDisabled }), dropdownItems: this.renderItems(), isPlain: true })));
|
|
16360
|
+
React__namespace.createElement(DropdownWithContext, { direction: dropDirection, isOpen: isOpen, toggle: React__namespace.createElement(OptionsToggle, { optionsToggle: optionsToggle, itemsPerPageTitle: itemsPerPageTitle, showToggle: perPageOptions && perPageOptions.length > 0, onToggle: this.onToggle, isOpen: isOpen, widgetId: widgetId, firstIndex: firstIndex, lastIndex: lastIndex, itemCount: itemCount, itemsTitle: itemsTitle, ofWord: ofWord, toggleTemplate: toggleTemplate, parentRef: this.parentRef.current, isDisabled: isDisabled }), dropdownItems: this.renderItems(), isPlain: true })));
|
|
16370
16361
|
}
|
|
16371
16362
|
}
|
|
16372
16363
|
PaginationOptionsMenu.displayName = 'PaginationOptionsMenu';
|
|
@@ -16384,8 +16375,8 @@
|
|
|
16384
16375
|
firstIndex: 0,
|
|
16385
16376
|
lastIndex: 0,
|
|
16386
16377
|
defaultToFullPage: false,
|
|
16387
|
-
itemCount: 0,
|
|
16388
16378
|
itemsTitle: 'items',
|
|
16379
|
+
toggleTemplate: ToggleTemplate,
|
|
16389
16380
|
onPerPageSelect: () => null
|
|
16390
16381
|
};
|
|
16391
16382
|
|
|
@@ -16441,8 +16432,9 @@
|
|
|
16441
16432
|
};
|
|
16442
16433
|
}
|
|
16443
16434
|
getLastPage() {
|
|
16444
|
-
const { itemCount, perPage } = this.props;
|
|
16445
|
-
|
|
16435
|
+
const { itemCount, perPage, page } = this.props;
|
|
16436
|
+
// when itemCount is not known let's set lastPage as page+1 as we don't know the total count
|
|
16437
|
+
return itemCount || itemCount === 0 ? Math.ceil(itemCount / perPage) || 0 : page + 1;
|
|
16446
16438
|
}
|
|
16447
16439
|
componentDidMount() {
|
|
16448
16440
|
const node = this.paginationRef.current;
|
|
@@ -16461,26 +16453,34 @@
|
|
|
16461
16453
|
if (!page && offset) {
|
|
16462
16454
|
page = Math.ceil(offset / perPage);
|
|
16463
16455
|
}
|
|
16464
|
-
|
|
16465
|
-
|
|
16466
|
-
page = firstPage;
|
|
16467
|
-
}
|
|
16468
|
-
else if (page > lastPage) {
|
|
16469
|
-
page = lastPage;
|
|
16456
|
+
if (page === 0 && !itemCount) {
|
|
16457
|
+
page = 1;
|
|
16470
16458
|
}
|
|
16471
|
-
const
|
|
16472
|
-
let
|
|
16473
|
-
|
|
16474
|
-
|
|
16475
|
-
|
|
16476
|
-
|
|
16477
|
-
|
|
16459
|
+
const lastPage = this.getLastPage();
|
|
16460
|
+
let firstIndex = (page - 1) * perPage + 1;
|
|
16461
|
+
let lastIndex = page * perPage;
|
|
16462
|
+
if (itemCount || itemCount === 0) {
|
|
16463
|
+
firstIndex = itemCount <= 0 ? 0 : (page - 1) * perPage + 1;
|
|
16464
|
+
if (page < firstPage && itemCount > 0) {
|
|
16465
|
+
page = firstPage;
|
|
16466
|
+
}
|
|
16467
|
+
else if (page > lastPage) {
|
|
16468
|
+
page = lastPage;
|
|
16469
|
+
}
|
|
16470
|
+
if (itemCount >= 0) {
|
|
16471
|
+
lastIndex = page === lastPage || itemCount === 0 ? itemCount : page * perPage;
|
|
16472
|
+
}
|
|
16478
16473
|
}
|
|
16474
|
+
const toggleTemplateProps = { firstIndex, lastIndex, itemCount, itemsTitle: titles.items, ofWord: titles.ofWord };
|
|
16479
16475
|
return (React__namespace.createElement("div", Object.assign({ ref: this.paginationRef, className: css(_default$p.pagination, variant === exports.PaginationVariant.bottom && _default$p.modifiers.bottom, isCompact && _default$p.modifiers.compact, isStatic && _default$p.modifiers.static, isSticky && _default$p.modifiers.sticky, className), id: `${widgetId}-${paginationId++}` }, getOUIAProps(Pagination.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe), props),
|
|
16480
16476
|
variant === exports.PaginationVariant.top && (React__namespace.createElement("div", { className: css(_default$p.paginationTotalItems) },
|
|
16481
|
-
|
|
16477
|
+
toggleTemplate && typeof toggleTemplate === 'string' && fillTemplate(toggleTemplate, toggleTemplateProps),
|
|
16478
|
+
toggleTemplate &&
|
|
16479
|
+
typeof toggleTemplate !== 'string' &&
|
|
16480
|
+
toggleTemplate(toggleTemplateProps),
|
|
16481
|
+
!toggleTemplate && (React__namespace.createElement(ToggleTemplate, { firstIndex: firstIndex, lastIndex: lastIndex, itemCount: itemCount, itemsTitle: titles.items, ofWord: titles.ofWord })))),
|
|
16482
16482
|
React__namespace.createElement(PaginationOptionsMenu, { itemsPerPageTitle: titles.itemsPerPage, perPageSuffix: titles.perPageSuffix, itemsTitle: isCompact ? '' : titles.items, optionsToggle: titles.optionsToggle, perPageOptions: perPageOptions, firstIndex: itemsStart !== null ? itemsStart : firstIndex, lastIndex: itemsEnd !== null ? itemsEnd : lastIndex, ofWord: titles.ofWord, defaultToFullPage: defaultToFullPage, itemCount: itemCount, page: page, perPage: perPage, lastPage: lastPage, onPerPageSelect: onPerPageSelect, dropDirection: dropDirection, widgetId: widgetId, toggleTemplate: toggleTemplate, isDisabled: isDisabled }),
|
|
16483
|
-
React__namespace.createElement(Navigation, { pagesTitle: titles.page, toLastPage: titles.toLastPage, toPreviousPage: titles.toPreviousPage, toNextPage: titles.toNextPage, toFirstPage: titles.toFirstPage, currPage: titles.currPage, paginationTitle: titles.paginationTitle, ofWord: titles.ofWord, page: itemCount <= 0 ? 0 : page, perPage: perPage, firstPage: itemsStart !== null ? itemsStart : 1, lastPage: lastPage, onSetPage: onSetPage, onFirstClick: onFirstClick, onPreviousClick: onPreviousClick, onNextClick: onNextClick, onLastClick: onLastClick, onPageInput: onPageInput, isDisabled: isDisabled, isCompact: isCompact }),
|
|
16483
|
+
React__namespace.createElement(Navigation, { pagesTitle: titles.page, toLastPage: titles.toLastPage, toPreviousPage: titles.toPreviousPage, toNextPage: titles.toNextPage, toFirstPage: titles.toFirstPage, currPage: titles.currPage, paginationTitle: titles.paginationTitle, ofWord: titles.ofWord, page: itemCount && itemCount <= 0 ? 0 : page, perPage: perPage, itemCount: itemCount, firstPage: itemsStart !== null ? itemsStart : 1, lastPage: lastPage, onSetPage: onSetPage, onFirstClick: onFirstClick, onPreviousClick: onPreviousClick, onNextClick: onNextClick, onLastClick: onLastClick, onPageInput: onPageInput, isDisabled: isDisabled, isCompact: isCompact }),
|
|
16484
16484
|
children));
|
|
16485
16485
|
}
|
|
16486
16486
|
}
|
|
@@ -16515,7 +16515,6 @@
|
|
|
16515
16515
|
itemsEnd: null,
|
|
16516
16516
|
perPageOptions: defaultPerPageOptions,
|
|
16517
16517
|
widgetId: 'pagination-options-menu',
|
|
16518
|
-
toggleTemplate: ToggleTemplate,
|
|
16519
16518
|
onSetPage: () => undefined,
|
|
16520
16519
|
onPerPageSelect: () => undefined,
|
|
16521
16520
|
onFirstClick: () => undefined,
|