@digigov/ui 0.26.2 → 0.26.3

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 (42) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/app/QrCodeViewer/QRCode.stories.d.ts +8 -0
  3. package/app/QrCodeViewer/QRCode.stories.js +46 -0
  4. package/app/QrCodeViewer/__stories__/Custom.d.ts +2 -0
  5. package/app/QrCodeViewer/__stories__/Custom.js +37 -0
  6. package/app/QrCodeViewer/__stories__/Default.d.ts +2 -0
  7. package/app/QrCodeViewer/__stories__/Default.js +24 -0
  8. package/app/QrCodeViewer/index.d.ts +8 -0
  9. package/app/QrCodeViewer/index.js +248 -0
  10. package/app/QrCodeViewer/index.mdx +21 -0
  11. package/app/QrCodeViewer/qrcodegen.d.ts +100 -0
  12. package/app/QrCodeViewer/qrcodegen.js +1086 -0
  13. package/app/QrCodeViewer/types.d.ts +29 -0
  14. package/app/QrCodeViewer/types.js +5 -0
  15. package/app/QrCodeViewer/utils.d.ts +11 -0
  16. package/app/QrCodeViewer/utils.js +108 -0
  17. package/app/index.d.ts +1 -0
  18. package/app/index.js +13 -0
  19. package/es/app/QrCodeViewer/QRCode.stories.js +8 -0
  20. package/es/app/QrCodeViewer/__stories__/Custom.js +22 -0
  21. package/es/app/QrCodeViewer/__stories__/Default.js +11 -0
  22. package/es/app/QrCodeViewer/index.js +224 -0
  23. package/es/app/QrCodeViewer/index.mdx +21 -0
  24. package/es/app/QrCodeViewer/qrcodegen.js +1085 -0
  25. package/es/app/QrCodeViewer/types.js +1 -0
  26. package/es/app/QrCodeViewer/utils.js +95 -0
  27. package/es/app/index.js +1 -0
  28. package/es/registry.js +8 -0
  29. package/esm/app/QrCodeViewer/QRCode.stories.js +8 -0
  30. package/esm/app/QrCodeViewer/__stories__/Custom.js +22 -0
  31. package/esm/app/QrCodeViewer/__stories__/Default.js +11 -0
  32. package/esm/app/QrCodeViewer/index.js +224 -0
  33. package/esm/app/QrCodeViewer/index.mdx +21 -0
  34. package/esm/app/QrCodeViewer/qrcodegen.js +1085 -0
  35. package/esm/app/QrCodeViewer/types.js +1 -0
  36. package/esm/app/QrCodeViewer/utils.js +95 -0
  37. package/esm/app/index.js +1 -0
  38. package/esm/index.js +1 -1
  39. package/esm/registry.js +8 -0
  40. package/package.json +2 -2
  41. package/registry.d.ts +4 -0
  42. package/registry.js +12 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ var DEFAULT_IMG_SCALE = 0.1;
2
+ export var MARGIN_SIZE = 4;
3
+ export function generatePath(modules) {
4
+ var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
5
+ var ops = [];
6
+ modules.forEach(function (row, y) {
7
+ var start = null;
8
+ row.forEach(function (cell, x) {
9
+ if (!cell && start !== null) {
10
+ // M0 0h7v1H0z injects the space with the move and drops the comma,
11
+ // saving a char per operation
12
+ ops.push("M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z"));
13
+ start = null;
14
+ return;
15
+ } // end of row, clean up or skip
16
+
17
+
18
+ if (x === row.length - 1) {
19
+ if (!cell) {
20
+ // We would have closed the op above already so this can only mean
21
+ // 2+ light modules in a row.
22
+ return;
23
+ }
24
+
25
+ if (start === null) {
26
+ // Just a single dark module.
27
+ ops.push("M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z"));
28
+ } else {
29
+ // Otherwise finish the current line.
30
+ ops.push("M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z"));
31
+ }
32
+
33
+ return;
34
+ }
35
+
36
+ if (cell && start === null) {
37
+ start = x;
38
+ }
39
+ });
40
+ });
41
+ return ops.join('');
42
+ } // We could just do this in generatePath, except that we want to support
43
+ // non-Path2D canvas, so we need to keep it an explicit step.
44
+
45
+ export function excavateModules(modules, excavation) {
46
+ return modules.slice().map(function (row, y) {
47
+ if (y < excavation.y || y >= excavation.y + excavation.h) {
48
+ return row;
49
+ }
50
+
51
+ return row.map(function (cell, x) {
52
+ if (x < excavation.x || x >= excavation.x + excavation.w) {
53
+ return cell;
54
+ }
55
+
56
+ return false;
57
+ });
58
+ });
59
+ }
60
+ export function getImageSettings(cells, size, includeMargin, imageSettings) {
61
+ if (imageSettings == null) {
62
+ return null;
63
+ }
64
+
65
+ var margin = includeMargin ? MARGIN_SIZE : 0;
66
+ var numCells = cells.length + margin * 2;
67
+ var defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);
68
+ var scale = numCells / size;
69
+ var w = (imageSettings.width || defaultSize) * scale;
70
+ var h = (imageSettings.height || defaultSize) * scale;
71
+ var x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;
72
+ var y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;
73
+ var excavation;
74
+
75
+ if (imageSettings.excavate) {
76
+ var floorX = Math.floor(x);
77
+ var floorY = Math.floor(y);
78
+ var ceilW = Math.ceil(w + x - floorX);
79
+ var ceilH = Math.ceil(h + y - floorY);
80
+ excavation = {
81
+ x: floorX,
82
+ y: floorY,
83
+ w: ceilW,
84
+ h: ceilH
85
+ };
86
+ }
87
+
88
+ return {
89
+ x: x,
90
+ y: y,
91
+ h: h,
92
+ w: w,
93
+ excavation: excavation
94
+ };
95
+ }
package/esm/app/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from '@digigov/ui/app/App';
2
2
  export * from '@digigov/ui/app/PageTitle';
3
3
  export * from '@digigov/ui/app/QrCodeScanner';
4
+ export * from '@digigov/ui/app/QrCodeViewer';
4
5
  export * from '@digigov/ui/app/Header';
5
6
  export * from '@digigov/ui/app/i18n';
6
7
  export * from '@digigov/ui/app/I18nText';
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Digigov v0.26.2
1
+ /** @license Digigov v0.26.3
2
2
  *
3
3
  * This source code is licensed under the BSD-2-Clause license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/esm/registry.js CHANGED
@@ -48,6 +48,10 @@ import * as _digigov_ui_app_OutdatedBrowserBanner from '@digigov/ui/app/Outdated
48
48
  import * as _digigov_ui_app_PageTitle from '@digigov/ui/app/PageTitle';
49
49
  import * as _digigov_ui_app_PhaseBannerHeader from '@digigov/ui/app/PhaseBannerHeader';
50
50
  import * as _digigov_ui_app_QrCodeScanner from '@digigov/ui/app/QrCodeScanner';
51
+ import * as _digigov_ui_app_QrCodeViewer from '@digigov/ui/app/QrCodeViewer';
52
+ import * as _digigov_ui_app_QrCodeViewer_qrcodegen from '@digigov/ui/app/QrCodeViewer/qrcodegen';
53
+ import * as _digigov_ui_app_QrCodeViewer_types from '@digigov/ui/app/QrCodeViewer/types';
54
+ import * as _digigov_ui_app_QrCodeViewer_utils from '@digigov/ui/app/QrCodeViewer/utils';
51
55
  import * as _digigov_ui_core_Accordion from '@digigov/ui/core/Accordion';
52
56
  import * as _digigov_ui_core_BackLink from '@digigov/ui/core/BackLink';
53
57
  import * as _digigov_ui_core_Base from '@digigov/ui/core/Base';
@@ -216,6 +220,10 @@ export default {
216
220
  '@digigov/ui/app/PageTitle': lazyImport(_digigov_ui_app_PageTitle),
217
221
  '@digigov/ui/app/PhaseBannerHeader': lazyImport(_digigov_ui_app_PhaseBannerHeader),
218
222
  '@digigov/ui/app/QrCodeScanner': lazyImport(_digigov_ui_app_QrCodeScanner),
223
+ '@digigov/ui/app/QrCodeViewer': lazyImport(_digigov_ui_app_QrCodeViewer),
224
+ '@digigov/ui/app/QrCodeViewer/qrcodegen': lazyImport(_digigov_ui_app_QrCodeViewer_qrcodegen),
225
+ '@digigov/ui/app/QrCodeViewer/types': lazyImport(_digigov_ui_app_QrCodeViewer_types),
226
+ '@digigov/ui/app/QrCodeViewer/utils': lazyImport(_digigov_ui_app_QrCodeViewer_utils),
219
227
  '@digigov/ui/core/Accordion': lazyImport(_digigov_ui_core_Accordion),
220
228
  '@digigov/ui/core/BackLink': lazyImport(_digigov_ui_core_BackLink),
221
229
  '@digigov/ui/core/Base': lazyImport(_digigov_ui_core_Base),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digigov/ui",
3
- "version": "0.26.2",
3
+ "version": "0.26.3",
4
4
  "description": "@digigov reusable components toolkit",
5
5
  "module": "./esm/index.js",
6
6
  "publishConfig": {
@@ -18,7 +18,7 @@
18
18
  "clsx": "1.1.1",
19
19
  "react": "16.14.0",
20
20
  "react-dom": "16.14.0",
21
- "@digigov/react-core": "0.16.2",
21
+ "@digigov/react-core": "0.16.3",
22
22
  "@digigov/react-extensions": "0.18.1"
23
23
  },
24
24
  "gitHead": "c903a46306f77f55ad7fc4d2e274006f39a6c871",
package/registry.d.ts CHANGED
@@ -49,6 +49,10 @@ declare var _default: {
49
49
  '@digigov/ui/app/PageTitle': {};
50
50
  '@digigov/ui/app/PhaseBannerHeader': {};
51
51
  '@digigov/ui/app/QrCodeScanner': {};
52
+ '@digigov/ui/app/QrCodeViewer': {};
53
+ '@digigov/ui/app/QrCodeViewer/qrcodegen': {};
54
+ '@digigov/ui/app/QrCodeViewer/types': {};
55
+ '@digigov/ui/app/QrCodeViewer/utils': {};
52
56
  '@digigov/ui/core/Accordion': {};
53
57
  '@digigov/ui/core/BackLink': {};
54
58
  '@digigov/ui/core/Base': {};
package/registry.js CHANGED
@@ -107,6 +107,14 @@ var _digigov_ui_app_PhaseBannerHeader = _interopRequireWildcard(require("@digigo
107
107
 
108
108
  var _digigov_ui_app_QrCodeScanner = _interopRequireWildcard(require("@digigov/ui/app/QrCodeScanner"));
109
109
 
110
+ var _digigov_ui_app_QrCodeViewer = _interopRequireWildcard(require("@digigov/ui/app/QrCodeViewer"));
111
+
112
+ var _digigov_ui_app_QrCodeViewer_qrcodegen = _interopRequireWildcard(require("@digigov/ui/app/QrCodeViewer/qrcodegen"));
113
+
114
+ var _digigov_ui_app_QrCodeViewer_types = _interopRequireWildcard(require("@digigov/ui/app/QrCodeViewer/types"));
115
+
116
+ var _digigov_ui_app_QrCodeViewer_utils = _interopRequireWildcard(require("@digigov/ui/app/QrCodeViewer/utils"));
117
+
110
118
  var _digigov_ui_core_Accordion = _interopRequireWildcard(require("@digigov/ui/core/Accordion"));
111
119
 
112
120
  var _digigov_ui_core_BackLink = _interopRequireWildcard(require("@digigov/ui/core/BackLink"));
@@ -380,6 +388,10 @@ var _default = {
380
388
  '@digigov/ui/app/PageTitle': lazyImport(_digigov_ui_app_PageTitle),
381
389
  '@digigov/ui/app/PhaseBannerHeader': lazyImport(_digigov_ui_app_PhaseBannerHeader),
382
390
  '@digigov/ui/app/QrCodeScanner': lazyImport(_digigov_ui_app_QrCodeScanner),
391
+ '@digigov/ui/app/QrCodeViewer': lazyImport(_digigov_ui_app_QrCodeViewer),
392
+ '@digigov/ui/app/QrCodeViewer/qrcodegen': lazyImport(_digigov_ui_app_QrCodeViewer_qrcodegen),
393
+ '@digigov/ui/app/QrCodeViewer/types': lazyImport(_digigov_ui_app_QrCodeViewer_types),
394
+ '@digigov/ui/app/QrCodeViewer/utils': lazyImport(_digigov_ui_app_QrCodeViewer_utils),
383
395
  '@digigov/ui/core/Accordion': lazyImport(_digigov_ui_core_Accordion),
384
396
  '@digigov/ui/core/BackLink': lazyImport(_digigov_ui_core_BackLink),
385
397
  '@digigov/ui/core/Base': lazyImport(_digigov_ui_core_Base),