@g9tm/lynxcontrols-barcode 1.7.3 → 2.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.
@@ -0,0 +1,174 @@
1
+ .g9-scan-card {
2
+ border-radius: var(--g9-radius-card, 14px);
3
+ background-color: #000;
4
+ flex-direction: column;
5
+ display: flex;
6
+ position: relative;
7
+ overflow: hidden;
8
+ }
9
+
10
+ .g9-scan-card--off {
11
+ background-color: var(--g9-surface-container);
12
+ }
13
+
14
+ .g9-scan-card__picture {
15
+ position: absolute;
16
+ top: 0;
17
+ bottom: 0;
18
+ left: 0;
19
+ right: 0;
20
+ }
21
+
22
+ .g9-scan-card__sweep {
23
+ background-color: #ffffffd9;
24
+ height: 2px;
25
+ animation: 1.4s ease-in-out forwards g9-scan-sweep;
26
+ position: absolute;
27
+ top: 0;
28
+ left: 8%;
29
+ right: 8%;
30
+ }
31
+
32
+ @keyframes g9-scan-sweep {
33
+ 0% {
34
+ opacity: 0;
35
+ transform: translateY(14px);
36
+ }
37
+
38
+ 15% {
39
+ opacity: 1;
40
+ }
41
+
42
+ 85% {
43
+ opacity: 1;
44
+ }
45
+
46
+ 100% {
47
+ opacity: 0;
48
+ transform: translateY(200px);
49
+ }
50
+ }
51
+
52
+ .g9-scan-card__tint {
53
+ opacity: 0;
54
+ transition: opacity .26s ease-out;
55
+ position: absolute;
56
+ top: 0;
57
+ bottom: 0;
58
+ left: 0;
59
+ right: 0;
60
+ }
61
+
62
+ .g9-scan-card__tint--ok {
63
+ opacity: .32;
64
+ background-color: var(--g9-success, #2e7d32);
65
+ }
66
+
67
+ .g9-scan-card__tint--fail {
68
+ opacity: .32;
69
+ background-color: var(--g9-error);
70
+ }
71
+
72
+ .g9-scan-card__chip-row {
73
+ flex-direction: row;
74
+ justify-content: center;
75
+ display: flex;
76
+ position: absolute;
77
+ top: 8px;
78
+ left: 0;
79
+ right: 0;
80
+ }
81
+
82
+ .g9-scan-card__chip {
83
+ background-color: #0000008c;
84
+ border-radius: 14px;
85
+ flex-direction: column;
86
+ align-items: center;
87
+ row-gap: 1px;
88
+ max-width: 88%;
89
+ padding: 5px 12px;
90
+ display: flex;
91
+ }
92
+
93
+ .g9-scan-card__headline {
94
+ color: #fff;
95
+ text-align: center;
96
+ font-size: 13px;
97
+ font-weight: bold;
98
+ }
99
+
100
+ .g9-scan-card__detail {
101
+ color: #fff;
102
+ text-align: center;
103
+ font-size: 12px;
104
+ }
105
+
106
+ .g9-scan-card__verdict-band {
107
+ justify-content: center;
108
+ align-items: center;
109
+ display: flex;
110
+ position: absolute;
111
+ top: 56px;
112
+ bottom: 48px;
113
+ left: 0;
114
+ right: 0;
115
+ }
116
+
117
+ .g9-scan-card__verdict {
118
+ justify-content: center;
119
+ align-items: center;
120
+ animation: .9s ease-out forwards g9-scan-verdict;
121
+ display: flex;
122
+ }
123
+
124
+ .g9-scan-card__verdict--ok {
125
+ background-color: var(--g9-success, #2e7d32);
126
+ }
127
+
128
+ .g9-scan-card__verdict--fail {
129
+ background-color: var(--g9-error);
130
+ }
131
+
132
+ .g9-scan-card__verdict-glyph {
133
+ color: #fff;
134
+ font-weight: bold;
135
+ }
136
+
137
+ @keyframes g9-scan-verdict {
138
+ 0% {
139
+ opacity: 0;
140
+ transform: scale(.6);
141
+ }
142
+
143
+ 20% {
144
+ opacity: 1;
145
+ transform: scale(1);
146
+ }
147
+
148
+ 75% {
149
+ opacity: 1;
150
+ }
151
+
152
+ 100% {
153
+ opacity: 0;
154
+ }
155
+ }
156
+
157
+ .g9-scan-card__bottom {
158
+ justify-content: space-between;
159
+ align-items: flex-end;
160
+ display: flex;
161
+ position: absolute;
162
+ bottom: 8px;
163
+ left: 8px;
164
+ right: 8px;
165
+ }
166
+
167
+ .g9-scan-card__bottom-start, .g9-scan-card__bottom-end {
168
+ flex-direction: row;
169
+ align-items: center;
170
+ display: flex;
171
+ }
172
+
173
+
174
+ /*# sourceMappingURL=scan-card.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["webpack://./src/scan-card.css"],"names":[],"mappings":"AACA;EAAE,0CAA0C;EAC1C,sBAAsB;EACtB,sBAAsB;EACtB,aAAa;EACb,kBAAkB;EAClB,gBAAgB;AAClB;;AAGA;EAAE,6CAA6C;AAC/C;;AAGA;EAAE,kBAAkB;EAClB,MAAM;EACN,SAAS;EACT,OAAO;EACP,QAAQ;AACV;;AAIA;EADE,2BAA2B;EAC3B,WAAW;EACX,kDAAkD;EAClD,kBAAkB;EAClB,MAAM;EACN,QAAQ;EACR,SAAS;AACX;;AAIA;EADE;IACE,UAAU;IACV,2BAA2B;EAC7B;;EAEA;IACE,UAAU;EACZ;;EAEA;IACE,UAAU;EACZ;;EAEA;IACE,UAAU;IACV,4BAA4B;EAC9B;AACF;;AACA;EAEE,UAAU;EACV,iCAAiC;EACjC,kBAAkB;EAClB,MAAM;EACN,SAAS;EACT,OAAO;EACP,QAAQ;AACV;;AACA;EAEE,YAAY;EACZ,4CAA4C;AAC9C;;AACA;EAEE,YAAY;EACZ,iCAAiC;AACnC;;AACA;EAEE,mBAAmB;EACnB,uBAAuB;EACvB,aAAa;EACb,kBAAkB;EAClB,QAAQ;EACR,OAAO;EACP,QAAQ;AACV;;AACA;EAEE,2BAA2B;EAC3B,mBAAmB;EACnB,sBAAsB;EACtB,mBAAmB;EACnB,YAAY;EACZ,cAAc;EACd,iBAAiB;EACjB,aAAa;AACf;;AACA;EAEE,WAAW;EACX,kBAAkB;EAClB,eAAe;EACf,iBAAiB;AACnB;;AACA;EAEE,WAAW;EACX,kBAAkB;EAClB,eAAe;AACjB;;AACA;EAEE,uBAAuB;EACvB,mBAAmB;EACnB,aAAa;EACb,kBAAkB;EAClB,SAAS;EACT,YAAY;EACZ,OAAO;EACP,QAAQ;AACV;;AACA;EAEE,uBAAuB;EACvB,mBAAmB;EACnB,gDAAgD;EAChD,aAAa;AACf;;AACA;EAEE,4CAA4C;AAC9C;;AACA;EAEE,iCAAiC;AACnC;;AACA;EAEE,WAAW;EACX,iBAAiB;AACnB;;AACA;EAEE;IACE,UAAU;IACV,oBAAoB;EACtB;;EAEA;IACE,UAAU;IACV,mBAAmB;EACrB;;EAEA;IACE,UAAU;EACZ;;EAEA;IACE,UAAU;EACZ;AACF;;AAFA;EAKE,8BAA8B;EAC9B,qBAAqB;EACrB,aAAa;EACb,kBAAkB;EAClB,WAAW;EACX,SAAS;EACT,UAAU;AACZ;;AAFA;EAKE,mBAAmB;EACnB,mBAAmB;EACnB,aAAa;AACf","sourcesContent":["/* G9ScanCard: a fixed-height camera card; the picture under the chrome, every movement a CSS animation. */\n.g9-scan-card {\n position: relative;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n border-radius: var(--g9-radius-card, 14px);\n background-color: #000000;\n}\n\n.g9-scan-card--off {\n background-color: var(--g9-surface-container);\n}\n\n.g9-scan-card__picture {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n}\n\n/* One sweep of the scan line per awaited code (a new key mounts a new line). */\n.g9-scan-card__sweep {\n position: absolute;\n left: 8%;\n right: 8%;\n top: 0;\n height: 2px;\n background-color: rgba(255, 255, 255, 0.85);\n animation: g9-scan-sweep 1.4s ease-in-out 1 forwards;\n}\n\n@keyframes g9-scan-sweep {\n 0% {\n transform: translateY(14px);\n opacity: 0;\n }\n 15% {\n opacity: 1;\n }\n 85% {\n opacity: 1;\n }\n 100% {\n transform: translateY(200px);\n opacity: 0;\n }\n}\n\n.g9-scan-card__tint {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n opacity: 0;\n transition: opacity 260ms ease-out;\n}\n\n.g9-scan-card__tint--ok {\n opacity: 0.32;\n background-color: var(--g9-success, #2e7d32);\n}\n\n.g9-scan-card__tint--fail {\n opacity: 0.32;\n background-color: var(--g9-error);\n}\n\n.g9-scan-card__chip-row {\n position: absolute;\n left: 0;\n right: 0;\n top: 8px;\n display: flex;\n flex-direction: row;\n justify-content: center;\n}\n\n.g9-scan-card__chip {\n max-width: 88%;\n display: flex;\n flex-direction: column;\n align-items: center;\n row-gap: 1px;\n padding: 5px 12px;\n border-radius: 14px;\n background-color: rgba(0, 0, 0, 0.55);\n}\n\n.g9-scan-card__headline {\n font-size: 13px;\n font-weight: bold;\n color: #ffffff;\n text-align: center;\n}\n\n.g9-scan-card__detail {\n font-size: 12px;\n color: #ffffff;\n text-align: center;\n}\n\n.g9-scan-card__verdict-band {\n position: absolute;\n left: 0;\n right: 0;\n top: 56px;\n bottom: 48px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.g9-scan-card__verdict {\n display: flex;\n align-items: center;\n justify-content: center;\n animation: g9-scan-verdict 900ms ease-out 1 forwards;\n}\n\n.g9-scan-card__verdict--ok {\n background-color: var(--g9-success, #2e7d32);\n}\n\n.g9-scan-card__verdict--fail {\n background-color: var(--g9-error);\n}\n\n.g9-scan-card__verdict-glyph {\n color: #ffffff;\n font-weight: bold;\n}\n\n@keyframes g9-scan-verdict {\n 0% {\n transform: scale(0.6);\n opacity: 0;\n }\n 20% {\n transform: scale(1);\n opacity: 1;\n }\n 75% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n}\n\n.g9-scan-card__bottom {\n position: absolute;\n left: 8px;\n right: 8px;\n bottom: 8px;\n display: flex;\n align-items: flex-end;\n justify-content: space-between;\n}\n\n.g9-scan-card__bottom-start,\n.g9-scan-card__bottom-end {\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n"],"sourceRoot":""}
@@ -0,0 +1,55 @@
1
+ import './scan-card.css';
2
+ import { type G9StyleProp } from '@g9tm/lynxcontrols/base';
3
+ import { type ReactNode } from '@lynx-js/react';
4
+ /** The answer a scan card shows over its picture for a moment: ✓ accepted, ✕ refused. */
5
+ export type G9ScanVerdict = 'accepted' | 'refused';
6
+ /** Props of {@link G9ScanCard}. */
7
+ export interface G9ScanCardProps {
8
+ readonly id?: string;
9
+ /** The card's height in dp — FIXED by the caller when the page is built (a keyboard opening must not shrink it). */
10
+ readonly height: number;
11
+ /** The camera element (the app's scanner view) — drawn under everything at `pictureOpacity`. Absent: a neutral panel. */
12
+ readonly camera?: ReactNode;
13
+ /** The picture's opacity (on the picture only, never a parent layer). Default 0.79. */
14
+ readonly pictureOpacity?: number;
15
+ /** The status chip: a headline, an optional detail (up to `detailLines`), its colour (null = a translucent dark chip). */
16
+ readonly headline: string;
17
+ readonly detail?: string | null;
18
+ readonly tone?: string | null;
19
+ /** Default 3 (a refusal's reason must not be cut at two). */
20
+ readonly detailLines?: number;
21
+ /** The last answer and its key: a new key flashes the verdict (and replays nothing else). */
22
+ readonly verdict?: G9ScanVerdict | null;
23
+ readonly verdictKey?: string | number;
24
+ /** How long the verdict stays, ms. Default 900. */
25
+ readonly verdictMs?: number;
26
+ /** Sweeps the scan line once each time this changes (a new code is awaited). */
27
+ readonly sweepKey?: string | number;
28
+ /** The bottom row: the start side (a «manual entry» button) and the end side (the tag's id). */
29
+ readonly bottomStart?: ReactNode;
30
+ readonly bottomEnd?: ReactNode;
31
+ /** More overlay (a «try again» button). */
32
+ readonly children?: ReactNode;
33
+ readonly direction?: 'ltr' | 'rtl';
34
+ readonly className?: string;
35
+ readonly style?: G9StyleProp;
36
+ }
37
+ /** The status chip's band from the top, in dp (the verdict sits between it and the bottom band). */
38
+ export declare const g9ScanCardChipBand = 56;
39
+ /** The bottom row's band (manual entry, torch) from the bottom, in dp. */
40
+ export declare const g9ScanCardBottomBand = 48;
41
+ /**
42
+ * Where the verdict badge fits: the band between the status chip and the bottom row. A full badge (64 dp) when the band
43
+ * holds it, a smaller one (≥ 36 dp) when it is short, none at all below that (it lay under the chip's text on a short
44
+ * barcode card — MAUI 6.2.52).
45
+ */
46
+ export declare function g9ScanVerdictSize(height: number): number;
47
+ /**
48
+ * A camera card for a walk that scans one code after another (MAUI 6.2.52 TagScanCameraCard): a card of a FIXED height,
49
+ * pinned where the page puts it (the top), the camera's picture dimmed under its chrome, a status chip at the top, a bottom
50
+ * row for a «manual entry» button and the code being worked on, a scan line that sweeps once per awaited code, and a green
51
+ * ✓ / red ✕ for each answer — the phone buzzes too: the caller plays its haptic with the answer. Everything that moves is a
52
+ * CSS animation or transition; nothing runs per frame.
53
+ */
54
+ export declare const G9ScanCard: import("react").NamedExoticComponent<G9ScanCardProps>;
55
+ //# sourceMappingURL=scan-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan-card.d.ts","sourceRoot":"","sources":["../src/scan-card.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAQ,KAAK,SAAS,EAA+B,MAAM,gBAAgB,CAAC;AAEnF,yFAAyF;AACzF,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,SAAS,CAAC;AAEnD,mCAAmC;AACnC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,oHAAoH;IACpH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yHAAyH;IACzH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC5B,uFAAuF;IACvF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,0HAA0H;IAC1H,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,6DAA6D;IAC7D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,6FAA6F;IAC7F,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,mDAAmD;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,gGAAgG;IAChG,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,oGAAoG;AACpG,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,uDAkErB,CAAC"}
@@ -0,0 +1,78 @@
1
+ import "./scan-card.css";
2
+ import { g9IdProps, mergeStyle } from "@g9tm/lynxcontrols/base";
3
+ import { memo, useEffect, useRef, useState } from "@lynx-js/react";
4
+ const g9ScanCardChipBand = 56;
5
+ const g9ScanCardBottomBand = 48;
6
+ function g9ScanVerdictSize(height) {
7
+ const band = height - g9ScanCardChipBand - g9ScanCardBottomBand;
8
+ if (band >= 72) return 64;
9
+ if (band >= 40) return Math.max(36, Math.floor(band - 8));
10
+ return 0;
11
+ }
12
+ const G9ScanCard = memo(function(props) {
13
+ var _props_verdictMs, _props_pictureOpacity, _props_detailLines;
14
+ const [shown, setShown] = useState(null);
15
+ const timer = useRef(null);
16
+ const verdictMs = null != (_props_verdictMs = props.verdictMs) ? _props_verdictMs : 900;
17
+ useEffect(()=>{
18
+ if (!props.verdict || void 0 === props.verdictKey) return;
19
+ setShown({
20
+ verdict: props.verdict,
21
+ key: props.verdictKey
22
+ });
23
+ if (timer.current) clearTimeout(timer.current);
24
+ timer.current = setTimeout(()=>setShown(null), verdictMs);
25
+ }, [
26
+ props.verdictKey
27
+ ]);
28
+ useEffect(()=>()=>{
29
+ if (timer.current) clearTimeout(timer.current);
30
+ }, []);
31
+ const size = g9ScanVerdictSize(props.height);
32
+ const rtl = 'rtl' === props.direction;
33
+ const tint = shown ? 'accepted' === shown.verdict ? 'g9-scan-card__tint--ok' : 'g9-scan-card__tint--fail' : '';
34
+ return <view {...g9IdProps(props.id)} className={`g9-scan-card${props.camera ? '' : ' g9-scan-card--off'}${props.className ? ` ${props.className}` : ''}`} style={mergeStyle({
35
+ height: `${props.height}px`
36
+ }, props.style)}>
37
+ {props.camera ? <view className="g9-scan-card__picture" style={{
38
+ opacity: String(null != (_props_pictureOpacity = props.pictureOpacity) ? _props_pictureOpacity : 0.79)
39
+ }}>
40
+ {props.camera}
41
+ </view> : null}
42
+ {props.camera && void 0 !== props.sweepKey ? <view key={`sweep-${String(props.sweepKey)}`} className="g9-scan-card__sweep"/> : null}
43
+ <view className={`g9-scan-card__tint ${tint}`}/>
44
+ <view className="g9-scan-card__chip-row">
45
+ <view className="g9-scan-card__chip" style={props.tone ? {
46
+ backgroundColor: props.tone
47
+ } : {}}>
48
+ <text className="g9-scan-card__headline" text-maxline="1">
49
+ {props.headline}
50
+ </text>
51
+ {props.detail ? <text className="g9-scan-card__detail" text-maxline={String(null != (_props_detailLines = props.detailLines) ? _props_detailLines : 3)}>
52
+ {props.detail}
53
+ </text> : null}
54
+ </view>
55
+ </view>
56
+ {shown && size > 0 ? <view className="g9-scan-card__verdict-band">
57
+ <view key={String(shown.key)} className={`g9-scan-card__verdict ${'accepted' === shown.verdict ? 'g9-scan-card__verdict--ok' : 'g9-scan-card__verdict--fail'}`} style={{
58
+ width: `${size}px`,
59
+ height: `${size}px`,
60
+ borderRadius: `${size / 2}px`
61
+ }}>
62
+ <text className="g9-scan-card__verdict-glyph" style={{
63
+ fontSize: `${Math.round(0.55 * size)}px`
64
+ }}>
65
+ {'accepted' === shown.verdict ? '✓' : '✕'}
66
+ </text>
67
+ </view>
68
+ </view> : null}
69
+ {props.children}
70
+ <view className="g9-scan-card__bottom" style={{
71
+ flexDirection: rtl ? 'row-reverse' : 'row'
72
+ }}>
73
+ <view className="g9-scan-card__bottom-start">{props.bottomStart}</view>
74
+ <view className="g9-scan-card__bottom-end">{props.bottomEnd}</view>
75
+ </view>
76
+ </view>;
77
+ });
78
+ export { G9ScanCard, g9ScanCardBottomBand, g9ScanCardChipBand, g9ScanVerdictSize };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@g9tm/lynxcontrols-barcode",
3
- "version": "1.7.3",
4
- "description": "G9BarcodeTextEntry: a scanner-aware text field. The scanner is consumer-provided (no camera dependency).",
3
+ "version": "2.1.0",
4
+ "description": "G9BarcodeTextEntry: a scanner-aware text field. The scanner is consumer-provided (no camera dependency); QR codes (/qr: offline encoder, SVG and view renderers).",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": [
@@ -12,6 +12,11 @@
12
12
  "source": "./src/index.ts",
13
13
  "types": "./dist/index.d.ts",
14
14
  "default": "./dist/index.jsx"
15
+ },
16
+ "./qr": {
17
+ "source": "./src/qr/index.ts",
18
+ "types": "./dist/qr/index.d.ts",
19
+ "default": "./dist/qr/index.jsx"
15
20
  }
16
21
  },
17
22
  "files": [
@@ -22,10 +27,10 @@
22
27
  "build": "rslib build"
23
28
  },
24
29
  "dependencies": {
25
- "@g9tm/lynxcontrols-foundation": "1.7.3",
26
- "@g9tm/lynxcontrols": "1.7.3"
30
+ "@g9tm/lynxcontrols-foundation": "2.1.0",
31
+ "@g9tm/lynxcontrols": "2.1.0"
27
32
  },
28
33
  "peerDependencies": {
29
- "@lynx-js/react": ">=0.129.1 <0.130.0"
34
+ "@lynx-js/react": ">=0.129.3 <0.130.0"
30
35
  }
31
36
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"barcode-text-entry.jsx","sources":["../src/barcode-text-entry.tsx"],"sourcesContent":["import { useControllableState } from '@g9tm/lynxcontrols/base';\nimport {\n G9TextEntry,\n type G9TextEntryHandle,\n type G9TextEntryProps,\n type G9ValueChangeSource,\n} from '@g9tm/lynxcontrols/fields';\nimport { useG9Diagnostics, useG9OptionalService, useG9Strings } from '@g9tm/lynxcontrols/provider';\nimport {\n createAbortController,\n type G9AbortController,\n G9StringKey,\n G9TextInputDirection,\n} from '@g9tm/lynxcontrols-foundation';\nimport { forwardRef, type ReactNode, useEffect, useImperativeHandle, useRef, useState } from '@lynx-js/react';\nimport {\n appendScannedCode,\n barcodeFieldState,\n type G9BarcodeAcceptor,\n type G9BarcodeScanMode,\n type G9BarcodeTextEntryState,\n isBarcodeAccepted,\n} from './model';\n\n/** Where a barcode field's value change came from: the text-entry sources plus an accepted `'scan'`. */\nexport type G9BarcodeValueSource = G9ValueChangeSource | 'scan';\n\n/** Props of {@link G9BarcodeTextEntry}: every `G9TextEntry` prop plus the scan workflow. */\nexport interface G9BarcodeTextEntryProps\n extends Omit<G9TextEntryProps, 'onTrailingPress' | 'isTrailingBusy' | 'onValueChange'> {\n /** One call per change; `source: 'scan'` for an accepted scanned code. */\n readonly onValueChange?: (value: string, details: { readonly source: G9BarcodeValueSource }) => void;\n /**\n * Codes must match before they are accepted (MAUI `AcceptedCodeRegex`): a pattern string, a `RegExp`, or a function.\n * Unset accepts any code. A malformed pattern or a throwing function rejects the code.\n */\n readonly acceptedCodeRegex?: G9BarcodeAcceptor;\n /** `'single'` (default) replaces the text; `'multiple'` appends `\", code\"` and keeps scanning. */\n readonly scanMode?: G9BarcodeScanMode;\n /** Allow typing as well as scanning (MAUI `IsEditable`). Default false. */\n readonly isEditable?: boolean;\n /** Placeholder while scanning (MAUI `ScanBusyText`). Default: the `Scanning` string. */\n readonly scanBusyText?: string | null;\n /** Controlled scan state (MAUI `ScanState`). */\n readonly scanState?: G9BarcodeTextEntryState;\n readonly defaultScanState?: G9BarcodeTextEntryState;\n readonly onScanStateChange?: (state: G9BarcodeTextEntryState) => void;\n /**\n * The scan icon was tapped (MAUI `ScanRequested`): you own the camera; call `startScan()`, then\n * `acceptScannedCode(code)` and `stopScan()` on the handle. Without it, the field scans through `services.scanner`.\n */\n readonly onScanRequested?: () => void;\n /** A code passed the acceptor (MAUI `Accepted`); never fired for typed text. */\n readonly onAccepted?: (code: string) => void;\n /** Symbologies passed to `services.scanner.scan` (e.g. `['qr', 'code128']`). */\n readonly scanFormats?: readonly string[];\n}\n\n/** Imperative handle: the text-entry handle plus MAUI `StartScan` / `StopScan` / `AcceptScannedCode`. */\nexport interface G9BarcodeTextEntryHandle extends G9TextEntryHandle {\n /** Enters `scanBusy` (MAUI `StartScan`). */\n startScan(): void;\n /** Back to `idle` from `scanBusy`; a scan through `services.scanner` is aborted and its late result ignored. */\n stopScan(): void;\n /** Validates and applies a code; `true` when accepted (MAUI `AcceptScannedCode`). */\n acceptScannedCode(code: string): boolean;\n /** Runs the built-in scan through `services.scanner` (what a tap does without `onScanRequested`). */\n scan(): Promise<void>;\n}\n\n/**\n * A scanner-aware text field (MAUI `G9BarcodeTextEntry`) on `G9TextEntry`: a trailing scan affordance (pinned right,\n * text pinned LTR), idle → spinner → ✓ / ⓘ states layered over your own field values, an acceptor for scanned codes,\n * and single or multiple (comma-joined) collection. The camera is never this package's: either handle\n * `onScanRequested`, or supply `services.scanner` and the field drives it (aborting on `stopScan` and on unmount).\n */\nexport const G9BarcodeTextEntry = forwardRef<G9BarcodeTextEntryHandle, G9BarcodeTextEntryProps>(\n function G9BarcodeTextEntry(props, ref): ReactNode {\n const strings = useG9Strings();\n const diagnostics = useG9Diagnostics();\n const scanner = useG9OptionalService('scanner');\n const [text, setText] = useControllableState<string, [details: { readonly source: G9BarcodeValueSource }]>({\n value: props.value,\n defaultValue: props.defaultValue ?? '',\n onChange: props.onValueChange,\n name: 'G9BarcodeTextEntry.value',\n });\n const [state, setState] = useControllableState<G9BarcodeTextEntryState>({\n value: props.scanState,\n defaultValue: props.defaultScanState ?? 'idle',\n onChange: props.onScanStateChange,\n name: 'G9BarcodeTextEntry.scanState',\n });\n const latest = useRef({ text, state, props });\n latest.current = { text, state, props };\n const entry = useRef<G9TextEntryHandle | null>(null);\n\n // Whether the built-in scanner can run (asked once; no permission prompt).\n const [scannerAvailable, setScannerAvailable] = useState(false);\n useEffect(() => {\n if (!scanner) return;\n let live = true;\n scanner.isAvailable().then(\n (available) => {\n if (live) setScannerAvailable(available === true);\n },\n () => undefined,\n );\n return () => {\n live = false;\n };\n }, [scanner]);\n\n const run = useRef<{ generation: number; controller: G9AbortController | null }>({\n generation: 0,\n controller: null,\n });\n const abortRun = () => {\n run.current.generation += 1;\n run.current.controller?.abort();\n run.current.controller = null;\n };\n useEffect(() => abortRun, []);\n\n const setScanState = (next: G9BarcodeTextEntryState) => {\n latest.current = { ...latest.current, state: next };\n setState(next);\n };\n const startScan = () => setScanState('scanBusy');\n const stopScan = () => {\n abortRun();\n if (latest.current.state === 'scanBusy') setScanState('idle');\n };\n const acceptScannedCode = (code: string): boolean => {\n if (!isBarcodeAccepted(code, latest.current.props.acceptedCodeRegex)) {\n setScanState('error');\n return false;\n }\n const next = appendScannedCode(latest.current.text, code, latest.current.props.scanMode ?? 'single');\n latest.current = { ...latest.current, text: next };\n setText(next, { source: 'scan' });\n setScanState('accepted');\n latest.current.props.onAccepted?.(code);\n return true;\n };\n\n const scan = async (): Promise<void> => {\n if (!scanner) return;\n abortRun();\n const generation = run.current.generation;\n const controller = createAbortController();\n run.current.controller = controller;\n startScan();\n try {\n for (;;) {\n const formats = latest.current.props.scanFormats;\n const result = await scanner.scan({ signal: controller.signal, ...(formats ? { formats } : {}) });\n if (generation !== run.current.generation) return;\n if (result.status === 'cancelled') {\n stopScan();\n return;\n }\n if (result.status === 'denied') {\n run.current.controller = null;\n setScanState('error');\n return;\n }\n const accepted = acceptScannedCode(result.text);\n if (!accepted || (latest.current.props.scanMode ?? 'single') === 'single') {\n run.current.controller = null;\n return;\n }\n // Multiple: stay armed for the next code.\n setScanState('scanBusy');\n }\n } catch (error) {\n if (generation !== run.current.generation) return;\n run.current.controller = null;\n setScanState('error');\n diagnostics.log({\n level: 'error',\n message: 'G9BarcodeTextEntry: scan failed.',\n source: 'G9BarcodeTextEntry',\n error,\n });\n }\n };\n\n useImperativeHandle(ref, () => {\n // The inner entry is mounted whenever this handle is reachable.\n const inner = () => entry.current as G9TextEntryHandle;\n return {\n focus: () => inner().focus(),\n blur: () => inner().blur(),\n validate: () => inner().validate(),\n get isListening() {\n return inner().isListening;\n },\n toggleVoice: () => inner().toggleVoice(),\n startVoice: () => inner().startVoice(),\n stopVoice: () => inner().stopVoice(),\n get element() {\n return inner().element;\n },\n startScan,\n stopScan,\n acceptScannedCode,\n scan,\n };\n });\n\n const field = barcodeFieldState(\n state,\n {\n hasError: props.hasError,\n readOnly: props.readOnly,\n useStatusColor: props.useStatusColor,\n statusColor: props.statusColor,\n placeholder: props.placeholder,\n isEditable: props.isEditable,\n },\n props.scanBusyText ?? strings.get(G9StringKey.Scanning),\n );\n const actionable = state === 'idle' && (props.onScanRequested !== undefined || scannerAvailable);\n const trailingIcon =\n field.trailing === 'accepted'\n ? 'check'\n : field.trailing === 'error'\n ? 'info'\n : (props.trailingIcon ?? 'scanCode');\n const {\n acceptedCodeRegex: _acceptor,\n scanMode: _mode,\n isEditable: _editable,\n scanBusyText: _busyText,\n scanState: _state,\n defaultScanState: _defaultState,\n onScanStateChange: _onState,\n onScanRequested: _onRequested,\n onAccepted: _onAccepted,\n scanFormats: _formats,\n ...entryProps\n } = props;\n return (\n <G9TextEntry\n {...entryProps}\n ref={entry}\n className={`g9-barcode g9-barcode--${state} ${props.className ?? ''}`}\n value={text}\n onValueChange={(value, details) => {\n setText(value, details);\n // Typing after a scan result returns the field to idle (MAUI: until the user types or scans again).\n if (latest.current.state === 'accepted' || latest.current.state === 'error') setScanState('idle');\n }}\n hasError={field.hasError}\n readOnly={field.readOnly}\n useStatusColor={field.useStatusColor}\n statusColor={field.statusColor}\n placeholder={field.placeholder}\n isTrailingBusy={field.isTrailingBusy}\n trailingIcon={trailingIcon}\n forceTrailingIconRight\n inputTextDirection={props.inputTextDirection ?? G9TextInputDirection.LeftToRight}\n {...(actionable\n ? {\n onTrailingPress: () => {\n if (latest.current.props.onScanRequested) latest.current.props.onScanRequested();\n else void scan();\n },\n }\n : {})}\n />\n );\n },\n);\n"],"names":["G9BarcodeTextEntry","forwardRef","props","ref","_props_defaultValue","_props_defaultScanState","_props_scanBusyText","_props_trailingIcon","_props_className","_props_inputTextDirection","strings","useG9Strings","diagnostics","useG9Diagnostics","scanner","useG9OptionalService","text","setText","useControllableState","state","setState","latest","useRef","entry","scannerAvailable","setScannerAvailable","useState","useEffect","live","available","undefined","run","abortRun","_run_current_controller","setScanState","next","startScan","stopScan","acceptScannedCode","code","_latest_current_props_scanMode","_latest_current_props","isBarcodeAccepted","appendScannedCode","scan","generation","controller","createAbortController","formats","result","accepted","error","useImperativeHandle","inner","field","barcodeFieldState","G9StringKey","actionable","trailingIcon","_acceptor","_mode","_editable","_busyText","_state","_defaultState","_onState","_onRequested","_onAccepted","_formats","entryProps","G9TextEntry","value","details","G9TextInputDirection"],"mappings":";;;;;;AA4EO,MAAMA,wCAAqBC,WAChC,SAA4BC,KAAK,EAAEC,GAAG;QAMpBC,qBAMAC,yBAoIdC,qBAQOC,qBAkByCC,kBAe1BC;IAxLxB,MAAMC,UAAUC;IAChB,MAAMC,cAAcC;IACpB,MAAMC,UAAUC,qBAAqB;IACrC,MAAM,CAACC,MAAMC,QAAQ,GAAGC,qBAAmF;QACzG,OAAOhB,MAAM,KAAK;QAClB,cAAc,QAAAE,CAAAA,sBAAAA,MAAM,YAAY,AAAD,IAAjBA,sBAAsB;QACpC,UAAUF,MAAM,aAAa;QAC7B,MAAM;IACR;IACA,MAAM,CAACiB,OAAOC,SAAS,GAAGF,qBAA8C;QACtE,OAAOhB,MA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,EAC5B,UAAUC,KAAK,EACf,YAAYC,SAAS,EACrB,cAAcC,SAAS,EACvB,WAAWC,MAAM,EACjB,kBAAkBC,aAAa,EAC/B,mBAAmBC,QAAQ,EAC3B,iBAAiBC,YAAY,EAC7B,YAAYC,WAAW,EACvB,aAAaC,QAAQ,EACrB,GAAGC,YACJ,GAAGnE;IACJ,QACGoE,aACE,GAAGD,UAAU,EACd,KAAK9C,OACL,WAAW,CAAC,uBAAuB,EAAEJ,MAAM,CAAC,EAAE,QAAAX,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,mBAAmB,IAAI,EACrE,OAAOQ,MACP,eAAe,CAACuD,OAAOC;QACrBvD,QAAQsD,OAAOC;QAEf,IAAInD,AAAyB,eAAzBA,OAAO,OAAO,CAAC,KAAK,IAAmBA,AAAyB,YAAzBA,OAAO,OAAO,CAAC,KAAK,EAAca,aAAa;IAC5F,GACA,UAAUoB,MAAM,QAAQ,EACxB,UAAUA,MAAM,QAAQ,EACxB,gBAAgBA,MAAM,cAAc,EACpC,aAAaA,MAAM,WAAW,EAC9B,aAAaA,MAAM,WAAW,EAC9B,gBAAgBA,MAAM,cAAc,EACpC,cAAcI,cACd,uBACA,oBAAoB,QAAAjD,CAAAA,4BAAAA,MAAM,kBAAkB,AAAD,IAAvBA,4BAA4BgE,qBAAqB,WAAW,GAC/E,GAAIhB,aACD;QACE,iBAAiB;YACf,IAAIpC,OAAO,OAAO,CAAC,KAAK,CAAC,eAAe,EAAEA,OAAO,OAAO,CAAC,KAAK,CAAC,eAAe;iBACpEuB;QACZ;IACF,IACA,CAAC,CAAC;AAGZ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.jsx","sources":["../src/model.ts"],"sourcesContent":["/** Whether the field keeps one code or collects many (MAUI `G9BarcodeScanMode`). */\nexport type G9BarcodeScanMode = 'single' | 'multiple';\n\n/** The scan state, tracked apart from the field's own error (MAUI `G9BarcodeTextEntryState`). */\nexport type G9BarcodeTextEntryState = 'idle' | 'scanBusy' | 'accepted' | 'error';\n\n/** Codes longer than this are rejected before any pattern runs, so a consumer pattern never sees unbounded input. */\nexport const g9BarcodeMaxCodeLength = 4096;\n\n/** A code acceptor: a pattern (string or `RegExp`), or a function the app supplies. */\nexport type G9BarcodeAcceptor = string | RegExp | ((code: string) => boolean) | null | undefined;\n\n/**\n * Whether a scanned code is accepted (MAUI `IsCodeAccepted`): no acceptor accepts any code; a malformed pattern or a\n * throwing function rejects it instead of throwing into the scan flow. A code over {@link g9BarcodeMaxCodeLength}\n * characters is rejected (MAUI bounded the match with a 250 ms regex timeout, which JavaScript cannot do).\n */\nexport function isBarcodeAccepted(code: string, acceptor: G9BarcodeAcceptor): boolean {\n if (code.length > g9BarcodeMaxCodeLength) return false;\n if (acceptor == null || (typeof acceptor === 'string' && acceptor.trim() === '')) return true;\n try {\n if (typeof acceptor === 'function') return acceptor(code) === true;\n const pattern =\n typeof acceptor === 'string'\n ? new RegExp(acceptor)\n : new RegExp(acceptor.source, acceptor.flags.replace('g', ''));\n return pattern.test(code);\n } catch {\n return false;\n }\n}\n\n/** The text after accepting `code` (MAUI: `Single` replaces, `Multiple` appends with `\", \"`). */\nexport function appendScannedCode(text: string, code: string, mode: G9BarcodeScanMode): string {\n return mode === 'multiple' && text.trim() !== '' ? `${text}, ${code}` : code;\n}\n\n/** What the consumer set on the borrowed field properties. */\nexport interface G9BarcodeConsumerField {\n readonly hasError?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly useStatusColor?: boolean | undefined;\n readonly statusColor?: string | null | undefined;\n readonly placeholder?: string | null | undefined;\n readonly isEditable?: boolean | undefined;\n}\n\n/** The field properties a scan state layers over the consumer's values (MAUI `ApplyBarcodeState`). */\nexport interface G9BarcodeFieldState {\n readonly hasError: boolean;\n readonly readOnly: boolean;\n readonly useStatusColor: boolean;\n readonly statusColor: string | null;\n readonly placeholder: string | null;\n readonly isTrailingBusy: boolean;\n /** The trailing glyph: `'scan'` (consumer icon or the scan glyph), `'accepted'` or `'error'`. */\n readonly trailing: 'scan' | 'accepted' | 'error';\n}\n\n/**\n * Effective field values for a scan state (the MAUI table): error forces `hasError`; not editable or busy forces\n * read-only; busy / accepted force the status colour (primary / success); busy swaps the placeholder for\n * `scanBusyText` and shows a spinner; accepted / error swap the trailing glyph. Everything else is the consumer's.\n */\nexport function barcodeFieldState(\n state: G9BarcodeTextEntryState,\n consumer: G9BarcodeConsumerField,\n scanBusyText: string,\n): G9BarcodeFieldState {\n const busy = state === 'scanBusy';\n const accepted = state === 'accepted';\n return {\n hasError: state === 'error' || consumer.hasError === true,\n readOnly: consumer.isEditable !== true || busy || consumer.readOnly === true,\n useStatusColor: busy || accepted || consumer.useStatusColor === true,\n statusColor: accepted ? 'var(--g9-success)' : busy ? 'var(--g9-primary)' : (consumer.statusColor ?? null),\n placeholder: busy ? scanBusyText : (consumer.placeholder ?? null),\n isTrailingBusy: busy,\n trailing: accepted ? 'accepted' : state === 'error' ? 'error' : 'scan',\n };\n}\n"],"names":["g9BarcodeMaxCodeLength","isBarcodeAccepted","code","acceptor","pattern","RegExp","appendScannedCode","text","mode","barcodeFieldState","state","consumer","scanBusyText","_consumer_statusColor","_consumer_placeholder","busy","accepted"],"mappings":"AAOO,MAAMA,yBAAyB;AAU/B,SAASC,kBAAkBC,IAAY,EAAEC,QAA2B;IACzE,IAAID,KAAK,MAAM,GAAGF,wBAAwB,OAAO;IACjD,IAAIG,AAAY,QAAZA,YAAqB,AAAoB,YAApB,OAAOA,YAAyBA,AAAoB,OAApBA,SAAS,IAAI,IAAY,OAAO;IACzF,IAAI;QACF,IAAI,AAAoB,cAApB,OAAOA,UAAyB,OAAOA,AAAmB,SAAnBA,SAASD;QACpD,MAAME,UACJ,AAAoB,YAApB,OAAOD,WACH,IAAIE,OAAOF,YACX,IAAIE,OAAOF,SAAS,MAAM,EAAEA,SAAS,KAAK,CAAC,OAAO,CAAC,KAAK;QAC9D,OAAOC,QAAQ,IAAI,CAACF;IACtB,EAAE,OAAM;QACN,O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