@kodaris/krubble-components 1.0.9 → 1.0.10
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/custom-elements.json +727 -57
- package/dist/button/button.d.ts +14 -0
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.js +120 -3
- package/dist/button/button.js.map +1 -1
- package/dist/form/text-field/text-field.js +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/krubble.bundled.js +1311 -56
- package/dist/krubble.bundled.js.map +1 -1
- package/dist/krubble.bundled.min.js +762 -76
- package/dist/krubble.bundled.min.js.map +1 -1
- package/dist/krubble.umd.js +1310 -55
- package/dist/krubble.umd.js.map +1 -1
- package/dist/krubble.umd.min.js +754 -68
- package/dist/krubble.umd.min.js.map +1 -1
- package/dist/table/table.d.ts +253 -0
- package/dist/table/table.d.ts.map +1 -0
- package/dist/table/table.js +1146 -0
- package/dist/table/table.js.map +1 -0
- package/dist/tabs/tabs.d.ts.map +1 -1
- package/dist/tabs/tabs.js +2 -0
- package/dist/tabs/tabs.js.map +1 -1
- package/package.json +5 -1
package/dist/krubble.bundled.js
CHANGED
|
@@ -89,7 +89,7 @@ const e$4=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"obj
|
|
|
89
89
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
90
90
|
*/function e$3(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$4(n,s,{get(){return o(this)}})}}
|
|
91
91
|
|
|
92
|
-
var __decorate$
|
|
92
|
+
var __decorate$c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
93
93
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
94
94
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
95
95
|
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;
|
|
@@ -196,13 +196,13 @@ KRAccordion.styles = i$5 `
|
|
|
196
196
|
padding: 16px 16px 8px 16px;
|
|
197
197
|
}
|
|
198
198
|
`;
|
|
199
|
-
__decorate$
|
|
199
|
+
__decorate$c([
|
|
200
200
|
n$1({ type: String })
|
|
201
201
|
], KRAccordion.prototype, "header", void 0);
|
|
202
|
-
__decorate$
|
|
202
|
+
__decorate$c([
|
|
203
203
|
n$1({ type: Boolean, reflect: true })
|
|
204
204
|
], KRAccordion.prototype, "expanded", void 0);
|
|
205
|
-
KRAccordion = __decorate$
|
|
205
|
+
KRAccordion = __decorate$c([
|
|
206
206
|
t$1('kr-accordion')
|
|
207
207
|
], KRAccordion);
|
|
208
208
|
|
|
@@ -219,7 +219,7 @@ const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4},e$2=t=>(...e)=>({_$
|
|
|
219
219
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
220
220
|
*/const e$1=e$2(class extends i$1{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter(s=>t[s]).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter(t=>""!==t)));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return E}});
|
|
221
221
|
|
|
222
|
-
var __decorate$
|
|
222
|
+
var __decorate$b = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
223
223
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
224
224
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
225
225
|
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;
|
|
@@ -403,23 +403,23 @@ KRAlert.styles = i$5 `
|
|
|
403
403
|
outline-offset: 2px;
|
|
404
404
|
}
|
|
405
405
|
`;
|
|
406
|
-
__decorate$
|
|
406
|
+
__decorate$b([
|
|
407
407
|
n$1({ type: String })
|
|
408
408
|
], KRAlert.prototype, "type", void 0);
|
|
409
|
-
__decorate$
|
|
409
|
+
__decorate$b([
|
|
410
410
|
n$1({ type: String })
|
|
411
411
|
], KRAlert.prototype, "header", void 0);
|
|
412
|
-
__decorate$
|
|
412
|
+
__decorate$b([
|
|
413
413
|
n$1({ type: Boolean })
|
|
414
414
|
], KRAlert.prototype, "dismissible", void 0);
|
|
415
|
-
__decorate$
|
|
415
|
+
__decorate$b([
|
|
416
416
|
n$1({ type: Boolean })
|
|
417
417
|
], KRAlert.prototype, "visible", void 0);
|
|
418
|
-
KRAlert = __decorate$
|
|
418
|
+
KRAlert = __decorate$b([
|
|
419
419
|
t$1('kr-alert')
|
|
420
420
|
], KRAlert);
|
|
421
421
|
|
|
422
|
-
var __decorate$
|
|
422
|
+
var __decorate$a = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
423
423
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
424
424
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
425
425
|
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;
|
|
@@ -430,6 +430,7 @@ var __decorate$9 = (undefined && undefined.__decorate) || function (decorators,
|
|
|
430
430
|
*
|
|
431
431
|
* @slot - The button content
|
|
432
432
|
* @fires click - Fired when the button is clicked
|
|
433
|
+
* @fires option-select - Fired when a dropdown option is selected
|
|
433
434
|
*/
|
|
434
435
|
let KRButton = class KRButton extends i$2 {
|
|
435
436
|
constructor() {
|
|
@@ -450,12 +451,36 @@ let KRButton = class KRButton extends i$2 {
|
|
|
450
451
|
* Whether the button is disabled
|
|
451
452
|
*/
|
|
452
453
|
this.disabled = false;
|
|
454
|
+
/**
|
|
455
|
+
* Dropdown options - when provided, button becomes a dropdown
|
|
456
|
+
*/
|
|
457
|
+
this.options = [];
|
|
453
458
|
this._state = 'idle';
|
|
454
459
|
this._stateText = '';
|
|
460
|
+
this._dropdownOpen = false;
|
|
461
|
+
this._handleHostClick = (e) => {
|
|
462
|
+
if (this.options.length) {
|
|
463
|
+
e.stopPropagation();
|
|
464
|
+
this._toggleDropdown();
|
|
465
|
+
}
|
|
466
|
+
};
|
|
455
467
|
this._handleKeydown = (e) => {
|
|
456
468
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
457
469
|
e.preventDefault();
|
|
458
|
-
this.
|
|
470
|
+
if (this.options.length) {
|
|
471
|
+
this._toggleDropdown();
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
this.click();
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (e.key === 'Escape' && this._dropdownOpen) {
|
|
478
|
+
this._dropdownOpen = false;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
this._handleClickOutside = (e) => {
|
|
482
|
+
if (this._dropdownOpen && !this.contains(e.target)) {
|
|
483
|
+
this._dropdownOpen = false;
|
|
459
484
|
}
|
|
460
485
|
};
|
|
461
486
|
}
|
|
@@ -464,10 +489,26 @@ let KRButton = class KRButton extends i$2 {
|
|
|
464
489
|
this.setAttribute('role', 'button');
|
|
465
490
|
this.setAttribute('tabindex', '0');
|
|
466
491
|
this.addEventListener('keydown', this._handleKeydown);
|
|
492
|
+
this.addEventListener('click', this._handleHostClick);
|
|
493
|
+
document.addEventListener('click', this._handleClickOutside);
|
|
467
494
|
}
|
|
468
495
|
disconnectedCallback() {
|
|
469
496
|
super.disconnectedCallback();
|
|
470
497
|
this.removeEventListener('keydown', this._handleKeydown);
|
|
498
|
+
this.removeEventListener('click', this._handleHostClick);
|
|
499
|
+
document.removeEventListener('click', this._handleClickOutside);
|
|
500
|
+
}
|
|
501
|
+
_toggleDropdown() {
|
|
502
|
+
this._dropdownOpen = !this._dropdownOpen;
|
|
503
|
+
}
|
|
504
|
+
_handleOptionClick(option, e) {
|
|
505
|
+
e.stopPropagation();
|
|
506
|
+
this._dropdownOpen = false;
|
|
507
|
+
this.dispatchEvent(new CustomEvent('option-select', {
|
|
508
|
+
detail: { id: option.id, label: option.label },
|
|
509
|
+
bubbles: true,
|
|
510
|
+
composed: true
|
|
511
|
+
}));
|
|
471
512
|
}
|
|
472
513
|
/**
|
|
473
514
|
* Shows a loading spinner and disables the button.
|
|
@@ -524,15 +565,27 @@ let KRButton = class KRButton extends i$2 {
|
|
|
524
565
|
this.classList.toggle('kr-button--large', this.size === 'large');
|
|
525
566
|
}
|
|
526
567
|
render() {
|
|
568
|
+
const hasOptions = this.options.length > 0;
|
|
527
569
|
return b `
|
|
528
570
|
<slot></slot>
|
|
571
|
+
${hasOptions ? b `<svg class="caret" xmlns="http://www.w3.org/2000/svg" height="20" width="20" viewBox="0 0 24 24" fill="currentColor"><path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"/></svg>` : A}
|
|
529
572
|
${this._state !== 'idle'
|
|
530
573
|
? b `<span class="state-overlay">
|
|
531
574
|
${this._state === 'loading'
|
|
532
575
|
? b `<span class="spinner"></span>`
|
|
533
576
|
: this._stateText}
|
|
534
577
|
</span>`
|
|
535
|
-
:
|
|
578
|
+
: A}
|
|
579
|
+
${hasOptions ? b `
|
|
580
|
+
<div class="dropdown ${this._dropdownOpen ? 'open' : ''}">
|
|
581
|
+
${this.options.map(option => b `
|
|
582
|
+
<button
|
|
583
|
+
class="dropdown-item"
|
|
584
|
+
@click=${(e) => this._handleOptionClick(option, e)}
|
|
585
|
+
>${option.label}</button>
|
|
586
|
+
`)}
|
|
587
|
+
</div>
|
|
588
|
+
` : A}
|
|
536
589
|
`;
|
|
537
590
|
}
|
|
538
591
|
};
|
|
@@ -681,26 +734,90 @@ KRButton.styles = i$5 `
|
|
|
681
734
|
height: 16px;
|
|
682
735
|
border-width: 3px;
|
|
683
736
|
}
|
|
737
|
+
|
|
738
|
+
/* Dropdown */
|
|
739
|
+
.dropdown {
|
|
740
|
+
position: absolute;
|
|
741
|
+
top: 100%;
|
|
742
|
+
left: 0;
|
|
743
|
+
margin-top: 4px;
|
|
744
|
+
min-width: 100%;
|
|
745
|
+
background: white;
|
|
746
|
+
border: 1px solid #9ba7b6;
|
|
747
|
+
border-radius: 8px;
|
|
748
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
|
749
|
+
padding: 8px 0;
|
|
750
|
+
z-index: 100;
|
|
751
|
+
display: none;
|
|
752
|
+
transform-origin: top;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.dropdown.open {
|
|
756
|
+
display: block;
|
|
757
|
+
animation: dropdown-fade-in 150ms ease-out;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
@keyframes dropdown-fade-in {
|
|
761
|
+
from {
|
|
762
|
+
opacity: 0;
|
|
763
|
+
transform: translateY(-4px);
|
|
764
|
+
}
|
|
765
|
+
to {
|
|
766
|
+
opacity: 1;
|
|
767
|
+
transform: translateY(0);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
.dropdown-item {
|
|
772
|
+
display: block;
|
|
773
|
+
width: 100%;
|
|
774
|
+
padding: 8px 16px;
|
|
775
|
+
text-align: left;
|
|
776
|
+
background: none;
|
|
777
|
+
border: none;
|
|
778
|
+
font-size: 14px;
|
|
779
|
+
color: #374151;
|
|
780
|
+
cursor: pointer;
|
|
781
|
+
font-family: inherit;
|
|
782
|
+
white-space: nowrap;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.dropdown-item:hover {
|
|
786
|
+
background: #f3f4f6;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/* Caret for dropdown button */
|
|
790
|
+
.caret {
|
|
791
|
+
margin-left: 4px;
|
|
792
|
+
margin-right: -6px;
|
|
793
|
+
display: flex;
|
|
794
|
+
}
|
|
684
795
|
`;
|
|
685
|
-
__decorate$
|
|
796
|
+
__decorate$a([
|
|
686
797
|
n$1({ type: String, reflect: true })
|
|
687
798
|
], KRButton.prototype, "variant", void 0);
|
|
688
|
-
__decorate$
|
|
799
|
+
__decorate$a([
|
|
689
800
|
n$1({ type: String, reflect: true })
|
|
690
801
|
], KRButton.prototype, "color", void 0);
|
|
691
|
-
__decorate$
|
|
802
|
+
__decorate$a([
|
|
692
803
|
n$1({ type: String, reflect: true })
|
|
693
804
|
], KRButton.prototype, "size", void 0);
|
|
694
|
-
__decorate$
|
|
805
|
+
__decorate$a([
|
|
695
806
|
n$1({ type: Boolean, reflect: true })
|
|
696
807
|
], KRButton.prototype, "disabled", void 0);
|
|
697
|
-
__decorate$
|
|
808
|
+
__decorate$a([
|
|
809
|
+
n$1({ type: Array })
|
|
810
|
+
], KRButton.prototype, "options", void 0);
|
|
811
|
+
__decorate$a([
|
|
698
812
|
r$1()
|
|
699
813
|
], KRButton.prototype, "_state", void 0);
|
|
700
|
-
__decorate$
|
|
814
|
+
__decorate$a([
|
|
701
815
|
r$1()
|
|
702
816
|
], KRButton.prototype, "_stateText", void 0);
|
|
703
|
-
|
|
817
|
+
__decorate$a([
|
|
818
|
+
r$1()
|
|
819
|
+
], KRButton.prototype, "_dropdownOpen", void 0);
|
|
820
|
+
KRButton = __decorate$a([
|
|
704
821
|
t$1('kr-button')
|
|
705
822
|
], KRButton);
|
|
706
823
|
|
|
@@ -710,7 +827,7 @@ KRButton = __decorate$9([
|
|
|
710
827
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
711
828
|
*/class e extends i$1{constructor(i){if(super(i),this.it=A,i.type!==t.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===A||null==r)return this._t=void 0,this.it=r;if(r===E)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName="unsafeHTML",e.resultType=1;const o$2=e$2(e);
|
|
712
829
|
|
|
713
|
-
var __decorate$
|
|
830
|
+
var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
714
831
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
715
832
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
716
833
|
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;
|
|
@@ -967,23 +1084,23 @@ KRCodeDemo.styles = i$5 `
|
|
|
967
1084
|
color: #fab387;
|
|
968
1085
|
}
|
|
969
1086
|
`;
|
|
970
|
-
__decorate$
|
|
1087
|
+
__decorate$9([
|
|
971
1088
|
n$1({ type: String })
|
|
972
1089
|
], KRCodeDemo.prototype, "language", void 0);
|
|
973
|
-
__decorate$
|
|
1090
|
+
__decorate$9([
|
|
974
1091
|
n$1({ type: String })
|
|
975
1092
|
], KRCodeDemo.prototype, "code", void 0);
|
|
976
|
-
__decorate$
|
|
1093
|
+
__decorate$9([
|
|
977
1094
|
r$1()
|
|
978
1095
|
], KRCodeDemo.prototype, "activeTab", void 0);
|
|
979
|
-
__decorate$
|
|
1096
|
+
__decorate$9([
|
|
980
1097
|
r$1()
|
|
981
1098
|
], KRCodeDemo.prototype, "copied", void 0);
|
|
982
|
-
KRCodeDemo = __decorate$
|
|
1099
|
+
KRCodeDemo = __decorate$9([
|
|
983
1100
|
t$1('kr-code-demo')
|
|
984
1101
|
], KRCodeDemo);
|
|
985
1102
|
|
|
986
|
-
var __decorate$
|
|
1103
|
+
var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
987
1104
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
988
1105
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
989
1106
|
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;
|
|
@@ -1152,14 +1269,14 @@ KRContextMenu.styles = i$5 `
|
|
|
1152
1269
|
margin: 4px 0;
|
|
1153
1270
|
}
|
|
1154
1271
|
`;
|
|
1155
|
-
__decorate$
|
|
1272
|
+
__decorate$8([
|
|
1156
1273
|
r$1()
|
|
1157
1274
|
], KRContextMenu.prototype, "items", void 0);
|
|
1158
|
-
KRContextMenu = __decorate$
|
|
1275
|
+
KRContextMenu = __decorate$8([
|
|
1159
1276
|
t$1('kr-context-menu')
|
|
1160
1277
|
], KRContextMenu);
|
|
1161
1278
|
|
|
1162
|
-
var __decorate$
|
|
1279
|
+
var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1163
1280
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1164
1281
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1165
1282
|
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;
|
|
@@ -1291,14 +1408,14 @@ KRDialog.styles = i$5 `
|
|
|
1291
1408
|
overflow: auto;
|
|
1292
1409
|
}
|
|
1293
1410
|
`;
|
|
1294
|
-
__decorate$
|
|
1411
|
+
__decorate$7([
|
|
1295
1412
|
r$1()
|
|
1296
1413
|
], KRDialog.prototype, "contentElement", void 0);
|
|
1297
|
-
KRDialog = __decorate$
|
|
1414
|
+
KRDialog = __decorate$7([
|
|
1298
1415
|
t$1('kr-dialog')
|
|
1299
1416
|
], KRDialog);
|
|
1300
1417
|
|
|
1301
|
-
var __decorate$
|
|
1418
|
+
var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1302
1419
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1303
1420
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1304
1421
|
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;
|
|
@@ -1595,19 +1712,19 @@ KRSnackbar.styles = i$5 `
|
|
|
1595
1712
|
`;
|
|
1596
1713
|
/** Track active snackbars for stacking */
|
|
1597
1714
|
KRSnackbar.activeSnackbars = [];
|
|
1598
|
-
__decorate$
|
|
1715
|
+
__decorate$6([
|
|
1599
1716
|
n$1({ type: String })
|
|
1600
1717
|
], KRSnackbar.prototype, "type", void 0);
|
|
1601
|
-
__decorate$
|
|
1718
|
+
__decorate$6([
|
|
1602
1719
|
n$1({ type: String })
|
|
1603
1720
|
], KRSnackbar.prototype, "title", void 0);
|
|
1604
|
-
__decorate$
|
|
1721
|
+
__decorate$6([
|
|
1605
1722
|
n$1({ type: String })
|
|
1606
1723
|
], KRSnackbar.prototype, "message", void 0);
|
|
1607
|
-
__decorate$
|
|
1724
|
+
__decorate$6([
|
|
1608
1725
|
n$1({ type: Number })
|
|
1609
1726
|
], KRSnackbar.prototype, "duration", void 0);
|
|
1610
|
-
KRSnackbar = KRSnackbar_1 = __decorate$
|
|
1727
|
+
KRSnackbar = KRSnackbar_1 = __decorate$6([
|
|
1611
1728
|
t$1('kr-snackbar')
|
|
1612
1729
|
], KRSnackbar);
|
|
1613
1730
|
|
|
@@ -1617,7 +1734,7 @@ KRSnackbar = KRSnackbar_1 = __decorate$5([
|
|
|
1617
1734
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1618
1735
|
*/const n="important",i=" !"+n,o$1=e$2(class extends i$1{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"style"!==t$1.name||t$1.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce((e,r)=>{const s=t[r];return null==s?e:e+`${r=r.includes("-")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`},"")}update(e,[r]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const t of this.ft)null==r[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in r){const e=r[t];if(null!=e){this.ft.add(t);const r="string"==typeof e&&e.endsWith(i);t.includes("-")||r?s.setProperty(t,r?e.slice(0,-11):e,r?n:""):s[t]=e;}}return E}});
|
|
1619
1736
|
|
|
1620
|
-
var __decorate$
|
|
1737
|
+
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1621
1738
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1622
1739
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1623
1740
|
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;
|
|
@@ -1792,7 +1909,9 @@ KRTabGroup.styles = [
|
|
|
1792
1909
|
}
|
|
1793
1910
|
|
|
1794
1911
|
.header {
|
|
1912
|
+
height: 44px;
|
|
1795
1913
|
display: flex;
|
|
1914
|
+
flex-shrink: 0;
|
|
1796
1915
|
align-items: stretch;
|
|
1797
1916
|
border-bottom: 1px solid #e5e7eb;
|
|
1798
1917
|
overflow-x: auto;
|
|
@@ -1917,20 +2036,20 @@ KRTabGroup.styles = [
|
|
|
1917
2036
|
}
|
|
1918
2037
|
`,
|
|
1919
2038
|
];
|
|
1920
|
-
__decorate$
|
|
2039
|
+
__decorate$5([
|
|
1921
2040
|
n$1({ type: String, attribute: 'active-tab-id' })
|
|
1922
2041
|
], KRTabGroup.prototype, "activeTabId", void 0);
|
|
1923
|
-
__decorate$
|
|
2042
|
+
__decorate$5([
|
|
1924
2043
|
n$1({ type: Boolean })
|
|
1925
2044
|
], KRTabGroup.prototype, "justified", void 0);
|
|
1926
|
-
__decorate$
|
|
2045
|
+
__decorate$5([
|
|
1927
2046
|
n$1({ type: String, reflect: true })
|
|
1928
2047
|
], KRTabGroup.prototype, "size", void 0);
|
|
1929
|
-
KRTabGroup = __decorate$
|
|
2048
|
+
KRTabGroup = __decorate$5([
|
|
1930
2049
|
t$1('kr-tab-group')
|
|
1931
2050
|
], KRTabGroup);
|
|
1932
2051
|
|
|
1933
|
-
var __decorate$
|
|
2052
|
+
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1934
2053
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1935
2054
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1936
2055
|
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;
|
|
@@ -2001,34 +2120,1170 @@ KRTab.styles = [
|
|
|
2001
2120
|
}
|
|
2002
2121
|
`,
|
|
2003
2122
|
];
|
|
2004
|
-
__decorate$
|
|
2123
|
+
__decorate$4([
|
|
2005
2124
|
n$1({ type: String, reflect: true })
|
|
2006
2125
|
], KRTab.prototype, "id", void 0);
|
|
2007
|
-
__decorate$
|
|
2126
|
+
__decorate$4([
|
|
2008
2127
|
n$1({ type: String })
|
|
2009
2128
|
], KRTab.prototype, "title", void 0);
|
|
2010
|
-
__decorate$
|
|
2129
|
+
__decorate$4([
|
|
2011
2130
|
n$1({ type: String })
|
|
2012
2131
|
], KRTab.prototype, "badge", void 0);
|
|
2013
|
-
__decorate$
|
|
2132
|
+
__decorate$4([
|
|
2014
2133
|
n$1({ type: String, attribute: 'badge-background' })
|
|
2015
2134
|
], KRTab.prototype, "badgeBackground", void 0);
|
|
2016
|
-
__decorate$
|
|
2135
|
+
__decorate$4([
|
|
2017
2136
|
n$1({ type: String, attribute: 'badge-color' })
|
|
2018
2137
|
], KRTab.prototype, "badgeColor", void 0);
|
|
2019
|
-
__decorate$
|
|
2138
|
+
__decorate$4([
|
|
2020
2139
|
n$1({ type: Boolean })
|
|
2021
2140
|
], KRTab.prototype, "disabled", void 0);
|
|
2022
|
-
__decorate$
|
|
2141
|
+
__decorate$4([
|
|
2023
2142
|
n$1({ type: Boolean })
|
|
2024
2143
|
], KRTab.prototype, "dismissible", void 0);
|
|
2025
|
-
__decorate$
|
|
2144
|
+
__decorate$4([
|
|
2026
2145
|
n$1({ type: Boolean, reflect: true })
|
|
2027
2146
|
], KRTab.prototype, "active", void 0);
|
|
2028
|
-
KRTab = __decorate$
|
|
2147
|
+
KRTab = __decorate$4([
|
|
2029
2148
|
t$1('kr-tab')
|
|
2030
2149
|
], KRTab);
|
|
2031
2150
|
|
|
2151
|
+
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2152
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2153
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2154
|
+
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;
|
|
2155
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2156
|
+
};
|
|
2157
|
+
// === Solr Utilities ===
|
|
2158
|
+
const SOLR_RESERVED_CHARS = [
|
|
2159
|
+
'"', '+', '-', '&&', '||', '!', '(', ')', '{',
|
|
2160
|
+
'}', '[', ']', '^', '~', '*', '?', ':'
|
|
2161
|
+
];
|
|
2162
|
+
const SOLR_RESERVED_CHARS_REPLACEMENT = [
|
|
2163
|
+
'\\"', '\\+', '\\-', '\\&\\&', '\\|\\|', '\\!', '\\(', '\\)', '\\{',
|
|
2164
|
+
'\\}', '\\[', '\\]', '\\^', '\\~', '\\*', '\\?', '\\:'
|
|
2165
|
+
];
|
|
2166
|
+
function escapeSolrQuery(query) {
|
|
2167
|
+
let escaped = query;
|
|
2168
|
+
for (let i = 0; i < SOLR_RESERVED_CHARS.length; i++) {
|
|
2169
|
+
escaped = escaped.split(SOLR_RESERVED_CHARS[i]).join(SOLR_RESERVED_CHARS_REPLACEMENT[i]);
|
|
2170
|
+
}
|
|
2171
|
+
return escaped;
|
|
2172
|
+
}
|
|
2173
|
+
let KRTable = class KRTable extends i$2 {
|
|
2174
|
+
constructor() {
|
|
2175
|
+
super(...arguments);
|
|
2176
|
+
/**
|
|
2177
|
+
* Internal flag to switch between scroll edge modes:
|
|
2178
|
+
* - 'overlay': Fixed padding with overlay elements that hide content at edges (scrollbar at viewport edge)
|
|
2179
|
+
* - 'edge': Padding scrolls with content, allowing table to reach edges when scrolling
|
|
2180
|
+
*/
|
|
2181
|
+
this._scrollStyle = 'edge';
|
|
2182
|
+
this._data = [];
|
|
2183
|
+
this._dataState = 'idle';
|
|
2184
|
+
this._page = 1;
|
|
2185
|
+
this._pageSize = 50;
|
|
2186
|
+
this._totalItems = 0;
|
|
2187
|
+
this._totalPages = 0;
|
|
2188
|
+
this._searchQuery = '';
|
|
2189
|
+
this._canScrollLeft = false;
|
|
2190
|
+
this._canScrollRight = false;
|
|
2191
|
+
this._canScrollHorizontal = false;
|
|
2192
|
+
this._columnPickerOpen = false;
|
|
2193
|
+
this._displayedColumns = [];
|
|
2194
|
+
this._columnWidths = new Map();
|
|
2195
|
+
this._resizing = null;
|
|
2196
|
+
this._resizeObserver = null;
|
|
2197
|
+
this._searchPositionLocked = false;
|
|
2198
|
+
this.def = { columns: [] };
|
|
2199
|
+
this._handleClickOutsideColumnPicker = (e) => {
|
|
2200
|
+
if (!this._columnPickerOpen)
|
|
2201
|
+
return;
|
|
2202
|
+
const path = e.composedPath();
|
|
2203
|
+
const picker = this.shadowRoot?.querySelector('.column-picker-wrapper');
|
|
2204
|
+
if (picker && !path.includes(picker)) {
|
|
2205
|
+
this._columnPickerOpen = false;
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
this._handleResizeMove = (e) => {
|
|
2209
|
+
if (!this._resizing)
|
|
2210
|
+
return;
|
|
2211
|
+
this._columnWidths.set(this._resizing.columnId, Math.max(50, this._resizing.startWidth + (e.clientX - this._resizing.startX)));
|
|
2212
|
+
this.requestUpdate();
|
|
2213
|
+
};
|
|
2214
|
+
this._handleResizeEnd = () => {
|
|
2215
|
+
this._resizing = null;
|
|
2216
|
+
document.removeEventListener('mousemove', this._handleResizeMove);
|
|
2217
|
+
document.removeEventListener('mouseup', this._handleResizeEnd);
|
|
2218
|
+
};
|
|
2219
|
+
}
|
|
2220
|
+
connectedCallback() {
|
|
2221
|
+
super.connectedCallback();
|
|
2222
|
+
this.classList.toggle('kr-table--scroll-overlay', this._scrollStyle === 'overlay');
|
|
2223
|
+
this.classList.toggle('kr-table--scroll-edge', this._scrollStyle === 'edge');
|
|
2224
|
+
this._fetch();
|
|
2225
|
+
this._initRefresh();
|
|
2226
|
+
document.addEventListener('click', this._handleClickOutsideColumnPicker);
|
|
2227
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
2228
|
+
// Unlock and recalculate on resize since layout changes
|
|
2229
|
+
this._searchPositionLocked = false;
|
|
2230
|
+
this._updateSearchPosition();
|
|
2231
|
+
});
|
|
2232
|
+
this._resizeObserver.observe(this);
|
|
2233
|
+
}
|
|
2234
|
+
disconnectedCallback() {
|
|
2235
|
+
super.disconnectedCallback();
|
|
2236
|
+
clearInterval(this._refreshTimer);
|
|
2237
|
+
document.removeEventListener('click', this._handleClickOutsideColumnPicker);
|
|
2238
|
+
this._resizeObserver?.disconnect();
|
|
2239
|
+
}
|
|
2240
|
+
updated(changedProperties) {
|
|
2241
|
+
if (changedProperties.has('def')) {
|
|
2242
|
+
this._displayedColumns = this.def.displayedColumns || this.def.columns.map(c => c.id);
|
|
2243
|
+
this._fetch();
|
|
2244
|
+
this._initRefresh();
|
|
2245
|
+
}
|
|
2246
|
+
this._updateScrollFlags();
|
|
2247
|
+
}
|
|
2248
|
+
// ----------------------------------------------------------------------------
|
|
2249
|
+
// Public Interface
|
|
2250
|
+
// ----------------------------------------------------------------------------
|
|
2251
|
+
refresh() {
|
|
2252
|
+
this._fetch();
|
|
2253
|
+
}
|
|
2254
|
+
goToPrevPage() {
|
|
2255
|
+
if (this._page > 1) {
|
|
2256
|
+
this._page--;
|
|
2257
|
+
this._fetch();
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
goToNextPage() {
|
|
2261
|
+
if (this._page < this._totalPages) {
|
|
2262
|
+
this._page++;
|
|
2263
|
+
this._fetch();
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
goToPage(page) {
|
|
2267
|
+
if (page >= 1 && page <= this._totalPages) {
|
|
2268
|
+
this._page = page;
|
|
2269
|
+
this._fetch();
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
// ----------------------------------------------------------------------------
|
|
2273
|
+
// Data Fetching
|
|
2274
|
+
// ----------------------------------------------------------------------------
|
|
2275
|
+
/**
|
|
2276
|
+
* Fetches data from the API and updates the table.
|
|
2277
|
+
* Shows a loading spinner while fetching, then displays rows on success
|
|
2278
|
+
* or an error snackbar on failure.
|
|
2279
|
+
* Request/response format depends on dataSource.mode (solr, opensearch, db).
|
|
2280
|
+
*/
|
|
2281
|
+
_fetch() {
|
|
2282
|
+
if (!this.def.dataSource)
|
|
2283
|
+
return;
|
|
2284
|
+
this._dataState = 'loading';
|
|
2285
|
+
// Build request based on mode
|
|
2286
|
+
let request;
|
|
2287
|
+
switch (this.def.dataSource.mode) {
|
|
2288
|
+
case 'opensearch':
|
|
2289
|
+
throw Error('Opensearch not supported yet');
|
|
2290
|
+
case 'db':
|
|
2291
|
+
throw Error('DB not supported yet');
|
|
2292
|
+
default: // solr
|
|
2293
|
+
request = {
|
|
2294
|
+
page: this._page - 1,
|
|
2295
|
+
size: this._pageSize,
|
|
2296
|
+
sorts: [],
|
|
2297
|
+
filterFields: [],
|
|
2298
|
+
queryFields: [],
|
|
2299
|
+
facetFields: []
|
|
2300
|
+
};
|
|
2301
|
+
if (this._searchQuery?.trim().length) {
|
|
2302
|
+
request.queryFields.push({
|
|
2303
|
+
name: '_text_',
|
|
2304
|
+
operation: 'IS',
|
|
2305
|
+
value: escapeSolrQuery(this._searchQuery)
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
this.def.dataSource.fetch(request)
|
|
2310
|
+
.then(response => {
|
|
2311
|
+
// Parse response based on mode
|
|
2312
|
+
switch (this.def.dataSource?.mode) {
|
|
2313
|
+
case 'opensearch': {
|
|
2314
|
+
throw Error('Opensearch not supported yet');
|
|
2315
|
+
}
|
|
2316
|
+
case 'db': {
|
|
2317
|
+
throw Error('DB not supported yet');
|
|
2318
|
+
}
|
|
2319
|
+
default: { // solr
|
|
2320
|
+
const res = response;
|
|
2321
|
+
this._data = res.data.content;
|
|
2322
|
+
this._totalItems = res.data.totalElements;
|
|
2323
|
+
this._totalPages = res.data.totalPages;
|
|
2324
|
+
this._pageSize = res.data.size;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
this._dataState = 'success';
|
|
2328
|
+
this._updateSearchPosition();
|
|
2329
|
+
})
|
|
2330
|
+
.catch(err => {
|
|
2331
|
+
this._dataState = 'error';
|
|
2332
|
+
KRSnackbar.show({
|
|
2333
|
+
message: err instanceof Error ? err.message : 'Failed to load data',
|
|
2334
|
+
type: 'error'
|
|
2335
|
+
});
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
/**
|
|
2339
|
+
* Sets up auto-refresh so the table automatically fetches fresh data
|
|
2340
|
+
* at a regular interval (useful for dashboards, monitoring views).
|
|
2341
|
+
* Configured via def.refreshInterval in milliseconds.
|
|
2342
|
+
*/
|
|
2343
|
+
_initRefresh() {
|
|
2344
|
+
clearInterval(this._refreshTimer);
|
|
2345
|
+
if (this.def.refreshInterval && this.def.refreshInterval > 0) {
|
|
2346
|
+
this._refreshTimer = window.setInterval(() => {
|
|
2347
|
+
this._fetch();
|
|
2348
|
+
}, this.def.refreshInterval);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
_handleSearch(e) {
|
|
2352
|
+
const input = e.target;
|
|
2353
|
+
this._searchQuery = input.value;
|
|
2354
|
+
this._page = 1;
|
|
2355
|
+
this._fetch();
|
|
2356
|
+
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Updates search position to be centered with equal gaps from title and tools.
|
|
2359
|
+
* On first call: resets to flex centering, measures position, then locks with fixed margin.
|
|
2360
|
+
* Subsequent calls are ignored unless _searchPositionLocked is reset (e.g., on resize).
|
|
2361
|
+
*/
|
|
2362
|
+
_updateSearchPosition() {
|
|
2363
|
+
// Skip if already locked (prevents shifts on pagination changes)
|
|
2364
|
+
if (this._searchPositionLocked)
|
|
2365
|
+
return;
|
|
2366
|
+
const search = this.shadowRoot?.querySelector('.search');
|
|
2367
|
+
const searchField = search?.querySelector('.search-field');
|
|
2368
|
+
if (!search || !searchField)
|
|
2369
|
+
return;
|
|
2370
|
+
// Reset to flex centering
|
|
2371
|
+
search.style.justifyContent = 'center';
|
|
2372
|
+
searchField.style.marginLeft = '';
|
|
2373
|
+
requestAnimationFrame(() => {
|
|
2374
|
+
const searchRect = search.getBoundingClientRect();
|
|
2375
|
+
const fieldRect = searchField.getBoundingClientRect();
|
|
2376
|
+
// Calculate how far from the left of search container the field currently is
|
|
2377
|
+
const currentOffset = fieldRect.left - searchRect.left;
|
|
2378
|
+
// Lock position: switch to flex-start and use fixed margin
|
|
2379
|
+
search.style.justifyContent = 'flex-start';
|
|
2380
|
+
searchField.style.marginLeft = `${currentOffset}px`;
|
|
2381
|
+
// Mark as locked so pagination changes don't shift the search
|
|
2382
|
+
this._searchPositionLocked = true;
|
|
2383
|
+
});
|
|
2384
|
+
}
|
|
2385
|
+
// ----------------------------------------------------------------------------
|
|
2386
|
+
// Columns
|
|
2387
|
+
// ----------------------------------------------------------------------------
|
|
2388
|
+
_toggleColumnPicker() {
|
|
2389
|
+
this._columnPickerOpen = !this._columnPickerOpen;
|
|
2390
|
+
}
|
|
2391
|
+
_toggleColumn(columnId) {
|
|
2392
|
+
if (this._displayedColumns.includes(columnId)) {
|
|
2393
|
+
this._displayedColumns = this._displayedColumns.filter(id => id !== columnId);
|
|
2394
|
+
}
|
|
2395
|
+
else {
|
|
2396
|
+
this._displayedColumns = [...this._displayedColumns, columnId];
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
// When a user toggles a column on via the column picker, it gets appended
|
|
2400
|
+
// to _displayedColumns. By mapping over _displayedColumns (not def.columns),
|
|
2401
|
+
// the new column appears at the right edge of the table instead of jumping
|
|
2402
|
+
// back to its original position in the column definition.
|
|
2403
|
+
getDisplayedColumns() {
|
|
2404
|
+
return this._displayedColumns.map(id => this.def.columns.find(col => col.id === id));
|
|
2405
|
+
}
|
|
2406
|
+
// ----------------------------------------------------------------------------
|
|
2407
|
+
// Scrolling
|
|
2408
|
+
// ----------------------------------------------------------------------------
|
|
2409
|
+
/**
|
|
2410
|
+
* Scroll event handler that updates scroll flags in real-time as user scrolls.
|
|
2411
|
+
* Updates shadow indicators to show if more content exists left/right.
|
|
2412
|
+
*/
|
|
2413
|
+
_handleScroll(e) {
|
|
2414
|
+
const container = e.target;
|
|
2415
|
+
this._canScrollLeft = container.scrollLeft > 0;
|
|
2416
|
+
this._canScrollRight = container.scrollLeft < container.scrollWidth - container.clientWidth - 1;
|
|
2417
|
+
}
|
|
2418
|
+
/**
|
|
2419
|
+
* Updates scroll state flags for the table content container.
|
|
2420
|
+
* - _canScrollLeft: true if scrolled right (can scroll back left)
|
|
2421
|
+
* - _canScrollRight: true if more content exists to the right
|
|
2422
|
+
* - _canScrollHorizontal: true if content is wider than container
|
|
2423
|
+
* These flags control scroll shadow indicators and CSS classes.
|
|
2424
|
+
*/
|
|
2425
|
+
_updateScrollFlags() {
|
|
2426
|
+
const container = this.shadowRoot?.querySelector('.content');
|
|
2427
|
+
if (container) {
|
|
2428
|
+
this._canScrollLeft = container.scrollLeft > 0;
|
|
2429
|
+
this._canScrollRight = container.scrollWidth > container.clientWidth && container.scrollLeft < container.scrollWidth - container.clientWidth - 1;
|
|
2430
|
+
this._canScrollHorizontal = container.scrollWidth > container.clientWidth;
|
|
2431
|
+
}
|
|
2432
|
+
this.classList.toggle('kr-table--scroll-left-available', this._canScrollLeft);
|
|
2433
|
+
this.classList.toggle('kr-table--scroll-right-available', this._canScrollRight);
|
|
2434
|
+
this.classList.toggle('kr-table--scroll-horizontal-available', this._canScrollHorizontal);
|
|
2435
|
+
}
|
|
2436
|
+
// ----------------------------------------------------------------------------
|
|
2437
|
+
// Column Resizing
|
|
2438
|
+
// ----------------------------------------------------------------------------
|
|
2439
|
+
_handleResizeStart(e, columnId) {
|
|
2440
|
+
e.preventDefault();
|
|
2441
|
+
const column = this.def.columns.find(c => c.id === columnId);
|
|
2442
|
+
this._resizing = {
|
|
2443
|
+
columnId,
|
|
2444
|
+
startX: e.clientX,
|
|
2445
|
+
startWidth: this._columnWidths.get(columnId) || parseInt(column?.width || '150', 10)
|
|
2446
|
+
};
|
|
2447
|
+
document.addEventListener('mousemove', this._handleResizeMove);
|
|
2448
|
+
document.addEventListener('mouseup', this._handleResizeEnd);
|
|
2449
|
+
}
|
|
2450
|
+
// ----------------------------------------------------------------------------
|
|
2451
|
+
// Header
|
|
2452
|
+
// ----------------------------------------------------------------------------
|
|
2453
|
+
_handleAction(action) {
|
|
2454
|
+
this.dispatchEvent(new CustomEvent('action', {
|
|
2455
|
+
detail: { action: action.id },
|
|
2456
|
+
bubbles: true,
|
|
2457
|
+
composed: true
|
|
2458
|
+
}));
|
|
2459
|
+
}
|
|
2460
|
+
// ----------------------------------------------------------------------------
|
|
2461
|
+
// Rendering
|
|
2462
|
+
// ----------------------------------------------------------------------------
|
|
2463
|
+
_renderCellContent(column, row) {
|
|
2464
|
+
const value = row[column.id];
|
|
2465
|
+
if (column.render) {
|
|
2466
|
+
return column.render(row);
|
|
2467
|
+
}
|
|
2468
|
+
if (value === null || value === undefined) {
|
|
2469
|
+
return '';
|
|
2470
|
+
}
|
|
2471
|
+
switch (column.type) {
|
|
2472
|
+
case 'number':
|
|
2473
|
+
return typeof value === 'number' ? value.toLocaleString() : String(value);
|
|
2474
|
+
case 'currency':
|
|
2475
|
+
return typeof value === 'number'
|
|
2476
|
+
? value.toLocaleString('en-US', { style: 'currency', currency: 'USD' })
|
|
2477
|
+
: String(value);
|
|
2478
|
+
case 'date':
|
|
2479
|
+
return value instanceof Date
|
|
2480
|
+
? value.toLocaleDateString()
|
|
2481
|
+
: new Date(value).toLocaleDateString();
|
|
2482
|
+
case 'boolean':
|
|
2483
|
+
if (value === true)
|
|
2484
|
+
return 'Yes';
|
|
2485
|
+
if (value === false)
|
|
2486
|
+
return 'No';
|
|
2487
|
+
return '';
|
|
2488
|
+
default:
|
|
2489
|
+
return String(value);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Returns CSS classes for a header cell based on column config.
|
|
2494
|
+
*/
|
|
2495
|
+
_getHeaderCellClasses(column, index) {
|
|
2496
|
+
return {
|
|
2497
|
+
'header-cell': true,
|
|
2498
|
+
'header-cell--align-center': column.align === 'center',
|
|
2499
|
+
'header-cell--align-right': column.align === 'right',
|
|
2500
|
+
'header-cell--sticky-left': column.sticky === 'left',
|
|
2501
|
+
'header-cell--sticky-left-last': column.sticky === 'left' &&
|
|
2502
|
+
!this.getDisplayedColumns().slice(index + 1).some(c => c.sticky === 'left'),
|
|
2503
|
+
'header-cell--sticky-right': column.sticky === 'right',
|
|
2504
|
+
'header-cell--sticky-right-first': column.sticky === 'right' &&
|
|
2505
|
+
!this.getDisplayedColumns().slice(0, index).some(c => c.sticky === 'right')
|
|
2506
|
+
};
|
|
2507
|
+
}
|
|
2508
|
+
/**
|
|
2509
|
+
* Returns CSS classes for a table cell based on column config:
|
|
2510
|
+
* - Alignment (center, right)
|
|
2511
|
+
* - Sticky positioning (left, right)
|
|
2512
|
+
* - Border classes for the last left-sticky or first right-sticky column
|
|
2513
|
+
*/
|
|
2514
|
+
_getCellClasses(column, index) {
|
|
2515
|
+
return {
|
|
2516
|
+
'cell': true,
|
|
2517
|
+
'cell--align-center': column.align === 'center',
|
|
2518
|
+
'cell--align-right': column.align === 'right',
|
|
2519
|
+
'cell--sticky-left': column.sticky === 'left',
|
|
2520
|
+
'cell--sticky-left-last': column.sticky === 'left' &&
|
|
2521
|
+
!this.getDisplayedColumns().slice(index + 1).some(c => c.sticky === 'left'),
|
|
2522
|
+
'cell--sticky-right': column.sticky === 'right',
|
|
2523
|
+
'cell--sticky-right-first': column.sticky === 'right' &&
|
|
2524
|
+
!this.getDisplayedColumns().slice(0, index).some(c => c.sticky === 'right')
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* Returns inline styles for a table cell:
|
|
2529
|
+
* - Width (from column config or default 150px)
|
|
2530
|
+
* - Min-width (if specified)
|
|
2531
|
+
* - Left/right offset for sticky columns (calculated from widths of preceding sticky columns)
|
|
2532
|
+
*/
|
|
2533
|
+
_getCellStyle(column, index) {
|
|
2534
|
+
const styles = {};
|
|
2535
|
+
const isLastColumn = index === this.getDisplayedColumns().length - 1;
|
|
2536
|
+
const customWidth = this._columnWidths.get(column.id);
|
|
2537
|
+
const width = customWidth ? `${customWidth}px` : (column.width || '150px');
|
|
2538
|
+
if (isLastColumn && !customWidth) {
|
|
2539
|
+
styles.flex = '1';
|
|
2540
|
+
styles.minWidth = column.width || '150px';
|
|
2541
|
+
styles.marginRight = '24px';
|
|
2542
|
+
}
|
|
2543
|
+
else {
|
|
2544
|
+
styles.width = width;
|
|
2545
|
+
}
|
|
2546
|
+
if (column.minWidth)
|
|
2547
|
+
styles.minWidth = column.minWidth;
|
|
2548
|
+
if (column.sticky === 'left') {
|
|
2549
|
+
let leftOffset = 0;
|
|
2550
|
+
for (let i = 0; i < index; i++) {
|
|
2551
|
+
if (this.getDisplayedColumns()[i].sticky === 'left') {
|
|
2552
|
+
leftOffset += parseInt(this.getDisplayedColumns()[i].width || '150', 10);
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
styles.left = `${leftOffset}px`;
|
|
2556
|
+
}
|
|
2557
|
+
if (column.sticky === 'right') {
|
|
2558
|
+
let rightOffset = 0;
|
|
2559
|
+
for (let i = index + 1; i < this.getDisplayedColumns().length; i++) {
|
|
2560
|
+
if (this.getDisplayedColumns()[i].sticky === 'right') {
|
|
2561
|
+
rightOffset += parseInt(this.getDisplayedColumns()[i].width || '150', 10);
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
styles.right = `${rightOffset}px`;
|
|
2565
|
+
}
|
|
2566
|
+
return styles;
|
|
2567
|
+
}
|
|
2568
|
+
/**
|
|
2569
|
+
* Renders the pagination controls:
|
|
2570
|
+
* - Previous page arrow (disabled on first page)
|
|
2571
|
+
* - Range text showing "1-50 of 150" format
|
|
2572
|
+
* - Next page arrow (disabled on last page)
|
|
2573
|
+
*
|
|
2574
|
+
* Hidden when there's no data or all data fits on one page.
|
|
2575
|
+
*/
|
|
2576
|
+
_renderPagination() {
|
|
2577
|
+
const start = (this._page - 1) * this._pageSize + 1;
|
|
2578
|
+
const end = Math.min(this._page * this._pageSize, this._totalItems);
|
|
2579
|
+
return b `
|
|
2580
|
+
<div class="pagination">
|
|
2581
|
+
<span
|
|
2582
|
+
class="pagination-icon ${this._page === 1 ? 'pagination-icon--disabled' : ''}"
|
|
2583
|
+
@click=${this.goToPrevPage}
|
|
2584
|
+
>
|
|
2585
|
+
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>
|
|
2586
|
+
</span>
|
|
2587
|
+
<span class="pagination-info">${start}-${end} of ${this._totalItems}</span>
|
|
2588
|
+
<span
|
|
2589
|
+
class="pagination-icon ${this._page === this._totalPages ? 'pagination-icon--disabled' : ''}"
|
|
2590
|
+
@click=${this.goToNextPage}
|
|
2591
|
+
>
|
|
2592
|
+
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>
|
|
2593
|
+
</span>
|
|
2594
|
+
</div>
|
|
2595
|
+
`;
|
|
2596
|
+
}
|
|
2597
|
+
/**
|
|
2598
|
+
* Renders the header toolbar containing:
|
|
2599
|
+
* - Title (left)
|
|
2600
|
+
* - Search bar with view selector dropdown (center)
|
|
2601
|
+
* - Tools (right): page navigation, refresh button, column visibility picker, actions dropdown
|
|
2602
|
+
*
|
|
2603
|
+
* Hidden when there's no title, no actions, and data fits on one page.
|
|
2604
|
+
*/
|
|
2605
|
+
_renderHeader() {
|
|
2606
|
+
if (!this.def.title && !this.def.actions?.length && this._totalPages <= 1) {
|
|
2607
|
+
return A;
|
|
2608
|
+
}
|
|
2609
|
+
return b `
|
|
2610
|
+
<div class="header">
|
|
2611
|
+
<div class="title">${this.def.title ?? ''}</div>
|
|
2612
|
+
<div class="search">
|
|
2613
|
+
<!-- TODO: Saved views dropdown
|
|
2614
|
+
<div class="views">
|
|
2615
|
+
<span>Default View</span>
|
|
2616
|
+
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"/></svg>
|
|
2617
|
+
</div>
|
|
2618
|
+
-->
|
|
2619
|
+
<div class="search-field">
|
|
2620
|
+
<svg class="search-icon" viewBox="0 -960 960 960" fill="currentColor"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>
|
|
2621
|
+
<input
|
|
2622
|
+
type="text"
|
|
2623
|
+
class="search-input"
|
|
2624
|
+
placeholder="Search..."
|
|
2625
|
+
.value=${this._searchQuery}
|
|
2626
|
+
@input=${this._handleSearch}
|
|
2627
|
+
/>
|
|
2628
|
+
</div>
|
|
2629
|
+
</div>
|
|
2630
|
+
<div class="tools">
|
|
2631
|
+
${this._renderPagination()}
|
|
2632
|
+
<span class="refresh" title="Refresh" @click=${() => this.refresh()}>
|
|
2633
|
+
<svg viewBox="0 -960 960 960" fill="currentColor"><path d="M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z"/></svg>
|
|
2634
|
+
</span>
|
|
2635
|
+
<div class="column-picker-wrapper">
|
|
2636
|
+
<span class="header-icon" title="Columns" @click=${this._toggleColumnPicker}>
|
|
2637
|
+
<svg viewBox="0 -960 960 960" fill="currentColor"><path d="M121-280v-400q0-33 23.5-56.5T201-760h559q33 0 56.5 23.5T840-680v400q0 33-23.5 56.5T760-200H201q-33 0-56.5-23.5T121-280Zm79 0h133v-400H200v400Zm213 0h133v-400H413v400Zm213 0h133v-400H626v400Z"/></svg>
|
|
2638
|
+
</span>
|
|
2639
|
+
<div class="column-picker ${this._columnPickerOpen ? 'open' : ''}">
|
|
2640
|
+
${[...this.def.columns].sort((a, b) => (a.label ?? a.id).localeCompare(b.label ?? b.id)).map(col => b `
|
|
2641
|
+
<div class="column-picker-item" @click=${() => this._toggleColumn(col.id)}>
|
|
2642
|
+
<div class="column-picker-checkbox ${this._displayedColumns.includes(col.id) ? 'checked' : ''}">
|
|
2643
|
+
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>
|
|
2644
|
+
</div>
|
|
2645
|
+
<span class="column-picker-label">${col.label ?? col.id}</span>
|
|
2646
|
+
</div>
|
|
2647
|
+
`)}
|
|
2648
|
+
</div>
|
|
2649
|
+
</div>
|
|
2650
|
+
${this.def.actions?.length ? b `
|
|
2651
|
+
<kr-button
|
|
2652
|
+
class="actions"
|
|
2653
|
+
.options=${this.def.actions.map(a => ({ id: a.id, label: a.label }))}
|
|
2654
|
+
@option-select=${(e) => this._handleAction({ id: e.detail.id, label: e.detail.label })}
|
|
2655
|
+
>
|
|
2656
|
+
Actions
|
|
2657
|
+
</kr-button>
|
|
2658
|
+
` : A}
|
|
2659
|
+
</div>
|
|
2660
|
+
</div>
|
|
2661
|
+
`;
|
|
2662
|
+
}
|
|
2663
|
+
/** Renders status message (loading, error, empty) */
|
|
2664
|
+
_renderStatus() {
|
|
2665
|
+
if (this._dataState === 'loading' && this._data.length === 0) {
|
|
2666
|
+
return b `<div class="status">Loading...</div>`;
|
|
2667
|
+
}
|
|
2668
|
+
if (this._dataState === 'error' && this._data.length === 0) {
|
|
2669
|
+
return b `<div class="status status--error">Error loading data</div>`;
|
|
2670
|
+
}
|
|
2671
|
+
if (this._data.length === 0) {
|
|
2672
|
+
return b `<div class="status">No data available</div>`;
|
|
2673
|
+
}
|
|
2674
|
+
return A;
|
|
2675
|
+
}
|
|
2676
|
+
/** Renders the scrollable data grid with column headers and rows. */
|
|
2677
|
+
_renderTable() {
|
|
2678
|
+
return b `
|
|
2679
|
+
<div class="wrapper">
|
|
2680
|
+
<div class="overlay-left"></div>
|
|
2681
|
+
<div class="overlay-right"></div>
|
|
2682
|
+
${this._renderStatus()}
|
|
2683
|
+
<div class="content" @scroll=${this._handleScroll}>
|
|
2684
|
+
<div class="table">
|
|
2685
|
+
<div class="header-row">
|
|
2686
|
+
${this.getDisplayedColumns().map((col, i) => b `
|
|
2687
|
+
<div
|
|
2688
|
+
class=${e$1(this._getHeaderCellClasses(col, i))}
|
|
2689
|
+
style=${o$1(this._getCellStyle(col, i))}
|
|
2690
|
+
>
|
|
2691
|
+
<span class="header-cell__label">${col.label ?? col.id}</span>
|
|
2692
|
+
<div
|
|
2693
|
+
class="header-cell__resize"
|
|
2694
|
+
@mousedown=${(e) => this._handleResizeStart(e, col.id)}
|
|
2695
|
+
></div>
|
|
2696
|
+
</div>
|
|
2697
|
+
`)}
|
|
2698
|
+
</div>
|
|
2699
|
+
${this._data.map(row => b `
|
|
2700
|
+
<div class="row">
|
|
2701
|
+
${this.getDisplayedColumns().map((col, i) => b `
|
|
2702
|
+
<div
|
|
2703
|
+
class=${e$1(this._getCellClasses(col, i))}
|
|
2704
|
+
style=${o$1(this._getCellStyle(col, i))}
|
|
2705
|
+
>
|
|
2706
|
+
${this._renderCellContent(col, row)}
|
|
2707
|
+
</div>
|
|
2708
|
+
`)}
|
|
2709
|
+
</div>
|
|
2710
|
+
`)}
|
|
2711
|
+
</div>
|
|
2712
|
+
</div>
|
|
2713
|
+
</div>
|
|
2714
|
+
`;
|
|
2715
|
+
}
|
|
2716
|
+
/**
|
|
2717
|
+
* Renders a data table with:
|
|
2718
|
+
* - Header bar with title, search input with view selector, and tools (pagination, refresh, column visibility, actions dropdown)
|
|
2719
|
+
* - Scrollable grid with sticky header row and optional sticky left/right columns
|
|
2720
|
+
* - Loading, error message, or empty state when no data
|
|
2721
|
+
*/
|
|
2722
|
+
render() {
|
|
2723
|
+
if (!this.def.columns.length) {
|
|
2724
|
+
return b `<slot></slot>`;
|
|
2725
|
+
}
|
|
2726
|
+
return b `
|
|
2727
|
+
${this._renderHeader()}
|
|
2728
|
+
${this._renderTable()}
|
|
2729
|
+
`;
|
|
2730
|
+
}
|
|
2731
|
+
};
|
|
2732
|
+
KRTable.styles = [krBaseCSS, i$5 `
|
|
2733
|
+
/* -------------------------------------------------------------------------
|
|
2734
|
+
* Host
|
|
2735
|
+
* ----------------------------------------------------------------------- */
|
|
2736
|
+
:host {
|
|
2737
|
+
display: flex;
|
|
2738
|
+
flex-direction: column;
|
|
2739
|
+
width: 100%;
|
|
2740
|
+
height: 100%;
|
|
2741
|
+
overflow: hidden;
|
|
2742
|
+
container-type: inline-size;
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
/* -------------------------------------------------------------------------
|
|
2746
|
+
* Header
|
|
2747
|
+
* ----------------------------------------------------------------------- */
|
|
2748
|
+
.header {
|
|
2749
|
+
flex-shrink: 0;
|
|
2750
|
+
display: flex;
|
|
2751
|
+
align-items: center;
|
|
2752
|
+
gap: 16px;
|
|
2753
|
+
margin: 0 24px;
|
|
2754
|
+
padding: 0 4px;
|
|
2755
|
+
height: 64px;
|
|
2756
|
+
border-bottom: 1px solid #e5e7eb;
|
|
2757
|
+
background: #fff;
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
:host(.kr-table--scroll-edge) .header {
|
|
2761
|
+
border-bottom: none;
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
.title {
|
|
2765
|
+
font-size: 20px;
|
|
2766
|
+
font-weight: 400;
|
|
2767
|
+
color: #000;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
/* -------------------------------------------------------------------------
|
|
2771
|
+
* Content
|
|
2772
|
+
* ----------------------------------------------------------------------- */
|
|
2773
|
+
.wrapper {
|
|
2774
|
+
flex: 1;
|
|
2775
|
+
position: relative;
|
|
2776
|
+
overflow: hidden;
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
.content {
|
|
2780
|
+
height: 100%;
|
|
2781
|
+
overflow: auto;
|
|
2782
|
+
padding-bottom: 24px;
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
/* -------------------------------------------------------------------------
|
|
2786
|
+
* Search
|
|
2787
|
+
* ----------------------------------------------------------------------- */
|
|
2788
|
+
.search {
|
|
2789
|
+
flex: 1;
|
|
2790
|
+
display: flex;
|
|
2791
|
+
align-items: center;
|
|
2792
|
+
justify-content: center;
|
|
2793
|
+
min-width: 0;
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
.search-field {
|
|
2797
|
+
width: 100%;
|
|
2798
|
+
max-width: 400px;
|
|
2799
|
+
position: relative;
|
|
2800
|
+
display: flex;
|
|
2801
|
+
align-items: center;
|
|
2802
|
+
border: 1px solid #00000038;
|
|
2803
|
+
border-radius: 18px;
|
|
2804
|
+
transition: border-color 0.2s, box-shadow 0.2s;
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
.search-field:focus-within {
|
|
2808
|
+
border-color: #163052;
|
|
2809
|
+
box-shadow: 0 0 0 3px rgba(22, 48, 82, 0.1);
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
/* TODO: Uncomment when views dropdown is added
|
|
2813
|
+
.search-field:focus-within .views {
|
|
2814
|
+
border-color: #163052;
|
|
2815
|
+
}
|
|
2816
|
+
*/
|
|
2817
|
+
|
|
2818
|
+
.search-icon {
|
|
2819
|
+
position: absolute;
|
|
2820
|
+
left: 16px;
|
|
2821
|
+
width: 20px;
|
|
2822
|
+
height: 20px;
|
|
2823
|
+
color: #656871;
|
|
2824
|
+
pointer-events: none;
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2827
|
+
.search-input {
|
|
2828
|
+
height: 36px;
|
|
2829
|
+
padding: 0 16px 0 42px;
|
|
2830
|
+
border: none;
|
|
2831
|
+
border-radius: 16px;
|
|
2832
|
+
font-size: 14px;
|
|
2833
|
+
font-weight: 400;
|
|
2834
|
+
font-family: inherit;
|
|
2835
|
+
color: #163052;
|
|
2836
|
+
background: transparent;
|
|
2837
|
+
outline: none;
|
|
2838
|
+
flex: 1;
|
|
2839
|
+
min-width: 0;
|
|
2840
|
+
width: 100%;
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
.search-input::placeholder {
|
|
2844
|
+
color: #656871;
|
|
2845
|
+
font-weight: 400;
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
.search-input:focus {
|
|
2849
|
+
outline: none;
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
@container (max-width: 800px) {
|
|
2853
|
+
.search-field {
|
|
2854
|
+
max-width: 250px;
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
.views {
|
|
2859
|
+
display: flex;
|
|
2860
|
+
align-items: center;
|
|
2861
|
+
gap: 4px;
|
|
2862
|
+
height: 36px;
|
|
2863
|
+
padding: 0 16px;
|
|
2864
|
+
border: 1px solid #00000038;
|
|
2865
|
+
border-right: none;
|
|
2866
|
+
border-radius: 16px 0 0 16px;
|
|
2867
|
+
font-size: 14px;
|
|
2868
|
+
font-family: inherit;
|
|
2869
|
+
color: #163052;
|
|
2870
|
+
background: transparent;
|
|
2871
|
+
cursor: pointer;
|
|
2872
|
+
white-space: nowrap;
|
|
2873
|
+
transition: border-color 0.2s;
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
.views:hover {
|
|
2877
|
+
background: #e8f0f8;
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
.views svg {
|
|
2881
|
+
width: 16px;
|
|
2882
|
+
height: 16px;
|
|
2883
|
+
color: #163052;
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
/* -------------------------------------------------------------------------
|
|
2887
|
+
* Pagination
|
|
2888
|
+
* ----------------------------------------------------------------------- */
|
|
2889
|
+
.tools {
|
|
2890
|
+
display: flex;
|
|
2891
|
+
align-items: center;
|
|
2892
|
+
gap: 8px;
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
.pagination {
|
|
2896
|
+
display: flex;
|
|
2897
|
+
align-items: center;
|
|
2898
|
+
gap: 2px;
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
.pagination-info {
|
|
2902
|
+
font-size: 13px;
|
|
2903
|
+
color: var(--kr-primary);
|
|
2904
|
+
white-space: nowrap;
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
.pagination-icon {
|
|
2908
|
+
display: flex;
|
|
2909
|
+
color: var(--kr-primary);
|
|
2910
|
+
cursor: pointer;
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
.pagination-icon--disabled {
|
|
2914
|
+
opacity: 0.3;
|
|
2915
|
+
pointer-events: none;
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
.pagination-icon svg {
|
|
2919
|
+
width: 24px;
|
|
2920
|
+
height: 24px;
|
|
2921
|
+
}
|
|
2922
|
+
|
|
2923
|
+
/* -------------------------------------------------------------------------
|
|
2924
|
+
* Header Icons
|
|
2925
|
+
* ----------------------------------------------------------------------- */
|
|
2926
|
+
.refresh,
|
|
2927
|
+
.header-icon {
|
|
2928
|
+
display: flex;
|
|
2929
|
+
align-items: center;
|
|
2930
|
+
justify-content: center;
|
|
2931
|
+
color: var(--kr-primary);
|
|
2932
|
+
background: #EBF1FA;
|
|
2933
|
+
cursor: pointer;
|
|
2934
|
+
padding: 6px;
|
|
2935
|
+
border-radius: 50%;
|
|
2936
|
+
transition: background 0.15s;
|
|
2937
|
+
}
|
|
2938
|
+
|
|
2939
|
+
.refresh:hover,
|
|
2940
|
+
.header-icon:hover {
|
|
2941
|
+
background: #e8f0f8;
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
.refresh svg,
|
|
2945
|
+
.header-icon svg {
|
|
2946
|
+
width: 24px;
|
|
2947
|
+
height: 24px;
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
/* -------------------------------------------------------------------------
|
|
2951
|
+
* Column Picker
|
|
2952
|
+
* ----------------------------------------------------------------------- */
|
|
2953
|
+
.column-picker-wrapper {
|
|
2954
|
+
position: relative;
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
.column-picker {
|
|
2958
|
+
position: absolute;
|
|
2959
|
+
top: 100%;
|
|
2960
|
+
right: 0;
|
|
2961
|
+
margin-top: 4px;
|
|
2962
|
+
min-width: 200px;
|
|
2963
|
+
max-height: calc(100vh - 120px);
|
|
2964
|
+
overflow-y: auto;
|
|
2965
|
+
background: white;
|
|
2966
|
+
border: 1px solid #9ba7b6;
|
|
2967
|
+
border-radius: 8px;
|
|
2968
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
|
2969
|
+
padding: 8px 0;
|
|
2970
|
+
z-index: 100;
|
|
2971
|
+
display: none;
|
|
2972
|
+
transform-origin: top;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
.column-picker.open {
|
|
2976
|
+
display: block;
|
|
2977
|
+
animation: column-picker-fade-in 150ms ease-out;
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
@keyframes column-picker-fade-in {
|
|
2981
|
+
from {
|
|
2982
|
+
opacity: 0;
|
|
2983
|
+
transform: translateY(-4px);
|
|
2984
|
+
}
|
|
2985
|
+
to {
|
|
2986
|
+
opacity: 1;
|
|
2987
|
+
transform: translateY(0);
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
.column-picker-item {
|
|
2992
|
+
display: flex;
|
|
2993
|
+
align-items: center;
|
|
2994
|
+
gap: 10px;
|
|
2995
|
+
padding: 8px 16px;
|
|
2996
|
+
cursor: pointer;
|
|
2997
|
+
white-space: nowrap;
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
.column-picker-item:hover {
|
|
3001
|
+
background: #f3f4f6;
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
.column-picker-checkbox {
|
|
3005
|
+
width: 16px;
|
|
3006
|
+
height: 16px;
|
|
3007
|
+
border: 1.5px solid #9ca3af;
|
|
3008
|
+
border-radius: 3px;
|
|
3009
|
+
display: flex;
|
|
3010
|
+
align-items: center;
|
|
3011
|
+
justify-content: center;
|
|
3012
|
+
flex-shrink: 0;
|
|
3013
|
+
transition: all 0.15s;
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
.column-picker-checkbox.checked {
|
|
3017
|
+
background: var(--kr-primary);
|
|
3018
|
+
border-color: var(--kr-primary);
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
.column-picker-checkbox svg {
|
|
3022
|
+
width: 12px;
|
|
3023
|
+
height: 12px;
|
|
3024
|
+
color: white;
|
|
3025
|
+
opacity: 0;
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
.column-picker-checkbox.checked svg {
|
|
3029
|
+
opacity: 1;
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
.column-picker-label {
|
|
3033
|
+
font-size: 14px;
|
|
3034
|
+
color: #374151;
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
/* -------------------------------------------------------------------------
|
|
3038
|
+
* Table Structure
|
|
3039
|
+
* ----------------------------------------------------------------------- */
|
|
3040
|
+
.table {
|
|
3041
|
+
display: flex;
|
|
3042
|
+
flex-direction: column;
|
|
3043
|
+
width: 100%;
|
|
3044
|
+
min-width: max-content;
|
|
3045
|
+
font-size: 14px;
|
|
3046
|
+
}
|
|
3047
|
+
|
|
3048
|
+
.row {
|
|
3049
|
+
display: flex;
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
.header-row {
|
|
3053
|
+
display: flex;
|
|
3054
|
+
position: sticky;
|
|
3055
|
+
top: 0;
|
|
3056
|
+
z-index: 2;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
.row:hover .cell {
|
|
3060
|
+
background: #f9fafb;
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
.cell {
|
|
3064
|
+
padding: 12px 16px;
|
|
3065
|
+
white-space: nowrap;
|
|
3066
|
+
overflow: hidden;
|
|
3067
|
+
text-overflow: ellipsis;
|
|
3068
|
+
flex-shrink: 0;
|
|
3069
|
+
box-sizing: border-box;
|
|
3070
|
+
}
|
|
3071
|
+
|
|
3072
|
+
.header-cell {
|
|
3073
|
+
display: flex;
|
|
3074
|
+
align-items: center;
|
|
3075
|
+
padding: 12px 16px;
|
|
3076
|
+
white-space: nowrap;
|
|
3077
|
+
flex-shrink: 0;
|
|
3078
|
+
box-sizing: border-box;
|
|
3079
|
+
background: #f9fafb;
|
|
3080
|
+
border-bottom: 2px solid #e5e7eb;
|
|
3081
|
+
font-weight: 600;
|
|
3082
|
+
color: #374151;
|
|
3083
|
+
overflow: visible;
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
.header-cell__label {
|
|
3087
|
+
flex: 1;
|
|
3088
|
+
overflow: hidden;
|
|
3089
|
+
text-overflow: ellipsis;
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
.header-cell__resize {
|
|
3093
|
+
width: 14px;
|
|
3094
|
+
margin-right: -22px;
|
|
3095
|
+
align-self: stretch;
|
|
3096
|
+
cursor: col-resize;
|
|
3097
|
+
display: flex;
|
|
3098
|
+
align-items: center;
|
|
3099
|
+
justify-content: center;
|
|
3100
|
+
z-index: 1;
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
.header-cell__resize::after {
|
|
3104
|
+
content: '';
|
|
3105
|
+
width: 2px;
|
|
3106
|
+
height: 20px;
|
|
3107
|
+
background: #c6c6cd;
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
.header-cell:last-child .header-cell__resize::after {
|
|
3111
|
+
display: none;
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
.cell {
|
|
3115
|
+
background: #fff;
|
|
3116
|
+
border-bottom: 1px solid #e5e7eb;
|
|
3117
|
+
color: #1f2937;
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
.cell--align-center {
|
|
3121
|
+
text-align: center;
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
.cell--align-right {
|
|
3125
|
+
text-align: right;
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3128
|
+
.cell--sticky-left,
|
|
3129
|
+
.cell--sticky-right {
|
|
3130
|
+
position: sticky;
|
|
3131
|
+
z-index: 1;
|
|
3132
|
+
}
|
|
3133
|
+
|
|
3134
|
+
.header-cell--sticky-left,
|
|
3135
|
+
.header-cell--sticky-right {
|
|
3136
|
+
position: sticky;
|
|
3137
|
+
z-index: 3;
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
.header-cell--align-center {
|
|
3141
|
+
text-align: center;
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
.header-cell--align-right {
|
|
3145
|
+
text-align: right;
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3148
|
+
.header-cell--sticky-left-last,
|
|
3149
|
+
.cell--sticky-left-last {
|
|
3150
|
+
border-right: 1px solid #d1d5db;
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
.header-cell--sticky-right-first,
|
|
3154
|
+
.cell--sticky-right-first {
|
|
3155
|
+
border-left: 1px solid #d1d5db;
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3158
|
+
/* -------------------------------------------------------------------------
|
|
3159
|
+
* Scroll Mode: Edge
|
|
3160
|
+
* Padding scrolls with content, table can reach edges when scrolling
|
|
3161
|
+
* ----------------------------------------------------------------------- */
|
|
3162
|
+
:host(.kr-table--scroll-edge) .table {
|
|
3163
|
+
padding-left: 24px;
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3166
|
+
/* Only add right padding when no horizontal scroll is needed */
|
|
3167
|
+
:host(.kr-table--scroll-edge):not(.kr-table--scroll-horizontal-available) .table {
|
|
3168
|
+
padding-right: 24px;
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
:host(.kr-table--scroll-edge) .header-row .header-cell {
|
|
3172
|
+
border-top: 1px solid #e5e7eb;
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
/* -------------------------------------------------------------------------
|
|
3176
|
+
* Scroll Mode: Overlay
|
|
3177
|
+
* Fixed padding with overlay elements that hide content at edges
|
|
3178
|
+
* ----------------------------------------------------------------------- */
|
|
3179
|
+
:host(.kr-table--scroll-overlay) .content {
|
|
3180
|
+
padding-left: 24px;
|
|
3181
|
+
padding-right: 24px;
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
.overlay-left,
|
|
3185
|
+
.overlay-right {
|
|
3186
|
+
display: none;
|
|
3187
|
+
position: absolute;
|
|
3188
|
+
top: 0;
|
|
3189
|
+
bottom: 0;
|
|
3190
|
+
width: 24px;
|
|
3191
|
+
z-index: 5;
|
|
3192
|
+
pointer-events: none;
|
|
3193
|
+
transition: box-shadow 0.15s ease;
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
:host(.kr-table--scroll-overlay) .overlay-left,
|
|
3197
|
+
:host(.kr-table--scroll-overlay) .overlay-right {
|
|
3198
|
+
display: block;
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
.overlay-left {
|
|
3202
|
+
left: 0;
|
|
3203
|
+
background: linear-gradient(to right, #fff 50%, transparent);
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
.overlay-right {
|
|
3207
|
+
right: 0;
|
|
3208
|
+
background: linear-gradient(to left, #fff 50%, transparent);
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3211
|
+
:host(.kr-table--scroll-left-available) .overlay-left {
|
|
3212
|
+
box-shadow: inset -6px 0 6px -6px rgba(0, 0, 0, 0.08);
|
|
3213
|
+
}
|
|
3214
|
+
|
|
3215
|
+
:host(.kr-table--scroll-right-available) .overlay-right {
|
|
3216
|
+
box-shadow: inset 6px 0 6px -6px rgba(0, 0, 0, 0.08);
|
|
3217
|
+
}
|
|
3218
|
+
|
|
3219
|
+
/* -------------------------------------------------------------------------
|
|
3220
|
+
* Status (Loading, Error, Empty)
|
|
3221
|
+
* ----------------------------------------------------------------------- */
|
|
3222
|
+
.status {
|
|
3223
|
+
position: absolute;
|
|
3224
|
+
top: 0;
|
|
3225
|
+
left: 0;
|
|
3226
|
+
right: 0;
|
|
3227
|
+
bottom: 0;
|
|
3228
|
+
display: flex;
|
|
3229
|
+
align-items: center;
|
|
3230
|
+
justify-content: center;
|
|
3231
|
+
font-size: 14px;
|
|
3232
|
+
font-weight: 400;
|
|
3233
|
+
color: #5f6368;
|
|
3234
|
+
pointer-events: none;
|
|
3235
|
+
}
|
|
3236
|
+
|
|
3237
|
+
.status--error {
|
|
3238
|
+
color: #dc2626;
|
|
3239
|
+
}
|
|
3240
|
+
`];
|
|
3241
|
+
__decorate$3([
|
|
3242
|
+
r$1()
|
|
3243
|
+
], KRTable.prototype, "_data", void 0);
|
|
3244
|
+
__decorate$3([
|
|
3245
|
+
r$1()
|
|
3246
|
+
], KRTable.prototype, "_dataState", void 0);
|
|
3247
|
+
__decorate$3([
|
|
3248
|
+
r$1()
|
|
3249
|
+
], KRTable.prototype, "_page", void 0);
|
|
3250
|
+
__decorate$3([
|
|
3251
|
+
r$1()
|
|
3252
|
+
], KRTable.prototype, "_pageSize", void 0);
|
|
3253
|
+
__decorate$3([
|
|
3254
|
+
r$1()
|
|
3255
|
+
], KRTable.prototype, "_totalItems", void 0);
|
|
3256
|
+
__decorate$3([
|
|
3257
|
+
r$1()
|
|
3258
|
+
], KRTable.prototype, "_totalPages", void 0);
|
|
3259
|
+
__decorate$3([
|
|
3260
|
+
r$1()
|
|
3261
|
+
], KRTable.prototype, "_searchQuery", void 0);
|
|
3262
|
+
__decorate$3([
|
|
3263
|
+
r$1()
|
|
3264
|
+
], KRTable.prototype, "_canScrollLeft", void 0);
|
|
3265
|
+
__decorate$3([
|
|
3266
|
+
r$1()
|
|
3267
|
+
], KRTable.prototype, "_canScrollRight", void 0);
|
|
3268
|
+
__decorate$3([
|
|
3269
|
+
r$1()
|
|
3270
|
+
], KRTable.prototype, "_canScrollHorizontal", void 0);
|
|
3271
|
+
__decorate$3([
|
|
3272
|
+
r$1()
|
|
3273
|
+
], KRTable.prototype, "_columnPickerOpen", void 0);
|
|
3274
|
+
__decorate$3([
|
|
3275
|
+
r$1()
|
|
3276
|
+
], KRTable.prototype, "_displayedColumns", void 0);
|
|
3277
|
+
__decorate$3([
|
|
3278
|
+
r$1()
|
|
3279
|
+
], KRTable.prototype, "_columnWidths", void 0);
|
|
3280
|
+
__decorate$3([
|
|
3281
|
+
n$1({ type: Object })
|
|
3282
|
+
], KRTable.prototype, "def", void 0);
|
|
3283
|
+
KRTable = __decorate$3([
|
|
3284
|
+
t$1('kr-table')
|
|
3285
|
+
], KRTable);
|
|
3286
|
+
|
|
2032
3287
|
/**
|
|
2033
3288
|
* @license
|
|
2034
3289
|
* Copyright 2018 Google LLC
|
|
@@ -2266,8 +3521,8 @@ KRTextField.styles = i$5 `
|
|
|
2266
3521
|
|
|
2267
3522
|
input:focus {
|
|
2268
3523
|
outline: none;
|
|
2269
|
-
border-color: var(--kr-text-field-focus-border-color, #
|
|
2270
|
-
box-shadow: 0 0 0 3px var(--kr-text-field-focus-ring-color, rgba(
|
|
3524
|
+
border-color: var(--kr-text-field-focus-border-color, #163052);
|
|
3525
|
+
box-shadow: 0 0 0 3px var(--kr-text-field-focus-ring-color, rgba(22, 48, 82, 0.1));
|
|
2271
3526
|
}
|
|
2272
3527
|
|
|
2273
3528
|
input:disabled {
|
|
@@ -2914,5 +4169,5 @@ KRSelectOption = __decorate([
|
|
|
2914
4169
|
t$1('kr-select-option')
|
|
2915
4170
|
], KRSelectOption);
|
|
2916
4171
|
|
|
2917
|
-
export { DialogRef, KRAccordion, KRAlert, KRButton, KRCodeDemo, KRContextMenu, KRDialog, KRSelect, KRSelectOption, KRSnackbar, KRTab, KRTabGroup, KRTextField, krBaseCSS };
|
|
4172
|
+
export { DialogRef, KRAccordion, KRAlert, KRButton, KRCodeDemo, KRContextMenu, KRDialog, KRSelect, KRSelectOption, KRSnackbar, KRTab, KRTabGroup, KRTable, KRTextField, krBaseCSS };
|
|
2918
4173
|
//# sourceMappingURL=krubble.bundled.js.map
|