@quandis/qbo4.ui 4.0.1-CI-20250107-234433 → 4.0.1-CI-20250108-223026
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 +3 -3
- package/scss/qboui.scss +33 -12
- package/src/qbo/Program.d.ts +3 -0
- package/src/qbo/Program.js +3 -0
- package/src/qbo/Program.ts +3 -0
- package/src/qbo/qbo-search.d.ts +18 -0
- package/src/qbo/qbo-search.js +199 -0
- package/src/qbo/qbo-search.ts +192 -0
- package/src/qbo/qbo-table-sort.d.ts +14 -0
- package/src/qbo/qbo-table-sort.js +102 -0
- package/src/qbo/qbo-table-sort.ts +96 -0
- package/src/qbo/qbo-tabs.d.ts +1 -0
- package/src/qbo/qbo-tabs.js +84 -0
- package/src/qbo/qbo-tabs.ts +85 -0
- package/src/qbo/styles.js +1 -1
- package/src/qbo/styles.ts +1 -1
- package/wwwroot/css/qbo-form.css +3 -0
- package/wwwroot/css/qbo-form.css.map +1 -1
- package/wwwroot/css/qbo-form.min.css +1 -1
- package/wwwroot/css/qboui.css +33 -12
- package/wwwroot/css/qboui.css.map +1 -1
- package/wwwroot/css/qboui.min.css +1 -1
- package/wwwroot/js/esm/qbo4.ui-code.js +30 -1
- package/wwwroot/js/esm/qbo4.ui-code.min.js.map +1 -1
- package/wwwroot/js/esm/qbo4.ui.js +466 -24
- package/wwwroot/js/esm/qbo4.ui.min.js +138 -21
- package/wwwroot/js/esm/qbo4.ui.min.js.map +1 -1
- package/wwwroot/js/qbo4.ui-code.js +30 -1
- package/wwwroot/js/qbo4.ui-code.min.js.map +1 -1
- package/wwwroot/js/qbo4.ui.js +466 -23
- package/wwwroot/js/qbo4.ui.min.js +135 -18
- package/wwwroot/js/qbo4.ui.min.js.map +1 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Quandis, Inc.",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "4.0.1-CI-
|
|
6
|
+
"version": "4.0.1-CI-20250108-223026",
|
|
7
7
|
"workspaces": [
|
|
8
8
|
"code"
|
|
9
9
|
],
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"src/"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@codemirror/commands": "^6.
|
|
30
|
+
"@codemirror/commands": "^6.8.0",
|
|
31
31
|
"@codemirror/lang-html": "^6.4.9",
|
|
32
32
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
33
33
|
"@codemirror/lang-sql": "^6.8.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"postcss": "^8.4.49",
|
|
56
56
|
"postcss-loader": "^8.1.1",
|
|
57
57
|
"sass": "^1.83.1",
|
|
58
|
-
"typescript": "^5.7.
|
|
58
|
+
"typescript": "^5.7.3",
|
|
59
59
|
"webpack": "^5.97.1",
|
|
60
60
|
"webpack-cli": "^6.0.1",
|
|
61
61
|
"webpack-merge": "^6.0.1"
|
package/scss/qboui.scss
CHANGED
|
@@ -1451,34 +1451,38 @@ details {
|
|
|
1451
1451
|
}
|
|
1452
1452
|
|
|
1453
1453
|
.qbo-tabs {
|
|
1454
|
+
border-bottom: 1px solid var(--qbo-border-color);
|
|
1454
1455
|
display: flex;
|
|
1455
1456
|
list-style: none;
|
|
1457
|
+
margin-block-start: 0.375em;
|
|
1458
|
+
margin-bottom: 0.5em;
|
|
1456
1459
|
padding-left: 0;
|
|
1457
|
-
margin-bottom: 1px;
|
|
1458
|
-
border-bottom: 1px solid var(--qbo-border-color);
|
|
1459
1460
|
}
|
|
1460
1461
|
|
|
1461
1462
|
.qbo-tabs li {
|
|
1462
|
-
margin-bottom: -1px;
|
|
1463
|
-
padding: 0.5rem 1rem;
|
|
1464
1463
|
border: 1px solid transparent;
|
|
1465
1464
|
border-top-left-radius: var(--qbo-border-radius);
|
|
1466
1465
|
border-top-right-radius: var(--qbo-border-radius);
|
|
1467
|
-
color:
|
|
1468
|
-
text-decoration: none;
|
|
1466
|
+
color: var(--qbo-h3-card-color);
|
|
1469
1467
|
cursor: pointer;
|
|
1468
|
+
font-size: 1.25rem;
|
|
1469
|
+
font-weight: 500;
|
|
1470
|
+
margin-bottom: -1px;
|
|
1471
|
+
max-width: var(--qbo-tab-max-width);
|
|
1472
|
+
overflow: hidden;
|
|
1473
|
+
padding: 0.5rem 1rem;
|
|
1474
|
+
text-decoration: none;
|
|
1475
|
+
text-overflow: ellipsis;
|
|
1476
|
+
white-space: nowrap;
|
|
1470
1477
|
}
|
|
1471
1478
|
|
|
1472
1479
|
.qbo-tabs li:hover {
|
|
1473
|
-
border-color: #
|
|
1474
|
-
color: #
|
|
1475
|
-
text-decoration: none;
|
|
1480
|
+
border-color: #81181d #81181d #fff;
|
|
1481
|
+
color: #81181d;
|
|
1476
1482
|
}
|
|
1477
1483
|
|
|
1478
1484
|
.qbo-tabs li.active {
|
|
1479
|
-
color:
|
|
1480
|
-
background-color: var(--qbo-table-header-background);
|
|
1481
|
-
border-color: #dee2e6 #dee2e6 #fff;
|
|
1485
|
+
border-color: #999 #999 #fff;
|
|
1482
1486
|
}
|
|
1483
1487
|
|
|
1484
1488
|
.qbo-tabs li:not(:last-child) {
|
|
@@ -1560,3 +1564,20 @@ span.yellow {
|
|
|
1560
1564
|
.progress-bar.qbo-queued {
|
|
1561
1565
|
display: none;
|
|
1562
1566
|
}
|
|
1567
|
+
|
|
1568
|
+
.qbo-module-viewer {
|
|
1569
|
+
height: 100%;
|
|
1570
|
+
box-shadow: initial;
|
|
1571
|
+
padding: 0.375rem 0.75rem 0.375rem 0.75rem;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
.qbo-module-viewer h2 {
|
|
1575
|
+
color: #595959;
|
|
1576
|
+
font-weight: normal;
|
|
1577
|
+
margin-bottom: 0.25em;
|
|
1578
|
+
margin-top: 0;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
.qbo-module-viewer h2 .btn-close {
|
|
1582
|
+
float: right;
|
|
1583
|
+
}
|
package/src/qbo/Program.d.ts
CHANGED
|
@@ -33,9 +33,12 @@ export * from './qbo-popover.js';
|
|
|
33
33
|
export * from './qbo-popup.js';
|
|
34
34
|
export * from './qbo-popup-listener.js';
|
|
35
35
|
export * from './qbo-resize.js';
|
|
36
|
+
export * from './qbo-search.js';
|
|
36
37
|
export * from './qbo-select.js';
|
|
37
38
|
export * from './qbo-selectable.js';
|
|
38
39
|
export * from './qbo-table.js';
|
|
40
|
+
export * from './qbo-table-sort.js';
|
|
41
|
+
export * from './qbo-tabs.js';
|
|
39
42
|
export * from './qbo-user-preferences.js';
|
|
40
43
|
export * from './qbo-validate.js';
|
|
41
44
|
export * from './styles.js';
|
package/src/qbo/Program.js
CHANGED
|
@@ -22,9 +22,12 @@ export * from './qbo-popover.js';
|
|
|
22
22
|
export * from './qbo-popup.js';
|
|
23
23
|
export * from './qbo-popup-listener.js';
|
|
24
24
|
export * from './qbo-resize.js';
|
|
25
|
+
export * from './qbo-search.js';
|
|
25
26
|
export * from './qbo-select.js';
|
|
26
27
|
export * from './qbo-selectable.js';
|
|
27
28
|
export * from './qbo-table.js';
|
|
29
|
+
export * from './qbo-table-sort.js';
|
|
30
|
+
export * from './qbo-tabs.js';
|
|
28
31
|
export * from './qbo-user-preferences.js';
|
|
29
32
|
export * from './qbo-validate.js';
|
|
30
33
|
export * from './styles.js';
|
package/src/qbo/Program.ts
CHANGED
|
@@ -39,9 +39,12 @@ export * from './qbo-popover.js'
|
|
|
39
39
|
export * from './qbo-popup.js';
|
|
40
40
|
export * from './qbo-popup-listener.js';
|
|
41
41
|
export * from './qbo-resize.js';
|
|
42
|
+
export * from './qbo-search.js';
|
|
42
43
|
export * from './qbo-select.js';
|
|
43
44
|
export * from './qbo-selectable.js';
|
|
44
45
|
export * from './qbo-table.js';
|
|
46
|
+
export * from './qbo-table-sort.js';
|
|
47
|
+
export * from './qbo-tabs.js';
|
|
45
48
|
export * from './qbo-user-preferences.js';
|
|
46
49
|
export * from './qbo-validate.js';
|
|
47
50
|
export * from './styles.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class QboSearch extends LitElement {
|
|
3
|
+
payload: Record<string, string>;
|
|
4
|
+
private expanded;
|
|
5
|
+
private inputText;
|
|
6
|
+
private jsonListContainer;
|
|
7
|
+
private inputContainer;
|
|
8
|
+
static styles: import("lit").CSSResult;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
firstUpdated(): void;
|
|
11
|
+
updated(): void;
|
|
12
|
+
private updateFloatingPosition;
|
|
13
|
+
private handleKeyDown;
|
|
14
|
+
private handleSearchClick;
|
|
15
|
+
private updateKey;
|
|
16
|
+
private updateValue;
|
|
17
|
+
private deleteKeyValuePair;
|
|
18
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { LitElement, html, css } from 'lit';
|
|
11
|
+
import { customElement, state, property } from 'lit/decorators.js';
|
|
12
|
+
import { computePosition, autoUpdate } from '@floating-ui/dom';
|
|
13
|
+
let QboSearch = class QboSearch extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.payload = {};
|
|
17
|
+
this.expanded = false;
|
|
18
|
+
this.inputText = '';
|
|
19
|
+
this.jsonListContainer = null;
|
|
20
|
+
this.inputContainer = null;
|
|
21
|
+
}
|
|
22
|
+
static { this.styles = css `
|
|
23
|
+
:host {
|
|
24
|
+
display: inline-block;
|
|
25
|
+
font-family: var(--qbo-font);
|
|
26
|
+
margin-left: auto;
|
|
27
|
+
vertical-align: top;
|
|
28
|
+
float: right;
|
|
29
|
+
position: relative;
|
|
30
|
+
}
|
|
31
|
+
input {
|
|
32
|
+
border: 1px solid var(--qbo-border-color);
|
|
33
|
+
border-radius: var(--qbo-border-radius);
|
|
34
|
+
font-size: 0.9em;
|
|
35
|
+
line-height: var(--qbo-line-height);
|
|
36
|
+
}
|
|
37
|
+
.collapsed {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
width: fit-content;
|
|
41
|
+
padding: 0.2em 0.5em;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
}
|
|
44
|
+
.collapsed input {
|
|
45
|
+
width: 5rem;
|
|
46
|
+
transition: width 0.3s ease;
|
|
47
|
+
}
|
|
48
|
+
.collapsed input:focus {
|
|
49
|
+
width: 15rem;
|
|
50
|
+
}
|
|
51
|
+
.input-container {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
width: fit-content;
|
|
55
|
+
border: 1px solid #ccc;
|
|
56
|
+
padding: 0.2em 0.5em;
|
|
57
|
+
position: relative;
|
|
58
|
+
}
|
|
59
|
+
.json-list {
|
|
60
|
+
position: absolute;
|
|
61
|
+
top: 100%;
|
|
62
|
+
right: 0;
|
|
63
|
+
background: white;
|
|
64
|
+
border: 1px solid #ccc;
|
|
65
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
|
66
|
+
padding: 0.5em;
|
|
67
|
+
z-index: 10000;
|
|
68
|
+
}
|
|
69
|
+
.json-item {
|
|
70
|
+
display: flex;
|
|
71
|
+
gap: 5px;
|
|
72
|
+
margin-bottom: 0.3em;
|
|
73
|
+
}
|
|
74
|
+
.json-item input {
|
|
75
|
+
flex: 1;
|
|
76
|
+
padding: 0.3em;
|
|
77
|
+
}
|
|
78
|
+
button {
|
|
79
|
+
padding: 0.3em;
|
|
80
|
+
font-size: 0.9em;
|
|
81
|
+
}
|
|
82
|
+
.search-icon {
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
margin-left: 0.5em;
|
|
85
|
+
}
|
|
86
|
+
svg {
|
|
87
|
+
height: 1rem;
|
|
88
|
+
width: 1rem;
|
|
89
|
+
}
|
|
90
|
+
`; }
|
|
91
|
+
render() {
|
|
92
|
+
return html `
|
|
93
|
+
${!this.expanded
|
|
94
|
+
? html `
|
|
95
|
+
<div class="collapsed" @click=${() => (this.expanded = true)}>
|
|
96
|
+
<svg class="qbo-icon" @click=${() => (this.expanded = true)}><use href="/ui/images/qbo-icons.svg#search"></use></svg>
|
|
97
|
+
</div>
|
|
98
|
+
`
|
|
99
|
+
: html `
|
|
100
|
+
<div class="input-container">
|
|
101
|
+
<input
|
|
102
|
+
type="text"
|
|
103
|
+
placeholder="Enter key:value"
|
|
104
|
+
.value=${this.inputText}
|
|
105
|
+
@input=${(e) => (this.inputText = e.target.value)}
|
|
106
|
+
@keydown=${this.handleKeyDown}
|
|
107
|
+
@blur=${() => (this.expanded = false)}
|
|
108
|
+
/>
|
|
109
|
+
<svg class="qbo-icon" @click=${this.handleSearchClick}><use href="/ui/images/qbo-icons.svg#search"></use></svg>
|
|
110
|
+
</div>
|
|
111
|
+
<div class="json-list" id="json-list">
|
|
112
|
+
${Object.entries(this.payload).map(([key, value]) => html `
|
|
113
|
+
<div class="json-item">
|
|
114
|
+
<input
|
|
115
|
+
type="text"
|
|
116
|
+
.value=${key}
|
|
117
|
+
@input=${(e) => this.updateKey(e, key)}
|
|
118
|
+
/>
|
|
119
|
+
<input
|
|
120
|
+
type="text"
|
|
121
|
+
.value=${value}
|
|
122
|
+
@input=${(e) => this.updateValue(e, key)}
|
|
123
|
+
/>
|
|
124
|
+
<button @click=${() => this.deleteKeyValuePair(key)}>Delete</button>
|
|
125
|
+
</div>
|
|
126
|
+
`)}
|
|
127
|
+
</div>
|
|
128
|
+
`}
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
firstUpdated() {
|
|
132
|
+
this.updateFloatingPosition();
|
|
133
|
+
}
|
|
134
|
+
updated() {
|
|
135
|
+
this.updateFloatingPosition();
|
|
136
|
+
}
|
|
137
|
+
async updateFloatingPosition() {
|
|
138
|
+
if (this.inputContainer && this.jsonListContainer) {
|
|
139
|
+
autoUpdate(this.inputContainer, this.jsonListContainer, async () => {
|
|
140
|
+
const { x, y } = await computePosition(this.inputContainer, this.jsonListContainer, {
|
|
141
|
+
middleware: [],
|
|
142
|
+
});
|
|
143
|
+
Object.assign(this.jsonListContainer.style, {
|
|
144
|
+
left: `${x}px`,
|
|
145
|
+
top: `${y}px`,
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
handleKeyDown(e) {
|
|
151
|
+
if (e.key === 'Enter' && this.inputText.includes(':')) {
|
|
152
|
+
const [key, value] = this.inputText.split(':').map(part => part.trim());
|
|
153
|
+
if (key && value) {
|
|
154
|
+
this.payload = { ...this.payload, [key]: value };
|
|
155
|
+
this.inputText = '';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
handleSearchClick() {
|
|
160
|
+
this.expanded = false;
|
|
161
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
162
|
+
detail: { payload: this.payload },
|
|
163
|
+
bubbles: true,
|
|
164
|
+
composed: true,
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
updateKey(e, oldKey) {
|
|
168
|
+
const newKey = e.target.value;
|
|
169
|
+
if (newKey && newKey !== oldKey) {
|
|
170
|
+
const { [oldKey]: _, ...rest } = this.payload;
|
|
171
|
+
this.payload = { ...rest, [newKey]: this.payload[oldKey] };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
updateValue(e, key) {
|
|
175
|
+
this.payload = { ...this.payload, [key]: e.target.value };
|
|
176
|
+
}
|
|
177
|
+
deleteKeyValuePair(key) {
|
|
178
|
+
const { [key]: _, ...rest } = this.payload;
|
|
179
|
+
this.payload = { ...rest };
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
__decorate([
|
|
183
|
+
property({ type: Object }),
|
|
184
|
+
__metadata("design:type", Object)
|
|
185
|
+
], QboSearch.prototype, "payload", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
state(),
|
|
188
|
+
__metadata("design:type", Object)
|
|
189
|
+
], QboSearch.prototype, "expanded", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
state(),
|
|
192
|
+
__metadata("design:type", Object)
|
|
193
|
+
], QboSearch.prototype, "inputText", void 0);
|
|
194
|
+
QboSearch = __decorate([
|
|
195
|
+
customElement('qbo-search')
|
|
196
|
+
], QboSearch);
|
|
197
|
+
export { QboSearch };
|
|
198
|
+
if (!customElements.get('qbo-search'))
|
|
199
|
+
customElements.define('qbo-search', QboSearch);
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { customElement, state, property } from 'lit/decorators.js';
|
|
3
|
+
import { computePosition, autoUpdate } from '@floating-ui/dom';
|
|
4
|
+
|
|
5
|
+
@customElement('qbo-search')
|
|
6
|
+
export class QboSearch extends LitElement {
|
|
7
|
+
@property({ type: Object })
|
|
8
|
+
payload: Record<string, string> = {};
|
|
9
|
+
|
|
10
|
+
@state()
|
|
11
|
+
private expanded = false;
|
|
12
|
+
|
|
13
|
+
@state()
|
|
14
|
+
private inputText = '';
|
|
15
|
+
|
|
16
|
+
private jsonListContainer: HTMLElement | null = null;
|
|
17
|
+
private inputContainer: HTMLElement | null = null;
|
|
18
|
+
|
|
19
|
+
static styles = css`
|
|
20
|
+
:host {
|
|
21
|
+
display: inline-block;
|
|
22
|
+
font-family: var(--qbo-font);
|
|
23
|
+
margin-left: auto;
|
|
24
|
+
vertical-align: top;
|
|
25
|
+
float: right;
|
|
26
|
+
position: relative;
|
|
27
|
+
}
|
|
28
|
+
input {
|
|
29
|
+
border: 1px solid var(--qbo-border-color);
|
|
30
|
+
border-radius: var(--qbo-border-radius);
|
|
31
|
+
font-size: 0.9em;
|
|
32
|
+
line-height: var(--qbo-line-height);
|
|
33
|
+
}
|
|
34
|
+
.collapsed {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
width: fit-content;
|
|
38
|
+
padding: 0.2em 0.5em;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
.collapsed input {
|
|
42
|
+
width: 5rem;
|
|
43
|
+
transition: width 0.3s ease;
|
|
44
|
+
}
|
|
45
|
+
.collapsed input:focus {
|
|
46
|
+
width: 15rem;
|
|
47
|
+
}
|
|
48
|
+
.input-container {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
width: fit-content;
|
|
52
|
+
border: 1px solid #ccc;
|
|
53
|
+
padding: 0.2em 0.5em;
|
|
54
|
+
position: relative;
|
|
55
|
+
}
|
|
56
|
+
.json-list {
|
|
57
|
+
position: absolute;
|
|
58
|
+
top: 100%;
|
|
59
|
+
right: 0;
|
|
60
|
+
background: white;
|
|
61
|
+
border: 1px solid #ccc;
|
|
62
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
|
63
|
+
padding: 0.5em;
|
|
64
|
+
z-index: 10000;
|
|
65
|
+
}
|
|
66
|
+
.json-item {
|
|
67
|
+
display: flex;
|
|
68
|
+
gap: 5px;
|
|
69
|
+
margin-bottom: 0.3em;
|
|
70
|
+
}
|
|
71
|
+
.json-item input {
|
|
72
|
+
flex: 1;
|
|
73
|
+
padding: 0.3em;
|
|
74
|
+
}
|
|
75
|
+
button {
|
|
76
|
+
padding: 0.3em;
|
|
77
|
+
font-size: 0.9em;
|
|
78
|
+
}
|
|
79
|
+
.search-icon {
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
margin-left: 0.5em;
|
|
82
|
+
}
|
|
83
|
+
svg {
|
|
84
|
+
height: 1rem;
|
|
85
|
+
width: 1rem;
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
render() {
|
|
90
|
+
return html`
|
|
91
|
+
${!this.expanded
|
|
92
|
+
? html`
|
|
93
|
+
<div class="collapsed" @click=${() => (this.expanded = true)}>
|
|
94
|
+
<svg class="qbo-icon" @click=${() => (this.expanded = true)}><use href="/ui/images/qbo-icons.svg#search"></use></svg>
|
|
95
|
+
</div>
|
|
96
|
+
`
|
|
97
|
+
: html`
|
|
98
|
+
<div class="input-container">
|
|
99
|
+
<input
|
|
100
|
+
type="text"
|
|
101
|
+
placeholder="Enter key:value"
|
|
102
|
+
.value=${this.inputText}
|
|
103
|
+
@input=${(e: Event) => (this.inputText = (e.target as HTMLInputElement).value)}
|
|
104
|
+
@keydown=${this.handleKeyDown}
|
|
105
|
+
@blur=${() => (this.expanded = false)}
|
|
106
|
+
/>
|
|
107
|
+
<svg class="qbo-icon" @click=${this.handleSearchClick}><use href="/ui/images/qbo-icons.svg#search"></use></svg>
|
|
108
|
+
</div>
|
|
109
|
+
<div class="json-list" id="json-list">
|
|
110
|
+
${Object.entries(this.payload).map(
|
|
111
|
+
([key, value]) => html`
|
|
112
|
+
<div class="json-item">
|
|
113
|
+
<input
|
|
114
|
+
type="text"
|
|
115
|
+
.value=${key}
|
|
116
|
+
@input=${(e: Event) => this.updateKey(e, key)}
|
|
117
|
+
/>
|
|
118
|
+
<input
|
|
119
|
+
type="text"
|
|
120
|
+
.value=${value}
|
|
121
|
+
@input=${(e: Event) => this.updateValue(e, key)}
|
|
122
|
+
/>
|
|
123
|
+
<button @click=${() => this.deleteKeyValuePair(key)}>Delete</button>
|
|
124
|
+
</div>
|
|
125
|
+
`
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
`}
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
firstUpdated() {
|
|
133
|
+
this.updateFloatingPosition();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
updated() {
|
|
137
|
+
this.updateFloatingPosition();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private async updateFloatingPosition() {
|
|
141
|
+
if (this.inputContainer && this.jsonListContainer) {
|
|
142
|
+
autoUpdate(this.inputContainer, this.jsonListContainer, async () => {
|
|
143
|
+
const { x, y } = await computePosition(this.inputContainer!, this.jsonListContainer!, {
|
|
144
|
+
middleware: [],
|
|
145
|
+
});
|
|
146
|
+
Object.assign(this.jsonListContainer!.style, {
|
|
147
|
+
left: `${x}px`,
|
|
148
|
+
top: `${y}px`,
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private handleKeyDown(e: KeyboardEvent) {
|
|
155
|
+
if (e.key === 'Enter' && this.inputText.includes(':')) {
|
|
156
|
+
const [key, value] = this.inputText.split(':').map(part => part.trim());
|
|
157
|
+
if (key && value) {
|
|
158
|
+
this.payload = { ...this.payload, [key]: value };
|
|
159
|
+
this.inputText = '';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private handleSearchClick() {
|
|
165
|
+
this.expanded = false;
|
|
166
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
167
|
+
detail: { payload: this.payload },
|
|
168
|
+
bubbles: true,
|
|
169
|
+
composed: true,
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private updateKey(e: Event, oldKey: string) {
|
|
174
|
+
const newKey = (e.target as HTMLInputElement).value;
|
|
175
|
+
if (newKey && newKey !== oldKey) {
|
|
176
|
+
const { [oldKey]: _, ...rest } = this.payload;
|
|
177
|
+
this.payload = { ...rest, [newKey]: this.payload[oldKey] };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private updateValue(e: Event, key: string) {
|
|
182
|
+
this.payload = { ...this.payload, [key]: (e.target as HTMLInputElement).value };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private deleteKeyValuePair(key: string) {
|
|
186
|
+
const { [key]: _, ...rest } = this.payload;
|
|
187
|
+
this.payload = { ...rest };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (!customElements.get('qbo-search'))
|
|
192
|
+
customElements.define('qbo-search', QboSearch);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class QboTableSort extends LitElement {
|
|
3
|
+
direction: 'asc' | 'desc';
|
|
4
|
+
selector: string;
|
|
5
|
+
sortBy: string | null;
|
|
6
|
+
trigger: 'ctrl' | null;
|
|
7
|
+
type: 'inline' | 'remote' | 'all';
|
|
8
|
+
table: HTMLTableElement | null;
|
|
9
|
+
firstUpdated(): void;
|
|
10
|
+
disconnectedCallback(): void;
|
|
11
|
+
sortInline(column: HTMLTableCellElement): void;
|
|
12
|
+
sortTable(event: MouseEvent): void;
|
|
13
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { LitElement, html } from 'lit';
|
|
11
|
+
import { property, state } from 'lit/decorators.js';
|
|
12
|
+
export class QboTableSort extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.direction = 'desc';
|
|
16
|
+
this.selector = 'table';
|
|
17
|
+
this.sortBy = null;
|
|
18
|
+
/* Trigger for raising the sort event. */
|
|
19
|
+
this.trigger = null;
|
|
20
|
+
this.type = 'inline';
|
|
21
|
+
this.table = null;
|
|
22
|
+
}
|
|
23
|
+
firstUpdated() {
|
|
24
|
+
this.table = this.closest('table');
|
|
25
|
+
if (this.table == null)
|
|
26
|
+
return;
|
|
27
|
+
this.table.addEventListener('click', this.sortTable.bind(this));
|
|
28
|
+
}
|
|
29
|
+
disconnectedCallback() {
|
|
30
|
+
this.table?.removeEventListener('click', this.sortTable.bind(this));
|
|
31
|
+
}
|
|
32
|
+
sortInline(column) {
|
|
33
|
+
const rows = Array.from(this.table.querySelector('tbody').querySelectorAll('tr'));
|
|
34
|
+
const sortType = column.getAttribute('data-sort') || 'string';
|
|
35
|
+
rows.sort((rowA, rowB) => {
|
|
36
|
+
const cellA = rowA.cells[column.cellIndex].getAttribute('data-sort-value')
|
|
37
|
+
?? rowA.cells[column.cellIndex].textContent.trim();
|
|
38
|
+
const cellB = rowB.cells[column.cellIndex].getAttribute('data-sort-value')
|
|
39
|
+
?? rowB.cells[column.cellIndex].textContent.trim();
|
|
40
|
+
switch (sortType) {
|
|
41
|
+
case 'numeric':
|
|
42
|
+
return this.direction === 'asc' ? Number(cellA) - Number(cellB) : Number(cellB) - Number(cellA);
|
|
43
|
+
case 'date':
|
|
44
|
+
return this.direction === 'asc'
|
|
45
|
+
? new Date(cellA).getTime() - new Date(cellB).getTime()
|
|
46
|
+
: new Date(cellB).getTime() - new Date(cellA).getTime();
|
|
47
|
+
case 'string':
|
|
48
|
+
default:
|
|
49
|
+
return this.direction === 'asc'
|
|
50
|
+
? cellA.localeCompare(cellB)
|
|
51
|
+
: cellB.localeCompare(cellA);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
rows.forEach(row => this.table.querySelector('tbody').appendChild(row));
|
|
55
|
+
const headers = this.table.querySelectorAll('th[data-sort]');
|
|
56
|
+
headers.forEach(th => th.classList.remove('sorted-asc', 'sorted-desc'));
|
|
57
|
+
column.classList.add(this.direction === 'asc' ? 'sorted-asc' : 'sorted-desc');
|
|
58
|
+
}
|
|
59
|
+
sortTable(event) {
|
|
60
|
+
const target = event.target;
|
|
61
|
+
const column = target?.closest('th');
|
|
62
|
+
if (column == null || column.getAttribute('data-sort') == null)
|
|
63
|
+
return;
|
|
64
|
+
this.direction = this.direction === 'asc' ? 'desc' : 'asc';
|
|
65
|
+
this.sortBy = column.getAttribute('data-sort') || column.innerText;
|
|
66
|
+
let sortType = 'string';
|
|
67
|
+
if (this.sortBy != null && this.sortBy.indexOf('|')) {
|
|
68
|
+
}
|
|
69
|
+
if (this.type !== 'remote')
|
|
70
|
+
this.sortInline(column);
|
|
71
|
+
this.dispatchEvent(new CustomEvent('sort', {
|
|
72
|
+
detail: { sortBy: this.sortBy, direction: this.direction, source: event },
|
|
73
|
+
bubbles: true,
|
|
74
|
+
composed: true,
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
return html ``; // The component itself doesn't render anything
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
__decorate([
|
|
82
|
+
property(),
|
|
83
|
+
__metadata("design:type", String)
|
|
84
|
+
], QboTableSort.prototype, "direction", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
property(),
|
|
87
|
+
__metadata("design:type", String)
|
|
88
|
+
], QboTableSort.prototype, "selector", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
state(),
|
|
91
|
+
__metadata("design:type", Object)
|
|
92
|
+
], QboTableSort.prototype, "sortBy", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
property(),
|
|
95
|
+
__metadata("design:type", Object)
|
|
96
|
+
], QboTableSort.prototype, "trigger", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
property(),
|
|
99
|
+
__metadata("design:type", String)
|
|
100
|
+
], QboTableSort.prototype, "type", void 0);
|
|
101
|
+
if (!customElements.get('qbo-table-sort'))
|
|
102
|
+
customElements.define('qbo-table-sort', QboTableSort);
|