@@ -30,7 +30,7 @@ import React, {
3030useState ,
3131useContext ,
3232} from "react" ;
33- import { arrayStringExposingStateControl } from "comps/controls/codeStateControl" ;
33+ import { arrayStringExposingStateControl , stringExposingStateControl } from "comps/controls/codeStateControl" ;
3434import { BoolControl } from "comps/controls/boolControl" ;
3535import { RefControl } from "comps/controls/refControl" ;
3636import { EditorContext } from "comps/editorState" ;
@@ -120,6 +120,7 @@ const BarcodeScannerComponent = React.lazy(
120120const ScannerTmpComp = ( function ( ) {
121121const childrenMap = {
122122data :arrayStringExposingStateControl ( "data" ) ,
123+ value :stringExposingStateControl ( "value" ) ,
123124text :withDefault ( StringControl , trans ( "scanner.text" ) ) ,
124125continuous :BoolControl ,
125126uniqueData :withDefault ( BoolControl , true ) ,
@@ -150,17 +151,27 @@ const ScannerTmpComp = (function () {
150151} , [ success , showModal ] ) ;
151152
152153const continuousValue = useRef < string [ ] > ( [ ] ) ;
154+ const seenSetRef = useRef < Set < string > > ( new Set ( ) ) ;
153155
154156const handleUpdate = ( err :any , result :any ) => {
155157if ( result ) {
156158if ( props . continuous ) {
157- continuousValue . current = [ ...continuousValue . current , result . text ] ;
159+ const scannedText :string = result . text ;
160+ if ( props . uniqueData && seenSetRef . current . has ( scannedText ) ) {
161+ return ;
162+ }
163+ continuousValue . current = [ ...continuousValue . current , scannedText ] ;
164+ if ( props . uniqueData ) {
165+ seenSetRef . current . add ( scannedText ) ;
166+ }
158167const val = props . uniqueData
159168 ?[ ...new Set ( continuousValue . current ) ]
160169 :continuousValue . current ;
170+ props . value . onChange ( scannedText ) ;
161171props . data . onChange ( val ) ;
162172props . onEvent ( "success" ) ;
163173} else {
174+ props . value . onChange ( result . text ) ;
164175props . data . onChange ( [ result . text ] ) ;
165176setShowModal ( false ) ;
166177setSuccess ( true ) ;
@@ -205,6 +216,7 @@ const ScannerTmpComp = (function () {
205216props . onEvent ( "click" ) ;
206217setShowModal ( true ) ;
207218continuousValue . current = [ ] ;
219+ seenSetRef . current = new Set ( ) ;
208220} }
209221>
210222< span > { props . text } </ span >
@@ -317,6 +329,7 @@ const ScannerTmpComp = (function () {
317329
318330export const ScannerComp = withExposingConfigs ( ScannerTmpComp , [
319331new NameConfig ( "data" , trans ( "data" ) ) ,
332+ new NameConfig ( "value" , trans ( "value" ) ) ,
320333new NameConfig ( "text" , trans ( "button.textDesc" ) ) ,
321334 ...CommonNameConfig ,
322335] ) ;