@digigov/ui 1.1.1 → 1.1.2
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/CHANGELOG.md +9 -1
- package/app/QrCodeScanner/index.d.ts +1 -1
- package/app/QrCodeScanner/index.js +11 -8
- package/cjs/app/QrCodeScanner/index.js +11 -8
- package/cjs/form/AutoComplete/index.js +10 -1
- package/cjs/form/AutoComplete/utils/index.js +1 -1
- package/form/AutoComplete/index.js +10 -1
- package/form/AutoComplete/utils/index.js +1 -1
- package/index.js +1 -1
- package/package.json +4 -4
- package/src/app/QrCodeScanner/index.tsx +14 -15
- package/src/form/AutoComplete/index.tsx +13 -3
- package/src/form/AutoComplete/utils.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Change Log - @digigov/ui
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 16 Feb 2024 09:57:32 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 1.1.2
|
|
6
|
+
Fri, 16 Feb 2024 09:57:32 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Change empty array with results data add click event to arrow for all values option
|
|
11
|
+
- Improve URL parsing for QRCodeScanner when using dataType=`url`
|
|
4
12
|
|
|
5
13
|
## 1.1.1
|
|
6
14
|
Mon, 29 Jan 2024 17:45:11 GMT
|
|
@@ -5,7 +5,7 @@ export interface QrCodeScannerProps {
|
|
|
5
5
|
legacyMode?: boolean;
|
|
6
6
|
validate?: (...args: any[]) => boolean;
|
|
7
7
|
onScan: (...args: any[]) => void;
|
|
8
|
-
onError: (err: any) => void;
|
|
8
|
+
onError: (err: any, data: any) => void;
|
|
9
9
|
onLoad?: (...args: any[]) => void;
|
|
10
10
|
onImageLoad?: (...args: any[]) => void;
|
|
11
11
|
delay?: number;
|
|
@@ -38,18 +38,21 @@ export var QrCodeScanner = function QrCodeScanner(_ref) {
|
|
|
38
38
|
}
|
|
39
39
|
var handleOnScan = function handleOnScan(data) {
|
|
40
40
|
if (data) {
|
|
41
|
+
debugger;
|
|
41
42
|
if (dataType === 'url') {
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
try {
|
|
44
|
+
new URL(data);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
return onError(new Error('@digigov-ui XSS Validation failed: qr code payload should follow the pattern `https://dilosi.services.gov.gr/show/:reference_code`'), data);
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
|
-
// run a validator function provided by the application code
|
|
47
|
-
if (validate && !validate(data)) {
|
|
48
|
-
return onError(new Error('Custom QR Code payload validation failed'));
|
|
49
|
-
}
|
|
50
|
-
// proceed with application defined callback function
|
|
51
|
-
onScan(data);
|
|
52
49
|
}
|
|
50
|
+
// run a validator function provided by the application code
|
|
51
|
+
if (validate && !validate(data)) {
|
|
52
|
+
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
53
|
+
}
|
|
54
|
+
// proceed with application defined callback function
|
|
55
|
+
onScan(data);
|
|
53
56
|
};
|
|
54
57
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(QrReader, _extends({
|
|
55
58
|
delay: 100,
|
|
@@ -50,18 +50,21 @@ var QrCodeScanner = exports.QrCodeScanner = function QrCodeScanner(_ref) {
|
|
|
50
50
|
}
|
|
51
51
|
var handleOnScan = function handleOnScan(data) {
|
|
52
52
|
if (data) {
|
|
53
|
+
debugger;
|
|
53
54
|
if (dataType === 'url') {
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
try {
|
|
56
|
+
new URL(data);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
return onError(new Error('@digigov-ui XSS Validation failed: qr code payload should follow the pattern `https://dilosi.services.gov.gr/show/:reference_code`'), data);
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
|
-
// run a validator function provided by the application code
|
|
59
|
-
if (validate && !validate(data)) {
|
|
60
|
-
return onError(new Error('Custom QR Code payload validation failed'));
|
|
61
|
-
}
|
|
62
|
-
// proceed with application defined callback function
|
|
63
|
-
onScan(data);
|
|
64
61
|
}
|
|
62
|
+
// run a validator function provided by the application code
|
|
63
|
+
if (validate && !validate(data)) {
|
|
64
|
+
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
65
|
+
}
|
|
66
|
+
// proceed with application defined callback function
|
|
67
|
+
onScan(data);
|
|
65
68
|
};
|
|
66
69
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(QrReader, (0, _extends2["default"])({
|
|
67
70
|
delay: 100,
|
|
@@ -567,7 +567,16 @@ var AutoComplete = exports.AutoComplete = exports["default"] = /*#__PURE__*/func
|
|
|
567
567
|
role: "combobox",
|
|
568
568
|
required: required,
|
|
569
569
|
value: query
|
|
570
|
-
})), showAllValues && DropdownArrow && /*#__PURE__*/_react["default"].createElement(DropdownArrow, {
|
|
570
|
+
})), showNoOptionsFound || showAllValues && !menuOpen && DropdownArrow && /*#__PURE__*/_react["default"].createElement(DropdownArrow, {
|
|
571
|
+
type: "button",
|
|
572
|
+
onClick: function onClick() {
|
|
573
|
+
_this7.elementReferences[-1].focus();
|
|
574
|
+
_this7.handleInputChange({
|
|
575
|
+
target: {
|
|
576
|
+
value: query
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
},
|
|
571
580
|
className: dropdownArrowClassName
|
|
572
581
|
}), /*#__PURE__*/_react["default"].createElement(_AutoCompleteResultList["default"], {
|
|
573
582
|
displayMenu: displayMenu,
|
|
@@ -37,6 +37,6 @@ var results = exports.results = ['Αφγανιστάν', 'Ακρωτήρι', 'Α
|
|
|
37
37
|
function suggest(query, syncResults) {
|
|
38
38
|
syncResults(query ? results.filter(function (result) {
|
|
39
39
|
return result.toLowerCase().indexOf(query.toLowerCase()) !== -1;
|
|
40
|
-
}) :
|
|
40
|
+
}) : results);
|
|
41
41
|
}
|
|
42
42
|
/* end Helpers Utils __stories__ */
|
|
@@ -521,7 +521,16 @@ var AutoComplete = /*#__PURE__*/function (_Component) {
|
|
|
521
521
|
role: "combobox",
|
|
522
522
|
required: required,
|
|
523
523
|
value: query
|
|
524
|
-
})), showAllValues && DropdownArrow && /*#__PURE__*/React.createElement(DropdownArrow, {
|
|
524
|
+
})), showNoOptionsFound || showAllValues && !menuOpen && DropdownArrow && /*#__PURE__*/React.createElement(DropdownArrow, {
|
|
525
|
+
type: "button",
|
|
526
|
+
onClick: function onClick() {
|
|
527
|
+
_this7.elementReferences[-1].focus();
|
|
528
|
+
_this7.handleInputChange({
|
|
529
|
+
target: {
|
|
530
|
+
value: query
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
},
|
|
525
534
|
className: dropdownArrowClassName
|
|
526
535
|
}), /*#__PURE__*/React.createElement(AutoCompleteResultList, {
|
|
527
536
|
displayMenu: displayMenu,
|
|
@@ -28,6 +28,6 @@ export var results = ['Αφγανιστάν', 'Ακρωτήρι', 'Αλβανί
|
|
|
28
28
|
export function suggest(query, syncResults) {
|
|
29
29
|
syncResults(query ? results.filter(function (result) {
|
|
30
30
|
return result.toLowerCase().indexOf(query.toLowerCase()) !== -1;
|
|
31
|
-
}) :
|
|
31
|
+
}) : results);
|
|
32
32
|
}
|
|
33
33
|
/* end Helpers Utils __stories__ */
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "@digigov reusable components toolkit",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"react-query": "2.26.4",
|
|
11
11
|
"yup": "0.32.11",
|
|
12
12
|
"publint": "0.1.8",
|
|
13
|
-
"@digigov/react-icons": "1.1.
|
|
13
|
+
"@digigov/react-icons": "1.1.2",
|
|
14
14
|
"dompurify": "3.0.6"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"clsx": "1.1.1",
|
|
20
20
|
"react": "^16.8.0 || ^17.0.0",
|
|
21
21
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
22
|
-
"@digigov/react-core": "1.
|
|
23
|
-
"@digigov/css": "1.
|
|
22
|
+
"@digigov/react-core": "1.2.0",
|
|
23
|
+
"@digigov/css": "1.2.0"
|
|
24
24
|
},
|
|
25
25
|
"gitHead": "c903a46306f77f55ad7fc4d2e274006f39a6c871",
|
|
26
26
|
"private": false,
|
|
@@ -8,7 +8,7 @@ export interface QrCodeScannerProps {
|
|
|
8
8
|
legacyMode?: boolean;
|
|
9
9
|
validate?: (...args) => boolean;
|
|
10
10
|
onScan: (...args) => void;
|
|
11
|
-
onError: (err: any) => void;
|
|
11
|
+
onError: (err: any, data: any) => void;
|
|
12
12
|
onLoad?: (...args) => void;
|
|
13
13
|
onImageLoad?: (...args) => void;
|
|
14
14
|
delay?: number;
|
|
@@ -57,27 +57,26 @@ In order to be safe, you can:
|
|
|
57
57
|
}
|
|
58
58
|
const handleOnScan = (data) => {
|
|
59
59
|
if (data) {
|
|
60
|
+
debugger;
|
|
60
61
|
if (dataType === 'url') {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
) {
|
|
62
|
+
try {
|
|
63
|
+
new URL(data);
|
|
64
|
+
} catch (e) {
|
|
66
65
|
return onError(
|
|
67
66
|
new Error(
|
|
68
|
-
'@digigov-ui XSS Validation failed: qr code payload should follow the pattern `https://
|
|
69
|
-
)
|
|
67
|
+
'@digigov-ui XSS Validation failed: qr code payload should follow the pattern `https://dilosi.services.gov.gr/show/:reference_code`'
|
|
68
|
+
), data
|
|
70
69
|
);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
|
-
// run a validator function provided by the application code
|
|
74
|
-
if (validate && !validate(data)) {
|
|
75
|
-
return onError(new Error('Custom QR Code payload validation failed'));
|
|
76
|
-
}
|
|
77
|
-
// proceed with application defined callback function
|
|
78
|
-
onScan(data);
|
|
79
72
|
}
|
|
80
|
-
|
|
73
|
+
// run a validator function provided by the application code
|
|
74
|
+
if (validate && !validate(data)) {
|
|
75
|
+
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
76
|
+
}
|
|
77
|
+
// proceed with application defined callback function
|
|
78
|
+
onScan(data);
|
|
79
|
+
}
|
|
81
80
|
return (
|
|
82
81
|
<>
|
|
83
82
|
<QrReader
|
|
@@ -567,9 +567,19 @@ export default class AutoComplete extends Component<AutoCompleteProps, State> {
|
|
|
567
567
|
value={query}
|
|
568
568
|
/>
|
|
569
569
|
|
|
570
|
-
{
|
|
571
|
-
|
|
572
|
-
|
|
570
|
+
{showNoOptionsFound ||
|
|
571
|
+
(showAllValues && !menuOpen && DropdownArrow && (
|
|
572
|
+
<DropdownArrow
|
|
573
|
+
type="button"
|
|
574
|
+
onClick={() => {
|
|
575
|
+
this.elementReferences[-1].focus();
|
|
576
|
+
this.handleInputChange({
|
|
577
|
+
target: { value: query },
|
|
578
|
+
});
|
|
579
|
+
}}
|
|
580
|
+
className={dropdownArrowClassName}
|
|
581
|
+
/>
|
|
582
|
+
))}
|
|
573
583
|
|
|
574
584
|
<AutoCompleteResultList
|
|
575
585
|
displayMenu={displayMenu}
|
|
@@ -293,9 +293,9 @@ export function suggest(
|
|
|
293
293
|
syncResults(
|
|
294
294
|
query
|
|
295
295
|
? results.filter(function (result) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
:
|
|
296
|
+
return result.toLowerCase().indexOf(query.toLowerCase()) !== -1;
|
|
297
|
+
})
|
|
298
|
+
: results
|
|
299
299
|
);
|
|
300
300
|
}
|
|
301
301
|
/* end Helpers Utils __stories__ */
|