@dicebear/micah 5.0.3 → 5.1.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.
@@ -5,12 +5,12 @@
5
5
  * File: https://www.figma.com/file/YHb4ShTgmO8Lqhkz1plLfL
6
6
  */
7
7
  export function onPreCreate({ prng, options }) {
8
- var _a, _b;
8
+ var _a;
9
9
  // Prevent baseColor from being used a second time if possible.
10
- options.baseColor = options.baseColor && options.baseColor.length > 0 ? [(_a = prng.pick(options.baseColor)) !== null && _a !== void 0 ? _a : 'transparent'] : [];
10
+ options.baseColor = options.baseColor && options.baseColor.length > 0 ? [prng.pick(options.baseColor, 'transparent')] : [];
11
11
  for (const colorName of ['eyebrows', 'hair', 'eyes', 'nose', 'ears', 'shirt', 'earrings', 'glasses', 'facialHair']) {
12
12
  // @ts-ignore
13
- const colorOption = (_b = options[`${colorName}Color`]) !== null && _b !== void 0 ? _b : [];
13
+ const colorOption = (_a = options[`${colorName}Color`]) !== null && _a !== void 0 ? _a : [];
14
14
  const index = colorOption.indexOf(options.baseColor[0]);
15
15
  if (colorOption.length > 1 && index > -1) {
16
16
  colorOption.splice(index, 1);
package/lib/index.js CHANGED
@@ -31,6 +31,16 @@ export const create = ({ prng, options }) => {
31
31
  'shape-rendering': 'auto'
32
32
  },
33
33
  body: `<g transform="translate(80 23)">${(_b = (_a = components.base) === null || _a === void 0 ? void 0 : _a.value(components, colors)) !== null && _b !== void 0 ? _b : ''}</g><g transform="translate(170 183)">${(_d = (_c = components.mouth) === null || _c === void 0 ? void 0 : _c.value(components, colors)) !== null && _d !== void 0 ? _d : ''}</g><g transform="translate(110 102)">${(_f = (_e = components.eyebrows) === null || _e === void 0 ? void 0 : _e.value(components, colors)) !== null && _f !== void 0 ? _f : ''}</g><g transform="translate(49 11)">${(_h = (_g = components.hair) === null || _g === void 0 ? void 0 : _g.value(components, colors)) !== null && _h !== void 0 ? _h : ''}</g><g transform="translate(142 119)">${(_k = (_j = components.eyes) === null || _j === void 0 ? void 0 : _j.value(components, colors)) !== null && _k !== void 0 ? _k : ''}</g><g transform="rotate(-8 1149.44 -1186.92)">${(_m = (_l = components.nose) === null || _l === void 0 ? void 0 : _l.value(components, colors)) !== null && _m !== void 0 ? _m : ''}</g><g transform="translate(84 154)">${(_p = (_o = components.ears) === null || _o === void 0 ? void 0 : _o.value(components, colors)) !== null && _p !== void 0 ? _p : ''}</g><g transform="translate(53 272)">${(_r = (_q = components.shirt) === null || _q === void 0 ? void 0 : _q.value(components, colors)) !== null && _r !== void 0 ? _r : ''}</g>`,
34
+ extra: () => ({
35
+ ...Object.entries(components).reduce((acc, [key, value]) => {
36
+ acc[key] = value === null || value === void 0 ? void 0 : value.name;
37
+ return acc;
38
+ }, {}),
39
+ ...Object.entries(colors).reduce((acc, [key, value]) => {
40
+ acc[`${key}Color`] = value;
41
+ return acc;
42
+ }, {}),
43
+ }),
34
44
  };
35
45
  };
36
46
  export { schema } from './schema.js';
@@ -5,8 +5,5 @@
5
5
  * File: https://www.figma.com/file/YHb4ShTgmO8Lqhkz1plLfL
6
6
  */
7
7
  export function convertColor(color) {
8
- if ('transparent' === color) {
9
- return color;
10
- }
11
- return `#${color}`;
8
+ return 'transparent' === color ? color : `#${color}`;
12
9
  }
@@ -6,18 +6,18 @@
6
6
  */
7
7
  import { convertColor } from './convertColor.js';
8
8
  export function getColors({ prng, options }) {
9
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
9
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
10
10
  return {
11
- 'base': convertColor((_b = prng.pick((_a = options.baseColor) !== null && _a !== void 0 ? _a : [])) !== null && _b !== void 0 ? _b : 'transparent'),
12
- 'earring': convertColor((_d = prng.pick((_c = options.earringColor) !== null && _c !== void 0 ? _c : [])) !== null && _d !== void 0 ? _d : 'transparent'),
13
- 'eyeShadow': convertColor((_f = prng.pick((_e = options.eyeShadowColor) !== null && _e !== void 0 ? _e : [])) !== null && _f !== void 0 ? _f : 'transparent'),
14
- 'eyebrows': convertColor((_h = prng.pick((_g = options.eyebrowsColor) !== null && _g !== void 0 ? _g : [])) !== null && _h !== void 0 ? _h : 'transparent'),
15
- 'facialHair': convertColor((_k = prng.pick((_j = options.facialHairColor) !== null && _j !== void 0 ? _j : [])) !== null && _k !== void 0 ? _k : 'transparent'),
16
- 'glasses': convertColor((_m = prng.pick((_l = options.glassesColor) !== null && _l !== void 0 ? _l : [])) !== null && _m !== void 0 ? _m : 'transparent'),
17
- 'hair': convertColor((_p = prng.pick((_o = options.hairColor) !== null && _o !== void 0 ? _o : [])) !== null && _p !== void 0 ? _p : 'transparent'),
18
- 'mouth': convertColor((_r = prng.pick((_q = options.mouthColor) !== null && _q !== void 0 ? _q : [])) !== null && _r !== void 0 ? _r : 'transparent'),
19
- 'shirt': convertColor((_t = prng.pick((_s = options.shirtColor) !== null && _s !== void 0 ? _s : [])) !== null && _t !== void 0 ? _t : 'transparent'),
20
- 'eyes': convertColor((_v = prng.pick((_u = options.eyesColor) !== null && _u !== void 0 ? _u : [])) !== null && _v !== void 0 ? _v : 'transparent'),
11
+ 'base': convertColor(prng.pick((_a = options.baseColor) !== null && _a !== void 0 ? _a : [], 'transparent')),
12
+ 'earring': convertColor(prng.pick((_b = options.earringColor) !== null && _b !== void 0 ? _b : [], 'transparent')),
13
+ 'eyeShadow': convertColor(prng.pick((_c = options.eyeShadowColor) !== null && _c !== void 0 ? _c : [], 'transparent')),
14
+ 'eyebrows': convertColor(prng.pick((_d = options.eyebrowsColor) !== null && _d !== void 0 ? _d : [], 'transparent')),
15
+ 'facialHair': convertColor(prng.pick((_e = options.facialHairColor) !== null && _e !== void 0 ? _e : [], 'transparent')),
16
+ 'glasses': convertColor(prng.pick((_f = options.glassesColor) !== null && _f !== void 0 ? _f : [], 'transparent')),
17
+ 'hair': convertColor(prng.pick((_g = options.hairColor) !== null && _g !== void 0 ? _g : [], 'transparent')),
18
+ 'mouth': convertColor(prng.pick((_h = options.mouthColor) !== null && _h !== void 0 ? _h : [], 'transparent')),
19
+ 'shirt': convertColor(prng.pick((_j = options.shirtColor) !== null && _j !== void 0 ? _j : [], 'transparent')),
20
+ 'eyes': convertColor(prng.pick((_k = options.eyesColor) !== null && _k !== void 0 ? _k : [], 'transparent')),
21
21
  };
22
22
  }
23
23
  ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dicebear/micah",
3
- "version": "5.0.3",
3
+ "version": "5.1.0",
4
4
  "description": "Avatar style for DiceBear",
5
5
  "keywords": [
6
6
  "dicebear"
@@ -29,7 +29,7 @@
29
29
  "test": "uvu tests"
30
30
  },
31
31
  "devDependencies": {
32
- "@dicebear/core": "^5.0.3",
32
+ "@dicebear/core": "^5.1.0",
33
33
  "@tsconfig/recommended": "^1.0.1",
34
34
  "del-cli": "^4.0.1",
35
35
  "typescript": "^4.6.3",
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "14f86eb4ad8c481902d505c838c26420370d232c"
47
+ "gitHead": "4f9e4686aa33809026d6ce25c4a5f2d0750d59f4"
48
48
  }