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

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 () {
@@ -2752,6 +2753,12 @@ const downloadGephi = snaData => {
2752
2753
 
2753
2754
  /* 轉檔工具, 提供API轉下載tsv/xlsx */
2754
2755
 
2756
+ /* 欄名走套件自帶的 getIntl():zh-tw 語系表的值與原本寫死的欄名相同,子站(僅 zh-tw)輸出不變;
2757
+ 主站英文頁輸出英文欄名(nmtl-web i18n 盤點 D6) */
2758
+ const header = id => getIntl().formatMessage({
2759
+ id
2760
+ });
2761
+
2755
2762
  /* 大事年表 */
2756
2763
  const chronologyConvert = data => {
2757
2764
  const getText = function () {
@@ -2763,6 +2770,15 @@ const chronologyConvert = data => {
2763
2770
  };
2764
2771
  };
2765
2772
 
2773
+ /* 資料來源:主站把名稱包在 .tooltipsources 裡(「資料來源:」前綴隨語系變動,無法再靠中文字剝除);
2774
+ 子站的時間軸 HTML 沒有這一層,沿用原本剝除「註」「資料來源:」的寫法 */
2775
+ const getSources = function () {
2776
+ let after = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
2777
+ const tagged = after.match(/<span class="tooltipsources">([\s\S]*?)<\/span>/);
2778
+ if (tagged) return tagged[1].replaceAll(/(<([^>]+)>)/gi, '').trim();
2779
+ return after.replaceAll('\n', '').replaceAll('\t', '').replace('註', '').replace('資料來源:', '').replaceAll(/(<([^>]+)>)/gi, '');
2780
+ };
2781
+
2766
2782
  /* 做資料過濾 */
2767
2783
  const newData = (data || []).map(_ref => {
2768
2784
  let {
@@ -2778,11 +2794,11 @@ const chronologyConvert = data => {
2778
2794
  }
2779
2795
  } = _ref;
2780
2796
  return {
2781
- 日期: `${year || ''}/${month || ''}/${day || ''}`,
2782
- 名稱: (displayDate || '').replace('<span>', '').replace('</span>', ''),
2783
- 描述: (headline || '').replaceAll(/(<([^>]+)>)/gi, ''),
2784
- 類型: getText(text).before,
2785
- '註(資料集名稱)': getText(text).after.replaceAll('\n', '').replaceAll('\t', '').replace('註', '').replace('資料來源:', '').replaceAll(/(<([^>]+)>)/gi, '')
2797
+ [header('export.chronology.date')]: `${year || ''}/${month || ''}/${day || ''}`,
2798
+ [header('export.chronology.name')]: (displayDate || '').replace('<span>', '').replace('</span>', ''),
2799
+ [header('export.chronology.description')]: (headline || '').replaceAll(/(<([^>]+)>)/gi, ''),
2800
+ [header('export.chronology.type')]: getText(text).before,
2801
+ [header('export.chronology.source')]: getSources(getText(text).after)
2786
2802
  };
2787
2803
  });
2788
2804
  return newData;
@@ -2799,12 +2815,12 @@ const mapConvert = data => (data || []).map(_ref2 => {
2799
2815
  posY
2800
2816
  } = _ref2;
2801
2817
  return {
2802
- '名稱(書名/文章名)': title || '',
2803
- 作者: author || '',
2804
- 出版者: publisher || '',
2805
- '地點(作品描述區域)': locations || '',
2806
- 經度: posX || '',
2807
- 緯度: posY || ''
2818
+ [header('export.works.title')]: title || '',
2819
+ [header('export.works.author')]: author || '',
2820
+ [header('export.map.publisher')]: publisher || '',
2821
+ [header('export.map.location')]: locations || '',
2822
+ [header('export.map.longitude')]: posX || '',
2823
+ [header('export.map.latitude')]: posY || ''
2808
2824
  };
2809
2825
  });
2810
2826
 
@@ -2820,13 +2836,13 @@ const mapLgConvert = data => (data || []).map(_ref3 => {
2820
2836
  activePosY
2821
2837
  } = _ref3;
2822
2838
  return {
2823
- 組織名稱: title || '',
2824
- 創立地點: locationOfFormation,
2825
- 創立地點經度: createPosX || '',
2826
- 創立地點緯度: createPosY || '',
2827
- 活動地點: workLocations || '',
2828
- 活動地點經度: activePosX || '',
2829
- 活動地點緯度: activePosY || ''
2839
+ [header('export.mapLg.orgName')]: title || '',
2840
+ [header('export.mapLg.foundingPlace')]: locationOfFormation,
2841
+ [header('export.mapLg.foundingLongitude')]: createPosX || '',
2842
+ [header('export.mapLg.foundingLatitude')]: createPosY || '',
2843
+ [header('export.mapLg.activityPlace')]: workLocations || '',
2844
+ [header('export.mapLg.activityLongitude')]: activePosX || '',
2845
+ [header('export.mapLg.activityLatitude')]: activePosY || ''
2830
2846
  };
2831
2847
  });
2832
2848
 
@@ -2841,16 +2857,16 @@ const worksBarChart = data => (data || []).map(_ref4 => {
2841
2857
  genreName
2842
2858
  } = _ref4;
2843
2859
  return {
2844
- '出版年/發表年': date || year || '',
2845
- '名稱(書名/文章名)': title || '',
2846
- 作者: (authors || []).map(_ref5 => {
2860
+ [header('export.works.publishYear')]: date || year || '',
2861
+ [header('export.works.title')]: title || '',
2862
+ [header('export.works.author')]: (authors || []).map(_ref5 => {
2847
2863
  let {
2848
2864
  author
2849
2865
  } = _ref5;
2850
2866
  return author;
2851
2867
  }).join(','),
2852
- 關鍵字: (keywords || '').replaceAll('\n', ''),
2853
- 文學分類: genreName || ''
2868
+ [header('export.works.keywords')]: (keywords || '').replaceAll('\n', ''),
2869
+ [header('export.works.genre')]: genreName || ''
2854
2870
  };
2855
2871
  });
2856
2872
 
@@ -2862,9 +2878,9 @@ const worksSlider = data => (data || []).map(_ref6 => {
2862
2878
  date
2863
2879
  } = _ref6;
2864
2880
  return {
2865
- '名稱(書名/文章名)': title || '',
2866
- 作者: author || '',
2867
- '出版日期/發表日期': date || ''
2881
+ [header('export.works.title')]: title || '',
2882
+ [header('export.works.author')]: author || '',
2883
+ [header('export.works.publishDate')]: date || ''
2868
2884
  // 文學分類: genreName || '',
2869
2885
  // 作品描述地: workDesc || '',
2870
2886
  // 作家出生地: locations,
@@ -3156,6 +3172,15 @@ styleInject(css_248z);
3156
3172
 
3157
3173
  /* eslint-disable prefer-destructuring */
3158
3174
 
3175
+ /* 元件內部字串:呼叫端有傳 intl(各站自己的 react-intl)就沿用;沒傳就走套件自帶的 getIntl(),
3176
+ 語系由各站在 IndexProvider 以 getIntl().setLocale() 設定。
3177
+ 原本沒傳時直接落在寫死的中文,英文頁的工具列整排都是中文(nmtl-web i18n 盤點 D1) */
3178
+ const translate = (intl, id) => intl ? intl.formatMessage({
3179
+ id
3180
+ }) : getIntl().formatMessage({
3181
+ id
3182
+ });
3183
+
3159
3184
  /* 視覺隱藏文字(供按鈕內容作為可及名稱, WCAG 4.1.2) */
3160
3185
  const hiddenTextStyle = {
3161
3186
  position: 'absolute',
@@ -3169,18 +3194,24 @@ const ShareButton = _ref => {
3169
3194
  let {
3170
3195
  className
3171
3196
  } = _ref;
3197
+ /* WCAG 4.1.2:react-share 預設 aria-label 只有 "facebook",讀屏聽不出點下去會做什麼;
3198
+ 一律改為「分享至 Facebook」(走查回饋 5c)。
3199
+ 字串走套件自帶的 getIntl(元件內部字串),不依賴各站的訊息檔 */
3200
+ const shareLabel = getIntl().formatMessage({
3201
+ id: 'common.share.facebook'
3202
+ });
3172
3203
  return /*#__PURE__*/React__default.createElement("div", {
3173
3204
  className: classNames('extraTools__share', className)
3174
3205
  }, /*#__PURE__*/React__default.createElement(FacebookShareButton, {
3175
3206
  url: document.location.href,
3176
- "aria-label": "\u5206\u4EAB\u81F3 Facebook"
3207
+ "aria-label": shareLabel
3177
3208
  }, /*#__PURE__*/React__default.createElement(FacebookIcon, {
3178
3209
  size: 32,
3179
3210
  round: true,
3180
3211
  "aria-hidden": "true"
3181
3212
  }), /*#__PURE__*/React__default.createElement("span", {
3182
3213
  style: hiddenTextStyle
3183
- }, "\u5206\u4EAB\u81F3 Facebook")));
3214
+ }, shareLabel)));
3184
3215
  };
3185
3216
  ShareButton.defaultProps = {
3186
3217
  className: undefined
@@ -3204,18 +3235,29 @@ const DownloadMenu = _ref2 => {
3204
3235
  exportFileName
3205
3236
  } = _ref2;
3206
3237
  const [anchorEl, setAnchorEl] = useState(null);
3238
+ /* react-data-export 的隱藏觸發器(見下方 xlsxTrigger 說明) */
3239
+ const xlsxTriggerRef = useRef(null);
3207
3240
  const hideButton = type => (exclude || []).filter(key => key === type).length > 0;
3241
+ const t = id => translate(intl, id);
3242
+ const downloadLabel = t('knowledge.writersAndWorksSNA.download');
3243
+
3244
+ /* xlsx 需由 react-data-export 產生檔案,但它只會把傳入的 element 包一層 <span onClick>;
3245
+ 若直接把 MenuItem 交給它,選單裡就會出現 <span><li role="menuitem"></span>——
3246
+ 既不是 role="menu" 的合法子項,MUI MenuList 的上下鍵巡覽(走 nextElementSibling
3247
+ 且要求元素自帶 tabindex)也會直接跳過它,造成「最後一個選項選不到」(走查回饋 2/5b)。
3248
+ 改為:選單一律只放真 MenuItem,xlsx 的下載動作轉由選單外的隱藏觸發器代打。 */
3249
+ const hasXlsx = !hideButton('downloadXls') && Boolean(DownloadExcel);
3208
3250
  const btns = [{
3209
3251
  key: 'downloadImage',
3210
3252
  onClick: () => domToImage({
3211
3253
  id: domToImageId,
3212
3254
  fileName: `${exportFileName}_${exportDateSuffix()}`
3213
3255
  }),
3214
- label: intl ? 'knowledge.writersAndWorksSNA.download.img' : '下載圖片'
3256
+ label: t('knowledge.writersAndWorksSNA.download.img')
3215
3257
  }, {
3216
3258
  key: 'downloadGephi',
3217
3259
  onClick: () => downloadGephi(data),
3218
- label: intl ? 'knowledge.writersAndWorksSNA.download.gephi' : '下載Gephi'
3260
+ label: t('knowledge.writersAndWorksSNA.download.gephi')
3219
3261
  }, {
3220
3262
  key: 'downloadTsv',
3221
3263
  onClick: () => exportXlsx({
@@ -3224,34 +3266,33 @@ const DownloadMenu = _ref2 => {
3224
3266
  extType: 'tsv',
3225
3267
  fileName: exportFileName
3226
3268
  }),
3227
- label: intl ? 'knowledge.writersAndWorksSNA.download.tsv' : '下載Tsv'
3269
+ label: t('knowledge.writersAndWorksSNA.download.tsv')
3228
3270
  }, {
3229
3271
  key: 'downloadXls',
3230
- // download click trigger 交給 react-data-export
3231
- label: intl ? 'knowledge.writersAndWorksSNA.download.xls' : '下載Excel'
3272
+ onClick: () => xlsxTriggerRef.current && xlsxTriggerRef.current.click(),
3273
+ label: t('knowledge.writersAndWorksSNA.download.xls'),
3274
+ requireExcel: true
3232
3275
  }];
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;
3276
+ const menuItems = btns.filter(_ref3 => {
3277
+ let {
3278
+ key,
3279
+ requireExcel
3280
+ } = _ref3;
3281
+ return !hideButton(key) && (!requireExcel || hasXlsx);
3282
+ });
3239
3283
  return /*#__PURE__*/React__default.createElement("div", {
3240
3284
  className: classNames('extraTools__download', className)
3241
3285
  }, /*#__PURE__*/React__default.createElement(Tooltip, {
3242
- title: intl ? intl.formatMessage({
3243
- id: 'knowledge.writersAndWorksSNA.download'
3244
- }) : '下載',
3286
+ title: downloadLabel,
3245
3287
  placement: "bottom"
3246
3288
  }, /*#__PURE__*/React__default.createElement("div", {
3247
3289
  className: "extraTools__download-icon",
3248
3290
  role: "button",
3249
3291
  tabIndex: 0,
3250
- "aria-label": intl ? intl.formatMessage({
3251
- id: 'knowledge.writersAndWorksSNA.download'
3252
- }) : '下載',
3292
+ "aria-label": downloadLabel,
3253
3293
  "aria-haspopup": "menu",
3254
3294
  "aria-expanded": Boolean(anchorEl),
3295
+ "aria-controls": anchorEl ? 'download-menu' : undefined,
3255
3296
  onClick: e => setAnchorEl(e.currentTarget),
3256
3297
  onKeyDown: e => {
3257
3298
  if (e.key === 'Enter' || e.key === ' ') {
@@ -3267,19 +3308,35 @@ const DownloadMenu = _ref2 => {
3267
3308
  anchorEl: anchorEl,
3268
3309
  keepMounted: true,
3269
3310
  open: Boolean(anchorEl),
3270
- onClose: () => setAnchorEl(null)
3271
- }, btns.map(_ref3 => {
3311
+ onClose: () => setAnchorEl(null),
3312
+ MenuListProps: {
3313
+ 'aria-label': downloadLabel
3314
+ }
3315
+ }, menuItems.map(_ref4 => {
3272
3316
  let {
3273
3317
  key,
3274
3318
  onClick,
3275
- label
3276
- } = _ref3;
3277
- return !hideButton(key) && isXlsxButton(key, /*#__PURE__*/React__default.createElement(MenuItem, {
3319
+ label: itemLabel
3320
+ } = _ref4;
3321
+ return /*#__PURE__*/React__default.createElement(MenuItem, {
3278
3322
  key: key,
3279
- onClick: onClick
3280
- }, intl ? intl.formatMessage({
3281
- id: label
3282
- }) : label));
3323
+ onClick: () => {
3324
+ /* 選完就關閉,焦點由 MUI 交還給觸發器(WCAG 2.4.3) */
3325
+ setAnchorEl(null);
3326
+ onClick();
3327
+ }
3328
+ }, itemLabel);
3329
+ })), hasXlsx && /*#__PURE__*/React__default.createElement("div", {
3330
+ className: "extraTools__download-xlsx",
3331
+ style: {
3332
+ display: 'none'
3333
+ },
3334
+ "aria-hidden": "true"
3335
+ }, /*#__PURE__*/React__default.createElement(DownloadExcel, {
3336
+ data: data,
3337
+ element: /*#__PURE__*/React__default.createElement("span", {
3338
+ ref: xlsxTriggerRef
3339
+ })
3283
3340
  })));
3284
3341
  };
3285
3342
  DownloadMenu.defaultProps = {
@@ -3315,27 +3372,23 @@ DownloadMenu.propTypes = {
3315
3372
  /** 匯出檔名前綴(下載圖片/Tsv 檔名=前綴_YYYY-MM-DD) */
3316
3373
  exportFileName: PropTypes.string
3317
3374
  };
3318
- const FullscreenBtn = _ref4 => {
3375
+ const FullscreenBtn = _ref5 => {
3319
3376
  let {
3320
3377
  className,
3321
3378
  intl,
3322
3379
  iconColor,
3323
3380
  fullscreenDomId
3324
- } = _ref4;
3381
+ } = _ref5;
3325
3382
  return /*#__PURE__*/React__default.createElement("div", {
3326
3383
  className: classNames('extraTools__fullscreenBtn', className)
3327
3384
  }, /*#__PURE__*/React__default.createElement(Tooltip, {
3328
- title: intl ? intl.formatMessage({
3329
- id: 'knowledge.writersAndWorksSNA.fullscreen'
3330
- }) : '全螢幕模式',
3385
+ title: translate(intl, 'knowledge.writersAndWorksSNA.fullscreen'),
3331
3386
  placement: "bottom"
3332
3387
  }, /*#__PURE__*/React__default.createElement("div", {
3333
3388
  className: "extraTools__fullscreenBtn-icon",
3334
3389
  role: "button",
3335
3390
  tabIndex: 0,
3336
- "aria-label": intl ? intl.formatMessage({
3337
- id: 'knowledge.writersAndWorksSNA.fullscreen'
3338
- }) : '全螢幕模式',
3391
+ "aria-label": translate(intl, 'knowledge.writersAndWorksSNA.fullscreen'),
3339
3392
  onClick: () => {
3340
3393
  if (screenfull.isEnabled && fullscreenDomId) screenfull.request(document.getElementById(fullscreenDomId));
3341
3394
  },
@@ -3368,14 +3421,14 @@ FullscreenBtn.propTypes = {
3368
3421
  /** 全螢幕指定DOM */
3369
3422
  fullscreenDomId: PropTypes.string
3370
3423
  };
3371
- const FontSizeChanger = _ref5 => {
3424
+ const FontSizeChanger = _ref6 => {
3372
3425
  let {
3373
3426
  className,
3374
3427
  intl,
3375
3428
  iconColor,
3376
3429
  FontSizeTargets,
3377
3430
  FontSizeOptions
3378
- } = _ref5;
3431
+ } = _ref6;
3379
3432
  /* WCAG 2.1.1/4.1.2 react-font-size-changer 渲染的 A+/A− 為純 div onClick、
3380
3433
  無法聚焦也無鍵盤操作(第三方庫不提供 prop):掛載後補 tabindex/role/aria-label/Enter+Space */
3381
3434
  const rootRef = useRef(null);
@@ -3385,12 +3438,9 @@ const FontSizeChanger = _ref5 => {
3385
3438
  if (el.getAttribute('tabindex') === '0') return;
3386
3439
  const isUp = el.classList.contains('font-size-up');
3387
3440
  const labelId = isUp ? 'knowledge.writersAndWorksSNA.big' : 'knowledge.writersAndWorksSNA.small';
3388
- const fallback = isUp ? '字級放大' : '字級縮小';
3389
3441
  el.setAttribute('tabindex', '0');
3390
3442
  el.setAttribute('role', 'button');
3391
- el.setAttribute('aria-label', intl ? intl.formatMessage({
3392
- id: labelId
3393
- }) : fallback);
3443
+ el.setAttribute('aria-label', translate(intl, labelId));
3394
3444
  el.addEventListener('keydown', event => {
3395
3445
  if (event.key === 'Enter' || event.key === ' ') {
3396
3446
  event.preventDefault();
@@ -3408,29 +3458,21 @@ const FontSizeChanger = _ref5 => {
3408
3458
  customButtons: {
3409
3459
  /* 外層按鈕由 react-font-size-changer 渲染,以 role="img" + aria-label 提供按鈕可及名稱(WCAG 4.1.2) */
3410
3460
  up: /*#__PURE__*/React__default.createElement(Tooltip, {
3411
- title: intl ? intl.formatMessage({
3412
- id: 'knowledge.writersAndWorksSNA.big'
3413
- }) : '字級放大',
3461
+ title: translate(intl, 'knowledge.writersAndWorksSNA.big'),
3414
3462
  placement: "bottom"
3415
3463
  }, /*#__PURE__*/React__default.createElement("span", {
3416
3464
  role: "img",
3417
- "aria-label": intl ? intl.formatMessage({
3418
- id: 'knowledge.writersAndWorksSNA.big'
3419
- }) : '字級放大'
3465
+ "aria-label": translate(intl, 'knowledge.writersAndWorksSNA.big')
3420
3466
  }, /*#__PURE__*/React__default.createElement(SVGComponent$2, {
3421
3467
  fill: iconColor,
3422
3468
  "aria-hidden": "true"
3423
3469
  }))),
3424
3470
  down: /*#__PURE__*/React__default.createElement(Tooltip, {
3425
- title: intl ? intl.formatMessage({
3426
- id: 'knowledge.writersAndWorksSNA.small'
3427
- }) : '字級縮小',
3471
+ title: translate(intl, 'knowledge.writersAndWorksSNA.small'),
3428
3472
  placement: "bottom"
3429
3473
  }, /*#__PURE__*/React__default.createElement("span", {
3430
3474
  role: "img",
3431
- "aria-label": intl ? intl.formatMessage({
3432
- id: 'knowledge.writersAndWorksSNA.small'
3433
- }) : '字級縮小'
3475
+ "aria-label": translate(intl, 'knowledge.writersAndWorksSNA.small')
3434
3476
  }, /*#__PURE__*/React__default.createElement(SVGComponent$1, {
3435
3477
  fill: iconColor,
3436
3478
  "aria-hidden": "true"
@@ -3466,27 +3508,23 @@ FontSizeChanger.propTypes = {
3466
3508
  /** 改變文字的選項 */
3467
3509
  FontSizeOptions: PropTypes.objectOf(PropTypes.any)
3468
3510
  };
3469
- const SNAResetBtn = _ref6 => {
3511
+ const SNAResetBtn = _ref7 => {
3470
3512
  let {
3471
3513
  className,
3472
3514
  intl,
3473
3515
  iconColor,
3474
3516
  renderSNA
3475
- } = _ref6;
3517
+ } = _ref7;
3476
3518
  const isMobile = useMediaQuery('(max-width: 746px)');
3477
3519
  return /*#__PURE__*/React__default.createElement("div", {
3478
3520
  className: classNames('extraTools__resetSNA', className)
3479
3521
  }, /*#__PURE__*/React__default.createElement("div", {
3480
3522
  id: "resetBtn"
3481
3523
  }, /*#__PURE__*/React__default.createElement(Tooltip, {
3482
- title: intl ? intl.formatMessage({
3483
- id: 'common.sna.reset'
3484
- }) : '回到原來位置與大小',
3524
+ title: translate(intl, 'common.sna.reset'),
3485
3525
  placement: "bottom"
3486
3526
  }, /*#__PURE__*/React__default.createElement(IconButton, {
3487
- "aria-label": intl ? intl.formatMessage({
3488
- id: 'common.sna.reset'
3489
- }) : '回到原來位置與大小',
3527
+ "aria-label": translate(intl, 'common.sna.reset'),
3490
3528
  onClick: () => renderSNA(),
3491
3529
  style: {
3492
3530
  padding: '0px'
@@ -1,4 +1,4 @@
1
- export { E as default } from './ExtraTools-0f9ca8be.js';
1
+ export { E as default } from './ExtraTools-2691c13e.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';
@@ -12,7 +12,19 @@ var css_248z = ".forwardLink {\n width: -moz-fit-content;\n width: fit-content
12
12
  styleInject(css_248z);
13
13
 
14
14
  var _excluded = ["className", "linkClassName", "title", "target", "disabled", "children", "tip", "onClick"];
15
- var locale = '/zh-tw'; // 20230318 暫時寫死,若套件納入語系控制,可將其置換
15
+
16
+ /*
17
+ * 導頁前綴沿用目前網址的語系段(/en/…、/zh-tw/…)。
18
+ * 原本寫死 '/zh-tw'(2023-03-18 暫時寫死),英文頁上的 ForwardLink 一律把使用者帶回中文站(nmtl-web i18n 盤點 D2)。
19
+ * history.location.pathname 不含 Router basename(各站 contextRoot),第一段就是語系;
20
+ * 只接受已知語系代碼,避免把 hr/lg/ra 這類兩個字母的子站代碼誤認成語系。
21
+ */
22
+ var KNOWN_LOCALES = ['zh-tw', 'zh-cn', 'en', 'en-us'];
23
+ var DEFAULT_LOCALE = 'zh-tw';
24
+ var getLocalePrefix = function getLocalePrefix(pathname) {
25
+ var firstSegment = (pathname || '').split('/').filter(Boolean)[0];
26
+ return "/".concat(firstSegment && KNOWN_LOCALES.includes(firstSegment.toLowerCase()) ? firstSegment : DEFAULT_LOCALE);
27
+ };
16
28
 
17
29
  /*
18
30
  * ⚠️ 本元件刻意「不輸出 href 屬性」,請勿改回 <a> 或 react-router <Link>。
@@ -69,7 +81,7 @@ var ForwardLink = function ForwardLink(_ref) {
69
81
  var go = useCallback(function () {
70
82
  if (onClick && onClick() === false) return;
71
83
  var to = {
72
- pathname: "".concat(locale).concat(pathname),
84
+ pathname: "".concat(getLocalePrefix(history.location.pathname)).concat(pathname),
73
85
  search: search
74
86
  };
75
87
  if (target === '_blank') {
@@ -1,4 +1,4 @@
1
- export { F as default } from './ForwardLink-fec856b3.js';
1
+ export { F as default } from './ForwardLink-5fbd2705.js';
2
2
  import './_rollupPluginBabelHelpers-a52356f6.js';
3
3
  import 'react';
4
4
  import 'prop-types';
@@ -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, useRef, useEffect } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { c as classNames } from './index-b76a85f4.js';
5
- import { F as ForwardLink } from './ForwardLink-fec856b3.js';
5
+ import { F as ForwardLink } from './ForwardLink-5fbd2705.js';
6
6
  import { getIntl } from './globalConfig';
7
7
  import { s as styleInject } from './style-inject.es-1f59c1d0.js';
8
8
  import './index-b47819f3.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';