@thalassic/ui 22.5.1 → 22.6.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.
@@ -0,0 +1,44 @@
1
+ import { provideThalassicIcons } from '@thalassic/ui';
2
+
3
+ /**
4
+ * Override the library's built-in {@link systemIcon}s with FontAwesome icons.
5
+ * Each FontAwesome definition is converted to inline SVG (with
6
+ * `fill="currentColor"`, so it inherits color and box sizing like the defaults)
7
+ * and registered through `provideThalassicIcons`. Names left unset keep the
8
+ * library defaults.
9
+ *
10
+ * ```ts
11
+ * import { faXmark, faChevronDown } from '@fortawesome/free-solid-svg-icons';
12
+ * import { provideFontAwesomeIcons } from '@thalassic/ui/fontawesome';
13
+ *
14
+ * provideFontAwesomeIcons({
15
+ * close: faXmark,
16
+ * 'chevron-down': faChevronDown,
17
+ * });
18
+ * ```
19
+ */
20
+ function provideFontAwesomeIcons(icons) {
21
+ const registry = {};
22
+ for (const name of Object.keys(icons)) {
23
+ const definition = icons[name];
24
+ if (!definition)
25
+ continue;
26
+ registry[name] = faToSvg(definition);
27
+ }
28
+ return provideThalassicIcons(registry);
29
+ }
30
+ function faToSvg(definition) {
31
+ const [width, height, , , pathData] = definition.icon;
32
+ const paths = Array.isArray(pathData) ? pathData : [pathData];
33
+ const body = paths.map(data => `<path d="${data}" />`).join('');
34
+ return (`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" fill="currentColor">` +
35
+ body +
36
+ '</svg>');
37
+ }
38
+
39
+ /**
40
+ * Generated bundle index. Do not edit.
41
+ */
42
+
43
+ export { provideFontAwesomeIcons };
44
+ //# sourceMappingURL=thalassic-ui-fontawesome.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thalassic-ui-fontawesome.mjs","sources":["../../../../libs/ui/fontawesome/src/provide-fontawesome-icons.ts","../../../../libs/ui/fontawesome/src/thalassic-ui-fontawesome.ts"],"sourcesContent":["import { EnvironmentProviders } from '@angular/core';\nimport { iconRegistry, provideThalassicIcons, systemIcon } from '@thalassic/ui';\nimport { fontAwesomeIcon } from './font-awesome-icon';\n\n/**\n * Override the library's built-in {@link systemIcon}s with FontAwesome icons.\n * Each FontAwesome definition is converted to inline SVG (with\n * `fill=\"currentColor\"`, so it inherits color and box sizing like the defaults)\n * and registered through `provideThalassicIcons`. Names left unset keep the\n * library defaults.\n *\n * ```ts\n * import { faXmark, faChevronDown } from '@fortawesome/free-solid-svg-icons';\n * import { provideFontAwesomeIcons } from '@thalassic/ui/fontawesome';\n *\n * provideFontAwesomeIcons({\n * close: faXmark,\n * 'chevron-down': faChevronDown,\n * });\n * ```\n */\nexport function provideFontAwesomeIcons(\n icons: Partial<Record<systemIcon, fontAwesomeIcon>>,\n): EnvironmentProviders {\n const registry: iconRegistry = {};\n\n for (const name of Object.keys(icons) as systemIcon[]) {\n const definition = icons[name];\n if (!definition) continue;\n registry[name] = faToSvg(definition);\n }\n\n return provideThalassicIcons(registry);\n}\n\nfunction faToSvg(definition: fontAwesomeIcon): string {\n const [width, height, , , pathData] = definition.icon;\n const paths = Array.isArray(pathData) ? pathData : [pathData];\n const body = paths.map(data => `<path d=\"${data}\" />`).join('');\n\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${width} ${height}\" fill=\"currentColor\">` +\n body +\n '</svg>'\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAIA;;;;;;;;;;;;;;;;AAgBG;AACG,SAAU,uBAAuB,CACrC,KAAmD,EAAA;IAEnD,MAAM,QAAQ,GAAiB,EAAE;IAEjC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAiB,EAAE;AACrD,QAAA,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC;AAC9B,QAAA,IAAI,CAAC,UAAU;YAAE;QACjB,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IACtC;AAEA,IAAA,OAAO,qBAAqB,CAAC,QAAQ,CAAC;AACxC;AAEA,SAAS,OAAO,CAAC,UAA2B,EAAA;AAC1C,IAAA,MAAM,CAAC,KAAK,EAAE,MAAM,MAAM,QAAQ,CAAC,GAAG,UAAU,CAAC,IAAI;AACrD,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAC7D,IAAA,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAA,SAAA,EAAY,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAE/D,IAAA,QACE,CAAA,qDAAA,EAAwD,KAAK,CAAA,CAAA,EAAI,MAAM,CAAA,sBAAA,CAAwB;QAC/F,IAAI;AACJ,QAAA,QAAQ;AAEZ;;AC7CA;;AAEG;;;;"}