@yuku123/z-mist-frontend-component 0.1.0

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 ADDED
@@ -0,0 +1,25 @@
1
+ # @yuku123/z-mist-frontend-component
2
+
3
+ > ��抽自 z-opc 对应 _frontend)
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @yuku123/z-mist-frontend-component
9
+ ```
10
+
11
+ ## 使用
12
+
13
+ ```jsx
14
+ import { SecretValueDisplay } from '@yuku123/z-mist-frontend-component'
15
+
16
+ <SecretValueDisplay prop="value"/>
17
+ ```
18
+
19
+ ## 仓库
20
+
21
+ https://github.com/yuku123/z-opc-frontend/tree/main/packages/z-mist-frontend-component
22
+
23
+ ## License
24
+
25
+ MIT
@@ -0,0 +1,315 @@
1
+ import re, { useState as te } from "react";
2
+ import { Space as ne, Input as ae, Button as $, message as oe } from "antd";
3
+ import { EyeInvisibleOutlined as se, EyeOutlined as le, CopyOutlined as ue } from "@ant-design/icons";
4
+ var v = { exports: {} }, _ = {};
5
+ /**
6
+ * @license React
7
+ * react-jsx-runtime.production.js
8
+ *
9
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
10
+ *
11
+ * This source code is licensed under the MIT license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ */
14
+ var D;
15
+ function ie() {
16
+ if (D) return _;
17
+ D = 1;
18
+ var l = Symbol.for("react.transitional.element"), f = Symbol.for("react.fragment");
19
+ function i(u, o, s) {
20
+ var m = null;
21
+ if (s !== void 0 && (m = "" + s), o.key !== void 0 && (m = "" + o.key), "key" in o) {
22
+ s = {};
23
+ for (var E in o)
24
+ E !== "key" && (s[E] = o[E]);
25
+ } else s = o;
26
+ return o = s.ref, {
27
+ $$typeof: l,
28
+ type: u,
29
+ key: m,
30
+ ref: o !== void 0 ? o : null,
31
+ props: s
32
+ };
33
+ }
34
+ return _.Fragment = f, _.jsx = i, _.jsxs = i, _;
35
+ }
36
+ var p = {};
37
+ /**
38
+ * @license React
39
+ * react-jsx-runtime.development.js
40
+ *
41
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
42
+ *
43
+ * This source code is licensed under the MIT license found in the
44
+ * LICENSE file in the root directory of this source tree.
45
+ */
46
+ var F;
47
+ function ce() {
48
+ return F || (F = 1, process.env.NODE_ENV !== "production" && (function() {
49
+ function l(e) {
50
+ if (e == null) return null;
51
+ if (typeof e == "function")
52
+ return e.$$typeof === Q ? null : e.displayName || e.name || null;
53
+ if (typeof e == "string") return e;
54
+ switch (e) {
55
+ case T:
56
+ return "Fragment";
57
+ case z:
58
+ return "Profiler";
59
+ case V:
60
+ return "StrictMode";
61
+ case X:
62
+ return "Suspense";
63
+ case B:
64
+ return "SuspenseList";
65
+ case Z:
66
+ return "Activity";
67
+ }
68
+ if (typeof e == "object")
69
+ switch (typeof e.tag == "number" && console.error(
70
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
71
+ ), e.$$typeof) {
72
+ case U:
73
+ return "Portal";
74
+ case J:
75
+ return e.displayName || "Context";
76
+ case q:
77
+ return (e._context.displayName || "Context") + ".Consumer";
78
+ case G:
79
+ var r = e.render;
80
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
81
+ case H:
82
+ return r = e.displayName || null, r !== null ? r : l(e.type) || "Memo";
83
+ case k:
84
+ r = e._payload, e = e._init;
85
+ try {
86
+ return l(e(r));
87
+ } catch {
88
+ }
89
+ }
90
+ return null;
91
+ }
92
+ function f(e) {
93
+ return "" + e;
94
+ }
95
+ function i(e) {
96
+ try {
97
+ f(e);
98
+ var r = !1;
99
+ } catch {
100
+ r = !0;
101
+ }
102
+ if (r) {
103
+ r = console;
104
+ var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
105
+ return t.call(
106
+ r,
107
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
108
+ n
109
+ ), f(e);
110
+ }
111
+ }
112
+ function u(e) {
113
+ if (e === T) return "<>";
114
+ if (typeof e == "object" && e !== null && e.$$typeof === k)
115
+ return "<...>";
116
+ try {
117
+ var r = l(e);
118
+ return r ? "<" + r + ">" : "<...>";
119
+ } catch {
120
+ return "<...>";
121
+ }
122
+ }
123
+ function o() {
124
+ var e = O.A;
125
+ return e === null ? null : e.getOwner();
126
+ }
127
+ function s() {
128
+ return Error("react-stack-top-frame");
129
+ }
130
+ function m(e) {
131
+ if (g.call(e, "key")) {
132
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
133
+ if (r && r.isReactWarning) return !1;
134
+ }
135
+ return e.key !== void 0;
136
+ }
137
+ function E(e, r) {
138
+ function t() {
139
+ h || (h = !0, console.error(
140
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
141
+ r
142
+ ));
143
+ }
144
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
145
+ get: t,
146
+ configurable: !0
147
+ });
148
+ }
149
+ function M() {
150
+ var e = l(this.type);
151
+ return N[e] || (N[e] = !0, console.error(
152
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
153
+ )), e = this.props.ref, e !== void 0 ? e : null;
154
+ }
155
+ function W(e, r, t, n, R, y) {
156
+ var a = t.ref;
157
+ return e = {
158
+ $$typeof: P,
159
+ type: e,
160
+ key: r,
161
+ props: t,
162
+ _owner: n
163
+ }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
164
+ enumerable: !1,
165
+ get: M
166
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
167
+ configurable: !1,
168
+ enumerable: !1,
169
+ writable: !0,
170
+ value: 0
171
+ }), Object.defineProperty(e, "_debugInfo", {
172
+ configurable: !1,
173
+ enumerable: !1,
174
+ writable: !0,
175
+ value: null
176
+ }), Object.defineProperty(e, "_debugStack", {
177
+ configurable: !1,
178
+ enumerable: !1,
179
+ writable: !0,
180
+ value: R
181
+ }), Object.defineProperty(e, "_debugTask", {
182
+ configurable: !1,
183
+ enumerable: !1,
184
+ writable: !0,
185
+ value: y
186
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
187
+ }
188
+ function j(e, r, t, n, R, y) {
189
+ var a = r.children;
190
+ if (a !== void 0)
191
+ if (n)
192
+ if (K(a)) {
193
+ for (n = 0; n < a.length; n++)
194
+ A(a[n]);
195
+ Object.freeze && Object.freeze(a);
196
+ } else
197
+ console.error(
198
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
199
+ );
200
+ else A(a);
201
+ if (g.call(r, "key")) {
202
+ a = l(e);
203
+ var d = Object.keys(r).filter(function(ee) {
204
+ return ee !== "key";
205
+ });
206
+ n = 0 < d.length ? "{key: someKey, " + d.join(": ..., ") + ": ...}" : "{key: someKey}", I[a + n] || (d = 0 < d.length ? "{" + d.join(": ..., ") + ": ...}" : "{}", console.error(
207
+ `A props object containing a "key" prop is being spread into JSX:
208
+ let props = %s;
209
+ <%s {...props} />
210
+ React keys must be passed directly to JSX without using spread:
211
+ let props = %s;
212
+ <%s key={someKey} {...props} />`,
213
+ n,
214
+ a,
215
+ d,
216
+ a
217
+ ), I[a + n] = !0);
218
+ }
219
+ if (a = null, t !== void 0 && (i(t), a = "" + t), m(r) && (i(r.key), a = "" + r.key), "key" in r) {
220
+ t = {};
221
+ for (var S in r)
222
+ S !== "key" && (t[S] = r[S]);
223
+ } else t = r;
224
+ return a && E(
225
+ t,
226
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
227
+ ), W(
228
+ e,
229
+ a,
230
+ t,
231
+ o(),
232
+ R,
233
+ y
234
+ );
235
+ }
236
+ function A(e) {
237
+ w(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === k && (e._payload.status === "fulfilled" ? w(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
238
+ }
239
+ function w(e) {
240
+ return typeof e == "object" && e !== null && e.$$typeof === P;
241
+ }
242
+ var b = re, P = Symbol.for("react.transitional.element"), U = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), V = Symbol.for("react.strict_mode"), z = Symbol.for("react.profiler"), q = Symbol.for("react.consumer"), J = Symbol.for("react.context"), G = Symbol.for("react.forward_ref"), X = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), k = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), Q = Symbol.for("react.client.reference"), O = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, g = Object.prototype.hasOwnProperty, K = Array.isArray, x = console.createTask ? console.createTask : function() {
243
+ return null;
244
+ };
245
+ b = {
246
+ react_stack_bottom_frame: function(e) {
247
+ return e();
248
+ }
249
+ };
250
+ var h, N = {}, C = b.react_stack_bottom_frame.bind(
251
+ b,
252
+ s
253
+ )(), Y = x(u(s)), I = {};
254
+ p.Fragment = T, p.jsx = function(e, r, t) {
255
+ var n = 1e4 > O.recentlyCreatedOwnerStacks++;
256
+ return j(
257
+ e,
258
+ r,
259
+ t,
260
+ !1,
261
+ n ? Error("react-stack-top-frame") : C,
262
+ n ? x(u(e)) : Y
263
+ );
264
+ }, p.jsxs = function(e, r, t) {
265
+ var n = 1e4 > O.recentlyCreatedOwnerStacks++;
266
+ return j(
267
+ e,
268
+ r,
269
+ t,
270
+ !0,
271
+ n ? Error("react-stack-top-frame") : C,
272
+ n ? x(u(e)) : Y
273
+ );
274
+ };
275
+ })()), p;
276
+ }
277
+ var L;
278
+ function fe() {
279
+ return L || (L = 1, process.env.NODE_ENV === "production" ? v.exports = ie() : v.exports = ce()), v.exports;
280
+ }
281
+ var c = fe();
282
+ function _e({ value: l, displayValue: f = "••••••", copyable: i = !0 }) {
283
+ const [u, o] = te(!1), s = () => {
284
+ l && (navigator.clipboard.writeText(l), oe.success("已复制到剪贴板"));
285
+ };
286
+ return /* @__PURE__ */ c.jsxs(ne, { children: [
287
+ /* @__PURE__ */ c.jsx(
288
+ ae,
289
+ {
290
+ value: u ? l : f,
291
+ readOnly: !0,
292
+ style: { width: 200 }
293
+ }
294
+ ),
295
+ /* @__PURE__ */ c.jsx(
296
+ $,
297
+ {
298
+ size: "small",
299
+ icon: u ? /* @__PURE__ */ c.jsx(se, {}) : /* @__PURE__ */ c.jsx(le, {}),
300
+ onClick: () => o(!u)
301
+ }
302
+ ),
303
+ i && /* @__PURE__ */ c.jsx(
304
+ $,
305
+ {
306
+ size: "small",
307
+ icon: /* @__PURE__ */ c.jsx(ue, {}),
308
+ onClick: s
309
+ }
310
+ )
311
+ ] });
312
+ }
313
+ export {
314
+ _e as SecretValueDisplay
315
+ };
@@ -0,0 +1,22 @@
1
+ (function(l,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react"),require("antd"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","react","antd","@ant-design/icons"],d):(l=typeof globalThis<"u"?globalThis:l||self,d(l.z_mist_frontend_component={},l.React,l.antd,l.icons))})(this,(function(l,d,E,O){"use strict";var T={exports:{}},p={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var w;function z(){if(w)return p;w=1;var u=Symbol.for("react.transitional.element"),m=Symbol.for("react.fragment");function f(i,o,s){var b=null;if(s!==void 0&&(b=""+s),o.key!==void 0&&(b=""+o.key),"key"in o){s={};for(var v in o)v!=="key"&&(s[v]=o[v])}else s=o;return o=s.ref,{$$typeof:u,type:i,key:b,ref:o!==void 0?o:null,props:s}}return p.Fragment=m,p.jsx=f,p.jsxs=f,p}var R={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var g;function U(){return g||(g=1,process.env.NODE_ENV!=="production"&&(function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case Z:return"Profiler";case H:return"StrictMode";case re:return"Suspense";case te:return"SuspenseList";case ae:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case B:return"Portal";case K:return e.displayName||"Context";case Q:return(e._context.displayName||"Context")+".Consumer";case ee:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ne:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case x:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function m(e){return""+e}function f(e){try{m(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),m(e)}}function i(e){if(e===S)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===x)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function o(){var e=j.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function b(e){if(F.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function v(e,r){function t(){$||($=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function G(){var e=u(this.type);return M[e]||(M[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function X(e,r,t,n,y,P){var a=t.ref;return e={$$typeof:D,type:e,key:r,props:t,_owner:n},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:G}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:y}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function C(e,r,t,n,y,P){var a=r.children;if(a!==void 0)if(n)if(se(a)){for(n=0;n<a.length;n++)Y(a[n]);Object.freeze&&Object.freeze(a)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Y(a);if(F.call(r,"key")){a=u(e);var _=Object.keys(r).filter(function(ue){return ue!=="key"});n=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",W[a+n]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,n,a,_,a),W[a+n]=!0)}if(a=null,t!==void 0&&(f(t),a=""+t),b(r)&&(f(r.key),a=""+r.key),"key"in r){t={};for(var h in r)h!=="key"&&(t[h]=r[h])}else t=r;return a&&v(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),X(e,a,t,o(),y,P)}function Y(e){I(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===x&&(e._payload.status==="fulfilled"?I(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function I(e){return typeof e=="object"&&e!==null&&e.$$typeof===D}var k=d,D=Symbol.for("react.transitional.element"),B=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),H=Symbol.for("react.strict_mode"),Z=Symbol.for("react.profiler"),Q=Symbol.for("react.consumer"),K=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),te=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),oe=Symbol.for("react.client.reference"),j=k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,se=Array.isArray,A=console.createTask?console.createTask:function(){return null};k={react_stack_bottom_frame:function(e){return e()}};var $,M={},L=k.react_stack_bottom_frame.bind(k,s)(),V=A(i(s)),W={};R.Fragment=S,R.jsx=function(e,r,t){var n=1e4>j.recentlyCreatedOwnerStacks++;return C(e,r,t,!1,n?Error("react-stack-top-frame"):L,n?A(i(e)):V)},R.jsxs=function(e,r,t){var n=1e4>j.recentlyCreatedOwnerStacks++;return C(e,r,t,!0,n?Error("react-stack-top-frame"):L,n?A(i(e)):V)}})()),R}var N;function q(){return N||(N=1,process.env.NODE_ENV==="production"?T.exports=z():T.exports=U()),T.exports}var c=q();function J({value:u,displayValue:m="••••••",copyable:f=!0}){const[i,o]=d.useState(!1),s=()=>{u&&(navigator.clipboard.writeText(u),E.message.success("已复制到剪贴板"))};return c.jsxs(E.Space,{children:[c.jsx(E.Input,{value:i?u:m,readOnly:!0,style:{width:200}}),c.jsx(E.Button,{size:"small",icon:i?c.jsx(O.EyeInvisibleOutlined,{}):c.jsx(O.EyeOutlined,{}),onClick:()=>o(!i)}),f&&c.jsx(E.Button,{size:"small",icon:c.jsx(O.CopyOutlined,{}),onClick:s})]})}l.SecretValueDisplay=J,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@yuku123/z-mist-frontend-component",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "z-mist 模块共享前端组件(抽自 z-opc/z-mist/_frontend)",
6
+ "keywords": ["react", "antd", "mist", "z-opc"],
7
+ "license": "MIT",
8
+ "author": { "name": "zifang", "email": "1340947819@qq.com" },
9
+ "homepage": "https://github.com/yuku123/z-opc-frontend/tree/main/packages/z-mist-frontend-component#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/yuku123/z-opc-frontend.git",
13
+ "directory": "packages/z-mist-frontend-component"
14
+ },
15
+ "bugs": { "url": "https://github.com/yuku123/z-opc-frontend/issues" },
16
+ "main": "./dist/z-mist-frontend-component.umd.js",
17
+ "module": "./dist/z-mist-frontend-component.es.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "import": "./dist/z-mist-frontend-component.es.js",
22
+ "require": "./dist/z-mist-frontend-component.umd.js"
23
+ }
24
+ },
25
+ "files": ["dist", "src", "README.md"],
26
+ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
27
+ "scripts": {
28
+ "dev": "vite --port 3091",
29
+ "build": "vite build",
30
+ "preview": "vite preview"
31
+ },
32
+ "peerDependencies": {
33
+ "react": "^19.2.0",
34
+ "react-dom": "^19.2.0",
35
+ "antd": "^6.3.3"
36
+ },
37
+ "devDependencies": {
38
+ "@vitejs/plugin-react": "^4.2.1",
39
+ "vite": "^6.2.0"
40
+ }
41
+ }
@@ -0,0 +1,45 @@
1
+ import React, {useState} from 'react'
2
+ import {Input, Button, Space, message} from 'antd'
3
+ import {EyeOutlined, EyeInvisibleOutlined, CopyOutlined} from '@ant-design/icons'
4
+
5
+ /**
6
+ * 密钥值显示(脱敏 + 显示切换 + 复制)
7
+ * <p>
8
+ * 抽自 z-mist/_frontend/src/pages/secret/SecretList.jsx
9
+ *
10
+ * @param {string} value - 原始密钥值(密文)
11
+ * @param {string} displayValue - 脱敏后的值(默认 ******)
12
+ * @param {boolean} copyable - 是否显示复制按钮
13
+ */
14
+ export default function SecretValueDisplay({value, displayValue = '••••••', copyable = true}) {
15
+ const [visible, setVisible] = useState(false)
16
+
17
+ const handleCopy = () => {
18
+ if (value) {
19
+ navigator.clipboard.writeText(value)
20
+ message.success('已复制到剪贴板')
21
+ }
22
+ }
23
+
24
+ return (
25
+ <Space>
26
+ <Input
27
+ value={visible ? value : displayValue}
28
+ readOnly
29
+ style={{width: 200}}
30
+ />
31
+ <Button
32
+ size="small"
33
+ icon={visible ? <EyeInvisibleOutlined/> : <EyeOutlined/>}
34
+ onClick={() => setVisible(!visible)}
35
+ />
36
+ {copyable && (
37
+ <Button
38
+ size="small"
39
+ icon={<CopyOutlined/>}
40
+ onClick={handleCopy}
41
+ />
42
+ )}
43
+ </Space>
44
+ )
45
+ }
package/src/dev.jsx ADDED
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom/client'
3
+ import SecretValueDisplay from './SecretValueDisplay'
4
+
5
+ const root = ReactDOM.createRoot(document.getElementById('root'))
6
+ root.render(
7
+ <div style={{padding: 40, display: 'flex', flexDirection: 'column', gap: 16}}>
8
+ <SecretValueDisplay value="sk-abc123def456" displayValue="••••••"/>
9
+ <SecretValueDisplay value="password-xyz"/>
10
+ </div>
11
+ )
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ export {default as SecretValueDisplay} from './SecretValueDisplay'