@daoyi/nmtl-ui 2.0.1-beta.126 → 2.0.1-beta.127

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.
@@ -3,7 +3,7 @@ import React__default, { createContext, forwardRef, createElement, useContext, u
3
3
  import PropTypes from 'prop-types';
4
4
  import { h as hoistNonReactStatics_cjs } from './hoist-non-react-statics.cjs-3f408ad2.js';
5
5
  import axios from 'axios';
6
- import { M as Modal } from './Modal-b62ff592.js';
6
+ import { M as Modal } from './Modal-e04532fa.js';
7
7
  import { c as commonjsGlobal, a as getDefaultExportFromCjs } from './_commonjsHelpers-70de2c37.js';
8
8
  import { c as classNames } from './index-b76a85f4.js';
9
9
  import { Input, IconButton, Button, Box, Typography, FormControl, RadioGroup, FormControlLabel, Radio, TextField, TextareaAutosize } from '@material-ui/core';
@@ -12,7 +12,7 @@ import 'react-is';
12
12
  import '@material-ui/styles';
13
13
  import { u as useTheme } from './useTheme-d16d02d9.js';
14
14
  import './withTheme-2d778133.js';
15
- import { S as Select } from './Select-141d7992.js';
15
+ import { S as Select } from './Select-cb3e1ba1.js';
16
16
  import { VolumeUp } from '@material-ui/icons';
17
17
  import { getIntl } from './globalConfig';
18
18
  import { s as styleInject } from './style-inject.es-1f59c1d0.js';
@@ -1,11 +1,11 @@
1
- export { C as default } from './ContactModal-ac82e7a6.js';
1
+ export { C as default } from './ContactModal-7e5b14e8.js';
2
2
  import './_rollupPluginBabelHelpers-a52356f6.js';
3
3
  import 'react';
4
4
  import 'prop-types';
5
5
  import './hoist-non-react-statics.cjs-3f408ad2.js';
6
6
  import 'react-is';
7
7
  import 'axios';
8
- import './Modal-b62ff592.js';
8
+ import './Modal-e04532fa.js';
9
9
  import './index-b76a85f4.js';
10
10
  import '@material-ui/core';
11
11
  import '@material-ui/icons';
@@ -18,7 +18,7 @@ import './defaultTheme-ed7746fe.js';
18
18
  import '@material-ui/styles';
19
19
  import './useTheme-d16d02d9.js';
20
20
  import './withTheme-2d778133.js';
21
- import './Select-141d7992.js';
21
+ import './Select-cb3e1ba1.js';
22
22
  import './Empty-c6a44967.js';
23
23
  import './createSvgIcon-e3803ee1.js';
24
24
  import 'react-dom';
@@ -3,7 +3,7 @@ import React__default, { useState } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { List, ListItem, ListItemIcon, ListItemText, IconButton, Drawer as Drawer$1, Divider } from '@material-ui/core';
5
5
  import { DehazeRounded } from '@material-ui/icons';
6
- import { S as Select } from './Select-141d7992.js';
6
+ import { S as Select } from './Select-cb3e1ba1.js';
7
7
  import { useHistory, useRouteMatch } from 'react-router-dom';
8
8
  import { getIntl } from './globalConfig';
9
9
  import { s as styleInject } from './style-inject.es-1f59c1d0.js';
@@ -1,10 +1,10 @@
1
- export { D as default } from './Drawer-48414c2e.js';
1
+ export { D as default } from './Drawer-629e59c7.js';
2
2
  import './_rollupPluginBabelHelpers-a52356f6.js';
3
3
  import 'react';
4
4
  import 'prop-types';
5
5
  import '@material-ui/core';
6
6
  import '@material-ui/icons';
7
- import './Select-141d7992.js';
7
+ import './Select-cb3e1ba1.js';
8
8
  import './index-b76a85f4.js';
9
9
  import './defaultTheme-ed7746fe.js';
10
10
  import 'react-is';
@@ -13,5 +13,5 @@ import './useTheme-d16d02d9.js';
13
13
  import './withTheme-2d778133.js';
14
14
  import './Empty-c6a44967.js';
15
15
  import './style-inject.es-1f59c1d0.js';
16
- import 'react-router-dom';
17
16
  import './globalConfig';
17
+ import 'react-router-dom';
@@ -7,6 +7,7 @@ import { a as getDefaultExportFromCjs } from './_commonjsHelpers-70de2c37.js';
7
7
  import { Menu, MenuItem, useMediaQuery, IconButton } from '@material-ui/core';
8
8
  import { T as Tooltip } from './Tooltip-6ebfa9c1.js';
9
9
  import { s as snaToExcel, f as fileDownload$1, a as jsonExcel } from './dataExport-a9e3fae1.js';
10
+ import { getIntl } from './globalConfig';
10
11
  import { s as styleInject } from './style-inject.es-1f59c1d0.js';
11
12
 
12
13
  var __assign$3 = (undefined && undefined.__assign) || function () {
@@ -3169,18 +3170,24 @@ const ShareButton = _ref => {
3169
3170
  let {
3170
3171
  className
3171
3172
  } = _ref;
3173
+ /* WCAG 4.1.2:react-share 預設 aria-label 只有 "facebook",讀屏聽不出點下去會做什麼;
3174
+ 一律改為「分享至 Facebook」(走查回饋 5c)。
3175
+ 字串走套件自帶的 getIntl(元件內部字串),不依賴各站的訊息檔 */
3176
+ const shareLabel = getIntl().formatMessage({
3177
+ id: 'common.share.facebook'
3178
+ });
3172
3179
  return /*#__PURE__*/React__default.createElement("div", {
3173
3180
  className: classNames('extraTools__share', className)
3174
3181
  }, /*#__PURE__*/React__default.createElement(FacebookShareButton, {
3175
3182
  url: document.location.href,
3176
- "aria-label": "\u5206\u4EAB\u81F3 Facebook"
3183
+ "aria-label": shareLabel
3177
3184
  }, /*#__PURE__*/React__default.createElement(FacebookIcon, {
3178
3185
  size: 32,
3179
3186
  round: true,
3180
3187
  "aria-hidden": "true"
3181
3188
  }), /*#__PURE__*/React__default.createElement("span", {
3182
3189
  style: hiddenTextStyle
3183
- }, "\u5206\u4EAB\u81F3 Facebook")));
3190
+ }, shareLabel)));
3184
3191
  };
3185
3192
  ShareButton.defaultProps = {
3186
3193
  className: undefined
@@ -3204,18 +3211,31 @@ const DownloadMenu = _ref2 => {
3204
3211
  exportFileName
3205
3212
  } = _ref2;
3206
3213
  const [anchorEl, setAnchorEl] = useState(null);
3214
+ /* react-data-export 的隱藏觸發器(見下方 xlsxTrigger 說明) */
3215
+ const xlsxTriggerRef = useRef(null);
3207
3216
  const hideButton = type => (exclude || []).filter(key => key === type).length > 0;
3217
+ const t = (key, fallback) => intl ? intl.formatMessage({
3218
+ id: key
3219
+ }) : fallback;
3220
+ const downloadLabel = t('knowledge.writersAndWorksSNA.download', '下載');
3221
+
3222
+ /* xlsx 需由 react-data-export 產生檔案,但它只會把傳入的 element 包一層 <span onClick>;
3223
+ 若直接把 MenuItem 交給它,選單裡就會出現 <span><li role="menuitem"></span>——
3224
+ 既不是 role="menu" 的合法子項,MUI MenuList 的上下鍵巡覽(走 nextElementSibling
3225
+ 且要求元素自帶 tabindex)也會直接跳過它,造成「最後一個選項選不到」(走查回饋 2/5b)。
3226
+ 改為:選單一律只放真 MenuItem,xlsx 的下載動作轉由選單外的隱藏觸發器代打。 */
3227
+ const hasXlsx = !hideButton('downloadXls') && Boolean(DownloadExcel);
3208
3228
  const btns = [{
3209
3229
  key: 'downloadImage',
3210
3230
  onClick: () => domToImage({
3211
3231
  id: domToImageId,
3212
3232
  fileName: `${exportFileName}_${exportDateSuffix()}`
3213
3233
  }),
3214
- label: intl ? 'knowledge.writersAndWorksSNA.download.img' : '下載圖片'
3234
+ label: t('knowledge.writersAndWorksSNA.download.img', '下載圖片')
3215
3235
  }, {
3216
3236
  key: 'downloadGephi',
3217
3237
  onClick: () => downloadGephi(data),
3218
- label: intl ? 'knowledge.writersAndWorksSNA.download.gephi' : '下載Gephi'
3238
+ label: t('knowledge.writersAndWorksSNA.download.gephi', '下載Gephi')
3219
3239
  }, {
3220
3240
  key: 'downloadTsv',
3221
3241
  onClick: () => exportXlsx({
@@ -3224,34 +3244,33 @@ const DownloadMenu = _ref2 => {
3224
3244
  extType: 'tsv',
3225
3245
  fileName: exportFileName
3226
3246
  }),
3227
- label: intl ? 'knowledge.writersAndWorksSNA.download.tsv' : '下載Tsv'
3247
+ label: t('knowledge.writersAndWorksSNA.download.tsv', '下載Tsv')
3228
3248
  }, {
3229
3249
  key: 'downloadXls',
3230
- // download click trigger 交給 react-data-export
3231
- label: intl ? 'knowledge.writersAndWorksSNA.download.xls' : '下載Excel'
3250
+ onClick: () => xlsxTriggerRef.current && xlsxTriggerRef.current.click(),
3251
+ label: t('knowledge.writersAndWorksSNA.download.xls', '下載Excel'),
3252
+ requireExcel: true
3232
3253
  }];
3233
- // eslint-disable-next-line no-confusing-arrow
3234
- const isXlsxButton = (key, dom) => key === 'downloadXls' && DownloadExcel ? /*#__PURE__*/React__default.createElement(DownloadExcel, {
3235
- key: key,
3236
- element: dom,
3237
- data: data
3238
- }) : dom;
3254
+ const menuItems = btns.filter(_ref3 => {
3255
+ let {
3256
+ key,
3257
+ requireExcel
3258
+ } = _ref3;
3259
+ return !hideButton(key) && (!requireExcel || hasXlsx);
3260
+ });
3239
3261
  return /*#__PURE__*/React__default.createElement("div", {
3240
3262
  className: classNames('extraTools__download', className)
3241
3263
  }, /*#__PURE__*/React__default.createElement(Tooltip, {
3242
- title: intl ? intl.formatMessage({
3243
- id: 'knowledge.writersAndWorksSNA.download'
3244
- }) : '下載',
3264
+ title: downloadLabel,
3245
3265
  placement: "bottom"
3246
3266
  }, /*#__PURE__*/React__default.createElement("div", {
3247
3267
  className: "extraTools__download-icon",
3248
3268
  role: "button",
3249
3269
  tabIndex: 0,
3250
- "aria-label": intl ? intl.formatMessage({
3251
- id: 'knowledge.writersAndWorksSNA.download'
3252
- }) : '下載',
3270
+ "aria-label": downloadLabel,
3253
3271
  "aria-haspopup": "menu",
3254
3272
  "aria-expanded": Boolean(anchorEl),
3273
+ "aria-controls": anchorEl ? 'download-menu' : undefined,
3255
3274
  onClick: e => setAnchorEl(e.currentTarget),
3256
3275
  onKeyDown: e => {
3257
3276
  if (e.key === 'Enter' || e.key === ' ') {
@@ -3267,19 +3286,35 @@ const DownloadMenu = _ref2 => {
3267
3286
  anchorEl: anchorEl,
3268
3287
  keepMounted: true,
3269
3288
  open: Boolean(anchorEl),
3270
- onClose: () => setAnchorEl(null)
3271
- }, btns.map(_ref3 => {
3289
+ onClose: () => setAnchorEl(null),
3290
+ MenuListProps: {
3291
+ 'aria-label': downloadLabel
3292
+ }
3293
+ }, menuItems.map(_ref4 => {
3272
3294
  let {
3273
3295
  key,
3274
3296
  onClick,
3275
- label
3276
- } = _ref3;
3277
- return !hideButton(key) && isXlsxButton(key, /*#__PURE__*/React__default.createElement(MenuItem, {
3297
+ label: itemLabel
3298
+ } = _ref4;
3299
+ return /*#__PURE__*/React__default.createElement(MenuItem, {
3278
3300
  key: key,
3279
- onClick: onClick
3280
- }, intl ? intl.formatMessage({
3281
- id: label
3282
- }) : label));
3301
+ onClick: () => {
3302
+ /* 選完就關閉,焦點由 MUI 交還給觸發器(WCAG 2.4.3) */
3303
+ setAnchorEl(null);
3304
+ onClick();
3305
+ }
3306
+ }, itemLabel);
3307
+ })), hasXlsx && /*#__PURE__*/React__default.createElement("div", {
3308
+ className: "extraTools__download-xlsx",
3309
+ style: {
3310
+ display: 'none'
3311
+ },
3312
+ "aria-hidden": "true"
3313
+ }, /*#__PURE__*/React__default.createElement(DownloadExcel, {
3314
+ data: data,
3315
+ element: /*#__PURE__*/React__default.createElement("span", {
3316
+ ref: xlsxTriggerRef
3317
+ })
3283
3318
  })));
3284
3319
  };
3285
3320
  DownloadMenu.defaultProps = {
@@ -3315,13 +3350,13 @@ DownloadMenu.propTypes = {
3315
3350
  /** 匯出檔名前綴(下載圖片/Tsv 檔名=前綴_YYYY-MM-DD) */
3316
3351
  exportFileName: PropTypes.string
3317
3352
  };
3318
- const FullscreenBtn = _ref4 => {
3353
+ const FullscreenBtn = _ref5 => {
3319
3354
  let {
3320
3355
  className,
3321
3356
  intl,
3322
3357
  iconColor,
3323
3358
  fullscreenDomId
3324
- } = _ref4;
3359
+ } = _ref5;
3325
3360
  return /*#__PURE__*/React__default.createElement("div", {
3326
3361
  className: classNames('extraTools__fullscreenBtn', className)
3327
3362
  }, /*#__PURE__*/React__default.createElement(Tooltip, {
@@ -3368,14 +3403,14 @@ FullscreenBtn.propTypes = {
3368
3403
  /** 全螢幕指定DOM */
3369
3404
  fullscreenDomId: PropTypes.string
3370
3405
  };
3371
- const FontSizeChanger = _ref5 => {
3406
+ const FontSizeChanger = _ref6 => {
3372
3407
  let {
3373
3408
  className,
3374
3409
  intl,
3375
3410
  iconColor,
3376
3411
  FontSizeTargets,
3377
3412
  FontSizeOptions
3378
- } = _ref5;
3413
+ } = _ref6;
3379
3414
  /* WCAG 2.1.1/4.1.2 react-font-size-changer 渲染的 A+/A− 為純 div onClick、
3380
3415
  無法聚焦也無鍵盤操作(第三方庫不提供 prop):掛載後補 tabindex/role/aria-label/Enter+Space */
3381
3416
  const rootRef = useRef(null);
@@ -3466,13 +3501,13 @@ FontSizeChanger.propTypes = {
3466
3501
  /** 改變文字的選項 */
3467
3502
  FontSizeOptions: PropTypes.objectOf(PropTypes.any)
3468
3503
  };
3469
- const SNAResetBtn = _ref6 => {
3504
+ const SNAResetBtn = _ref7 => {
3470
3505
  let {
3471
3506
  className,
3472
3507
  intl,
3473
3508
  iconColor,
3474
3509
  renderSNA
3475
- } = _ref6;
3510
+ } = _ref7;
3476
3511
  const isMobile = useMediaQuery('(max-width: 746px)');
3477
3512
  return /*#__PURE__*/React__default.createElement("div", {
3478
3513
  className: classNames('extraTools__resetSNA', className)
@@ -1,4 +1,4 @@
1
- export { E as default } from './ExtraTools-0f9ca8be.js';
1
+ export { E as default } from './ExtraTools-11d483d5.js';
2
2
  import './_rollupPluginBabelHelpers-a52356f6.js';
3
3
  import 'react';
4
4
  import './index-b76a85f4.js';
@@ -8,3 +8,4 @@ import '@material-ui/core';
8
8
  import './Tooltip-6ebfa9c1.js';
9
9
  import './style-inject.es-1f59c1d0.js';
10
10
  import './dataExport-a9e3fae1.js';
11
+ import './globalConfig';
@@ -3,13 +3,13 @@ import React__default, { useState, useEffect } from 'react';
3
3
  import { c as classNames } from './index-b76a85f4.js';
4
4
  import PropTypes from 'prop-types';
5
5
  import axios from 'axios';
6
- import { C as ContactModal } from './ContactModal-ac82e7a6.js';
6
+ import { C as ContactModal } from './ContactModal-7e5b14e8.js';
7
7
  import { S as Spin } from './Spin-8f87eadc.js';
8
8
  import { getIntl } from './globalConfig';
9
9
  import { s as styleInject } from './style-inject.es-1f59c1d0.js';
10
10
  import './hoist-non-react-statics.cjs-3f408ad2.js';
11
11
  import 'react-is';
12
- import './Modal-b62ff592.js';
12
+ import './Modal-e04532fa.js';
13
13
  import '@material-ui/core';
14
14
  import '@material-ui/icons';
15
15
  import './Button-7bd5aa09.js';
@@ -18,7 +18,7 @@ import './defaultTheme-ed7746fe.js';
18
18
  import '@material-ui/styles';
19
19
  import './useTheme-d16d02d9.js';
20
20
  import './withTheme-2d778133.js';
21
- import './Select-141d7992.js';
21
+ import './Select-cb3e1ba1.js';
22
22
  import './Empty-c6a44967.js';
23
23
  import './createSvgIcon-e3803ee1.js';
24
24
  import 'react-dom';
@@ -7,8 +7,8 @@ import { useHistory, useRouteMatch, NavLink } from 'react-router-dom';
7
7
  import { Typography, IconButton } from '@material-ui/core';
8
8
  import { SearchOutlined } from '@material-ui/icons';
9
9
  import { K as KeywordSearch } from './KeywordSearch-fec33a2c.js';
10
- import { S as Select } from './Select-141d7992.js';
11
- import { c as checkLanguageSupport, D as Drawer, d as defaultSupportLanguage } from './Drawer-48414c2e.js';
10
+ import { S as Select } from './Select-cb3e1ba1.js';
11
+ import { c as checkLanguageSupport, D as Drawer, d as defaultSupportLanguage } from './Drawer-629e59c7.js';
12
12
  import { getIntl } from './globalConfig';
13
13
  import { s as styleInject } from './style-inject.es-1f59c1d0.js';
14
14
  import './isObjectLike-e111475d.js';
@@ -2,7 +2,7 @@ import { a as _slicedToArray } from './_rollupPluginBabelHelpers-a52356f6.js';
2
2
  import React__default, { useState, useEffect, useRef } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { c as classNames } from './index-b76a85f4.js';
5
- import { M as Modal } from './Modal-b62ff592.js';
5
+ import { M as Modal } from './Modal-e04532fa.js';
6
6
  import { Typography } from '@material-ui/core';
7
7
  import { r as requireCreateSvgIcon, i as interopRequireDefault, a as interopRequireWildcard } from './createSvgIcon-e3803ee1.js';
8
8
  import { getIntl } from './globalConfig';
@@ -1,4 +1,4 @@
1
- import React__default from 'react';
1
+ import React__default, { useRef } from 'react';
2
2
  import { c as classNames } from './index-b76a85f4.js';
3
3
  import PropTypes from 'prop-types';
4
4
  import { Dialog, DialogTitle, IconButton, DialogContent, DialogActions, CircularProgress } from '@material-ui/core';
@@ -11,6 +11,8 @@ import { s as styleInject } from './style-inject.es-1f59c1d0.js';
11
11
  var css_248z = ".modal__title h2 {\n display: flex;\n align-items: center;\n}\n.modal__title__text {\n flex: 1;\n font-size: 1rem;\n padding: 8px 0;\n color: inherit;\n}\n.modal__title__close {\n cursor: pointer;\n color: inherit;\n}\n.modal--transparent .MuiPaper-root {\n background: transparent !important;\n box-shadow: none;\n}\n.modal--transparent .modal__title {\n background: transparent !important;\n}";
12
12
  styleInject(css_248z);
13
13
 
14
+ /* 每個 Modal 實例需要唯一 id,才能把標題和 role="dialog" 綁起來 */
15
+ var modalSeq = 0;
14
16
  var Modal = function Modal(props) {
15
17
  var className = props.className,
16
18
  title = props.title,
@@ -28,6 +30,16 @@ var Modal = function Modal(props) {
28
30
  var endIcon = loading && /*#__PURE__*/React__default.createElement(CircularProgress, {
29
31
  size: 14
30
32
  });
33
+
34
+ /* WCAG 4.1.2 對話框需有可及名稱。MUI Dialog 只把 aria-labelledby 轉給
35
+ role="dialog" 的那層 Paper;aria-label 會被歸進 ...other 掛到外層 Modal
36
+ 容器上,讀屏開啟時等於沒名字,故改用 aria-labelledby 指向標題文字。 */
37
+ var titleIdRef = useRef(null);
38
+ if (!titleIdRef.current) {
39
+ modalSeq += 1;
40
+ titleIdRef.current = "nmtl-modal-".concat(modalSeq, "-title");
41
+ }
42
+ var titleId = titleIdRef.current;
31
43
  return /*#__PURE__*/React__default.createElement(Dialog, {
32
44
  className: classNames('modal', {
33
45
  'modal--transparent': transparent
@@ -36,15 +48,15 @@ var Modal = function Modal(props) {
36
48
  open: visible || false,
37
49
  onClose: function onClose() {
38
50
  return closable && onCancel();
39
- }
40
- // WCAG 4.1.2 對話框需有可及名稱
41
- ,
42
- "aria-label": typeof title === 'string' ? title : undefined
51
+ },
52
+ "aria-labelledby": title ? titleId : undefined
43
53
  }, /*#__PURE__*/React__default.createElement(DialogTitle, {
44
54
  className: "modal__title"
45
55
  }, /*#__PURE__*/React__default.createElement("span", {
56
+ id: titleId,
46
57
  className: "modal__title__text"
47
58
  }, title), closable && /*#__PURE__*/React__default.createElement(IconButton, {
59
+ autoFocus: true,
48
60
  "aria-label": getIntl().formatMessage({
49
61
  id: 'aria.modal.close'
50
62
  }),
@@ -63,8 +75,7 @@ var Modal = function Modal(props) {
63
75
  onClick: onOk,
64
76
  color: "primary",
65
77
  endIcon: endIcon,
66
- disabled: loading,
67
- autoFocus: true
78
+ disabled: loading
68
79
  }, okText)) : footer));
69
80
  };
70
81
  Modal.defaultProps = {
@@ -1,4 +1,4 @@
1
- export { M as default } from './Modal-b62ff592.js';
1
+ export { M as default } from './Modal-e04532fa.js';
2
2
  import 'react';
3
3
  import './index-b76a85f4.js';
4
4
  import 'prop-types';
@@ -2,13 +2,14 @@ import React__default, { useMemo, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { c as classNames } from './index-b76a85f4.js';
4
4
  import { e as event, d as d3Select, a as dispatch, c as customEvent, D as DragEvent, q as quadtree, m as map, t as timer, T as Transform, i as identity, b as interrupt, o as ordinal, f as category10 } from './transform-3a04288b.js';
5
- import { E as ExtraTools } from './ExtraTools-0f9ca8be.js';
5
+ import { E as ExtraTools } from './ExtraTools-11d483d5.js';
6
6
  import { s as styleInject } from './style-inject.es-1f59c1d0.js';
7
7
  import './_rollupPluginBabelHelpers-a52356f6.js';
8
8
  import './_commonjsHelpers-70de2c37.js';
9
9
  import '@material-ui/core';
10
10
  import './Tooltip-6ebfa9c1.js';
11
11
  import './dataExport-a9e3fae1.js';
12
+ import './globalConfig';
12
13
 
13
14
  function sourceEvent() {
14
15
  var current = event, source;
@@ -1,5 +1,5 @@
1
1
  import { b as _objectSpread2, d as _typeof } from './_rollupPluginBabelHelpers-a52356f6.js';
2
- import React__default from 'react';
2
+ import React__default, { useRef } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { c as classNames } from './index-b76a85f4.js';
5
5
  import { FormControl, Select as Select$1, CircularProgress, MenuItem } from '@material-ui/core';
@@ -9,11 +9,24 @@ import '@material-ui/styles';
9
9
  import { u as useTheme } from './useTheme-d16d02d9.js';
10
10
  import './withTheme-2d778133.js';
11
11
  import { E as Empty } from './Empty-c6a44967.js';
12
+ import { getIntl } from './globalConfig';
12
13
  import { s as styleInject } from './style-inject.es-1f59c1d0.js';
13
14
 
14
15
  var css_248z = ".select .MuiSelect-nativeInput {\n visibility: hidden;\n}\n.select__placeholder {\n color: #6b6130;\n}\n.select--small {\n width: 100%;\n}\n.select--small .MuiSelect-root {\n padding: 0.5rem 1.5rem 0.25rem;\n color: white;\n}\n.select--small .MuiSelect-root .select__placeholder {\n color: white;\n}\n.select--small .MuiSelect-root:hover, .select--small .MuiSelect-root:focus {\n background: transparent;\n}\n.select--small .MuiSvgIcon-root {\n color: white;\n}\n.select--small .MuiOutlinedInput-root {\n border-radius: 45px;\n}";
15
16
  styleInject(css_248z);
16
17
 
18
+ /* 視覺隱藏的可及名稱容器(不依賴各站的 .visually-hidden) */
19
+ var hiddenLabelStyle = {
20
+ position: 'absolute',
21
+ width: 1,
22
+ height: 1,
23
+ overflow: 'hidden',
24
+ clip: 'rect(1px, 1px, 1px, 1px)',
25
+ whiteSpace: 'nowrap'
26
+ };
27
+
28
+ /* 每個 Select 實例需要唯一 id 才能做 aria-labelledby 串接 */
29
+ var selectSeq = 0;
17
30
  var Select = function Select(props) {
18
31
  var style = props.style,
19
32
  className = props.className,
@@ -24,13 +37,18 @@ var Select = function Select(props) {
24
37
  variantSmall = props.variantSmall,
25
38
  background = props.background,
26
39
  menuItemClass = props.menuItemClass;
40
+ /* 未指定 placeholder 時走套件 i18n(原本寫死英文 'Please select...',
41
+ 中文語系也照唸英文,走查回饋 5a) */
42
+ var placeholderText = placeholder === undefined ? getIntl().formatMessage({
43
+ id: 'common.select.placeholder'
44
+ }) : placeholder;
27
45
  var options = props.options,
28
46
  value = props.value,
29
47
  defaultValue = props.defaultValue,
30
48
  _onChange = props.onChange,
31
49
  ariaLabel = props.ariaLabel,
32
50
  ariaLabelledby = props.ariaLabelledby;
33
- /* WCAG 1.4.3 提示字顏色依主題深淺自動選色:select.scss 的 #6b6130 只適用淺底,
51
+ /* WCAG 1.4.3 提示字顏色依主題深淺自動選色:select.scss 的 #6b6130 只適用淺底,
34
52
  深色主題(palette.type=dark,如 ocean 深色 Modal)需改亮灰(WAVE 實測「請輸入 年齡」被抓) */
35
53
  var theme = useTheme();
36
54
  var placeholderStyle = theme && theme.palette && theme.palette.type === 'dark' ? {
@@ -41,24 +59,42 @@ var Select = function Select(props) {
41
59
  return _typeof(option) === 'object' ? key === option.value : key === option;
42
60
  }) || key;
43
61
  };
62
+
63
+ /* WCAG 4.1.2/3.3.2 可及名稱=「這個選單是做什麼的」+「目前選了什麼」。
64
+ 直接掛 aria-label 會整個蓋掉顯示層的選中值文字(讀屏只唸得出用途、唸不出選了誰),
65
+ 故改採 MUI 原生作法:把用途文字放進視覺隱藏的 label 元素,
66
+ 再以 aria-labelledby="<label id> <顯示層 id>" 串起來(走查回饋 5a)。 */
67
+ var uidRef = useRef(null);
68
+ if (!uidRef.current) {
69
+ selectSeq += 1;
70
+ uidRef.current = "nmtl-select-".concat(selectSeq);
71
+ }
72
+ var uid = uidRef.current;
73
+ var buttonId = "".concat(uid, "-value");
74
+ var useHiddenLabel = Boolean(ariaLabel) && !ariaLabelledby;
75
+ // eslint-disable-next-line no-nested-ternary
76
+ var labelledby = ariaLabelledby ? "".concat(ariaLabelledby, " ").concat(buttonId) : useHiddenLabel ? "".concat(uid, "-label ").concat(buttonId) : undefined;
44
77
  return /*#__PURE__*/React__default.createElement(FormControl, {
45
78
  className: classNames('select', {
46
79
  'select--small': variantSmall
47
80
  }, className),
48
81
  variant: "outlined"
49
- }, /*#__PURE__*/React__default.createElement(Select$1, {
82
+ }, useHiddenLabel && /*#__PURE__*/React__default.createElement("span", {
83
+ id: "".concat(uid, "-label"),
84
+ style: hiddenLabelStyle
85
+ }, ariaLabel), /*#__PURE__*/React__default.createElement(Select$1, {
50
86
  style: _objectSpread2(_objectSpread2({}, style || {}), {}, {
51
87
  background: background
52
88
  }),
53
89
  displayEmpty: true,
54
90
  disabled: disabled || loading
55
- // WCAG 3.3.2 可及名稱:顯示層(role=button)預設以其文字內容(選中值/placeholder)為名稱;
56
- // 僅在明確提供 ariaLabel/ariaLabelledby 時才覆蓋(避免蓋掉有意義的選中值文字)。
91
+ // WCAG 3.3.2 可及名稱:未提供 ariaLabel/ariaLabelledby 時,顯示層(role=button)
92
+ // 以其文字內容(選中值/placeholder)為名稱;有提供時改為「用途 + 選中值」(見上方 labelledby)。
57
93
  // 隱藏原生 input 由 select.scss 的 visibility:hidden 讓檢測工具略過,無需再標 label。
58
94
  ,
59
95
  SelectDisplayProps: {
60
- 'aria-labelledby': ariaLabelledby || undefined,
61
- 'aria-label': ariaLabelledby ? undefined : ariaLabel
96
+ id: buttonId,
97
+ 'aria-labelledby': labelledby
62
98
  },
63
99
  renderValue: function renderValue(id) {
64
100
  var finder = itemFind(id);
@@ -73,7 +109,7 @@ var Select = function Select(props) {
73
109
  content = /*#__PURE__*/React__default.createElement("span", {
74
110
  className: "select__placeholder",
75
111
  style: placeholderStyle
76
- }, placeholder);
112
+ }, placeholderText);
77
113
  }
78
114
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, content, loading && /*#__PURE__*/React__default.createElement(CircularProgress, {
79
115
  size: 16,
@@ -109,7 +145,7 @@ Select.defaultProps = {
109
145
  labelInValue: undefined,
110
146
  disabled: undefined,
111
147
  loading: undefined,
112
- placeholder: 'Please select...',
148
+ placeholder: undefined,
113
149
  variantSmall: undefined,
114
150
  background: undefined,
115
151
  menuItemClass: undefined,
@@ -134,7 +170,7 @@ Select.propTypes = {
134
170
  disabled: PropTypes.bool,
135
171
  /** 是否載入中 */
136
172
  loading: PropTypes.bool,
137
- /** 下拉選單提示字 */
173
+ /** 下拉選單提示字(不給則使用套件 i18n 的「請選擇…」) */
138
174
  placeholder: PropTypes.string,
139
175
  /** 是否使用小size */
140
176
  variantSmall: PropTypes.bool,
@@ -144,7 +180,7 @@ Select.propTypes = {
144
180
  menuItemClass: PropTypes.objectOf(PropTypes.any),
145
181
  /** 點選後的返回 */
146
182
  onChange: PropTypes.func,
147
- /** 無障礙名稱(WCAG 3.3.2),未提供時以placeholder代替 */
183
+ /** 無障礙名稱(WCAG 3.3.2):說明「這個選單是做什麼的」,會與選中值一起被讀出 */
148
184
  ariaLabel: PropTypes.string,
149
185
  /** 以外部元素id作為無障礙名稱 */
150
186
  ariaLabelledby: PropTypes.string
@@ -1,4 +1,4 @@
1
- export { S as default } from './Select-141d7992.js';
1
+ export { S as default } from './Select-cb3e1ba1.js';
2
2
  import './_rollupPluginBabelHelpers-a52356f6.js';
3
3
  import 'react';
4
4
  import 'prop-types';
@@ -11,3 +11,4 @@ import './useTheme-d16d02d9.js';
11
11
  import './withTheme-2d778133.js';
12
12
  import './Empty-c6a44967.js';
13
13
  import './style-inject.es-1f59c1d0.js';
14
+ import './globalConfig';
@@ -94,7 +94,9 @@ var zhtw = {
94
94
  "aria.pagination.pageCurrent": "第 {page} 頁,目前頁",
95
95
  "aria.pagination.select": "選擇頁碼,目前在第 {page} 頁,共 {totalPage} 頁(選擇後結果將更新)",
96
96
  "aria.pagination.changed": "已切換至第 {page} 頁,結果已更新",
97
- "aria.keyword.groupLabel": "關鍵字,共 {count} 個,可用方向鍵瀏覽"
97
+ "aria.keyword.groupLabel": "關鍵字,共 {count} 個,可用方向鍵瀏覽",
98
+ "common.select.placeholder": "請選擇…",
99
+ "common.share.facebook": "分享至 Facebook"
98
100
  };
99
101
 
100
102
  var zhcn = {
@@ -177,7 +179,9 @@ var zhcn = {
177
179
  "aria.pagination.pageCurrent": "第 {page} 页,目前页",
178
180
  "aria.pagination.select": "选择页码,目前在第 {page} 页,共 {totalPage} 页(选择后结果将更新)",
179
181
  "aria.pagination.changed": "已切换至第 {page} 页,结果已更新",
180
- "aria.keyword.groupLabel": "关键字,共 {count} 个,可用方向键浏览"
182
+ "aria.keyword.groupLabel": "关键字,共 {count} 个,可用方向键浏览",
183
+ "common.select.placeholder": "请选择…",
184
+ "common.share.facebook": "分享至 Facebook"
181
185
  };
182
186
 
183
187
  var enus = {
@@ -260,7 +264,9 @@ var enus = {
260
264
  "aria.pagination.pageCurrent": "Page {page}, current page",
261
265
  "aria.pagination.select": "Select page, currently on page {page} of {totalPage} (results update after selection)",
262
266
  "aria.pagination.changed": "Moved to page {page}. Results updated",
263
- "aria.keyword.groupLabel": "Keywords, {count} items, use arrow keys to browse"
267
+ "aria.keyword.groupLabel": "Keywords, {count} items, use arrow keys to browse",
268
+ "common.select.placeholder": "Please select...",
269
+ "common.share.facebook": "Share on Facebook"
264
270
  };
265
271
 
266
272
  var _languages;
package/lib/index.d.ts CHANGED
@@ -34,4 +34,6 @@ export { default as CollapseContent } from './components/CollapseContent';
34
34
  export { default as MoreButton } from './components/MoreButton';
35
35
  export { default as KeywordTicker } from './components/KeywordTicker';
36
36
  export { default as ExtraTools } from './components/ExtraTools';
37
- export { default as Filter } from './components/Filter';
37
+ export { default as Filter } from './components/Filter';
38
+
39
+ export { getIntl } from './components/globalConfig';
package/lib/index.js CHANGED
@@ -34,4 +34,6 @@ export { default as CollapseContent } from './components/CollapseContent';
34
34
  export { default as MoreButton } from './components/MoreButton';
35
35
  export { default as KeywordTicker } from './components/KeywordTicker';
36
36
  export { default as ExtraTools } from './components/ExtraTools';
37
- export { default as Filter } from './components/Filter';
37
+ export { default as Filter } from './components/Filter';
38
+
39
+ export { getIntl } from './components/globalConfig';
package/package.json CHANGED
@@ -1,125 +1,134 @@
1
- {
2
- "name": "@daoyi/nmtl-ui",
3
- "version": "2.0.1-beta.126",
4
- "description": "This project is to be used as a starter kit for building React component using Storybook and Rollup",
5
- "author": "daoyi",
6
- "main": "lib/index.js",
7
- "typings": "lib/index.d.ts",
8
- "files": [
9
- "lib"
10
- ],
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/HsunTsai/react-storybook-jsx-starter"
14
- },
15
- "dependencies": {
16
- "@geometricpanda/storybook-addon-badges": "0.2.2",
17
- "@material-ui/core": "4.12.3",
18
- "@material-ui/icons": "4.11.2",
19
- "@material-ui/lab": "4.0.0-alpha.60",
20
- "@material-ui/styles": "4.11.4",
21
- "axios": "0.21.1",
22
- "babel-eslint": "10.1.0",
23
- "classnames": "2.3.1",
24
- "d3": "5.16.0",
25
- "d3-selection": "1.4.2",
26
- "d3-transition": "1.3.2",
27
- "dom-to-image": "2.6.0",
28
- "formik": "2.2.9",
29
- "html-to-react": "1.4.5",
30
- "jquery": "3.6.0",
31
- "js-file-download": "0.4.12",
32
- "jszip": "3.7.1",
33
- "lodash": "4.17.21",
34
- "markdown-it": "12.0.6",
35
- "moment": "^2.29.4",
36
- "notistack": "1.0.10",
37
- "prop-types": "15.7.2",
38
- "query-string": "6.12.1",
39
- "react": "16.14.0",
40
- "react-awesome-lightbox": "^1.8.1",
41
- "react-data-export": "0.6.0",
42
- "react-dom": "16.14.0",
43
- "react-dropzone": "11.3.2",
44
- "react-facebook-login": "4.1.1",
45
- "react-file-download": "0.3.5",
46
- "react-font-size-changer": "0.2.0",
47
- "react-google-login": "5.2.2",
48
- "react-intl": "5.8.0",
49
- "react-redux": "7.2.5",
50
- "react-router-dom": "5.2.0",
51
- "react-share": "4.4.0",
52
- "react-slick": "^0.28.1",
53
- "redux": "4.1.0",
54
- "sass": "1.41.1",
55
- "screenfull": "5.2.0",
56
- "slick-carousel": "^1.8.1",
57
- "styled-components": "5.3.5",
58
- "xlsx": "0.18.5"
59
- },
60
- "devDependencies": {
61
- "@babel/core": "7.14.8",
62
- "@babel/preset-env": "7.14.8",
63
- "@babel/preset-react": "7.14.5",
64
- "@rollup/plugin-babel": "5.3.1",
65
- "@rollup/plugin-commonjs": "22.0.0",
66
- "@rollup/plugin-node-resolve": "13.2.1",
67
- "@rollup/plugin-replace": "4.0.0",
68
- "@rollup/plugin-image": "2.1.1",
69
- "@rollup/plugin-json": "4.1.0",
70
- "@storybook/addon-essentials": "6.5.13",
71
- "@storybook/addon-links": "6.5.13",
72
- "@storybook/addon-notes": "6.0.0-alpha.6",
73
- "@storybook/addons": "6.5.13",
74
- "@storybook/preset-scss": "1.0.3",
75
- "@storybook/react": "6.5.13",
76
- "autoprefixer": "9.8.6",
77
- "babel-loader": "8.2.2",
78
- "babel-plugin-transform-imports": "2.0.0",
79
- "css-loader": "1.0.1",
80
- "eslint": "7.2.0",
81
- "eslint-config-airbnb": "18.2.1",
82
- "eslint-config-node": "4.1.0",
83
- "eslint-config-prettier": "8.3.0",
84
- "eslint-loader": "4.0.2",
85
- "eslint-plugin-import": "2.22.1",
86
- "eslint-plugin-jsx-a11y": "6.4.1",
87
- "eslint-plugin-node": "11.1.0",
88
- "eslint-plugin-prettier": "3.4.1",
89
- "eslint-plugin-react": "7.21.5",
90
- "eslint-plugin-react-hooks": "1.7.0",
91
- "http-proxy-middleware": "1.3.1",
92
- "prettier": "2.4.1",
93
- "rollup": "2.70.2",
94
- "rollup-plugin-cleaner": "1.0.0",
95
- "rollup-plugin-postcss": "4.0.1",
96
- "rollup-plugin-terser": "7.0.2",
97
- "sass-loader": "7.1.0",
98
- "style-loader": "0.22.1"
99
- },
100
- "browserslist": {
101
- "production": [
102
- ">0.2%",
103
- "not dead",
104
- "not op_mini all"
105
- ],
106
- "development": [
107
- "last 1 chrome version",
108
- "last 1 firefox version",
109
- "last 1 safari version"
110
- ]
111
- },
112
- "scripts": {
113
- "start": "set NODE_OPTIONS=--max_old_space_size=16384 && yarn storybook",
114
- "lint": "eslint ./src/**/*.{js,jsx}",
115
- "format": "prettier --write --tab-width 4 --use-tabs true \"{,src/**/}*.{js,jsx}\"",
116
- "storybook": "start-storybook -p 6006 --no-open",
117
- "build": "rollup -c && npm run build-index",
118
- "build-index": "node ./rollup.index.js",
119
- "build-storybook": "build-storybook -c .storybook -o public",
120
- "create": "node ./buildUtils/create.js",
121
- "pub": "npm version patch -m Publish && npm publish",
122
- "pub-alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
123
- "pub-beta": "npm version prerelease --preid=beta && npm publish --tag beta"
124
- }
125
- }
1
+ {
2
+ "name": "@daoyi/nmtl-ui",
3
+ "packageManager": "pnpm@10.34.5",
4
+ "version": "2.0.1-beta.127",
5
+ "description": "This project is to be used as a starter kit for building React component using Storybook and Rollup",
6
+ "author": "daoyi",
7
+ "main": "lib/index.js",
8
+ "typings": "lib/index.d.ts",
9
+ "files": [
10
+ "lib"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/HsunTsai/react-storybook-jsx-starter"
15
+ },
16
+ "dependencies": {
17
+ "@geometricpanda/storybook-addon-badges": "0.2.2",
18
+ "@material-ui/core": "4.12.3",
19
+ "@material-ui/icons": "4.11.2",
20
+ "@material-ui/lab": "4.0.0-alpha.60",
21
+ "@material-ui/styles": "4.11.4",
22
+ "axios": "0.21.1",
23
+ "babel-eslint": "10.1.0",
24
+ "classnames": "2.3.1",
25
+ "d3": "5.16.0",
26
+ "d3-selection": "1.4.2",
27
+ "d3-transition": "1.3.2",
28
+ "dom-to-image": "2.6.0",
29
+ "formik": "2.2.9",
30
+ "html-to-react": "1.4.5",
31
+ "jquery": "3.6.0",
32
+ "js-file-download": "0.4.12",
33
+ "jszip": "3.7.1",
34
+ "lodash": "4.17.21",
35
+ "markdown-it": "12.0.6",
36
+ "moment": "^2.29.4",
37
+ "notistack": "1.0.10",
38
+ "prop-types": "15.7.2",
39
+ "query-string": "6.12.1",
40
+ "react": "16.14.0",
41
+ "react-awesome-lightbox": "^1.8.1",
42
+ "react-data-export": "0.6.0",
43
+ "react-dom": "16.14.0",
44
+ "react-dropzone": "11.3.2",
45
+ "react-facebook-login": "4.1.1",
46
+ "react-file-download": "0.3.5",
47
+ "react-font-size-changer": "0.2.0",
48
+ "react-google-login": "5.2.2",
49
+ "react-intl": "5.8.0",
50
+ "react-redux": "7.2.5",
51
+ "react-router-dom": "5.2.0",
52
+ "react-share": "4.4.0",
53
+ "react-slick": "^0.28.1",
54
+ "redux": "4.1.0",
55
+ "sass": "1.41.1",
56
+ "screenfull": "5.2.0",
57
+ "slick-carousel": "^1.8.1",
58
+ "styled-components": "5.3.5",
59
+ "xlsx": "0.18.5"
60
+ },
61
+ "devDependencies": {
62
+ "@babel/core": "7.14.8",
63
+ "@babel/preset-env": "7.14.8",
64
+ "@babel/preset-react": "7.14.5",
65
+ "@rollup/plugin-babel": "5.3.1",
66
+ "@rollup/plugin-commonjs": "22.0.0",
67
+ "@rollup/plugin-node-resolve": "13.2.1",
68
+ "@rollup/plugin-replace": "4.0.0",
69
+ "@rollup/plugin-image": "2.1.1",
70
+ "@rollup/plugin-json": "4.1.0",
71
+ "@storybook/addon-essentials": "6.5.13",
72
+ "@storybook/addon-links": "6.5.13",
73
+ "@storybook/addon-notes": "6.0.0-alpha.6",
74
+ "@storybook/addons": "6.5.13",
75
+ "@storybook/preset-scss": "1.0.3",
76
+ "@storybook/react": "6.5.13",
77
+ "autoprefixer": "9.8.6",
78
+ "babel-loader": "8.2.2",
79
+ "babel-plugin-transform-imports": "2.0.0",
80
+ "css-loader": "1.0.1",
81
+ "eslint": "7.2.0",
82
+ "eslint-config-airbnb": "18.2.1",
83
+ "eslint-config-node": "4.1.0",
84
+ "eslint-config-prettier": "8.3.0",
85
+ "eslint-loader": "4.0.2",
86
+ "eslint-plugin-import": "2.22.1",
87
+ "eslint-plugin-jsx-a11y": "6.4.1",
88
+ "eslint-plugin-node": "11.1.0",
89
+ "eslint-plugin-prettier": "3.4.1",
90
+ "eslint-plugin-react": "7.21.5",
91
+ "eslint-plugin-react-hooks": "1.7.0",
92
+ "http-proxy-middleware": "1.3.1",
93
+ "prettier": "2.4.1",
94
+ "rollup": "2.70.2",
95
+ "rollup-plugin-cleaner": "1.0.0",
96
+ "rollup-plugin-postcss": "4.0.1",
97
+ "rollup-plugin-terser": "7.0.2",
98
+ "sass-loader": "7.1.0",
99
+ "style-loader": "0.22.1"
100
+ },
101
+ "browserslist": {
102
+ "production": [
103
+ ">0.2%",
104
+ "not dead",
105
+ "not op_mini all"
106
+ ],
107
+ "development": [
108
+ "last 1 chrome version",
109
+ "last 1 firefox version",
110
+ "last 1 safari version"
111
+ ]
112
+ },
113
+ "scripts": {
114
+ "start": "set NODE_OPTIONS=--max_old_space_size=16384 && yarn storybook",
115
+ "lint": "eslint ./src/**/*.{js,jsx}",
116
+ "format": "prettier --write --tab-width 4 --use-tabs true \"{,src/**/}*.{js,jsx}\"",
117
+ "storybook": "start-storybook -p 6006 --no-open",
118
+ "build": "rollup -c && npm run build-index",
119
+ "build-index": "node ./rollup.index.js",
120
+ "build-storybook": "build-storybook -c .storybook -o public",
121
+ "create": "node ./buildUtils/create.js",
122
+ "pub": "npm version patch -m Publish && npm publish",
123
+ "pub-alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
124
+ "pub-beta": "npm version prerelease --preid=beta && npm publish --tag beta"
125
+ },
126
+ "pnpm": {
127
+ "onlyBuiltDependencies": [
128
+ "core-js",
129
+ "esbuild",
130
+ "protobufjs",
131
+ "styled-components"
132
+ ]
133
+ }
134
+ }