@pezkuwi/ui-shared 3.16.7 → 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.
Files changed (182) hide show
  1. package/package.json +308 -9
  2. package/build/README.md +0 -3
  3. package/build/bundle.js +0 -2
  4. package/build/cjs/bundle.d.ts +0 -2
  5. package/build/cjs/bundle.js +0 -7
  6. package/build/cjs/icons/beachball/colors.js +0 -16
  7. package/build/cjs/icons/beachball/container.js +0 -22
  8. package/build/cjs/icons/beachball/defaults.js +0 -8
  9. package/build/cjs/icons/beachball/demo.js +0 -21
  10. package/build/cjs/icons/beachball/index.js +0 -24
  11. package/build/cjs/icons/beachball/seeder.js +0 -21
  12. package/build/cjs/icons/beachball/shape/circle.js +0 -16
  13. package/build/cjs/icons/beachball/shape/square.js +0 -19
  14. package/build/cjs/icons/beachball/svg/circle.js +0 -11
  15. package/build/cjs/icons/beachball/svg/element.js +0 -12
  16. package/build/cjs/icons/beachball/svg/rect.js +0 -10
  17. package/build/cjs/icons/beachball/svg/svg.js +0 -7
  18. package/build/cjs/icons/beachball/types.js +0 -2
  19. package/build/cjs/icons/index.js +0 -7
  20. package/build/cjs/icons/polkadot.js +0 -116
  21. package/build/cjs/icons/types.js +0 -2
  22. package/build/cjs/index.js +0 -5
  23. package/build/cjs/packageDetect.js +0 -5
  24. package/build/cjs/packageInfo.js +0 -4
  25. package/build/icons/beachball/colors.d.ts +0 -2
  26. package/build/icons/beachball/colors.js +0 -13
  27. package/build/icons/beachball/container.d.ts +0 -1
  28. package/build/icons/beachball/container.js +0 -19
  29. package/build/icons/beachball/defaults.d.ts +0 -2
  30. package/build/icons/beachball/defaults.js +0 -5
  31. package/build/icons/beachball/demo.d.ts +0 -1
  32. package/build/icons/beachball/demo.js +0 -19
  33. package/build/icons/beachball/index.d.ts +0 -2
  34. package/build/icons/beachball/index.js +0 -21
  35. package/build/icons/beachball/seeder.d.ts +0 -2
  36. package/build/icons/beachball/seeder.js +0 -18
  37. package/build/icons/beachball/shape/circle.d.ts +0 -2
  38. package/build/icons/beachball/shape/circle.js +0 -13
  39. package/build/icons/beachball/shape/square.d.ts +0 -2
  40. package/build/icons/beachball/shape/square.js +0 -16
  41. package/build/icons/beachball/svg/circle.d.ts +0 -1
  42. package/build/icons/beachball/svg/circle.js +0 -8
  43. package/build/icons/beachball/svg/element.d.ts +0 -1
  44. package/build/icons/beachball/svg/element.js +0 -9
  45. package/build/icons/beachball/svg/rect.d.ts +0 -1
  46. package/build/icons/beachball/svg/rect.js +0 -7
  47. package/build/icons/beachball/svg/svg.d.ts +0 -1
  48. package/build/icons/beachball/svg/svg.js +0 -4
  49. package/build/icons/beachball/types.d.ts +0 -2
  50. package/build/icons/beachball/types.js +0 -1
  51. package/build/icons/index.d.ts +0 -2
  52. package/build/icons/index.js +0 -2
  53. package/build/icons/polkadot.d.ts +0 -5
  54. package/build/icons/polkadot.js +0 -113
  55. package/build/icons/types.d.ts +0 -10
  56. package/build/icons/types.js +0 -1
  57. package/build/index.d.ts +0 -2
  58. package/build/index.js +0 -2
  59. package/build/package.json +0 -336
  60. package/build/packageDetect.d.ts +0 -1
  61. package/build/packageDetect.js +0 -3
  62. package/build/packageInfo.d.ts +0 -6
  63. package/build/packageInfo.js +0 -1
  64. package/src/bundle.ts +0 -5
  65. package/src/icons/beachball/LICENSE +0 -16
  66. package/src/icons/beachball/README.md +0 -19
  67. package/src/icons/beachball/colors.spec.ts +0 -67
  68. package/src/icons/beachball/colors.ts +0 -28
  69. package/src/icons/beachball/container.spec.ts +0 -46
  70. package/src/icons/beachball/container.ts +0 -27
  71. package/src/icons/beachball/defaults.ts +0 -11
  72. package/src/icons/beachball/demo.ts +0 -35
  73. package/src/icons/beachball/index.spec.ts +0 -36
  74. package/src/icons/beachball/index.ts +0 -33
  75. package/src/icons/beachball/seeder.spec.ts +0 -30
  76. package/src/icons/beachball/seeder.ts +0 -30
  77. package/src/icons/beachball/shape/circle.spec.ts +0 -20
  78. package/src/icons/beachball/shape/circle.ts +0 -23
  79. package/src/icons/beachball/shape/square.ts +0 -26
  80. package/src/icons/beachball/svg/circle.spec.ts +0 -19
  81. package/src/icons/beachball/svg/circle.ts +0 -14
  82. package/src/icons/beachball/svg/element.spec.ts +0 -19
  83. package/src/icons/beachball/svg/element.ts +0 -17
  84. package/src/icons/beachball/svg/rect.spec.ts +0 -19
  85. package/src/icons/beachball/svg/rect.ts +0 -13
  86. package/src/icons/beachball/svg/svg.spec.ts +0 -19
  87. package/src/icons/beachball/svg/svg.ts +0 -10
  88. package/src/icons/beachball/types.ts +0 -6
  89. package/src/icons/index.ts +0 -5
  90. package/src/icons/polkadot.spec.ts +0 -35
  91. package/src/icons/polkadot.ts +0 -154
  92. package/src/icons/types.ts +0 -14
  93. package/src/index.ts +0 -6
  94. package/src/packageDetect.ts +0 -11
  95. package/src/packageInfo.ts +0 -6
  96. package/tsconfig.build.json +0 -12
  97. package/tsconfig.build.tsbuildinfo +0 -1
  98. package/tsconfig.spec.json +0 -16
  99. package/tsconfig.spec.tsbuildinfo +0 -1
  100. /package/{build/LICENSE → LICENSE} +0 -0
  101. /package/{build-tsc/bundle.d.ts → bundle.d.ts} +0 -0
  102. /package/{build-tsc-esm/bundle.js → bundle.js} +0 -0
  103. /package/{build → cjs}/bundle.d.ts +0 -0
  104. /package/{build-tsc-cjs → cjs}/bundle.js +0 -0
  105. /package/{build-tsc → cjs}/icons/beachball/colors.d.ts +0 -0
  106. /package/{build-tsc-cjs → cjs}/icons/beachball/colors.js +0 -0
  107. /package/{build-tsc → cjs}/icons/beachball/container.d.ts +0 -0
  108. /package/{build-tsc-cjs → cjs}/icons/beachball/container.js +0 -0
  109. /package/{build-tsc → cjs}/icons/beachball/defaults.d.ts +0 -0
  110. /package/{build-tsc-cjs → cjs}/icons/beachball/defaults.js +0 -0
  111. /package/{build-tsc → cjs}/icons/beachball/demo.d.ts +0 -0
  112. /package/{build-tsc-cjs → cjs}/icons/beachball/demo.js +0 -0
  113. /package/{build-tsc → cjs}/icons/beachball/index.d.ts +0 -0
  114. /package/{build-tsc-cjs → cjs}/icons/beachball/index.js +0 -0
  115. /package/{build-tsc → cjs}/icons/beachball/seeder.d.ts +0 -0
  116. /package/{build-tsc-cjs → cjs}/icons/beachball/seeder.js +0 -0
  117. /package/{build-tsc → cjs}/icons/beachball/shape/circle.d.ts +0 -0
  118. /package/{build-tsc-cjs → cjs}/icons/beachball/shape/circle.js +0 -0
  119. /package/{build-tsc → cjs}/icons/beachball/shape/square.d.ts +0 -0
  120. /package/{build-tsc-cjs → cjs}/icons/beachball/shape/square.js +0 -0
  121. /package/{build-tsc → cjs}/icons/beachball/svg/circle.d.ts +0 -0
  122. /package/{build-tsc-cjs → cjs}/icons/beachball/svg/circle.js +0 -0
  123. /package/{build-tsc → cjs}/icons/beachball/svg/element.d.ts +0 -0
  124. /package/{build-tsc-cjs → cjs}/icons/beachball/svg/element.js +0 -0
  125. /package/{build-tsc → cjs}/icons/beachball/svg/rect.d.ts +0 -0
  126. /package/{build-tsc-cjs → cjs}/icons/beachball/svg/rect.js +0 -0
  127. /package/{build-tsc → cjs}/icons/beachball/svg/svg.d.ts +0 -0
  128. /package/{build-tsc-cjs → cjs}/icons/beachball/svg/svg.js +0 -0
  129. /package/{build-tsc → cjs}/icons/beachball/types.d.ts +0 -0
  130. /package/{build-tsc-cjs → cjs}/icons/beachball/types.js +0 -0
  131. /package/{build-tsc → cjs}/icons/index.d.ts +0 -0
  132. /package/{build-tsc-cjs → cjs}/icons/index.js +0 -0
  133. /package/{build-tsc → cjs}/icons/polkadot.d.ts +0 -0
  134. /package/{build-tsc-cjs → cjs}/icons/polkadot.js +0 -0
  135. /package/{build-tsc → cjs}/icons/types.d.ts +0 -0
  136. /package/{build-tsc-cjs → cjs}/icons/types.js +0 -0
  137. /package/{build-tsc → cjs}/index.d.ts +0 -0
  138. /package/{build-tsc-cjs → cjs}/index.js +0 -0
  139. /package/{build/cjs → cjs}/package.json +0 -0
  140. /package/{build-tsc → cjs}/packageDetect.d.ts +0 -0
  141. /package/{build-tsc-cjs → cjs}/packageDetect.js +0 -0
  142. /package/{build-tsc → cjs}/packageInfo.d.ts +0 -0
  143. /package/{build-tsc-cjs → cjs}/packageInfo.js +0 -0
  144. /package/{build/icons → icons}/beachball/README.md +0 -0
  145. /package/{build/cjs/icons → icons}/beachball/colors.d.ts +0 -0
  146. /package/{build-tsc-esm/icons → icons}/beachball/colors.js +0 -0
  147. /package/{build/cjs/icons → icons}/beachball/container.d.ts +0 -0
  148. /package/{build-tsc-esm/icons → icons}/beachball/container.js +0 -0
  149. /package/{build/cjs/icons → icons}/beachball/defaults.d.ts +0 -0
  150. /package/{build-tsc-esm/icons → icons}/beachball/defaults.js +0 -0
  151. /package/{build/cjs/icons → icons}/beachball/demo.d.ts +0 -0
  152. /package/{build-tsc-esm/icons → icons}/beachball/demo.js +0 -0
  153. /package/{build/cjs/icons → icons}/beachball/index.d.ts +0 -0
  154. /package/{build-tsc-esm/icons → icons}/beachball/index.js +0 -0
  155. /package/{build/cjs/icons → icons}/beachball/seeder.d.ts +0 -0
  156. /package/{build-tsc-esm/icons → icons}/beachball/seeder.js +0 -0
  157. /package/{build/cjs/icons → icons}/beachball/shape/circle.d.ts +0 -0
  158. /package/{build-tsc-esm/icons → icons}/beachball/shape/circle.js +0 -0
  159. /package/{build/cjs/icons → icons}/beachball/shape/square.d.ts +0 -0
  160. /package/{build-tsc-esm/icons → icons}/beachball/shape/square.js +0 -0
  161. /package/{build/cjs/icons → icons}/beachball/svg/circle.d.ts +0 -0
  162. /package/{build-tsc-esm/icons → icons}/beachball/svg/circle.js +0 -0
  163. /package/{build/cjs/icons → icons}/beachball/svg/element.d.ts +0 -0
  164. /package/{build-tsc-esm/icons → icons}/beachball/svg/element.js +0 -0
  165. /package/{build/cjs/icons → icons}/beachball/svg/rect.d.ts +0 -0
  166. /package/{build-tsc-esm/icons → icons}/beachball/svg/rect.js +0 -0
  167. /package/{build/cjs/icons → icons}/beachball/svg/svg.d.ts +0 -0
  168. /package/{build-tsc-esm/icons → icons}/beachball/svg/svg.js +0 -0
  169. /package/{build/cjs/icons → icons}/beachball/types.d.ts +0 -0
  170. /package/{build-tsc-esm/icons → icons}/beachball/types.js +0 -0
  171. /package/{build/cjs/icons → icons}/index.d.ts +0 -0
  172. /package/{build-tsc-esm/icons → icons}/index.js +0 -0
  173. /package/{build/cjs/icons → icons}/polkadot.d.ts +0 -0
  174. /package/{build-tsc-esm/icons → icons}/polkadot.js +0 -0
  175. /package/{build/cjs/icons → icons}/types.d.ts +0 -0
  176. /package/{build-tsc-esm/icons → icons}/types.js +0 -0
  177. /package/{build/cjs/index.d.ts → index.d.ts} +0 -0
  178. /package/{build-tsc-esm/index.js → index.js} +0 -0
  179. /package/{build/cjs/packageDetect.d.ts → packageDetect.d.ts} +0 -0
  180. /package/{build-tsc-esm/packageDetect.js → packageDetect.js} +0 -0
  181. /package/{build/cjs/packageInfo.d.ts → packageInfo.d.ts} +0 -0
  182. /package/{build-tsc-esm/packageInfo.js → packageInfo.js} +0 -0
@@ -1,33 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Copyright 2016 Dan Finlay
5
-
6
- import type { Options } from '../types.js';
7
-
8
- import { circle } from './shape/circle.js';
9
- import { element } from './svg/element.js';
10
- import { colors } from './colors.js';
11
- import { container as newContainer } from './container.js';
12
- import { SHAPE_COUNT } from './defaults.js';
13
- import { seeder as newSeeder } from './seeder.js';
14
-
15
- export function beachballIcon (seed: string | Uint8Array, { size = 256 }: Options, className = '', style?: Record<string, string>): HTMLElement {
16
- const seeder = newSeeder(seed);
17
- const colorGen = colors(seeder);
18
- const outer = newContainer(size, 'white', className, style);
19
- const container = newContainer(size, colorGen());
20
- const svg = element(size);
21
-
22
- outer.appendChild(container);
23
- container.appendChild(svg);
24
-
25
- for (let count = 0; count < SHAPE_COUNT; count++) {
26
- const fill = colorGen();
27
- const shape = circle(seeder, fill, size, count);
28
-
29
- svg.appendChild(shape);
30
- }
31
-
32
- return outer;
33
- }
@@ -1,30 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /// <reference types="@pezkuwi/dev-test/globals.d.ts" />
5
-
6
- import type { Seeder } from './types.js';
7
-
8
- import { seeder as newSeeder } from './seeder.js';
9
-
10
- describe('seeder', (): void => {
11
- let seeder: Seeder;
12
-
13
- beforeEach((): void => {
14
- seeder = newSeeder(new Uint8Array([1, 2, 3, 4]));
15
- });
16
-
17
- it('generates numbers using 2 spaces', (): void => {
18
- expect(
19
- seeder()
20
- ).toEqual(0.0156402587890625);
21
- });
22
-
23
- it('generates numbers using 2 spaces (incremented)', (): void => {
24
- seeder();
25
-
26
- expect(
27
- seeder()
28
- ).toEqual(0.0078582763671875);
29
- });
30
- });
@@ -1,30 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import type { Seeder } from './types.js';
5
-
6
- import { isU8a, stringToU8a } from '@pezkuwi/util';
7
-
8
- const DIVISOR = 256 * 256;
9
-
10
- export function seeder (_seed: string | Uint8Array = new Uint8Array(32)): Seeder {
11
- const seed: Uint8Array = isU8a(_seed)
12
- ? _seed
13
- : stringToU8a(_seed);
14
-
15
- let index = (seed[Math.floor(seed.length / 2)] % seed.length) - 1;
16
-
17
- const next = (): number => {
18
- index += 1;
19
-
20
- if (index === seed.length) {
21
- index = 0;
22
- }
23
-
24
- return seed[index];
25
- };
26
-
27
- return (): number => {
28
- return ((next() * 256) + next()) / DIVISOR;
29
- };
30
- }
@@ -1,20 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /// <reference types="@pezkuwi/dev-test/globals.d.ts" />
5
-
6
- import xmlserializer from 'xmlserializer';
7
-
8
- import { seeder } from '../seeder.js';
9
- import { circle } from './circle.js';
10
-
11
- describe('circle', (): void => {
12
- it('creates a circle shape', (): void => {
13
- expect(
14
- xmlserializer.serializeToString(
15
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-explicit-any
16
- circle(seeder(), 'blue', 50, 2) as any
17
- )
18
- ).toEqual('<circle xmlns="http://www.w3.org/2000/svg" cx="25" cy="32.5" r="15" fill="blue"/>');
19
- });
20
- });
@@ -1,23 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Copyright 2016 Dan Finlay
5
-
6
- import type { Seeder } from '../types.js';
7
-
8
- import { SHAPE_COUNT } from '../defaults.js';
9
- import { circle as newCircle } from '../svg/circle.js';
10
-
11
- export function circle (seeder: Seeder, fill: string, diameter: number, count: number): Element {
12
- const center = diameter / 2;
13
- const angle = seeder() * 360;
14
- const radius = (((SHAPE_COUNT - count) / SHAPE_COUNT) * (diameter / 2)) + ((diameter / 8) * seeder());
15
- const offset = (diameter / 4) * (seeder() + ((count + 1) / SHAPE_COUNT));
16
- const cx = (offset * Math.sin(angle)) + center;
17
- const cy = (offset * Math.cos(angle)) + center;
18
- const svg = newCircle(radius, cx, cy);
19
-
20
- svg.setAttributeNS('', 'fill', fill);
21
-
22
- return svg;
23
- }
@@ -1,26 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Copyright 2016 Dan Finlay
5
-
6
- import type { Seeder } from '../types.js';
7
-
8
- import { SHAPE_COUNT } from '../defaults.js';
9
- import { rect as newRect } from '../svg/rect.js';
10
-
11
- export function square (seeder: Seeder, fill: string, diameter: number, count: number): Element {
12
- const center = diameter / 2;
13
- const svg = newRect(diameter);
14
- const firstRot = seeder();
15
- const angle = Math.PI * 2 * firstRot;
16
- const scale = count / SHAPE_COUNT;
17
- const velocity = ((diameter / SHAPE_COUNT) * seeder()) + (scale * diameter);
18
- const tx = (Math.cos(angle) * velocity).toFixed(3);
19
- const ty = (Math.sin(angle) * velocity).toFixed(3);
20
- const rot = ((firstRot * 360) + (seeder() * 180)).toFixed(1);
21
-
22
- svg.setAttributeNS('', 'transform', `translate(${tx} ${ty}) rotate(${rot} ${center} ${center})`);
23
- svg.setAttributeNS('', 'fill', fill);
24
-
25
- return svg;
26
- }
@@ -1,19 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /// <reference types="@pezkuwi/dev-test/globals.d.ts" />
5
-
6
- import xs from 'xmlserializer';
7
-
8
- import { circle } from './circle.js';
9
-
10
- describe('circle', (): void => {
11
- it('creates a basic SVG circle element', (): void => {
12
- expect(
13
- xs.serializeToString(
14
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-explicit-any
15
- circle(123, 12, 34) as any
16
- )
17
- ).toEqual('<circle xmlns="http://www.w3.org/2000/svg" cx="12" cy="34" r="123"/>');
18
- });
19
- });
@@ -1,14 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { svg } from './svg.js';
5
-
6
- export function circle (r: number, cx: number, cy: number): Element {
7
- const elem = svg('circle');
8
-
9
- elem.setAttributeNS('', 'cx', `${cx}`);
10
- elem.setAttributeNS('', 'cy', `${cy}`);
11
- elem.setAttributeNS('', 'r', `${r}`);
12
-
13
- return elem;
14
- }
@@ -1,19 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /// <reference types="@pezkuwi/dev-test/globals.d.ts" />
5
-
6
- import xs from 'xmlserializer';
7
-
8
- import { element } from './element.js';
9
-
10
- describe('element', (): void => {
11
- it('creates a basic SVG element', (): void => {
12
- expect(
13
- xs.serializeToString(
14
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-explicit-any
15
- element(123) as any
16
- )
17
- ).toEqual('<svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="123" height="123"/>');
18
- });
19
- });
@@ -1,17 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Copyright 2016 Dan Finlay
5
-
6
- import { svg } from './svg.js';
7
-
8
- export function element (size: number, type = 'svg', x = 0, y = 0): Element {
9
- const elem = svg(type);
10
-
11
- elem.setAttributeNS('', 'x', `${x}`);
12
- elem.setAttributeNS('', 'y', `${y}`);
13
- elem.setAttributeNS('', 'width', `${size}`);
14
- elem.setAttributeNS('', 'height', `${size}`);
15
-
16
- return elem;
17
- }
@@ -1,19 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /// <reference types="@pezkuwi/dev-test/globals.d.ts" />
5
-
6
- import xs from 'xmlserializer';
7
-
8
- import { rect } from './rect.js';
9
-
10
- describe('rect', (): void => {
11
- it('creates a basic SVG rect element', (): void => {
12
- expect(
13
- xs.serializeToString(
14
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-explicit-any
15
- rect(123) as any
16
- )
17
- ).toEqual('<rect xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="123" height="123" rx="7.6875" ry="7.6875"/>');
18
- });
19
- });
@@ -1,13 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { element } from './element.js';
5
-
6
- export function rect (size: number): Element {
7
- const elem = element(size, 'rect');
8
-
9
- elem.setAttributeNS('', 'rx', `${size / 16}`);
10
- elem.setAttributeNS('', 'ry', `${size / 16}`);
11
-
12
- return elem;
13
- }
@@ -1,19 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /// <reference types="@pezkuwi/dev-test/globals.d.ts" />
5
-
6
- import xs from 'xmlserializer';
7
-
8
- import { svg } from './svg.js';
9
-
10
- describe('svg', (): void => {
11
- it('creates a basic SVG element', (): void => {
12
- expect(
13
- xs.serializeToString(
14
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-explicit-any
15
- svg('rect') as any
16
- )
17
- ).toEqual('<rect xmlns="http://www.w3.org/2000/svg"/>');
18
- });
19
- });
@@ -1,10 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Copyright 2016 Dan Finlay
5
-
6
- const SVG_NS = 'http://www.w3.org/2000/svg';
7
-
8
- export function svg (type: string): Element {
9
- return document.createElementNS(SVG_NS, type);
10
- }
@@ -1,6 +0,0 @@
1
- // Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export type Seeder = () => number;
5
-
6
- export type ColorGen = (alpha?: number) => string;
@@ -1,5 +0,0 @@
1
- // Copyright 2018-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export { beachballIcon } from './beachball/index.js';
5
- export { polkadotIcon } from './polkadot.js';
@@ -1,35 +0,0 @@
1
- // Copyright 2018-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /// <reference types="@pezkuwi/dev-test/globals.d.ts" />
5
-
6
- import { polkadotIcon } from './polkadot.js';
7
-
8
- describe('polkadotIcon', (): void => {
9
- it('generates the correct points from known', (): void => {
10
- expect(
11
- polkadotIcon('5Dqvi1p4C7EhPPFKCixpF3QiaJEaDwWrR9gfWR5eUsfC39TX', { isAlternative: false })
12
- ).toEqual([
13
- { cx: 32, cy: 32, fill: '#eee', r: 32 },
14
- { cx: 32, cy: 8, fill: 'hsl(196, 65%, 53%)', r: 5 },
15
- { cx: 32, cy: 20, fill: 'hsl(320, 65%, 53%)', r: 5 },
16
- { cx: 21.607695154586736, cy: 14, fill: 'transparent', r: 5 },
17
- { cx: 11.215390309173472, cy: 20, fill: 'hsl(112, 65%, 15%)', r: 5 },
18
- { cx: 21.607695154586736, cy: 26, fill: 'hsl(22, 65%, 15%)', r: 5 },
19
- { cx: 11.215390309173472, cy: 32, fill: 'hsl(213, 65%, 15%)', r: 5 },
20
- { cx: 11.215390309173472, cy: 44, fill: 'hsl(163, 65%, 53%)', r: 5 },
21
- { cx: 21.607695154586736, cy: 38, fill: 'hsl(213, 65%, 53%)', r: 5 },
22
- { cx: 21.607695154586736, cy: 50, fill: 'hsl(185, 65%, 75%)', r: 5 },
23
- { cx: 32, cy: 56, fill: 'hsl(163, 65%, 53%)', r: 5 },
24
- { cx: 32, cy: 44, fill: 'hsl(213, 65%, 53%)', r: 5 },
25
- { cx: 42.392304845413264, cy: 50, fill: 'hsl(213, 65%, 15%)', r: 5 },
26
- { cx: 52.78460969082653, cy: 44, fill: 'hsl(112, 65%, 15%)', r: 5 },
27
- { cx: 42.392304845413264, cy: 38, fill: 'hsl(22, 65%, 15%)', r: 5 },
28
- { cx: 52.78460969082653, cy: 32, fill: 'transparent', r: 5 },
29
- { cx: 52.78460969082653, cy: 20, fill: 'hsl(196, 65%, 53%)', r: 5 },
30
- { cx: 42.392304845413264, cy: 26, fill: 'hsl(320, 65%, 53%)', r: 5 },
31
- { cx: 42.392304845413264, cy: 14, fill: 'hsl(11, 65%, 35%)', r: 5 },
32
- { cx: 32, cy: 32, fill: 'hsl(309, 65%, 53%)', r: 5 }
33
- ]);
34
- });
35
- });
@@ -1,154 +0,0 @@
1
- // Copyright 2018-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Copyright 2018 Paritytech via paritytech/oo7/polkadot-identicon
5
-
6
- // This has been converted from the original version that can be found at
7
- //
8
- // https://github.com/paritytech/oo7/blob/251ba2b7c45503b68eab4320c270b5afa9bccb60/packages/polkadot-identicon/src/index.jsx
9
-
10
- import type { Circle, Options } from './types.js';
11
-
12
- import { blake2AsU8a, decodeAddress } from '@pezkuwi/util-crypto';
13
-
14
- interface Scheme {
15
- freq: number;
16
- colors: readonly number[];
17
- }
18
-
19
- const S = 64;
20
- const C = S / 2;
21
- const Z = S / 64 * 5;
22
-
23
- const SCHEMES: readonly Scheme[] = [
24
- /* target */ { colors: [0, 28, 0, 0, 28, 0, 0, 28, 0, 0, 28, 0, 0, 28, 0, 0, 28, 0, 1], freq: 1 },
25
- /* cube */ { colors: [0, 1, 3, 2, 4, 3, 0, 1, 3, 2, 4, 3, 0, 1, 3, 2, 4, 3, 5], freq: 20 },
26
- /* quazar */ { colors: [1, 2, 3, 1, 2, 4, 5, 5, 4, 1, 2, 3, 1, 2, 4, 5, 5, 4, 0], freq: 16 },
27
- /* flower */ { colors: [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3], freq: 32 },
28
- /* cyclic */ { colors: [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6], freq: 32 },
29
- /* vmirror */ { colors: [0, 1, 2, 3, 4, 5, 3, 4, 2, 0, 1, 6, 7, 8, 9, 7, 8, 6, 10], freq: 128 },
30
- /* hmirror */ { colors: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 8, 6, 7, 5, 3, 4, 2, 11], freq: 128 }
31
- ];
32
-
33
- const SCHEMES_TOTAL = SCHEMES
34
- .map((s): number => s.freq)
35
- .reduce((a, b): number => a + b);
36
-
37
- const OUTER_CIRCLE: Circle = {
38
- cx: C,
39
- cy: C,
40
- fill: '#eee',
41
- r: C
42
- };
43
-
44
- let zeroHash: Uint8Array = new Uint8Array();
45
-
46
- function getRotation (isSixPoint: boolean): { r: number; ro2: number; r3o4: number; ro4: number; rroot3o2: number; rroot3o4: number } {
47
- const r = isSixPoint
48
- ? (C / 8 * 5)
49
- : (C / 4 * 3);
50
- const rroot3o2 = r * Math.sqrt(3) / 2;
51
- const ro2 = r / 2;
52
- const rroot3o4 = r * Math.sqrt(3) / 4;
53
- const ro4 = r / 4;
54
- const r3o4 = r * 3 / 4;
55
-
56
- return { r, r3o4, ro2, ro4, rroot3o2, rroot3o4 };
57
- }
58
-
59
- function getCircleXY (isSixPoint = false): [number, number][] {
60
- const { r, r3o4, ro2, ro4, rroot3o2, rroot3o4 } = getRotation(isSixPoint);
61
-
62
- return [
63
- [C, C - r],
64
- [C, C - ro2],
65
- [C - rroot3o4, C - r3o4],
66
- [C - rroot3o2, C - ro2],
67
- [C - rroot3o4, C - ro4],
68
- [C - rroot3o2, C],
69
- [C - rroot3o2, C + ro2],
70
- [C - rroot3o4, C + ro4],
71
- [C - rroot3o4, C + r3o4],
72
- [C, C + r],
73
- [C, C + ro2],
74
- [C + rroot3o4, C + r3o4],
75
- [C + rroot3o2, C + ro2],
76
- [C + rroot3o4, C + ro4],
77
- [C + rroot3o2, C],
78
- [C + rroot3o2, C - ro2],
79
- [C + rroot3o4, C - ro4],
80
- [C + rroot3o4, C - r3o4],
81
- [C, C]
82
- ];
83
- }
84
-
85
- function findScheme (d: number): Scheme {
86
- let cum = 0;
87
- const schema = SCHEMES.find((schema): boolean => {
88
- cum += schema.freq;
89
-
90
- return d < cum;
91
- });
92
-
93
- if (!schema) {
94
- throw new Error('Unable to find schema');
95
- }
96
-
97
- return schema;
98
- }
99
-
100
- function addressToId (address: string): Uint8Array {
101
- if (!zeroHash.length) {
102
- zeroHash = blake2AsU8a(new Uint8Array(32), 512);
103
- }
104
-
105
- return blake2AsU8a(decodeAddress(address), 512).map((x, i) => (x + 256 - zeroHash[i]) % 256);
106
- }
107
-
108
- function getColors (address: string): string[] {
109
- const id = addressToId(address);
110
- const d = Math.floor((id[30] + id[31] * 256) % SCHEMES_TOTAL);
111
- const rot = (id[28] % 6) * 3;
112
- const sat = (Math.floor(id[29] * 70 / 256 + 26) % 80) + 30;
113
- const scheme = findScheme(d);
114
- const palette = Array.from(id).map((x, i): string => {
115
- const b = (x + i % 28 * 58) % 256;
116
-
117
- if (b === 0) {
118
- return '#444';
119
- } else if (b === 255) {
120
- return 'transparent';
121
- }
122
-
123
- const h = Math.floor(b % 64 * 360 / 64);
124
- const l = [53, 15, 35, 75][Math.floor(b / 64)];
125
-
126
- return `hsl(${h}, ${sat}%, ${l}%)`;
127
- });
128
-
129
- return scheme.colors.map((_, i): string =>
130
- palette[scheme.colors[i < 18 ? (i + rot) % 18 : 18]]
131
- );
132
- }
133
-
134
- /**
135
- * @description Generates an array of the circles that make up an identicon
136
- */
137
- export function polkadotIcon (address: string, { isAlternative }: Options): Circle[] {
138
- const xy = getCircleXY(isAlternative);
139
- let colors: string[];
140
-
141
- try {
142
- // in some cases, e.g. RN where crypto may not be initialized, chaos can
143
- // happen when hashing, in these cases we just fill with a placeholder
144
- colors = getColors(address);
145
- } catch {
146
- colors = new Array<string>(xy.length).fill('#ddd');
147
- }
148
-
149
- return [OUTER_CIRCLE].concat(
150
- xy.map(([cx, cy], index): Circle => ({
151
- cx, cy, fill: colors[index], r: Z
152
- }))
153
- );
154
- }
@@ -1,14 +0,0 @@
1
- // Copyright 2018-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export interface Circle {
5
- cx: number;
6
- cy: number;
7
- fill: string;
8
- r: number;
9
- }
10
-
11
- export interface Options {
12
- isAlternative?: boolean;
13
- size?: number;
14
- }
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- // Copyright 2018-2025 @pezkuwi/ui-shared authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import './packageDetect.js';
5
-
6
- export * from './bundle.js';
@@ -1,11 +0,0 @@
1
- // Copyright 2017-2026 @pezkuwi/ui-shared 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 { detectPackage } from '@pezkuwi/util';
8
-
9
- import { packageInfo } from './packageInfo.js';
10
-
11
- detectPackage(packageInfo, null, []);
@@ -1,6 +0,0 @@
1
- // Copyright 2017-2026 @pezkuwi/ui-shared 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/ui-shared', path: 'auto', type: 'auto', version: '3.16.6' };
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "baseUrl": "..",
5
- "outDir": "./build",
6
- "rootDir": "./src"
7
- },
8
- "exclude": [
9
- "**/*.spec.ts"
10
- ],
11
- "references": []
12
- }