@matdata/yasr 5.5.0 → 5.7.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.
@@ -1,246 +0,0 @@
1
- import { describe, it } from "mocha";
2
- import { expect } from "chai";
3
- import Yasr from "../../../index";
4
- import Parser from "../../../parsers";
5
-
6
- describe("Table Plugin", () => {
7
- describe("Markdown Generation", () => {
8
- it("should generate markdown table from simple results", () => {
9
- const container = document.createElement("div");
10
- const yasr = new Yasr(container);
11
-
12
- // Mock SPARQL results
13
- const mockResults = {
14
- head: {
15
- vars: ["subject", "predicate", "object"],
16
- },
17
- results: {
18
- bindings: [
19
- {
20
- subject: { type: "uri", value: "http://example.org/resource/1" } as Parser.BindingValue,
21
- predicate: { type: "uri", value: "http://example.org/name" } as Parser.BindingValue,
22
- object: { type: "literal", value: "Test Name" } as Parser.BindingValue,
23
- },
24
- {
25
- subject: { type: "uri", value: "http://example.org/resource/2" } as Parser.BindingValue,
26
- predicate: { type: "uri", value: "http://example.org/name" } as Parser.BindingValue,
27
- object: { type: "literal", value: "Another Name" } as Parser.BindingValue,
28
- },
29
- ],
30
- },
31
- };
32
-
33
- yasr.setResponse(
34
- {
35
- response: JSON.stringify(mockResults),
36
- status: 200,
37
- contentType: "application/sparql-results+json",
38
- },
39
- 0,
40
- );
41
-
42
- const tablePlugin = yasr.plugins["table"];
43
- // @ts-ignore - accessing private method for testing
44
- const markdown = tablePlugin.getMarkdownTable();
45
-
46
- expect(markdown).to.be.a("string");
47
- expect(markdown).to.include("| subject | predicate | object |");
48
- expect(markdown).to.include("| --- | --- | --- |");
49
- expect(markdown).to.include("http://example.org/resource/1");
50
- expect(markdown).to.include("Test Name");
51
- });
52
-
53
- it("should escape pipe characters in markdown values", () => {
54
- const container = document.createElement("div");
55
- const yasr = new Yasr(container);
56
-
57
- // Mock SPARQL results with pipe character
58
- const mockResults = {
59
- head: {
60
- vars: ["value"],
61
- },
62
- results: {
63
- bindings: [
64
- {
65
- value: { type: "literal", value: "text|with|pipes" } as Parser.BindingValue,
66
- },
67
- ],
68
- },
69
- };
70
-
71
- yasr.setResponse(
72
- {
73
- response: JSON.stringify(mockResults),
74
- status: 200,
75
- contentType: "application/sparql-results+json",
76
- },
77
- 0,
78
- );
79
-
80
- const tablePlugin = yasr.plugins["table"];
81
- // @ts-ignore - accessing private method for testing
82
- const markdown = tablePlugin.getMarkdownTable();
83
-
84
- expect(markdown).to.include("text\\|with\\|pipes");
85
- });
86
- });
87
-
88
- describe("URI Prefixing", () => {
89
- it("should show URI prefixes when enabled", () => {
90
- const container = document.createElement("div");
91
- const yasr = new Yasr(container, {
92
- prefixes: {
93
- ex: "http://example.org/",
94
- },
95
- });
96
-
97
- const mockResults = {
98
- head: {
99
- vars: ["resource"],
100
- },
101
- results: {
102
- bindings: [
103
- {
104
- resource: { type: "uri", value: "http://example.org/test" } as Parser.BindingValue,
105
- },
106
- ],
107
- },
108
- };
109
-
110
- yasr.setResponse(
111
- {
112
- response: JSON.stringify(mockResults),
113
- status: 200,
114
- contentType: "application/sparql-results+json",
115
- },
116
- 0,
117
- );
118
-
119
- const tablePlugin = yasr.plugins["table"];
120
- // Draw with prefixes enabled (default)
121
- tablePlugin.draw({ showUriPrefixes: true });
122
-
123
- const tableHtml = container.innerHTML;
124
- expect(tableHtml).to.include("ex:test");
125
- });
126
-
127
- it("should show full URIs when prefixing disabled", () => {
128
- const container = document.createElement("div");
129
- const yasr = new Yasr(container, {
130
- prefixes: {
131
- ex: "http://example.org/",
132
- },
133
- });
134
-
135
- const mockResults = {
136
- head: {
137
- vars: ["resource"],
138
- },
139
- results: {
140
- bindings: [
141
- {
142
- resource: { type: "uri", value: "http://example.org/test" } as Parser.BindingValue,
143
- },
144
- ],
145
- },
146
- };
147
-
148
- yasr.setResponse(
149
- {
150
- response: JSON.stringify(mockResults),
151
- status: 200,
152
- contentType: "application/sparql-results+json",
153
- },
154
- 0,
155
- );
156
-
157
- const tablePlugin = yasr.plugins["table"];
158
- // Draw with prefixes disabled
159
- tablePlugin.draw({ showUriPrefixes: false });
160
-
161
- const tableHtml = container.innerHTML;
162
- expect(tableHtml).to.include("http://example.org/test");
163
- expect(tableHtml).to.not.include("ex:test");
164
- });
165
- });
166
-
167
- describe("Datatype Display", () => {
168
- it("should show datatypes when enabled", () => {
169
- const container = document.createElement("div");
170
- const yasr = new Yasr(container);
171
-
172
- const mockResults = {
173
- head: {
174
- vars: ["number"],
175
- },
176
- results: {
177
- bindings: [
178
- {
179
- number: {
180
- type: "literal",
181
- value: "42",
182
- datatype: "http://www.w3.org/2001/XMLSchema#integer",
183
- } as Parser.BindingValue,
184
- },
185
- ],
186
- },
187
- };
188
-
189
- yasr.setResponse(
190
- {
191
- response: JSON.stringify(mockResults),
192
- status: 200,
193
- contentType: "application/sparql-results+json",
194
- },
195
- 0,
196
- );
197
-
198
- const tablePlugin = yasr.plugins["table"];
199
- // Draw with datatypes enabled (default)
200
- tablePlugin.draw({ showDatatypes: true });
201
-
202
- const tableHtml = container.innerHTML;
203
- expect(tableHtml).to.include("^^");
204
- expect(tableHtml).to.include("XMLSchema#integer");
205
- });
206
-
207
- it("should hide datatypes when disabled", () => {
208
- const container = document.createElement("div");
209
- const yasr = new Yasr(container);
210
-
211
- const mockResults = {
212
- head: {
213
- vars: ["number"],
214
- },
215
- results: {
216
- bindings: [
217
- {
218
- number: {
219
- type: "literal",
220
- value: "42",
221
- datatype: "http://www.w3.org/2001/XMLSchema#integer",
222
- } as Parser.BindingValue,
223
- },
224
- ],
225
- },
226
- };
227
-
228
- yasr.setResponse(
229
- {
230
- response: JSON.stringify(mockResults),
231
- status: 200,
232
- contentType: "application/sparql-results+json",
233
- },
234
- 0,
235
- );
236
-
237
- const tablePlugin = yasr.plugins["table"];
238
- // Draw with datatypes disabled
239
- tablePlugin.draw({ showDatatypes: false });
240
-
241
- const tableHtml = container.innerHTML;
242
- expect(tableHtml).to.not.include("^^");
243
- expect(tableHtml).to.not.include("XMLSchema#integer");
244
- });
245
- });
246
- });
@@ -1,29 +0,0 @@
1
- declare module "column-resizer" {
2
- interface ColumnResizerOptions {
3
- liveDrag?: boolean;
4
- draggingClass?: string;
5
- gripInnerHtml?: string;
6
- minWidth?: number;
7
- headerOnly?: boolean;
8
- hoverCursor?: string;
9
- dragCursor?: string;
10
- resizeMode?: "fit" | "overflow" | "flex";
11
- widths?: number[];
12
- partialRefresh?: boolean;
13
- onResize?: (() => void) | boolean;
14
- [key: string]: any;
15
- }
16
-
17
- interface ColumnResizerInstance {
18
- reset(options: { disable: boolean; onResize?: () => void; partialRefresh?: boolean; headerOnly?: boolean }): void;
19
- onResize: () => void;
20
- }
21
-
22
- class ColumnResizer implements ColumnResizerInstance {
23
- constructor(table: HTMLElement, options?: ColumnResizerOptions);
24
- reset(options: { disable: boolean; onResize?: () => void; partialRefresh?: boolean; headerOnly?: boolean }): void;
25
- onResize: () => void;
26
- }
27
-
28
- export default ColumnResizer;
29
- }
@@ -1,167 +0,0 @@
1
- /**
2
- Delimiters
3
- Delimiters used by us
4
- - CamelCase
5
- Delimiters used by datatables
6
- - dashes
7
- - underscores
8
- */
9
-
10
- .yasr {
11
- .tableControls {
12
- display: flex;
13
- align-items: center;
14
- padding: 0px;
15
- padding-right: 5px;
16
- flex-wrap: wrap;
17
-
18
- .tableFilter {
19
- margin-right: 10px;
20
- height: 100%;
21
- }
22
-
23
- .tableSizer {
24
- height: 100%;
25
- }
26
- .switch {
27
- display: flex;
28
- align-items: center;
29
- margin-right: 10px;
30
- }
31
- .copyMarkdownBtn {
32
- margin-right: 10px;
33
- padding: 4px 8px;
34
- cursor: pointer;
35
- border: 1px solid var(--yasgui-border-color, #ddd);
36
- background-color: var(--yasgui-bg-secondary, #f7f7f7);
37
- color: var(--yasgui-text-primary, #000);
38
- border-radius: 3px;
39
- font-size: 0.9em;
40
- white-space: nowrap;
41
-
42
- &:hover {
43
- background-color: var(--yasgui-bg-tertiary, #eee);
44
- }
45
-
46
- &:active {
47
- background-color: var(--yasgui-bg-primary, #fff);
48
- }
49
- }
50
- }
51
- .dataTable.compactTable {
52
- white-space: nowrap;
53
- div:not(.expanded) {
54
- overflow: hidden;
55
- text-overflow: ellipsis;
56
- }
57
- }
58
- .dataTable:not(.compactTable) {
59
- div:not(.expanded) {
60
- word-break: break-all;
61
- }
62
- }
63
- .expanded {
64
- white-space: normal;
65
- word-break: break-all;
66
- }
67
- .expandable:not(.expanded) {
68
- cursor: pointer;
69
- a {
70
- pointer-events: none;
71
- }
72
- }
73
-
74
- .dt-container {
75
- font-size: 0.9em;
76
- min-width: 100%;
77
- .grip-container {
78
- max-width: 100%;
79
- }
80
- .grip-padding > tbody > tr > td,
81
- .grip-padding > tbody > tr > th {
82
- padding-left: 7px !important;
83
- padding-right: 5px !important;
84
- }
85
- .dataTable {
86
- min-width: 100%;
87
- box-sizing: border-box;
88
- // Override border-bottom datatables styling
89
- &.no-footer {
90
- border-bottom: none;
91
- }
92
-
93
- tbody tr:hover {
94
- background-color: var(--yasgui-bg-tertiary, #f9f9f9);
95
- }
96
-
97
- thead tr th {
98
- //cannot select text anyway (as headers are buttons as well)
99
- //By setting it to none explicitly, we won't have issues when resizing columns _and_ selecting text at the meantime
100
- user-select: none;
101
- font-weight: bold;
102
- text-align: start;
103
- overflow: hidden;
104
- text-overflow: ellipsis;
105
- border: none;
106
- padding: 5px;
107
- padding-left: 7px;
108
- min-width: 28px;
109
- &.sorting {
110
- min-width: 10px;
111
- padding-right: 18px; //space for sort icon
112
- }
113
- &:hover {
114
- background-color: var(--yasgui-tab-bg, #f9f9f9);
115
- }
116
- }
117
-
118
- td {
119
- padding: 5px;
120
- & > div {
121
- hyphens: auto;
122
- &.rowNumber {
123
- word-break: keep-all;
124
- overflow: visible;
125
- }
126
- }
127
- .tableEllipse {
128
- cursor: pointer;
129
- font-weight: bold;
130
- padding: 0 2px;
131
- background-color: #428bca33;
132
- border-radius: 2px;
133
- margin: 0 3px;
134
- }
135
- }
136
- }
137
-
138
- /**
139
- Selector for pagination element
140
- */
141
- div.dt-paging {
142
- button.dt-paging-button {
143
- border: none;
144
- background: transparent;
145
- color: var(--yasgui-text-secondary, #505050);
146
-
147
- // When the buttons are disabled show the default YASR disabled color
148
- &.disabled {
149
- color: var(--yasgui-text-muted, #999) !important;
150
- }
151
-
152
- &.current {
153
- text-decoration: underline !important; // dataTables made the text-decoration important
154
- color: var(--yasgui-accent-color, #337ab7);
155
- }
156
-
157
- &:hover {
158
- // Don't override the disabled grayed out style
159
- &:not(.disabled) {
160
- font-weight: bold;
161
- color: var(--yasgui-text-secondary, #505050) !important;
162
- }
163
- }
164
- }
165
- }
166
- }
167
- }