@websline/system-components 1.3.6 → 1.3.7

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.
@@ -1,6 +1,5 @@
1
- export const registry: {
2
- [k: string]: any;
3
- };
1
+ export function addIconsToRegistry(pathModuleRecord: any): void;
2
+ export const registry: {};
4
3
  export const synonyms: {
5
4
  "checkbox-stack": string;
6
5
  "file-pdf": string;
@@ -1,28 +1,34 @@
1
+ // paths within the components folder are imported as component names automatically
2
+ // e.g. ./components/subDir/testIcon.svelte -> subDirTestIcon
3
+ // Check the icon story in Storybook to easily extract the icon name
4
+ // NOTE: this doesn't return anything outside of this package, so a custom import is required in the consuming project
1
5
  const moduleRegistry = import.meta.glob("./**/*.svelte", {
2
6
  eager: true,
3
7
  base: "./components",
4
8
  import: "default",
5
9
  });
6
10
 
7
- // paths within the components folder are imported as component names automatically
8
- // e.g. ./components/subDir/testIcon.svelte -> subDirTestIcon
9
- // Check the icon story in Storybook to easily extract the icon name
10
- const registry = Object.fromEntries(
11
- Object.entries(moduleRegistry).map(([path, module]) => {
12
- const name = path
13
- // remove extension
14
- .replace(/\.[^/.]+$/, "")
15
- // squash any non-alphanumeric into single hyphen (handles underscores)
16
- .replace(/[^a-zA-Z0-9]+/g, "-")
17
- // replace "-" w/ uppercase of the following letter
18
- .replace(/-([a-z])/g, (m, p1) => p1.toUpperCase())
19
- // remove remaining "-"
20
- .replaceAll("-", "")
21
- // first letter lowercase
22
- .replace(/^([A-Z])/, (m, p1) => p1.toLowerCase());
23
- return [name, module];
24
- }),
25
- );
11
+ const registry = {};
12
+
13
+ const addIconsToRegistry = (pathModuleRecord) => {
14
+ const map = Object.fromEntries(
15
+ Object.entries(pathModuleRecord).map(([path, module]) => {
16
+ const name = path
17
+ // remove extension
18
+ .replace(/\.[^/.]+$/, "")
19
+ // squash any non-alphanumeric into single hyphen (handles underscores)
20
+ .replace(/[^a-zA-Z0-9]+/g, "-")
21
+ // replace "-" w/ uppercase of the following letter
22
+ .replace(/-([a-z])/g, (m, p1) => p1.toUpperCase())
23
+ // remove remaining "-"
24
+ .replaceAll("-", "")
25
+ // first letter lowercase
26
+ .replace(/^([A-Z])/, (m, p1) => p1.toLowerCase());
27
+ return [name, module];
28
+ }),
29
+ );
30
+ Object.assign(registry, map);
31
+ };
26
32
 
27
33
  // e.g. for backwards compatibility
28
34
  const synonyms = {
@@ -31,6 +37,8 @@ const synonyms = {
31
37
  unlink: "connectCrossed",
32
38
  };
33
39
 
40
+ addIconsToRegistry(moduleRegistry);
41
+
34
42
  // attach synonyms to registry, with error handling for duplicates
35
43
  Object.entries(synonyms).map(([k, v]) => {
36
44
  if (registry[k]) {
@@ -42,4 +50,4 @@ Object.entries(synonyms).map(([k, v]) => {
42
50
  registry[k] = registry[v];
43
51
  });
44
52
 
45
- export { registry, synonyms };
53
+ export { addIconsToRegistry, registry, synonyms };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export { default as Chip } from "./components/atoms/chip/Chip.svelte";
8
8
  export { default as CloseButton } from "./components/atoms/actions/closeButton/CloseButton.svelte";
9
9
  export { default as ColorChip } from "./components/atoms/colorChip/ColorChip.svelte";
10
10
  export { default as HelperText } from "./components/atoms/helperText/HelperText.svelte";
11
+ export { addIconsToRegistry } from "./components/atoms/icon/index.js";
11
12
  export { default as Icon } from "./components/atoms/icon/Icon.svelte";
12
13
  export { default as IconButton } from "./components/atoms/actions/iconButton/IconButton.svelte";
13
14
  export { default as Input } from "./components/atoms/input/Input.svelte";
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ export { default as Chip } from "./components/atoms/chip/Chip.svelte";
13
13
  export { default as CloseButton } from "./components/atoms/actions/closeButton/CloseButton.svelte";
14
14
  export { default as ColorChip } from "./components/atoms/colorChip/ColorChip.svelte";
15
15
  export { default as HelperText } from "./components/atoms/helperText/HelperText.svelte";
16
+ export { addIconsToRegistry } from "./components/atoms/icon/index.js";
16
17
  export { default as Icon } from "./components/atoms/icon/Icon.svelte";
17
18
  export { default as IconButton } from "./components/atoms/actions/iconButton/IconButton.svelte";
18
19
  export { default as Input } from "./components/atoms/input/Input.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websline/system-components",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },