@sit-onyx/icons 1.0.0-beta.20 → 1.0.0-beta.21

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.
@@ -0,0 +1,25 @@
1
+ import type { IconCategories, IconMetadata } from "./types.js";
2
+ export {
3
+ /**
4
+ * Metadata for all available onyx icons.
5
+ */
6
+ default as ICON_METADATA, } from "./metadata.json";
7
+ /**
8
+ * Groups all available icon metadata by category.
9
+ * Categories and icons will be sorted alphabetically.
10
+ */
11
+ export declare const groupIconsByCategory: (iconMetadata: Record<string, IconMetadata>) => IconCategories;
12
+ /**
13
+ * Transform an icon name to its corresponding JavaScript import name.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * "bell-disabled" => "bellDisabled"
18
+ * // e.g. used as 'import bellDisabled from "@sit-onyx/icons/bell-disabled.svg?raw"'
19
+ * ```
20
+ */
21
+ export declare const getIconImportName: (iconName: string) => string;
22
+ /**
23
+ * Capitalizes the first character of the given string.
24
+ */
25
+ export declare const capitalize: (value: string) => string;
@@ -1,12 +1,10 @@
1
1
  export type IconMetadata = {
2
- category: string;
3
- deprecated?: boolean;
4
- aliases?: string[];
2
+ category: string;
3
+ deprecated?: boolean;
4
+ aliases?: string[];
5
5
  };
6
-
7
6
  export type GroupedIconCategory = {
8
- iconName: string;
9
- metadata: IconMetadata;
7
+ iconName: string;
8
+ metadata: IconMetadata;
10
9
  };
11
-
12
10
  export type IconCategories = Record<string, GroupedIconCategory[]>;
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@sit-onyx/icons",
3
3
  "description": "SVG icons for the onyx design system",
4
- "version": "1.0.0-beta.20",
4
+ "version": "1.0.0-beta.21",
5
5
  "type": "module",
6
+ "author": "Schwarz IT KG",
6
7
  "license": "Apache-2.0",
8
+ "engines": {
9
+ "node": ">=20"
10
+ },
7
11
  "repository": {
8
12
  "type": "git",
9
13
  "url": "https://github.com/schwarzit/onyx",
@@ -13,20 +17,21 @@
13
17
  "url": "https://github.com/schwarzit/onyx/issues"
14
18
  },
15
19
  "files": [
16
- "src",
20
+ "src/assets",
17
21
  "dist"
18
22
  ],
19
23
  "exports": {
20
24
  ".": {
21
- "types": "./src/index.ts",
25
+ "types": "./dist/index.d.ts",
22
26
  "import": "./dist/index.js"
23
27
  },
24
- "./metadata": "./src/metadata.json",
28
+ "./metadata": "./dist/metadata.json",
25
29
  "./*": "./src/assets/*"
26
30
  },
27
31
  "devDependencies": {
28
32
  "@changesets/write": "~0.4.0",
29
- "tsx": "^4.20.3"
33
+ "tsx": "^4.20.3",
34
+ "@sit-onyx/shared": "^1.0.0-beta.4"
30
35
  },
31
36
  "scripts": {
32
37
  "build": "tsc",
package/src/index.ts DELETED
@@ -1,63 +0,0 @@
1
- import type { IconCategories, IconMetadata } from "./types.js";
2
-
3
- export {
4
- /**
5
- * Metadata for all available onyx icons.
6
- */
7
- default as ICON_METADATA,
8
- } from "./metadata.json";
9
-
10
- /**
11
- * Groups all available icon metadata by category.
12
- * Categories and icons will be sorted alphabetically.
13
- */
14
- export const groupIconsByCategory = (iconMetadata: Record<string, IconMetadata>) => {
15
- const categories = Object.entries(iconMetadata).reduce<IconCategories>(
16
- (categories, [iconName, metadata]) => {
17
- const icons = categories[metadata.category] ?? [];
18
- icons.push({ iconName, metadata });
19
- categories[metadata.category] = icons;
20
- return categories;
21
- },
22
- {},
23
- );
24
-
25
- const sortedCategories: typeof categories = {};
26
-
27
- Object.keys(categories)
28
- .sort()
29
- .forEach((category) => {
30
- const sortedMetadata = categories[category].slice().sort((a, b) => {
31
- return a.iconName.localeCompare(b.iconName);
32
- });
33
- sortedCategories[category] = sortedMetadata;
34
- });
35
-
36
- return sortedCategories;
37
- };
38
-
39
- /**
40
- * Transform an icon name to its corresponding JavaScript import name.
41
- *
42
- * @example
43
- * ```ts
44
- * "bell-disabled" => "bellDisabled"
45
- * // e.g. used as 'import bellDisabled from "@sit-onyx/icons/bell-disabled.svg?raw"'
46
- * ```
47
- */
48
- export const getIconImportName = (iconName: string) => {
49
- return iconName
50
- .split("-")
51
- .map((word, index) => {
52
- if (index === 0) return word;
53
- return capitalize(word);
54
- })
55
- .join("");
56
- };
57
-
58
- /**
59
- * Capitalizes the first character of the given string.
60
- */
61
- export const capitalize = (value: string) => {
62
- return value.charAt(0).toUpperCase() + value.slice(1);
63
- };