@taybart/corvid 0.1.3 → 0.1.5
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/dom.d.ts +2 -1
- package/dist/index.js +16 -3
- package/package.json +1 -1
- package/dist/qr.d.ts +0 -22
- package/dist/renderer.d.ts +0 -0
package/dist/dom.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare function onKey(key: string, cb: (ev: {
|
|
|
12
12
|
alt: boolean;
|
|
13
13
|
meta: boolean;
|
|
14
14
|
shift: boolean;
|
|
15
|
-
}) => void): void;
|
|
15
|
+
}) => void, verbose?: boolean): () => void;
|
|
16
16
|
export declare function els(query: string, verbose?: boolean): el[];
|
|
17
17
|
/*** element ***/
|
|
18
18
|
type elOpts = {
|
|
@@ -36,6 +36,7 @@ export declare class el {
|
|
|
36
36
|
parent(parent: HTMLElement | el): this;
|
|
37
37
|
appendChild(ch: HTMLElement | el): this;
|
|
38
38
|
child(ch: HTMLElement | el): this;
|
|
39
|
+
prependChild(ch: HTMLElement | el): this;
|
|
39
40
|
empty(): this;
|
|
40
41
|
content(content: any, { text }?: {
|
|
41
42
|
text?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -242,15 +242,22 @@ function dom_define_property(obj, key, value) {
|
|
|
242
242
|
function ready(cb) {
|
|
243
243
|
window.addEventListener('DOMContentLoaded', cb);
|
|
244
244
|
}
|
|
245
|
-
function onKey(key, cb) {
|
|
246
|
-
|
|
245
|
+
function onKey(key, cb, verbose = false) {
|
|
246
|
+
const log = new logger(verbose ? utils_logLevel.debug : utils_logLevel.none, 'onKey');
|
|
247
|
+
log.debug(`adding ${key} keydown listener`);
|
|
248
|
+
const handler = (ev)=>{
|
|
247
249
|
if (ev.key === key) cb({
|
|
248
250
|
ctrl: ev.ctrlKey,
|
|
249
251
|
alt: ev.altKey,
|
|
250
252
|
meta: ev.metaKey,
|
|
251
253
|
shift: ev.shiftKey
|
|
252
254
|
});
|
|
253
|
-
}
|
|
255
|
+
};
|
|
256
|
+
window.addEventListener('keydown', handler);
|
|
257
|
+
return ()=>{
|
|
258
|
+
log.debug(`removing ${key} listener`);
|
|
259
|
+
window.removeEventListener('keydown', handler);
|
|
260
|
+
};
|
|
254
261
|
}
|
|
255
262
|
function els(query, verbose = false) {
|
|
256
263
|
return Array.from(document.querySelectorAll(query)).map((n)=>new dom_el(n, verbose));
|
|
@@ -283,6 +290,12 @@ class dom_el {
|
|
|
283
290
|
else this.el.appendChild(ch);
|
|
284
291
|
return this;
|
|
285
292
|
}
|
|
293
|
+
prependChild(ch) {
|
|
294
|
+
if (!this.el) throw new Error(`no element from query: ${this.query}`);
|
|
295
|
+
if (ch instanceof dom_el) this.el.prepend(ch.el);
|
|
296
|
+
else this.el.prepend(ch);
|
|
297
|
+
return this;
|
|
298
|
+
}
|
|
286
299
|
empty() {
|
|
287
300
|
if (this.el) this.el.innerHTML = '';
|
|
288
301
|
return this;
|
package/package.json
CHANGED
package/dist/qr.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
interface QRCodeConfig {
|
|
2
|
-
text: string;
|
|
3
|
-
size?: number;
|
|
4
|
-
ecLevel?: 'L' | 'M' | 'Q' | 'H';
|
|
5
|
-
minVersion?: number;
|
|
6
|
-
maxVersion?: number;
|
|
7
|
-
quiet?: number;
|
|
8
|
-
radius?: number;
|
|
9
|
-
background?: string | null;
|
|
10
|
-
fill?: string | GradientFill;
|
|
11
|
-
left?: number;
|
|
12
|
-
top?: number;
|
|
13
|
-
}
|
|
14
|
-
interface GradientFill {
|
|
15
|
-
type: 'linear-gradient' | 'radial-gradient';
|
|
16
|
-
position: number[];
|
|
17
|
-
colorStops: Array<[number, string]>;
|
|
18
|
-
}
|
|
19
|
-
export default class QrCreator {
|
|
20
|
-
static render(config: QRCodeConfig, element: HTMLElement | HTMLCanvasElement): void;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
package/dist/renderer.d.ts
DELETED
|
File without changes
|