graphwise-reactodia 0.0.1-TR13 → 0.0.1-TR15
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 +72 -42
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.css +44 -1
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.js +21 -7
- package/dist/collection/components/graphwise-reactodia/reactodia-app.js +24 -10
- 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 +38 -0
- package/dist/esm/graphwise-reactodia.entry.js +72 -42
- package/dist/graphwise-reactodia/graphwise-reactodia.esm.js +1 -1
- package/dist/graphwise-reactodia/p-a2c710e4.entry.js +1 -0
- package/dist/types/components/graphwise-reactodia/graphwise-reactodia.d.ts +11 -5
- package/dist/types/components/graphwise-reactodia/models/reactodia-app-props.d.ts +4 -0
- package/dist/types/components.d.ts +4 -4
- package/package.json +1 -1
- package/dist/graphwise-reactodia/p-420b9dce.entry.js +0 -1
|
@@ -31374,8 +31374,10 @@ let DiagramService = DiagramService_1 = class DiagramService {
|
|
|
31374
31374
|
clearTimeout(notifyTimer);
|
|
31375
31375
|
}
|
|
31376
31376
|
notifyTimer = setTimeout(() => {
|
|
31377
|
+
if (notifyTimer) {
|
|
31378
|
+
onChangeCallback(model.exportLayout());
|
|
31379
|
+
}
|
|
31377
31380
|
notifyTimer = undefined;
|
|
31378
|
-
onChangeCallback(model.exportLayout());
|
|
31379
31381
|
}, DiagramService_1.NOTIFY_DEBOUNCE_MS);
|
|
31380
31382
|
};
|
|
31381
31383
|
model.history.events.on(DiagramService_1.HISTORY_CHANGED_EVENT, onHistoryChange);
|
|
@@ -31383,6 +31385,7 @@ let DiagramService = DiagramService_1 = class DiagramService {
|
|
|
31383
31385
|
model.history.events.off(DiagramService_1.HISTORY_CHANGED_EVENT, onHistoryChange);
|
|
31384
31386
|
if (notifyTimer) {
|
|
31385
31387
|
clearTimeout(notifyTimer);
|
|
31388
|
+
notifyTimer = undefined;
|
|
31386
31389
|
}
|
|
31387
31390
|
};
|
|
31388
31391
|
}
|
|
@@ -31524,34 +31527,33 @@ class SubscriptionList {
|
|
|
31524
31527
|
}
|
|
31525
31528
|
}
|
|
31526
31529
|
|
|
31527
|
-
const NODE_COLOR_VARIABLES = [
|
|
31528
|
-
'--gw-foreground-visual-diagram-categorical-01',
|
|
31529
|
-
'--gw-foreground-visual-diagram-categorical-02',
|
|
31530
|
-
'--gw-foreground-visual-diagram-categorical-03',
|
|
31531
|
-
'--gw-foreground-visual-diagram-categorical-04',
|
|
31532
|
-
'--gw-foreground-visual-diagram-categorical-05',
|
|
31533
|
-
'--gw-foreground-visual-diagram-categorical-06',
|
|
31534
|
-
'--gw-foreground-visual-diagram-categorical-07',
|
|
31535
|
-
'--gw-foreground-visual-diagram-categorical-08',
|
|
31536
|
-
'--gw-foreground-visual-diagram-categorical-09',
|
|
31537
|
-
'--gw-foreground-visual-diagram-categorical-10',
|
|
31538
|
-
'--gw-foreground-visual-diagram-categorical-11',
|
|
31539
|
-
'--gw-foreground-visual-diagram-categorical-12',
|
|
31540
|
-
'--gw-foreground-visual-diagram-categorical-13',
|
|
31541
|
-
'--gw-foreground-visual-diagram-categorical-14',
|
|
31542
|
-
'--gw-foreground-visual-diagram-categorical-15',
|
|
31543
|
-
'--gw-foreground-visual-diagram-categorical-16',
|
|
31544
|
-
'--gw-foreground-visual-diagram-categorical-17',
|
|
31545
|
-
'--gw-foreground-visual-diagram-categorical-18',
|
|
31546
|
-
'--gw-foreground-visual-diagram-categorical-19',
|
|
31547
|
-
'--gw-foreground-visual-diagram-categorical-20'
|
|
31548
|
-
];
|
|
31549
31530
|
/**
|
|
31550
31531
|
* Color slot assigned to each type, in the order the types are first seen.
|
|
31551
31532
|
*/
|
|
31552
31533
|
const typeToIndex = new Map();
|
|
31553
|
-
|
|
31554
|
-
|
|
31534
|
+
/**
|
|
31535
|
+
* Returns the internal property of the given palette slot, numbered from 1 and padded to two digits as in `_theme.scss`.
|
|
31536
|
+
*/
|
|
31537
|
+
function getTypeColorProperty(slot) {
|
|
31538
|
+
return `--_graphwise-reactodia-type-color-${String(slot).padStart(2, '0')}`;
|
|
31539
|
+
}
|
|
31540
|
+
/**
|
|
31541
|
+
* Reads the type palette of the Theme API: the internal properties `_theme.scss` resolves from the ones
|
|
31542
|
+
* the host declares, in slot order up to the first empty one.
|
|
31543
|
+
*/
|
|
31544
|
+
function getPalette() {
|
|
31545
|
+
const host = document.querySelector('graphwise-reactodia');
|
|
31546
|
+
if (!host) {
|
|
31547
|
+
return [];
|
|
31548
|
+
}
|
|
31549
|
+
const style = getComputedStyle(host);
|
|
31550
|
+
const palette = [];
|
|
31551
|
+
let color = style.getPropertyValue(getTypeColorProperty(1)).trim();
|
|
31552
|
+
while (color) {
|
|
31553
|
+
palette.push(color);
|
|
31554
|
+
color = style.getPropertyValue(getTypeColorProperty(palette.length + 1)).trim();
|
|
31555
|
+
}
|
|
31556
|
+
return palette;
|
|
31555
31557
|
}
|
|
31556
31558
|
/**
|
|
31557
31559
|
* Colors an element by its type: each type takes the next color from the palette, which wraps
|
|
@@ -31571,8 +31573,8 @@ const resolveTypeStyle = (types) => {
|
|
|
31571
31573
|
index = typeToIndex.size;
|
|
31572
31574
|
typeToIndex.set(type, index);
|
|
31573
31575
|
}
|
|
31574
|
-
const
|
|
31575
|
-
return
|
|
31576
|
+
const colors = getPalette();
|
|
31577
|
+
return colors.length ? { color: colors[index % colors.length] } : undefined;
|
|
31576
31578
|
};
|
|
31577
31579
|
const resetColors = () => {
|
|
31578
31580
|
typeToIndex.clear();
|
|
@@ -31695,6 +31697,10 @@ let workspaceContext = null;
|
|
|
31695
31697
|
* the React root.
|
|
31696
31698
|
*/
|
|
31697
31699
|
const subscriptions = new SubscriptionList();
|
|
31700
|
+
let diagramStorageSubscription;
|
|
31701
|
+
const diagramService = service(DiagramService);
|
|
31702
|
+
const diagramStorageService = service(DiagramStorageService);
|
|
31703
|
+
const eventService = service(EventService);
|
|
31698
31704
|
/**
|
|
31699
31705
|
* Builds a Reactodia {@link SparqlDataProvider} for the given endpoint using the supplied
|
|
31700
31706
|
* query preset. The host owns the query configuration and always passes it in via props.
|
|
@@ -31754,20 +31760,30 @@ async function seedGraphToCanvas(context, dataProvider, links, signal) {
|
|
|
31754
31760
|
* root in {@link unmountReactodia}.
|
|
31755
31761
|
*/
|
|
31756
31762
|
function onDiagramChange(model) {
|
|
31757
|
-
|
|
31758
|
-
|
|
31759
|
-
|
|
31763
|
+
subscribeToDiagramChange(model);
|
|
31764
|
+
}
|
|
31765
|
+
/**
|
|
31766
|
+
* Starts persisting the model's edits to local storage, keeping the subscription in {@link diagramStorageSubscription}.
|
|
31767
|
+
*/
|
|
31768
|
+
function subscribeToDiagramChange(model) {
|
|
31769
|
+
diagramStorageSubscription === null || diagramStorageSubscription === void 0 ? void 0 : diagramStorageSubscription();
|
|
31770
|
+
diagramStorageSubscription = diagramService.subscribeToDiagramChange(model, (diagram) => diagramStorageService.save(diagram));
|
|
31771
|
+
subscriptions.add(diagramStorageSubscription);
|
|
31760
31772
|
}
|
|
31761
31773
|
/**
|
|
31762
31774
|
* Subscribes to the host's "clear persisted diagram" command so the saved layout is dropped on
|
|
31763
31775
|
* request (e.g. before a fresh seed should take precedence over previously saved edits). The
|
|
31764
31776
|
* subscription is tracked in {@link subscriptions} so it is released together with the React
|
|
31765
31777
|
* root in {@link unmountReactodia}.
|
|
31778
|
+
*
|
|
31779
|
+
* @param model The diagram model whose edits are persisted
|
|
31766
31780
|
*/
|
|
31767
|
-
function onClearDiagramStorage() {
|
|
31768
|
-
|
|
31769
|
-
|
|
31770
|
-
|
|
31781
|
+
function onClearDiagramStorage(model) {
|
|
31782
|
+
subscriptions.add(eventService.subscribeToClearDiagramStorage(() => {
|
|
31783
|
+
// re-subscribe, to avoid any pending debounced saves, which may write over the cleared diagram
|
|
31784
|
+
subscribeToDiagramChange(model);
|
|
31785
|
+
diagramStorageService.clear();
|
|
31786
|
+
}));
|
|
31771
31787
|
}
|
|
31772
31788
|
/**
|
|
31773
31789
|
* The Reactodia workspace React component.
|
|
@@ -31786,11 +31802,10 @@ function ReactodiaApp(props) {
|
|
|
31786
31802
|
workspaceContext = context;
|
|
31787
31803
|
const { model } = context;
|
|
31788
31804
|
onDiagramChange(model);
|
|
31789
|
-
onClearDiagramStorage();
|
|
31805
|
+
onClearDiagramStorage(model);
|
|
31790
31806
|
const dataProvider = createDataProvider(props);
|
|
31791
31807
|
const isReload = props.isReload;
|
|
31792
|
-
const savedDiagram =
|
|
31793
|
-
const diagramService = service(DiagramService);
|
|
31808
|
+
const savedDiagram = diagramStorageService.load();
|
|
31794
31809
|
if (isReload) {
|
|
31795
31810
|
// Reload the diagram that is currently on the canvas. This may happen when the host changes the provider
|
|
31796
31811
|
// settings, or when the user switches the language at runtime, since there is no existing mechanism to
|
|
@@ -31826,6 +31841,7 @@ function ReactodiaApp(props) {
|
|
|
31826
31841
|
translations: translationsForLanguage(language),
|
|
31827
31842
|
typeStyleResolver: resolveTypeStyle
|
|
31828
31843
|
}, reactExports.createElement(DefaultWorkspace, {
|
|
31844
|
+
colorScheme: props.theme,
|
|
31829
31845
|
menu: reactExports.createElement(GraphwiseMenu),
|
|
31830
31846
|
// place Undo/redo/layout actions in top right corner.
|
|
31831
31847
|
actionsToolbar: { dock: 'ne' }
|
|
@@ -31867,7 +31883,7 @@ function unmountReactodia(root) {
|
|
|
31867
31883
|
root.unmount();
|
|
31868
31884
|
}
|
|
31869
31885
|
|
|
31870
|
-
const graphwiseReactodiaCss = "graphwise-reactodia{display:block;width:100%;height:
|
|
31886
|
+
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}";
|
|
31871
31887
|
|
|
31872
31888
|
const GraphwiseReactodia = class {
|
|
31873
31889
|
constructor(hostRef) {
|
|
@@ -31876,6 +31892,14 @@ const GraphwiseReactodia = class {
|
|
|
31876
31892
|
* UI language code (e.g. `en`, `fr`) for the Reactodia interface. Defaults to English.
|
|
31877
31893
|
*/
|
|
31878
31894
|
this.language = LanguageKey.EN;
|
|
31895
|
+
/**
|
|
31896
|
+
* `connectedCallback` and the watchers can run before all props are set: when the component's
|
|
31897
|
+
* code is already loaded, the instance is created as soon as the
|
|
31898
|
+
* element is attached, and every prop set after that triggers its watcher. Rendering at that
|
|
31899
|
+
* point would initialise the graph without all props. `componentDidLoad` runs once the initial
|
|
31900
|
+
* props are set, so we use it to determine when it's safe to render.
|
|
31901
|
+
*/
|
|
31902
|
+
this.isComponentLoaded = false;
|
|
31879
31903
|
}
|
|
31880
31904
|
onCurrentRepositoryChange() {
|
|
31881
31905
|
this.renderGraph();
|
|
@@ -31891,9 +31915,11 @@ const GraphwiseReactodia = class {
|
|
|
31891
31915
|
this.renderGraph(true);
|
|
31892
31916
|
}
|
|
31893
31917
|
connectedCallback() {
|
|
31894
|
-
|
|
31895
|
-
|
|
31896
|
-
|
|
31918
|
+
this.renderGraph();
|
|
31919
|
+
}
|
|
31920
|
+
componentDidLoad() {
|
|
31921
|
+
this.isComponentLoaded = true;
|
|
31922
|
+
this.renderGraph();
|
|
31897
31923
|
}
|
|
31898
31924
|
disconnectedCallback() {
|
|
31899
31925
|
if (this.reactRoot) {
|
|
@@ -31902,10 +31928,13 @@ const GraphwiseReactodia = class {
|
|
|
31902
31928
|
}
|
|
31903
31929
|
}
|
|
31904
31930
|
render() {
|
|
31905
|
-
return (h(Host, { key: '
|
|
31931
|
+
return (h(Host, { key: 'a03aad892cb1947ab2426d77b3229e1324776c2c' }));
|
|
31906
31932
|
}
|
|
31907
31933
|
renderGraph(isReloading) {
|
|
31908
31934
|
var _a;
|
|
31935
|
+
if (!this.isComponentLoaded) {
|
|
31936
|
+
return;
|
|
31937
|
+
}
|
|
31909
31938
|
if (!this.currentRepository) {
|
|
31910
31939
|
throw new Error('currentRepository is required');
|
|
31911
31940
|
}
|
|
@@ -31924,6 +31953,7 @@ const GraphwiseReactodia = class {
|
|
|
31924
31953
|
config: this.config,
|
|
31925
31954
|
language: this.language,
|
|
31926
31955
|
providerSettings: this.providerSettings,
|
|
31956
|
+
theme: this.theme,
|
|
31927
31957
|
};
|
|
31928
31958
|
if (this.reactRoot && !isReloading) {
|
|
31929
31959
|
void updateReactodia(props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as r}from"./p-Cypw7ydc.js";export{s as setNonce}from"./p-Cypw7ydc.js";import{g as t}from"./p-CalY52z6.js";(()=>{const r=import.meta.url,t={};return""!==r&&(t.resourcesUrl=new URL(".",r).href),e(t)})().then((async e=>(await t(),r([["p-
|
|
1
|
+
import{p as e,b as r}from"./p-Cypw7ydc.js";export{s as setNonce}from"./p-Cypw7ydc.js";import{g as t}from"./p-CalY52z6.js";(()=>{const r=import.meta.url,t={};return""!==r&&(t.resourcesUrl=new URL(".",r).href),e(t)})().then((async e=>(await t(),r([["p-a2c710e4",[[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"]}]]]],e))));
|