@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.
Files changed (45) hide show
  1. package/lib/components/form.js +1 -1
  2. package/lib/components/form.js.map +1 -1
  3. package/lib/components/vdom.d.ts +1 -1
  4. package/lib/components/windowedlist.js +2 -1
  5. package/lib/components/windowedlist.js.map +1 -1
  6. package/lib/hoverbox.d.ts +1 -1
  7. package/lib/icon/labicon.js +49 -48
  8. package/lib/icon/labicon.js.map +1 -1
  9. package/lib/icon/widgets/tabbarsvg.js +2 -1
  10. package/lib/icon/widgets/tabbarsvg.js.map +1 -1
  11. package/package.json +20 -19
  12. package/src/FormRendererRegistry.tsx +60 -0
  13. package/src/components/accordiontoolbar.ts +252 -0
  14. package/src/components/button.tsx +45 -0
  15. package/src/components/collapser.ts +176 -0
  16. package/src/components/form.tsx +678 -0
  17. package/src/components/htmlselect.tsx +99 -0
  18. package/src/components/iframe.ts +153 -0
  19. package/src/components/index.ts +20 -0
  20. package/src/components/inputgroup.tsx +51 -0
  21. package/src/components/interface.ts +9 -0
  22. package/src/components/menu.ts +442 -0
  23. package/src/components/panelwithtoolbar.ts +41 -0
  24. package/src/components/search.tsx +216 -0
  25. package/src/components/sidepanel.ts +168 -0
  26. package/src/components/spinner.ts +31 -0
  27. package/src/components/styling.ts +114 -0
  28. package/src/components/switch.ts +103 -0
  29. package/src/components/toolbar.tsx +1119 -0
  30. package/src/components/vdom.ts +324 -0
  31. package/src/components/windowedlist.ts +1422 -0
  32. package/src/hoverbox.ts +401 -0
  33. package/src/icon/iconimports.ts +206 -0
  34. package/src/icon/index.ts +6 -0
  35. package/src/icon/labicon.tsx +955 -0
  36. package/src/icon/widgets/commandpalettesvg.ts +78 -0
  37. package/src/icon/widgets/index.ts +6 -0
  38. package/src/icon/widgets/menusvg.ts +218 -0
  39. package/src/icon/widgets/tabbarsvg.ts +122 -0
  40. package/src/index.ts +13 -0
  41. package/src/style/icon.ts +581 -0
  42. package/src/style/index.ts +4 -0
  43. package/src/svg.d.ts +58 -0
  44. package/src/tokens.ts +68 -0
  45. 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
+ }