@bchr/bchr-front-lib 0.6.10 → 0.6.12

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.
@@ -38,6 +38,7 @@ var PASSWORD_ICON_STYLE = {
38
38
  color: "#337DB7",
39
39
  fontWeight: "bolder"
40
40
  };
41
+ var MODIFY_INPUT_CLASS = "bchr-input-password-decrypt-modify";
41
42
  var normalizeValue = function normalizeValue(value) {
42
43
  if (value === null || value === undefined) {
43
44
  return "";
@@ -256,7 +257,7 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
256
257
  _context.n = 3;
257
258
  break;
258
259
  }
259
- commitValue("", false);
260
+ showPlainText("", false);
260
261
  if (inputRef.current && inputRef.current.focus) {
261
262
  inputRef.current.focus();
262
263
  }
@@ -266,7 +267,7 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
266
267
  _context.n = 4;
267
268
  break;
268
269
  }
269
- showPlainText(secret);
270
+ showPlainText(secret, false);
270
271
  return _context.a(2);
271
272
  case 4:
272
273
  if (secret) {
@@ -312,7 +313,7 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
312
313
  _antd.message.error("解密失败");
313
314
  return _context.a(2);
314
315
  case 11:
315
- showPlainText(result);
316
+ showPlainText(result, ui_render_type !== "modify");
316
317
  _context.n = 14;
317
318
  break;
318
319
  case 12:
@@ -347,36 +348,30 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
347
348
  if (onKeyDown) {
348
349
  onKeyDown(event);
349
350
  }
350
- if (disabled || toggle || composingRef.current || event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey || event.isComposing) {
351
+ if (disabled || !toggle || event.defaultPrevented) {
351
352
  return;
352
353
  }
353
- if (event.key === "Backspace" || event.key === "Delete") {
354
- event.preventDefault();
355
- commitValue(editingRef.current ? realValueRef.current.slice(0, -1) : "", false);
356
- return;
357
- }
358
- if (event.key.length !== 1) {
359
- return;
360
- }
361
- event.preventDefault();
362
- commitValue(editingRef.current ? realValueRef.current + event.key : event.key, true);
363
354
  };
364
355
  var onModifyPaste = function onModifyPaste(event) {
365
356
  if (onPaste) {
366
357
  onPaste(event);
367
358
  }
368
- if (disabled || toggle || composingRef.current || event.defaultPrevented) {
359
+ if (disabled) {
360
+ return;
361
+ }
362
+ if (!toggle) {
363
+ event.preventDefault();
369
364
  return;
370
365
  }
371
- var text = event.clipboardData ? event.clipboardData.getData("text") : "";
372
- event.preventDefault();
373
- if (!text) {
366
+ if (event.defaultPrevented) {
374
367
  return;
375
368
  }
376
- commitValue(editingRef.current ? realValueRef.current + text : text, false);
377
369
  };
378
370
  var onCompositionStart = function onCompositionStart(event) {
379
371
  clearRevealTimer();
372
+ if (!toggle) {
373
+ return;
374
+ }
380
375
  var compositionDisplayValue = event && event.target ? event.target.value : typeof event === "string" ? event : "";
381
376
  composingRef.current = true;
382
377
  composeBaseDisplayRef.current = compositionDisplayValue;
@@ -387,25 +382,19 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
387
382
  return;
388
383
  }
389
384
  composingRef.current = false;
390
- if (disabled || toggle) {
391
- return;
392
- }
393
- var domValue = event && event.target ? event.target.value : typeof event === "string" ? event : "";
394
- var baseValue = composeBaseDisplayRef.current;
395
- var composedText = baseValue && domValue.startsWith(baseValue) ? domValue.slice(baseValue.length) : domValue.replace(/^\*+/, "");
396
- if (!composedText) {
385
+ if (disabled || !toggle) {
397
386
  setCompositionDisplay(null);
398
387
  return;
399
388
  }
400
- commitValue(editingRef.current ? realValueRef.current + composedText : composedText, true);
389
+ commitValue(event && event.target ? event.target.value : "", false);
401
390
  };
402
391
  var onModifyChange = function onModifyChange(valueOrEvent) {
403
392
  var nextValue = valueOrEvent && valueOrEvent.target ? valueOrEvent.target.value : valueOrEvent;
404
- if (composingRef.current && !toggle) {
405
- setCompositionDisplay(nextValue);
393
+ if (disabled || !toggle) {
406
394
  return;
407
395
  }
408
- if (disabled || !toggle && nextValue !== "") {
396
+ if (composingRef.current) {
397
+ setCompositionDisplay(nextValue);
409
398
  return;
410
399
  }
411
400
  commitValue(nextValue, false);
@@ -443,22 +432,15 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
443
432
  } else {
444
433
  modifyDisplay = maskValue(realValue, resolvedMaskLength);
445
434
  }
446
- return /*#__PURE__*/_react["default"].createElement(_antd.Input, _extends({}, restInputProps, {
435
+ return /*#__PURE__*/_react["default"].createElement(_antd.Input, _extends({}, restInputProps, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
447
436
  ref: inputRef,
448
437
  className: className,
449
438
  style: style,
450
439
  value: modifyDisplay,
451
440
  placeholder: placeholder,
452
- disabled: disabled,
453
- allowClear: allowClear,
454
- maxLength: toggle && typeof maxLength === "number" ? maxLength : undefined,
455
- onChange: onModifyChange,
456
- onKeyDown: onModifyKeyDown,
457
- onPaste: onModifyPaste,
458
- onCompositionStart: onCompositionStart,
459
- onCompositionEnd: onCompositionEnd,
460
- suffix: renderToggleIcon()
461
- }));
441
+ disabled: !toggle || disabled,
442
+ allowClear: allowClear && toggle
443
+ }, "className", [className, MODIFY_INPUT_CLASS].filter(Boolean).join(" ")), "maxLength", toggle && typeof maxLength === "number" ? maxLength : undefined), "onChange", onModifyChange), "onKeyDown", onModifyKeyDown), "onPaste", onModifyPaste), "onCompositionStart", onCompositionStart), "onCompositionEnd", onCompositionEnd), "suffix", renderToggleIcon())));
462
444
  }
463
445
  return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
464
446
  className: className,
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var ExcelJS = _interopRequireWildcard(require("exceljs"));
7
+ var ExcelJS = _interopRequireWildcard(require("exceljs/dist/exceljs.bare.js"));
8
8
  var _fileSaver = require("file-saver");
9
9
  var _Values = _interopRequireDefault(require("./Values"));
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -386,7 +386,7 @@ var ExcelKits = {
386
386
  header: column.title,
387
387
  key: column.dataIndex,
388
388
  locked: column.locked,
389
- width: column.width * 0.1
389
+ width: column.width != null ? column.width * 0.1 : undefined
390
390
  };
391
391
  }
392
392
  };
@@ -246,6 +246,18 @@
246
246
  display: none;
247
247
  }
248
248
 
249
+ .bchr-input-password-decrypt-modify.ant-input-affix-wrapper-disabled,
250
+ .bchr-input-password-decrypt-modify.ant-input-affix-wrapper-disabled:hover {
251
+ border: 1px solid #d9d9d9;
252
+ padding-left: 11px;
253
+ background-color: #fff;
254
+ }
255
+
256
+ .bchr-input-password-decrypt-modify.ant-input-affix-wrapper-disabled .ant-input[disabled] {
257
+ background: transparent;
258
+ border: none;
259
+ }
260
+
249
261
  .ant-select-dropdown {
250
262
  width: 100%;
251
263
  min-height: 38px;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@bchr/bchr-front-lib",
3
- "version": "0.6.10",
3
+ "version": "0.6.12",
4
4
  "description": "bchr front lib",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
7
  "prepublish": "babel src --out-dir lib --copy-files",
8
8
  "login": "npm login",
9
- "publish": "npm publish "
9
+ "publish": "npm publish ",
10
+ "unpublish": "npm unpublish "
10
11
  },
11
12
  "publishConfig": {
12
13
  "registry": "https://registry.npmjs.org",
@@ -11,6 +11,7 @@ const PASSWORD_ICON_STYLE = {
11
11
  color: "#337DB7",
12
12
  fontWeight: "bolder"
13
13
  };
14
+ const MODIFY_INPUT_CLASS = "bchr-input-password-decrypt-modify";
14
15
 
15
16
  const normalizeValue = (value) => {
16
17
  if (value === null || value === undefined) {
@@ -210,14 +211,14 @@ const InputPasswordDecrypt = (props) => {
210
211
  const secret = realValueRef.current;
211
212
  if (ui_render_type === "modify") {
212
213
  if (!secret) {
213
- commitValue("", false);
214
+ showPlainText("", false);
214
215
  if (inputRef.current && inputRef.current.focus) {
215
216
  inputRef.current.focus();
216
217
  }
217
218
  return;
218
219
  }
219
220
  if (editingRef.current) {
220
- showPlainText(secret);
221
+ showPlainText(secret, false);
221
222
  return;
222
223
  }
223
224
  }
@@ -245,7 +246,7 @@ const InputPasswordDecrypt = (props) => {
245
246
  message.error("解密失败");
246
247
  return;
247
248
  }
248
- showPlainText(result);
249
+ showPlainText(result, ui_render_type !== "modify");
249
250
  } catch (error) {
250
251
  if (requestSeq !== requestSeqRef.current) {
251
252
  return;
@@ -265,38 +266,32 @@ const InputPasswordDecrypt = (props) => {
265
266
  if (onKeyDown) {
266
267
  onKeyDown(event);
267
268
  }
268
- if (disabled || toggle || composingRef.current || event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey || event.isComposing) {
269
+ if (disabled || !toggle || event.defaultPrevented) {
269
270
  return;
270
271
  }
271
- if (event.key === "Backspace" || event.key === "Delete") {
272
- event.preventDefault();
273
- commitValue(editingRef.current ? realValueRef.current.slice(0, -1) : "", false);
274
- return;
275
- }
276
- if (event.key.length !== 1) {
277
- return;
278
- }
279
- event.preventDefault();
280
- commitValue(editingRef.current ? realValueRef.current + event.key : event.key, true);
281
272
  };
282
273
 
283
274
  const onModifyPaste = (event) => {
284
275
  if (onPaste) {
285
276
  onPaste(event);
286
277
  }
287
- if (disabled || toggle || composingRef.current || event.defaultPrevented) {
278
+ if (disabled) {
279
+ return;
280
+ }
281
+ if (!toggle) {
282
+ event.preventDefault();
288
283
  return;
289
284
  }
290
- const text = event.clipboardData ? event.clipboardData.getData("text") : "";
291
- event.preventDefault();
292
- if (!text) {
285
+ if (event.defaultPrevented) {
293
286
  return;
294
287
  }
295
- commitValue(editingRef.current ? realValueRef.current + text : text, false);
296
288
  };
297
289
 
298
290
  const onCompositionStart = (event) => {
299
291
  clearRevealTimer();
292
+ if (!toggle) {
293
+ return;
294
+ }
300
295
  const compositionDisplayValue = event && event.target ? event.target.value : (typeof event === "string" ? event : "");
301
296
  composingRef.current = true;
302
297
  composeBaseDisplayRef.current = compositionDisplayValue;
@@ -308,28 +303,20 @@ const InputPasswordDecrypt = (props) => {
308
303
  return;
309
304
  }
310
305
  composingRef.current = false;
311
- if (disabled || toggle) {
312
- return;
313
- }
314
- const domValue = event && event.target ? event.target.value : (typeof event === "string" ? event : "");
315
- const baseValue = composeBaseDisplayRef.current;
316
- const composedText = baseValue && domValue.startsWith(baseValue)
317
- ? domValue.slice(baseValue.length)
318
- : domValue.replace(/^\*+/, "");
319
- if (!composedText) {
306
+ if (disabled || !toggle) {
320
307
  setCompositionDisplay(null);
321
308
  return;
322
309
  }
323
- commitValue(editingRef.current ? realValueRef.current + composedText : composedText, true);
310
+ commitValue(event && event.target ? event.target.value : "", false);
324
311
  };
325
312
 
326
313
  const onModifyChange = (valueOrEvent) => {
327
314
  const nextValue = valueOrEvent && valueOrEvent.target ? valueOrEvent.target.value : valueOrEvent;
328
- if (composingRef.current && !toggle) {
329
- setCompositionDisplay(nextValue);
315
+ if (disabled || !toggle) {
330
316
  return;
331
317
  }
332
- if (disabled || (!toggle && nextValue !== "")) {
318
+ if (composingRef.current) {
319
+ setCompositionDisplay(nextValue);
333
320
  return;
334
321
  }
335
322
  commitValue(nextValue, false);
@@ -375,8 +362,9 @@ const InputPasswordDecrypt = (props) => {
375
362
  style={style}
376
363
  value={modifyDisplay}
377
364
  placeholder={placeholder}
378
- disabled={disabled}
379
- allowClear={allowClear}
365
+ disabled={!toggle || disabled}
366
+ allowClear={allowClear && toggle}
367
+ className={[className, MODIFY_INPUT_CLASS].filter(Boolean).join(" ")}
380
368
  maxLength={toggle && typeof maxLength === "number" ? maxLength : undefined}
381
369
  onChange={onModifyChange}
382
370
  onKeyDown={onModifyKeyDown}
@@ -1,4 +1,4 @@
1
- import * as ExcelJS from "exceljs";
1
+ import * as ExcelJS from "exceljs/dist/exceljs.bare.js";
2
2
  import {saveAs} from "file-saver";
3
3
  import Values from "./Values";
4
4
 
@@ -365,7 +365,7 @@ const ExcelKits = {
365
365
  header : column.title,
366
366
  key : column.dataIndex,
367
367
  locked : column.locked,
368
- width : column.width * 0.1
368
+ width : column.width != null ? column.width * 0.1 : undefined
369
369
  }
370
370
  }
371
371
  }
@@ -246,6 +246,18 @@
246
246
  display: none;
247
247
  }
248
248
 
249
+ .bchr-input-password-decrypt-modify.ant-input-affix-wrapper-disabled,
250
+ .bchr-input-password-decrypt-modify.ant-input-affix-wrapper-disabled:hover {
251
+ border: 1px solid #d9d9d9;
252
+ padding-left: 11px;
253
+ background-color: #fff;
254
+ }
255
+
256
+ .bchr-input-password-decrypt-modify.ant-input-affix-wrapper-disabled .ant-input[disabled] {
257
+ background: transparent;
258
+ border: none;
259
+ }
260
+
249
261
  .ant-select-dropdown {
250
262
  width: 100%;
251
263
  min-height: 38px;