@daoyi/nmtl-ui 2.0.1-beta.106 → 2.0.1-beta.107
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/lib/components/Filter.js +11 -4
- package/lib/components/Pagination.js +120 -50
- package/lib/components/globalConfig.js +27 -3
- package/package.json +1 -1
package/lib/components/Filter.js
CHANGED
|
@@ -739,12 +739,19 @@ var Filter = function Filter(_ref) {
|
|
|
739
739
|
setLiveMessage = _useState2[1];
|
|
740
740
|
var urlSearch = queryString.parse(search);
|
|
741
741
|
var FilterItem = He.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\t\tcolor: ", ";\n\t\t.filter__item--active {\n\t\t\tcolor: ", ";\n\t\t}\n\t\t:hover {\n\t\t\tcolor: ", ";\n\t\t}\n\t\t::after {\n\t\t\tcolor: ", ";\n\t\t}\n\t"])), textColor, textHoverColor || textColor, textHoverColor || textColor, textColor);
|
|
742
|
-
var handleClick = useCallback(function (key, title) {
|
|
742
|
+
var handleClick = useCallback(function (key, title, count) {
|
|
743
743
|
if (disabled) return;
|
|
744
744
|
if (onClick && typeof onClick === 'function') onClick(key);else historyAppendSearch(_defineProperty({
|
|
745
745
|
history: history
|
|
746
746
|
}, filterKey, key));
|
|
747
|
-
|
|
747
|
+
/* WCAG 4.1.3 篩選後播報結果筆數(實測回饋 R28):筆數是篩選效果最直接的回饋,
|
|
748
|
+
尤其結果為 0 筆時;各分類筆數已在各 chip 可及名稱中(隨選可得),不逐一播報 */
|
|
749
|
+
setLiveMessage(typeof count === 'number' ? getIntl().formatMessage({
|
|
750
|
+
id: 'aria.filter.appliedCount'
|
|
751
|
+
}, {
|
|
752
|
+
title: title,
|
|
753
|
+
count: count
|
|
754
|
+
}) : getIntl().formatMessage({
|
|
748
755
|
id: 'aria.filter.applied'
|
|
749
756
|
}, {
|
|
750
757
|
title: title
|
|
@@ -781,12 +788,12 @@ var Filter = function Filter(_ref) {
|
|
|
781
788
|
id: 'aria.filter.hint'
|
|
782
789
|
})),
|
|
783
790
|
onClick: function onClick() {
|
|
784
|
-
return handleClick(key, title);
|
|
791
|
+
return handleClick(key, title, count);
|
|
785
792
|
},
|
|
786
793
|
onKeyDown: function onKeyDown(event) {
|
|
787
794
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
788
795
|
event.preventDefault();
|
|
789
|
-
handleClick(key, title);
|
|
796
|
+
handleClick(key, title, count);
|
|
790
797
|
}
|
|
791
798
|
}
|
|
792
799
|
}, "".concat(title, "(").concat(count, ")"));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as _objectWithoutProperties$1 } from './_rollupPluginBabelHelpers-a52356f6.js';
|
|
1
|
+
import { c as _objectWithoutProperties$1, a as _slicedToArray$1 } from './_rollupPluginBabelHelpers-a52356f6.js';
|
|
2
2
|
import * as React$2 from 'react';
|
|
3
|
-
import React__default, { Children, isValidElement, cloneElement } from 'react';
|
|
3
|
+
import React__default, { Children, isValidElement, cloneElement, useState, useRef, useEffect } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { k as _objectWithoutProperties, o as _slicedToArray, _ as _extends, q as _objectWithoutPropertiesLoose, r as alpha, j as formatMuiErrorMessage } from './defaultTheme-ed7746fe.js';
|
|
6
6
|
import { u as useControlled, c as clsx, b as useEventCallback, w as withStyles, d as useIsFocusVisible, e as useForkRef, f as createSvgIcon, g as capitalize, h as debounce, r as requireCreateSvgIcon, i as interopRequireDefault, a as interopRequireWildcard } from './createSvgIcon-e3803ee1.js';
|
|
@@ -13,6 +13,7 @@ import * as ReactDOM from 'react-dom';
|
|
|
13
13
|
import ReactDOM__default from 'react-dom';
|
|
14
14
|
import { c as classNames } from './index-b76a85f4.js';
|
|
15
15
|
import { IconButton } from '@material-ui/core';
|
|
16
|
+
import { getIntl } from './globalConfig';
|
|
16
17
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
17
18
|
import './_commonjsHelpers-70de2c37.js';
|
|
18
19
|
|
|
@@ -3551,58 +3552,127 @@ var Pagination = function Pagination(_ref) {
|
|
|
3551
3552
|
var current = Number.parseInt(props.current, 10) || 1;
|
|
3552
3553
|
// eslint-disable-next-line react/destructuring-assignment
|
|
3553
3554
|
var defaultCurrent = Number.parseInt(props.defaultCurrent, 10) || 1;
|
|
3555
|
+
|
|
3556
|
+
/* WCAG 4.1.3 換頁後清單於原頁面更新,aria-live 播報(實測回饋 R29) */
|
|
3557
|
+
var _useState = useState(''),
|
|
3558
|
+
_useState2 = _slicedToArray$1(_useState, 2),
|
|
3559
|
+
liveMessage = _useState2[0],
|
|
3560
|
+
setLiveMessage = _useState2[1];
|
|
3561
|
+
var didMountRef = useRef(false);
|
|
3562
|
+
useEffect(function () {
|
|
3563
|
+
if (!didMountRef.current) {
|
|
3564
|
+
didMountRef.current = true;
|
|
3565
|
+
return undefined;
|
|
3566
|
+
}
|
|
3567
|
+
setLiveMessage(getIntl().formatMessage({
|
|
3568
|
+
id: 'aria.pagination.changed'
|
|
3569
|
+
}, {
|
|
3570
|
+
page: current
|
|
3571
|
+
}));
|
|
3572
|
+
var timer = setTimeout(function () {
|
|
3573
|
+
return setLiveMessage('');
|
|
3574
|
+
}, 3000);
|
|
3575
|
+
return function () {
|
|
3576
|
+
return clearTimeout(timer);
|
|
3577
|
+
};
|
|
3578
|
+
}, [current]);
|
|
3554
3579
|
var handlePageSelected = function handlePageSelected(event) {
|
|
3555
3580
|
var page = Number.parseInt(event.target.value, 10);
|
|
3556
3581
|
_onChange(page);
|
|
3557
3582
|
};
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3583
|
+
|
|
3584
|
+
/* WCAG 2.4.6 / 4.1.2 頁碼項可及名稱(實測回饋 R29):
|
|
3585
|
+
MUI 預設英文「Go to page N」,改為 locale 化「第 N 頁」;目前頁項另帶
|
|
3586
|
+
aria-current(MUI PaginationItem 內建) */
|
|
3587
|
+
var getItemAriaLabel = function getItemAriaLabel(type, page, selected) {
|
|
3588
|
+
if (type === 'page') {
|
|
3589
|
+
return getIntl().formatMessage({
|
|
3590
|
+
id: selected ? 'aria.pagination.pageCurrent' : 'aria.pagination.page'
|
|
3591
|
+
}, {
|
|
3592
|
+
page: page
|
|
3593
|
+
});
|
|
3594
|
+
}
|
|
3595
|
+
return undefined;
|
|
3596
|
+
};
|
|
3597
|
+
return (
|
|
3598
|
+
/*#__PURE__*/
|
|
3599
|
+
/* WCAG 1.3.1 分頁為導覽 landmark(實測回饋 R29) */
|
|
3600
|
+
React__default.createElement("nav", {
|
|
3601
|
+
className: classNames('ntml-pagination', className),
|
|
3602
|
+
"aria-label": getIntl().formatMessage({
|
|
3603
|
+
id: 'aria.pagination.nav'
|
|
3604
|
+
})
|
|
3605
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3606
|
+
className: "ntml-pagination__center"
|
|
3607
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3608
|
+
style: {
|
|
3609
|
+
display: 'flex',
|
|
3610
|
+
alignItems: 'center'
|
|
3611
|
+
}
|
|
3612
|
+
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
|
3613
|
+
"aria-label": getIntl().formatMessage({
|
|
3614
|
+
id: 'aria.pagination.prev'
|
|
3615
|
+
}),
|
|
3616
|
+
disabled: current === 1,
|
|
3617
|
+
onClick: function onClick() {
|
|
3618
|
+
return _onChange(current - 1);
|
|
3619
|
+
}
|
|
3620
|
+
}, /*#__PURE__*/React__default.createElement(default_1$1, {
|
|
3621
|
+
color: "secondary"
|
|
3622
|
+
})), /*#__PURE__*/React__default.createElement(MUIPagination, {
|
|
3623
|
+
color: "secondary",
|
|
3624
|
+
count: count,
|
|
3625
|
+
boundaryCount: 1,
|
|
3626
|
+
siblingCount: 0,
|
|
3627
|
+
page: current,
|
|
3628
|
+
defaultPage: defaultCurrent,
|
|
3629
|
+
hideNextButton: true,
|
|
3630
|
+
hidePrevButton: true,
|
|
3631
|
+
getItemAriaLabel: getItemAriaLabel,
|
|
3632
|
+
onChange: function onChange(event, value) {
|
|
3633
|
+
return _onChange(value);
|
|
3634
|
+
}
|
|
3635
|
+
}), /*#__PURE__*/React__default.createElement(IconButton, {
|
|
3636
|
+
"aria-label": getIntl().formatMessage({
|
|
3637
|
+
id: 'aria.pagination.next'
|
|
3638
|
+
}),
|
|
3639
|
+
disabled: current === count,
|
|
3640
|
+
onClick: function onClick() {
|
|
3641
|
+
return _onChange(current + 1);
|
|
3642
|
+
}
|
|
3643
|
+
}, /*#__PURE__*/React__default.createElement(default_1, {
|
|
3644
|
+
color: "secondary"
|
|
3645
|
+
})))), /*#__PURE__*/React__default.createElement("div", {
|
|
3646
|
+
className: "ntml-pagination__rightSide"
|
|
3647
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3648
|
+
className: "ntml-pagination__rightSide-showTotal"
|
|
3649
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
3650
|
+
"aria-hidden": "true"
|
|
3651
|
+
}, "\u76EE\u524D\u5728\u7B2C"), /*#__PURE__*/React__default.createElement(NativeSelect$1, {
|
|
3652
|
+
value: current,
|
|
3653
|
+
onChange: handlePageSelected,
|
|
3654
|
+
inputProps: {
|
|
3655
|
+
'aria-label': getIntl().formatMessage({
|
|
3656
|
+
id: 'aria.pagination.select'
|
|
3657
|
+
}, {
|
|
3658
|
+
page: current,
|
|
3659
|
+
totalPage: count
|
|
3660
|
+
})
|
|
3661
|
+
}
|
|
3662
|
+
}, pages.map(function (page, idx) {
|
|
3663
|
+
return /*#__PURE__*/React__default.createElement("option", {
|
|
3664
|
+
value: page,
|
|
3665
|
+
key: idx.toString()
|
|
3666
|
+
}, page);
|
|
3667
|
+
})), /*#__PURE__*/React__default.createElement("span", {
|
|
3668
|
+
"aria-hidden": "true"
|
|
3669
|
+
}, "\u9801\uFF0C\u5171".concat(count, "\u9801")))), /*#__PURE__*/React__default.createElement("div", {
|
|
3670
|
+
"aria-live": "polite",
|
|
3671
|
+
"aria-atomic": "true",
|
|
3672
|
+
role: "status",
|
|
3673
|
+
className: "visually-hidden"
|
|
3674
|
+
}, liveMessage))
|
|
3675
|
+
);
|
|
3606
3676
|
};
|
|
3607
3677
|
Pagination.defaultProps = {
|
|
3608
3678
|
className: undefined,
|
|
@@ -81,7 +81,15 @@ var zhtw = {
|
|
|
81
81
|
"aria.filter.applied": "已套用篩選:{title},結果已更新",
|
|
82
82
|
"aria.export.download": "(下載檔案)",
|
|
83
83
|
"aria.backTop": "回到頁面頂端",
|
|
84
|
-
"aria.moreButton.hintCollapse": "(點選後收合、僅顯示部分結果)"
|
|
84
|
+
"aria.moreButton.hintCollapse": "(點選後收合、僅顯示部分結果)",
|
|
85
|
+
"aria.filter.appliedCount": "已套用篩選:{title},共 {count} 筆結果",
|
|
86
|
+
"aria.pagination.nav": "分頁導覽",
|
|
87
|
+
"aria.pagination.prev": "上一頁",
|
|
88
|
+
"aria.pagination.next": "下一頁",
|
|
89
|
+
"aria.pagination.page": "第 {page} 頁",
|
|
90
|
+
"aria.pagination.pageCurrent": "第 {page} 頁,目前頁",
|
|
91
|
+
"aria.pagination.select": "選擇頁碼,目前在第 {page} 頁,共 {totalPage} 頁(選擇後結果將更新)",
|
|
92
|
+
"aria.pagination.changed": "已切換至第 {page} 頁,結果已更新"
|
|
85
93
|
};
|
|
86
94
|
|
|
87
95
|
var zhcn = {
|
|
@@ -151,7 +159,15 @@ var zhcn = {
|
|
|
151
159
|
"aria.filter.applied": "已套用筛选:{title},结果已更新",
|
|
152
160
|
"aria.export.download": "(下载档案)",
|
|
153
161
|
"aria.backTop": "回到页面顶端",
|
|
154
|
-
"aria.moreButton.hintCollapse": "(点选后收合、仅显示部分结果)"
|
|
162
|
+
"aria.moreButton.hintCollapse": "(点选后收合、仅显示部分结果)",
|
|
163
|
+
"aria.filter.appliedCount": "已套用筛选:{title},共 {count} 笔结果",
|
|
164
|
+
"aria.pagination.nav": "分页导览",
|
|
165
|
+
"aria.pagination.prev": "上一页",
|
|
166
|
+
"aria.pagination.next": "下一页",
|
|
167
|
+
"aria.pagination.page": "第 {page} 页",
|
|
168
|
+
"aria.pagination.pageCurrent": "第 {page} 页,目前页",
|
|
169
|
+
"aria.pagination.select": "选择页码,目前在第 {page} 页,共 {totalPage} 页(选择后结果将更新)",
|
|
170
|
+
"aria.pagination.changed": "已切换至第 {page} 页,结果已更新"
|
|
155
171
|
};
|
|
156
172
|
|
|
157
173
|
var enus = {
|
|
@@ -221,7 +237,15 @@ var enus = {
|
|
|
221
237
|
"aria.filter.applied": "Filter applied: {title}. Results updated",
|
|
222
238
|
"aria.export.download": " (downloads a file)",
|
|
223
239
|
"aria.backTop": "Back to top",
|
|
224
|
-
"aria.moreButton.hintCollapse": " (click to collapse results)"
|
|
240
|
+
"aria.moreButton.hintCollapse": " (click to collapse results)",
|
|
241
|
+
"aria.filter.appliedCount": "Filter applied: {title}. {count} results",
|
|
242
|
+
"aria.pagination.nav": "Pagination",
|
|
243
|
+
"aria.pagination.prev": "Previous page",
|
|
244
|
+
"aria.pagination.next": "Next page",
|
|
245
|
+
"aria.pagination.page": "Page {page}",
|
|
246
|
+
"aria.pagination.pageCurrent": "Page {page}, current page",
|
|
247
|
+
"aria.pagination.select": "Select page, currently on page {page} of {totalPage} (results update after selection)",
|
|
248
|
+
"aria.pagination.changed": "Moved to page {page}. Results updated"
|
|
225
249
|
};
|
|
226
250
|
|
|
227
251
|
var _languages;
|
package/package.json
CHANGED