@carbon/ibm-products-web-components 0.0.1-canary.3564

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 (69) hide show
  1. package/.storybook/Preview.ts +161 -0
  2. package/.storybook/_container.scss +73 -0
  3. package/.storybook/container.ts +41 -0
  4. package/.storybook/main.ts +25 -0
  5. package/.storybook/manager.ts +13 -0
  6. package/.storybook/preview-head.html +3 -0
  7. package/.storybook/templates/with-layer.scss +38 -0
  8. package/.storybook/templates/with-layer.ts +90 -0
  9. package/.storybook/theme.ts +12 -0
  10. package/LICENSE +201 -0
  11. package/es/components/side-panel/defs.d.ts +39 -0
  12. package/es/components/side-panel/defs.js +51 -0
  13. package/es/components/side-panel/defs.js.map +1 -0
  14. package/es/components/side-panel/index.d.ts +9 -0
  15. package/es/components/side-panel/index.js +9 -0
  16. package/es/components/side-panel/index.js.map +1 -0
  17. package/es/components/side-panel/side-panel.d.ts +539 -0
  18. package/es/components/side-panel/side-panel.js +837 -0
  19. package/es/components/side-panel/side-panel.js.map +1 -0
  20. package/es/components/side-panel/side-panel.scss.js +13 -0
  21. package/es/components/side-panel/side-panel.scss.js.map +1 -0
  22. package/es/components/side-panel/side-panel.test.d.ts +7 -0
  23. package/es/components/side-panel/side-panel.test.js +56 -0
  24. package/es/components/side-panel/side-panel.test.js.map +1 -0
  25. package/es/globals/internal/handle.d.ts +18 -0
  26. package/es/globals/internal/handle.js +8 -0
  27. package/es/globals/internal/handle.js.map +1 -0
  28. package/es/globals/settings.d.ts +15 -0
  29. package/es/globals/settings.js +28 -0
  30. package/es/globals/settings.js.map +1 -0
  31. package/es/index.d.ts +9 -0
  32. package/es/index.js +9 -0
  33. package/es/index.js.map +1 -0
  34. package/lib/components/side-panel/defs.d.ts +39 -0
  35. package/lib/components/side-panel/defs.js +51 -0
  36. package/lib/components/side-panel/defs.js.map +1 -0
  37. package/lib/components/side-panel/index.d.ts +9 -0
  38. package/lib/components/side-panel/side-panel.d.ts +539 -0
  39. package/lib/components/side-panel/side-panel.test.d.ts +7 -0
  40. package/lib/globals/internal/handle.d.ts +18 -0
  41. package/lib/globals/settings.d.ts +15 -0
  42. package/lib/globals/settings.js +32 -0
  43. package/lib/globals/settings.js.map +1 -0
  44. package/lib/index.d.ts +9 -0
  45. package/netlify.toml +8 -0
  46. package/package.json +96 -0
  47. package/scss/components/side-panel/side-panel.scss +302 -0
  48. package/scss/components/side-panel/story-styles.scss +46 -0
  49. package/src/components/side-panel/defs.ts +46 -0
  50. package/src/components/side-panel/index.ts +10 -0
  51. package/src/components/side-panel/side-panel.mdx +106 -0
  52. package/src/components/side-panel/side-panel.scss +302 -0
  53. package/src/components/side-panel/side-panel.stories.ts +525 -0
  54. package/src/components/side-panel/side-panel.test.ts +52 -0
  55. package/src/components/side-panel/side-panel.ts +980 -0
  56. package/src/components/side-panel/story-styles.scss +46 -0
  57. package/src/globals/internal/handle.ts +19 -0
  58. package/src/globals/settings.ts +22 -0
  59. package/src/index.ts +10 -0
  60. package/src/typings/resources.d.ts +26 -0
  61. package/tasks/build.js +165 -0
  62. package/tools/rollup-plugin-icon-paths.js +39 -0
  63. package/tools/rollup-plugin-icons.js +73 -0
  64. package/tools/rollup-plugin-lit-scss.js +89 -0
  65. package/tools/svg-result-carbon-icon-loader.js +28 -0
  66. package/tools/svg-result-carbon-icon.js +42 -0
  67. package/tools/vite-svg-result-carbon-icon-loader.ts +65 -0
  68. package/tsconfig.json +36 -0
  69. package/vite.config.ts +32 -0
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright IBM Corp. 2023, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ @use '@carbon/styles/scss/theme' as *;
8
+
9
+ $story-prefix: 'side-panel-stories__';
10
+
11
+ .#{$story-prefix}body-content {
12
+ display: flex;
13
+ flex-direction: column;
14
+ padding: 1rem;
15
+ gap: 1rem;
16
+ }
17
+
18
+ .#{$story-prefix}text-inputs {
19
+ display: flex;
20
+ gap: 1rem;
21
+
22
+ > * {
23
+ flex-basis: 50%;
24
+ }
25
+ }
26
+
27
+ .#{$story-prefix}story-container {
28
+ position: fixed;
29
+ display: grid;
30
+ block-size: 100vh;
31
+ grid-template-rows: 3rem 1fr;
32
+ inline-size: 100vw;
33
+ inset-block-start: 0;
34
+ inset-inline-start: 0;
35
+ }
36
+
37
+ .#{$story-prefix}story-header {
38
+ background: $background-inverse;
39
+ }
40
+
41
+ .#{$story-prefix}story-content {
42
+ position: relative;
43
+ display: flex;
44
+ align-items: center;
45
+ justify-content: center;
46
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2019
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ /**
11
+ * An object to keep track of things that can be cleaned up.
12
+ */
13
+ export default interface Handle {
14
+ /**
15
+ * Releases the thing that this object is keeping track of.
16
+ * For example, if this `Handle` is keeping track of an event listener, this `release()` method removes the event listener.
17
+ */
18
+ release(): null;
19
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * Copyright IBM Corp. 2024, 2024
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ const prefix = 'c4p';
10
+ const carbonPrefix = 'cds';
11
+
12
+ /**
13
+ * A selector selecting tabbable nodes.
14
+ * Borrowed from `carbon-angular`. tabbable === focusable.
15
+ */
16
+ const selectorTabbable = `
17
+ ${prefix}-side-nav-link,
18
+ ${prefix}-side-nav-menu,
19
+ ${prefix}-side-nav-menu-item
20
+ `;
21
+ // Because we're going to have a bunch of exports
22
+ export { prefix, carbonPrefix, selectorTabbable };
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2024, 2024
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ export { default as CDSSidePanel } from './components/side-panel/side-panel';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2019, 2021
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ declare module '*.scss';
11
+ declare module '*.scss?lit';
12
+ declare module 'vitest/config';
13
+
14
+ declare module '*.mdx' {
15
+ let MDXComponent: (props: any) => JSX.Element;
16
+ // @ts-ignore
17
+ export default {
18
+ parameters: {
19
+ docs: {
20
+ // @ts-ignore
21
+ container: JSX.Element,
22
+ page: MDXComponent,
23
+ },
24
+ },
25
+ };
26
+ }
package/tasks/build.js ADDED
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ import { fileURLToPath } from 'url';
11
+ import { globby } from 'globby';
12
+ import { rollup } from 'rollup';
13
+ import alias from '@rollup/plugin-alias';
14
+ import autoprefixer from 'autoprefixer';
15
+ import carbonIcons from '../tools/rollup-plugin-icons.js';
16
+ import carbonIconPaths from '../tools/rollup-plugin-icon-paths.js';
17
+ import commonjs from '@rollup/plugin-commonjs';
18
+ import copy from 'rollup-plugin-copy';
19
+ import cssnano from 'cssnano';
20
+ import litSCSS from '../tools/rollup-plugin-lit-scss.js';
21
+ import nodeResolve from '@rollup/plugin-node-resolve';
22
+ import path from 'path';
23
+ import postcss from 'postcss';
24
+ import typescript from '@rollup/plugin-typescript';
25
+
26
+ import * as packageJson from '../package.json' assert { type: 'json' };
27
+
28
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
29
+
30
+ async function build() {
31
+ const esInputs = await globby([
32
+ 'src/**/*.ts',
33
+ '!src/**/*.stories.ts',
34
+ '!src/**/*.d.ts',
35
+ '!src/polyfills',
36
+ ]);
37
+
38
+ const libInputs = await globby([
39
+ 'src/components/**/defs.ts',
40
+ 'src/globals/**/*.ts',
41
+ '!src/globals/decorators/**/*.ts',
42
+ '!src/globals/directives/**/*.ts',
43
+ '!src/globals/internal/**/*.ts',
44
+ '!src/globals/mixins/**/*.ts',
45
+ ]);
46
+
47
+ const iconInput = await globby([
48
+ 'node_modules/@carbon/icons/lib/**/*.js',
49
+ '!**/index.js',
50
+ ]);
51
+
52
+ const entryPoint = {
53
+ rootDir: 'src',
54
+ outputDirectory: path.resolve(__dirname, '..'),
55
+ };
56
+
57
+ const formats = [
58
+ {
59
+ type: 'esm',
60
+ directory: 'es',
61
+ },
62
+ {
63
+ type: 'commonjs',
64
+ directory: 'lib',
65
+ },
66
+ ];
67
+
68
+ for (const format of formats) {
69
+ const outputDirectory = path.join(
70
+ entryPoint.outputDirectory,
71
+ format.directory
72
+ );
73
+
74
+ const cwcInputConfig = getRollupConfig(
75
+ format.type === 'esm' ? esInputs : libInputs,
76
+ entryPoint.rootDir,
77
+ outputDirectory,
78
+ format.type === 'esm' ? iconInput : []
79
+ );
80
+
81
+ const cwcBundle = await rollup(cwcInputConfig);
82
+
83
+ await cwcBundle.write({
84
+ dir: outputDirectory,
85
+ format: format.type,
86
+ preserveModules: true,
87
+ preserveModulesRoot: 'src',
88
+ banner,
89
+ exports: 'named',
90
+ sourcemap: true,
91
+ });
92
+ }
93
+ }
94
+
95
+ const banner = `/**
96
+ * Copyright IBM Corp. 2024
97
+ *
98
+ * This source code is licensed under the Apache-2.0 license found in the
99
+ * LICENSE file in the root directory of this source tree.
100
+ */
101
+ `;
102
+
103
+ function getRollupConfig(input, rootDir, outDir, iconInput) {
104
+ return {
105
+ input,
106
+ // Mark dependencies listed in `package.json` as external so that they are
107
+ // not included in the output bundle.
108
+ external: [
109
+ ...Object.keys(packageJson.default.dependencies),
110
+ ...Object.keys(packageJson.default.devDependencies),
111
+ ].map((name) => {
112
+ // Transform the name of each dependency into a regex so that imports from
113
+ // nested paths are correctly marked as external.
114
+ //
115
+ // Example:
116
+ // import 'module-name';
117
+ // import 'module-name/path/to/nested/module';
118
+ return new RegExp(`^${name}(/.*)?`);
119
+ }),
120
+ plugins: [
121
+ alias({
122
+ entries: [{ find: /^(.*)\.scss\?lit$/, replacement: '$1.scss' }],
123
+ }),
124
+ copy({
125
+ targets: [{ src: 'src/components/**/*.scss', dest: 'scss' }],
126
+ flatten: false,
127
+ }),
128
+ nodeResolve({
129
+ browser: true,
130
+ mainFields: ['jsnext', 'module', 'main'],
131
+ extensions: ['.js', '.ts'],
132
+ }),
133
+ commonjs({
134
+ include: [/node_modules/],
135
+ }),
136
+ litSCSS({
137
+ includePaths: [
138
+ path.resolve(__dirname, '../node_modules'),
139
+ path.resolve(__dirname, '../../../node_modules'),
140
+ ],
141
+ async preprocessor(contents, id) {
142
+ return (
143
+ await postcss([autoprefixer(), cssnano()]).process(contents, {
144
+ from: id,
145
+ })
146
+ ).css;
147
+ },
148
+ }),
149
+ carbonIcons(iconInput, banner),
150
+ typescript({
151
+ noEmitOnError: true,
152
+ compilerOptions: {
153
+ rootDir,
154
+ outDir,
155
+ },
156
+ }),
157
+ carbonIconPaths(),
158
+ ],
159
+ };
160
+ }
161
+
162
+ build().catch((error) => {
163
+ console.log(error);
164
+ process.exit(1);
165
+ });
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2020, 2023
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ import path from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ /**
14
+ * @returns {object} The rollup plugin to transform `@carbon/icons/lib` imports to relative path in build.
15
+ */
16
+ export default function rollupPluginIconPaths() {
17
+ return {
18
+ name: 'transform-icon-paths',
19
+
20
+ generateBundle(options, bundle) {
21
+ function transformIconPaths(filePath, content) {
22
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
23
+ const iconPathRegex = /@carbon\/icons\/lib/g;
24
+ const filenameES = filePath.replace(/[/\\]src[/\\]/, '/es/');
25
+ const iconsDir = path.relative(
26
+ path.dirname(filenameES),
27
+ path.resolve(__dirname, '../icons')
28
+ );
29
+ return content.replace(iconPathRegex, iconsDir);
30
+ }
31
+
32
+ for (const [fileName, fileData] of Object.entries(bundle)) {
33
+ if (fileData.type === 'chunk') {
34
+ fileData.code = transformIconPaths(fileName, fileData.code);
35
+ }
36
+ }
37
+ },
38
+ };
39
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2024
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ import path from 'path';
11
+ import { createRequire } from 'node:module';
12
+ import { fileURLToPath } from 'url';
13
+ import icon from './svg-result-carbon-icon.js';
14
+
15
+ /**
16
+ * @param {Array} [inputs] icon files of the @carbon/icons/lib folder from node_modules
17
+ * @param {String} [banner] license banner to prepend to file
18
+ * @returns {object} The rollup plugin to generate lit svg template icon files.
19
+ */
20
+ export default function rollupPluginIcons(inputs, banner) {
21
+ return {
22
+ name: 'carbon-icons',
23
+
24
+ async buildEnd() {
25
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
26
+ const require = createRequire(import.meta.url);
27
+
28
+ for (const input of inputs) {
29
+ const iconPath = path.resolve(__dirname, `../${input}`);
30
+
31
+ const svg = await import(iconPath);
32
+
33
+ const iconsDir = path.dirname(require.resolve('@carbon/icons/lib'));
34
+ const iconsESPath = path.resolve(
35
+ 'es',
36
+ 'icons',
37
+ path.relative(iconsDir, iconPath)
38
+ );
39
+
40
+ const code = `${banner}
41
+ import { svg } from 'lit';
42
+ import spread from '@carbon/web-components/es/globals/directives/spread.js';
43
+
44
+ const svgResultCarbonIcon = ${icon(svg.default)};
45
+ export default svgResultCarbonIcon;`;
46
+
47
+ this.emitFile({
48
+ type: 'asset',
49
+ fileName: `icons/${path.relative(iconsDir, iconPath)}`,
50
+ source: code,
51
+ });
52
+
53
+ // emit icon type file
54
+ const typeCode = `${banner}
55
+ import { SVGTemplateResult } from 'lit-html';
56
+ declare const svgResultCarbonIcon: ({ children, ...attrs }?: { children?: SVGTemplateResult; [attr: string]: any }) => SVGTemplateResult;
57
+ export default svgResultCarbonIcon;`;
58
+
59
+ const typePath = path.format({
60
+ ...path.parse(iconPath),
61
+ base: '',
62
+ ext: '.d.ts',
63
+ });
64
+
65
+ this.emitFile({
66
+ type: 'asset',
67
+ fileName: `icons/${path.relative(iconsDir, typePath)}`,
68
+ source: typeCode,
69
+ });
70
+ }
71
+ },
72
+ };
73
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2020, 2023
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ import path from 'path';
11
+ import { promisify } from 'util';
12
+ import * as sass from 'sass';
13
+ import { createFilter } from '@rollup/pluginutils';
14
+
15
+ const renderSass = promisify(sass.render);
16
+ const noop = (s) => s;
17
+
18
+ /**
19
+ * @param {string} css A CSS.
20
+ * @returns {string} A `lit-html` template of the given CSS.
21
+ */
22
+ function transformToTemplate(css) {
23
+ return `import { css } from 'lit';export default css([${JSON.stringify(
24
+ css
25
+ )}])`;
26
+ }
27
+
28
+ /**
29
+ * @param {object} [options] The options.
30
+ * @param {RegExp} [options.include=/\.scss/] The files to include.
31
+ * @param {RegExp} [options.exclude] The files to exclude.
32
+ * @param {Function} [options.preprocessor] The CSS preprocessor to use.
33
+ * @returns {object} The rollup plugin to transform an `.scss` file to a `lit-html` template.
34
+ */
35
+ export default function LitSCSS({
36
+ include = /\.scss$/i,
37
+ exclude,
38
+ preprocessor = noop,
39
+ ...options
40
+ } = {}) {
41
+ const filter = createFilter(include, exclude);
42
+ return {
43
+ name: 'lit-scss',
44
+
45
+ /**
46
+ * Enqueues the module contents for loading.
47
+ *
48
+ * @param {string} id The module ID.
49
+ */
50
+ load(id) {
51
+ if (filter(id)) {
52
+ this.addWatchFile(path.resolve(id));
53
+ }
54
+ return null;
55
+ },
56
+
57
+ /**
58
+ * Transforms the module contents.
59
+ *
60
+ * @param {string} contents The module contents.
61
+ * @param {string} id The module ID.
62
+ * @returns {object} The transformed module contents.
63
+ */
64
+ async transform(contents, id) {
65
+ if (!filter(id)) {
66
+ return null;
67
+ }
68
+
69
+ const finalContent = `
70
+ $feature-flags: (
71
+ enable-css-custom-properties: true,
72
+ );
73
+ ${contents}`;
74
+
75
+ const { css } = await renderSass({
76
+ ...options,
77
+ file: id,
78
+ data: finalContent,
79
+ });
80
+
81
+ return {
82
+ code: transformToTemplate(await preprocessor(css.toString(), id)),
83
+ map: {
84
+ mappings: '',
85
+ },
86
+ };
87
+ },
88
+ };
89
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2019, 2023
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ const path = require('path');
11
+ const createSVGResultFromCarbonIcon = require('./svg-result-carbon-icon');
12
+
13
+ /**
14
+ * A Vite loader to generate `lit-html`'s `SVGResult` from an icon descriptor from `@carbon/icons`.
15
+ *
16
+ * @returns {string} The massaged module content.
17
+ */
18
+ function svgResultCarbonIconLoader() {
19
+ const descriptor = require(this.resourcePath); // eslint-disable-line global-require
20
+ return `
21
+ import { svg } from 'lit';
22
+ import spread from '@carbon/web-components/es/globals/directives/spread.js';
23
+ const svgResultCarbonIcon = ${createSVGResultFromCarbonIcon(descriptor)};
24
+ export default svgResultCarbonIcon;
25
+ `;
26
+ }
27
+
28
+ module.exports = svgResultCarbonIconLoader;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2019, 2024
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ import { getAttributes, formatAttributes } from '@carbon/icon-helpers';
11
+
12
+ // TODO: update @carbon/icon-helpers with this version of toString
13
+ const toString = (descriptor) => {
14
+ if (typeof descriptor === 'string') {
15
+ return descriptor;
16
+ }
17
+ const { elem = 'svg', attrs = {}, content = [] } = descriptor;
18
+ const children = content.map(toString).join('');
19
+ if (elem !== 'svg') {
20
+ return `<${elem} ${formatAttributes(attrs)}>${children}</${elem}>`;
21
+ }
22
+ return `<${elem} ${formatAttributes(
23
+ getAttributes(attrs)
24
+ )}>${children}</${elem}>`;
25
+ };
26
+
27
+ /**
28
+ * Function that takes a valid @carbon/icons style icon descriptor and returns a lit-html svg instance
29
+ *
30
+ * @param {object} descriptor Object representation of an SVG icon as generated by @carbon/icons
31
+ */
32
+ const icon = (descriptor) => {
33
+ descriptor.attrs = getAttributes(
34
+ Object.assign(descriptor.attrs, {
35
+ '...': '${spread(attrs)}', // eslint-disable-line no-template-curly-in-string
36
+ })
37
+ );
38
+ descriptor?.content?.unshift('${children}'); // eslint-disable-line no-template-curly-in-string
39
+ return `({ children, ...attrs } = {}) => svg\`${toString(descriptor)}\``;
40
+ };
41
+
42
+ export default icon;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2019, 2023
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ const path = require('path');
11
+ const createSVGResultFromCarbonIcon = require('./svg-result-carbon-icon');
12
+
13
+ /**
14
+ * A Vite plugin to generate `lit-html`'s `SVGResult` from an icon descriptor from `@carbon/icons`.
15
+ *
16
+ * @returns {string} The massaged module content.
17
+ */
18
+ export default function svgResultCarbonIconLoader() {
19
+ const svgRegex = /@carbon[\\/]icons[\\/]/i;
20
+
21
+ const paths = new Map<string, string>();
22
+
23
+ return {
24
+ name: 'svg-result-carbon-icon-loader',
25
+ enforce: 'pre',
26
+
27
+ resolveId(id: string): string | null {
28
+ if (id.match(svgRegex)) {
29
+ paths.set(id, id);
30
+ return id;
31
+ } else {
32
+ return null;
33
+ }
34
+ },
35
+
36
+ async load(id: string): Promise<string | undefined> {
37
+ let outcome: string | undefined;
38
+ if (!id.match(svgRegex)) {
39
+ return outcome;
40
+ }
41
+ return ``;
42
+ },
43
+
44
+ async transform(src: string, id: string) {
45
+ if (!paths.has(id)) {
46
+ return null;
47
+ }
48
+
49
+ const outcome: string | undefined = src;
50
+ if (!id.match(svgRegex)) {
51
+ return outcome;
52
+ }
53
+
54
+ const descriptor = require(id);
55
+ return `
56
+ import { svg } from 'lit';
57
+ import spread from '@carbon/web-components/es/globals/directives/spread.js';
58
+ const svgResultCarbonIcon = ${createSVGResultFromCarbonIcon.default(
59
+ descriptor
60
+ )};
61
+ export default svgResultCarbonIcon;
62
+ `;
63
+ },
64
+ };
65
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2017",
4
+ "module": "es2015",
5
+ "moduleResolution": "node",
6
+ "lib": ["es2017", "esnext.array", "dom", "dom.iterable"],
7
+ "typeRoots": [
8
+ "src/typings",
9
+ "tests/typings",
10
+ "node_modules/@types",
11
+ "../../node_modules/@types"
12
+ ],
13
+ "declaration": true,
14
+ "rootDir": ".",
15
+ "skipLibCheck": true,
16
+ "sourceMap": true,
17
+ "stripInternal": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "noImplicitReturns": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+ "experimentalDecorators": true,
23
+ "strict": true,
24
+ "noImplicitAny": false,
25
+ "allowSyntheticDefaultImports": true,
26
+ "resolveJsonModule": true
27
+ },
28
+ "include": [
29
+ "src/**/*.ts",
30
+ "src/**/*.tsx",
31
+ "tests/**/*.ts",
32
+ ".storybook/**/*.ts",
33
+ ".storybook/**/*.tsx"
34
+ ],
35
+ "exclude": ["src/**/*.stories.ts", "src/globals/internal/storybook-cdn.ts"]
36
+ }