File: svg.d.ts

package info (click to toggle)
jupyterlab 4.0.11%2Bds1%2B~cs11.25.27-7
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 43,496 kB
  • sloc: javascript: 18,395; python: 8,932; sh: 399; makefile: 95; perl: 33; xml: 1
file content (58 lines) | stat: -rw-r--r-- 1,911 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

// including this file in a package allows for the use of import statements
// with svg files. Example: `import xSvg from 'path/xSvg.svg'`

// for use with raw-loader in Webpack.
// The svg will be imported as a raw string

declare module '*.svg' {
  const value: string;
  export default value;
}

// for use with svg-react-loader in Webpack.
// The svg will be imported as a ReactElement

// declare module '*.svg' {
//   import { HTMLAttributes } from 'react';
//   const value: React.ComponentType<HTMLAttributes<SVGElement>>;
//   export default value;
// }

// as an alternative to importing svgs one at a time, you can do a glob import
// using `context.requires`. This is a Webpack only extension. Implementation:

// import { PathExt } from '@jupyterlab/coreutils';
//
// /**
//  * Import all svgs from a directory. The input argument should be
//  * of the form `require.context('raw-loader!<path>', true, /\.svg$/)`.
//  * <path> should be a string literal path, as this is needed by `require`.
//  */
// export function importSvgs(r: any, exclude: string[] = []): IModel[] {
//   const excset = new Set(exclude);
//
//   return r.keys().reduce((svgs: IModel[], item: string, index: number) => {
//     const name = PathExt.stem(item);
//     if (!excset.has(name)) {
//       svgs.push({ name: name, svg: r(item).default });
//     }
//     return svgs;
//   }, []);
// }
//
// // create the array of default icon models
// let icons: IModel[];
// try {
//   // require.context is supplied by Webpack, and doesn't play nice with jest
//   icons = importSvgs(
//     require.context('raw-loader!../../style/icons', true, /\.svg$/),
//     ['bad', 'blank']
//   );
// } catch (e) {
//   // fallback for jest tests
//   icons = [];
// }
// export const defaultIcons: ReadonlyArray<IModel> = icons;