@jupyterlab/ui-components 4.0.0-alpha.34 → 4.0.0-alpha.35
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.
- package/lib/components/form.js +1 -1
- package/lib/components/form.js.map +1 -1
- package/lib/components/vdom.d.ts +1 -1
- package/lib/components/windowedlist.js +2 -1
- package/lib/components/windowedlist.js.map +1 -1
- package/lib/hoverbox.d.ts +1 -1
- package/lib/icon/labicon.js +49 -48
- package/lib/icon/labicon.js.map +1 -1
- package/lib/icon/widgets/tabbarsvg.js +2 -1
- package/lib/icon/widgets/tabbarsvg.js.map +1 -1
- package/package.json +20 -19
- package/src/FormRendererRegistry.tsx +60 -0
- package/src/components/accordiontoolbar.ts +252 -0
- package/src/components/button.tsx +45 -0
- package/src/components/collapser.ts +176 -0
- package/src/components/form.tsx +678 -0
- package/src/components/htmlselect.tsx +99 -0
- package/src/components/iframe.ts +153 -0
- package/src/components/index.ts +20 -0
- package/src/components/inputgroup.tsx +51 -0
- package/src/components/interface.ts +9 -0
- package/src/components/menu.ts +442 -0
- package/src/components/panelwithtoolbar.ts +41 -0
- package/src/components/search.tsx +216 -0
- package/src/components/sidepanel.ts +168 -0
- package/src/components/spinner.ts +31 -0
- package/src/components/styling.ts +114 -0
- package/src/components/switch.ts +103 -0
- package/src/components/toolbar.tsx +1119 -0
- package/src/components/vdom.ts +324 -0
- package/src/components/windowedlist.ts +1422 -0
- package/src/hoverbox.ts +401 -0
- package/src/icon/iconimports.ts +206 -0
- package/src/icon/index.ts +6 -0
- package/src/icon/labicon.tsx +955 -0
- package/src/icon/widgets/commandpalettesvg.ts +78 -0
- package/src/icon/widgets/index.ts +6 -0
- package/src/icon/widgets/menusvg.ts +218 -0
- package/src/icon/widgets/tabbarsvg.ts +122 -0
- package/src/index.ts +13 -0
- package/src/style/icon.ts +581 -0
- package/src/style/index.ts +4 -0
- package/src/svg.d.ts +58 -0
- package/src/tokens.ts +68 -0
- package/src/utils.ts +90 -0
package/src/utils.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { Text } from '@jupyterlab/coreutils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Inner works of class combining functions
|
|
8
|
+
*/
|
|
9
|
+
function _classes(
|
|
10
|
+
classes: (string | false | undefined | null | { [className: string]: any })[]
|
|
11
|
+
): string[] {
|
|
12
|
+
return classes
|
|
13
|
+
.map(c =>
|
|
14
|
+
c && typeof c === 'object'
|
|
15
|
+
? Object.keys(c).map(key => !!c[key] && key)
|
|
16
|
+
: typeof c === 'string'
|
|
17
|
+
? c.split(/\s+/)
|
|
18
|
+
: []
|
|
19
|
+
)
|
|
20
|
+
.reduce((flattened, c) => flattened.concat(c), [] as string[])
|
|
21
|
+
.filter(c => !!c) as string[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Combines classNames.
|
|
26
|
+
*
|
|
27
|
+
* @param classes - A list of classNames
|
|
28
|
+
*
|
|
29
|
+
* @returns A single string with the combined className
|
|
30
|
+
*/
|
|
31
|
+
export function classes(
|
|
32
|
+
...classes: (
|
|
33
|
+
| string
|
|
34
|
+
| false
|
|
35
|
+
| undefined
|
|
36
|
+
| null
|
|
37
|
+
| { [className: string]: any }
|
|
38
|
+
)[]
|
|
39
|
+
): string {
|
|
40
|
+
return _classes(classes).join(' ');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Combines classNames. Removes all duplicates
|
|
45
|
+
*
|
|
46
|
+
* @param classes - A list of classNames
|
|
47
|
+
*
|
|
48
|
+
* @returns A single string with the combined className
|
|
49
|
+
*/
|
|
50
|
+
export function classesDedupe(
|
|
51
|
+
...classes: (
|
|
52
|
+
| string
|
|
53
|
+
| false
|
|
54
|
+
| undefined
|
|
55
|
+
| null
|
|
56
|
+
| { [className: string]: any }
|
|
57
|
+
)[]
|
|
58
|
+
): string {
|
|
59
|
+
return [...new Set(_classes(classes))].join(' ');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Translates the attributes of a DOM element into attributes that can
|
|
64
|
+
* be understood by React. Currently not comprehensive, we will add special
|
|
65
|
+
* cases as they become relevant.
|
|
66
|
+
*
|
|
67
|
+
* @param elem - A DOM element
|
|
68
|
+
*
|
|
69
|
+
* @param ignore - An optional list of attribute names to ignore
|
|
70
|
+
*
|
|
71
|
+
* @returns An object with key:value pairs that are the React-friendly
|
|
72
|
+
* translation of elem's attributes
|
|
73
|
+
*/
|
|
74
|
+
export function getReactAttrs(
|
|
75
|
+
elem: Element,
|
|
76
|
+
{ ignore = [] }: { ignore?: string[] } = {}
|
|
77
|
+
): { [key: string]: string | null } {
|
|
78
|
+
return elem
|
|
79
|
+
.getAttributeNames()
|
|
80
|
+
.reduce<{ [key: string]: string | null }>((d, name) => {
|
|
81
|
+
if (name === 'style' || ignore.includes(name)) {
|
|
82
|
+
void 0;
|
|
83
|
+
} else if (name.startsWith('data')) {
|
|
84
|
+
d[name] = elem.getAttribute(name);
|
|
85
|
+
} else {
|
|
86
|
+
d[Text.camelCase(name)] = elem.getAttribute(name);
|
|
87
|
+
}
|
|
88
|
+
return d;
|
|
89
|
+
}, {});
|
|
90
|
+
}
|