@pezkuwi/vue-identicon 3.16.6
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/README.md +37 -0
- package/build/Identicon.d.ts +28 -0
- package/build/Identicon.js +111 -0
- package/build/LICENSE +201 -0
- package/build/README.md +37 -0
- package/build/bundle-pezkuwi-vue-identicon.js +887 -0
- package/build/bundle.d.ts +2 -0
- package/build/bundle.js +2 -0
- package/build/cjs/Identicon.d.ts +28 -0
- package/build/cjs/Identicon.js +115 -0
- package/build/cjs/bundle.d.ts +2 -0
- package/build/cjs/bundle.js +7 -0
- package/build/cjs/icons/Beachball.d.ts +17 -0
- package/build/cjs/icons/Beachball.js +21 -0
- package/build/cjs/icons/Empty.d.ts +11 -0
- package/build/cjs/icons/Empty.js +16 -0
- package/build/cjs/icons/Jdenticon.d.ts +14 -0
- package/build/cjs/icons/Jdenticon.js +19 -0
- package/build/cjs/icons/Polkadot.d.ts +17 -0
- package/build/cjs/icons/Polkadot.js +24 -0
- package/build/cjs/icons/index.d.ts +4 -0
- package/build/cjs/icons/index.js +7 -0
- package/build/cjs/index.d.ts +4 -0
- package/build/cjs/index.js +7 -0
- package/build/cjs/package.json +3 -0
- package/build/cjs/packageDetect.d.ts +1 -0
- package/build/cjs/packageDetect.js +6 -0
- package/build/cjs/packageInfo.d.ts +6 -0
- package/build/cjs/packageInfo.js +4 -0
- package/build/cjs/util.d.ts +6 -0
- package/build/cjs/util.js +15 -0
- package/build/icons/Beachball.d.ts +17 -0
- package/build/icons/Beachball.js +18 -0
- package/build/icons/Empty.d.ts +11 -0
- package/build/icons/Empty.js +13 -0
- package/build/icons/Jdenticon.d.ts +14 -0
- package/build/icons/Jdenticon.js +15 -0
- package/build/icons/Polkadot.d.ts +17 -0
- package/build/icons/Polkadot.js +21 -0
- package/build/icons/index.d.ts +4 -0
- package/build/icons/index.js +4 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +4 -0
- package/build/package.json +213 -0
- package/build/packageDetect.d.ts +1 -0
- package/build/packageDetect.js +4 -0
- package/build/packageInfo.d.ts +6 -0
- package/build/packageInfo.js +1 -0
- package/build/util.d.ts +6 -0
- package/build/util.js +12 -0
- package/build-tsc/Identicon.d.ts +28 -0
- package/build-tsc/bundle.d.ts +2 -0
- package/build-tsc/icons/Beachball.d.ts +17 -0
- package/build-tsc/icons/Empty.d.ts +11 -0
- package/build-tsc/icons/Jdenticon.d.ts +14 -0
- package/build-tsc/icons/Polkadot.d.ts +17 -0
- package/build-tsc/icons/index.d.ts +4 -0
- package/build-tsc/index.d.ts +4 -0
- package/build-tsc/packageDetect.d.ts +1 -0
- package/build-tsc/packageInfo.d.ts +6 -0
- package/build-tsc/util.d.ts +6 -0
- package/build-tsc-cjs/Identicon.js +115 -0
- package/build-tsc-cjs/bundle.js +7 -0
- package/build-tsc-cjs/icons/Beachball.js +21 -0
- package/build-tsc-cjs/icons/Empty.js +16 -0
- package/build-tsc-cjs/icons/Jdenticon.js +19 -0
- package/build-tsc-cjs/icons/Polkadot.js +24 -0
- package/build-tsc-cjs/icons/index.js +7 -0
- package/build-tsc-cjs/index.js +7 -0
- package/build-tsc-cjs/packageDetect.js +6 -0
- package/build-tsc-cjs/packageInfo.js +4 -0
- package/build-tsc-cjs/util.js +15 -0
- package/build-tsc-esm/Identicon.js +111 -0
- package/build-tsc-esm/bundle.js +2 -0
- package/build-tsc-esm/icons/Beachball.js +18 -0
- package/build-tsc-esm/icons/Empty.js +13 -0
- package/build-tsc-esm/icons/Jdenticon.js +15 -0
- package/build-tsc-esm/icons/Polkadot.js +21 -0
- package/build-tsc-esm/icons/index.js +4 -0
- package/build-tsc-esm/index.js +4 -0
- package/build-tsc-esm/packageDetect.js +4 -0
- package/build-tsc-esm/packageInfo.js +1 -0
- package/build-tsc-esm/util.js +12 -0
- package/index.html +17 -0
- package/package.json +38 -0
- package/src/Identicon.ts +141 -0
- package/src/bundle.ts +5 -0
- package/src/icons/Beachball.ts +32 -0
- package/src/icons/Empty.ts +17 -0
- package/src/icons/Jdenticon.ts +27 -0
- package/src/icons/Polkadot.ts +38 -0
- package/src/icons/index.ts +7 -0
- package/src/index.ts +10 -0
- package/src/packageDetect.ts +12 -0
- package/src/packageInfo.ts +6 -0
- package/src/util.ts +17 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
|
|
3
|
+
import { decodeAddress, encodeAddress, isEthereumAddress } from '@pezkuwi/util-crypto';
|
|
4
|
+
import { Beachball, Empty, Jdenticon, Polkadot } from './icons/index.js';
|
|
5
|
+
import { adaptVNodeAttrs } from './util.js';
|
|
6
|
+
const DEFAULT_SIZE = 64;
|
|
7
|
+
function resolvePublicKey(value, prefix) {
|
|
8
|
+
if (isHex(value) && isEthereumAddress(value)) {
|
|
9
|
+
return value.padEnd(66, '0');
|
|
10
|
+
}
|
|
11
|
+
return isU8a(value) || isHex(value)
|
|
12
|
+
? encodeAddress(value, prefix)
|
|
13
|
+
: value;
|
|
14
|
+
}
|
|
15
|
+
export function encodeAccount(value, prefix) {
|
|
16
|
+
try {
|
|
17
|
+
const address = resolvePublicKey(value, prefix);
|
|
18
|
+
const publicKey = u8aToHex(decodeAddress(address, false, prefix));
|
|
19
|
+
return { address, publicKey };
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return { address: '', publicKey: '0x' };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @name Identicon
|
|
27
|
+
* @description The main Identicon component, taking a number of properties
|
|
28
|
+
* @example
|
|
29
|
+
* ```html
|
|
30
|
+
* <Identicon :size="128" :theme="polkadot" :value="..." />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const Identicon = defineComponent({
|
|
34
|
+
components: {
|
|
35
|
+
Beachball,
|
|
36
|
+
Empty,
|
|
37
|
+
Jdenticon,
|
|
38
|
+
Polkadot
|
|
39
|
+
},
|
|
40
|
+
created: function () {
|
|
41
|
+
this.createData();
|
|
42
|
+
},
|
|
43
|
+
data: function () {
|
|
44
|
+
return {
|
|
45
|
+
address: '',
|
|
46
|
+
iconSize: DEFAULT_SIZE,
|
|
47
|
+
isAlternativeIcon: false,
|
|
48
|
+
publicKey: '0x',
|
|
49
|
+
type: 'empty'
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
methods: {
|
|
53
|
+
createData: function () {
|
|
54
|
+
this.iconSize = this.size || DEFAULT_SIZE;
|
|
55
|
+
this.type = this.theme;
|
|
56
|
+
this.isAlternativeIcon = this.isAlternative || false;
|
|
57
|
+
this.recodeAddress();
|
|
58
|
+
},
|
|
59
|
+
recodeAddress: function () {
|
|
60
|
+
const { address, publicKey } = encodeAccount(this.value);
|
|
61
|
+
this.address = address;
|
|
62
|
+
this.publicKey = publicKey;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
props: ['prefix', 'isAlternative', 'size', 'theme', 'value'],
|
|
66
|
+
render() {
|
|
67
|
+
const { address, iconSize, isAlternativeIcon, publicKey, type } = this.$data;
|
|
68
|
+
if (type === 'empty') {
|
|
69
|
+
return h(Empty, {
|
|
70
|
+
...adaptVNodeAttrs({
|
|
71
|
+
key: address,
|
|
72
|
+
size: iconSize
|
|
73
|
+
})
|
|
74
|
+
}, []);
|
|
75
|
+
}
|
|
76
|
+
else if (type === 'jdenticon') {
|
|
77
|
+
return h(Jdenticon, {
|
|
78
|
+
...adaptVNodeAttrs({
|
|
79
|
+
key: address,
|
|
80
|
+
publicKey,
|
|
81
|
+
size: iconSize
|
|
82
|
+
})
|
|
83
|
+
}, []);
|
|
84
|
+
}
|
|
85
|
+
else if (type === 'substrate') {
|
|
86
|
+
throw new Error('substrate type is not supported');
|
|
87
|
+
}
|
|
88
|
+
const cmp = type.charAt(0).toUpperCase() + type.slice(1);
|
|
89
|
+
if (['Beachball', 'Polkadot'].includes(cmp)) {
|
|
90
|
+
const component = cmp === 'Beachball'
|
|
91
|
+
? Beachball
|
|
92
|
+
: Polkadot;
|
|
93
|
+
return h(component, {
|
|
94
|
+
...adaptVNodeAttrs({
|
|
95
|
+
address,
|
|
96
|
+
isAlternative: isAlternativeIcon,
|
|
97
|
+
key: address,
|
|
98
|
+
size: iconSize
|
|
99
|
+
})
|
|
100
|
+
}, []);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return h(cmp, {}, []);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
watch: {
|
|
107
|
+
value: function () {
|
|
108
|
+
this.recodeAddress();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { beachballIcon } from '@pezkuwi/ui-shared';
|
|
3
|
+
/**
|
|
4
|
+
* @name Beachball
|
|
5
|
+
* @description The Beachball identicon
|
|
6
|
+
*/
|
|
7
|
+
export const Beachball = defineComponent({
|
|
8
|
+
props: ['address', 'size', 'isAlternative'],
|
|
9
|
+
render() {
|
|
10
|
+
const { address, isAlternative, size } = this.$props;
|
|
11
|
+
return h({
|
|
12
|
+
template: beachballIcon(address, {
|
|
13
|
+
isAlternative,
|
|
14
|
+
size
|
|
15
|
+
}).outerHTML
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineComponent } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* @name Empty
|
|
4
|
+
* @description An empty identicon
|
|
5
|
+
*/
|
|
6
|
+
export const Empty = defineComponent({
|
|
7
|
+
props: ['size'],
|
|
8
|
+
template: `
|
|
9
|
+
<svg :height="size" :width="size" viewBox="0 0 64 64">
|
|
10
|
+
<circle cx="50%" cy="50%" fill="#eee" r="50%" />
|
|
11
|
+
</svg>
|
|
12
|
+
`
|
|
13
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as jdenticon from 'jdenticon';
|
|
2
|
+
import { defineComponent, h } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* @name Jdenticon
|
|
5
|
+
* @description The substrate default via Jdenticon
|
|
6
|
+
*/
|
|
7
|
+
export const Jdenticon = defineComponent({
|
|
8
|
+
props: ['publicKey', 'size'],
|
|
9
|
+
render() {
|
|
10
|
+
const { publicKey, size } = this.$props;
|
|
11
|
+
return h({
|
|
12
|
+
template: jdenticon.toSvg(publicKey.substring(2), size)
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { polkadotIcon } from '@pezkuwi/ui-shared';
|
|
3
|
+
import { adaptVNodeAttrs } from '../util.js';
|
|
4
|
+
/**
|
|
5
|
+
* @name Polkadot
|
|
6
|
+
* @description The Polkadot default identicon
|
|
7
|
+
*/
|
|
8
|
+
export const Polkadot = defineComponent({
|
|
9
|
+
props: ['address', 'isAlternative', 'size'],
|
|
10
|
+
render() {
|
|
11
|
+
const { address, isAlternative, size } = this.$props;
|
|
12
|
+
const circles = polkadotIcon(address, { isAlternative }).map(({ cx, cy, fill, r }) => h('circle', { ...adaptVNodeAttrs({ cx, cy, fill, r }) }, []));
|
|
13
|
+
return h('svg', {
|
|
14
|
+
...adaptVNodeAttrs({
|
|
15
|
+
height: size,
|
|
16
|
+
viewBox: '0 0 64 64',
|
|
17
|
+
width: size
|
|
18
|
+
})
|
|
19
|
+
}, circles);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const packageInfo = { name: '@pezkuwi/vue-identicon', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '3.16.6' };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { version } from 'vue';
|
|
2
|
+
const isV3 = version.startsWith('3.');
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* Adjust attributes to be usable in both Vue 2 and Vue 3 components.
|
|
7
|
+
*/
|
|
8
|
+
export function adaptVNodeAttrs(data) {
|
|
9
|
+
return isV3
|
|
10
|
+
? data
|
|
11
|
+
: { attrs: data };
|
|
12
|
+
}
|
package/index.html
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" />
|
|
4
|
+
<style>
|
|
5
|
+
#demo {
|
|
6
|
+
padding: 0.5em;
|
|
7
|
+
}
|
|
8
|
+
.padded {
|
|
9
|
+
margin: 0.5em !important;
|
|
10
|
+
}
|
|
11
|
+
</style>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<div id="demo"></div>
|
|
15
|
+
<script src="./build/Demo.js"></script>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Jaco Greeff <jacogr@gmail.com>",
|
|
3
|
+
"bugs": "https://github.com/pezkuwichain/ui/issues",
|
|
4
|
+
"description": "Renders an SVG picture representing an address",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=18"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://github.com/pezkuwichain/ui/tree/master/packages/vue-identicon#readme",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"name": "@pezkuwi/vue-identicon",
|
|
11
|
+
"repository": {
|
|
12
|
+
"directory": "packages/vue-identicon",
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/pezkuwichain/ui.git"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"./packageDetect.js",
|
|
18
|
+
"./packageDetect.cjs"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"version": "3.16.6",
|
|
22
|
+
"main": "index.js",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@pezkuwi/ui-shared": "3.16.6",
|
|
25
|
+
"@pezkuwi/util": "^14.0.5",
|
|
26
|
+
"@pezkuwi/util-crypto": "^14.0.5",
|
|
27
|
+
"jdenticon": "3.2.0",
|
|
28
|
+
"tslib": "^2.8.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"vue": "^2.7.16"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@pezkuwi/util": "*",
|
|
35
|
+
"@pezkuwi/util-crypto": "*",
|
|
36
|
+
"vue": ">= 2.7"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/Identicon.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/vue-identicon authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { VNode } from 'vue';
|
|
5
|
+
import type { Prefix } from '@pezkuwi/util-crypto/address/types';
|
|
6
|
+
|
|
7
|
+
import { defineComponent, h } from 'vue';
|
|
8
|
+
|
|
9
|
+
import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
|
|
10
|
+
import { decodeAddress, encodeAddress, isEthereumAddress } from '@pezkuwi/util-crypto';
|
|
11
|
+
|
|
12
|
+
import { Beachball, Empty, Jdenticon, Polkadot } from './icons/index.js';
|
|
13
|
+
import { adaptVNodeAttrs } from './util.js';
|
|
14
|
+
|
|
15
|
+
interface Account {
|
|
16
|
+
address: string;
|
|
17
|
+
publicKey: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface Data {
|
|
21
|
+
address: string;
|
|
22
|
+
iconSize: number;
|
|
23
|
+
isAlternativeIcon: boolean;
|
|
24
|
+
publicKey: string;
|
|
25
|
+
type: 'beachball' | 'empty' | 'jdenticon' | 'polkadot' | 'substrate';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const DEFAULT_SIZE = 64;
|
|
29
|
+
|
|
30
|
+
function resolvePublicKey (value: string | Uint8Array, prefix?: Prefix): string {
|
|
31
|
+
if (isHex(value) && isEthereumAddress(value)) {
|
|
32
|
+
return value.padEnd(66, '0');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return isU8a(value) || isHex(value)
|
|
36
|
+
? encodeAddress(value as string, prefix)
|
|
37
|
+
: value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function encodeAccount (value: string | Uint8Array, prefix?: Prefix): Account {
|
|
41
|
+
try {
|
|
42
|
+
const address = resolvePublicKey(value, prefix);
|
|
43
|
+
const publicKey = u8aToHex(decodeAddress(address, false, prefix));
|
|
44
|
+
|
|
45
|
+
return { address, publicKey };
|
|
46
|
+
} catch {
|
|
47
|
+
return { address: '', publicKey: '0x' };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @name Identicon
|
|
53
|
+
* @description The main Identicon component, taking a number of properties
|
|
54
|
+
* @example
|
|
55
|
+
* ```html
|
|
56
|
+
* <Identicon :size="128" :theme="polkadot" :value="..." />
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export const Identicon = defineComponent({
|
|
60
|
+
components: {
|
|
61
|
+
Beachball,
|
|
62
|
+
Empty,
|
|
63
|
+
Jdenticon,
|
|
64
|
+
Polkadot
|
|
65
|
+
},
|
|
66
|
+
created: function (): void {
|
|
67
|
+
this.createData();
|
|
68
|
+
},
|
|
69
|
+
data: function (): Data {
|
|
70
|
+
return {
|
|
71
|
+
address: '',
|
|
72
|
+
iconSize: DEFAULT_SIZE,
|
|
73
|
+
isAlternativeIcon: false,
|
|
74
|
+
publicKey: '0x',
|
|
75
|
+
type: 'empty'
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
methods: {
|
|
79
|
+
createData: function (): void {
|
|
80
|
+
this.iconSize = this.size as number || DEFAULT_SIZE;
|
|
81
|
+
this.type = this.theme as 'empty';
|
|
82
|
+
this.isAlternativeIcon = this.isAlternative as boolean || false;
|
|
83
|
+
this.recodeAddress();
|
|
84
|
+
},
|
|
85
|
+
recodeAddress: function (): void {
|
|
86
|
+
const { address, publicKey } = encodeAccount(this.value as string);
|
|
87
|
+
|
|
88
|
+
this.address = address;
|
|
89
|
+
this.publicKey = publicKey;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
props: ['prefix', 'isAlternative', 'size', 'theme', 'value'],
|
|
93
|
+
render (): VNode {
|
|
94
|
+
const { address, iconSize, isAlternativeIcon, publicKey, type } = this.$data;
|
|
95
|
+
|
|
96
|
+
if (type === 'empty') {
|
|
97
|
+
return h(Empty, {
|
|
98
|
+
...adaptVNodeAttrs({
|
|
99
|
+
key: address,
|
|
100
|
+
size: iconSize
|
|
101
|
+
})
|
|
102
|
+
}, []);
|
|
103
|
+
} else if (type === 'jdenticon') {
|
|
104
|
+
return h(Jdenticon, {
|
|
105
|
+
...adaptVNodeAttrs(
|
|
106
|
+
{
|
|
107
|
+
key: address,
|
|
108
|
+
publicKey,
|
|
109
|
+
size: iconSize
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
}, []);
|
|
113
|
+
} else if (type === 'substrate') {
|
|
114
|
+
throw new Error('substrate type is not supported');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const cmp = type.charAt(0).toUpperCase() + type.slice(1);
|
|
118
|
+
|
|
119
|
+
if (['Beachball', 'Polkadot'].includes(cmp)) {
|
|
120
|
+
const component = cmp === 'Beachball'
|
|
121
|
+
? Beachball
|
|
122
|
+
: Polkadot;
|
|
123
|
+
|
|
124
|
+
return h(component, {
|
|
125
|
+
...adaptVNodeAttrs({
|
|
126
|
+
address,
|
|
127
|
+
isAlternative: isAlternativeIcon,
|
|
128
|
+
key: address,
|
|
129
|
+
size: iconSize
|
|
130
|
+
})
|
|
131
|
+
}, []);
|
|
132
|
+
} else {
|
|
133
|
+
return h(cmp, {}, []);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
watch: {
|
|
137
|
+
value: function (): void {
|
|
138
|
+
this.recodeAddress();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
package/src/bundle.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/vue-identicon authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { VNode } from 'vue';
|
|
5
|
+
|
|
6
|
+
import { defineComponent, h } from 'vue';
|
|
7
|
+
|
|
8
|
+
import { beachballIcon } from '@pezkuwi/ui-shared';
|
|
9
|
+
|
|
10
|
+
interface PropsType {
|
|
11
|
+
address: string;
|
|
12
|
+
size: number;
|
|
13
|
+
isAlternative: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @name Beachball
|
|
18
|
+
* @description The Beachball identicon
|
|
19
|
+
*/
|
|
20
|
+
export const Beachball = defineComponent({
|
|
21
|
+
props: ['address', 'size', 'isAlternative'],
|
|
22
|
+
render (): VNode {
|
|
23
|
+
const { address, isAlternative, size } = this.$props as PropsType;
|
|
24
|
+
|
|
25
|
+
return h({
|
|
26
|
+
template: beachballIcon(address, {
|
|
27
|
+
isAlternative,
|
|
28
|
+
size
|
|
29
|
+
}).outerHTML
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/vue-identicon authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { defineComponent } from 'vue';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @name Empty
|
|
8
|
+
* @description An empty identicon
|
|
9
|
+
*/
|
|
10
|
+
export const Empty = defineComponent({
|
|
11
|
+
props: ['size'],
|
|
12
|
+
template: `
|
|
13
|
+
<svg :height="size" :width="size" viewBox="0 0 64 64">
|
|
14
|
+
<circle cx="50%" cy="50%" fill="#eee" r="50%" />
|
|
15
|
+
</svg>
|
|
16
|
+
`
|
|
17
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/vue-identicon authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { VNode } from 'vue';
|
|
5
|
+
|
|
6
|
+
import * as jdenticon from 'jdenticon';
|
|
7
|
+
import { defineComponent, h } from 'vue';
|
|
8
|
+
|
|
9
|
+
interface PropsType {
|
|
10
|
+
publicKey: string,
|
|
11
|
+
size: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @name Jdenticon
|
|
16
|
+
* @description The substrate default via Jdenticon
|
|
17
|
+
*/
|
|
18
|
+
export const Jdenticon = defineComponent({
|
|
19
|
+
props: ['publicKey', 'size'],
|
|
20
|
+
render (): VNode {
|
|
21
|
+
const { publicKey, size } = this.$props as PropsType;
|
|
22
|
+
|
|
23
|
+
return h({
|
|
24
|
+
template: jdenticon.toSvg(publicKey.substring(2), size)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/vue-identicon authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { VNode } from 'vue';
|
|
5
|
+
|
|
6
|
+
import { defineComponent, h } from 'vue';
|
|
7
|
+
|
|
8
|
+
import { polkadotIcon } from '@pezkuwi/ui-shared';
|
|
9
|
+
|
|
10
|
+
import { adaptVNodeAttrs } from '../util.js';
|
|
11
|
+
|
|
12
|
+
interface propsType {
|
|
13
|
+
address: string;
|
|
14
|
+
isAlternative: boolean;
|
|
15
|
+
size: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @name Polkadot
|
|
20
|
+
* @description The Polkadot default identicon
|
|
21
|
+
*/
|
|
22
|
+
export const Polkadot = defineComponent({
|
|
23
|
+
props: ['address', 'isAlternative', 'size'],
|
|
24
|
+
render (): VNode {
|
|
25
|
+
const { address, isAlternative, size } = this.$props as propsType;
|
|
26
|
+
const circles = polkadotIcon(address, { isAlternative }).map(({ cx, cy, fill, r }) =>
|
|
27
|
+
h('circle', { ...adaptVNodeAttrs({ cx, cy, fill, r }) }, [])
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return h('svg', {
|
|
31
|
+
...adaptVNodeAttrs({
|
|
32
|
+
height: size,
|
|
33
|
+
viewBox: '0 0 64 64',
|
|
34
|
+
width: size
|
|
35
|
+
})
|
|
36
|
+
}, circles);
|
|
37
|
+
}
|
|
38
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright 2017-2026 @pezkuwi/vue-identicon authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Do not edit, auto-generated by @pezkuwi/dev
|
|
5
|
+
// (packageInfo imports will be kept as-is, user-editable)
|
|
6
|
+
|
|
7
|
+
import { packageInfo as sharedInfo } from '@pezkuwi/ui-shared/packageInfo';
|
|
8
|
+
import { detectPackage } from '@pezkuwi/util';
|
|
9
|
+
|
|
10
|
+
import { packageInfo } from './packageInfo.js';
|
|
11
|
+
|
|
12
|
+
detectPackage(packageInfo, null, [sharedInfo]);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright 2017-2026 @pezkuwi/vue-identicon authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Do not edit, auto-generated by @pezkuwi/dev
|
|
5
|
+
|
|
6
|
+
export const packageInfo = { name: '@pezkuwi/vue-identicon', path: 'auto', type: 'auto', version: '3.16.6' };
|
package/src/util.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/vue-identicon authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { version } from 'vue';
|
|
5
|
+
|
|
6
|
+
const isV3 = version.startsWith('3.');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
* Adjust attributes to be usable in both Vue 2 and Vue 3 components.
|
|
12
|
+
*/
|
|
13
|
+
export function adaptVNodeAttrs (data: Record<string, unknown>): Record<string, unknown> {
|
|
14
|
+
return isV3
|
|
15
|
+
? data
|
|
16
|
+
: { attrs: data };
|
|
17
|
+
}
|