@bchr/bchr-front-lib 0.5.11-alpha-2025.10.23.1 → 0.6.1

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.
package/README.md CHANGED
@@ -1,3 +1,18 @@
1
1
  # BCHR-FRONT-LIB
2
2
 
3
3
  ## 1. update react page component ref use mode
4
+
5
+ ## 2. Password mask length
6
+
7
+ `InputPasswordDecrypt`, `FormForBrowse`, `FormForModify`, and `GridForBrowse` support the optional `maskLength` prop:
8
+
9
+ ```jsx
10
+ <InputPasswordDecrypt ui_render_type="browse" initValue={encryptedValue} maskLength={12} requestUrl={requestUrl} appconfig={appconfig} />
11
+ <FormForBrowse {...formProps} maskLength={12} />
12
+ <FormForModify {...formProps} maskLength={12} />
13
+ <GridForBrowse {...gridProps} maskLength={12} />
14
+ ```
15
+
16
+ `maskLength` must be a positive integer. Missing or invalid values, including numeric strings, default to 8. Empty values remain empty. All password fields within a form or grid use the same length; no field type configuration is required. `FormModifyModal` forwards this prop to `FormForModify` automatically.
17
+
18
+ Changing the effective mask length hides any displayed plaintext and invalidates pending decryption requests. Manual hiding and automatic hiding after 5 seconds use the current length. This prop only controls the displayed mask, not the editable field's input length.
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _antd = require("antd");
10
+ var _HttpService = _interopRequireDefault(require("../../../services/HttpService"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
13
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
14
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
15
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
16
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
17
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
18
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
20
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
21
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
22
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
23
+ var MASK_LENGTH = 8;
24
+ var maskValue = function maskValue(value, maskLength) {
25
+ if (value === null || value === undefined || value === "") {
26
+ return "";
27
+ }
28
+ return "*".repeat(maskLength);
29
+ };
30
+ var InputPasswordDecrypt = function InputPasswordDecrypt(props) {
31
+ var ui_render_type = props.ui_render_type,
32
+ initValue = props.initValue,
33
+ requestUrl = props.requestUrl,
34
+ appconfig = props.appconfig,
35
+ appConfig = props.appConfig,
36
+ maskLength = props.maskLength;
37
+ var resolvedMaskLength = Number.isInteger(maskLength) && maskLength > 0 ? maskLength : MASK_LENGTH;
38
+ var serviceConfig = appconfig || appConfig;
39
+ var _useState = (0, _react.useState)(false),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ toggle = _useState2[0],
42
+ setToggle = _useState2[1];
43
+ var _useState3 = (0, _react.useState)(maskValue(initValue, resolvedMaskLength)),
44
+ _useState4 = _slicedToArray(_useState3, 2),
45
+ toggleVal = _useState4[0],
46
+ setToggleVal = _useState4[1];
47
+ var _useState5 = (0, _react.useState)(false),
48
+ _useState6 = _slicedToArray(_useState5, 2),
49
+ loading = _useState6[0],
50
+ setLoading = _useState6[1];
51
+ var timerRef = (0, _react.useRef)(null);
52
+ var requestSeqRef = (0, _react.useRef)(0);
53
+ var clearHideTimer = function clearHideTimer() {
54
+ if (timerRef.current) {
55
+ clearTimeout(timerRef.current);
56
+ timerRef.current = null;
57
+ }
58
+ };
59
+ (0, _react.useEffect)(function () {
60
+ setToggle(false);
61
+ setToggleVal(maskValue(initValue, resolvedMaskLength));
62
+ setLoading(false);
63
+ return function () {
64
+ requestSeqRef.current += 1;
65
+ clearHideTimer();
66
+ };
67
+ }, [initValue, resolvedMaskLength]);
68
+ var hidePlainText = function hidePlainText() {
69
+ clearHideTimer();
70
+ setToggleVal(maskValue(initValue, resolvedMaskLength));
71
+ setToggle(false);
72
+ };
73
+ var showPlainText = function showPlainText(plainText) {
74
+ clearHideTimer();
75
+ setToggleVal(plainText);
76
+ setToggle(true);
77
+ timerRef.current = setTimeout(function () {
78
+ timerRef.current = null;
79
+ setToggleVal(maskValue(initValue, resolvedMaskLength));
80
+ setToggle(false);
81
+ }, 5000);
82
+ };
83
+ var onToggleFull = /*#__PURE__*/function () {
84
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
85
+ var requestSeq, result, _t;
86
+ return _regenerator().w(function (_context) {
87
+ while (1) switch (_context.p = _context.n) {
88
+ case 0:
89
+ if (!toggle) {
90
+ _context.n = 1;
91
+ break;
92
+ }
93
+ hidePlainText();
94
+ return _context.a(2);
95
+ case 1:
96
+ if (!loading) {
97
+ _context.n = 2;
98
+ break;
99
+ }
100
+ return _context.a(2);
101
+ case 2:
102
+ if (requestUrl) {
103
+ _context.n = 3;
104
+ break;
105
+ }
106
+ _antd.message.error("请为组件注入属性【requestUrl】");
107
+ return _context.a(2);
108
+ case 3:
109
+ if (serviceConfig) {
110
+ _context.n = 4;
111
+ break;
112
+ }
113
+ _antd.message.error("请为组件注入属性【appconfig】");
114
+ return _context.a(2);
115
+ case 4:
116
+ requestSeq = requestSeqRef.current + 1;
117
+ requestSeqRef.current = requestSeq;
118
+ setLoading(true);
119
+ _context.p = 5;
120
+ _context.n = 6;
121
+ return new _HttpService["default"](requestUrl, serviceConfig).post("decrypt", {
122
+ data: initValue
123
+ });
124
+ case 6:
125
+ result = _context.v;
126
+ if (!(requestSeq !== requestSeqRef.current)) {
127
+ _context.n = 7;
128
+ break;
129
+ }
130
+ return _context.a(2);
131
+ case 7:
132
+ if (!(typeof result !== "string")) {
133
+ _context.n = 8;
134
+ break;
135
+ }
136
+ _antd.message.error("解密失败");
137
+ return _context.a(2);
138
+ case 8:
139
+ showPlainText(result);
140
+ _context.n = 11;
141
+ break;
142
+ case 9:
143
+ _context.p = 9;
144
+ _t = _context.v;
145
+ if (!(requestSeq !== requestSeqRef.current)) {
146
+ _context.n = 10;
147
+ break;
148
+ }
149
+ return _context.a(2);
150
+ case 10:
151
+ if (_t && _t.responseJSON && _t.responseJSON.msg) {
152
+ _antd.message.error(_t.responseJSON.msg);
153
+ } else {
154
+ _antd.message.error("解密失败");
155
+ }
156
+ case 11:
157
+ _context.p = 11;
158
+ if (requestSeq === requestSeqRef.current) {
159
+ setLoading(false);
160
+ }
161
+ return _context.f(11);
162
+ case 12:
163
+ return _context.a(2);
164
+ }
165
+ }, _callee, null, [[5, 9, 11, 12]]);
166
+ }));
167
+ return function onToggleFull() {
168
+ return _ref.apply(this, arguments);
169
+ };
170
+ }();
171
+ if (ui_render_type === "modify") {
172
+ return /*#__PURE__*/_react["default"].createElement(_antd.Input, {
173
+ value: toggleVal,
174
+ addonAfter: /*#__PURE__*/_react["default"].createElement("span", {
175
+ className: "iconfont ".concat(toggle ? "icon-bchr-show" : "icon-bchr-hide")
176
+ })
177
+ });
178
+ } else if (ui_render_type === "browse") {
179
+ return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("span", null, toggleVal, /*#__PURE__*/_react["default"].createElement("span", {
180
+ className: "iconfont ".concat(toggle ? "icon-bchr-show" : "icon-bchr-hide"),
181
+ style: {
182
+ cursor: "pointer",
183
+ margin: "0 5px",
184
+ color: "#337DB7",
185
+ fontWeight: "bolder"
186
+ },
187
+ onClick: onToggleFull
188
+ })));
189
+ }
190
+ };
191
+ var _default = exports["default"] = InputPasswordDecrypt;
@@ -10,7 +10,7 @@ var _antd = require("antd");
10
10
  var _icons = require("@ant-design/icons");
11
11
  var _moment = _interopRequireDefault(require("moment"));
12
12
  var _consts = require("../consts");
13
- var _InputPassword = _interopRequireDefault(require("../InputPassword"));
13
+ var _InputPasswordDecrypt = _interopRequireDefault(require("../InputPasswordDecrypt"));
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
15
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
16
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
@@ -320,9 +320,12 @@ var FormForBrowse = /*#__PURE__*/function (_React$Component) {
320
320
  }
321
321
  components = /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", null, value));
322
322
  if (ui_render_type === _consts.UI_RENDER_TYPE.INPUT_PASSWORD) {
323
- components = /*#__PURE__*/_react["default"].createElement("div", null, initialValues[code] && /*#__PURE__*/_react["default"].createElement(_InputPassword["default"], {
323
+ components = /*#__PURE__*/_react["default"].createElement("div", null, initialValues[code] && /*#__PURE__*/_react["default"].createElement(_InputPasswordDecrypt["default"], {
324
324
  ui_render_type: 'browse',
325
- initValue: initialValues[code]
325
+ initValue: initialValues[code],
326
+ maskLength: _this.props.maskLength,
327
+ requestUrl: _this.props.file_service_path,
328
+ appconfig: _this.props.appconfig || _this.props.appConfig
326
329
  }));
327
330
  }
328
331
  if (ui_render_type === _consts.UI_RENDER_TYPE.UPLOAD) {
@@ -11,7 +11,7 @@ var _moment = _interopRequireDefault(require("moment"));
11
11
  var _consts = require("../consts");
12
12
  var _zh_CN = _interopRequireDefault(require("antd/es/locale/zh_CN"));
13
13
  var _HttpService = _interopRequireDefault(require("../../../../services/HttpService"));
14
- var _InputPassword = _interopRequireDefault(require("../InputPassword"));
14
+ var _InputPasswordDecrypt = _interopRequireDefault(require("../InputPasswordDecrypt"));
15
15
  require("../../../AppFormulaFunctions");
16
16
  var _BaseAppUtils = require("../../../BaseAppUtils");
17
17
  var _SmartModal = require("../../modal/SmartModal");
@@ -330,9 +330,12 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
330
330
  }, ext_props));
331
331
  break;
332
332
  case _consts.UI_RENDER_TYPE.INPUT_PASSWORD:
333
- component = b_readonly || _this2.disabledExpression(dataItem, data) ? /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_InputPassword["default"], {
333
+ component = b_readonly || _this2.disabledExpression(dataItem, data) ? /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_InputPasswordDecrypt["default"], {
334
334
  ui_render_type: 'browse',
335
- initValue: displayValue
335
+ initValue: displayValue,
336
+ maskLength: _this2.props.maskLength,
337
+ requestUrl: _this2.props.file_service_path,
338
+ appconfig: _this2.props.appconfig || _this2.props.appConfig
336
339
  })) : /*#__PURE__*/_react["default"].createElement(_antd.Input, _extends({
337
340
  key: form_id + "_" + code,
338
341
  placeholder: "请填写" + name,
@@ -14,7 +14,7 @@ var _consts = require("../consts");
14
14
  var _GridFilterRowIndicator = _interopRequireDefault(require("./GridFilterRowIndicator"));
15
15
  var _zh_CN = _interopRequireDefault(require("antd/es/locale/zh_CN"));
16
16
  var _GridColumnCustomToolBar = _interopRequireDefault(require("./GridColumnCustomToolBar"));
17
- var _InputPassword = _interopRequireDefault(require("../InputPassword"));
17
+ var _InputPasswordDecrypt = _interopRequireDefault(require("../InputPasswordDecrypt"));
18
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
20
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
@@ -584,9 +584,12 @@ var GridForBrowse = /*#__PURE__*/function (_React$Component) {
584
584
  dangerouslySetInnerHTML: {
585
585
  __html: column_value_prefix
586
586
  }
587
- }), dataItem[code] ? /*#__PURE__*/_react["default"].createElement(_InputPassword["default"], {
587
+ }), dataItem[code] ? /*#__PURE__*/_react["default"].createElement(_InputPasswordDecrypt["default"], {
588
588
  ui_render_type: 'browse',
589
- initValue: dataItem[code]
589
+ initValue: dataItem[code],
590
+ maskLength: this.props.maskLength,
591
+ requestUrl: this.props.requestUrl,
592
+ appconfig: this.props.appconfig || this.props.appConfig
590
593
  }) : null);
591
594
  } else {
592
595
  return /*#__PURE__*/_react["default"].createElement("td", {