ontotext-yasgui-web-component 0.0.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/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/cjs/index-c487dc05.js +1152 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/cjs/ontotext-yasgui-web-component.cjs.js +19 -0
- package/dist/cjs/ontotext-yasgui.cjs.entry.js +391 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/ontotext-yasgui-web-component/ontotext-yasgui-web-component.css +2361 -0
- package/dist/collection/components/ontotext-yasgui-web-component/ontotext-yasgui-web-component.js +152 -0
- package/dist/collection/components/yasgui/yasgui-script.js +4 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/js/main.js +8 -0
- package/dist/collection/models/ontotext-yasgui.js +41 -0
- package/dist/collection/models/yasgui-configuration.js +11 -0
- package/dist/collection/pages/default-view/main.js +8 -0
- package/dist/collection/pages/view-configurations/main.js +31 -0
- package/dist/collection/pages/view-modes/main.js +18 -0
- package/dist/collection/services/yasgui/configuration/configurator.js +1 -0
- package/dist/collection/services/yasgui/configuration/yasgui-configuration-builder.js +28 -0
- package/dist/collection/services/yasgui/configuration/yasgui-configurator.js +45 -0
- package/dist/collection/services/yasgui/configuration/yasqe-configurator.js +17 -0
- package/dist/collection/services/yasgui/configuration/yasr-configurator.js +12 -0
- package/dist/collection/services/yasgui/yasgui-builder.js +26 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +2 -0
- package/dist/components/ontotext-yasgui.d.ts +11 -0
- package/dist/components/ontotext-yasgui.js +407 -0
- package/dist/esm/index-5e3f8118.js +1124 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/ontotext-yasgui-web-component.js +17 -0
- package/dist/esm/ontotext-yasgui.entry.js +387 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/ontotext-yasgui-web-component/index.esm.js +0 -0
- package/dist/ontotext-yasgui-web-component/ontotext-yasgui-web-component.esm.js +1 -0
- package/dist/ontotext-yasgui-web-component/p-498af5d3.js +2 -0
- package/dist/ontotext-yasgui-web-component/p-88daf135.entry.js +2 -0
- package/dist/types/components/ontotext-yasgui-web-component/ontotext-yasgui-web-component.d.ts +21 -0
- package/dist/types/components.d.ts +46 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/models/ontotext-yasgui.d.ts +17 -0
- package/dist/types/models/yasgui-configuration.d.ts +40 -0
- package/dist/types/services/yasgui/configuration/configurator.d.ts +15 -0
- package/dist/types/services/yasgui/configuration/yasgui-configuration-builder.d.ts +18 -0
- package/dist/types/services/yasgui/configuration/yasgui-configurator.d.ts +14 -0
- package/dist/types/services/yasgui/configuration/yasqe-configurator.d.ts +8 -0
- package/dist/types/services/yasgui/configuration/yasr-configurator.d.ts +8 -0
- package/dist/types/services/yasgui/yasgui-builder.d.ts +20 -0
- package/dist/types/stencil-public-runtime.d.ts +1581 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +11 -0
- package/package.json +41 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class OntotextYasgui {
|
|
2
|
+
constructor(yasgui, config) {
|
|
3
|
+
this.yasgui = yasgui;
|
|
4
|
+
this.init(config);
|
|
5
|
+
}
|
|
6
|
+
setQuery(query) {
|
|
7
|
+
this.yasgui.getTab().getYasqe().setValue(query);
|
|
8
|
+
}
|
|
9
|
+
getQuery() {
|
|
10
|
+
return this.yasgui.getTab().getYasqe().getValue();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Initializes ontotext-yasgui component.
|
|
14
|
+
*
|
|
15
|
+
* @param config
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
init(config) {
|
|
19
|
+
if (config.initialQuery) {
|
|
20
|
+
this.setQuery(config.initialQuery);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
addYasqeListener(eventName, callback) {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
this.yasgui.getTab().yasqe.on(eventName, (_instance, _tab) => {
|
|
26
|
+
callback();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
destroy() {
|
|
30
|
+
if (this.yasgui) {
|
|
31
|
+
Object.keys(this.yasgui._tabs).forEach((tabId) => {
|
|
32
|
+
const tab = this.yasgui._tabs[tabId];
|
|
33
|
+
tab.getYasr() && tab.getYasr().destroy();
|
|
34
|
+
});
|
|
35
|
+
this.yasgui.destroy();
|
|
36
|
+
// this.yasguiElement = null;
|
|
37
|
+
this.yasgui = null;
|
|
38
|
+
localStorage.removeItem('yasqe__query');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var RenderingMode;
|
|
2
|
+
(function (RenderingMode) {
|
|
3
|
+
RenderingMode["YASGUI"] = "mode-yasgui";
|
|
4
|
+
RenderingMode["YASQE"] = "mode-yasqe";
|
|
5
|
+
RenderingMode["YASR"] = "mode-yasr";
|
|
6
|
+
})(RenderingMode || (RenderingMode = {}));
|
|
7
|
+
export var Orientation;
|
|
8
|
+
(function (Orientation) {
|
|
9
|
+
Orientation["VERTICAL"] = "orientation-vertical";
|
|
10
|
+
Orientation["HORIZONTAL"] = "orientation-horizontal";
|
|
11
|
+
})(Orientation || (Orientation = {}));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const ontoElement = document.querySelector("ontotext-yasgui");
|
|
2
|
+
ontoElement.config = {
|
|
3
|
+
query: '',
|
|
4
|
+
yasguiConfig: {
|
|
5
|
+
requestConfig: {
|
|
6
|
+
endpoint: "/repositories/test-repo"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
ontoElement.addEventListener("queryExecuted", () => {
|
|
12
|
+
const div = document.createElement('div');
|
|
13
|
+
div.innerHTML = '<div id="queryRan">Query was Executed</div>';
|
|
14
|
+
document.body.appendChild(div);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
function setShowEditorTabs(hideEditorTab) {
|
|
18
|
+
ontoElement.config = {...ontoElement.config, showEditorTabs: hideEditorTab}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function setShowResultTabs(showResultTabs) {
|
|
22
|
+
ontoElement.config = {...ontoElement.config, showResultTabs: showResultTabs}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function setDefaultQuery(query) {
|
|
26
|
+
ontoElement.config = {...ontoElement.config, query: query}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function setInitialQuery(initialQuery) {
|
|
30
|
+
ontoElement.config = {...ontoElement.config, initialQuery: initialQuery}
|
|
31
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
let ontoElement = document.querySelector("ontotext-yasgui");
|
|
2
|
+
ontoElement.config = {
|
|
3
|
+
yasguiConfig: {
|
|
4
|
+
requestConfig: {
|
|
5
|
+
endpoint: "/repositories/test-repo"
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
render: 'mode-yasgui',
|
|
9
|
+
orientation: 'orientation-vertical'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function renderMode(mode) {
|
|
13
|
+
ontoElement.config = {...ontoElement.config, render: mode};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function renderOrientation(mode) {
|
|
17
|
+
ontoElement.config = {...ontoElement.config, orientation: mode};
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { YasguiConfigurator } from './yasgui-configurator';
|
|
2
|
+
import { YasqeConfigurator } from './yasqe-configurator';
|
|
3
|
+
import { YasrConfigurator } from './yasr-configurator';
|
|
4
|
+
/**
|
|
5
|
+
* Builder for yasgui configuration.
|
|
6
|
+
*/
|
|
7
|
+
class YasguiConfigurationBuilderDefinition {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.initConfigurators();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds a yasgui configuration.
|
|
13
|
+
* @param el - hte ontotext-yasgui element.
|
|
14
|
+
* @param config - custom configuration passed by client of component.
|
|
15
|
+
*/
|
|
16
|
+
build(el, config) {
|
|
17
|
+
return this.configurators
|
|
18
|
+
.reduce((result, configurator) => configurator.config(el, result, config), {});
|
|
19
|
+
}
|
|
20
|
+
initConfigurators() {
|
|
21
|
+
this.configurators = [
|
|
22
|
+
YasguiConfigurator,
|
|
23
|
+
YasqeConfigurator,
|
|
24
|
+
YasrConfigurator
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export const YasguiConfigurationBuilder = new YasguiConfigurationBuilderDefinition();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Orientation, RenderingMode } from '../../../models/yasgui-configuration';
|
|
2
|
+
import deepmerge from 'deepmerge';
|
|
3
|
+
/**
|
|
4
|
+
* Manages all top configuration of yasgui.
|
|
5
|
+
*/
|
|
6
|
+
class YasguiConfiguratorDefinition {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.defaultYasguiConfig = {
|
|
9
|
+
render: RenderingMode.YASGUI,
|
|
10
|
+
orientation: Orientation.VERTICAL,
|
|
11
|
+
copyEndpointOnNewTab: true,
|
|
12
|
+
requestConfig: {
|
|
13
|
+
endpoint: '',
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers: () => {
|
|
16
|
+
return {
|
|
17
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
18
|
+
'Accept': 'application/sparql-results+json',
|
|
19
|
+
'X-GraphDB-Local-Consistency': 'updating'
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
config(_el, config, yasguiConfig) {
|
|
26
|
+
this.setOrientation(yasguiConfig, _el);
|
|
27
|
+
this.setRenderMode(yasguiConfig, _el);
|
|
28
|
+
return deepmerge.all([config, this.defaultYasguiConfig, yasguiConfig.yasguiConfig || {}]);
|
|
29
|
+
}
|
|
30
|
+
setRenderMode(yasguiConfig, _el) {
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
const modes = Object.values(RenderingMode);
|
|
33
|
+
_el.classList.remove(...modes);
|
|
34
|
+
const newMode = !!yasguiConfig.render ? yasguiConfig.render : this.defaultYasguiConfig.render;
|
|
35
|
+
_el.classList.add(newMode);
|
|
36
|
+
}
|
|
37
|
+
setOrientation(yasguiConfig, _el) {
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
const orientations = Object.values(Orientation);
|
|
40
|
+
_el.classList.remove(...orientations);
|
|
41
|
+
const newOrientation = !!yasguiConfig.orientation ? yasguiConfig.orientation : this.defaultYasguiConfig.orientation;
|
|
42
|
+
_el.classList.add(newOrientation);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export const YasguiConfigurator = new YasguiConfiguratorDefinition();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class YasqeConfiguratorDefinition {
|
|
2
|
+
config(el, config, yasguiConfig) {
|
|
3
|
+
if (yasguiConfig.hasOwnProperty('showEditorTabs') && !yasguiConfig.showEditorTabs) {
|
|
4
|
+
el.classList.add('hidden-editor-tabs');
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
el.classList.remove('hidden-editor-tabs');
|
|
8
|
+
}
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
if (yasguiConfig.query && window.Yasgui) {
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
window.Yasgui.Yasqe.defaults.value = yasguiConfig.query;
|
|
13
|
+
}
|
|
14
|
+
return config;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export const YasqeConfigurator = new YasqeConfiguratorDefinition();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class YasrConfiguratorDefinition {
|
|
2
|
+
config(el, config, yasguiConfig) {
|
|
3
|
+
if (yasguiConfig.hasOwnProperty('showResultTabs') && !yasguiConfig.showResultTabs) {
|
|
4
|
+
el.classList.add('hidden-result-tabs');
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
el.classList.remove('hidden-result-tabs');
|
|
8
|
+
}
|
|
9
|
+
return config;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export const YasrConfigurator = new YasrConfiguratorDefinition();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { YasguiConfigurationBuilder } from './configuration/yasgui-configuration-builder';
|
|
2
|
+
import { OntotextYasgui } from '../../models/ontotext-yasgui';
|
|
3
|
+
/**
|
|
4
|
+
* Builder yasgui instance.
|
|
5
|
+
* It configures, creates an instance of yasgui and apply patches to created instance.
|
|
6
|
+
*/
|
|
7
|
+
class YasguiBuilderDefinition {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.yasguiConfigurationBuilder = YasguiConfigurationBuilder;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds an instance of yasgui. The building of instances is a two-step process.
|
|
13
|
+
* A yasgui configuration is created on first step.
|
|
14
|
+
* The created instance is patched on second step.
|
|
15
|
+
* @param el - parent element of yasgui instance.
|
|
16
|
+
* @param config - configuration passed from client of component. It overrides default values of yasgui component.
|
|
17
|
+
*/
|
|
18
|
+
build(el, config) {
|
|
19
|
+
const yasguiConfig = this.yasguiConfigurationBuilder.build(el, config);
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
const yasgui = new Yasgui(el, yasguiConfig);
|
|
22
|
+
// monkey patches have to be applied before return yasgui.
|
|
23
|
+
return new OntotextYasgui(yasgui, config);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const YasguiBuilder = new YasguiBuilderDefinition();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* OntotextYasguiWebComponent custom elements */
|
|
2
|
+
export { OntotextYasguiWebComponent as OntotextYasgui } from '../types/components/ontotext-yasgui-web-component/ontotext-yasgui-web-component';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Used to manually set the base path where assets can be found.
|
|
6
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
7
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
8
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
9
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
10
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
11
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
12
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
13
|
+
*/
|
|
14
|
+
export declare const setAssetPath: (path: string) => void;
|
|
15
|
+
|
|
16
|
+
export interface SetPlatformOptions {
|
|
17
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
18
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
19
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
22
|
+
export * from '../types';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface OntotextYasgui extends Components.OntotextYasgui, HTMLElement {}
|
|
4
|
+
export const OntotextYasgui: {
|
|
5
|
+
prototype: OntotextYasgui;
|
|
6
|
+
new (): OntotextYasgui;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|