@pisell/materials 6.0.17 → 6.0.19

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.
Files changed (41) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +6 -6
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +21 -21
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +21 -21
  11. package/es/components/dataSourceComponents/fields/Input/WithMode.d.ts +0 -1
  12. package/es/components/dataSourceComponents/fields/Input/WithMode.js +48 -508
  13. package/es/components/pisellQRScanner/index.d.ts +37 -0
  14. package/es/components/pisellQRScanner/index.js +1153 -0
  15. package/es/components/pisellQRScanner/index.less +71 -0
  16. package/es/index.d.ts +2 -0
  17. package/es/index.js +1 -0
  18. package/es/locales/en-US.d.ts +13 -0
  19. package/es/locales/en-US.js +14 -3
  20. package/es/locales/zh-CN.d.ts +9 -0
  21. package/es/locales/zh-CN.js +11 -1
  22. package/es/locales/zh-TW.d.ts +9 -0
  23. package/es/locales/zh-TW.js +11 -1
  24. package/lib/components/dataSourceComponents/fields/Input/WithMode.d.ts +0 -1
  25. package/lib/components/dataSourceComponents/fields/Input/WithMode.js +44 -323
  26. package/lib/components/pisellQRScanner/index.d.ts +37 -0
  27. package/lib/components/pisellQRScanner/index.js +706 -0
  28. package/lib/components/pisellQRScanner/index.less +71 -0
  29. package/lib/index.d.ts +2 -0
  30. package/lib/index.js +3 -0
  31. package/lib/locales/en-US.d.ts +13 -0
  32. package/lib/locales/en-US.js +19 -1
  33. package/lib/locales/zh-CN.d.ts +9 -0
  34. package/lib/locales/zh-CN.js +11 -1
  35. package/lib/locales/zh-TW.d.ts +9 -0
  36. package/lib/locales/zh-TW.js +11 -1
  37. package/lowcode/pisell-qrscanner/meta.ts +86 -0
  38. package/lowcode/pisell-qrscanner/snippets.ts +25 -0
  39. package/package.json +3 -3
  40. package/es/components/dataSourceComponents/fields/Input/WithMode.less +0 -96
  41. package/lib/components/dataSourceComponents/fields/Input/WithMode.less +0 -96
@@ -0,0 +1,71 @@
1
+ /* 全屏扫码容器 */
2
+ .pisell-qr-scanner-fullscreen {
3
+ position: fixed;
4
+ top: 0;
5
+ left: 0;
6
+ width: 100vw;
7
+ height: 100vh;
8
+ background-color: #000;
9
+ z-index: 9999;
10
+ overflow: hidden;
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ }
15
+
16
+ /* 视频容器 */
17
+ .scan-container {
18
+ position: relative;
19
+ width: 100%;
20
+ height: 100%;
21
+ overflow: hidden;
22
+ }
23
+
24
+ /* 视频元素 */
25
+ .scan-video {
26
+ width: 100%;
27
+ height: 100%;
28
+ object-fit: cover;
29
+ display: block;
30
+ }
31
+
32
+ /* 关闭按钮 */
33
+ .scan-close-left {
34
+ position: fixed;
35
+ top: 20px;
36
+ left: 20px;
37
+ z-index: 10000;
38
+ font-size: 24px;
39
+ color: #fff;
40
+ cursor: pointer;
41
+ background-color: rgba(255, 255, 255, 0.15);
42
+ width: 44px;
43
+ height: 44px;
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: center;
47
+ border-radius: 50%;
48
+ }
49
+
50
+ /* 上传按钮 */
51
+ .scan-upload {
52
+ position: fixed;
53
+ right: 30px;
54
+ bottom: 60px;
55
+ width: 88px;
56
+ height: 88px;
57
+ display: flex;
58
+ align-items: center;
59
+ justify-content: center;
60
+ z-index: 10000;
61
+ font-size: 48px;
62
+ color: #fff;
63
+ background-color: rgba(255, 255, 255, 0.15);
64
+ border-radius: 50%;
65
+ cursor: pointer;
66
+ }
67
+
68
+ /* 隐藏的文件输入框 */
69
+ .scan-file-input {
70
+ display: none;
71
+ }
package/es/index.d.ts CHANGED
@@ -76,6 +76,8 @@ export { default as PisellLoading } from './components/pisellLoading';
76
76
  export { default as PisellMenu } from './components/pisellMenu';
77
77
  export type { PisellMenuProps } from './components/pisellMenu/types';
78
78
  export { default as PisellModal } from './components/pisellModal';
79
+ export { default as PisellQRScanner } from './components/pisellQRScanner';
80
+ export type { PisellQRScannerProps } from './components/pisellQRScanner';
79
81
  export { default as PisellRow } from './components/pisellRow';
80
82
  export { default as PisellScan } from './components/pisellScan';
81
83
  export { default as PisellStatisticList } from './components/pisellStatisticList';
package/es/index.js CHANGED
@@ -75,6 +75,7 @@ export { default as PisellSider } from "./components/pisellLayout/sider";
75
75
  export { default as PisellLoading } from "./components/pisellLoading";
76
76
  export { default as PisellMenu } from "./components/pisellMenu";
77
77
  export { default as PisellModal } from "./components/pisellModal";
78
+ export { default as PisellQRScanner } from "./components/pisellQRScanner";
78
79
  export { default as PisellRow } from "./components/pisellRow";
79
80
  export { default as PisellScan } from "./components/pisellScan";
80
81
  export { default as PisellStatisticList } from "./components/pisellStatisticList";
@@ -210,5 +210,18 @@ declare const _default: {
210
210
  'pisell-data-source-form-app-identifier-start-with-letter': string;
211
211
  'pisell-data-source-form-app-identifier-special-ends': string;
212
212
  'pisell-data-source-form-app-identifier-consecutive-special': string;
213
+ 'pisell-group-permissions-rule-required': string;
214
+ 'pisell-group-permissions-rule-limit': string;
215
+ 'pisell-data-source-form-app-identifier-letters-only': string;
216
+ 'pisell-data-source-form-app-identifier-alphanumeric': string;
217
+ "qrscanner-loading": string;
218
+ "qrscanner-success": string;
219
+ "qrscanner-success-qrcode": string;
220
+ "qrscanner-success-barcode": string;
221
+ "qrscanner-error-upload-image": string;
222
+ "qrscanner-error-load-failed": string;
223
+ "qrscanner-error-no-code": string;
224
+ "qrscanner-error-camera-init": string;
225
+ "qrscanner-error-process-image": string;
213
226
  };
214
227
  export default _default;
@@ -1,4 +1,9 @@
1
- export default {
1
+ var _tableFilterSearch$;
2
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ export default (_tableFilterSearch$ = {
2
7
  "table-filter-search": "Search",
3
8
  "table-filter-clear": "Clear",
4
9
  "table-filter-filter": "Filter",
@@ -266,5 +271,11 @@ export default {
266
271
  'pisell-data-source-form-app-identifier-pattern': 'Can only contain lowercase letters, numbers, hyphens, dots, and underscores',
267
272
  'pisell-data-source-form-app-identifier-start-with-letter': 'Must start with a letter',
268
273
  'pisell-data-source-form-app-identifier-special-ends': 'Cannot end with a hyphen, dot, or underscore',
269
- 'pisell-data-source-form-app-identifier-consecutive-special': 'Cannot contain consecutive hyphens, dots, or underscores'
270
- };
274
+ 'pisell-data-source-form-app-identifier-consecutive-special': 'Cannot contain consecutive hyphens, dots, or underscores',
275
+ // TODO(reilly): Added new properties to `zh-CN.ts`, so adding them here to avoid errors.
276
+ // Please update these translations as needed
277
+ 'pisell-group-permissions-rule-required': 'Required',
278
+ 'pisell-group-permissions-rule-limit': 'Maximum {{num}} characters',
279
+ 'pisell-data-source-form-app-identifier-letters-only': 'Must start with a letter',
280
+ 'pisell-data-source-form-app-identifier-alphanumeric': 'Can only contain letters, numbers, hyphens, dots, and underscores'
281
+ }, _defineProperty(_tableFilterSearch$, "pisell-data-source-form-app-identifier-special-ends", 'Cannot end with a hyphen, dot, or underscore'), _defineProperty(_tableFilterSearch$, "pisell-data-source-form-app-identifier-consecutive-special", 'Cannot contain consecutive hyphens, dots, or underscores'), _defineProperty(_tableFilterSearch$, "qrscanner-loading", "Recognizing QR code..."), _defineProperty(_tableFilterSearch$, "qrscanner-success", "Successfully recognized: "), _defineProperty(_tableFilterSearch$, "qrscanner-success-qrcode", "QR code successfully recognized: "), _defineProperty(_tableFilterSearch$, "qrscanner-success-barcode", "Barcode successfully recognized: "), _defineProperty(_tableFilterSearch$, "qrscanner-error-upload-image", "Please upload an image file"), _defineProperty(_tableFilterSearch$, "qrscanner-error-load-failed", "Failed to read file"), _defineProperty(_tableFilterSearch$, "qrscanner-error-no-code", "No QR code or barcode detected."), _defineProperty(_tableFilterSearch$, "qrscanner-error-camera-init", "Cannot start camera. Please make sure it's authorized."), _defineProperty(_tableFilterSearch$, "qrscanner-error-process-image", "Error processing image"), _tableFilterSearch$);
@@ -209,5 +209,14 @@ declare const _default: {
209
209
  'pisell-data-source-form-app-identifier-start-with-letter': string;
210
210
  'pisell-data-source-form-app-identifier-special-ends': string;
211
211
  'pisell-data-source-form-app-identifier-consecutive-special': string;
212
+ "qrscanner-loading": string;
213
+ "qrscanner-success": string;
214
+ "qrscanner-success-qrcode": string;
215
+ "qrscanner-success-barcode": string;
216
+ "qrscanner-error-upload-image": string;
217
+ "qrscanner-error-load-failed": string;
218
+ "qrscanner-error-no-code": string;
219
+ "qrscanner-error-camera-init": string;
220
+ "qrscanner-error-process-image": string;
212
221
  };
213
222
  export default _default;
@@ -263,5 +263,15 @@ export default {
263
263
  'pisell-data-source-form-app-identifier-pattern': '只能包含小写字母、数字、连字符、点和下划线',
264
264
  'pisell-data-source-form-app-identifier-start-with-letter': '必须以字母开头',
265
265
  'pisell-data-source-form-app-identifier-special-ends': '不能以连字符、点或下划线结尾',
266
- 'pisell-data-source-form-app-identifier-consecutive-special': '不能包含连续的连字符、点或下划线'
266
+ 'pisell-data-source-form-app-identifier-consecutive-special': '不能包含连续的连字符、点或下划线',
267
+ // QR Scanner 相关文案
268
+ "qrscanner-loading": "正在识别二维码...",
269
+ "qrscanner-success": "识别成功: ",
270
+ "qrscanner-success-qrcode": "二维码识别成功: ",
271
+ "qrscanner-success-barcode": "条形码识别成功: ",
272
+ "qrscanner-error-upload-image": "请上传图片文件",
273
+ "qrscanner-error-load-failed": "读取文件失败",
274
+ "qrscanner-error-no-code": "未检测到二维码或条形码",
275
+ "qrscanner-error-camera-init": "无法启动摄像头,请确保已授权",
276
+ "qrscanner-error-process-image": "处理图像时出错"
267
277
  };
@@ -209,5 +209,14 @@ declare const _default: {
209
209
  'pisell-data-source-form-app-identifier-start-with-letter': string;
210
210
  'pisell-data-source-form-app-identifier-special-ends': string;
211
211
  'pisell-data-source-form-app-identifier-consecutive-special': string;
212
+ "qrscanner-loading": string;
213
+ "qrscanner-success": string;
214
+ "qrscanner-success-qrcode": string;
215
+ "qrscanner-success-barcode": string;
216
+ "qrscanner-error-upload-image": string;
217
+ "qrscanner-error-load-failed": string;
218
+ "qrscanner-error-no-code": string;
219
+ "qrscanner-error-camera-init": string;
220
+ "qrscanner-error-process-image": string;
212
221
  };
213
222
  export default _default;
@@ -265,5 +265,15 @@ export default {
265
265
  'pisell-data-source-form-app-identifier-pattern': '只能包含小寫字母、數字、連字符、點和下劃線',
266
266
  'pisell-data-source-form-app-identifier-start-with-letter': '必須以字母開頭',
267
267
  'pisell-data-source-form-app-identifier-special-ends': '不能以連字符、點或下劃線結尾',
268
- 'pisell-data-source-form-app-identifier-consecutive-special': '不能包含連續的連字符、點或下劃線'
268
+ 'pisell-data-source-form-app-identifier-consecutive-special': '不能包含連續的連字符、點或下劃線',
269
+ // QR Scanner 相關文案
270
+ "qrscanner-loading": "正在識別二維碼...",
271
+ "qrscanner-success": "識別成功: ",
272
+ "qrscanner-success-qrcode": "二維碼識別成功: ",
273
+ "qrscanner-success-barcode": "條形碼識別成功: ",
274
+ "qrscanner-error-upload-image": "請上傳圖片文件",
275
+ "qrscanner-error-load-failed": "讀取文件失敗",
276
+ "qrscanner-error-no-code": "未檢測到二維碼或條形碼",
277
+ "qrscanner-error-camera-init": "無法啟動攝像頭,請確保已授權",
278
+ "qrscanner-error-process-image": "處理圖像時出錯"
269
279
  };
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
2
  import { InputProps } from './type';
3
- import './WithMode.less';
4
3
  declare const InputWithMode: React.FC<InputProps & import("../../dataSourceForm/utils").WithModeProps>;
5
4
  export default InputWithMode;
@@ -34,13 +34,23 @@ __export(WithMode_exports, {
34
34
  module.exports = __toCommonJS(WithMode_exports);
35
35
  var import_antd = require("antd");
36
36
  var import_react = __toESM(require("react"));
37
- var import_library = require("@zxing/library");
38
37
  var import_iconfont = __toESM(require("./../../../../components/iconfont"));
39
38
  var import_ReadPretty = __toESM(require("./ReadPretty"));
40
39
  var import_utils = require("../../dataSourceForm/utils");
41
- var import_WithMode = require("./WithMode.less");
40
+ var import_pisellQRScanner = __toESM(require("../../../../components/pisellQRScanner"));
42
41
  var Input = (props) => {
43
- const { enableQRScanner, value: propValue, onChange, ...restProps } = props;
42
+ const {
43
+ enableQRScanner,
44
+ value: propValue,
45
+ onChange,
46
+ renderMode,
47
+ // 明确解构,避免通过restProps传递
48
+ innerRef,
49
+ // 明确解构
50
+ className,
51
+ // 明确解构className
52
+ ...restProps
53
+ } = props;
44
54
  const [inputValue, setInputValue] = (0, import_react.useState)(propValue || "");
45
55
  (0, import_react.useEffect)(() => {
46
56
  if (propValue !== void 0 && propValue !== inputValue) {
@@ -48,10 +58,6 @@ var Input = (props) => {
48
58
  }
49
59
  }, [propValue]);
50
60
  const [scanVisible, setScanVisible] = (0, import_react.useState)(false);
51
- const [uploading, setUploading] = (0, import_react.useState)(false);
52
- const videoRef = (0, import_react.useRef)(null);
53
- const fileInputRef = (0, import_react.useRef)(null);
54
- const codeReaderRef = (0, import_react.useRef)(null);
55
61
  const setValue = (value) => {
56
62
  console.log("设置输入框值:", value);
57
63
  setInputValue(value);
@@ -81,233 +87,11 @@ var Input = (props) => {
81
87
  const handleScanClick = () => {
82
88
  setScanVisible(true);
83
89
  };
90
+ const handleScanComplete = (value) => {
91
+ setValue(value);
92
+ };
84
93
  const handleScanClose = () => {
85
- var _a;
86
94
  setScanVisible(false);
87
- (_a = codeReaderRef.current) == null ? void 0 : _a.reset();
88
- if (videoRef.current && videoRef.current.srcObject) {
89
- const stream = videoRef.current.srcObject;
90
- const tracks = stream.getTracks();
91
- tracks.forEach((track) => {
92
- track.stop();
93
- });
94
- videoRef.current.srcObject = null;
95
- }
96
- };
97
- (0, import_react.useEffect)(() => {
98
- return () => {
99
- var _a;
100
- (_a = codeReaderRef.current) == null ? void 0 : _a.reset();
101
- };
102
- }, []);
103
- const handleUploadClick = () => {
104
- var _a;
105
- (_a = fileInputRef.current) == null ? void 0 : _a.click();
106
- };
107
- const handleFileChange = async (event) => {
108
- const files = event.target.files;
109
- if (!files || files.length === 0)
110
- return;
111
- setUploading(true);
112
- try {
113
- const file = files[0];
114
- if (!file.type.startsWith("image/")) {
115
- import_antd.message.error("请上传图片文件");
116
- setUploading(false);
117
- return;
118
- }
119
- const reader = new FileReader();
120
- reader.onload = async (e) => {
121
- if (!e.target || !e.target.result)
122
- return;
123
- try {
124
- const img = document.createElement("img");
125
- img.style.position = "absolute";
126
- img.style.top = "-9999px";
127
- img.style.left = "-9999px";
128
- const canvas = document.createElement("canvas");
129
- canvas.style.position = "absolute";
130
- canvas.style.top = "-9999px";
131
- canvas.style.left = "-9999px";
132
- document.body.appendChild(img);
133
- document.body.appendChild(canvas);
134
- await new Promise((resolve, reject) => {
135
- var _a;
136
- img.onload = resolve;
137
- img.onerror = reject;
138
- img.src = ((_a = e.target) == null ? void 0 : _a.result) || "";
139
- });
140
- try {
141
- const hints = /* @__PURE__ */ new Map();
142
- hints.set(2, true);
143
- if (!codeReaderRef.current) {
144
- codeReaderRef.current = new import_library.BrowserMultiFormatReader(hints, 500);
145
- }
146
- let result;
147
- try {
148
- result = await codeReaderRef.current.decodeFromImageElement(img);
149
- } catch (directError) {
150
- console.log("直接解码失败,尝试预处理图像...");
151
- const width = img.naturalWidth || img.width;
152
- const height = img.naturalHeight || img.height;
153
- canvas.width = width;
154
- canvas.height = height;
155
- const ctx = canvas.getContext("2d");
156
- if (!ctx)
157
- throw new Error("无法创建Canvas上下文");
158
- ctx.drawImage(img, 0, 0, width, height);
159
- const imageData = ctx.getImageData(0, 0, width, height);
160
- const data = imageData.data;
161
- for (let i = 0; i < data.length; i += 4) {
162
- data[i] = data[i] < 128 ? 0 : 255;
163
- data[i + 1] = data[i + 1] < 128 ? 0 : 255;
164
- data[i + 2] = data[i + 2] < 128 ? 0 : 255;
165
- }
166
- ctx.putImageData(imageData, 0, 0);
167
- try {
168
- const dataUrl = canvas.toDataURL("image/png");
169
- const canvasImg = document.createElement("img");
170
- document.body.appendChild(canvasImg);
171
- await new Promise((resolve, reject) => {
172
- canvasImg.onload = resolve;
173
- canvasImg.onerror = reject;
174
- canvasImg.src = dataUrl;
175
- });
176
- result = await codeReaderRef.current.decodeFromImageElement(canvasImg);
177
- document.body.removeChild(canvasImg);
178
- } catch (canvasError) {
179
- console.log("Canvas增强解码失败,尝试最后方法...");
180
- const newImg = document.createElement("img");
181
- document.body.appendChild(newImg);
182
- await new Promise((resolve, reject) => {
183
- newImg.onload = resolve;
184
- newImg.onerror = reject;
185
- newImg.src = canvas.toDataURL("image/png");
186
- });
187
- result = await codeReaderRef.current.decodeFromImageElement(newImg);
188
- document.body.removeChild(newImg);
189
- }
190
- }
191
- if (result && result.getText) {
192
- const text = result.getText();
193
- setValue(text);
194
- handleScanClose();
195
- } else {
196
- throw new Error("未能获取有效的二维码文本");
197
- }
198
- } catch (decodeError) {
199
- console.error("二维码识别失败", decodeError);
200
- import_antd.message.error("无法识别二维码,请上传清晰的二维码图片");
201
- } finally {
202
- if (document.body.contains(img)) {
203
- document.body.removeChild(img);
204
- }
205
- if (document.body.contains(canvas)) {
206
- document.body.removeChild(canvas);
207
- }
208
- }
209
- } catch (imgError) {
210
- console.error("图片加载失败", imgError);
211
- import_antd.message.error("图片加载失败");
212
- } finally {
213
- setUploading(false);
214
- if (fileInputRef.current) {
215
- fileInputRef.current.value = "";
216
- }
217
- }
218
- };
219
- reader.onerror = () => {
220
- import_antd.message.error("读取文件失败");
221
- setUploading(false);
222
- };
223
- reader.readAsDataURL(file);
224
- } catch (error) {
225
- console.error("处理图片出错", error);
226
- setUploading(false);
227
- import_antd.message.error("处理图片时出错");
228
- }
229
- };
230
- (0, import_react.useEffect)(() => {
231
- if (scanVisible && videoRef.current) {
232
- initCamera();
233
- }
234
- }, [scanVisible]);
235
- const initCamera = async () => {
236
- try {
237
- if (codeReaderRef.current) {
238
- try {
239
- codeReaderRef.current.reset();
240
- } catch (err) {
241
- console.log("重置之前的实例出错", err);
242
- }
243
- }
244
- codeReaderRef.current = new import_library.BrowserMultiFormatReader(void 0, 100);
245
- console.log("创建二维码阅读器实例成功");
246
- const constraints = {
247
- video: {
248
- facingMode: "environment"
249
- }
250
- };
251
- console.log("正在请求摄像头权限...");
252
- const stream = await navigator.mediaDevices.getUserMedia(constraints);
253
- console.log("获取摄像头流成功");
254
- if (videoRef.current) {
255
- videoRef.current.srcObject = stream;
256
- await new Promise((resolve) => {
257
- if (!videoRef.current) {
258
- resolve();
259
- return;
260
- }
261
- videoRef.current.onloadedmetadata = () => {
262
- if (!videoRef.current)
263
- return;
264
- console.log("视频元数据加载完成");
265
- videoRef.current.play().then(() => {
266
- console.log("视频开始播放成功");
267
- resolve();
268
- }).catch((err) => {
269
- console.error("视频播放失败", err);
270
- import_antd.message.error("摄像头播放失败");
271
- resolve();
272
- });
273
- };
274
- setTimeout(resolve, 3e3);
275
- });
276
- console.log("准备开始扫描...");
277
- if (codeReaderRef.current && videoRef.current) {
278
- try {
279
- codeReaderRef.current.decodeFromVideoDevice(
280
- null,
281
- videoRef.current,
282
- (result, error) => {
283
- if (result) {
284
- const text = result.getText();
285
- console.log("扫描成功:", text);
286
- try {
287
- setValue(text);
288
- setTimeout(() => handleScanClose(), 500);
289
- } catch (e) {
290
- console.error("设置值出错", e);
291
- handleScanClose();
292
- }
293
- }
294
- }
295
- );
296
- console.log("扫描器初始化完成,等待二维码...");
297
- } catch (e) {
298
- console.error("初始化扫描器失败", e);
299
- import_antd.message.error("初始化二维码扫描失败");
300
- handleScanClose();
301
- }
302
- }
303
- } else {
304
- throw new Error("视频元素不存在");
305
- }
306
- } catch (err) {
307
- console.error("摄像头初始化错误", err);
308
- import_antd.message.error("无法启动摄像头,请确保已授权");
309
- handleScanClose();
310
- }
311
95
  };
312
96
  const scanSuffix = enableQRScanner ? /* @__PURE__ */ import_react.default.createElement(
313
97
  import_iconfont.default,
@@ -318,108 +102,45 @@ var Input = (props) => {
318
102
  onClick: handleScanClick
319
103
  }
320
104
  ) : null;
321
- const fullscreenStyle = {
322
- position: "fixed",
323
- top: 0,
324
- left: 0,
325
- width: "100vw",
326
- height: "100vh",
327
- backgroundColor: "#000",
328
- zIndex: 9999,
329
- overflow: "hidden",
330
- display: "flex",
331
- justifyContent: "center",
332
- alignItems: "center"
333
- };
334
- const videoContainerStyle = {
335
- position: "relative",
336
- width: "100%",
337
- height: "100%",
338
- overflow: "hidden"
339
- };
340
- const videoStyle = {
341
- width: "100%",
342
- height: "100%",
343
- objectFit: "cover"
344
- };
345
- const closeButtonStyle = {
346
- position: "fixed",
347
- top: 20,
348
- left: 20,
349
- zIndex: 9999,
350
- fontSize: 24,
351
- color: "#fff",
352
- cursor: "pointer",
353
- backgroundColor: "rgba(255, 255, 255, 0.15)",
354
- width: 44,
355
- height: 44,
356
- display: "flex",
357
- alignItems: "center",
358
- justifyContent: "center",
359
- borderRadius: "50%"
360
- };
361
- const uploadButtonStyle = {
362
- position: "fixed",
363
- right: 30,
364
- bottom: 60,
365
- width: 88,
366
- height: 88,
367
- display: "flex",
368
- alignItems: "center",
369
- justifyContent: "center",
370
- zIndex: 9999,
371
- fontSize: 48,
372
- color: "#fff",
373
- backgroundColor: "rgba(255, 255, 255, 0.15)",
374
- borderRadius: "50%",
375
- cursor: "pointer"
376
- };
105
+ if (renderMode === "view" || renderMode === "tableView") {
106
+ return /* @__PURE__ */ import_react.default.createElement(import_ReadPretty.default, { ...props });
107
+ }
108
+ (0, import_react.useEffect)(() => {
109
+ if (enableQRScanner) {
110
+ const styleEl = document.createElement("style");
111
+ styleEl.id = "pisell-qr-scanner-style";
112
+ styleEl.innerHTML = `
113
+ .pisell-input-with-scanner .pisell-lowcode-input-group .pisell-lowcode-input-group-addon {
114
+ background-color: var(--primary-600, #7F56D9);
115
+ }
116
+ `;
117
+ document.head.appendChild(styleEl);
118
+ return () => {
119
+ const existingStyle = document.getElementById("pisell-qr-scanner-style");
120
+ if (existingStyle) {
121
+ document.head.removeChild(existingStyle);
122
+ }
123
+ };
124
+ }
125
+ }, [enableQRScanner]);
377
126
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
378
127
  import_antd.Input,
379
128
  {
380
129
  ...restProps,
381
- ref: props.innerRef || void 0,
130
+ ref: innerRef || void 0,
131
+ className: `${className || ""} ${enableQRScanner ? "pisell-input-with-scanner" : ""}`,
382
132
  addonAfter: scanSuffix,
383
133
  value: inputValue,
384
134
  onChange: handleInputChange
385
135
  }
386
- ), scanVisible && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-scan-fullscreen", style: fullscreenStyle }, /* @__PURE__ */ import_react.default.createElement("div", { style: videoContainerStyle }, /* @__PURE__ */ import_react.default.createElement(
387
- "video",
388
- {
389
- ref: videoRef,
390
- className: "scan-video",
391
- style: videoStyle,
392
- autoPlay: true,
393
- playsInline: true,
394
- muted: true
395
- }
396
- )), /* @__PURE__ */ import_react.default.createElement(
397
- import_iconfont.default,
398
- {
399
- type: "pisell2-arrow-left",
400
- className: "scan-close-left",
401
- style: closeButtonStyle,
402
- onClick: handleScanClose
403
- }
404
- ), /* @__PURE__ */ import_react.default.createElement(
405
- import_iconfont.default,
406
- {
407
- type: "pisell2-image-01",
408
- className: "scan-upload",
409
- style: uploadButtonStyle,
410
- onClick: handleUploadClick
411
- }
412
136
  ), /* @__PURE__ */ import_react.default.createElement(
413
- "input",
137
+ import_pisellQRScanner.default,
414
138
  {
415
- type: "file",
416
- ref: fileInputRef,
417
- onChange: handleFileChange,
418
- accept: "image/*",
419
- className: "scan-file-input",
420
- style: { display: "none" }
139
+ visible: scanVisible,
140
+ onClose: handleScanClose,
141
+ onScan: handleScanComplete
421
142
  }
422
- )));
143
+ ));
423
144
  };
424
145
  var InputWithMode = (0, import_utils.withMode)(Input, import_ReadPretty.default);
425
146
  var WithMode_default = InputWithMode;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import type { DetailedHTMLProps, HTMLAttributes, VideoHTMLAttributes, InputHTMLAttributes } from 'react';
4
+ declare type ExtendedDetailedHTMLProps<T extends HTMLAttributes<E>, E extends HTMLElement> = DetailedHTMLProps<T, E> & {
5
+ children?: React.ReactNode;
6
+ };
7
+ declare global {
8
+ namespace JSX {
9
+ interface IntrinsicElements {
10
+ div: ExtendedDetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
11
+ video: DetailedHTMLProps<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
12
+ input: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
13
+ }
14
+ }
15
+ }
16
+ export interface PisellQRScannerProps {
17
+ /** 是否可见 */
18
+ visible: boolean;
19
+ /** 是否显示上传图片按钮 */
20
+ showUpload?: boolean;
21
+ /** 关闭回调 */
22
+ onClose: () => void;
23
+ /** 扫码成功回调 */
24
+ onScan: (value: string) => void;
25
+ /**
26
+ * 样式属性,可选
27
+ * 注意: 不应传入renderMode等不必要属性
28
+ */
29
+ style?: React.CSSProperties;
30
+ /** 类名,可选 */
31
+ className?: string;
32
+ }
33
+ /**
34
+ * 二维码扫描组件
35
+ */
36
+ declare const PisellQRScanner: React.FC<PisellQRScannerProps>;
37
+ export default PisellQRScanner;