@dicebear/initials 5.0.0-alpha.2 → 5.0.0-alpha.20
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/LICENSE +1 -1
- package/lib/core.d.ts +3 -0
- package/lib/core.js +55 -0
- package/{dist → lib}/index.d.ts +9 -9
- package/lib/index.js +10 -0
- package/lib/schema.d.ts +2 -0
- package/lib/schema.js +100 -0
- package/lib/types.d.ts +7 -0
- package/lib/types.js +1 -0
- package/package.json +22 -33
- package/dist/core.d.ts +0 -3
- package/dist/index.es.js +0 -142
- package/dist/index.js +0 -152
- package/dist/index.umd.js +0 -8
- package/dist/options.d.ts +0 -15
package/LICENSE
CHANGED
package/lib/core.d.ts
ADDED
package/lib/core.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { schema } from './schema.js';
|
|
2
|
+
import initials from 'initials';
|
|
3
|
+
const colors = {
|
|
4
|
+
amber: 'rgba(255, 179, 0, 1)',
|
|
5
|
+
blue: 'rgba(30, 136, 229, 1)',
|
|
6
|
+
blueGrey: 'rgba(84, 110, 122, 1)',
|
|
7
|
+
brown: 'rgba(109, 76, 65, 1)',
|
|
8
|
+
cyan: 'rgba(0, 172, 193, 1)',
|
|
9
|
+
deepOrange: 'rgba(244, 81, 30, 1)',
|
|
10
|
+
deepPurple: 'rgba(94, 53, 177, 1)',
|
|
11
|
+
green: 'rgba(67, 160, 71, 1)',
|
|
12
|
+
grey: 'rgba(117, 117, 117, 1)',
|
|
13
|
+
indigo: 'rgba(57, 73, 171, 1)',
|
|
14
|
+
lightBlue: 'rgba(3, 155, 229, 1)',
|
|
15
|
+
lightGreen: 'rgba(124, 179, 66, 1)',
|
|
16
|
+
lime: 'rgba(192, 202, 51, 1)',
|
|
17
|
+
orange: 'rgba(251, 140, 0, 1)',
|
|
18
|
+
pink: 'rgba(216, 27, 96, 1)',
|
|
19
|
+
purple: 'rgba(142, 36, 170, 1)',
|
|
20
|
+
red: 'rgba(229, 57, 53, 1)',
|
|
21
|
+
teal: 'rgba(0, 137, 123, 1)',
|
|
22
|
+
yellow: 'rgba(253, 216, 53, 1)',
|
|
23
|
+
};
|
|
24
|
+
export const style = {
|
|
25
|
+
meta: {
|
|
26
|
+
title: 'Initials',
|
|
27
|
+
creator: 'Florian Körner',
|
|
28
|
+
source: 'https://github.com/dicebear/dicebear',
|
|
29
|
+
license: {
|
|
30
|
+
name: 'CC0 1.0',
|
|
31
|
+
url: 'https://creativecommons.org/publicdomain/zero/1.0/',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
schema: schema,
|
|
35
|
+
create: ({ prng, options }) => {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f;
|
|
37
|
+
options.backgroundColor = (_a = options.backgroundColor) === null || _a === void 0 ? void 0 : _a.map((val) => { var _a; return (_a = colors[val]) !== null && _a !== void 0 ? _a : val; });
|
|
38
|
+
const fontFamily = (_c = (_b = options.fontFamily) === null || _b === void 0 ? void 0 : _b.join(', ')) !== null && _c !== void 0 ? _c : 'Arial, sans-serif';
|
|
39
|
+
const fontSize = (_d = options.fontSize) !== null && _d !== void 0 ? _d : 50;
|
|
40
|
+
const fontWeight = (_e = options.fontWeight) !== null && _e !== void 0 ? _e : 400;
|
|
41
|
+
const seedInitials = initials(prng.seed.trim())
|
|
42
|
+
.toLocaleUpperCase()
|
|
43
|
+
.slice(0, (_f = options.chars) !== null && _f !== void 0 ? _f : 2);
|
|
44
|
+
// prettier-ignore
|
|
45
|
+
const svg = [
|
|
46
|
+
`<text x="50%" y="50%" font-family="${fontFamily}" font-size="${fontSize}" fontWeight="${fontWeight}" fill="#FFF" text-anchor="middle" dy="${(fontSize * .356).toFixed(3)}">${seedInitials}</text>`,
|
|
47
|
+
].join('');
|
|
48
|
+
return {
|
|
49
|
+
attributes: {
|
|
50
|
+
viewBox: '0 0 100 100',
|
|
51
|
+
},
|
|
52
|
+
body: svg,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
package/{dist → lib}/index.d.ts
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* DiceBear Initials (@dicebear/initials)
|
|
3
|
-
*
|
|
4
|
-
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
|
|
5
|
-
* Copyright (c)
|
|
6
|
-
*/
|
|
7
|
-
declare let create: import("@dicebear/core").StyleCreate<import("./
|
|
8
|
-
export { create, meta, schema };
|
|
9
|
-
export
|
|
1
|
+
/*!
|
|
2
|
+
* DiceBear Initials (@dicebear/initials)
|
|
3
|
+
*
|
|
4
|
+
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
|
|
5
|
+
* Copyright (c) 2022 Florian Körner
|
|
6
|
+
*/
|
|
7
|
+
declare let create: import("@dicebear/core").StyleCreate<import("./types.js").Options>, meta: import("@dicebear/core").StyleMeta, schema: import("json-schema").JSONSchema7;
|
|
8
|
+
export { create, meta, schema };
|
|
9
|
+
export * from './types.js';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* DiceBear Initials (@dicebear/initials)
|
|
3
|
+
*
|
|
4
|
+
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
|
|
5
|
+
* Copyright (c) 2022 Florian Körner
|
|
6
|
+
*/
|
|
7
|
+
import { style } from './core.js';
|
|
8
|
+
let { create, meta, schema } = style;
|
|
9
|
+
export { create, meta, schema };
|
|
10
|
+
export * from './types.js';
|
package/lib/schema.d.ts
ADDED
package/lib/schema.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export const schema = {
|
|
2
|
+
title: 'Options',
|
|
3
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
4
|
+
properties: {
|
|
5
|
+
backgroundColor: {
|
|
6
|
+
type: 'array',
|
|
7
|
+
items: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
pattern: '^([0-9a-zA-Z]+|#[a-fA-F0-9]{3}|#[a-fA-F0-9]{4}|#[a-fA-F0-9]{6}|#[a-fA-F0-9]{8})$',
|
|
10
|
+
},
|
|
11
|
+
default: [
|
|
12
|
+
'amber',
|
|
13
|
+
'blue',
|
|
14
|
+
'blueGrey',
|
|
15
|
+
'brown',
|
|
16
|
+
'cyan',
|
|
17
|
+
'deepOrange',
|
|
18
|
+
'deepPurple',
|
|
19
|
+
'green',
|
|
20
|
+
'grey',
|
|
21
|
+
'indigo',
|
|
22
|
+
'lightBlue',
|
|
23
|
+
'lightGreen',
|
|
24
|
+
'lime',
|
|
25
|
+
'orange',
|
|
26
|
+
'pink',
|
|
27
|
+
'purple',
|
|
28
|
+
'red',
|
|
29
|
+
'teal',
|
|
30
|
+
'yellow',
|
|
31
|
+
],
|
|
32
|
+
examples: [
|
|
33
|
+
['amber'],
|
|
34
|
+
['blue'],
|
|
35
|
+
['blueGrey'],
|
|
36
|
+
['brown'],
|
|
37
|
+
['cyan'],
|
|
38
|
+
['deepOrange'],
|
|
39
|
+
['deepPurple'],
|
|
40
|
+
['green'],
|
|
41
|
+
['grey'],
|
|
42
|
+
['indigo'],
|
|
43
|
+
['lightBlue'],
|
|
44
|
+
['lightGreen'],
|
|
45
|
+
['lime'],
|
|
46
|
+
['orange'],
|
|
47
|
+
['pink'],
|
|
48
|
+
['purple'],
|
|
49
|
+
['red'],
|
|
50
|
+
['teal'],
|
|
51
|
+
['yellow'],
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
fontFamily: {
|
|
55
|
+
type: 'array',
|
|
56
|
+
uniqueItems: true,
|
|
57
|
+
minItems: 1,
|
|
58
|
+
items: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
pattern: '^[a-zA-Z0-9\\-\\s]+$',
|
|
61
|
+
},
|
|
62
|
+
default: ['Arial', 'sans-serif'],
|
|
63
|
+
examples: [
|
|
64
|
+
['Arial'],
|
|
65
|
+
['Verdana'],
|
|
66
|
+
['Helvetica'],
|
|
67
|
+
['Tahoma'],
|
|
68
|
+
['Trebuchet MS'],
|
|
69
|
+
['Times New Roman'],
|
|
70
|
+
['Georgia'],
|
|
71
|
+
['Garamond'],
|
|
72
|
+
['Courier New'],
|
|
73
|
+
['Brush Script MT'],
|
|
74
|
+
['sans-serif'],
|
|
75
|
+
['serif'],
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
fontSize: {
|
|
79
|
+
type: 'integer',
|
|
80
|
+
minimum: 1,
|
|
81
|
+
maximum: 100,
|
|
82
|
+
default: 50,
|
|
83
|
+
examples: [25, 50, 75, 100],
|
|
84
|
+
},
|
|
85
|
+
chars: {
|
|
86
|
+
type: 'number',
|
|
87
|
+
minimum: 0,
|
|
88
|
+
maximum: 2,
|
|
89
|
+
default: 2,
|
|
90
|
+
examples: [1, 2],
|
|
91
|
+
},
|
|
92
|
+
fontWeight: {
|
|
93
|
+
type: 'number',
|
|
94
|
+
default: 400,
|
|
95
|
+
enum: [100, 200, 300, 400, 500, 600, 700, 800, 900],
|
|
96
|
+
examples: [100, 200, 300, 400, 500, 600, 700, 800, 900],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
additionalProperties: false,
|
|
100
|
+
};
|
package/lib/types.d.ts
ADDED
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,61 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/initials",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.20",
|
|
4
4
|
"description": "Initials avatar style for DiceBear",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"dicebear"
|
|
7
|
-
"avatar",
|
|
8
|
-
"identicon",
|
|
9
|
-
"svg",
|
|
10
|
-
"sprites",
|
|
11
|
-
"initials"
|
|
6
|
+
"dicebear"
|
|
12
7
|
],
|
|
13
|
-
"homepage": "https://github.com/dicebear/dicebear/tree/master/packages/@dicebear/initials",
|
|
14
8
|
"bugs": {
|
|
15
9
|
"url": "https://github.com/dicebear/dicebear/issues"
|
|
16
10
|
},
|
|
17
11
|
"repository": {
|
|
18
12
|
"type": "git",
|
|
19
|
-
"url": "git
|
|
20
|
-
"directory": "/packages/@dicebear/initials"
|
|
13
|
+
"url": "git+https://github.com/dicebear/dicebear.git"
|
|
21
14
|
},
|
|
22
15
|
"license": "MIT",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"module": "dist/index.es.js",
|
|
27
|
-
"browser": "dist/index.umd.js",
|
|
28
|
-
"types": "dist/index.d.ts",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": "./lib/index.js",
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
29
19
|
"files": [
|
|
30
20
|
"LICENSE",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
21
|
+
"lib",
|
|
22
|
+
"README.md"
|
|
33
23
|
],
|
|
34
24
|
"scripts": {
|
|
35
|
-
"
|
|
25
|
+
"prebuild": "del-cli lib",
|
|
26
|
+
"build": "tsc",
|
|
36
27
|
"prepublishOnly": "npm run build",
|
|
37
|
-
"
|
|
38
|
-
"build": "dicebear-project build DiceBear.Initials"
|
|
28
|
+
"test": "uvu tests"
|
|
39
29
|
},
|
|
40
30
|
"dependencies": {
|
|
41
|
-
"initials": "^3.
|
|
31
|
+
"initials": "^3.1.2"
|
|
42
32
|
},
|
|
43
33
|
"devDependencies": {
|
|
44
|
-
"@dicebear/core": "^5.0.0-alpha.
|
|
45
|
-
"@tsconfig/recommended": "^1.0.
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"jest": "^26.6.3",
|
|
50
|
-
"shx": "^0.3.3",
|
|
51
|
-
"ts-jest": "^26.5.4",
|
|
52
|
-
"typescript": "^4.2.3"
|
|
34
|
+
"@dicebear/core": "^5.0.0-alpha.20",
|
|
35
|
+
"@tsconfig/recommended": "^1.0.1",
|
|
36
|
+
"del-cli": "^4.0.1",
|
|
37
|
+
"typescript": "^4.6.3",
|
|
38
|
+
"uvu": "^0.5.3"
|
|
53
39
|
},
|
|
54
40
|
"peerDependencies": {
|
|
55
|
-
"@dicebear/core": "^5.0.0-alpha.
|
|
41
|
+
"@dicebear/core": "^5.0.0-alpha.6"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
56
45
|
},
|
|
57
46
|
"publishConfig": {
|
|
58
47
|
"access": "public"
|
|
59
48
|
},
|
|
60
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "6b1c2bd64294365be21d0a133a362ede5ed62b5a"
|
|
61
50
|
}
|
package/dist/core.d.ts
DELETED
package/dist/index.es.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { utils } from '@dicebear/core';
|
|
2
|
-
import initials from 'initials';
|
|
3
|
-
|
|
4
|
-
var title = "Options";
|
|
5
|
-
var $schema = "http://json-schema.org/draft-07/schema#";
|
|
6
|
-
var properties = {
|
|
7
|
-
backgroundColor: {
|
|
8
|
-
title: "Background Color",
|
|
9
|
-
type: "array",
|
|
10
|
-
items: {
|
|
11
|
-
anyOf: [
|
|
12
|
-
{
|
|
13
|
-
type: "string",
|
|
14
|
-
pattern: "^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
type: "string",
|
|
18
|
-
pattern: "^[0-9a-zA-Z]+$"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
"default": [
|
|
23
|
-
"amber",
|
|
24
|
-
"blue",
|
|
25
|
-
"blueGrey",
|
|
26
|
-
"brown",
|
|
27
|
-
"cyan",
|
|
28
|
-
"deepOrange",
|
|
29
|
-
"deepPurple",
|
|
30
|
-
"green",
|
|
31
|
-
"grey",
|
|
32
|
-
"indigo",
|
|
33
|
-
"lightBlue",
|
|
34
|
-
"lightGreen",
|
|
35
|
-
"lime",
|
|
36
|
-
"orange",
|
|
37
|
-
"pink",
|
|
38
|
-
"purple",
|
|
39
|
-
"red",
|
|
40
|
-
"teal",
|
|
41
|
-
"yellow"
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
fontSize: {
|
|
45
|
-
title: "Font Size",
|
|
46
|
-
type: "integer",
|
|
47
|
-
minimum: 1,
|
|
48
|
-
maximum: 100,
|
|
49
|
-
"default": 50
|
|
50
|
-
},
|
|
51
|
-
chars: {
|
|
52
|
-
title: "Chars",
|
|
53
|
-
type: "number",
|
|
54
|
-
minimum: 0,
|
|
55
|
-
maximum: 2,
|
|
56
|
-
"default": 2
|
|
57
|
-
},
|
|
58
|
-
bold: {
|
|
59
|
-
title: "Bold",
|
|
60
|
-
type: "boolean"
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
var additionalProperties = false;
|
|
64
|
-
var schema$1 = {
|
|
65
|
-
title: title,
|
|
66
|
-
$schema: $schema,
|
|
67
|
-
properties: properties,
|
|
68
|
-
additionalProperties: additionalProperties
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const colors = {
|
|
72
|
-
amber: 'rgba(255, 179, 0, 1)',
|
|
73
|
-
blue: 'rgba(30, 136, 229, 1)',
|
|
74
|
-
blueGrey: 'rgba(84, 110, 122, 1)',
|
|
75
|
-
brown: 'rgba(109, 76, 65, 1)',
|
|
76
|
-
cyan: 'rgba(0, 172, 193, 1)',
|
|
77
|
-
deepOrange: 'rgba(244, 81, 30, 1)',
|
|
78
|
-
deepPurple: 'rgba(94, 53, 177, 1)',
|
|
79
|
-
green: 'rgba(67, 160, 71, 1)',
|
|
80
|
-
grey: 'rgba(117, 117, 117, 1)',
|
|
81
|
-
indigo: 'rgba(57, 73, 171, 1)',
|
|
82
|
-
lightBlue: 'rgba(3, 155, 229, 1)',
|
|
83
|
-
lightGreen: 'rgba(124, 179, 66, 1)',
|
|
84
|
-
lime: 'rgba(192, 202, 51, 1)',
|
|
85
|
-
orange: 'rgba(251, 140, 0, 1)',
|
|
86
|
-
pink: 'rgba(216, 27, 96, 1)',
|
|
87
|
-
purple: 'rgba(142, 36, 170, 1)',
|
|
88
|
-
red: 'rgba(229, 57, 53, 1)',
|
|
89
|
-
teal: 'rgba(0, 137, 123, 1)',
|
|
90
|
-
yellow: 'rgba(253, 216, 53, 1)'
|
|
91
|
-
};
|
|
92
|
-
const style = {
|
|
93
|
-
meta: {
|
|
94
|
-
title: 'Initials',
|
|
95
|
-
creator: 'Florian Körner',
|
|
96
|
-
source: 'https://github.com/dicebear/dicebear',
|
|
97
|
-
license: {
|
|
98
|
-
name: 'CC0 1.0',
|
|
99
|
-
url: 'https://creativecommons.org/publicdomain/zero/1.0/'
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
schema: schema$1,
|
|
103
|
-
create: _ref => {
|
|
104
|
-
var _options$backgroundCo, _options$fontSize, _options$chars;
|
|
105
|
-
|
|
106
|
-
let {
|
|
107
|
-
prng,
|
|
108
|
-
options
|
|
109
|
-
} = _ref;
|
|
110
|
-
let defaults = utils.schema.defaults(schema$1);
|
|
111
|
-
options.backgroundColor = (_options$backgroundCo = options.backgroundColor) === null || _options$backgroundCo === void 0 ? void 0 : _options$backgroundCo.map(val => {
|
|
112
|
-
var _colors$val;
|
|
113
|
-
|
|
114
|
-
return (_colors$val = colors[val]) !== null && _colors$val !== void 0 ? _colors$val : val;
|
|
115
|
-
});
|
|
116
|
-
let fontFamily = 'Arial,sans-serif';
|
|
117
|
-
let fontSize = ((_options$fontSize = options.fontSize) !== null && _options$fontSize !== void 0 ? _options$fontSize : defaults.fontSize) / 100;
|
|
118
|
-
let seedInitials = initials(prng.seed.trim()).toLocaleUpperCase().slice(0, (_options$chars = options.chars) !== null && _options$chars !== void 0 ? _options$chars : defaults.chars); // prettier-ignore
|
|
119
|
-
|
|
120
|
-
let svg = ["<text x=\"50%\" y=\"50%\" style=\"".concat(options.bold ? 'font-weight: bold;' : '', " font-family: ").concat(fontFamily, "; font-size: ").concat(fontSize, "px\" fill=\"#FFF\" text-anchor=\"middle\" dy=\"").concat((fontSize * .356).toFixed(3), "\">").concat(seedInitials, "</text>")].join('');
|
|
121
|
-
return {
|
|
122
|
-
attributes: {
|
|
123
|
-
viewBox: '0 0 1 1'
|
|
124
|
-
},
|
|
125
|
-
body: svg
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
/*!
|
|
131
|
-
* DiceBear Initials (@dicebear/initials)
|
|
132
|
-
*
|
|
133
|
-
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
|
|
134
|
-
* Copyright (c) 2021 Florian Körner
|
|
135
|
-
*/
|
|
136
|
-
let {
|
|
137
|
-
create,
|
|
138
|
-
meta,
|
|
139
|
-
schema
|
|
140
|
-
} = style;
|
|
141
|
-
|
|
142
|
-
export { create, meta, schema };
|
package/dist/index.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@dicebear/core');
|
|
6
|
-
var initials = require('initials');
|
|
7
|
-
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var initials__default = /*#__PURE__*/_interopDefaultLegacy(initials);
|
|
11
|
-
|
|
12
|
-
var title = "Options";
|
|
13
|
-
var $schema = "http://json-schema.org/draft-07/schema#";
|
|
14
|
-
var properties = {
|
|
15
|
-
backgroundColor: {
|
|
16
|
-
title: "Background Color",
|
|
17
|
-
type: "array",
|
|
18
|
-
items: {
|
|
19
|
-
anyOf: [
|
|
20
|
-
{
|
|
21
|
-
type: "string",
|
|
22
|
-
pattern: "^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
type: "string",
|
|
26
|
-
pattern: "^[0-9a-zA-Z]+$"
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
},
|
|
30
|
-
"default": [
|
|
31
|
-
"amber",
|
|
32
|
-
"blue",
|
|
33
|
-
"blueGrey",
|
|
34
|
-
"brown",
|
|
35
|
-
"cyan",
|
|
36
|
-
"deepOrange",
|
|
37
|
-
"deepPurple",
|
|
38
|
-
"green",
|
|
39
|
-
"grey",
|
|
40
|
-
"indigo",
|
|
41
|
-
"lightBlue",
|
|
42
|
-
"lightGreen",
|
|
43
|
-
"lime",
|
|
44
|
-
"orange",
|
|
45
|
-
"pink",
|
|
46
|
-
"purple",
|
|
47
|
-
"red",
|
|
48
|
-
"teal",
|
|
49
|
-
"yellow"
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
fontSize: {
|
|
53
|
-
title: "Font Size",
|
|
54
|
-
type: "integer",
|
|
55
|
-
minimum: 1,
|
|
56
|
-
maximum: 100,
|
|
57
|
-
"default": 50
|
|
58
|
-
},
|
|
59
|
-
chars: {
|
|
60
|
-
title: "Chars",
|
|
61
|
-
type: "number",
|
|
62
|
-
minimum: 0,
|
|
63
|
-
maximum: 2,
|
|
64
|
-
"default": 2
|
|
65
|
-
},
|
|
66
|
-
bold: {
|
|
67
|
-
title: "Bold",
|
|
68
|
-
type: "boolean"
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var additionalProperties = false;
|
|
72
|
-
var schema$1 = {
|
|
73
|
-
title: title,
|
|
74
|
-
$schema: $schema,
|
|
75
|
-
properties: properties,
|
|
76
|
-
additionalProperties: additionalProperties
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const colors = {
|
|
80
|
-
amber: 'rgba(255, 179, 0, 1)',
|
|
81
|
-
blue: 'rgba(30, 136, 229, 1)',
|
|
82
|
-
blueGrey: 'rgba(84, 110, 122, 1)',
|
|
83
|
-
brown: 'rgba(109, 76, 65, 1)',
|
|
84
|
-
cyan: 'rgba(0, 172, 193, 1)',
|
|
85
|
-
deepOrange: 'rgba(244, 81, 30, 1)',
|
|
86
|
-
deepPurple: 'rgba(94, 53, 177, 1)',
|
|
87
|
-
green: 'rgba(67, 160, 71, 1)',
|
|
88
|
-
grey: 'rgba(117, 117, 117, 1)',
|
|
89
|
-
indigo: 'rgba(57, 73, 171, 1)',
|
|
90
|
-
lightBlue: 'rgba(3, 155, 229, 1)',
|
|
91
|
-
lightGreen: 'rgba(124, 179, 66, 1)',
|
|
92
|
-
lime: 'rgba(192, 202, 51, 1)',
|
|
93
|
-
orange: 'rgba(251, 140, 0, 1)',
|
|
94
|
-
pink: 'rgba(216, 27, 96, 1)',
|
|
95
|
-
purple: 'rgba(142, 36, 170, 1)',
|
|
96
|
-
red: 'rgba(229, 57, 53, 1)',
|
|
97
|
-
teal: 'rgba(0, 137, 123, 1)',
|
|
98
|
-
yellow: 'rgba(253, 216, 53, 1)'
|
|
99
|
-
};
|
|
100
|
-
const style = {
|
|
101
|
-
meta: {
|
|
102
|
-
title: 'Initials',
|
|
103
|
-
creator: 'Florian Körner',
|
|
104
|
-
source: 'https://github.com/dicebear/dicebear',
|
|
105
|
-
license: {
|
|
106
|
-
name: 'CC0 1.0',
|
|
107
|
-
url: 'https://creativecommons.org/publicdomain/zero/1.0/'
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
schema: schema$1,
|
|
111
|
-
create: _ref => {
|
|
112
|
-
var _options$backgroundCo, _options$fontSize, _options$chars;
|
|
113
|
-
|
|
114
|
-
let {
|
|
115
|
-
prng,
|
|
116
|
-
options
|
|
117
|
-
} = _ref;
|
|
118
|
-
let defaults = core.utils.schema.defaults(schema$1);
|
|
119
|
-
options.backgroundColor = (_options$backgroundCo = options.backgroundColor) === null || _options$backgroundCo === void 0 ? void 0 : _options$backgroundCo.map(val => {
|
|
120
|
-
var _colors$val;
|
|
121
|
-
|
|
122
|
-
return (_colors$val = colors[val]) !== null && _colors$val !== void 0 ? _colors$val : val;
|
|
123
|
-
});
|
|
124
|
-
let fontFamily = 'Arial,sans-serif';
|
|
125
|
-
let fontSize = ((_options$fontSize = options.fontSize) !== null && _options$fontSize !== void 0 ? _options$fontSize : defaults.fontSize) / 100;
|
|
126
|
-
let seedInitials = initials__default["default"](prng.seed.trim()).toLocaleUpperCase().slice(0, (_options$chars = options.chars) !== null && _options$chars !== void 0 ? _options$chars : defaults.chars); // prettier-ignore
|
|
127
|
-
|
|
128
|
-
let svg = ["<text x=\"50%\" y=\"50%\" style=\"".concat(options.bold ? 'font-weight: bold;' : '', " font-family: ").concat(fontFamily, "; font-size: ").concat(fontSize, "px\" fill=\"#FFF\" text-anchor=\"middle\" dy=\"").concat((fontSize * .356).toFixed(3), "\">").concat(seedInitials, "</text>")].join('');
|
|
129
|
-
return {
|
|
130
|
-
attributes: {
|
|
131
|
-
viewBox: '0 0 1 1'
|
|
132
|
-
},
|
|
133
|
-
body: svg
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
/*!
|
|
139
|
-
* DiceBear Initials (@dicebear/initials)
|
|
140
|
-
*
|
|
141
|
-
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
|
|
142
|
-
* Copyright (c) 2021 Florian Körner
|
|
143
|
-
*/
|
|
144
|
-
let {
|
|
145
|
-
create,
|
|
146
|
-
meta,
|
|
147
|
-
schema
|
|
148
|
-
} = style;
|
|
149
|
-
|
|
150
|
-
exports.create = create;
|
|
151
|
-
exports.meta = meta;
|
|
152
|
-
exports.schema = schema;
|
package/dist/index.umd.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@dicebear/core")):"function"==typeof define&&define.amd?define(["exports","@dicebear/core"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).DiceBear=e.DiceBear||{},e.DiceBear.Initials={}),e.DiceBear)}(this,(function(e,t){"use strict";var n={title:"Options",$schema:"http://json-schema.org/draft-07/schema#",properties:{backgroundColor:{title:"Background Color",type:"array",items:{anyOf:[{type:"string",pattern:"^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"},{type:"string",pattern:"^[0-9a-zA-Z]+$"}]},default:["amber","blue","blueGrey","brown","cyan","deepOrange","deepPurple","green","grey","indigo","lightBlue","lightGreen","lime","orange","pink","purple","red","teal","yellow"]},fontSize:{title:"Font Size",type:"integer",minimum:1,maximum:100,default:50},chars:{title:"Chars",type:"number",minimum:0,maximum:2,default:2},bold:{title:"Bold",type:"boolean"}},additionalProperties:!1},r=s;s.addTo=function(e,t){return e?"string"==typeof e?function(e,t){return b(h(e,t))}(e,C(t)):function(e,t){return d(e,t).map(b)}(e,C(t)):""},s.parse=function(e,t){return e?"string"==typeof e?h(e,C(t)):d(e,C(t)):{}},s.find=s;var i=" -\\/:-@\\[-`\\{-\\~",a=/^[A-Z]+$/,l=/\(([^)]+)\)/,o=/^[^\s]+@[^\s]+$/,u=/@[^\s]+/,c=/[\w._-]+@[\w.-]+[\w]/g,f=new RegExp("(^|["+i+"])[^"+i+"]","g"),g=new RegExp("["+i+"]","g");function s(e,t){return e?"string"==typeof e?p(e,C(t)):m(e,C(t)):""}function p(e,t){var n,r,i,a=t.length||2;if(i=v(e,t))return i;if(!(e=y(e)))return"";if((n=e.match(f).map((function(e){return e[e.length-1]}))).length<2)return e.length>a?e.substr(0,a):e;if((r=n.join("")).length>=a)return r;for(var l=w(e),o=0;o<l.length;o++)if(l[o].length>=a)return l[o]}function m(e,t){var n,r,i,a=[],l={},o={},u={},c=t.length||2;e.forEach((function(e){if(e||(e=""),!u[e])if(e.length<c)u[e]=[e];else{if(r=v(e,t))return l[r]=1,void(u[e]=[r]);i=w(e).filter((function(e){return e.length===c&&(l[e]&&(o[e]=1),l[e]=1,!0)})),u[e]=i}}));var f=[];for(var g in u)f.unshift(g);for(var s=f.length,p=0;p<s;p++){i=u[f[p]],a.push(i);for(var h=0;h<i.length;h++)o[i[h]]>0&&(o[i[h]]--,i.splice(h,1))}return n=a.map((function(e){return e.length})),0===n.length?e:0===Math.min.apply(null,n)?(t.length++,m(e,t)):e.map((function(e){return u[e][0]}))}function h(e,t){var n,r,i,o={};return e?((n=v(e,t))&&(e=(e=e.replace(a,"")).replace(l,"")),t.initials&&(n=t.initials),n||(n=p(e,t)),null!=(i=e.match(c))&&(r=i.pop()),r&&(e=e.replace(r,"")).trim()==="<"+r+">"&&(e="",n||(n=p(r,t))),(e=e.replace(g," ").trim())&&(o.name=e),n&&(o.initials=n),r&&(o.email=r),o):{}}function d(e,t){var n=m(e,t);return e.map((function(e,r){return t.existing[e]=n[r],h(e,t)}))}function b(e){return e.name||e.email?e.email?e.name?e.name+" ("+e.initials+") <"+e.email+">":e.email+" ("+e.initials+")":e.name+" ("+e.initials+")":e.initials}function y(e){return e=(e=o.test(e)?e.replace(u,""):e.replace(c,"")).replace(g," ").trim()}function v(e,t){var n;return t.existing[e]?t.existing[e]:a.test(e)?e:null!=(n=e.match(l))?n.pop():void 0}var x={};function w(e){var t,n=[];return e=y(e),x[e]?x[e].slice(0):(t=e.split(" ").map(B),n=(n=F(t)).sort((function(e,t){return e.length-t.length||n.indexOf(e)-n.indexOf(t)})),x[e]=n,n.slice(0))}function F(e){var t,n,r=e.shift();return e.length>0?(n=[],t=F(e),r.forEach((function(e){t.forEach((function(t){n.push(e+t)}))})),n):r}function B(e){for(var t=[];e.length;)t.unshift(e),e=e.substr(0,e.length-1);return t}function C(e){return e||(e={length:2}),"number"==typeof e&&(e={length:e}),e.length=Math.max(e.length||0,2),e.existing=e.existing||{},e}var z=r;const A={amber:"rgba(255, 179, 0, 1)",blue:"rgba(30, 136, 229, 1)",blueGrey:"rgba(84, 110, 122, 1)",brown:"rgba(109, 76, 65, 1)",cyan:"rgba(0, 172, 193, 1)",deepOrange:"rgba(244, 81, 30, 1)",deepPurple:"rgba(94, 53, 177, 1)",green:"rgba(67, 160, 71, 1)",grey:"rgba(117, 117, 117, 1)",indigo:"rgba(57, 73, 171, 1)",lightBlue:"rgba(3, 155, 229, 1)",lightGreen:"rgba(124, 179, 66, 1)",lime:"rgba(192, 202, 51, 1)",orange:"rgba(251, 140, 0, 1)",pink:"rgba(216, 27, 96, 1)",purple:"rgba(142, 36, 170, 1)",red:"rgba(229, 57, 53, 1)",teal:"rgba(0, 137, 123, 1)",yellow:"rgba(253, 216, 53, 1)"},O={meta:{title:"Initials",creator:"Florian Körner",source:"https://github.com/dicebear/dicebear",license:{name:"CC0 1.0",url:"https://creativecommons.org/publicdomain/zero/1.0/"}},schema:n,create:e=>{var r,i,a;let{prng:l,options:o}=e,u=t.utils.schema.defaults(n);o.backgroundColor=null===(r=o.backgroundColor)||void 0===r?void 0:r.map((e=>{var t;return null!==(t=A[e])&&void 0!==t?t:e}));let c=(null!==(i=o.fontSize)&&void 0!==i?i:u.fontSize)/100,f=z(l.seed.trim()).toLocaleUpperCase().slice(0,null!==(a=o.chars)&&void 0!==a?a:u.chars);return{attributes:{viewBox:"0 0 1 1"},body:['<text x="50%" y="50%" style="'.concat(o.bold?"font-weight: bold;":""," font-family: ").concat("Arial,sans-serif","; font-size: ").concat(c,'px" fill="#FFF" text-anchor="middle" dy="').concat((.356*c).toFixed(3),'">').concat(f,"</text>")].join("")}}};
|
|
2
|
-
/*!
|
|
3
|
-
* DiceBear Initials (@dicebear/initials)
|
|
4
|
-
*
|
|
5
|
-
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
|
|
6
|
-
* Copyright (c) 2021 Florian Körner
|
|
7
|
-
*/
|
|
8
|
-
let{create:k,meta:j,schema:E}=O;e.create=k,e.meta=j,e.schema=E,Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/dist/options.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
3
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
5
|
-
*/
|
|
6
|
-
export declare type BackgroundColor = (string | string)[];
|
|
7
|
-
export declare type FontSize = number;
|
|
8
|
-
export declare type Chars = number;
|
|
9
|
-
export declare type Bold = boolean;
|
|
10
|
-
export interface Options {
|
|
11
|
-
backgroundColor?: BackgroundColor;
|
|
12
|
-
fontSize?: FontSize;
|
|
13
|
-
chars?: Chars;
|
|
14
|
-
bold?: Bold;
|
|
15
|
-
}
|