graphwise-reactodia 0.0.1-TR12 → 0.0.1-TR14
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/dist/cjs/graphwise-reactodia.cjs.entry.js +77 -51
- package/dist/cjs/graphwise-reactodia.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.css +47 -1
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.js +17 -12
- package/dist/collection/components/graphwise-reactodia/reactodia-app.js +36 -17
- package/dist/collection/components/graphwise-reactodia/services/diagram/diagram.service.js +4 -1
- package/dist/collection/components/graphwise-reactodia/styles/type-style.resolver.js +25 -26
- package/dist/collection/pages/graphwise-reactodia/main.js +10 -0
- package/dist/collection/pages/graphwise-reactodia/owl-rdfs-settings.js +195 -0
- package/dist/esm/graphwise-reactodia.entry.js +77 -51
- package/dist/esm/graphwise-reactodia.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/graphwise-reactodia/graphwise-reactodia.esm.js +1 -1
- package/dist/graphwise-reactodia/p-0cb06f14.entry.js +1 -0
- package/dist/types/components/graphwise-reactodia/graphwise-reactodia.d.ts +7 -10
- package/dist/types/components/graphwise-reactodia/models/reactodia-app-props.d.ts +8 -4
- package/dist/types/components/graphwise-reactodia/reactodia-app.d.ts +3 -2
- package/dist/types/components.d.ts +6 -6
- package/package.json +2 -2
- package/dist/graphwise-reactodia/p-52bd1b0e.entry.js +0 -1
|
@@ -31376,8 +31376,10 @@ let DiagramService = DiagramService_1 = class DiagramService {
|
|
|
31376
31376
|
clearTimeout(notifyTimer);
|
|
31377
31377
|
}
|
|
31378
31378
|
notifyTimer = setTimeout(() => {
|
|
31379
|
+
if (notifyTimer) {
|
|
31380
|
+
onChangeCallback(model.exportLayout());
|
|
31381
|
+
}
|
|
31379
31382
|
notifyTimer = undefined;
|
|
31380
|
-
onChangeCallback(model.exportLayout());
|
|
31381
31383
|
}, DiagramService_1.NOTIFY_DEBOUNCE_MS);
|
|
31382
31384
|
};
|
|
31383
31385
|
model.history.events.on(DiagramService_1.HISTORY_CHANGED_EVENT, onHistoryChange);
|
|
@@ -31385,6 +31387,7 @@ let DiagramService = DiagramService_1 = class DiagramService {
|
|
|
31385
31387
|
model.history.events.off(DiagramService_1.HISTORY_CHANGED_EVENT, onHistoryChange);
|
|
31386
31388
|
if (notifyTimer) {
|
|
31387
31389
|
clearTimeout(notifyTimer);
|
|
31390
|
+
notifyTimer = undefined;
|
|
31388
31391
|
}
|
|
31389
31392
|
};
|
|
31390
31393
|
}
|
|
@@ -31526,34 +31529,33 @@ class SubscriptionList {
|
|
|
31526
31529
|
}
|
|
31527
31530
|
}
|
|
31528
31531
|
|
|
31529
|
-
const NODE_COLOR_VARIABLES = [
|
|
31530
|
-
'--gw-foreground-visual-diagram-categorical-01',
|
|
31531
|
-
'--gw-foreground-visual-diagram-categorical-02',
|
|
31532
|
-
'--gw-foreground-visual-diagram-categorical-03',
|
|
31533
|
-
'--gw-foreground-visual-diagram-categorical-04',
|
|
31534
|
-
'--gw-foreground-visual-diagram-categorical-05',
|
|
31535
|
-
'--gw-foreground-visual-diagram-categorical-06',
|
|
31536
|
-
'--gw-foreground-visual-diagram-categorical-07',
|
|
31537
|
-
'--gw-foreground-visual-diagram-categorical-08',
|
|
31538
|
-
'--gw-foreground-visual-diagram-categorical-09',
|
|
31539
|
-
'--gw-foreground-visual-diagram-categorical-10',
|
|
31540
|
-
'--gw-foreground-visual-diagram-categorical-11',
|
|
31541
|
-
'--gw-foreground-visual-diagram-categorical-12',
|
|
31542
|
-
'--gw-foreground-visual-diagram-categorical-13',
|
|
31543
|
-
'--gw-foreground-visual-diagram-categorical-14',
|
|
31544
|
-
'--gw-foreground-visual-diagram-categorical-15',
|
|
31545
|
-
'--gw-foreground-visual-diagram-categorical-16',
|
|
31546
|
-
'--gw-foreground-visual-diagram-categorical-17',
|
|
31547
|
-
'--gw-foreground-visual-diagram-categorical-18',
|
|
31548
|
-
'--gw-foreground-visual-diagram-categorical-19',
|
|
31549
|
-
'--gw-foreground-visual-diagram-categorical-20'
|
|
31550
|
-
];
|
|
31551
31532
|
/**
|
|
31552
31533
|
* Color slot assigned to each type, in the order the types are first seen.
|
|
31553
31534
|
*/
|
|
31554
31535
|
const typeToIndex = new Map();
|
|
31555
|
-
|
|
31556
|
-
|
|
31536
|
+
/**
|
|
31537
|
+
* Returns the internal property of the given palette slot, numbered from 1 and padded to two digits as in `_theme.scss`.
|
|
31538
|
+
*/
|
|
31539
|
+
function getTypeColorProperty(slot) {
|
|
31540
|
+
return `--_graphwise-reactodia-type-color-${String(slot).padStart(2, '0')}`;
|
|
31541
|
+
}
|
|
31542
|
+
/**
|
|
31543
|
+
* Reads the type palette of the Theme API: the internal properties `_theme.scss` resolves from the ones
|
|
31544
|
+
* the host declares, in slot order up to the first empty one.
|
|
31545
|
+
*/
|
|
31546
|
+
function getPalette() {
|
|
31547
|
+
const host = document.querySelector('graphwise-reactodia');
|
|
31548
|
+
if (!host) {
|
|
31549
|
+
return [];
|
|
31550
|
+
}
|
|
31551
|
+
const style = getComputedStyle(host);
|
|
31552
|
+
const palette = [];
|
|
31553
|
+
let color = style.getPropertyValue(getTypeColorProperty(1)).trim();
|
|
31554
|
+
while (color) {
|
|
31555
|
+
palette.push(color);
|
|
31556
|
+
color = style.getPropertyValue(getTypeColorProperty(palette.length + 1)).trim();
|
|
31557
|
+
}
|
|
31558
|
+
return palette;
|
|
31557
31559
|
}
|
|
31558
31560
|
/**
|
|
31559
31561
|
* Colors an element by its type: each type takes the next color from the palette, which wraps
|
|
@@ -31573,8 +31575,8 @@ const resolveTypeStyle = (types) => {
|
|
|
31573
31575
|
index = typeToIndex.size;
|
|
31574
31576
|
typeToIndex.set(type, index);
|
|
31575
31577
|
}
|
|
31576
|
-
const
|
|
31577
|
-
return
|
|
31578
|
+
const colors = getPalette();
|
|
31579
|
+
return colors.length ? { color: colors[index % colors.length] } : undefined;
|
|
31578
31580
|
};
|
|
31579
31581
|
const resetColors = () => {
|
|
31580
31582
|
typeToIndex.clear();
|
|
@@ -31697,10 +31699,13 @@ let workspaceContext = null;
|
|
|
31697
31699
|
* the React root.
|
|
31698
31700
|
*/
|
|
31699
31701
|
const subscriptions = new SubscriptionList();
|
|
31702
|
+
let diagramStorageSubscription;
|
|
31703
|
+
const diagramService = service(DiagramService);
|
|
31704
|
+
const diagramStorageService = service(DiagramStorageService);
|
|
31705
|
+
const eventService = service(EventService);
|
|
31700
31706
|
/**
|
|
31701
31707
|
* Builds a Reactodia {@link SparqlDataProvider} for the given endpoint using the supplied
|
|
31702
|
-
* query preset. The host owns the query configuration and passes it in via props
|
|
31703
|
-
* is provided we fall back to Reactodia's generic {@link OwlRdfsSettings} OWL/RDFS preset.
|
|
31708
|
+
* query preset. The host owns the query configuration and always passes it in via props.
|
|
31704
31709
|
*/
|
|
31705
31710
|
function createDataProvider(props) {
|
|
31706
31711
|
const { currentRepository, config, providerSettings } = props;
|
|
@@ -31757,20 +31762,30 @@ async function seedGraphToCanvas(context, dataProvider, links, signal) {
|
|
|
31757
31762
|
* root in {@link unmountReactodia}.
|
|
31758
31763
|
*/
|
|
31759
31764
|
function onDiagramChange(model) {
|
|
31760
|
-
|
|
31761
|
-
|
|
31762
|
-
|
|
31765
|
+
subscribeToDiagramChange(model);
|
|
31766
|
+
}
|
|
31767
|
+
/**
|
|
31768
|
+
* Starts persisting the model's edits to local storage, keeping the subscription in {@link diagramStorageSubscription}.
|
|
31769
|
+
*/
|
|
31770
|
+
function subscribeToDiagramChange(model) {
|
|
31771
|
+
diagramStorageSubscription === null || diagramStorageSubscription === void 0 ? void 0 : diagramStorageSubscription();
|
|
31772
|
+
diagramStorageSubscription = diagramService.subscribeToDiagramChange(model, (diagram) => diagramStorageService.save(diagram));
|
|
31773
|
+
subscriptions.add(diagramStorageSubscription);
|
|
31763
31774
|
}
|
|
31764
31775
|
/**
|
|
31765
31776
|
* Subscribes to the host's "clear persisted diagram" command so the saved layout is dropped on
|
|
31766
31777
|
* request (e.g. before a fresh seed should take precedence over previously saved edits). The
|
|
31767
31778
|
* subscription is tracked in {@link subscriptions} so it is released together with the React
|
|
31768
31779
|
* root in {@link unmountReactodia}.
|
|
31780
|
+
*
|
|
31781
|
+
* @param model The diagram model whose edits are persisted
|
|
31769
31782
|
*/
|
|
31770
|
-
function onClearDiagramStorage() {
|
|
31771
|
-
|
|
31772
|
-
|
|
31773
|
-
|
|
31783
|
+
function onClearDiagramStorage(model) {
|
|
31784
|
+
subscriptions.add(eventService.subscribeToClearDiagramStorage(() => {
|
|
31785
|
+
// re-subscribe, to avoid any pending debounced saves, which may write over the cleared diagram
|
|
31786
|
+
subscribeToDiagramChange(model);
|
|
31787
|
+
diagramStorageService.clear();
|
|
31788
|
+
}));
|
|
31774
31789
|
}
|
|
31775
31790
|
/**
|
|
31776
31791
|
* The Reactodia workspace React component.
|
|
@@ -31789,14 +31804,14 @@ function ReactodiaApp(props) {
|
|
|
31789
31804
|
workspaceContext = context;
|
|
31790
31805
|
const { model } = context;
|
|
31791
31806
|
onDiagramChange(model);
|
|
31792
|
-
onClearDiagramStorage();
|
|
31807
|
+
onClearDiagramStorage(model);
|
|
31793
31808
|
const dataProvider = createDataProvider(props);
|
|
31794
31809
|
const isReload = props.isReload;
|
|
31795
|
-
const savedDiagram =
|
|
31796
|
-
const diagramService = service(DiagramService);
|
|
31810
|
+
const savedDiagram = diagramStorageService.load();
|
|
31797
31811
|
if (isReload) {
|
|
31798
|
-
//
|
|
31799
|
-
//
|
|
31812
|
+
// Reload the diagram that is currently on the canvas. This may happen when the host changes the provider
|
|
31813
|
+
// settings, or when the user switches the language at runtime, since there is no existing mechanism to
|
|
31814
|
+
// re-translate the UI at runtime (not for the UI labels at least)
|
|
31800
31815
|
await diagramService.importDiagram(model, dataProvider, currentDiagram, signal);
|
|
31801
31816
|
}
|
|
31802
31817
|
else if ((_a = config.seedIris) === null || _a === void 0 ? void 0 : _a.length) {
|
|
@@ -31827,7 +31842,12 @@ function ReactodiaApp(props) {
|
|
|
31827
31842
|
defaultLanguage: language,
|
|
31828
31843
|
translations: translationsForLanguage(language),
|
|
31829
31844
|
typeStyleResolver: resolveTypeStyle
|
|
31830
|
-
}, reactExports.createElement(DefaultWorkspace, {
|
|
31845
|
+
}, reactExports.createElement(DefaultWorkspace, {
|
|
31846
|
+
colorScheme: props.theme,
|
|
31847
|
+
menu: reactExports.createElement(GraphwiseMenu),
|
|
31848
|
+
// place Undo/redo/layout actions in top right corner.
|
|
31849
|
+
actionsToolbar: { dock: 'ne' }
|
|
31850
|
+
}));
|
|
31831
31851
|
}
|
|
31832
31852
|
/**
|
|
31833
31853
|
* Mounts the Reactodia application into the given container and returns the React root.
|
|
@@ -31838,8 +31858,9 @@ function mountReactodia(container, props) {
|
|
|
31838
31858
|
return root;
|
|
31839
31859
|
}
|
|
31840
31860
|
/**
|
|
31841
|
-
* Re-points the diagram at a new SPARQL endpoint
|
|
31842
|
-
*
|
|
31861
|
+
* Re-points the diagram at a new SPARQL endpoint by recreating it with a fresh data provider.
|
|
31862
|
+
* The canvas is reset to empty, matching the initial mount, since the data of another repository
|
|
31863
|
+
* has nothing to do with the current graph.
|
|
31843
31864
|
*/
|
|
31844
31865
|
async function updateReactodia(props) {
|
|
31845
31866
|
if (!workspaceContext) {
|
|
@@ -31864,7 +31885,7 @@ function unmountReactodia(root) {
|
|
|
31864
31885
|
root.unmount();
|
|
31865
31886
|
}
|
|
31866
31887
|
|
|
31867
|
-
const graphwiseReactodiaCss = "graphwise-reactodia{display:block;width:100%;height:
|
|
31888
|
+
const graphwiseReactodiaCss = "graphwise-reactodia{--_graphwise-reactodia-type-color-01:var(--graphwise-reactodia-type-color-01);--_graphwise-reactodia-type-color-02:var(--graphwise-reactodia-type-color-02);--_graphwise-reactodia-type-color-03:var(--graphwise-reactodia-type-color-03);--_graphwise-reactodia-type-color-04:var(--graphwise-reactodia-type-color-04);--_graphwise-reactodia-type-color-05:var(--graphwise-reactodia-type-color-05);--_graphwise-reactodia-type-color-06:var(--graphwise-reactodia-type-color-06);--_graphwise-reactodia-type-color-07:var(--graphwise-reactodia-type-color-07);--_graphwise-reactodia-type-color-08:var(--graphwise-reactodia-type-color-08);--_graphwise-reactodia-type-color-09:var(--graphwise-reactodia-type-color-09);--_graphwise-reactodia-type-color-10:var(--graphwise-reactodia-type-color-10);--_graphwise-reactodia-type-color-11:var(--graphwise-reactodia-type-color-11);--_graphwise-reactodia-type-color-12:var(--graphwise-reactodia-type-color-12);--_graphwise-reactodia-type-color-13:var(--graphwise-reactodia-type-color-13);--_graphwise-reactodia-type-color-14:var(--graphwise-reactodia-type-color-14);--_graphwise-reactodia-type-color-15:var(--graphwise-reactodia-type-color-15);--_graphwise-reactodia-type-color-16:var(--graphwise-reactodia-type-color-16);--_graphwise-reactodia-type-color-17:var(--graphwise-reactodia-type-color-17);--_graphwise-reactodia-type-color-18:var(--graphwise-reactodia-type-color-18);--_graphwise-reactodia-type-color-19:var(--graphwise-reactodia-type-color-19);--_graphwise-reactodia-type-color-20:var(--graphwise-reactodia-type-color-20)}graphwise-reactodia{display:block;width:100%;height:100%}graphwise-reactodia .reactodia-container{position:relative;width:100%;height:100%}graphwise-reactodia .reactodia-selection-action__link{display:none}";
|
|
31868
31889
|
|
|
31869
31890
|
const GraphwiseReactodia = class {
|
|
31870
31891
|
constructor(hostRef) {
|
|
@@ -31874,12 +31895,13 @@ const GraphwiseReactodia = class {
|
|
|
31874
31895
|
*/
|
|
31875
31896
|
this.language = LanguageKey.EN;
|
|
31876
31897
|
}
|
|
31877
|
-
|
|
31898
|
+
onCurrentRepositoryChange() {
|
|
31878
31899
|
this.renderGraph();
|
|
31879
31900
|
}
|
|
31880
|
-
|
|
31901
|
+
onLanguageOrSettingsChange() {
|
|
31881
31902
|
// The translations are evaluated by the workspace at construction, so the only way
|
|
31882
31903
|
// to re-translate the UI is to re-create the graph.
|
|
31904
|
+
// Setting changes should keep the current diagram despite possible
|
|
31883
31905
|
this.renderGraph(true);
|
|
31884
31906
|
}
|
|
31885
31907
|
onThemeChange() {
|
|
@@ -31898,7 +31920,7 @@ const GraphwiseReactodia = class {
|
|
|
31898
31920
|
}
|
|
31899
31921
|
}
|
|
31900
31922
|
render() {
|
|
31901
|
-
return (index$1.h(index$1.Host, { key: '
|
|
31923
|
+
return (index$1.h(index$1.Host, { key: 'b2e584a0f1de975692197473d516219a7aa0f42f' }));
|
|
31902
31924
|
}
|
|
31903
31925
|
renderGraph(isReloading) {
|
|
31904
31926
|
var _a;
|
|
@@ -31908,6 +31930,9 @@ const GraphwiseReactodia = class {
|
|
|
31908
31930
|
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.queryFunction)) {
|
|
31909
31931
|
throw new Error('config.queryFunction is required');
|
|
31910
31932
|
}
|
|
31933
|
+
if (!this.providerSettings) {
|
|
31934
|
+
throw new Error('providerSettings is required');
|
|
31935
|
+
}
|
|
31911
31936
|
if (!this.hostElement) {
|
|
31912
31937
|
return;
|
|
31913
31938
|
}
|
|
@@ -31917,6 +31942,7 @@ const GraphwiseReactodia = class {
|
|
|
31917
31942
|
config: this.config,
|
|
31918
31943
|
language: this.language,
|
|
31919
31944
|
providerSettings: this.providerSettings,
|
|
31945
|
+
theme: this.theme,
|
|
31920
31946
|
};
|
|
31921
31947
|
if (this.reactRoot && !isReloading) {
|
|
31922
31948
|
void updateReactodia(props);
|
|
@@ -31927,9 +31953,9 @@ const GraphwiseReactodia = class {
|
|
|
31927
31953
|
}
|
|
31928
31954
|
get hostElement() { return index$1.getElement(this); }
|
|
31929
31955
|
static get watchers() { return {
|
|
31930
|
-
"currentRepository": ["
|
|
31931
|
-
"
|
|
31932
|
-
"
|
|
31956
|
+
"currentRepository": ["onCurrentRepositoryChange"],
|
|
31957
|
+
"language": ["onLanguageOrSettingsChange"],
|
|
31958
|
+
"providerSettings": ["onLanguageOrSettingsChange"],
|
|
31933
31959
|
"theme": ["onThemeChange"]
|
|
31934
31960
|
}; }
|
|
31935
31961
|
};
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"],"theme":[1]},null,{"currentRepository":["
|
|
22
|
+
return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"],"theme":[1]},null,{"currentRepository":["onCurrentRepositoryChange"],"language":["onLanguageOrSettingsChange"],"providerSettings":["onLanguageOrSettingsChange"],"theme":["onThemeChange"]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-CcJr5lkF.js');
|
|
|
6
6
|
const defineCustomElements = async (win, options) => {
|
|
7
7
|
if (typeof window === 'undefined') return undefined;
|
|
8
8
|
await appGlobals.globalScripts();
|
|
9
|
-
return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"],"theme":[1]},null,{"currentRepository":["
|
|
9
|
+
return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"],"theme":[1]},null,{"currentRepository":["onCurrentRepositoryChange"],"language":["onLanguageOrSettingsChange"],"providerSettings":["onLanguageOrSettingsChange"],"theme":["onThemeChange"]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -1,10 +1,56 @@
|
|
|
1
|
+
graphwise-reactodia {
|
|
2
|
+
/** @prop --graphwise-reactodia-type-color-01: Color slot 1 of 20 for node types */
|
|
3
|
+
--_graphwise-reactodia-type-color-01: var(--graphwise-reactodia-type-color-01);
|
|
4
|
+
/** @prop --graphwise-reactodia-type-color-02: Color slot 2 of 20 for node types */
|
|
5
|
+
--_graphwise-reactodia-type-color-02: var(--graphwise-reactodia-type-color-02);
|
|
6
|
+
/** @prop --graphwise-reactodia-type-color-03: Color slot 3 of 20 for node types */
|
|
7
|
+
--_graphwise-reactodia-type-color-03: var(--graphwise-reactodia-type-color-03);
|
|
8
|
+
/** @prop --graphwise-reactodia-type-color-04: Color slot 4 of 20 for node types */
|
|
9
|
+
--_graphwise-reactodia-type-color-04: var(--graphwise-reactodia-type-color-04);
|
|
10
|
+
/** @prop --graphwise-reactodia-type-color-05: Color slot 5 of 20 for node types */
|
|
11
|
+
--_graphwise-reactodia-type-color-05: var(--graphwise-reactodia-type-color-05);
|
|
12
|
+
/** @prop --graphwise-reactodia-type-color-06: Color slot 6 of 20 for node types */
|
|
13
|
+
--_graphwise-reactodia-type-color-06: var(--graphwise-reactodia-type-color-06);
|
|
14
|
+
/** @prop --graphwise-reactodia-type-color-07: Color slot 7 of 20 for node types */
|
|
15
|
+
--_graphwise-reactodia-type-color-07: var(--graphwise-reactodia-type-color-07);
|
|
16
|
+
/** @prop --graphwise-reactodia-type-color-08: Color slot 8 of 20 for node types */
|
|
17
|
+
--_graphwise-reactodia-type-color-08: var(--graphwise-reactodia-type-color-08);
|
|
18
|
+
/** @prop --graphwise-reactodia-type-color-09: Color slot 9 of 20 for node types */
|
|
19
|
+
--_graphwise-reactodia-type-color-09: var(--graphwise-reactodia-type-color-09);
|
|
20
|
+
/** @prop --graphwise-reactodia-type-color-10: Color slot 10 of 20 for node types */
|
|
21
|
+
--_graphwise-reactodia-type-color-10: var(--graphwise-reactodia-type-color-10);
|
|
22
|
+
/** @prop --graphwise-reactodia-type-color-11: Color slot 11 of 20 for node types */
|
|
23
|
+
--_graphwise-reactodia-type-color-11: var(--graphwise-reactodia-type-color-11);
|
|
24
|
+
/** @prop --graphwise-reactodia-type-color-12: Color slot 12 of 20 for node types */
|
|
25
|
+
--_graphwise-reactodia-type-color-12: var(--graphwise-reactodia-type-color-12);
|
|
26
|
+
/** @prop --graphwise-reactodia-type-color-13: Color slot 13 of 20 for node types */
|
|
27
|
+
--_graphwise-reactodia-type-color-13: var(--graphwise-reactodia-type-color-13);
|
|
28
|
+
/** @prop --graphwise-reactodia-type-color-14: Color slot 14 of 20 for node types */
|
|
29
|
+
--_graphwise-reactodia-type-color-14: var(--graphwise-reactodia-type-color-14);
|
|
30
|
+
/** @prop --graphwise-reactodia-type-color-15: Color slot 15 of 20 for node types */
|
|
31
|
+
--_graphwise-reactodia-type-color-15: var(--graphwise-reactodia-type-color-15);
|
|
32
|
+
/** @prop --graphwise-reactodia-type-color-16: Color slot 16 of 20 for node types */
|
|
33
|
+
--_graphwise-reactodia-type-color-16: var(--graphwise-reactodia-type-color-16);
|
|
34
|
+
/** @prop --graphwise-reactodia-type-color-17: Color slot 17 of 20 for node types */
|
|
35
|
+
--_graphwise-reactodia-type-color-17: var(--graphwise-reactodia-type-color-17);
|
|
36
|
+
/** @prop --graphwise-reactodia-type-color-18: Color slot 18 of 20 for node types */
|
|
37
|
+
--_graphwise-reactodia-type-color-18: var(--graphwise-reactodia-type-color-18);
|
|
38
|
+
/** @prop --graphwise-reactodia-type-color-19: Color slot 19 of 20 for node types */
|
|
39
|
+
--_graphwise-reactodia-type-color-19: var(--graphwise-reactodia-type-color-19);
|
|
40
|
+
/** @prop --graphwise-reactodia-type-color-20: Color slot 20 of 20 for node types */
|
|
41
|
+
--_graphwise-reactodia-type-color-20: var(--graphwise-reactodia-type-color-20);
|
|
42
|
+
}
|
|
43
|
+
|
|
1
44
|
graphwise-reactodia {
|
|
2
45
|
display: block;
|
|
3
46
|
width: 100%;
|
|
4
|
-
height:
|
|
47
|
+
height: 100%;
|
|
5
48
|
}
|
|
6
49
|
graphwise-reactodia .reactodia-container {
|
|
7
50
|
position: relative;
|
|
8
51
|
width: 100%;
|
|
9
52
|
height: 100%;
|
|
53
|
+
}
|
|
54
|
+
graphwise-reactodia .reactodia-selection-action__link {
|
|
55
|
+
display: none;
|
|
10
56
|
}
|
|
@@ -20,12 +20,13 @@ export class GraphwiseReactodia {
|
|
|
20
20
|
*/
|
|
21
21
|
this.language = LanguageKey.EN;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
onCurrentRepositoryChange() {
|
|
24
24
|
this.renderGraph();
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
onLanguageOrSettingsChange() {
|
|
27
27
|
// The translations are evaluated by the workspace at construction, so the only way
|
|
28
28
|
// to re-translate the UI is to re-create the graph.
|
|
29
|
+
// Setting changes should keep the current diagram despite possible
|
|
29
30
|
this.renderGraph(true);
|
|
30
31
|
}
|
|
31
32
|
onThemeChange() {
|
|
@@ -44,7 +45,7 @@ export class GraphwiseReactodia {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
render() {
|
|
47
|
-
return (h(Host, { key: '
|
|
48
|
+
return (h(Host, { key: 'b2e584a0f1de975692197473d516219a7aa0f42f' }));
|
|
48
49
|
}
|
|
49
50
|
renderGraph(isReloading) {
|
|
50
51
|
var _a;
|
|
@@ -54,6 +55,9 @@ export class GraphwiseReactodia {
|
|
|
54
55
|
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.queryFunction)) {
|
|
55
56
|
throw new Error('config.queryFunction is required');
|
|
56
57
|
}
|
|
58
|
+
if (!this.providerSettings) {
|
|
59
|
+
throw new Error('providerSettings is required');
|
|
60
|
+
}
|
|
57
61
|
if (!this.hostElement) {
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
@@ -63,6 +67,7 @@ export class GraphwiseReactodia {
|
|
|
63
67
|
config: this.config,
|
|
64
68
|
language: this.language,
|
|
65
69
|
providerSettings: this.providerSettings,
|
|
70
|
+
theme: this.theme,
|
|
66
71
|
};
|
|
67
72
|
if (this.reactRoot && !isReloading) {
|
|
68
73
|
void updateReactodia(props);
|
|
@@ -172,7 +177,7 @@ export class GraphwiseReactodia {
|
|
|
172
177
|
"optional": true,
|
|
173
178
|
"docs": {
|
|
174
179
|
"tags": [],
|
|
175
|
-
"text": "Query preset for the SPARQL data provider, owned and configured by the host. A DOM\nproperty (an object, not an attribute) passed in from outside the wrapper.
|
|
180
|
+
"text": "Query preset for the SPARQL data provider, owned and configured by the host. A DOM\nproperty (an object, not an attribute) passed in from outside the wrapper. Required: the\nwrapper has no default preset and throws when it is missing. Changing it rebuilds the data\nprovider and reloads the graph with it, keeping the current diagram."
|
|
176
181
|
},
|
|
177
182
|
"getter": false,
|
|
178
183
|
"setter": false
|
|
@@ -182,15 +187,15 @@ export class GraphwiseReactodia {
|
|
|
182
187
|
"attribute": "theme",
|
|
183
188
|
"mutable": false,
|
|
184
189
|
"complexType": {
|
|
185
|
-
"original": "
|
|
186
|
-
"resolved": "
|
|
190
|
+
"original": "'light' | 'dark'",
|
|
191
|
+
"resolved": "\"dark\" | \"light\"",
|
|
187
192
|
"references": {}
|
|
188
193
|
},
|
|
189
194
|
"required": false,
|
|
190
195
|
"optional": true,
|
|
191
196
|
"docs": {
|
|
192
197
|
"tags": [],
|
|
193
|
-
"text": "The
|
|
198
|
+
"text": "The reactodia theme to use"
|
|
194
199
|
},
|
|
195
200
|
"getter": false,
|
|
196
201
|
"setter": false,
|
|
@@ -202,13 +207,13 @@ export class GraphwiseReactodia {
|
|
|
202
207
|
static get watchers() {
|
|
203
208
|
return [{
|
|
204
209
|
"propName": "currentRepository",
|
|
205
|
-
"methodName": "
|
|
206
|
-
}, {
|
|
207
|
-
"propName": "providerSettings",
|
|
208
|
-
"methodName": "onProviderSettingsChange"
|
|
210
|
+
"methodName": "onCurrentRepositoryChange"
|
|
209
211
|
}, {
|
|
210
212
|
"propName": "language",
|
|
211
|
-
"methodName": "
|
|
213
|
+
"methodName": "onLanguageOrSettingsChange"
|
|
214
|
+
}, {
|
|
215
|
+
"propName": "providerSettings",
|
|
216
|
+
"methodName": "onLanguageOrSettingsChange"
|
|
212
217
|
}, {
|
|
213
218
|
"propName": "theme",
|
|
214
219
|
"methodName": "onThemeChange"
|
|
@@ -33,10 +33,13 @@ let workspaceContext = null;
|
|
|
33
33
|
* the React root.
|
|
34
34
|
*/
|
|
35
35
|
const subscriptions = new SubscriptionList();
|
|
36
|
+
let diagramStorageSubscription;
|
|
37
|
+
const diagramService = service(DiagramService);
|
|
38
|
+
const diagramStorageService = service(DiagramStorageService);
|
|
39
|
+
const eventService = service(EventService);
|
|
36
40
|
/**
|
|
37
41
|
* Builds a Reactodia {@link SparqlDataProvider} for the given endpoint using the supplied
|
|
38
|
-
* query preset. The host owns the query configuration and passes it in via props
|
|
39
|
-
* is provided we fall back to Reactodia's generic {@link OwlRdfsSettings} OWL/RDFS preset.
|
|
42
|
+
* query preset. The host owns the query configuration and always passes it in via props.
|
|
40
43
|
*/
|
|
41
44
|
function createDataProvider(props) {
|
|
42
45
|
const { currentRepository, config, providerSettings } = props;
|
|
@@ -93,20 +96,30 @@ async function seedGraphToCanvas(context, dataProvider, links, signal) {
|
|
|
93
96
|
* root in {@link unmountReactodia}.
|
|
94
97
|
*/
|
|
95
98
|
function onDiagramChange(model) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
subscribeToDiagramChange(model);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Starts persisting the model's edits to local storage, keeping the subscription in {@link diagramStorageSubscription}.
|
|
103
|
+
*/
|
|
104
|
+
function subscribeToDiagramChange(model) {
|
|
105
|
+
diagramStorageSubscription === null || diagramStorageSubscription === void 0 ? void 0 : diagramStorageSubscription();
|
|
106
|
+
diagramStorageSubscription = diagramService.subscribeToDiagramChange(model, (diagram) => diagramStorageService.save(diagram));
|
|
107
|
+
subscriptions.add(diagramStorageSubscription);
|
|
99
108
|
}
|
|
100
109
|
/**
|
|
101
110
|
* Subscribes to the host's "clear persisted diagram" command so the saved layout is dropped on
|
|
102
111
|
* request (e.g. before a fresh seed should take precedence over previously saved edits). The
|
|
103
112
|
* subscription is tracked in {@link subscriptions} so it is released together with the React
|
|
104
113
|
* root in {@link unmountReactodia}.
|
|
114
|
+
*
|
|
115
|
+
* @param model The diagram model whose edits are persisted
|
|
105
116
|
*/
|
|
106
|
-
function onClearDiagramStorage() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
117
|
+
function onClearDiagramStorage(model) {
|
|
118
|
+
subscriptions.add(eventService.subscribeToClearDiagramStorage(() => {
|
|
119
|
+
// re-subscribe, to avoid any pending debounced saves, which may write over the cleared diagram
|
|
120
|
+
subscribeToDiagramChange(model);
|
|
121
|
+
diagramStorageService.clear();
|
|
122
|
+
}));
|
|
110
123
|
}
|
|
111
124
|
/**
|
|
112
125
|
* The Reactodia workspace React component.
|
|
@@ -125,14 +138,14 @@ function ReactodiaApp(props) {
|
|
|
125
138
|
workspaceContext = context;
|
|
126
139
|
const { model } = context;
|
|
127
140
|
onDiagramChange(model);
|
|
128
|
-
onClearDiagramStorage();
|
|
141
|
+
onClearDiagramStorage(model);
|
|
129
142
|
const dataProvider = createDataProvider(props);
|
|
130
143
|
const isReload = props.isReload;
|
|
131
|
-
const savedDiagram =
|
|
132
|
-
const diagramService = service(DiagramService);
|
|
144
|
+
const savedDiagram = diagramStorageService.load();
|
|
133
145
|
if (isReload) {
|
|
134
|
-
//
|
|
135
|
-
//
|
|
146
|
+
// Reload the diagram that is currently on the canvas. This may happen when the host changes the provider
|
|
147
|
+
// settings, or when the user switches the language at runtime, since there is no existing mechanism to
|
|
148
|
+
// re-translate the UI at runtime (not for the UI labels at least)
|
|
136
149
|
await diagramService.importDiagram(model, dataProvider, currentDiagram, signal);
|
|
137
150
|
}
|
|
138
151
|
else if ((_a = config.seedIris) === null || _a === void 0 ? void 0 : _a.length) {
|
|
@@ -163,7 +176,12 @@ function ReactodiaApp(props) {
|
|
|
163
176
|
defaultLanguage: language,
|
|
164
177
|
translations: translationsForLanguage(language),
|
|
165
178
|
typeStyleResolver: resolveTypeStyle
|
|
166
|
-
}, createElement(DefaultWorkspace, {
|
|
179
|
+
}, createElement(DefaultWorkspace, {
|
|
180
|
+
colorScheme: props.theme,
|
|
181
|
+
menu: createElement(GraphwiseMenu),
|
|
182
|
+
// place Undo/redo/layout actions in top right corner.
|
|
183
|
+
actionsToolbar: { dock: 'ne' }
|
|
184
|
+
}));
|
|
167
185
|
}
|
|
168
186
|
/**
|
|
169
187
|
* Mounts the Reactodia application into the given container and returns the React root.
|
|
@@ -174,8 +192,9 @@ export function mountReactodia(container, props) {
|
|
|
174
192
|
return root;
|
|
175
193
|
}
|
|
176
194
|
/**
|
|
177
|
-
* Re-points the diagram at a new SPARQL endpoint
|
|
178
|
-
*
|
|
195
|
+
* Re-points the diagram at a new SPARQL endpoint by recreating it with a fresh data provider.
|
|
196
|
+
* The canvas is reset to empty, matching the initial mount, since the data of another repository
|
|
197
|
+
* has nothing to do with the current graph.
|
|
179
198
|
*/
|
|
180
199
|
export async function updateReactodia(props) {
|
|
181
200
|
if (!workspaceContext) {
|
|
@@ -46,8 +46,10 @@ let DiagramService = DiagramService_1 = class DiagramService {
|
|
|
46
46
|
clearTimeout(notifyTimer);
|
|
47
47
|
}
|
|
48
48
|
notifyTimer = setTimeout(() => {
|
|
49
|
+
if (notifyTimer) {
|
|
50
|
+
onChangeCallback(model.exportLayout());
|
|
51
|
+
}
|
|
49
52
|
notifyTimer = undefined;
|
|
50
|
-
onChangeCallback(model.exportLayout());
|
|
51
53
|
}, DiagramService_1.NOTIFY_DEBOUNCE_MS);
|
|
52
54
|
};
|
|
53
55
|
model.history.events.on(DiagramService_1.HISTORY_CHANGED_EVENT, onHistoryChange);
|
|
@@ -55,6 +57,7 @@ let DiagramService = DiagramService_1 = class DiagramService {
|
|
|
55
57
|
model.history.events.off(DiagramService_1.HISTORY_CHANGED_EVENT, onHistoryChange);
|
|
56
58
|
if (notifyTimer) {
|
|
57
59
|
clearTimeout(notifyTimer);
|
|
60
|
+
notifyTimer = undefined;
|
|
58
61
|
}
|
|
59
62
|
};
|
|
60
63
|
}
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
const NODE_COLOR_VARIABLES = [
|
|
2
|
-
'--gw-foreground-visual-diagram-categorical-01',
|
|
3
|
-
'--gw-foreground-visual-diagram-categorical-02',
|
|
4
|
-
'--gw-foreground-visual-diagram-categorical-03',
|
|
5
|
-
'--gw-foreground-visual-diagram-categorical-04',
|
|
6
|
-
'--gw-foreground-visual-diagram-categorical-05',
|
|
7
|
-
'--gw-foreground-visual-diagram-categorical-06',
|
|
8
|
-
'--gw-foreground-visual-diagram-categorical-07',
|
|
9
|
-
'--gw-foreground-visual-diagram-categorical-08',
|
|
10
|
-
'--gw-foreground-visual-diagram-categorical-09',
|
|
11
|
-
'--gw-foreground-visual-diagram-categorical-10',
|
|
12
|
-
'--gw-foreground-visual-diagram-categorical-11',
|
|
13
|
-
'--gw-foreground-visual-diagram-categorical-12',
|
|
14
|
-
'--gw-foreground-visual-diagram-categorical-13',
|
|
15
|
-
'--gw-foreground-visual-diagram-categorical-14',
|
|
16
|
-
'--gw-foreground-visual-diagram-categorical-15',
|
|
17
|
-
'--gw-foreground-visual-diagram-categorical-16',
|
|
18
|
-
'--gw-foreground-visual-diagram-categorical-17',
|
|
19
|
-
'--gw-foreground-visual-diagram-categorical-18',
|
|
20
|
-
'--gw-foreground-visual-diagram-categorical-19',
|
|
21
|
-
'--gw-foreground-visual-diagram-categorical-20'
|
|
22
|
-
];
|
|
23
1
|
/**
|
|
24
2
|
* Color slot assigned to each type, in the order the types are first seen.
|
|
25
3
|
*/
|
|
26
4
|
const typeToIndex = new Map();
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Returns the internal property of the given palette slot, numbered from 1 and padded to two digits as in `_theme.scss`.
|
|
7
|
+
*/
|
|
8
|
+
function getTypeColorProperty(slot) {
|
|
9
|
+
return `--_graphwise-reactodia-type-color-${String(slot).padStart(2, '0')}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Reads the type palette of the Theme API: the internal properties `_theme.scss` resolves from the ones
|
|
13
|
+
* the host declares, in slot order up to the first empty one.
|
|
14
|
+
*/
|
|
15
|
+
function getPalette() {
|
|
16
|
+
const host = document.querySelector('graphwise-reactodia');
|
|
17
|
+
if (!host) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
const style = getComputedStyle(host);
|
|
21
|
+
const palette = [];
|
|
22
|
+
let color = style.getPropertyValue(getTypeColorProperty(1)).trim();
|
|
23
|
+
while (color) {
|
|
24
|
+
palette.push(color);
|
|
25
|
+
color = style.getPropertyValue(getTypeColorProperty(palette.length + 1)).trim();
|
|
26
|
+
}
|
|
27
|
+
return palette;
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Colors an element by its type: each type takes the next color from the palette, which wraps
|
|
@@ -45,8 +44,8 @@ export const resolveTypeStyle = (types) => {
|
|
|
45
44
|
index = typeToIndex.size;
|
|
46
45
|
typeToIndex.set(type, index);
|
|
47
46
|
}
|
|
48
|
-
const
|
|
49
|
-
return
|
|
47
|
+
const colors = getPalette();
|
|
48
|
+
return colors.length ? { color: colors[index % colors.length] } : undefined;
|
|
50
49
|
};
|
|
51
50
|
export const resetColors = () => {
|
|
52
51
|
typeToIndex.clear();
|
|
@@ -27,6 +27,12 @@ function setQueryFunction() {
|
|
|
27
27
|
reactodia.config = {...reactodia.config, queryFunction: stubQueryFunction};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// The wrapper has no default preset, so the host always passes one. The demo uses Reactodia's generic
|
|
31
|
+
// OWL/RDFS preset, copied into `owl-rdfs-settings.js`.
|
|
32
|
+
function setProviderSettings() {
|
|
33
|
+
reactodia.providerSettings = OWL_RDFS_SETTINGS;
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
function setSeed() {
|
|
31
37
|
reactodia.config = {...reactodia.config, seedIris: SEED_NODES};
|
|
32
38
|
}
|
|
@@ -43,6 +49,10 @@ function setLanguage(language) {
|
|
|
43
49
|
reactodia.language = language;
|
|
44
50
|
}
|
|
45
51
|
|
|
52
|
+
function setTheme(theme) {
|
|
53
|
+
reactodia.theme = theme;
|
|
54
|
+
}
|
|
55
|
+
|
|
46
56
|
// The host asks the component to drop its persisted diagram by dispatching a namespaced window
|
|
47
57
|
// event, rather than holding an element reference and calling a method on it.
|
|
48
58
|
function clearDiagramStorage() {
|