@bchr/bchr-front-lib 0.6.13 → 0.6.14

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.
@@ -115,6 +115,8 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
115
115
  var realValueRef = (0, _react.useRef)(incomingValue);
116
116
  var emittedRef = (0, _react.useRef)(incomingValue);
117
117
  var editingRef = (0, _react.useRef)(false);
118
+ var decryptedValueRef = (0, _react.useRef)("");
119
+ var hasDecryptedRef = (0, _react.useRef)(false);
118
120
  var maskLengthRef = (0, _react.useRef)(resolvedMaskLength);
119
121
  var composingRef = (0, _react.useRef)(false);
120
122
  var composeBaseDisplayRef = (0, _react.useRef)("");
@@ -196,6 +198,8 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
196
198
  emittedRef.current = incomingValue;
197
199
  editingRef.current = false;
198
200
  realValueRef.current = incomingValue;
201
+ decryptedValueRef.current = "";
202
+ hasDecryptedRef.current = false;
199
203
  setRealValue(incomingValue);
200
204
  requestSeqRef.current += 1;
201
205
  clearHideTimer();
@@ -219,6 +223,8 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
219
223
  emittedRef.current = normalized;
220
224
  editingRef.current = true;
221
225
  realValueRef.current = normalized;
226
+ decryptedValueRef.current = normalized;
227
+ hasDecryptedRef.current = true;
222
228
  setCompositionDisplay(null);
223
229
  setRealValue(normalized);
224
230
  if (flash) {
@@ -250,85 +256,110 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
250
256
  resetReveal();
251
257
  secret = realValueRef.current;
252
258
  if (!(ui_render_type === "modify")) {
253
- _context.n = 3;
259
+ _context.n = 5;
254
260
  break;
255
261
  }
256
- if (!editingRef.current) {
262
+ if (secret) {
257
263
  _context.n = 3;
258
264
  break;
259
265
  }
260
- showPlainText(secret, false);
266
+ decryptedValueRef.current = "";
267
+ hasDecryptedRef.current = true;
268
+ showPlainText("", false);
269
+ setTimeout(function () {
270
+ if (inputRef.current && inputRef.current.focus) {
271
+ inputRef.current.focus();
272
+ }
273
+ }, 0);
261
274
  return _context.a(2);
262
275
  case 3:
263
- if (secret) {
276
+ if (!editingRef.current) {
264
277
  _context.n = 4;
265
278
  break;
266
279
  }
280
+ showPlainText(secret, false);
267
281
  return _context.a(2);
268
282
  case 4:
269
- if (requestContextPath) {
283
+ if (!hasDecryptedRef.current) {
270
284
  _context.n = 5;
271
285
  break;
272
286
  }
273
- _antd.message.error("请为组件注入属性【requestUrl】");
287
+ showPlainText(decryptedValueRef.current, false);
274
288
  return _context.a(2);
275
289
  case 5:
276
- if (serviceConfig) {
290
+ if (secret) {
277
291
  _context.n = 6;
278
292
  break;
279
293
  }
280
- _antd.message.error("请为组件注入属性【appconfig】");
281
294
  return _context.a(2);
282
295
  case 6:
296
+ if (requestContextPath) {
297
+ _context.n = 7;
298
+ break;
299
+ }
300
+ _antd.message.error("请为组件注入属性【requestUrl】");
301
+ return _context.a(2);
302
+ case 7:
303
+ if (serviceConfig) {
304
+ _context.n = 8;
305
+ break;
306
+ }
307
+ _antd.message.error("请为组件注入属性【appconfig】");
308
+ return _context.a(2);
309
+ case 8:
283
310
  requestSeq = requestSeqRef.current + 1;
284
311
  requestSeqRef.current = requestSeq;
285
312
  setLoading(true);
286
- _context.p = 7;
287
- _context.n = 8;
313
+ _context.p = 9;
314
+ _context.n = 10;
288
315
  return new _HttpService["default"](requestContextPath, serviceConfig).post("decrypt", {
289
316
  data: secret
290
317
  });
291
- case 8:
318
+ case 10:
292
319
  result = _context.v;
293
320
  if (!(requestSeq !== requestSeqRef.current)) {
294
- _context.n = 9;
321
+ _context.n = 11;
295
322
  break;
296
323
  }
297
324
  return _context.a(2);
298
- case 9:
325
+ case 11:
299
326
  if (!(typeof result !== "string")) {
300
- _context.n = 10;
327
+ _context.n = 12;
301
328
  break;
302
329
  }
303
330
  _antd.message.error("解密失败");
304
331
  return _context.a(2);
305
- case 10:
332
+ case 12:
333
+ if (ui_render_type === "modify") {
334
+ decryptedValueRef.current = result;
335
+ hasDecryptedRef.current = true;
336
+ }
306
337
  showPlainText(result, ui_render_type !== "modify");
307
- _context.n = 13;
338
+ _context.n = 15;
308
339
  break;
309
- case 11:
310
- _context.p = 11;
340
+ case 13:
341
+ _context.p = 13;
311
342
  _t = _context.v;
312
343
  if (!(requestSeq !== requestSeqRef.current)) {
313
- _context.n = 12;
344
+ _context.n = 14;
314
345
  break;
315
346
  }
316
347
  return _context.a(2);
317
- case 12:
348
+ case 14:
318
349
  resetReveal();
319
350
  setToggle(false);
320
351
  setToggleVal(maskValue(secret, resolvedMaskLength));
321
352
  _antd.message.error(getErrorMessage(_t));
322
- case 13:
323
- _context.p = 13;
353
+ case 15:
354
+ _context.p = 15;
324
355
  if (requestSeq === requestSeqRef.current) {
325
356
  setLoading(false);
326
357
  }
327
- return _context.f(13);
328
- case 14:
358
+ return _context.f(15);
359
+ case 16:
329
360
  return _context.a(2);
330
361
  }
331
- }, _callee, null, [[7, 11, 13, 14]]);
362
+ }, _callee, null, [[9, 13, 15, 16]]);
332
363
  }));
333
364
  return function onToggleFull() {
334
365
  return _ref.apply(this, arguments);
@@ -422,15 +453,22 @@ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
422
453
  } else {
423
454
  modifyDisplay = maskValue(realValue, resolvedMaskLength);
424
455
  }
425
- return /*#__PURE__*/_react["default"].createElement(_antd.Input, _extends({}, restInputProps, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
456
+ return /*#__PURE__*/_react["default"].createElement(_antd.Input, _extends({}, restInputProps, {
426
457
  ref: inputRef,
427
- className: className,
428
458
  style: style,
429
459
  value: modifyDisplay,
430
460
  placeholder: placeholder,
431
461
  disabled: !toggle || disabled,
432
- allowClear: allowClear && toggle
433
- }, "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
+ allowClear: allowClear && toggle,
463
+ className: [className, MODIFY_INPUT_CLASS].filter(Boolean).join(" "),
464
+ maxLength: toggle && typeof maxLength === "number" ? maxLength : undefined,
465
+ onChange: onModifyChange,
466
+ onKeyDown: onModifyKeyDown,
467
+ onPaste: onModifyPaste,
468
+ onCompositionStart: onCompositionStart,
469
+ onCompositionEnd: onCompositionEnd,
470
+ suffix: renderToggleIcon()
471
+ }));
434
472
  }
435
473
  return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
436
474
  className: className,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bchr/bchr-front-lib",
3
- "version": "0.6.13",
3
+ "version": "0.6.14",
4
4
  "description": "bchr front lib",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -79,6 +79,8 @@ const InputPasswordDecrypt = (props) => {
79
79
  const realValueRef = useRef(incomingValue);
80
80
  const emittedRef = useRef(incomingValue);
81
81
  const editingRef = useRef(false);
82
+ const decryptedValueRef = useRef("");
83
+ const hasDecryptedRef = useRef(false);
82
84
  const maskLengthRef = useRef(resolvedMaskLength);
83
85
  const composingRef = useRef(false);
84
86
  const composeBaseDisplayRef = useRef("");
@@ -167,6 +169,8 @@ const InputPasswordDecrypt = (props) => {
167
169
  emittedRef.current = incomingValue;
168
170
  editingRef.current = false;
169
171
  realValueRef.current = incomingValue;
172
+ decryptedValueRef.current = "";
173
+ hasDecryptedRef.current = false;
170
174
  setRealValue(incomingValue);
171
175
  requestSeqRef.current += 1;
172
176
  clearHideTimer();
@@ -188,6 +192,8 @@ const InputPasswordDecrypt = (props) => {
188
192
  emittedRef.current = normalized;
189
193
  editingRef.current = true;
190
194
  realValueRef.current = normalized;
195
+ decryptedValueRef.current = normalized;
196
+ hasDecryptedRef.current = true;
191
197
  setCompositionDisplay(null);
192
198
  setRealValue(normalized);
193
199
  if (flash) {
@@ -210,10 +216,25 @@ const InputPasswordDecrypt = (props) => {
210
216
  resetReveal();
211
217
  const secret = realValueRef.current;
212
218
  if (ui_render_type === "modify") {
219
+ if (!secret) {
220
+ decryptedValueRef.current = "";
221
+ hasDecryptedRef.current = true;
222
+ showPlainText("", false);
223
+ setTimeout(() => {
224
+ if (inputRef.current && inputRef.current.focus) {
225
+ inputRef.current.focus();
226
+ }
227
+ }, 0);
228
+ return;
229
+ }
213
230
  if (editingRef.current) {
214
231
  showPlainText(secret, false);
215
232
  return;
216
233
  }
234
+ if (hasDecryptedRef.current) {
235
+ showPlainText(decryptedValueRef.current, false);
236
+ return;
237
+ }
217
238
  }
218
239
  if (!secret) {
219
240
  return;
@@ -239,6 +260,10 @@ const InputPasswordDecrypt = (props) => {
239
260
  message.error("解密失败");
240
261
  return;
241
262
  }
263
+ if (ui_render_type === "modify") {
264
+ decryptedValueRef.current = result;
265
+ hasDecryptedRef.current = true;
266
+ }
242
267
  showPlainText(result, ui_render_type !== "modify");
243
268
  } catch (error) {
244
269
  if (requestSeq !== requestSeqRef.current) {
@@ -351,7 +376,6 @@ const InputPasswordDecrypt = (props) => {
351
376
  <Input
352
377
  {...restInputProps}
353
378
  ref={inputRef}
354
- className={className}
355
379
  style={style}
356
380
  value={modifyDisplay}
357
381
  placeholder={placeholder}