@design.estate/dees-catalog 23.1.0 → 23.2.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.
- package/dist_bundle/bundle.js +3913 -1606
- package/dist_bundle/bundle.js.map +1 -1
- package/dist_bundle/bundle.js.third-party-notices.json +26 -0
- package/dist_bundle/bundle.js.third-party-notices.txt +43 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-UTOZ2L3B.js → chunk-74TRVA7N.js} +7 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-UTOZ2L3B.js.map → chunk-74TRVA7N.js.map} +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-LEBMHFXJ.js → chunk-I4IO5H5N.js} +2 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-TU4V7MTI.js → chunk-T6MJ73SK.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-SOHMEKJH.js → de-OOMCZNLC.js} +7 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-OOMCZNLC.js.map +1 -0
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-EHNIAOW7.js → dees-modal-HUKGQIM3.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-C24RW3H4.js → dees-workspace-terminal-OISBUFI7.js} +4 -4
- package/dist_bundle/third-party-notices.md +35 -2
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/elements/00group-dataview/dees-qrcode/dees-qrcode.d.ts +44 -0
- package/dist_ts_web/elements/00group-dataview/dees-qrcode/dees-qrcode.demo.d.ts +1 -0
- package/dist_ts_web/elements/00group-dataview/dees-qrcode/dees-qrcode.demo.js +40 -0
- package/dist_ts_web/elements/00group-dataview/dees-qrcode/dees-qrcode.js +249 -0
- package/dist_ts_web/elements/00group-dataview/dees-qrcode/index.d.ts +1 -0
- package/dist_ts_web/elements/00group-dataview/dees-qrcode/index.js +2 -0
- package/dist_ts_web/elements/00group-dataview/index.d.ts +1 -0
- package/dist_ts_web/elements/00group-dataview/index.js +2 -1
- package/dist_ts_web/i18n/de.d.ts +16 -0
- package/dist_ts_web/i18n/de.js +6 -1
- package/dist_ts_web/i18n/messages.d.ts +16 -0
- package/dist_ts_web/i18n/messages.js +6 -1
- package/package.json +5 -3
- package/readme.md +30 -0
- package/scripts/reflect-allowlist.json +3 -0
- package/third-party-notices.md +35 -2
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/elements/00group-dataview/dees-qrcode/dees-qrcode.demo.ts +42 -0
- package/ts_web/elements/00group-dataview/dees-qrcode/dees-qrcode.ts +213 -0
- package/ts_web/elements/00group-dataview/dees-qrcode/index.ts +1 -0
- package/ts_web/elements/00group-dataview/index.ts +1 -0
- package/ts_web/i18n/de.ts +6 -0
- package/ts_web/i18n/messages.ts +6 -0
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-SOHMEKJH.js.map +0 -1
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-LEBMHFXJ.js.map → chunk-I4IO5H5N.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-TU4V7MTI.js.map → chunk-T6MJ73SK.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-EHNIAOW7.js.map → dees-modal-HUKGQIM3.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-C24RW3H4.js.map → dees-workspace-terminal-OISBUFI7.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design.estate/dees-catalog",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.",
|
|
6
6
|
"main": "dist_ts_web/index.js",
|
|
@@ -54,13 +54,15 @@
|
|
|
54
54
|
"lightweight-charts": "^5.1.0",
|
|
55
55
|
"lucide": "^1.8.0",
|
|
56
56
|
"monaco-editor": "0.55.1",
|
|
57
|
-
"pdfjs-dist": "4.10.38"
|
|
57
|
+
"pdfjs-dist": "4.10.38",
|
|
58
|
+
"qrcode": "^1.5.4"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@design.estate/wcctools": "^7.1.4",
|
|
61
62
|
"@git.zone/tsrepo": "^1.1.1",
|
|
62
63
|
"@push.rocks/projectinfo": "^5.1.0",
|
|
63
|
-
"@types/node": "26.6.5"
|
|
64
|
+
"@types/node": "26.6.5",
|
|
65
|
+
"@types/qrcode": "^1.5.6"
|
|
64
66
|
},
|
|
65
67
|
"files": [
|
|
66
68
|
"ts/**/*",
|
package/readme.md
CHANGED
|
@@ -41,6 +41,7 @@ switcher**, **view-toggle**, and **single-selection toggle** all lead to
|
|
|
41
41
|
| Track epics, tasks and subtasks across workflow columns | [`dees-kanban`](#deeskanban) | Board, ordering, projects, filters, ticket detail with links, source and history, discussion, live refresh and stable ticket references. |
|
|
42
42
|
| Show a conversation about a record: comments by people and agents, what happened, a reply | [`dees-thread`](#deesthread) | Timeline of comments and events, Markdown composer with close/reopen actions, pending and refused posts, read-only and failed states. The host owns posting and adds the posted entry. |
|
|
43
43
|
| Show who wrote, did or owns something: a picture, else initials; an agent apart from a person | [`dees-avatar`](#deesavatar) | Round for a person, a rounded square with its own glyph for an agent or the system; a picture that fails falls back to the initials. `decorative` beside a visible name. |
|
|
44
|
+
| Show a link or code for a phone to scan: device pairing, a sign-in, an address | [`dees-qrcode`](#deesqrcode) | A QR code as SVG, dark on a light tile in both themes; `size`, `errorCorrection` (default `M`) and `quietZone`. An empty or oversized value shows a note in its place. |
|
|
44
45
|
| Compose comments with searchable inline references | [`dees-input-richtext`](#deesinputrichtext) `searchReferences`, [`dees-input-reference`](#deesinputreference) | In Markdown, `#` at the start of a word searches the host's records at the caret and links the one chosen; `dees-input-reference` writes plain text with references, at `#_`. Both keep stable reference IDs. |
|
|
45
46
|
| Search, filter, sort, edit and act on records | [`dees-table`](#deestable) | Use its columns, selection and data actions before building a table toolbar or row-action layer. |
|
|
46
47
|
| Offer an action about what a tile shows: open its details, export it, add to it | [`dees-tile`](#deestile) `actions` | Footer or header actions, drawn and held while they run exactly like a table's header and footer actions. Never a footer bar of buttons built by hand; actions on a table's rows or on the table itself are the table's own. See [Where actions go](#where-actions-go). |
|
|
@@ -454,6 +455,7 @@ task guide and examples deliberately; the generated table does not replace them.
|
|
|
454
455
|
| `dees-kanban-ticket-detail` | kanban | [DeesKanbanTicketDetail](#deeskanbanticketdetail) | [Source](ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.ts) |
|
|
455
456
|
| `dees-label` | layout | [DeesLabel](#deeslabel) | [Source](ts_web/elements/00group-layout/dees-label/dees-label.ts) |
|
|
456
457
|
| `dees-legend` | chart | [DeesLegend](#deeslegend) | [Source](ts_web/elements/00group-chart/dees-legend/dees-legend.ts) |
|
|
458
|
+
| `dees-meter` | feedback | — | [Source](ts_web/elements/00group-feedback/dees-meter/dees-meter.ts) |
|
|
457
459
|
| `dees-modal` | overlay | [DeesModal](#deesmodal) | [Source](ts_web/elements/00group-overlay/dees-modal/dees-modal.ts) |
|
|
458
460
|
| `dees-mosaic` | layout | [DeesMosaic](#deesmosaic) | [Source](ts_web/elements/00group-layout/dees-mosaic/dees-mosaic.ts) |
|
|
459
461
|
| `dees-pagination` | layout | [DeesPagination](#deespagination) | [Source](ts_web/elements/00group-layout/dees-pagination/dees-pagination.ts) |
|
|
@@ -463,6 +465,7 @@ task guide and examples deliberately; the generated table does not replace them.
|
|
|
463
465
|
| `dees-preview` | media | [DeesPreview](#deespreview) | [Source](ts_web/elements/00group-media/dees-preview/dees-preview.ts) |
|
|
464
466
|
| `dees-profilepicture-modal` | input | — | [Source](ts_web/elements/00group-input/profilepicture/profilepicture.modal.ts) |
|
|
465
467
|
| `dees-progressbar` | feedback | [DeesProgressbar](#deesprogressbar) | [Source](ts_web/elements/00group-feedback/dees-progressbar/dees-progressbar.ts) |
|
|
468
|
+
| `dees-qrcode` | dataview | [DeesQrcode](#deesqrcode) | [Source](ts_web/elements/00group-dataview/dees-qrcode/dees-qrcode.ts) |
|
|
466
469
|
| `dees-resize-handle` | layout | [DeesResizeHandle](#deesresizehandle) | [Source](ts_web/elements/00group-layout/dees-resize-handle/dees-resize-handle.ts) |
|
|
467
470
|
| `dees-searchbar` | utility | [DeesSearchbar](#deessearchbar) | [Source](ts_web/elements/00group-utility/dees-searchbar/dees-searchbar.ts) |
|
|
468
471
|
| `dees-settings` | layout | — | [Source](ts_web/elements/00group-layout/dees-settings/dees-settings.ts) |
|
|
@@ -3982,6 +3985,33 @@ html`<dees-avatar name="Mara Chen" image-url=${mara.pictureUrl}></dees-avatar>
|
|
|
3982
3985
|
|
|
3983
3986
|
---
|
|
3984
3987
|
|
|
3988
|
+
#### `DeesQrcode`
|
|
3989
|
+
|
|
3990
|
+
A QR code for a string a phone scans: a pairing link, a sign-in code, an address.
|
|
3991
|
+
|
|
3992
|
+
```typescript
|
|
3993
|
+
html`<dees-qrcode .value=${pairingLink} .size=${240} label="Pairing code for a new device"></dees-qrcode>`;
|
|
3994
|
+
```
|
|
3995
|
+
|
|
3996
|
+
- **Value.** `value` is the text to encode. It may hold a single-use secret, so it never reflects
|
|
3997
|
+
to an attribute. A new value draws a new code.
|
|
3998
|
+
- **Drawing.** One SVG path of the encoder's dark modules, `shape-rendering="crispEdges"`, so the
|
|
3999
|
+
code stays sharp at any size and zoom. Dark modules sit on a light tile in both themes: a scanner
|
|
4000
|
+
needs the code's own contrast, not the page's.
|
|
4001
|
+
- **Size.** `size` is the tile's side in CSS pixels (200 by default), the quiet zone included.
|
|
4002
|
+
`quietZone` (`quiet-zone`) is the light margin in modules, 4 by default as scanners expect.
|
|
4003
|
+
- **Error correction.** `errorCorrection` (`error-correction`) is `'L'`, `'M'` (the default, suited
|
|
4004
|
+
to a phone camera reading a screen), `'Q'` or `'H'`; a higher level survives more damage and
|
|
4005
|
+
needs more modules for the same text. An unknown level reads as `'M'`.
|
|
4006
|
+
- **Name.** The code is an image named `label`, or "QR code" without one.
|
|
4007
|
+
- **Nothing to draw.** An empty value, a value longer than the largest QR code holds at the chosen
|
|
4008
|
+
level, or a value that is no string shows a note in the code's place instead of a code; nothing
|
|
4009
|
+
throws.
|
|
4010
|
+
|
|
4011
|
+
Encoding uses [`qrcode`](https://www.npmjs.com/package/qrcode) (MIT), with no network requests.
|
|
4012
|
+
|
|
4013
|
+
---
|
|
4014
|
+
|
|
3985
4015
|
#### `DeesThread`
|
|
3986
4016
|
|
|
3987
4017
|
A conversation about a record, as an issue tracker shows one: comments by people and
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
"codeBefore": "large-text: the source a diff compares against",
|
|
19
19
|
"unifiedDiff": "large-text: a whole unified diff"
|
|
20
20
|
},
|
|
21
|
+
"ts_web/elements/00group-dataview/dees-qrcode/dees-qrcode.ts": {
|
|
22
|
+
"value": "user-data: the encoded text, which may carry a single-use pairing or sign-in code"
|
|
23
|
+
},
|
|
21
24
|
"ts_web/elements/00group-dataview/dees-table/dees-table.ts": {
|
|
22
25
|
"filterText": "user-data: the typed search query",
|
|
23
26
|
"errorDetail": "large-text: the technical cause of a failed load, such as a response or a stack trace",
|
package/third-party-notices.md
CHANGED
|
@@ -175,6 +175,7 @@ wording reproduced once and every copyright notice it covers listed with it.
|
|
|
175
175
|
- dayjs 1.11.21 — MIT
|
|
176
176
|
- decode-named-character-reference 1.3.0 — MIT
|
|
177
177
|
- devlop 1.1.0 — MIT
|
|
178
|
+
- dijkstrajs 1.0.3 — MIT
|
|
178
179
|
- echarts 6.1.0 — Apache-2.0
|
|
179
180
|
- escape-string-regexp 5.0.0 — MIT
|
|
180
181
|
- extend 3.0.2 — MIT
|
|
@@ -255,6 +256,7 @@ wording reproduced once and every copyright notice it covers listed with it.
|
|
|
255
256
|
- prosemirror-state 1.4.4 — MIT
|
|
256
257
|
- prosemirror-transform 1.11.0 — MIT
|
|
257
258
|
- prosemirror-view 1.41.6 — MIT
|
|
259
|
+
- qrcode 1.5.4 — MIT
|
|
258
260
|
- remark-frontmatter 5.0.0 — MIT
|
|
259
261
|
- remark-gfm 4.0.1 — MIT
|
|
260
262
|
- remark-html 16.0.1 — MIT
|
|
@@ -847,13 +849,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
847
849
|
SOFTWARE.
|
|
848
850
|
```
|
|
849
851
|
|
|
850
|
-
### MIT —
|
|
852
|
+
### MIT — 14 packages
|
|
851
853
|
|
|
852
|
-
Applies to: @push.rocks/smartenv 6.1.0, @push.rocks/smartjson 6.0.2, @push.rocks/smartstring 4.2.1, @push.rocks/smarttime 5.0.1, @tsclass/tsclass 10.4.0, croner 10.0.1, extend 3.0.2, nanoid 5.1.16, path-to-regexp 8.3.0, sweet-scroll 4.0.0, symbol-tree 3.2.4, uuid 11.1.1, monaco-editor 0.55.1.
|
|
854
|
+
Applies to: @push.rocks/smartenv 6.1.0, @push.rocks/smartjson 6.0.2, @push.rocks/smartstring 4.2.1, @push.rocks/smarttime 5.0.1, @tsclass/tsclass 10.4.0, croner 10.0.1, extend 3.0.2, nanoid 5.1.16, path-to-regexp 8.3.0, qrcode 1.5.4, sweet-scroll 4.0.0, symbol-tree 3.2.4, uuid 11.1.1, monaco-editor 0.55.1.
|
|
853
855
|
|
|
854
856
|
Copyright notices:
|
|
855
857
|
|
|
856
858
|
- Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
|
859
|
+
- Copyright (c) 2012 Ryan Day
|
|
857
860
|
- Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
|
|
858
861
|
- Copyright (c) 2014 Lossless GmbH (hello@lossless.com)
|
|
859
862
|
- Copyright (c) 2014 Stefan Thomas
|
|
@@ -940,6 +943,36 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
940
943
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
941
944
|
```
|
|
942
945
|
|
|
946
|
+
### MIT — dijkstrajs
|
|
947
|
+
|
|
948
|
+
Applies to: dijkstrajs 1.0.3.
|
|
949
|
+
|
|
950
|
+
Copyright notices:
|
|
951
|
+
|
|
952
|
+
- Copyright (C) 2008
|
|
953
|
+
|
|
954
|
+
```text
|
|
955
|
+
```
|
|
956
|
+
Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
|
|
957
|
+
|
|
958
|
+
Copyright (C) 2008
|
|
959
|
+
Wyatt Baldwin <self@wyattbaldwin.com>
|
|
960
|
+
All rights reserved
|
|
961
|
+
|
|
962
|
+
Licensed under the MIT license.
|
|
963
|
+
|
|
964
|
+
http://www.opensource.org/licenses/mit-license.php
|
|
965
|
+
|
|
966
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
967
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
968
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
969
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
970
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
971
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
972
|
+
THE SOFTWARE.
|
|
973
|
+
```
|
|
974
|
+
```
|
|
975
|
+
|
|
943
976
|
### MIT — fast-json-stable-stringify
|
|
944
977
|
|
|
945
978
|
Applies to: fast-json-stable-stringify 2.1.0.
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@design.estate/dees-catalog',
|
|
6
|
-
version: '23.
|
|
6
|
+
version: '23.2.0',
|
|
7
7
|
description: 'A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.'
|
|
8
8
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { html } from '@design.estate/dees-element';
|
|
2
|
+
import { demoPage, demoSection } from '../../../demos/templates.js';
|
|
3
|
+
|
|
4
|
+
/** A pairing payload of the length a device pairing carries: an origin, a single-use code and an identity. */
|
|
5
|
+
const pairingPayload = `agl-pair:${new URLSearchParams({
|
|
6
|
+
origin: 'https://controller.example.com',
|
|
7
|
+
code: 'K7QF-2M9X-VD4P-8RTA',
|
|
8
|
+
controller: 'ctl_01J9Z6Q4X8M2N5P7R3T1V0W9YB',
|
|
9
|
+
fingerprint: 'sha256:9f2c6b1e4d8a7f3c0b5e2d9a6c1f8e4b7d3a0c9e6f2b5d8a1c4e7f0b3d6a9c2e',
|
|
10
|
+
name: 'Studio controller',
|
|
11
|
+
}).toString()}`;
|
|
12
|
+
|
|
13
|
+
const caption = (textArg: string) => html`<span style="font-size: 12px; opacity: .7;">${textArg}</span>`;
|
|
14
|
+
|
|
15
|
+
export const demoFunc = () => demoPage('QR code', 'A QR code for a string, drawn as SVG so it stays sharp at any size. Dark modules on a light tile in both themes, because a scanner reads dark on light. An empty value, or one longer than a QR code holds, shows a note in its place.', html`
|
|
16
|
+
${demoSection('Pairing a device', `A phone scans the controller's pairing link: ${pairingPayload.length} characters at the default error correction (M) and quiet zone (4 modules).`, html`
|
|
17
|
+
<div class="dees-demo-canvas" style="display: flex; gap: 24px; align-items: center; flex-wrap: wrap;">
|
|
18
|
+
<dees-qrcode .value=${pairingPayload} .size=${240} label="Pairing code for a new device"></dees-qrcode>
|
|
19
|
+
<code style="max-width: 360px; font-size: 12px; overflow-wrap: anywhere;">${pairingPayload}</code>
|
|
20
|
+
</div>
|
|
21
|
+
`)}
|
|
22
|
+
${demoSection('Sizes and error correction', 'The same link at 120, 160 and 200 pixels, and at each error correction level: a higher level survives more damage and needs more modules.', html`
|
|
23
|
+
<div class="dees-demo-canvas" style="display: flex; gap: 24px; align-items: end; flex-wrap: wrap;">
|
|
24
|
+
${[120, 160, 200].map((sizeArg) => html`
|
|
25
|
+
<div style="display: grid; gap: 8px; justify-items: center;">
|
|
26
|
+
<dees-qrcode value="https://design.estate" .size=${sizeArg}></dees-qrcode>${caption(`${sizeArg}px`)}
|
|
27
|
+
</div>
|
|
28
|
+
`)}
|
|
29
|
+
${(['L', 'M', 'Q', 'H'] as const).map((levelArg) => html`
|
|
30
|
+
<div style="display: grid; gap: 8px; justify-items: center;">
|
|
31
|
+
<dees-qrcode value="https://design.estate" .size=${120} error-correction=${levelArg}></dees-qrcode>${caption(`Level ${levelArg}`)}
|
|
32
|
+
</div>
|
|
33
|
+
`)}
|
|
34
|
+
</div>
|
|
35
|
+
`)}
|
|
36
|
+
${demoSection('Nothing to encode, and too much', 'An empty value and 3,000 characters: the code gives way to a note instead of failing.', html`
|
|
37
|
+
<div class="dees-demo-canvas" style="display: flex; gap: 24px; flex-wrap: wrap;">
|
|
38
|
+
<dees-qrcode .value=${''} .size=${160}></dees-qrcode>
|
|
39
|
+
<dees-qrcode .value=${'x'.repeat(3000)} .size=${160}></dees-qrcode>
|
|
40
|
+
</div>
|
|
41
|
+
`)}
|
|
42
|
+
`);
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeesElement,
|
|
3
|
+
css,
|
|
4
|
+
cssManager,
|
|
5
|
+
customElement,
|
|
6
|
+
html,
|
|
7
|
+
property,
|
|
8
|
+
type TemplateResult,
|
|
9
|
+
} from '@design.estate/dees-element';
|
|
10
|
+
import * as qrcode from 'qrcode';
|
|
11
|
+
import { themeDefaultStyles } from '../../00theme.js';
|
|
12
|
+
import { dcLocalize } from '../../../i18n/localize.js';
|
|
13
|
+
import { demoFunc } from './dees-qrcode.demo.js';
|
|
14
|
+
|
|
15
|
+
declare global {
|
|
16
|
+
interface HTMLElementTagNameMap {
|
|
17
|
+
'dees-qrcode': DeesQrcode;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* How much of a QR code may be damaged and still read: about 7% (`L`), 15% (`M`), 25% (`Q`) or 30%
|
|
23
|
+
* (`H`). A higher level holds less text in the same number of modules.
|
|
24
|
+
*/
|
|
25
|
+
export type TDeesQrcodeErrorCorrection = 'L' | 'M' | 'Q' | 'H';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Why a QR code cannot be drawn: there is nothing to encode, more than the largest QR code holds at
|
|
29
|
+
* the chosen level, or the encoder refused the value for another reason (a value that is no string).
|
|
30
|
+
*/
|
|
31
|
+
type TQrcodeProblem = 'empty' | 'too-long' | 'unencodable';
|
|
32
|
+
|
|
33
|
+
const problemMessages = {
|
|
34
|
+
empty: 'qrcode.empty',
|
|
35
|
+
'too-long': 'qrcode.tooLong',
|
|
36
|
+
unencodable: 'qrcode.unencodable',
|
|
37
|
+
} as const satisfies Record<TQrcodeProblem, string>;
|
|
38
|
+
|
|
39
|
+
const errorCorrectionLevels: readonly TDeesQrcodeErrorCorrection[] = ['L', 'M', 'Q', 'H'];
|
|
40
|
+
|
|
41
|
+
type TQrcodeEncoding =
|
|
42
|
+
| { ok: true; size: number; path: string }
|
|
43
|
+
| { ok: false; problem: TQrcodeProblem };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* dees-qrcode — a QR code for a string: a pairing link, a sign-in code, an address to open on a
|
|
47
|
+
* phone. It draws dark modules on a light tile in both themes, because a scanner reads dark on
|
|
48
|
+
* light, and it draws them as SVG, so the code stays sharp at any size and zoom.
|
|
49
|
+
*
|
|
50
|
+
* The code is an image to assistive technology, named by `label`. An empty value, or one longer
|
|
51
|
+
* than a QR code holds at the chosen error correction, shows a visible note in the code's place
|
|
52
|
+
* instead.
|
|
53
|
+
*/
|
|
54
|
+
@customElement('dees-qrcode')
|
|
55
|
+
export class DeesQrcode extends DeesElement {
|
|
56
|
+
public static demo = demoFunc;
|
|
57
|
+
public static demoGroups = ['Data View'];
|
|
58
|
+
|
|
59
|
+
private readonly t = dcLocalize(this);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The text to encode. It may hold a single-use secret, such as a pairing code, so it never
|
|
63
|
+
* reflects: an attribute copy would land in every serialization of the page.
|
|
64
|
+
*/
|
|
65
|
+
@property({ type: String })
|
|
66
|
+
accessor value = '';
|
|
67
|
+
|
|
68
|
+
/** The side of the square tile in CSS pixels, the quiet zone included. */
|
|
69
|
+
@property({ type: Number, reflect: true })
|
|
70
|
+
accessor size = 200;
|
|
71
|
+
|
|
72
|
+
/** `M` (about 15% recoverable) suits a phone camera reading a screen; an unknown level reads as `M`. */
|
|
73
|
+
@property({ type: String, reflect: true, attribute: 'error-correction' })
|
|
74
|
+
accessor errorCorrection: TDeesQrcodeErrorCorrection = 'M';
|
|
75
|
+
|
|
76
|
+
/** The light margin around the code, in modules; scanners expect at least 4. */
|
|
77
|
+
@property({ type: Number, reflect: true, attribute: 'quiet-zone' })
|
|
78
|
+
accessor quietZone = 4;
|
|
79
|
+
|
|
80
|
+
/** The code's accessible name: what scanning it does ("Pairing code for a new device"). */
|
|
81
|
+
@property({ type: String, reflect: true })
|
|
82
|
+
accessor label = '';
|
|
83
|
+
|
|
84
|
+
private encoded: { value: string; errorCorrection: TDeesQrcodeErrorCorrection; quietZone: number; result: TQrcodeEncoding } | null = null;
|
|
85
|
+
|
|
86
|
+
public static styles = [
|
|
87
|
+
themeDefaultStyles,
|
|
88
|
+
cssManager.defaultStyles,
|
|
89
|
+
css`
|
|
90
|
+
:host {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
vertical-align: top;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* Dark on light in both themes: a scanner needs the code's own contrast, not the page's. */
|
|
96
|
+
.code {
|
|
97
|
+
display: block;
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
border: var(--dees-line-width-hairline) solid var(--dees-color-border-subtle);
|
|
101
|
+
border-radius: var(--dees-radius-md);
|
|
102
|
+
background: #ffffff;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.code svg {
|
|
106
|
+
display: block;
|
|
107
|
+
width: 100%;
|
|
108
|
+
height: 100%;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.code path {
|
|
112
|
+
fill: #000000;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.problem {
|
|
116
|
+
display: flex;
|
|
117
|
+
box-sizing: border-box;
|
|
118
|
+
align-items: center;
|
|
119
|
+
justify-content: center;
|
|
120
|
+
padding: var(--dees-spacing-md);
|
|
121
|
+
border: var(--dees-line-width-hairline) dashed var(--dees-color-border-default);
|
|
122
|
+
border-radius: var(--dees-radius-md);
|
|
123
|
+
background: var(--dees-color-bg-secondary);
|
|
124
|
+
color: var(--dees-color-text-secondary);
|
|
125
|
+
font-family: var(--dees-font-family);
|
|
126
|
+
font-size: var(--dees-font-secondary-size);
|
|
127
|
+
font-weight: var(--dees-font-secondary-weight);
|
|
128
|
+
line-height: var(--dees-font-secondary-line);
|
|
129
|
+
letter-spacing: var(--dees-font-secondary-tracking);
|
|
130
|
+
text-align: center;
|
|
131
|
+
overflow-wrap: anywhere;
|
|
132
|
+
}
|
|
133
|
+
`,
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
public render(): TemplateResult {
|
|
137
|
+
const side = Number.isFinite(this.size) && this.size > 0 ? this.size : 200;
|
|
138
|
+
const box = `width: ${side}px; height: ${side}px`;
|
|
139
|
+
const result = this.encode();
|
|
140
|
+
if (!result.ok) {
|
|
141
|
+
return html`
|
|
142
|
+
<div class="problem" part="problem" data-problem=${result.problem} style=${box}>
|
|
143
|
+
${this.t(problemMessages[result.problem])}
|
|
144
|
+
</div>
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
return html`
|
|
148
|
+
<div class="code" part="code" role="img" aria-label=${this.label || this.t('qrcode.name')} style=${box}>
|
|
149
|
+
<svg
|
|
150
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
151
|
+
viewBox=${`0 0 ${result.size} ${result.size}`}
|
|
152
|
+
shape-rendering="crispEdges"
|
|
153
|
+
aria-hidden="true"
|
|
154
|
+
focusable="false"
|
|
155
|
+
><path d=${result.path}></path></svg>
|
|
156
|
+
</div>
|
|
157
|
+
`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** The code for the current value, worked out again only when the value or the level changes. */
|
|
161
|
+
private encode(): TQrcodeEncoding {
|
|
162
|
+
const quietZone = Number.isFinite(this.quietZone) ? Math.max(0, Math.floor(this.quietZone)) : 4;
|
|
163
|
+
const errorCorrection = errorCorrectionLevels.includes(this.errorCorrection) ? this.errorCorrection : 'M';
|
|
164
|
+
const cached = this.encoded;
|
|
165
|
+
if (
|
|
166
|
+
cached
|
|
167
|
+
&& cached.value === this.value
|
|
168
|
+
&& cached.errorCorrection === errorCorrection
|
|
169
|
+
&& cached.quietZone === quietZone
|
|
170
|
+
) {
|
|
171
|
+
return cached.result;
|
|
172
|
+
}
|
|
173
|
+
const result = encodeQrcode(this.value, errorCorrection, quietZone);
|
|
174
|
+
this.encoded = { value: this.value, errorCorrection, quietZone, result };
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Encodes `valueArg` and draws its dark modules as one path in module units, a quiet zone of
|
|
181
|
+
* `quietZoneArg` modules around them: each row's runs of dark modules are rectangles one module tall.
|
|
182
|
+
*/
|
|
183
|
+
const encodeQrcode = (
|
|
184
|
+
valueArg: string,
|
|
185
|
+
errorCorrectionArg: TDeesQrcodeErrorCorrection,
|
|
186
|
+
quietZoneArg: number,
|
|
187
|
+
): TQrcodeEncoding => {
|
|
188
|
+
if (!valueArg) return { ok: false, problem: 'empty' };
|
|
189
|
+
let symbol: qrcode.QRCode;
|
|
190
|
+
try {
|
|
191
|
+
symbol = qrcode.create(valueArg, { errorCorrectionLevel: errorCorrectionArg });
|
|
192
|
+
} catch (error) {
|
|
193
|
+
// For a string the encoder refuses only data larger than the largest QR code holds.
|
|
194
|
+
const tooLong = error instanceof Error && /too big/i.test(error.message);
|
|
195
|
+
return { ok: false, problem: tooLong ? 'too-long' : 'unencodable' };
|
|
196
|
+
}
|
|
197
|
+
const { size, data } = symbol.modules;
|
|
198
|
+
const parts: string[] = [];
|
|
199
|
+
for (let row = 0; row < size; row++) {
|
|
200
|
+
let column = 0;
|
|
201
|
+
while (column < size) {
|
|
202
|
+
if (!data[row * size + column]) {
|
|
203
|
+
column++;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const start = column;
|
|
207
|
+
while (column < size && data[row * size + column]) column++;
|
|
208
|
+
const run = column - start;
|
|
209
|
+
parts.push(`M${start + quietZoneArg} ${row + quietZoneArg}h${run}v1h-${run}z`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return { ok: true, size: size + quietZoneArg * 2, path: parts.join('') };
|
|
213
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dees-qrcode.js';
|
|
@@ -6,5 +6,6 @@ export * from './dees-table/index.js';
|
|
|
6
6
|
export * from './dees-table-search/index.js';
|
|
7
7
|
export * from './dees-statsgrid/index.js';
|
|
8
8
|
export * from './dees-grouped-list/index.js';
|
|
9
|
+
export * from './dees-qrcode/index.js';
|
|
9
10
|
export * from './dees-storage-browser/index.js';
|
|
10
11
|
export * from './dees-thread/index.js';
|
package/ts_web/i18n/de.ts
CHANGED
|
@@ -187,6 +187,12 @@ export default dcMessages.translation('de', {
|
|
|
187
187
|
'progressbar.name': 'Fortschritt',
|
|
188
188
|
'meter.name': 'Stand',
|
|
189
189
|
|
|
190
|
+
// dees-qrcode
|
|
191
|
+
'qrcode.name': 'QR-Code',
|
|
192
|
+
'qrcode.empty': 'Nichts als QR-Code anzuzeigen',
|
|
193
|
+
'qrcode.tooLong': 'Zu lang für einen QR-Code',
|
|
194
|
+
'qrcode.unencodable': 'Kann nicht als QR-Code angezeigt werden',
|
|
195
|
+
|
|
190
196
|
// dees-dashboardgrid, dees-pagination, dees-mosaic, dees-resize-handle
|
|
191
197
|
'dashboardgrid.deleteTile': 'Kachel löschen',
|
|
192
198
|
'dashboardgrid.empty': 'Keine Widgets konfiguriert',
|
package/ts_web/i18n/messages.ts
CHANGED
|
@@ -213,6 +213,12 @@ export const dcMessages = plugins.smarti18n.defineCatalog({
|
|
|
213
213
|
'progressbar.name': { message: 'Progress', description: 'A progress bar\'s accessible name while its host gives it no label.' },
|
|
214
214
|
'meter.name': { message: 'Level', description: 'A meter\'s accessible name while its host gives it no label: how full a quantity is, such as a usage window.' },
|
|
215
215
|
|
|
216
|
+
// dees-qrcode
|
|
217
|
+
'qrcode.name': { message: 'QR code', description: 'A QR code\'s accessible name while its host gives it no label.' },
|
|
218
|
+
'qrcode.empty': { message: 'Nothing to show as a QR code', description: 'Shown in a QR code\'s place while it has no text to encode.' },
|
|
219
|
+
'qrcode.tooLong': { message: 'Too long for a QR code', description: 'Shown in a QR code\'s place when its text is more than the largest QR code holds.' },
|
|
220
|
+
'qrcode.unencodable': { message: 'Cannot be shown as a QR code', description: 'Shown in a QR code\'s place when its value cannot be encoded for another reason.' },
|
|
221
|
+
|
|
216
222
|
// dees-dashboardgrid, dees-pagination, dees-mosaic, dees-resize-handle
|
|
217
223
|
'dashboardgrid.deleteTile': { message: 'Delete tile', description: 'A dashboard tile\'s context menu entry that removes the tile.' },
|
|
218
224
|
'dashboardgrid.empty': { message: 'No widgets configured', description: 'Said by a dashboard without tiles.' },
|