@matdata/yasr 5.0.1 → 5.2.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@matdata/yasr",
3
3
  "description": "Yet Another SPARQL Resultset GUI",
4
- "version": "5.0.1",
4
+ "version": "5.2.0",
5
5
  "main": "build/yasr.min.js",
6
6
  "types": "build/ts/src/index.d.ts",
7
7
  "license": "MIT",
package/src/main.scss CHANGED
@@ -1,5 +1,9 @@
1
1
  @use "scss/variables.scss";
2
2
  .yasr {
3
+ display: flex;
4
+ flex-direction: column;
5
+ min-height: 400px; // Minimum height for vertical layout to give plugins space
6
+
3
7
  .yasr_btn {
4
8
  border: none;
5
9
  background: inherit;
@@ -56,7 +60,7 @@
56
60
  // redeclared here to target yasr_btns in btnGroup
57
61
  border-bottom: 2px solid transparent;
58
62
  &.selected {
59
- border-bottom: 2px solid #337ab7;
63
+ border-bottom: 2px solid var(--yasgui-accent-color, #337ab7);
60
64
  }
61
65
  padding-left: 6px;
62
66
  padding-right: 6px;
@@ -81,8 +85,10 @@
81
85
  .yasr_header {
82
86
  display: flex;
83
87
  flex-wrap: wrap;
88
+ flex-shrink: 0;
84
89
  }
85
90
  .yasr_fallback_info:not(:empty) {
91
+ flex-shrink: 0;
86
92
  margin-top: 5px;
87
93
  border: 1px solid #d1d1d1;
88
94
  padding: 0.5rem;
@@ -123,8 +129,8 @@
123
129
  }
124
130
  }
125
131
  .yasr_btn {
126
- color: #505050;
127
- fill: #505050;
132
+ color: var(--yasgui-button-text, #505050);
133
+ fill: var(--yasgui-button-text, #505050);
128
134
  display: flex;
129
135
  align-items: center;
130
136
  justify-content: center;
@@ -145,8 +151,8 @@
145
151
  box-shadow: none;
146
152
  }
147
153
  &:not(.disabled):hover {
148
- fill: black;
149
- color: black;
154
+ fill: var(--yasgui-button-hover, black);
155
+ color: var(--yasgui-button-hover, black);
150
156
  }
151
157
  }
152
158
 
@@ -191,8 +197,8 @@
191
197
  }
192
198
  &:focus,
193
199
  &.selected {
194
- color: #337ab7;
195
- fill: #337ab7;
200
+ color: var(--yasgui-accent-color, #337ab7);
201
+ fill: var(--yasgui-accent-color, #337ab7);
196
202
  }
197
203
  }
198
204
 
@@ -226,4 +232,10 @@
226
232
  flex-grow: 1;
227
233
  min-width: 10px;
228
234
  }
235
+
236
+ .yasr_results {
237
+ flex: 1;
238
+ overflow: auto;
239
+ min-height: 0;
240
+ }
229
241
  }
@@ -2,7 +2,7 @@ import Parser from "./";
2
2
  export default function (queryResponse: any, postProcessBinding: Parser.PostProcessBinding): Parser.SparqlResults {
3
3
  if (typeof queryResponse == "string") {
4
4
  const json = JSON.parse(queryResponse);
5
- if (postProcessBinding) {
5
+ if (postProcessBinding && json.results) {
6
6
  for (const binding in json.results.bindings) {
7
7
  json.results.bindings[binding] = postProcessBinding(json.results.bindings[binding]);
8
8
  }
@@ -15,6 +15,7 @@ import "codemirror/mode/xml/xml.js";
15
15
 
16
16
  import "codemirror/mode/javascript/javascript.js";
17
17
  import "codemirror/lib/codemirror.css";
18
+ import "codemirror/theme/material-palenight.css";
18
19
  import { drawSvgStringAsElement, addClass, removeClass, drawFontAwesomeIconAsSvg } from "@matdata/yasgui-utils";
19
20
  import * as faAlignIcon from "@fortawesome/free-solid-svg-icons/faAlignLeft";
20
21
  import { DeepReadonly } from "ts-essentials";
@@ -78,6 +79,10 @@ export default class Response implements Plugin<PluginConfig> {
78
79
  value = lines.slice(0, config.maxLines).join("\n");
79
80
  }
80
81
 
82
+ // Detect current theme from document
83
+ const isDarkTheme = document.documentElement.getAttribute("data-theme") === "dark";
84
+ const cmTheme = isDarkTheme ? "material-palenight" : "default";
85
+
81
86
  const codemirrorOpts: Partial<CodeMirror.EditorConfiguration> = {
82
87
  readOnly: true,
83
88
  lineNumbers: true,
@@ -86,6 +91,7 @@ export default class Response implements Plugin<PluginConfig> {
86
91
  gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
87
92
  value: value,
88
93
  extraKeys: { Tab: false },
94
+ theme: cmTheme,
89
95
  };
90
96
  const mode = this.yasr.results?.getType();
91
97
  if (mode === "json") {