@jupytergis/base 0.6.0 → 0.6.1
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/shared/components/Badge.d.ts +1 -1
- package/lib/shared/components/Badge.js +3 -2
- package/lib/shared/components/Button.d.ts +1 -1
- package/lib/shared/components/Button.js +2 -1
- package/lib/stacBrowser/components/StacFilterSection.js +12 -2
- package/lib/stacBrowser/components/StacPanelFilters.js +19 -3
- package/lib/toolbar/widget.d.ts +1 -0
- package/lib/toolbar/widget.js +23 -2
- package/package.json +2 -2
- package/style/shared/button.css +5 -0
- package/style/stacBrowser.css +17 -0
|
@@ -3,5 +3,5 @@ interface IBadgeProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
|
3
3
|
variant?: 'destructive' | 'outline' | 'secondary';
|
|
4
4
|
size?: 'sm' | 'lg' | 'icon';
|
|
5
5
|
}
|
|
6
|
-
declare function Badge({ variant, ...props }: IBadgeProps): React.JSX.Element;
|
|
6
|
+
declare function Badge({ variant, className, ...props }: IBadgeProps): React.JSX.Element;
|
|
7
7
|
export default Badge;
|
|
@@ -10,10 +10,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import * as React from 'react';
|
|
13
|
+
import { cn } from './utils';
|
|
13
14
|
function Badge(_a) {
|
|
14
|
-
var { variant } = _a, props = __rest(_a, ["variant"]);
|
|
15
|
+
var { variant, className } = _a, props = __rest(_a, ["variant", "className"]);
|
|
15
16
|
return (
|
|
16
17
|
// @ts-expect-error lol
|
|
17
|
-
React.createElement("div", Object.assign({ "data-variant": variant, className: 'jgis-badge' }, props)));
|
|
18
|
+
React.createElement("div", Object.assign({ "data-variant": variant, className: cn('jgis-badge', className) }, props)));
|
|
18
19
|
}
|
|
19
20
|
export default Badge;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
interface IButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
3
|
asChild?: boolean;
|
|
4
4
|
variant?: 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link' | 'icon';
|
|
5
|
-
size?: 'sm' | 'lg' | 'icon';
|
|
5
|
+
size?: 'sm' | 'lg' | 'icon' | 'icon-sm';
|
|
6
6
|
}
|
|
7
7
|
declare const Button: React.ForwardRefExoticComponent<IButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
8
8
|
export { Button };
|
|
@@ -11,10 +11,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { Slot } from '@radix-ui/react-slot';
|
|
13
13
|
import * as React from 'react';
|
|
14
|
+
import { cn } from './utils';
|
|
14
15
|
const Button = React.forwardRef((_a, ref) => {
|
|
15
16
|
var { variant, className, size, asChild = false } = _a, props = __rest(_a, ["variant", "className", "size", "asChild"]);
|
|
16
17
|
const Comp = asChild ? Slot : 'button';
|
|
17
|
-
return (React.createElement(Comp, Object.assign({ "data-size": size, "data-variant": variant, className:
|
|
18
|
+
return (React.createElement(Comp, Object.assign({ "data-size": size, "data-variant": variant, className: cn('jgis-button', className), ref: ref }, props)));
|
|
18
19
|
});
|
|
19
20
|
Button.displayName = 'Button';
|
|
20
21
|
export { Button };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { faXmark } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
1
3
|
import { ChevronRight } from 'lucide-react';
|
|
2
4
|
import React, { useMemo } from 'react';
|
|
3
5
|
import Badge from "../../shared/components/Badge";
|
|
6
|
+
import { Button } from "../../shared/components/Button";
|
|
4
7
|
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "../../shared/components/DropdownMenu";
|
|
5
8
|
const StacFilterSection = ({ section, data, selectedCollections, selectedData, handleCheckedChange, }) => {
|
|
6
9
|
const items = useMemo(() => {
|
|
@@ -38,12 +41,19 @@ const StacFilterSection = ({ section, data, selectedCollections, selectedData, h
|
|
|
38
41
|
} }, product.productCode))))))));
|
|
39
42
|
}
|
|
40
43
|
}, [section, data, selectedCollections, selectedData, handleCheckedChange]);
|
|
44
|
+
const isTriggerDisabled = (section === 'Platform' || section === 'Data / Product') &&
|
|
45
|
+
selectedCollections.length === 0;
|
|
41
46
|
return (React.createElement("div", { className: "jgis-stac-filter-section-container" },
|
|
42
47
|
React.createElement(DropdownMenu, { modal: false },
|
|
43
|
-
React.createElement(DropdownMenuTrigger, { className: "jgis-stac-filter-trigger" },
|
|
48
|
+
React.createElement(DropdownMenuTrigger, { className: "jgis-stac-filter-trigger", disabled: isTriggerDisabled },
|
|
44
49
|
section,
|
|
45
50
|
React.createElement(ChevronRight, { className: "DropdownMenuIcon" })),
|
|
46
51
|
React.createElement(DropdownMenuContent, { side: "right" }, items)),
|
|
47
|
-
React.createElement("div", { className: "jgis-stac-filter-section-badges" }, selectedData.map(data => (React.createElement(Badge, { key: data },
|
|
52
|
+
React.createElement("div", { className: "jgis-stac-filter-section-badges" }, selectedData.map(data => (React.createElement(Badge, { key: data, className: "jgis-stac-badge" },
|
|
53
|
+
React.createElement("span", null, data),
|
|
54
|
+
React.createElement(Button, { variant: "icon", size: "icon-sm", className: "jgis-stac-badge-icon", onClick: () => {
|
|
55
|
+
handleCheckedChange(data, '');
|
|
56
|
+
} },
|
|
57
|
+
React.createElement(FontAwesomeIcon, { icon: faXmark }))))))));
|
|
48
58
|
};
|
|
49
59
|
export default StacFilterSection;
|
|
@@ -6,7 +6,7 @@ import { Calendar } from "../../shared/components/Calendar";
|
|
|
6
6
|
import Checkbox from "../../shared/components/Checkbox";
|
|
7
7
|
import { Popover, PopoverContent, PopoverTrigger, } from "../../shared/components/Popover";
|
|
8
8
|
import StacFilterSection from "./StacFilterSection";
|
|
9
|
-
import { datasets as datasetsList, platforms, products, } from "../constants";
|
|
9
|
+
import { datasets as datasetsList, platforms as platformsList, products as productsList, } from "../constants";
|
|
10
10
|
const StacPanelFilters = ({ filterState, filterSetters, startTime, setStartTime, endTime, setEndTime, useWorldBBox, setUseWorldBBox, }) => {
|
|
11
11
|
const handleDatasetSelection = (dataset, collection) => {
|
|
12
12
|
const collections = new Set(filterState.collections);
|
|
@@ -19,6 +19,22 @@ const StacPanelFilters = ({ filterState, filterSetters, startTime, setStartTime,
|
|
|
19
19
|
});
|
|
20
20
|
if (datasetsForCollection.length === 0) {
|
|
21
21
|
collections.delete(collection);
|
|
22
|
+
const platforms = new Set(filterState.platforms);
|
|
23
|
+
const products = new Set(filterState.products);
|
|
24
|
+
// Remove platforms belonging to this collection
|
|
25
|
+
if (platformsList[collection]) {
|
|
26
|
+
platformsList[collection].forEach(platform => {
|
|
27
|
+
platforms.delete(platform);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// Remove products belonging to this collection
|
|
31
|
+
productsList
|
|
32
|
+
.filter(product => product.collections.includes(collection))
|
|
33
|
+
.forEach(product => {
|
|
34
|
+
products.delete(product.productCode);
|
|
35
|
+
});
|
|
36
|
+
filterSetters.platforms(platforms);
|
|
37
|
+
filterSetters.products(products);
|
|
22
38
|
}
|
|
23
39
|
}
|
|
24
40
|
else {
|
|
@@ -59,7 +75,7 @@ const StacPanelFilters = ({ filterState, filterSetters, startTime, setStartTime,
|
|
|
59
75
|
React.createElement(PopoverContent, null,
|
|
60
76
|
React.createElement(Calendar, { mode: "single", selected: endTime, onSelect: setEndTime, autoFocus: true })))),
|
|
61
77
|
React.createElement(StacFilterSection, { section: "Collection", data: datasetsList, selectedCollections: Array.from(filterState.collections), selectedData: Array.from(filterState.datasets), handleCheckedChange: handleDatasetSelection }),
|
|
62
|
-
React.createElement(StacFilterSection, { section: "Platform", data:
|
|
63
|
-
React.createElement(StacFilterSection, { section: "Data / Product", data:
|
|
78
|
+
React.createElement(StacFilterSection, { section: "Platform", data: platformsList, selectedCollections: Array.from(filterState.collections), selectedData: Array.from(filterState.platforms), handleCheckedChange: platform => handleToggle('platforms', platform) }),
|
|
79
|
+
React.createElement(StacFilterSection, { section: "Data / Product", data: productsList, selectedCollections: Array.from(filterState.collections), selectedData: Array.from(filterState.products), handleCheckedChange: product => handleToggle('products', product) })));
|
|
64
80
|
};
|
|
65
81
|
export default StacPanelFilters;
|
package/lib/toolbar/widget.d.ts
CHANGED
package/lib/toolbar/widget.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UsersItem } from '@jupyter/collaboration';
|
|
1
|
+
import { UsersItem, DefaultIconRenderer } from '@jupyter/collaboration';
|
|
2
2
|
import { CommandToolbarButton } from '@jupyterlab/apputils';
|
|
3
3
|
import { MenuSvg, ReactWidget, ReactiveToolbar, ToolbarButton, addIcon, redoIcon, undoIcon, } from '@jupyterlab/ui-components';
|
|
4
4
|
import { Widget } from '@lumino/widgets';
|
|
@@ -17,9 +17,29 @@ export class Separator extends Widget {
|
|
|
17
17
|
this.addClass(TOOLBAR_SEPARATOR_CLASS);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
function createUserIconRenderer(model) {
|
|
21
|
+
let selectedUserId;
|
|
22
|
+
return (props) => {
|
|
23
|
+
const { user } = props;
|
|
24
|
+
const isSelected = user.userId === selectedUserId;
|
|
25
|
+
const className = isSelected ? 'selected' : '';
|
|
26
|
+
const onClick = () => {
|
|
27
|
+
if (user.userId === selectedUserId) {
|
|
28
|
+
selectedUserId = undefined;
|
|
29
|
+
model.setUserToFollow(undefined);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
selectedUserId = user.userId;
|
|
33
|
+
model.setUserToFollow(user.userId);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return (React.createElement(DefaultIconRenderer, { user: user, onClick: onClick, className: className }));
|
|
37
|
+
};
|
|
38
|
+
}
|
|
20
39
|
export class ToolbarWidget extends ReactiveToolbar {
|
|
21
40
|
constructor(options) {
|
|
22
41
|
super();
|
|
42
|
+
this._model = options.model;
|
|
23
43
|
this.addClass('jGIS-toolbar-widget');
|
|
24
44
|
if (options.commands) {
|
|
25
45
|
const undoButton = new CommandToolbarButton({
|
|
@@ -102,7 +122,8 @@ export class ToolbarWidget extends ReactiveToolbar {
|
|
|
102
122
|
'temporal-controller-button';
|
|
103
123
|
this.addItem('spacer', ReactiveToolbar.createSpacerItem());
|
|
104
124
|
// Users
|
|
105
|
-
|
|
125
|
+
const iconRenderer = createUserIconRenderer(this._model);
|
|
126
|
+
this.addItem('users', ReactWidget.create(React.createElement(UsersItem, { model: this._model, iconRenderer: iconRenderer })));
|
|
106
127
|
}
|
|
107
128
|
}
|
|
108
129
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupytergis/base",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "A JupyterLab extension for 3D modelling.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@jupyter/collaboration": "^3.1.0",
|
|
45
45
|
"@jupyter/react-components": "^0.16.6",
|
|
46
46
|
"@jupyter/ydoc": "^2.0.0 || ^3.0.0",
|
|
47
|
-
"@jupytergis/schema": "^0.6.
|
|
47
|
+
"@jupytergis/schema": "^0.6.1",
|
|
48
48
|
"@jupyterlab/application": "^4.3.0",
|
|
49
49
|
"@jupyterlab/apputils": "^4.3.0",
|
|
50
50
|
"@jupyterlab/completer": "^4.3.0",
|
package/style/shared/button.css
CHANGED
package/style/stacBrowser.css
CHANGED
|
@@ -56,6 +56,10 @@
|
|
|
56
56
|
gap: 0.15rem;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
.jgis-stac-filter-trigger:disabled {
|
|
60
|
+
cursor: not-allowed;
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
.jgis-stac-filter-section-container {
|
|
60
64
|
display: flex;
|
|
61
65
|
flex-direction: column;
|
|
@@ -72,3 +76,16 @@
|
|
|
72
76
|
width: 1rem;
|
|
73
77
|
height: 1rem;
|
|
74
78
|
}
|
|
79
|
+
|
|
80
|
+
.jgis-stac-badge {
|
|
81
|
+
gap: 0.25rem;
|
|
82
|
+
padding-right: 0.3rem !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.jgis-stac-badge-icon:hover {
|
|
86
|
+
background-color: color-mix(
|
|
87
|
+
in srgb,
|
|
88
|
+
var(--jp-error-color0),
|
|
89
|
+
transparent 20%
|
|
90
|
+
) !important;
|
|
91
|
+
}
|