@pezkuwi/react-identicon 3.16.6 → 3.16.8
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/package.json +209 -8
- package/build/Identicon.js +0 -104
- package/build/README.md +0 -34
- package/build/bundle.js +0 -3
- package/build/cjs/Identicon.d.ts +0 -5
- package/build/cjs/Identicon.js +0 -108
- package/build/cjs/bundle.d.ts +0 -3
- package/build/cjs/bundle.js +0 -9
- package/build/cjs/icons/Beachball.js +0 -17
- package/build/cjs/icons/Empty.js +0 -10
- package/build/cjs/icons/Ethereum.js +0 -18
- package/build/cjs/icons/Jdenticon.js +0 -12
- package/build/cjs/icons/Polkadot.js +0 -15
- package/build/cjs/icons/index.js +0 -13
- package/build/cjs/index.js +0 -7
- package/build/cjs/packageInfo.js +0 -4
- package/build/cjs/styled.js +0 -5
- package/build/cjs/types.js +0 -2
- package/build/icons/Beachball.d.ts +0 -5
- package/build/icons/Beachball.js +0 -13
- package/build/icons/Empty.d.ts +0 -5
- package/build/icons/Empty.js +0 -6
- package/build/icons/Ethereum.d.ts +0 -5
- package/build/icons/Ethereum.js +0 -14
- package/build/icons/Jdenticon.d.ts +0 -5
- package/build/icons/Jdenticon.js +0 -8
- package/build/icons/Polkadot.d.ts +0 -5
- package/build/icons/Polkadot.js +0 -11
- package/build/icons/index.d.ts +0 -5
- package/build/icons/index.js +0 -5
- package/build/index.d.ts +0 -4
- package/build/index.js +0 -4
- package/build/package.json +0 -249
- package/build/packageDetect.d.ts +0 -1
- package/build/packageDetect.js +0 -5
- package/build/packageInfo.d.ts +0 -6
- package/build/packageInfo.js +0 -1
- package/build/styled.d.ts +0 -1
- package/build/styled.js +0 -1
- package/build/types.d.ts +0 -23
- package/build/types.js +0 -1
- package/build-tsc-cjs/packageDetect.js +0 -7
- package/demo.png +0 -0
- package/index.html +0 -17
- package/src/Identicon.tsx +0 -154
- package/src/bundle.ts +0 -6
- package/src/icons/Beachball.tsx +0 -32
- package/src/icons/Empty.tsx +0 -20
- package/src/icons/Ethereum.tsx +0 -37
- package/src/icons/Jdenticon.tsx +0 -24
- package/src/icons/Polkadot.tsx +0 -59
- package/src/icons/index.ts +0 -8
- package/src/index.ts +0 -10
- package/src/packageDetect.ts +0 -13
- package/src/packageInfo.ts +0 -6
- package/src/styled.ts +0 -4
- package/src/types.ts +0 -30
- package/tsconfig.build.json +0 -12
- package/tsconfig.build.tsbuildinfo +0 -1
- /package/{build-tsc/Identicon.d.ts → Identicon.d.ts} +0 -0
- /package/{build-tsc-esm/Identicon.js → Identicon.js} +0 -0
- /package/{build/LICENSE → LICENSE} +0 -0
- /package/{build/bundle-pezkuwi-react-identicon.js → bundle-pezkuwi-react-identicon.js} +0 -0
- /package/{build-tsc/bundle.d.ts → bundle.d.ts} +0 -0
- /package/{build-tsc-esm/bundle.js → bundle.js} +0 -0
- /package/{build → cjs}/Identicon.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/Identicon.js +0 -0
- /package/{build → cjs}/bundle.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/bundle.js +0 -0
- /package/{build-tsc → cjs}/icons/Beachball.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/icons/Beachball.js +0 -0
- /package/{build-tsc → cjs}/icons/Empty.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/icons/Empty.js +0 -0
- /package/{build-tsc → cjs}/icons/Ethereum.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/icons/Ethereum.js +0 -0
- /package/{build-tsc → cjs}/icons/Jdenticon.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/icons/Jdenticon.js +0 -0
- /package/{build-tsc → cjs}/icons/Polkadot.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/icons/Polkadot.js +0 -0
- /package/{build-tsc → cjs}/icons/index.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/icons/index.js +0 -0
- /package/{build-tsc → cjs}/index.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/index.js +0 -0
- /package/{build/cjs → cjs}/package.json +0 -0
- /package/{build-tsc → cjs}/packageDetect.d.ts +0 -0
- /package/{build/cjs → cjs}/packageDetect.js +0 -0
- /package/{build-tsc → cjs}/packageInfo.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/packageInfo.js +0 -0
- /package/{build-tsc → cjs}/styled.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/styled.js +0 -0
- /package/{build-tsc → cjs}/types.d.ts +0 -0
- /package/{build-tsc-cjs → cjs}/types.js +0 -0
- /package/{build/cjs/icons → icons}/Beachball.d.ts +0 -0
- /package/{build-tsc-esm/icons → icons}/Beachball.js +0 -0
- /package/{build/cjs/icons → icons}/Empty.d.ts +0 -0
- /package/{build-tsc-esm/icons → icons}/Empty.js +0 -0
- /package/{build/cjs/icons → icons}/Ethereum.d.ts +0 -0
- /package/{build-tsc-esm/icons → icons}/Ethereum.js +0 -0
- /package/{build/cjs/icons → icons}/Jdenticon.d.ts +0 -0
- /package/{build-tsc-esm/icons → icons}/Jdenticon.js +0 -0
- /package/{build/cjs/icons → icons}/Polkadot.d.ts +0 -0
- /package/{build-tsc-esm/icons → icons}/Polkadot.js +0 -0
- /package/{build/cjs/icons → icons}/index.d.ts +0 -0
- /package/{build-tsc-esm/icons → icons}/index.js +0 -0
- /package/{build/cjs/index.d.ts → index.d.ts} +0 -0
- /package/{build-tsc-esm/index.js → index.js} +0 -0
- /package/{build/cjs/packageDetect.d.ts → packageDetect.d.ts} +0 -0
- /package/{build-tsc-esm/packageDetect.js → packageDetect.js} +0 -0
- /package/{build/cjs/packageInfo.d.ts → packageInfo.d.ts} +0 -0
- /package/{build-tsc-esm/packageInfo.js → packageInfo.js} +0 -0
- /package/{build/cjs/styled.d.ts → styled.d.ts} +0 -0
- /package/{build-tsc-esm/styled.js → styled.js} +0 -0
- /package/{build/cjs/types.d.ts → types.d.ts} +0 -0
- /package/{build-tsc-esm/types.js → types.js} +0 -0
package/package.json
CHANGED
|
@@ -15,11 +15,217 @@
|
|
|
15
15
|
},
|
|
16
16
|
"sideEffects": [
|
|
17
17
|
"./packageDetect.js",
|
|
18
|
-
"./packageDetect.
|
|
18
|
+
"./cjs/packageDetect.js"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "3.16.
|
|
22
|
-
"main": "index.js",
|
|
21
|
+
"version": "3.16.8",
|
|
22
|
+
"main": "./cjs/index.js",
|
|
23
|
+
"module": "./index.js",
|
|
24
|
+
"types": "./index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./cjs/package.json": "./cjs/package.json",
|
|
27
|
+
"./cjs/*": "./cjs/*.js",
|
|
28
|
+
".": {
|
|
29
|
+
"module": {
|
|
30
|
+
"types": "./index.d.ts",
|
|
31
|
+
"default": "./index.js"
|
|
32
|
+
},
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./cjs/index.d.ts",
|
|
35
|
+
"default": "./cjs/index.js"
|
|
36
|
+
},
|
|
37
|
+
"default": {
|
|
38
|
+
"types": "./index.d.ts",
|
|
39
|
+
"default": "./index.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"./bundle": {
|
|
43
|
+
"module": {
|
|
44
|
+
"types": "./bundle.d.ts",
|
|
45
|
+
"default": "./bundle.js"
|
|
46
|
+
},
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./cjs/bundle.d.ts",
|
|
49
|
+
"default": "./cjs/bundle.js"
|
|
50
|
+
},
|
|
51
|
+
"default": {
|
|
52
|
+
"types": "./bundle.d.ts",
|
|
53
|
+
"default": "./bundle.js"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"./icons": {
|
|
57
|
+
"module": {
|
|
58
|
+
"types": "./icons/index.d.ts",
|
|
59
|
+
"default": "./icons/index.js"
|
|
60
|
+
},
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./cjs/icons/index.d.ts",
|
|
63
|
+
"default": "./cjs/icons/index.js"
|
|
64
|
+
},
|
|
65
|
+
"default": {
|
|
66
|
+
"types": "./icons/index.d.ts",
|
|
67
|
+
"default": "./icons/index.js"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./icons/Beachball": {
|
|
71
|
+
"module": {
|
|
72
|
+
"types": "./icons/Beachball.d.ts",
|
|
73
|
+
"default": "./icons/Beachball.js"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./cjs/icons/Beachball.d.ts",
|
|
77
|
+
"default": "./cjs/icons/Beachball.js"
|
|
78
|
+
},
|
|
79
|
+
"default": {
|
|
80
|
+
"types": "./icons/Beachball.d.ts",
|
|
81
|
+
"default": "./icons/Beachball.js"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"./icons/Empty": {
|
|
85
|
+
"module": {
|
|
86
|
+
"types": "./icons/Empty.d.ts",
|
|
87
|
+
"default": "./icons/Empty.js"
|
|
88
|
+
},
|
|
89
|
+
"require": {
|
|
90
|
+
"types": "./cjs/icons/Empty.d.ts",
|
|
91
|
+
"default": "./cjs/icons/Empty.js"
|
|
92
|
+
},
|
|
93
|
+
"default": {
|
|
94
|
+
"types": "./icons/Empty.d.ts",
|
|
95
|
+
"default": "./icons/Empty.js"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"./icons/Ethereum": {
|
|
99
|
+
"module": {
|
|
100
|
+
"types": "./icons/Ethereum.d.ts",
|
|
101
|
+
"default": "./icons/Ethereum.js"
|
|
102
|
+
},
|
|
103
|
+
"require": {
|
|
104
|
+
"types": "./cjs/icons/Ethereum.d.ts",
|
|
105
|
+
"default": "./cjs/icons/Ethereum.js"
|
|
106
|
+
},
|
|
107
|
+
"default": {
|
|
108
|
+
"types": "./icons/Ethereum.d.ts",
|
|
109
|
+
"default": "./icons/Ethereum.js"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"./icons/Jdenticon": {
|
|
113
|
+
"module": {
|
|
114
|
+
"types": "./icons/Jdenticon.d.ts",
|
|
115
|
+
"default": "./icons/Jdenticon.js"
|
|
116
|
+
},
|
|
117
|
+
"require": {
|
|
118
|
+
"types": "./cjs/icons/Jdenticon.d.ts",
|
|
119
|
+
"default": "./cjs/icons/Jdenticon.js"
|
|
120
|
+
},
|
|
121
|
+
"default": {
|
|
122
|
+
"types": "./icons/Jdenticon.d.ts",
|
|
123
|
+
"default": "./icons/Jdenticon.js"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"./icons/Polkadot": {
|
|
127
|
+
"module": {
|
|
128
|
+
"types": "./icons/Polkadot.d.ts",
|
|
129
|
+
"default": "./icons/Polkadot.js"
|
|
130
|
+
},
|
|
131
|
+
"require": {
|
|
132
|
+
"types": "./cjs/icons/Polkadot.d.ts",
|
|
133
|
+
"default": "./cjs/icons/Polkadot.js"
|
|
134
|
+
},
|
|
135
|
+
"default": {
|
|
136
|
+
"types": "./icons/Polkadot.d.ts",
|
|
137
|
+
"default": "./icons/Polkadot.js"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"./Identicon": {
|
|
141
|
+
"module": {
|
|
142
|
+
"types": "./Identicon.d.ts",
|
|
143
|
+
"default": "./Identicon.js"
|
|
144
|
+
},
|
|
145
|
+
"require": {
|
|
146
|
+
"types": "./cjs/Identicon.d.ts",
|
|
147
|
+
"default": "./cjs/Identicon.js"
|
|
148
|
+
},
|
|
149
|
+
"default": {
|
|
150
|
+
"types": "./Identicon.d.ts",
|
|
151
|
+
"default": "./Identicon.js"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"./package.json": {
|
|
155
|
+
"require": "./cjs/package.json",
|
|
156
|
+
"default": "./package.json"
|
|
157
|
+
},
|
|
158
|
+
"./packageDetect": {
|
|
159
|
+
"module": {
|
|
160
|
+
"types": "./packageDetect.d.ts",
|
|
161
|
+
"default": "./packageDetect.js"
|
|
162
|
+
},
|
|
163
|
+
"require": {
|
|
164
|
+
"types": "./cjs/packageDetect.d.ts",
|
|
165
|
+
"default": "./cjs/packageDetect.js"
|
|
166
|
+
},
|
|
167
|
+
"default": {
|
|
168
|
+
"types": "./packageDetect.d.ts",
|
|
169
|
+
"default": "./packageDetect.js"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"./packageInfo.js": {
|
|
173
|
+
"module": {
|
|
174
|
+
"types": "./packageInfo.d.ts",
|
|
175
|
+
"default": "./packageInfo.js"
|
|
176
|
+
},
|
|
177
|
+
"require": {
|
|
178
|
+
"types": "./cjs/packageInfo.d.ts",
|
|
179
|
+
"default": "./cjs/packageInfo.js"
|
|
180
|
+
},
|
|
181
|
+
"default": {
|
|
182
|
+
"types": "./packageInfo.d.ts",
|
|
183
|
+
"default": "./packageInfo.js"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"./packageInfo": {
|
|
187
|
+
"module": {
|
|
188
|
+
"types": "./packageInfo.d.ts",
|
|
189
|
+
"default": "./packageInfo.js"
|
|
190
|
+
},
|
|
191
|
+
"require": {
|
|
192
|
+
"types": "./cjs/packageInfo.d.ts",
|
|
193
|
+
"default": "./cjs/packageInfo.js"
|
|
194
|
+
},
|
|
195
|
+
"default": {
|
|
196
|
+
"types": "./packageInfo.d.ts",
|
|
197
|
+
"default": "./packageInfo.js"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"./styled": {
|
|
201
|
+
"module": {
|
|
202
|
+
"types": "./styled.d.ts",
|
|
203
|
+
"default": "./styled.js"
|
|
204
|
+
},
|
|
205
|
+
"require": {
|
|
206
|
+
"types": "./cjs/styled.d.ts",
|
|
207
|
+
"default": "./cjs/styled.js"
|
|
208
|
+
},
|
|
209
|
+
"default": {
|
|
210
|
+
"types": "./styled.d.ts",
|
|
211
|
+
"default": "./styled.js"
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
"./types": {
|
|
215
|
+
"module": {
|
|
216
|
+
"types": "./types.d.ts",
|
|
217
|
+
"default": "./types.js"
|
|
218
|
+
},
|
|
219
|
+
"require": {
|
|
220
|
+
"types": "./cjs/types.d.ts",
|
|
221
|
+
"default": "./cjs/types.js"
|
|
222
|
+
},
|
|
223
|
+
"default": {
|
|
224
|
+
"types": "./types.d.ts",
|
|
225
|
+
"default": "./types.js"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
23
229
|
"dependencies": {
|
|
24
230
|
"@pezkuwi/keyring": "^14.0.5",
|
|
25
231
|
"@pezkuwi/ui-settings": "3.16.6",
|
|
@@ -32,11 +238,6 @@
|
|
|
32
238
|
"styled-components": "^6.1.1",
|
|
33
239
|
"tslib": "^2.8.1"
|
|
34
240
|
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@types/react-copy-to-clipboard": "^5.0.7",
|
|
37
|
-
"@types/react-dom": "^18.2.18",
|
|
38
|
-
"xmlserializer": "^0.6.1"
|
|
39
|
-
},
|
|
40
241
|
"peerDependencies": {
|
|
41
242
|
"@pezkuwi/keyring": "*",
|
|
42
243
|
"@pezkuwi/util": "*",
|
package/build/Identicon.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import CopyToClipboard from 'react-copy-to-clipboard';
|
|
4
|
-
import { ICON_DEFAULT_HOST, settings } from '@pezkuwi/ui-settings';
|
|
5
|
-
import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
|
|
6
|
-
import { decodeAddress, encodeAddress, ethereumEncode } from '@pezkuwi/util-crypto';
|
|
7
|
-
import { Beachball, Empty, Ethereum, Jdenticon, Polkadot } from './icons/index.js';
|
|
8
|
-
import { styled } from './styled.js';
|
|
9
|
-
const Fallback = Beachball;
|
|
10
|
-
const DEFAULT_SIZE = 64;
|
|
11
|
-
const Components = {
|
|
12
|
-
beachball: Beachball,
|
|
13
|
-
empty: Empty,
|
|
14
|
-
ethereum: Ethereum,
|
|
15
|
-
jdenticon: Jdenticon,
|
|
16
|
-
polkadot: Polkadot,
|
|
17
|
-
substrate: Jdenticon
|
|
18
|
-
};
|
|
19
|
-
class BaseIcon extends React.PureComponent {
|
|
20
|
-
state = {
|
|
21
|
-
address: '',
|
|
22
|
-
publicKey: '0x'
|
|
23
|
-
};
|
|
24
|
-
static prefix = undefined;
|
|
25
|
-
static setDefaultPrefix(prefix) {
|
|
26
|
-
BaseIcon.prefix = prefix;
|
|
27
|
-
}
|
|
28
|
-
static getDerivedStateFromProps({ prefix = BaseIcon.prefix, theme, value }, prevState) {
|
|
29
|
-
if (theme === 'ethereum') {
|
|
30
|
-
const address = isU8a(value)
|
|
31
|
-
? ethereumEncode(value)
|
|
32
|
-
: value || '';
|
|
33
|
-
return { address, publicKey: '' };
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const address = isU8a(value) || isHex(value)
|
|
37
|
-
? encodeAddress(value, prefix)
|
|
38
|
-
: (value || '');
|
|
39
|
-
const publicKey = u8aToHex(decodeAddress(address, false, prefix));
|
|
40
|
-
return address === prevState.address
|
|
41
|
-
? null
|
|
42
|
-
: {
|
|
43
|
-
address,
|
|
44
|
-
publicKey
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return {
|
|
49
|
-
address: '',
|
|
50
|
-
publicKey: '0x'
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
render() {
|
|
55
|
-
const { address } = this.state;
|
|
56
|
-
const wrapped = this.getWrapped(this.state, this.props);
|
|
57
|
-
return !address
|
|
58
|
-
? wrapped
|
|
59
|
-
: (_jsx(CopyToClipboard, { onCopy: this.onCopy, text: address, children: wrapped }));
|
|
60
|
-
}
|
|
61
|
-
getWrapped({ address, publicKey }, { Custom }) {
|
|
62
|
-
const { className = '', isAlternative, isHighlight, size = DEFAULT_SIZE, style = {}, theme = settings.icon } = this.props;
|
|
63
|
-
const Component = !address
|
|
64
|
-
? Empty
|
|
65
|
-
: Custom || Components[theme === 'default' ? ICON_DEFAULT_HOST : theme] || Fallback;
|
|
66
|
-
return (_jsx(StyledDiv, { className: `ui--IdentityIcon ${className}`, style: style, children: _jsx(Component, { address: address, className: isHighlight ? 'highlight' : '', isAlternative: isAlternative, publicKey: publicKey, size: size }) }, address));
|
|
67
|
-
}
|
|
68
|
-
onCopy = () => {
|
|
69
|
-
const { onCopy } = this.props;
|
|
70
|
-
const { address } = this.state;
|
|
71
|
-
if (address && onCopy) {
|
|
72
|
-
onCopy(address);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function Icon(props) {
|
|
77
|
-
return _jsx(BaseIcon, { ...props });
|
|
78
|
-
}
|
|
79
|
-
const StyledDiv = styled.div `
|
|
80
|
-
cursor: copy;
|
|
81
|
-
display: inline-block;
|
|
82
|
-
line-height: 0;
|
|
83
|
-
|
|
84
|
-
> .container {
|
|
85
|
-
position: relative;
|
|
86
|
-
|
|
87
|
-
> div,
|
|
88
|
-
> svg {
|
|
89
|
-
position: relative;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&.highlight:before {
|
|
93
|
-
position: absolute;
|
|
94
|
-
top: 0;
|
|
95
|
-
left: 0;
|
|
96
|
-
right: 0;
|
|
97
|
-
bottom: 0;
|
|
98
|
-
border-radius: 50%;
|
|
99
|
-
box-shadow: 0 0 5px 2px #aaa;
|
|
100
|
-
content: '';
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
`;
|
|
104
|
-
export const Identicon = React.memo(Icon);
|
package/build/README.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# @pezkuwi/react-identicon
|
|
2
|
-
|
|
3
|
-
A generic identity icon that can render icons based on the theme, be it Substrate or Polkadot
|
|
4
|
-
|
|
5
|
-
## Usage Examples
|
|
6
|
-
|
|
7
|
-
To install the component, do `yarn add @pezkuwi/react-identicon`
|
|
8
|
-
|
|
9
|
-
Inside a React component, you can now render any account with the associated icon -
|
|
10
|
-
|
|
11
|
-
```javascript
|
|
12
|
-
import Identicon from '@pezkuwi/react-identicon';
|
|
13
|
-
|
|
14
|
-
...
|
|
15
|
-
render () {
|
|
16
|
-
// address is an ss58-encoded address or publicKey (hex string or Uint8Array)
|
|
17
|
-
const { address } = this.props;
|
|
18
|
-
// size (optional) is a number, indicating the size (in pixels, 64 as default)
|
|
19
|
-
const size = 32;
|
|
20
|
-
// theme (optional), depicts the type of icon, one of
|
|
21
|
-
// 'polkadot', 'substrate' (default), 'beachball' or 'jdenticon'
|
|
22
|
-
const theme = 'polkadot';
|
|
23
|
-
|
|
24
|
-
// standard className & style props are also available
|
|
25
|
-
return (
|
|
26
|
-
<Identicon
|
|
27
|
-
value={address}
|
|
28
|
-
size={size}
|
|
29
|
-
theme={theme}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
...
|
|
34
|
-
```
|
package/build/bundle.js
DELETED
package/build/cjs/Identicon.d.ts
DELETED
package/build/cjs/Identicon.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Identicon = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
-
const react_copy_to_clipboard_1 = tslib_1.__importDefault(require("react-copy-to-clipboard"));
|
|
8
|
-
const ui_settings_1 = require("@pezkuwi/ui-settings");
|
|
9
|
-
const util_1 = require("@pezkuwi/util");
|
|
10
|
-
const util_crypto_1 = require("@pezkuwi/util-crypto");
|
|
11
|
-
const index_js_1 = require("./icons/index.js");
|
|
12
|
-
const styled_js_1 = require("./styled.js");
|
|
13
|
-
const Fallback = index_js_1.Beachball;
|
|
14
|
-
const DEFAULT_SIZE = 64;
|
|
15
|
-
const Components = {
|
|
16
|
-
beachball: index_js_1.Beachball,
|
|
17
|
-
empty: index_js_1.Empty,
|
|
18
|
-
ethereum: index_js_1.Ethereum,
|
|
19
|
-
jdenticon: index_js_1.Jdenticon,
|
|
20
|
-
polkadot: index_js_1.Polkadot,
|
|
21
|
-
substrate: index_js_1.Jdenticon
|
|
22
|
-
};
|
|
23
|
-
class BaseIcon extends react_1.default.PureComponent {
|
|
24
|
-
state = {
|
|
25
|
-
address: '',
|
|
26
|
-
publicKey: '0x'
|
|
27
|
-
};
|
|
28
|
-
static prefix = undefined;
|
|
29
|
-
static setDefaultPrefix(prefix) {
|
|
30
|
-
BaseIcon.prefix = prefix;
|
|
31
|
-
}
|
|
32
|
-
static getDerivedStateFromProps({ prefix = BaseIcon.prefix, theme, value }, prevState) {
|
|
33
|
-
if (theme === 'ethereum') {
|
|
34
|
-
const address = (0, util_1.isU8a)(value)
|
|
35
|
-
? (0, util_crypto_1.ethereumEncode)(value)
|
|
36
|
-
: value || '';
|
|
37
|
-
return { address, publicKey: '' };
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
const address = (0, util_1.isU8a)(value) || (0, util_1.isHex)(value)
|
|
41
|
-
? (0, util_crypto_1.encodeAddress)(value, prefix)
|
|
42
|
-
: (value || '');
|
|
43
|
-
const publicKey = (0, util_1.u8aToHex)((0, util_crypto_1.decodeAddress)(address, false, prefix));
|
|
44
|
-
return address === prevState.address
|
|
45
|
-
? null
|
|
46
|
-
: {
|
|
47
|
-
address,
|
|
48
|
-
publicKey
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
return {
|
|
53
|
-
address: '',
|
|
54
|
-
publicKey: '0x'
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
render() {
|
|
59
|
-
const { address } = this.state;
|
|
60
|
-
const wrapped = this.getWrapped(this.state, this.props);
|
|
61
|
-
return !address
|
|
62
|
-
? wrapped
|
|
63
|
-
: ((0, jsx_runtime_1.jsx)(react_copy_to_clipboard_1.default, { onCopy: this.onCopy, text: address, children: wrapped }));
|
|
64
|
-
}
|
|
65
|
-
getWrapped({ address, publicKey }, { Custom }) {
|
|
66
|
-
const { className = '', isAlternative, isHighlight, size = DEFAULT_SIZE, style = {}, theme = ui_settings_1.settings.icon } = this.props;
|
|
67
|
-
const Component = !address
|
|
68
|
-
? index_js_1.Empty
|
|
69
|
-
: Custom || Components[theme === 'default' ? ui_settings_1.ICON_DEFAULT_HOST : theme] || Fallback;
|
|
70
|
-
return ((0, jsx_runtime_1.jsx)(StyledDiv, { className: `ui--IdentityIcon ${className}`, style: style, children: (0, jsx_runtime_1.jsx)(Component, { address: address, className: isHighlight ? 'highlight' : '', isAlternative: isAlternative, publicKey: publicKey, size: size }) }, address));
|
|
71
|
-
}
|
|
72
|
-
onCopy = () => {
|
|
73
|
-
const { onCopy } = this.props;
|
|
74
|
-
const { address } = this.state;
|
|
75
|
-
if (address && onCopy) {
|
|
76
|
-
onCopy(address);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function Icon(props) {
|
|
81
|
-
return (0, jsx_runtime_1.jsx)(BaseIcon, { ...props });
|
|
82
|
-
}
|
|
83
|
-
const StyledDiv = styled_js_1.styled.div `
|
|
84
|
-
cursor: copy;
|
|
85
|
-
display: inline-block;
|
|
86
|
-
line-height: 0;
|
|
87
|
-
|
|
88
|
-
> .container {
|
|
89
|
-
position: relative;
|
|
90
|
-
|
|
91
|
-
> div,
|
|
92
|
-
> svg {
|
|
93
|
-
position: relative;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
&.highlight:before {
|
|
97
|
-
position: absolute;
|
|
98
|
-
top: 0;
|
|
99
|
-
left: 0;
|
|
100
|
-
right: 0;
|
|
101
|
-
bottom: 0;
|
|
102
|
-
border-radius: 50%;
|
|
103
|
-
box-shadow: 0 0 5px 2px #aaa;
|
|
104
|
-
content: '';
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
`;
|
|
108
|
-
exports.Identicon = react_1.default.memo(Icon);
|
package/build/cjs/bundle.d.ts
DELETED
package/build/cjs/bundle.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.packageInfo = exports.Identicon = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("./icons/index.js"), exports);
|
|
6
|
-
var Identicon_js_1 = require("./Identicon.js");
|
|
7
|
-
Object.defineProperty(exports, "Identicon", { enumerable: true, get: function () { return Identicon_js_1.Identicon; } });
|
|
8
|
-
var packageInfo_js_1 = require("./packageInfo.js");
|
|
9
|
-
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Beachball = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
-
const ui_shared_1 = require("@pezkuwi/ui-shared");
|
|
8
|
-
function Identicon({ address, className = '', size, style = {} }) {
|
|
9
|
-
const updateElem = (0, react_1.useCallback)((node) => {
|
|
10
|
-
if (node) {
|
|
11
|
-
node.innerHTML = '';
|
|
12
|
-
node.appendChild((0, ui_shared_1.beachballIcon)(address, { isAlternative: false, size }));
|
|
13
|
-
}
|
|
14
|
-
}, [address, size]);
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: className, ref: updateElem, style: style }));
|
|
16
|
-
}
|
|
17
|
-
exports.Beachball = react_1.default.memo(Identicon);
|
package/build/cjs/icons/Empty.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Empty = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
-
function Identicon({ className = '', size, style = {} }) {
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)("svg", { className: className, height: size, style: style, viewBox: '0 0 64 64', width: size }));
|
|
9
|
-
}
|
|
10
|
-
exports.Empty = react_1.default.memo(Identicon);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Ethereum = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const ethereum_blockies_base64_1 = tslib_1.__importDefault(require("ethereum-blockies-base64"));
|
|
7
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
8
|
-
const styled_js_1 = require("../styled.js");
|
|
9
|
-
function Identicon({ address, className = '', size, style = {} }) {
|
|
10
|
-
const imgSrc = (0, react_1.useMemo)(() => (0, ethereum_blockies_base64_1.default)(address), [address]);
|
|
11
|
-
return ((0, jsx_runtime_1.jsx)(StyledImg, { className: className, size: size, src: imgSrc, style: style }));
|
|
12
|
-
}
|
|
13
|
-
const StyledImg = styled_js_1.styled.img(({ size }) => `
|
|
14
|
-
display: block;
|
|
15
|
-
height: ${size}px;
|
|
16
|
-
width: ${size}px;
|
|
17
|
-
`);
|
|
18
|
-
exports.Ethereum = react_1.default.memo(Identicon);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Jdenticon = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const jdenticon = tslib_1.__importStar(require("jdenticon"));
|
|
7
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
8
|
-
function Identicon({ className = '', publicKey, size, style = {} }) {
|
|
9
|
-
const html = (0, react_1.useMemo)(() => ({ __html: jdenticon.toSvg(publicKey.substring(2), size) }), [publicKey, size]);
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: className, dangerouslySetInnerHTML: html, style: style }));
|
|
11
|
-
}
|
|
12
|
-
exports.Jdenticon = react_1.default.memo(Identicon);
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Polkadot = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
-
const ui_shared_1 = require("@pezkuwi/ui-shared");
|
|
8
|
-
function renderCircle({ cx, cy, fill, r }, key) {
|
|
9
|
-
return ((0, jsx_runtime_1.jsx)("circle", { cx: cx, cy: cy, fill: fill, r: r }, key));
|
|
10
|
-
}
|
|
11
|
-
function Identicon({ address, className = '', isAlternative = false, size, style = {} }) {
|
|
12
|
-
const circles = (0, react_1.useMemo)(() => (0, ui_shared_1.polkadotIcon)(address, { isAlternative }), [address, isAlternative]);
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)("svg", { className: className, height: size, id: address, name: address, style: style, viewBox: '0 0 64 64', width: size, children: circles.map(renderCircle) }));
|
|
14
|
-
}
|
|
15
|
-
exports.Polkadot = react_1.default.memo(Identicon);
|
package/build/cjs/icons/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Polkadot = exports.Jdenticon = exports.Ethereum = exports.Empty = exports.Beachball = void 0;
|
|
4
|
-
var Beachball_js_1 = require("./Beachball.js");
|
|
5
|
-
Object.defineProperty(exports, "Beachball", { enumerable: true, get: function () { return Beachball_js_1.Beachball; } });
|
|
6
|
-
var Empty_js_1 = require("./Empty.js");
|
|
7
|
-
Object.defineProperty(exports, "Empty", { enumerable: true, get: function () { return Empty_js_1.Empty; } });
|
|
8
|
-
var Ethereum_js_1 = require("./Ethereum.js");
|
|
9
|
-
Object.defineProperty(exports, "Ethereum", { enumerable: true, get: function () { return Ethereum_js_1.Ethereum; } });
|
|
10
|
-
var Jdenticon_js_1 = require("./Jdenticon.js");
|
|
11
|
-
Object.defineProperty(exports, "Jdenticon", { enumerable: true, get: function () { return Jdenticon_js_1.Jdenticon; } });
|
|
12
|
-
var Polkadot_js_1 = require("./Polkadot.js");
|
|
13
|
-
Object.defineProperty(exports, "Polkadot", { enumerable: true, get: function () { return Polkadot_js_1.Polkadot; } });
|
package/build/cjs/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
require("./packageDetect.js");
|
|
5
|
-
const bundle_js_1 = require("./bundle.js");
|
|
6
|
-
tslib_1.__exportStar(require("./bundle.js"), exports);
|
|
7
|
-
exports.default = bundle_js_1.Identicon;
|
package/build/cjs/packageInfo.js
DELETED
package/build/cjs/styled.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.styled = void 0;
|
|
4
|
-
var styled_components_1 = require("styled-components");
|
|
5
|
-
Object.defineProperty(exports, "styled", { enumerable: true, get: function () { return styled_components_1.styled; } });
|
package/build/cjs/types.js
DELETED
package/build/icons/Beachball.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React, { useCallback } from 'react';
|
|
3
|
-
import { beachballIcon } from '@pezkuwi/ui-shared';
|
|
4
|
-
function Identicon({ address, className = '', size, style = {} }) {
|
|
5
|
-
const updateElem = useCallback((node) => {
|
|
6
|
-
if (node) {
|
|
7
|
-
node.innerHTML = '';
|
|
8
|
-
node.appendChild(beachballIcon(address, { isAlternative: false, size }));
|
|
9
|
-
}
|
|
10
|
-
}, [address, size]);
|
|
11
|
-
return (_jsx("div", { className: className, ref: updateElem, style: style }));
|
|
12
|
-
}
|
|
13
|
-
export const Beachball = React.memo(Identicon);
|
package/build/icons/Empty.d.ts
DELETED
package/build/icons/Empty.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
function Identicon({ className = '', size, style = {} }) {
|
|
4
|
-
return (_jsx("svg", { className: className, height: size, style: style, viewBox: '0 0 64 64', width: size }));
|
|
5
|
-
}
|
|
6
|
-
export const Empty = React.memo(Identicon);
|