@daoyi/nmtl-ui 2.0.1-beta.146 → 2.0.1-beta.147

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.
@@ -12100,6 +12100,15 @@ FormItem.propTypes = {
12100
12100
  onNotify: PropTypes.func
12101
12101
  };
12102
12102
 
12103
+ /* 使用者輸入的值放進 HTML 信件:跳脫 HTML 特殊字元,換行改成 <br />(多行的「內容」才不會擠成一行) */
12104
+ const HTML_ESCAPES = {
12105
+ '&': '&amp;',
12106
+ '<': '&lt;',
12107
+ '>': '&gt;',
12108
+ '"': '&quot;'
12109
+ };
12110
+ const toHtml = value => String(value).replace(/[&<>"]/g, c => HTML_ESCAPES[c]).replace(/\r?\n/g, '<br />');
12111
+
12103
12112
  /* 資料提供 - 郵件內容 */
12104
12113
  const dataProvideMail = _ref => {
12105
12114
  let {
@@ -12122,50 +12131,50 @@ const dataProvideMail = _ref => {
12122
12131
  case 'name':
12123
12132
  if (values[key]) body.push(`${formatMessage({
12124
12133
  id: 'common.form.name'
12125
- })}:${values[key]}`);
12134
+ })}:${toHtml(values[key])}`);
12126
12135
  break;
12127
12136
  case 'email':
12128
- if (values[key]) body.push(`e-mail:${values[key]}`);
12137
+ if (values[key]) body.push(`e-mail:${toHtml(values[key])}`);
12129
12138
  break;
12130
12139
  case 'phone':
12131
12140
  if (values[key]) body.push(`${formatMessage({
12132
12141
  id: 'common.form.phone'
12133
- })}:${values[key]}`);
12142
+ })}:${toHtml(values[key])}`);
12134
12143
  break;
12135
12144
  case 'age':
12136
12145
  if (values[key]) body.push(`${formatMessage({
12137
12146
  id: 'common.form.age'
12138
- })}:${values[key]}`);
12147
+ })}:${toHtml(values[key])}`);
12139
12148
  break;
12140
12149
  case 'job':
12141
12150
  if (values[key]) body.push(`${formatMessage({
12142
12151
  id: 'common.form.job'
12143
- })}:${values[key]}`);
12152
+ })}:${toHtml(values[key])}`);
12144
12153
  break;
12145
12154
  case 'dataName':
12146
12155
  if (values[key]) body.push(`${formatMessage({
12147
12156
  id: 'common.form.dataname'
12148
- })}:${values[key]}`);
12157
+ })}:${toHtml(values[key])}`);
12149
12158
  break;
12150
12159
  case 'author':
12151
12160
  if (values[key]) body.push(`${formatMessage({
12152
12161
  id: 'common.form.author'
12153
- })}:${values[key]}`);
12162
+ })}:${toHtml(values[key])}`);
12154
12163
  break;
12155
12164
  case 'date':
12156
12165
  if (values[key]) body.push(`${formatMessage({
12157
12166
  id: 'common.form.datadate'
12158
- })}:${values[key]}`);
12167
+ })}:${toHtml(values[key])}`);
12159
12168
  break;
12160
12169
  case 'offer':
12161
12170
  if (values[key]) body.push(`${formatMessage({
12162
12171
  id: 'common.form.providername'
12163
- })}:${values[key]}`);
12172
+ })}:${toHtml(values[key])}`);
12164
12173
  break;
12165
12174
  case 'message':
12166
12175
  if (values[key]) body.push(`${formatMessage({
12167
12176
  id: 'common.content'
12168
- })}:${values[key]}`);
12177
+ })}:${toHtml(values[key])}`);
12169
12178
  break;
12170
12179
  }
12171
12180
  });
@@ -12194,30 +12203,30 @@ const problemMail = _ref2 => {
12194
12203
  case 'name':
12195
12204
  if (values[key]) body.push(`${formatMessage({
12196
12205
  id: 'common.form.name'
12197
- })}:${values[key]}`);
12206
+ })}:${toHtml(values[key])}`);
12198
12207
  break;
12199
12208
  case 'email':
12200
- if (values[key]) body.push(`e-mail:${values[key]}`);
12209
+ if (values[key]) body.push(`e-mail:${toHtml(values[key])}`);
12201
12210
  break;
12202
12211
  case 'phone':
12203
12212
  if (values[key]) body.push(`${formatMessage({
12204
12213
  id: 'common.form.phone'
12205
- })}:${values[key]}`);
12214
+ })}:${toHtml(values[key])}`);
12206
12215
  break;
12207
12216
  case 'age':
12208
12217
  if (values[key]) body.push(`${formatMessage({
12209
12218
  id: 'common.form.age'
12210
- })}:${values[key]}`);
12219
+ })}:${toHtml(values[key])}`);
12211
12220
  break;
12212
12221
  case 'job':
12213
12222
  if (values[key]) body.push(`${formatMessage({
12214
12223
  id: 'common.form.job'
12215
- })}:${values[key]}`);
12224
+ })}:${toHtml(values[key])}`);
12216
12225
  break;
12217
12226
  case 'message':
12218
12227
  if (values[key]) body.push(`${formatMessage({
12219
12228
  id: 'common.content'
12220
- })}:${values[key]}`);
12229
+ })}:${toHtml(values[key])}`);
12221
12230
  break;
12222
12231
  }
12223
12232
  });
@@ -12251,7 +12260,8 @@ var ContactModal = function ContactModal(_ref) {
12251
12260
  open = _ref.open,
12252
12261
  emailAPI = _ref.emailAPI,
12253
12262
  setOpen = _ref.setOpen,
12254
- onNotify = _ref.onNotify;
12263
+ onNotify = _ref.onNotify,
12264
+ initialMessage = _ref.initialMessage;
12255
12265
  var _getIntl = getIntl(),
12256
12266
  formatMessage = _getIntl.formatMessage;
12257
12267
  var _useState = useState(false),
@@ -12405,6 +12415,12 @@ var ContactModal = function ContactModal(_ref) {
12405
12415
  }
12406
12416
  });
12407
12417
 
12418
+ /* 開啟時帶入預設的「內容」(例:全文搜尋的我要糾錯帶入作品與搜尋字詞)。
12419
+ 關閉、送出成功都會 resetForm 清空,所以每次開啟都換成這次的內容;使用者已經輸入的內容不覆蓋 */
12420
+ useEffect(function () {
12421
+ if (open && initialMessage && !formik.values.message) formik.setFieldValue('message', initialMessage, false);
12422
+ }, [open, initialMessage]);
12423
+
12408
12424
  /* 關閉表單 */
12409
12425
  var handleClose = function handleClose() {
12410
12426
  formik.resetForm();
@@ -12506,7 +12522,8 @@ ContactModal.defaultProps = {
12506
12522
  open: false,
12507
12523
  emailAPI: '/nmtl2/mail',
12508
12524
  setOpen: function setOpen() {},
12509
- onNotify: function onNotify() {}
12525
+ onNotify: function onNotify() {},
12526
+ initialMessage: ''
12510
12527
  };
12511
12528
  ContactModal.propTypes = {
12512
12529
  /** 我有問題的種類為(DATA_PROVIDER or PROBLEM) */
@@ -12520,7 +12537,9 @@ ContactModal.propTypes = {
12520
12537
  /** 設定Modal是否開啟 */
12521
12538
  setOpen: PropTypes.func,
12522
12539
  /** 錯誤或成功時的提示 */
12523
- onNotify: PropTypes.func
12540
+ onNotify: PropTypes.func,
12541
+ /** 開啟時帶入「內容」欄的文字(使用者已輸入的不覆蓋;關閉後清空) */
12542
+ initialMessage: PropTypes.string
12524
12543
  };
12525
12544
 
12526
12545
  export { ContactModal as C };
@@ -1,4 +1,4 @@
1
- export { C as default } from './ContactModal-864f9ccc.js';
1
+ export { C as default } from './ContactModal-2c1332d5.js';
2
2
  import './_rollupPluginBabelHelpers-a52356f6.js';
3
3
  import 'react';
4
4
  import 'prop-types';
@@ -3,7 +3,7 @@ import React__default, { useState, useEffect } from 'react';
3
3
  import { c as classNames } from './index-c33afcb5.js';
4
4
  import PropTypes from 'prop-types';
5
5
  import axios from 'axios';
6
- import { C as ContactModal } from './ContactModal-864f9ccc.js';
6
+ import { C as ContactModal } from './ContactModal-2c1332d5.js';
7
7
  import { S as Spin } from './Spin-07679812.js';
8
8
  import { getIntl } from './globalConfig';
9
9
  import { s as styleInject } from './style-inject.es-1f59c1d0.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@daoyi/nmtl-ui",
3
3
  "packageManager": "pnpm@10.34.5",
4
- "version": "2.0.1-beta.146",
4
+ "version": "2.0.1-beta.147",
5
5
  "description": "This project is to be used as a starter kit for building React component using Storybook and Rollup",
6
6
  "author": "daoyi",
7
7
  "main": "lib/index.js",