@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.45 → 2.0.0-next.49

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 (95) hide show
  1. package/.storybook/ComponentPreview.tsx +26 -0
  2. package/.storybook/PreviewTemplate.tsx +99 -0
  3. package/.storybook/action-handler.ts +81 -0
  4. package/.storybook/channels.ts +44 -0
  5. package/.storybook/main.ts +313 -0
  6. package/.storybook/manager.ts +71 -0
  7. package/.storybook/openbridgeTheme.ts +197 -0
  8. package/.storybook/preview-head.html +15 -0
  9. package/.storybook/preview.tsx +129 -0
  10. package/.storybook/vitest.setup.ts +23 -0
  11. package/bundle/openbridge-webcomponents.bundle.js +14869 -14889
  12. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  13. package/custom-elements.json +81 -82
  14. package/dist/components/badge/badge.css.js +15 -15
  15. package/dist/components/icon-button/icon-button.d.ts +4 -0
  16. package/dist/components/icon-button/icon-button.d.ts.map +1 -1
  17. package/dist/components/icon-button/icon-button.js.map +1 -1
  18. package/dist/navigation-instruments/compass/compass.d.ts +3 -3
  19. package/dist/navigation-instruments/compass/compass.d.ts.map +1 -1
  20. package/dist/navigation-instruments/compass/compass.js +3 -3
  21. package/dist/navigation-instruments/compass/compass.js.map +1 -1
  22. package/dist/navigation-instruments/compass-indicator/compass-indicator.d.ts +12 -0
  23. package/dist/navigation-instruments/compass-indicator/compass-indicator.d.ts.map +1 -1
  24. package/dist/navigation-instruments/compass-indicator/compass-indicator.js +9 -1
  25. package/dist/navigation-instruments/compass-indicator/compass-indicator.js.map +1 -1
  26. package/dist/navigation-instruments/velocity-projection-plot/velocity-projection-plot.d.ts +4 -4
  27. package/dist/navigation-instruments/velocity-projection-plot/velocity-projection-plot.d.ts.map +1 -1
  28. package/dist/navigation-instruments/velocity-projection-plot/velocity-projection-plot.js +15 -14
  29. package/dist/navigation-instruments/velocity-projection-plot/velocity-projection-plot.js.map +1 -1
  30. package/dist/navigation-instruments/watch/environment.d.ts +39 -1
  31. package/dist/navigation-instruments/watch/environment.d.ts.map +1 -1
  32. package/dist/navigation-instruments/watch/environment.js +71 -88
  33. package/dist/navigation-instruments/watch/environment.js.map +1 -1
  34. package/dist/navigation-instruments/watch/watch.d.ts +1 -1
  35. package/dist/navigation-instruments/watch/watch.d.ts.map +1 -1
  36. package/dist/navigation-instruments/watch/watch.js +4 -4
  37. package/dist/navigation-instruments/watch/watch.js.map +1 -1
  38. package/dist/navigation-instruments/wind/wind.d.ts +1 -1
  39. package/dist/navigation-instruments/wind/wind.d.ts.map +1 -1
  40. package/dist/navigation-instruments/wind/wind.js +3 -3
  41. package/dist/navigation-instruments/wind/wind.js.map +1 -1
  42. package/dist/navigation-instruments/wind-indicator/wind-indicator.d.ts +63 -9
  43. package/dist/navigation-instruments/wind-indicator/wind-indicator.d.ts.map +1 -1
  44. package/dist/navigation-instruments/wind-indicator/wind-indicator.js +57 -1995
  45. package/dist/navigation-instruments/wind-indicator/wind-indicator.js.map +1 -1
  46. package/dist/navigation-instruments/wind-propulsion/wind-propulsion.d.ts +1 -1
  47. package/dist/navigation-instruments/wind-propulsion/wind-propulsion.d.ts.map +1 -1
  48. package/dist/navigation-instruments/wind-propulsion/wind-propulsion.js +4 -4
  49. package/dist/navigation-instruments/wind-propulsion/wind-propulsion.js.map +1 -1
  50. package/eslint.config.mjs +589 -0
  51. package/fix-imports.mjs +185 -0
  52. package/fix-js-extensions.mjs +44 -0
  53. package/lit-localize.json +15 -0
  54. package/new-component.ts +148 -0
  55. package/package.json +56 -3
  56. package/postcss.config.mjs +195 -0
  57. package/script/check-css-mixins.ts +191 -0
  58. package/script/check-css-variables.ts +280 -0
  59. package/script/convert-icons.ts +202 -0
  60. package/script/convert-vessel-svg-to-ts.ts +110 -0
  61. package/script/docgen/README.md +95 -0
  62. package/script/docgen/docs-gen.ts +225 -0
  63. package/script/docgen/prompt-system.txt +187 -0
  64. package/script/download-alert-icons.ts +193 -0
  65. package/script/download-icons.ts +314 -0
  66. package/script/figmavariables.json +139 -0
  67. package/script/generate-bundle-entry.ts +77 -0
  68. package/script/prepare-full-bundle.ts +105 -0
  69. package/script/sort-custom-element-manifest.ts +67 -0
  70. package/src/components/badge/badge.css +15 -15
  71. package/src/components/badge/badge.stories.ts +2 -0
  72. package/src/components/icon-button/icon-button.ts +4 -0
  73. package/src/navigation-instruments/compass/compass.stories.ts +5 -2
  74. package/src/navigation-instruments/compass/compass.ts +4 -4
  75. package/src/navigation-instruments/compass-indicator/compass-indicator.stories.ts +34 -1
  76. package/src/navigation-instruments/compass-indicator/compass-indicator.ts +19 -1
  77. package/src/navigation-instruments/velocity-projection-plot/velocity-projection-plot.stories.ts +13 -13
  78. package/src/navigation-instruments/velocity-projection-plot/velocity-projection-plot.ts +15 -11
  79. package/src/navigation-instruments/watch/environment.ts +120 -87
  80. package/src/navigation-instruments/watch/watch.stories.ts +2 -2
  81. package/src/navigation-instruments/watch/watch.ts +3 -3
  82. package/src/navigation-instruments/wind/wind.stories.ts +4 -3
  83. package/src/navigation-instruments/wind/wind.ts +2 -2
  84. package/src/navigation-instruments/wind-indicator/wind-indicator.stories.ts +22 -12
  85. package/src/navigation-instruments/wind-indicator/wind-indicator.ts +91 -46
  86. package/src/navigation-instruments/wind-propulsion/wind-propulsion.stories.ts +3 -3
  87. package/src/navigation-instruments/wind-propulsion/wind-propulsion.ts +3 -3
  88. package/tsconfig.json +38 -0
  89. package/vite.config.ts +107 -0
  90. package/vitest.browser.config.ts +14 -0
  91. package/vitest.config.ts +51 -0
  92. package/xliff/es-419.xlf +111 -0
  93. package/xliff/fi-FI.xlf +139 -0
  94. package/dist/NotoSans.ttf +0 -0
  95. package/dist/oicl.svg +0 -4
@@ -0,0 +1,193 @@
1
+ import {Api} from 'figma-api';
2
+ import type {
3
+ CanvasNode,
4
+ FrameNode,
5
+ GetFileResponse,
6
+ Style,
7
+ SubcanvasNode,
8
+ } from '@figma/rest-api-spec';
9
+ import * as dotenv from 'dotenv';
10
+ import * as fs from 'fs';
11
+ import {
12
+ IconRef,
13
+ getCssColorIcon,
14
+ getStylesForNode,
15
+ kebabToUpperCamelCase,
16
+ } from './convert-icons.js';
17
+
18
+ dotenv.config();
19
+
20
+ const documentId = 'TPoHGyeEtlcpnNekOa4lY3';
21
+
22
+ const useCache = false;
23
+
24
+ const iconMapUrl: {url: string; name: string; typeA: boolean}[] = [
25
+ {
26
+ url: 'https://www.figma.com/file/TPoHGyeEtlcpnNekOa4lY3/OpenBridge-CAM?type=design&node-id=850-47442&mode=design&t=QA1ohadrbRZxW1ss-4',
27
+ name: '14-alarm-unack',
28
+ typeA: true,
29
+ },
30
+ {
31
+ url: 'https://www.figma.com/file/TPoHGyeEtlcpnNekOa4lY3/OpenBridge-CAM?type=design&node-id=850-47508&mode=design&t=QA1ohadrbRZxW1ss-4',
32
+ name: '14-alarm-unack',
33
+ typeA: false,
34
+ },
35
+ {
36
+ url: 'https://www.figma.com/file/TPoHGyeEtlcpnNekOa4lY3/OpenBridge-CAM?type=design&node-id=850-47481&mode=design&t=QA1ohadrbRZxW1ss-4',
37
+ name: '14-alarm-silenced',
38
+ typeA: true,
39
+ },
40
+ {
41
+ url: 'https://www.figma.com/file/TPoHGyeEtlcpnNekOa4lY3/OpenBridge-CAM?type=design&node-id=850-47505&mode=design&t=QA1ohadrbRZxW1ss-4',
42
+ name: '14-alarm-silenced',
43
+ typeA: false,
44
+ },
45
+ {
46
+ url: 'https://www.figma.com/file/TPoHGyeEtlcpnNekOa4lY3/OpenBridge-CAM?type=design&node-id=850-47445&mode=design&t=QA1ohadrbRZxW1ss-4',
47
+ name: '14-warning-unack',
48
+ typeA: true,
49
+ },
50
+ {
51
+ url: 'https://www.figma.com/file/TPoHGyeEtlcpnNekOa4lY3/OpenBridge-CAM?type=design&node-id=850-47475&mode=design&t=QA1ohadrbRZxW1ss-4',
52
+ name: '14-warning-unack',
53
+ typeA: false,
54
+ },
55
+ ];
56
+
57
+ const iconMap: {id: string; name: string; typeA: boolean}[] = iconMapUrl.map(
58
+ (icon) => {
59
+ let id = icon.url.match(/node-id=([0-9/-]+)/)![1];
60
+ // replace - with :
61
+ id = id.replace(/-/g, ':');
62
+ return {id, name: icon.name, typeA: icon.typeA};
63
+ }
64
+ );
65
+
66
+ const iconDir = './src/components/alert-icon/icons';
67
+ const cacheDir = './script/.cache/alert-icons';
68
+
69
+ export async function main() {
70
+ // delete all icons
71
+
72
+ if (fs.existsSync(iconDir)) {
73
+ const files = fs.readdirSync(iconDir);
74
+ for (const file of files) {
75
+ fs.unlinkSync(`${iconDir}/${file}`);
76
+ }
77
+ } else {
78
+ fs.mkdirSync(iconDir);
79
+ }
80
+
81
+ if (!fs.existsSync(cacheDir)) {
82
+ fs.mkdirSync(cacheDir, {recursive: true});
83
+ }
84
+
85
+ const api_token = process.env.FIGMA_TOKEN;
86
+ if (!api_token) {
87
+ throw new Error('FIGMA_TOKEN is not set, please set it in the .env file');
88
+ }
89
+
90
+ const api = new Api({
91
+ personalAccessToken: api_token,
92
+ });
93
+
94
+ const cachepath = './script/.cache-figma-alert.json';
95
+ let file: GetFileResponse;
96
+ if (fs.existsSync(cachepath) && useCache) {
97
+ file = JSON.parse(fs.readFileSync(cachepath, 'utf8'));
98
+ } else {
99
+ file = await api.getFile({file_key: documentId}, {ids: '850:47441'});
100
+ // save to cache
101
+ fs.writeFileSync(cachepath, JSON.stringify(file, null, 2));
102
+ }
103
+ console.log('Got page');
104
+ const page = file.document.children.find(
105
+ (p) => p.name === 'Icons'
106
+ ) as CanvasNode;
107
+ const frames = page.children.filter(
108
+ (child) => child.name === 'Frame 3'
109
+ ) as FrameNode[];
110
+ const styles: {[styleId: string]: Style} = file.styles;
111
+
112
+ const knownIds = iconMap.map((icon) => icon.id);
113
+ let icons = frames.flatMap((frame): IconRef[] => {
114
+ return frame.children
115
+ .filter((child) => knownIds.includes(child.id))
116
+ .map((child) => {
117
+ const icon = iconMap.find((icon) => icon.id === child.id);
118
+ const name = icon!.name + (icon!.typeA ? '-a' : '-b');
119
+ const javascriptName = 'svg' + kebabToUpperCamelCase(name);
120
+ return {
121
+ name: name,
122
+ id: child.id,
123
+ javascriptName: javascriptName,
124
+ styles: getStylesForNode(child as SubcanvasNode, styles),
125
+ };
126
+ });
127
+ });
128
+
129
+ // remove duplicate icon names
130
+ const seen = new Set();
131
+ icons = icons.filter((icon) => {
132
+ const duplicate = seen.has(icon.javascriptName);
133
+ seen.add(icon.javascriptName);
134
+ if (duplicate) {
135
+ console.log('Duplicate icon name', icon.name);
136
+ }
137
+ return !duplicate;
138
+ });
139
+
140
+ // download all icons
141
+ if (!useCache) {
142
+ const split = 50;
143
+ for (let i = 0; i < icons.length; i += split) {
144
+ console.log('Got images', i);
145
+ const iconChunks = icons.slice(i, i + split);
146
+ const images = await api.getImages(
147
+ {file_key: documentId},
148
+ {
149
+ ids: iconChunks.map((icon) => icon.id).join(','),
150
+ scale: 1,
151
+ format: 'svg',
152
+ }
153
+ );
154
+
155
+ // write icons to disk
156
+ await Promise.all(
157
+ Object.keys(images.images).map(async (nodeId) => {
158
+ const icon = icons.find((icon) => icon.id === nodeId);
159
+ const imageUrl = images.images[nodeId];
160
+ if (icon && imageUrl) {
161
+ // download icons
162
+ const request = await fetch(imageUrl);
163
+ const imageData = await request.text();
164
+ fs.writeFileSync(`${cacheDir}/${icon.name}.svg`, imageData);
165
+ }
166
+ })
167
+ );
168
+ }
169
+ }
170
+
171
+ const fileImport: string[] = [];
172
+ for (const icon of icons) {
173
+ const imageData = fs.readFileSync(`${cacheDir}/${icon.name}.svg`, 'utf8');
174
+ const cssColorIcon = getCssColorIcon(imageData, icon);
175
+
176
+ // convert icon.name from kebab case to upper cammel case
177
+ const name = icon.name.toLowerCase();
178
+
179
+ const component = `import {svg} from 'lit';
180
+ export const ${icon.javascriptName} = svg\`${cssColorIcon}\`;
181
+ `;
182
+ fs.writeFileSync(`${iconDir}/icon-${name}.ts`, component);
183
+ fileImport.push(
184
+ `import {${icon.javascriptName}} from './icons/icon-${name}';`
185
+ );
186
+ }
187
+
188
+ fileImport.sort();
189
+ console.log(fileImport.join('\n'));
190
+ console.log('done');
191
+ }
192
+
193
+ main();
@@ -0,0 +1,314 @@
1
+ import {Api} from 'figma-api';
2
+ import type {
3
+ CanvasNode,
4
+ ComponentNode,
5
+ FrameNode,
6
+ GetFileResponse,
7
+ Style,
8
+ SubcanvasNode,
9
+ TextNode,
10
+ } from '@figma/rest-api-spec';
11
+ import * as dotenv from 'dotenv';
12
+ import * as fs from 'fs';
13
+ import {
14
+ getCssColorIcon,
15
+ getSingleColorIcon,
16
+ getStylesForNode,
17
+ kebabToUpperCamelCase,
18
+ } from './convert-icons.js';
19
+
20
+ dotenv.config();
21
+
22
+ interface IconRef {
23
+ name: string;
24
+ id: string;
25
+ javascriptName: string;
26
+ styles: {[colorCode: string]: {cssClass: string}};
27
+ categories: string[];
28
+ }
29
+ const documentId = 'IkDwOtza6OdjLbIdWA7mI7';
30
+
31
+ const useCache = false;
32
+
33
+ function recursiveFindNodeByPath(
34
+ node: CanvasNode | FrameNode,
35
+ path: string[]
36
+ ): SubcanvasNode | null {
37
+ const oldPath = [...path];
38
+ const name = path.shift();
39
+ for (const child of node.children) {
40
+ if (child.name === name) {
41
+ if (path.length === 0) {
42
+ return child;
43
+ }
44
+ if (child.type === 'FRAME') {
45
+ return recursiveFindNodeByPath(child, path);
46
+ }
47
+ return null;
48
+ }
49
+ }
50
+ for (const child of node.children) {
51
+ if (child.type === 'FRAME') {
52
+ const found = recursiveFindNodeByPath(child, oldPath);
53
+ if (found) {
54
+ return found;
55
+ }
56
+ }
57
+ }
58
+ return null;
59
+ }
60
+
61
+ function findIconsInPage(
62
+ node: CanvasNode,
63
+ styles: {[styleName: string]: Style}
64
+ ): IconRef[] {
65
+ const icons: IconRef[] = [];
66
+ const pageName = node.name.substring(3); // remove id from name
67
+ for (const card of node.children) {
68
+ if (card.type !== 'FRAME') {
69
+ continue;
70
+ }
71
+ if (card.name === '.Navigation-bar') {
72
+ continue;
73
+ }
74
+ if (card.name === 'filter') {
75
+ continue;
76
+ }
77
+ if (
78
+ ['3420:28660', '3420:31035', '3420:32585', '3427:38428'].includes(card.id)
79
+ ) {
80
+ // Scip "Intro cards"
81
+ continue;
82
+ }
83
+ const sectionTitle = recursiveFindNodeByPath(card, [
84
+ 'Icon section title',
85
+ 'Text container',
86
+ 'Title',
87
+ ]) as FrameNode | null;
88
+ if (!sectionTitle) {
89
+ console.error(
90
+ 'No section title found. Page: ' + pageName + ' Card: ' + card.name
91
+ );
92
+ continue;
93
+ }
94
+ const sectionTitleText = sectionTitle.children[1] as TextNode;
95
+ const title = sectionTitleText.characters;
96
+ const newIcons = recursiveFindIcons(card, [pageName, title], styles);
97
+ console.log(
98
+ 'Found ' +
99
+ newIcons.map((icon) => icon.name).join(', ') +
100
+ ' icons in section: ' +
101
+ title +
102
+ ' on page: ' +
103
+ pageName
104
+ );
105
+ icons.push(...newIcons);
106
+ }
107
+ return icons;
108
+ }
109
+
110
+ function recursiveFindIcons(
111
+ node: FrameNode,
112
+ categories: string[],
113
+ styles: {[styleName: string]: Style}
114
+ ): IconRef[] {
115
+ const icons = node.children
116
+ .filter(
117
+ (child): child is ComponentNode =>
118
+ child.type === 'COMPONENT' &&
119
+ !['01-illustration', '0-illustration'].includes(child.name)
120
+ )
121
+ .map((icon) => createIconRef(icon, styles, categories));
122
+ const frames = node.children.filter(
123
+ (child): child is FrameNode => child.type === 'FRAME'
124
+ );
125
+ for (const frame of frames) {
126
+ icons.push(...recursiveFindIcons(frame, categories, styles));
127
+ }
128
+ return icons;
129
+ }
130
+
131
+ export async function main() {
132
+ // delete all icons
133
+ const iconDir = './src/icons';
134
+ if (fs.existsSync(iconDir)) {
135
+ const files = fs.readdirSync(iconDir);
136
+ for (const file of files.filter((file) => file !== 'icon.ts')) {
137
+ fs.unlinkSync(`${iconDir}/${file}`);
138
+ }
139
+ } else {
140
+ fs.mkdirSync(iconDir);
141
+ }
142
+
143
+ const api_token = process.env.FIGMA_TOKEN;
144
+ if (!api_token) {
145
+ throw new Error('FIGMA_TOKEN is not set, please set it in the .env file');
146
+ }
147
+
148
+ const api = new Api({
149
+ personalAccessToken: api_token,
150
+ });
151
+
152
+ const cachepath = './script/.cache-figma.json';
153
+ let file: GetFileResponse;
154
+ const cacheExists = fs.existsSync(cachepath);
155
+ const cacheIsOld =
156
+ cacheExists &&
157
+ fs.statSync(cachepath).mtime.getTime() < Date.now() - 1000 * 60 * 60;
158
+ if (cacheExists && useCache && !cacheIsOld) {
159
+ file = JSON.parse(fs.readFileSync(cachepath, 'utf8'));
160
+ } else {
161
+ file = await api.getFile({file_key: documentId});
162
+ // save to cache
163
+ fs.writeFileSync(cachepath, JSON.stringify(file));
164
+ }
165
+
166
+ const pages = file.document.children.filter(
167
+ (p) => !['3512:9655', '3597:122', '3427:38027'].includes(p.id)
168
+ );
169
+ const styles = file.styles;
170
+
171
+ let icons: IconRef[] = [];
172
+
173
+ for (const page of pages) {
174
+ icons.push(...findIconsInPage(page as CanvasNode, styles));
175
+ }
176
+
177
+ // remove duplicate icon names
178
+ const seen = new Set();
179
+ icons = icons.filter((icon) => {
180
+ const duplicate = seen.has(icon.javascriptName);
181
+ seen.add(icon.javascriptName);
182
+ if (duplicate) {
183
+ console.log('Duplicate icon name', icon.name);
184
+ }
185
+ return !duplicate;
186
+ });
187
+
188
+ const iconsToDownload = useCache
189
+ ? icons.filter((icon) => {
190
+ return !fs.existsSync(`./script/.cache/icons/${icon.name}.svg`);
191
+ })
192
+ : icons;
193
+
194
+ // download icons
195
+
196
+ const split = 50;
197
+ for (let i = 0; i < iconsToDownload.length; i += split) {
198
+ console.log('Got images', i);
199
+ const iconChunks = iconsToDownload.slice(i, i + split);
200
+ const images = await api.getImages(
201
+ {file_key: documentId},
202
+ {
203
+ ids: iconChunks.map((icon) => icon.id).join(','),
204
+ scale: 1,
205
+ format: 'svg',
206
+ }
207
+ );
208
+
209
+ // write icons to disk
210
+ await Promise.all(
211
+ Object.keys(images.images).map(async (nodeId) => {
212
+ const icon = icons.find((icon) => icon.id === nodeId);
213
+ const imageUrl = images.images[nodeId];
214
+ if (icon && imageUrl) {
215
+ // download icons
216
+ const request = await fetch(imageUrl);
217
+ const imageData = await request.text();
218
+ fs.writeFileSync(`./script/.cache/icons/${icon.name}.svg`, imageData);
219
+ }
220
+ })
221
+ );
222
+ }
223
+
224
+ const scriptMapping: string[] = [];
225
+ const fileImport: string[] = [];
226
+ for (const icon of icons) {
227
+ const imageData = fs.readFileSync(
228
+ `./script/.cache/icons/${icon.name}.svg`,
229
+ 'utf8'
230
+ );
231
+ const cssColorIcon = getCssColorIcon(imageData, icon);
232
+ const singleColorIcon = getSingleColorIcon(imageData, icon);
233
+
234
+ // convert icon.name from kebab case to upper cammel case
235
+ const upperCammelCaseName = kebabToUpperCamelCase(icon.name);
236
+ const name = icon.name.toLowerCase();
237
+
238
+ const component = `import {LitElement, html, css, svg} from 'lit';
239
+ import {property} from 'lit/decorators.js';
240
+ import {customElement} from '../decorator.js';
241
+
242
+ @customElement('obi-${name}')
243
+ export class Obi${upperCammelCaseName} extends LitElement {
244
+ @property({type: Boolean}) useCssColor = false;
245
+
246
+ private icon = svg\`${singleColorIcon}\`;
247
+
248
+ private iconCss = svg\`${cssColorIcon}\`;
249
+
250
+ override render() {
251
+ return html\`
252
+ <div class="wrapper">\${this.useCssColor ? this.iconCss : this.icon}</div>
253
+ \`;
254
+ }
255
+
256
+
257
+ static override styles = css\`
258
+ .wrapper {
259
+ height: 100%;
260
+ width: 100%;
261
+ line-height: 0;
262
+ }
263
+ .wrapper > * {
264
+ height: 100%;
265
+ width: 100%;
266
+ }
267
+ \`;
268
+ }
269
+
270
+ declare global {
271
+ interface HTMLElementTagNameMap {
272
+ 'obi-${name}': Obi${upperCammelCaseName};
273
+ }
274
+ }`;
275
+ fs.writeFileSync(`./src/icons/icon-${name}.ts`, component);
276
+ fileImport.push(`import './icon-${name}.js';`);
277
+
278
+ scriptMapping.push(`'${icon.name}': ['${icon.categories.join("', '")}']`);
279
+ }
280
+
281
+ // write script
282
+ const script = `export const iconIds: Record<string, string[]> = {
283
+ ${scriptMapping.sort().join(',\n')}
284
+ };
285
+ `;
286
+ fs.writeFileSync('./src/icons/names.ts', script);
287
+ fileImport.sort();
288
+ fileImport.push('export { ObiIcon } from "./icon.js";');
289
+ fs.writeFileSync('./src/icons/index.ts', fileImport.join('\n'));
290
+ console.log('done');
291
+ }
292
+
293
+ main();
294
+ function createIconRef(
295
+ child: ComponentNode,
296
+ styles: {[styleName: string]: Style},
297
+ categories: string[] = []
298
+ ): IconRef {
299
+ const name = child.name
300
+ .toLocaleLowerCase()
301
+ .replace(/æ/g, 'ae')
302
+ .replace(/ø/g, 'oe')
303
+ .replace(/å/g, 'aa')
304
+ .replace(/ /g, '')
305
+ .replace(/%/g, '');
306
+ const javascriptName = 'svg' + name.replace(/[^a-zA-Z0-9]/g, '');
307
+ return {
308
+ name: name,
309
+ id: child.id,
310
+ javascriptName: javascriptName,
311
+ styles: getStylesForNode(child, styles),
312
+ categories: categories,
313
+ };
314
+ }
@@ -0,0 +1,139 @@
1
+ {
2
+ "VariableID:1b39a46721c3451d87c9b07292b9fef6ae86b874/27539:50": "border-outline-color",
3
+ "VariableID:12d856ec4be56c9428e360d289d1b27048893dc3/27539:228": "automation-device-tertiary-inverted-color",
4
+ "VariableID:b188d8bb01ab018e9472eb2b71b6df846fa0b80e/27539:225": "automation-device-tertiary-color",
5
+ "VariableID:1dc272bd7d84b93d2f356c26f1e99c3f5c6fadb2/27539:223": "automation-device-primary-color",
6
+ "VariableID:3f19014afa97397dfb54ae295c580a41a0b96f54/27539:68": "alert-alarm-color",
7
+ "VariableID:04ae28536959a8c36d4412f7c25e27c2ab26cf5f/27539:414": "alert-alarm-outline-color",
8
+ "VariableID:ba05439bbd06c4f8ff0beb10a2d95a53254be2ca/27539:71": "on-alarm-color",
9
+ "VariableID:dcd704e2dcb29496b7ec52bf1b9ae2285391fdda/27539:214": "on-alarm-active-color",
10
+ "VariableID:3c2fba1b9d8d6c8f8df87dbaa11a941a87dff69e/27539:69": "alert-warning-color",
11
+ "VariableID:028a6015d864bf94d8ca7d2917be854b87900e69/27539:325": "alert-warning-outline-color",
12
+ "VariableID:37074b7dccecb7d93c4f989d3cf156c319fac32d/27539:211": "on-warning-active-color",
13
+ "VariableID:8639304f251cc403fa6886b8c3652e4ef3795d6c/27539:78": "alert-running-color",
14
+ "VariableID:f5ea9b3d63742557e8ad8331b352e851c7ca04bc/27539:317": "on-running-active-color",
15
+ "VariableID:66712a120176392fb4f3229ddfa4b9feb1f489c1/27539:70": "alert-caution-color",
16
+ "VariableID:85fbc997d1f2213fafb26798f95e66e7f44fd0dc/27539:324": "alert-caution-outline-color",
17
+ "VariableID:7947ce7f6fe244fd57d473dfed7d1adc7933bb64/27539:208": "on-caution-active-color",
18
+ "VariableID:d97299ff03540d70ef100f2bc71618ee65760666/27539:195": "indent-enabled-background-color",
19
+ "VariableID:bdc3858e7ec77df8164471d55c165a8bb165a319/27539:196": "indent-enabled-border-color",
20
+ "VariableID:e1180c439049346db7bf1bffc0a848f21dc90d69/27539:43": "element-neutral-color",
21
+ "VariableID:0fbed0fce14adf342e3004730ed5563681147068/27539:74": "element-active-inverted-color",
22
+ "VariableID:971117b0dddce7e8b6326d986c384e7d7375c87a/27539:183": "data-weather-sun-primary-color",
23
+ "VariableID:40666ac8e01d54159d7eaa8935c426a80789ac21/27539:184": "data-weather-sun-secondary-color",
24
+ "VariableID:d8cfac56a2a220455295dc0628385e942e8c46ab/27539:185": "data-weather-cloud-light-primary-color",
25
+ "VariableID:7badfeb3d88a66838f8cb7d4b115bf70e35c3e84/27539:186": "data-weather-cloud-light-seconday-color",
26
+ "VariableID:778aa43d12101e8aab99f0258191b8a2d258f0b5/27539:221": "data-weather-cloud-primary-color",
27
+ "VariableID:4ce6619ec54c1f6d80c9e5fb6c68349363402c66/27539:220": "data-weather-cloud-seconday-color",
28
+ "VariableID:152bfe36b2e029763836d9997634e1431f793fab/27539:192": "data-weather-rain-primary-color",
29
+ "VariableID:fad3f7c9335c9c30cf318c4b0937db1b2f2799c0/27539:187": "data-weather-cloud-rain-primary-color",
30
+ "VariableID:ad5f861a79e6705713ab94a85944a491334bc9af/27539:188": "data-weather-cloud-rain-secondary-color",
31
+ "VariableID:a7a0997bbb102160d04b582aa4ea7409409132ff/27539:190": "data-weather-cloud-heavy-primary-color",
32
+ "VariableID:b49c7f446bb89bc9315113cc7c455fd37d8178e5/27539:189": "data-weather-cloud-heavy-secondary-color",
33
+ "VariableID:745adc5453dc04b30e6263b876b57b15ad7cbad8/27539:193": "data-weather-lightning-primary-color",
34
+ "VariableID:af5e0ab99006df951da2a87d494e101dfdd245f1/27539:191": "data-weather-snow-primary-color",
35
+ "VariableID:ee68310f2c297c0cfdf7eaaf563b70589bf89cd5/27539:194": "data-weather-moon-primary-color",
36
+ "VariableID:1e5e649fcf32a3d37c17dfb6b47624db51998ebe/27539:61": "instrument-tick-mark-secondary-color",
37
+ "VariableID:da6590ed7619907bed81207a16c3a1aaa8997c60/27539:226": "automation-device-primary-inverted-color",
38
+ "VariableID:45c59cee99f65610be0052ca4f056343a68db215/27539:285": "automation-pipe-primary-color",
39
+ "VariableID:38f5e367af8c33083d86f11a32c887a35a99f574/27539:287": "automation-pipe-tertiary-color",
40
+ "VariableID:6936f32a01f07189d16fe2925a6db067e5da4b01/27539:150": "navigation-light-yellow-color",
41
+ "VariableID:bc6744610e304d3527fdcbc339272f690dbac331/27539:149": "navigation-light-red-color",
42
+ "VariableID:8e3473b6a468663b814d3cbc8ba21441099a6522/27539:148": "navigation-light-green-color",
43
+ "VariableID:8da084358336f923a341e5ebf490ca7440a1595e/27539:45": "element-disabled-color",
44
+ "VariableID:52957003cecd36ac7cfef85a6eb615644ab157fb/27539:47": "container-background-color",
45
+ "VariableID:66712a120176392fb4f3229ddfa4b9feb1f489c1/26029:960": "alert-caution-color",
46
+ "VariableID:5f95286e7464c24855fd5968136fc446fdd7fd75/26029:963": "on-caution-color",
47
+ "VariableID:f9f95a44a756439f6cc70f7384bd184932714bf9/27539:224": "automation-device-secondary-color",
48
+ "VariableID:9e87ee011b9e69609351ed65156519e5c1cd61a1/20358:1244": "on-indent-neutral-color",
49
+ "VariableID:e3ac1ca4108adbc16e84057f77a9b318f3497f5d/27539:42": "element-active-color",
50
+ "VariableID:f9f0737e0ae154a81b9defc2a3e8180e7ff73527/1180:8": "active-text",
51
+ "VariableID:f0e04b849b5b3118f8a2cdc5019ffe26b6969ee7/20358:304": "base-cyan-100",
52
+ "VariableID:70464ca2671a0c8873a63874890228c2b3e83cec/20358:1241": "on-normal-neutral-color",
53
+ "VariableID:a36dd8a3bfb87cbfede2a2e0cca5990b155a4947/20358:134": "on-warning-color",
54
+ "VariableID:c0bd5311474512cc976c304aea390a01f3dfb663/20358:288": "on-running-color",
55
+ "VariableID:4adefb0a443c39e9e48c98ea96dbefe5e39ccb03/20546:22": "container-section-color",
56
+ "VariableID:e3ac1ca4108adbc16e84057f77a9b318f3497f5d/25623:784": "element-active-color",
57
+ "VariableID:23e14f7dd8a9a2a5e35e0cb1e26a4c8ff820c197/20358:223": "warning-enabled-background-color",
58
+ "VariableID:5cebb65b885cfc047ae8ac8781dd44644dbfcde8/20358:1262": "on-indent-active-color",
59
+ "VariableID:fcdf82685406e2fd5689411671980ac76428f6e7/20358:275": "on-alarm-neutral-color",
60
+ "VariableID:1dc272bd7d84b93d2f356c26f1e99c3f5c6fadb2/24272:183": "automation-device-primary-color",
61
+ "VariableID:38f5e367af8c33083d86f11a32c887a35a99f574/8048:692": "automation-pipe-tertiary-color",
62
+ "VariableID:f041eb0e7a839819ea5b173a176a3d38ca501455/20546:5": "container-global-color",
63
+ "VariableID:e3ac1ca4108adbc16e84057f77a9b318f3497f5d/26029:932": "element-active-color",
64
+ "VariableID:b188d8bb01ab018e9472eb2b71b6df846fa0b80e/24272:185": "automation-device-tertiary-color",
65
+ "VariableID:da6590ed7619907bed81207a16c3a1aaa8997c60/24272:186": "automation-device-primary-inverted-color",
66
+ "VariableID:12d856ec4be56c9428e360d289d1b27048893dc3/24272:188": "automation-device-tertiary-inverted-color",
67
+ "VariableID:f9f95a44a756439f6cc70f7384bd184932714bf9/24272:184": "automation-device-secondary-color",
68
+ "VariableID:da6590ed7619907bed81207a16c3a1aaa8997c60/26029:1115": "automation-device-primary-inverted-color",
69
+ "VariableID:f9f95a44a756439f6cc70f7384bd184932714bf9/26029:1113": "automation-device-secondary-color",
70
+ "VariableID:e1180c439049346db7bf1bffc0a848f21dc90d69/3040:838": "element-neutral-color",
71
+ "VariableID:1b39a46721c3451d87c9b07292b9fef6ae86b874/3040:664": "border-outline-color",
72
+ "VariableID:1b39a46721c3451d87c9b07292b9fef6ae86b874/20546:146": "border-outline-color",
73
+ "VariableID:45c59cee99f65610be0052ca4f056343a68db215/26029:1307": "automation-pipe-primary-color",
74
+ "VariableID:38f5e367af8c33083d86f11a32c887a35a99f574/26029:1309": "automation-pipe-tertiary-color",
75
+ "VariableID:e3ac1ca4108adbc16e84057f77a9b318f3497f5d/24272:2": "element-active-color",
76
+ "VariableID:e3ac1ca4108adbc16e84057f77a9b318f3497f5d/20358:1257": "element-active-color",
77
+ "VariableID:12d856ec4be56c9428e360d289d1b27048893dc3/20594:0": "automation-device-tertiary-inverted-color",
78
+ "VariableID:b188d8bb01ab018e9472eb2b71b6df846fa0b80e/20413:11": "automation-device-tertiary-color",
79
+ "VariableID:1dc272bd7d84b93d2f356c26f1e99c3f5c6fadb2/20413:9": "automation-device-primary-color",
80
+ "VariableID:f9f95a44a756439f6cc70f7384bd184932714bf9/20413:10": "automation-device-secondary-color",
81
+ "VariableID:e3ac1ca4108adbc16e84057f77a9b318f3497f5d/5881:138": "element-active-color",
82
+ "VariableID:3f19014afa97397dfb54ae295c580a41a0b96f54/20358:130": "alert-alarm-color",
83
+ "VariableID:04ae28536959a8c36d4412f7c25e27c2ab26cf5f/20358:793": "alert-alarm-outline-color",
84
+ "VariableID:ba05439bbd06c4f8ff0beb10a2d95a53254be2ca/20546:145": "on-alarm-color",
85
+ "VariableID:dcd704e2dcb29496b7ec52bf1b9ae2285391fdda/20546:141": "on-alarm-active-color",
86
+ "VariableID:3c2fba1b9d8d6c8f8df87dbaa11a941a87dff69e/20358:131": "alert-warning-color",
87
+ "VariableID:028a6015d864bf94d8ca7d2917be854b87900e69/20358:370": "alert-warning-outline-color",
88
+ "VariableID:37074b7dccecb7d93c4f989d3cf156c319fac32d/20358:271": "on-warning-active-color",
89
+ "VariableID:8639304f251cc403fa6886b8c3652e4ef3795d6c/20358:140": "alert-running-color",
90
+ "VariableID:f5ea9b3d63742557e8ad8331b352e851c7ca04bc/20546:142": "on-running-active-color",
91
+ "VariableID:66712a120176392fb4f3229ddfa4b9feb1f489c1/20358:132": "alert-caution-color",
92
+ "VariableID:85fbc997d1f2213fafb26798f95e66e7f44fd0dc/20358:369": "alert-caution-outline-color",
93
+ "VariableID:7947ce7f6fe244fd57d473dfed7d1adc7933bb64/20358:268": "on-caution-active-color",
94
+ "VariableID:d97299ff03540d70ef100f2bc71618ee65760666/20546:24": "indent-enabled-background-color",
95
+ "VariableID:bdc3858e7ec77df8164471d55c165a8bb165a319/20358:1148": "indent-enabled-border-color",
96
+ "VariableID:e1180c439049346db7bf1bffc0a848f21dc90d69/20358:1239": "element-neutral-color",
97
+ "VariableID:0fbed0fce14adf342e3004730ed5563681147068/20358:136": "element-active-inverted-color",
98
+ "VariableID:971117b0dddce7e8b6326d986c384e7d7375c87a/20358:243": "data-weather-sun-primary-color",
99
+ "VariableID:40666ac8e01d54159d7eaa8935c426a80789ac21/20358:244": "data-weather-sun-secondary-color",
100
+ "VariableID:d8cfac56a2a220455295dc0628385e942e8c46ab/20508:31": "data-weather-cloud-light-primary-color",
101
+ "VariableID:7badfeb3d88a66838f8cb7d4b115bf70e35c3e84/20508:32": "data-weather-cloud-light-seconday-color",
102
+ "VariableID:778aa43d12101e8aab99f0258191b8a2d258f0b5/20508:45": "data-weather-cloud-primary-color",
103
+ "VariableID:4ce6619ec54c1f6d80c9e5fb6c68349363402c66/20508:44": "data-weather-cloud-seconday-color",
104
+ "VariableID:152bfe36b2e029763836d9997634e1431f793fab/20508:38": "data-weather-rain-primary-color",
105
+ "VariableID:fad3f7c9335c9c30cf318c4b0937db1b2f2799c0/20508:33": "data-weather-cloud-rain-primary-color",
106
+ "VariableID:ad5f861a79e6705713ab94a85944a491334bc9af/20508:34": "data-weather-cloud-rain-secondary-color",
107
+ "VariableID:a7a0997bbb102160d04b582aa4ea7409409132ff/20508:36": "data-weather-cloud-heavy-primary-color",
108
+ "VariableID:b49c7f446bb89bc9315113cc7c455fd37d8178e5/20508:35": "data-weather-cloud-heavy-secondary-color",
109
+ "VariableID:745adc5453dc04b30e6263b876b57b15ad7cbad8/20508:39": "data-weather-lightning-primary-color",
110
+ "VariableID:af5e0ab99006df951da2a87d494e101dfdd245f1/20508:37": "data-weather-snow-primary-color",
111
+ "VariableID:ee68310f2c297c0cfdf7eaaf563b70589bf89cd5/20508:40": "data-weather-moon-primary-color",
112
+ "VariableID:1e5e649fcf32a3d37c17dfb6b47624db51998ebe/20546:4": "instrument-tick-mark-secondary-color",
113
+ "VariableID:4adefb0a443c39e9e48c98ea96dbefe5e39ccb03/27539:48": "container-section-color",
114
+ "VariableID:12d856ec4be56c9428e360d289d1b27048893dc3/25146:860": "automation-device-tertiary-inverted-color",
115
+ "VariableID:da6590ed7619907bed81207a16c3a1aaa8997c60/25146:858": "automation-device-primary-inverted-color",
116
+ "VariableID:da6590ed7619907bed81207a16c3a1aaa8997c60/20413:12": "automation-device-primary-inverted-color",
117
+ "VariableID:12d856ec4be56c9428e360d289d1b27048893dc3/25990:2991": "automation-device-tertiary-inverted-color",
118
+ "VariableID:da6590ed7619907bed81207a16c3a1aaa8997c60/25990:1733": "automation-device-primary-inverted-color",
119
+ "VariableID:45c59cee99f65610be0052ca4f056343a68db215/20413:16": "automation-pipe-primary-color",
120
+ "VariableID:38f5e367af8c33083d86f11a32c887a35a99f574/20413:18": "automation-pipe-tertiary-color",
121
+ "VariableID:6936f32a01f07189d16fe2925a6db067e5da4b01/20508:27": "navigation-light-yellow-color",
122
+ "VariableID:bc6744610e304d3527fdcbc339272f690dbac331/20508:26": "navigation-light-red-color",
123
+ "VariableID:8e3473b6a468663b814d3cbc8ba21441099a6522/20508:25": "navigation-light-green-color",
124
+ "VariableID:e3ac1ca4108adbc16e84057f77a9b318f3497f5d/3040:832": "element-active-color",
125
+ "VariableID:8da084358336f923a341e5ebf490ca7440a1595e/20358:1133": "element-disabled-color",
126
+ "VariableID:52957003cecd36ac7cfef85a6eb615644ab157fb/20358:109": "container-background-color",
127
+ "VariableID:fcdf82685406e2fd5689411671980ac76428f6e7/27539:215": "on-alarm-neutral-color",
128
+ "VariableID:5f95286e7464c24855fd5968136fc446fdd7fd75/27539:73": "on-caution-color",
129
+ "VariableID:23e14f7dd8a9a2a5e35e0cb1e26a4c8ff820c197/27539:163": "warning-enabled-background-color",
130
+ "VariableID:f041eb0e7a839819ea5b173a176a3d38ca501455/27539:46": "container-global-color",
131
+ "VariableID:f9f0737e0ae154a81b9defc2a3e8180e7ff73527/1358:1": "active-text",
132
+ "VariableID:f0e04b849b5b3118f8a2cdc5019ffe26b6969ee7/27539:257": "base-cyan-100",
133
+ "VariableID:70464ca2671a0c8873a63874890228c2b3e83cec/27539:104": "on-normal-neutral-color",
134
+ "VariableID:a36dd8a3bfb87cbfede2a2e0cca5990b155a4947/27539:72": "on-warning-color",
135
+ "VariableID:c0bd5311474512cc976c304aea390a01f3dfb663/27539:229": "on-running-color",
136
+ "VariableID:5cebb65b885cfc047ae8ac8781dd44644dbfcde8/28770:94": "on-indent-active-color",
137
+ "VariableID:9e87ee011b9e69609351ed65156519e5c1cd61a1/28770:96": "on-indent-neutral-color",
138
+ "VariableID:e3ac1ca4108adbc16e84057f77a9b318f3497f5d/33216:2576": "element-active-color"
139
+ }