@aquera/nile-elements 0.1.74-beta-1.0 → 0.1.75-beta-1.2
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/README.md +3 -0
- package/demo/index.html +117 -22
- package/dist/{fixture-3bfb4490.cjs.js → fixture-5b79f853.cjs.js} +2 -2
- package/dist/{fixture-3bfb4490.cjs.js.map → fixture-5b79f853.cjs.js.map} +1 -1
- package/dist/{fixture-e7023246.esm.js → fixture-90b199c4.esm.js} +1 -1
- package/dist/{fixture-8edec91c.esm.js → fixture-cf7bfcf5.esm.js} +1 -1
- package/dist/{fixture-7bfb866e.cjs.js → fixture-dbd66009.cjs.js} +2 -2
- package/dist/{fixture-fe6c932e.cjs.js.map → fixture-dbd66009.cjs.js.map} +1 -1
- package/dist/index.js +10 -5
- package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
- package/dist/nile-accordion/nile-accordian.test.esm.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
- package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.test.esm.js +1 -1
- package/dist/nile-button/nile-button.test.cjs.js +1 -1
- package/dist/nile-button/nile-button.test.esm.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
- package/dist/nile-card/nile-card.test.cjs.js +1 -1
- package/dist/nile-card/nile-card.test.esm.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.esm.js +1 -1
- package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.test.esm.js +1 -1
- package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.esm.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.esm.js +1 -1
- package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.test.esm.js +1 -1
- package/dist/nile-file-preview/nile-file-preview.test.cjs.js +1 -1
- package/dist/nile-file-preview/nile-file-preview.test.esm.js +1 -1
- package/dist/nile-file-upload/nile-file-upload.test.cjs.js +1 -1
- package/dist/nile-file-upload/nile-file-upload.test.esm.js +1 -1
- package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +1 -1
- package/dist/nile-filter-chip/nile-filter-chip.test.esm.js +1 -1
- package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
- package/dist/nile-form-group/nile-form-group.test.esm.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
- package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.test.esm.js +1 -1
- package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
- package/dist/nile-icon/nile-icon.test.esm.js +1 -1
- package/dist/nile-input/nile-input.test.cjs.js +1 -1
- package/dist/nile-input/nile-input.test.esm.js +1 -1
- package/dist/nile-link/nile-link.test.cjs.js +1 -1
- package/dist/nile-link/nile-link.test.esm.js +1 -1
- package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
- package/dist/nile-loader/nile-loader.test.esm.js +1 -1
- package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
- package/dist/nile-popover/nile-popover.test.esm.js +1 -1
- package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
- package/dist/nile-popup/nile-popup.test.esm.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +1 -1
- package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
- package/dist/nile-radio/nile-radio.test.esm.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.esm.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.esm.js +1 -1
- package/dist/nile-select/nile-select.test.cjs.js +1 -1
- package/dist/nile-select/nile-select.test.esm.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
- package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.test.esm.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +4 -0
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +2 -2
- package/dist/nile-virtual-select/nile-virtual-select.test.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.test.esm.js +1 -1
- package/dist/nile-virtual-select/renderer.cjs.js +1 -1
- package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
- package/dist/nile-virtual-select/renderer.esm.js +4 -3
- package/dist/nile-virtual-select/temp_nile-virtual-select copy.cjs.js +2 -0
- package/dist/nile-virtual-select/temp_nile-virtual-select copy.cjs.js.map +1 -0
- package/dist/nile-virtual-select/temp_nile-virtual-select copy.esm.js +231 -0
- package/dist/src/internal/resizable-helper.d.ts +59 -0
- package/dist/src/internal/resizable-helper.js +115 -0
- package/dist/src/internal/resizable-helper.js.map +1 -0
- package/dist/src/internal/resizable-styles.d.ts +16 -0
- package/dist/src/internal/resizable-styles.js +144 -0
- package/dist/src/internal/resizable-styles.js.map +1 -0
- package/dist/src/internal/virtualizer-error-handler.d.ts +30 -0
- package/dist/src/internal/virtualizer-error-handler.js +82 -0
- package/dist/src/internal/virtualizer-error-handler.js.map +1 -0
- package/dist/src/lib/index.d.ts +7 -0
- package/dist/src/lib/index.js +8 -0
- package/dist/src/lib/index.js.map +1 -0
- package/dist/src/lib/virtualize.d.ts +32 -0
- package/dist/src/lib/virtualize.js +105 -0
- package/dist/src/lib/virtualize.js.map +1 -0
- package/dist/src/lib/virtualize.test.d.ts +7 -0
- package/dist/src/lib/virtualize.test.js +57 -0
- package/dist/src/lib/virtualize.test.js.map +1 -0
- package/dist/src/nile-badge/__snapshots__/nile-badge.test.snap.js +17 -0
- package/dist/src/nile-calendar/__snapshots__/nile-calendar.test.snap.js +310 -0
- package/dist/src/nile-card/__snapshots__/nile-card.test.snap.js +34 -0
- package/dist/src/nile-checkbox/__snapshots__/nile-checkbox.test.snap.js +31 -0
- package/dist/src/nile-grid/data-processor.d.ts +37 -0
- package/dist/src/nile-grid/data-processor.js +122 -0
- package/dist/src/nile-grid/data-processor.js.map +1 -0
- package/dist/src/nile-grid/event-handlers.d.ts +35 -0
- package/dist/src/nile-grid/event-handlers.js +158 -0
- package/dist/src/nile-grid/event-handlers.js.map +1 -0
- package/dist/src/nile-grid/index.d.ts +5 -0
- package/dist/src/nile-grid/index.js +6 -0
- package/dist/src/nile-grid/index.js.map +1 -0
- package/dist/src/nile-grid/nile-grid.css.d.ts +1 -0
- package/dist/src/nile-grid/nile-grid.css.js +120 -0
- package/dist/src/nile-grid/nile-grid.css.js.map +1 -0
- package/dist/src/nile-grid/nile-grid.d.ts +39 -0
- package/dist/src/nile-grid/nile-grid.js +182 -0
- package/dist/src/nile-grid/nile-grid.js.map +1 -0
- package/dist/src/nile-grid/renderer.d.ts +8 -0
- package/dist/src/nile-grid/renderer.js +78 -0
- package/dist/src/nile-grid/renderer.js.map +1 -0
- package/dist/src/nile-grid/resize-handler.d.ts +4 -0
- package/dist/src/nile-grid/resize-handler.js +36 -0
- package/dist/src/nile-grid/resize-handler.js.map +1 -0
- package/dist/src/nile-grid/types.d.ts +32 -0
- package/dist/src/nile-grid/types.js +2 -0
- package/dist/src/nile-grid/types.js.map +1 -0
- package/dist/src/nile-grid/utils.d.ts +4 -0
- package/dist/src/nile-grid/utils.js +32 -0
- package/dist/src/nile-grid/utils.js.map +1 -0
- package/dist/src/nile-hero/__snapshots__/nile-hero.test.snap.js +47 -0
- package/dist/src/nile-icon/__snapshots__/nile-icon.test.snap.js +16 -0
- package/dist/src/nile-input/__snapshots__/nile-input.test.snap.js +75 -0
- package/dist/src/nile-popover/__snapshots__/nile-popover.test.snap.js +22 -0
- package/dist/src/nile-select/nile-select.js +3 -2
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-table-body/virtual-scroll-helper.d.ts +9 -0
- package/dist/src/nile-table-body/virtual-scroll-helper.js +24 -0
- package/dist/src/nile-table-body/virtual-scroll-helper.js.map +1 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +4 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +10 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.js +71 -9
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
- package/dist/src/nile-virtual-select/renderer.d.ts +2 -2
- package/dist/src/nile-virtual-select/renderer.js +6 -5
- package/dist/src/nile-virtual-select/renderer.js.map +1 -1
- package/dist/src/nile-virtual-select/temp_nile-virtual-select copy.d.ts +273 -0
- package/dist/src/nile-virtual-select/temp_nile-virtual-select copy.js +1305 -0
- package/dist/src/nile-virtual-select/temp_nile-virtual-select copy.js.map +1 -0
- package/dist/src/nile-virtual-select/virtualizer-error-handler.d.ts +21 -0
- package/dist/src/nile-virtual-select/virtualizer-error-handler.js +56 -0
- package/dist/src/nile-virtual-select/virtualizer-error-handler.js.map +1 -0
- package/dist/src/nile-virtual-table-body/index.d.ts +2 -0
- package/dist/src/nile-virtual-table-body/index.js +3 -0
- package/dist/src/nile-virtual-table-body/index.js.map +1 -0
- package/dist/src/nile-virtual-table-body/nile-virtual-table-body.css.d.ts +1 -0
- package/dist/src/nile-virtual-table-body/nile-virtual-table-body.css.js +44 -0
- package/dist/src/nile-virtual-table-body/nile-virtual-table-body.css.js.map +1 -0
- package/dist/src/nile-virtual-table-body/nile-virtual-table-body.d.ts +50 -0
- package/dist/src/nile-virtual-table-body/nile-virtual-table-body.js +135 -0
- package/dist/src/nile-virtual-table-body/nile-virtual-table-body.js.map +1 -0
- package/dist/src/nile-virtual-table-body/renderer.d.ts +16 -0
- package/dist/src/nile-virtual-table-body/renderer.js +49 -0
- package/dist/src/nile-virtual-table-body/renderer.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-select/nile-select.ts +3 -2
- package/src/nile-virtual-select/nile-virtual-select.css.ts +4 -0
- package/src/nile-virtual-select/nile-virtual-select.ts +86 -11
- package/src/nile-virtual-select/renderer.ts +7 -5
- package/src/nile-virtual-select/temp_nile-virtual-select copy.ts +1398 -0
- package/vscode-html-custom-data.json +246 -1
- package/dist/axe.min-2b379f29.cjs.js +0 -12
- package/dist/axe.min-2b379f29.cjs.js.map +0 -1
- package/dist/axe.min-c2cd8733.esm.js +0 -12
- package/dist/fixture-2b5b3aba.esm.js +0 -569
- package/dist/fixture-7bfb866e.cjs.js.map +0 -1
- package/dist/fixture-fe6c932e.cjs.js +0 -395
@@ -0,0 +1,144 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2023
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import { css } from 'lit';
|
8
|
+
/**
|
9
|
+
* Resizable Styles Utility
|
10
|
+
* Centralized styles for resizable table functionality
|
11
|
+
*/
|
12
|
+
export const resizableHostStyles = css `
|
13
|
+
/* Resizable-specific host styles */
|
14
|
+
:host([resizable]) {
|
15
|
+
position: relative;
|
16
|
+
overflow: hidden;
|
17
|
+
table-layout: fixed;
|
18
|
+
}
|
19
|
+
`;
|
20
|
+
export const resizableHeaderStyles = css `
|
21
|
+
/* Resizable-specific header styles */
|
22
|
+
:host([resizable]) {
|
23
|
+
position: relative;
|
24
|
+
border-right: 1px solid var(--nile-colors-neutral-400);
|
25
|
+
}
|
26
|
+
|
27
|
+
/* Resizable-specific wrapper styles */
|
28
|
+
:host([resizable]) .header__item__wrapper {
|
29
|
+
position: relative;
|
30
|
+
}
|
31
|
+
`;
|
32
|
+
export const resizerStyles = css `
|
33
|
+
/* Resizer styles - only apply when resizable */
|
34
|
+
.resizer {
|
35
|
+
position: absolute;
|
36
|
+
right: 0;
|
37
|
+
top: -1000px;
|
38
|
+
bottom: -1000px;
|
39
|
+
width: 8px;
|
40
|
+
cursor: col-resize;
|
41
|
+
user-select: none;
|
42
|
+
background-color: var(--nile-colors-neutral-100);
|
43
|
+
transition: background-color 0.2s;
|
44
|
+
z-index: 10;
|
45
|
+
opacity: 0;
|
46
|
+
transition: opacity 0.2s ease;
|
47
|
+
pointer-events: none;
|
48
|
+
}
|
49
|
+
|
50
|
+
:host([resizable]):hover .resizer {
|
51
|
+
opacity: 1;
|
52
|
+
pointer-events: auto;
|
53
|
+
}
|
54
|
+
|
55
|
+
.resizer::before {
|
56
|
+
content: '';
|
57
|
+
position: absolute;
|
58
|
+
right: 3px;
|
59
|
+
top: 0;
|
60
|
+
width: 2px;
|
61
|
+
height: 100%;
|
62
|
+
background-color: var(--nile-colors-neutral-500);
|
63
|
+
opacity: 0.8;
|
64
|
+
}
|
65
|
+
|
66
|
+
.resizer:hover {
|
67
|
+
background-color: var(--nile-colors-neutral-400);
|
68
|
+
}
|
69
|
+
|
70
|
+
.resizer:hover::before {
|
71
|
+
background-color: var(--nile-colors-neutral-700);
|
72
|
+
opacity: 1;
|
73
|
+
}
|
74
|
+
|
75
|
+
.resizer.resizing {
|
76
|
+
background-color: var(--nile-colors-neutral-400);
|
77
|
+
opacity: 1;
|
78
|
+
pointer-events: auto;
|
79
|
+
}
|
80
|
+
|
81
|
+
.resizer.resizing::before {
|
82
|
+
background-color: var(--nile-colors-neutral-700);
|
83
|
+
opacity: 1;
|
84
|
+
width: 3px;
|
85
|
+
}
|
86
|
+
`;
|
87
|
+
export const headerResizerStyles = css `
|
88
|
+
/* Header resizer styles */
|
89
|
+
.resizer {
|
90
|
+
position: absolute;
|
91
|
+
right: -2px;
|
92
|
+
top: -1000px;
|
93
|
+
bottom: -1000px;
|
94
|
+
width: 8px;
|
95
|
+
cursor: ew-resize;
|
96
|
+
user-select: none;
|
97
|
+
transition: background-color 0.2s;
|
98
|
+
z-index: 10;
|
99
|
+
opacity: 0;
|
100
|
+
transition: opacity 0.2s ease;
|
101
|
+
}
|
102
|
+
|
103
|
+
:host([resizable]):hover .resizer {
|
104
|
+
opacity: 1;
|
105
|
+
}
|
106
|
+
|
107
|
+
.resizer::before {
|
108
|
+
content: '';
|
109
|
+
position: absolute;
|
110
|
+
height: 100%;
|
111
|
+
opacity: 0.8;
|
112
|
+
}
|
113
|
+
|
114
|
+
.resizer.resizing {
|
115
|
+
border-right: 4px double var(--nile-colors-neutral-400);
|
116
|
+
background-color: transparent;
|
117
|
+
opacity: 1;
|
118
|
+
}
|
119
|
+
`;
|
120
|
+
export const resizableSlotStyles = css `
|
121
|
+
/* Slot styles for resizable mode */
|
122
|
+
:host([resizable]) ::slotted(*) {
|
123
|
+
overflow: hidden;
|
124
|
+
text-overflow: ellipsis;
|
125
|
+
white-space: nowrap;
|
126
|
+
display: block;
|
127
|
+
}
|
128
|
+
|
129
|
+
:host([resizable]) ::slotted(span),
|
130
|
+
:host([resizable]) ::slotted(div),
|
131
|
+
:host([resizable]) ::slotted(p) {
|
132
|
+
overflow: hidden;
|
133
|
+
text-overflow: ellipsis;
|
134
|
+
white-space: nowrap;
|
135
|
+
display: block;
|
136
|
+
}
|
137
|
+
`;
|
138
|
+
export const tableLayoutStyles = css `
|
139
|
+
/* Apply fixed table layout only when resizable columns are present */
|
140
|
+
.nile__table__body[resizable] {
|
141
|
+
table-layout: fixed;
|
142
|
+
}
|
143
|
+
`;
|
144
|
+
//# sourceMappingURL=resizable-styles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"resizable-styles.js","sourceRoot":"","sources":["../../../src/internal/resizable-styles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;GAGG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;;;;;;;CAOrC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;;;;;;;;CAWvC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsD/B,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCrC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;CAiBrC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;CAKnC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit';\n\n/**\n * Resizable Styles Utility\n * Centralized styles for resizable table functionality\n */\n\nexport const resizableHostStyles = css`\n /* Resizable-specific host styles */\n :host([resizable]) {\n position: relative;\n overflow: hidden;\n table-layout: fixed;\n }\n`;\n\nexport const resizableHeaderStyles = css`\n /* Resizable-specific header styles */\n :host([resizable]) {\n position: relative;\n border-right: 1px solid var(--nile-colors-neutral-400);\n }\n\n /* Resizable-specific wrapper styles */\n :host([resizable]) .header__item__wrapper {\n position: relative;\n }\n`;\n\nexport const resizerStyles = css`\n /* Resizer styles - only apply when resizable */\n .resizer {\n position: absolute;\n right: 0;\n top: -1000px;\n bottom: -1000px;\n width: 8px;\n cursor: col-resize;\n user-select: none;\n background-color: var(--nile-colors-neutral-100);\n transition: background-color 0.2s;\n z-index: 10;\n opacity: 0;\n transition: opacity 0.2s ease;\n pointer-events: none;\n }\n\n :host([resizable]):hover .resizer {\n opacity: 1;\n pointer-events: auto;\n }\n\n .resizer::before {\n content: '';\n position: absolute;\n right: 3px;\n top: 0;\n width: 2px;\n height: 100%;\n background-color: var(--nile-colors-neutral-500);\n opacity: 0.8;\n }\n\n .resizer:hover {\n background-color: var(--nile-colors-neutral-400);\n }\n\n .resizer:hover::before {\n background-color: var(--nile-colors-neutral-700);\n opacity: 1;\n }\n\n .resizer.resizing {\n background-color: var(--nile-colors-neutral-400);\n opacity: 1;\n pointer-events: auto;\n }\n\n .resizer.resizing::before {\n background-color: var(--nile-colors-neutral-700);\n opacity: 1;\n width: 3px;\n }\n`;\n\nexport const headerResizerStyles = css`\n /* Header resizer styles */\n .resizer {\n position: absolute;\n right: -2px;\n top: -1000px;\n bottom: -1000px;\n width: 8px;\n cursor: ew-resize;\n user-select: none;\n transition: background-color 0.2s;\n z-index: 10;\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n\n :host([resizable]):hover .resizer {\n opacity: 1;\n }\n\n .resizer::before {\n content: '';\n position: absolute;\n height: 100%;\n opacity: 0.8;\n }\n\n .resizer.resizing {\n border-right: 4px double var(--nile-colors-neutral-400);\n background-color: transparent;\n opacity: 1;\n }\n`;\n\nexport const resizableSlotStyles = css`\n /* Slot styles for resizable mode */\n :host([resizable]) ::slotted(*) {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n display: block;\n }\n\n :host([resizable]) ::slotted(span),\n :host([resizable]) ::slotted(div),\n :host([resizable]) ::slotted(p) {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n display: block;\n }\n`;\n\nexport const tableLayoutStyles = css`\n /* Apply fixed table layout only when resizable columns are present */\n .nile__table__body[resizable] {\n table-layout: fixed;\n }\n`; \n"]}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
/**
|
8
|
+
* Error handler specifically for virtualizer DOM manipulation errors
|
9
|
+
* Catches and ignores common virtualizer errors that occur during rapid updates
|
10
|
+
*/
|
11
|
+
export declare class VirtualizerErrorHandler {
|
12
|
+
private static isSetup;
|
13
|
+
private static originalConsoleError;
|
14
|
+
/**
|
15
|
+
* Sets up global error handling for virtualizer errors
|
16
|
+
* This should be called once during application initialization
|
17
|
+
*/
|
18
|
+
static setup(): void;
|
19
|
+
/**
|
20
|
+
* Restores original error handling
|
21
|
+
*/
|
22
|
+
static teardown(): void;
|
23
|
+
/**
|
24
|
+
* Checks if an error is a virtualizer DOM manipulation error that should be ignored
|
25
|
+
*/
|
26
|
+
static isVirtualizerError(error: any): boolean;
|
27
|
+
private static setupConsoleErrorHandler;
|
28
|
+
private static setupUnhandledErrorHandler;
|
29
|
+
private static setupUnhandledRejectionHandler;
|
30
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
/**
|
8
|
+
* Error handler specifically for virtualizer DOM manipulation errors
|
9
|
+
* Catches and ignores common virtualizer errors that occur during rapid updates
|
10
|
+
*/
|
11
|
+
export class VirtualizerErrorHandler {
|
12
|
+
/**
|
13
|
+
* Sets up global error handling for virtualizer errors
|
14
|
+
* This should be called once during application initialization
|
15
|
+
*/
|
16
|
+
static setup() {
|
17
|
+
if (this.isSetup) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
this.originalConsoleError = console.error;
|
21
|
+
this.setupConsoleErrorHandler();
|
22
|
+
this.setupUnhandledErrorHandler();
|
23
|
+
this.setupUnhandledRejectionHandler();
|
24
|
+
this.isSetup = true;
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* Restores original error handling
|
28
|
+
*/
|
29
|
+
static teardown() {
|
30
|
+
if (!this.isSetup) {
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
if (this.originalConsoleError) {
|
34
|
+
console.error = this.originalConsoleError;
|
35
|
+
}
|
36
|
+
this.isSetup = false;
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* Checks if an error is a virtualizer DOM manipulation error that should be ignored
|
40
|
+
*/
|
41
|
+
static isVirtualizerError(error) {
|
42
|
+
const errorMessage = error?.message || error?.toString() || '';
|
43
|
+
return (errorMessage.includes('Cannot read properties of null (reading \'insertBefore\')') ||
|
44
|
+
errorMessage.includes('directive-helpers.ts:132') ||
|
45
|
+
errorMessage.includes('repeat.ts:416') ||
|
46
|
+
errorMessage.includes('virtualize.ts:139') ||
|
47
|
+
errorMessage.includes('Virtualizer.ts:816') ||
|
48
|
+
errorMessage.includes('Virtualizer.ts:546') ||
|
49
|
+
errorMessage.includes('Virtualizer.ts:617'));
|
50
|
+
}
|
51
|
+
static setupConsoleErrorHandler() {
|
52
|
+
console.error = (...args) => {
|
53
|
+
const errorMessage = args[0]?.toString() || '';
|
54
|
+
if (this.isVirtualizerError(errorMessage)) {
|
55
|
+
console.warn('Virtualizer DOM error caught and ignored:', ...args);
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
// For all other errors, use the original console.error
|
59
|
+
this.originalConsoleError.apply(console, args);
|
60
|
+
};
|
61
|
+
}
|
62
|
+
static setupUnhandledErrorHandler() {
|
63
|
+
window.addEventListener('error', (event) => {
|
64
|
+
if (this.isVirtualizerError(event.error)) {
|
65
|
+
console.warn('Unhandled virtualizer error caught and ignored:', event.error);
|
66
|
+
event.preventDefault();
|
67
|
+
return false;
|
68
|
+
}
|
69
|
+
});
|
70
|
+
}
|
71
|
+
static setupUnhandledRejectionHandler() {
|
72
|
+
window.addEventListener('unhandledrejection', (event) => {
|
73
|
+
if (this.isVirtualizerError(event.reason)) {
|
74
|
+
console.warn('Unhandled virtualizer promise rejection caught and ignored:', event.reason);
|
75
|
+
event.preventDefault();
|
76
|
+
return false;
|
77
|
+
}
|
78
|
+
});
|
79
|
+
}
|
80
|
+
}
|
81
|
+
VirtualizerErrorHandler.isSetup = false;
|
82
|
+
//# sourceMappingURL=virtualizer-error-handler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtualizer-error-handler.js","sourceRoot":"","sources":["../../../src/internal/virtualizer-error-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAIlC;;;OAGG;IACH,MAAM,CAAC,KAAK;QACV,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,KAAK,CAAC;QAC1C,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAChC,IAAI,CAAC,0BAA0B,E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CAAC,oBAAoB,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,0BAA0B;QACvC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACzC,IAAI,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzC,OAAO,CAAC,IAAI,CAAC,iDAAiD,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC7E,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,8BAA8B;QAC3C,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;YACtD,IAAI,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1C,OAAO,CAAC,IAAI,CAAC,6DAA6D,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAC1F,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;;AAjFc,+BAAO,GAAG,KAAK,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Error handler specifically for virtualizer DOM manipulation errors\n * Catches and ignores common virtualizer errors that occur during rapid updates\n */\nexport class VirtualizerErrorHandler {\n private static isSetup = false;\n private static originalConsoleError: typeof console.error;\n\n /**\n * Sets up global error handling for virtualizer errors\n * This should be called once during application initialization\n */\n static setup(): void {\n if (this.isSetup) {\n return;\n }\n\n this.originalConsoleError = console.error;\n this.setupConsoleErrorHandler();\n this.setupUnhandledErrorHandler();\n this.setupUnhandledRejectionHandler();\n this.isSetup = true;\n }\n\n /**\n * Restores original error handling\n */\n static teardown(): void {\n if (!this.isSetup) {\n return;\n }\n\n if (this.originalConsoleError) {\n console.error = this.originalConsoleError;\n }\n this.isSetup = false;\n }\n\n /**\n * Checks if an error is a virtualizer DOM manipulation error that should be ignored\n */\n static isVirtualizerError(error: any): boolean {\n const errorMessage = error?.message || error?.toString() || '';\n return (\n errorMessage.includes('Cannot read properties of null (reading \\'insertBefore\\')') ||\n errorMessage.includes('directive-helpers.ts:132') ||\n errorMessage.includes('repeat.ts:416') ||\n errorMessage.includes('virtualize.ts:139') ||\n errorMessage.includes('Virtualizer.ts:816') ||\n errorMessage.includes('Virtualizer.ts:546') ||\n errorMessage.includes('Virtualizer.ts:617')\n );\n }\n\n private static setupConsoleErrorHandler(): void {\n console.error = (...args: any[]) => {\n const errorMessage = args[0]?.toString() || '';\n \n if (this.isVirtualizerError(errorMessage)) {\n console.warn('Virtualizer DOM error caught and ignored:', ...args);\n return;\n }\n \n // For all other errors, use the original console.error\n this.originalConsoleError.apply(console, args);\n };\n }\n\n private static setupUnhandledErrorHandler(): void {\n window.addEventListener('error', (event) => {\n if (this.isVirtualizerError(event.error)) {\n console.warn('Unhandled virtualizer error caught and ignored:', event.error);\n event.preventDefault();\n return false;\n }\n });\n }\n\n private static setupUnhandledRejectionHandler(): void {\n window.addEventListener('unhandledrejection', (event) => {\n if (this.isVirtualizerError(event.reason)) {\n console.warn('Unhandled virtualizer promise rejection caught and ignored:', event.reason);\n event.preventDefault();\n return false;\n }\n });\n }\n}\n"]}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
export { virtualize, createVirtualizer, type VirtualizeOptions } from './virtualize.js';
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
export { virtualize, createVirtualizer } from './virtualize.js';
|
8
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAA0B,MAAM,iBAAiB,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { virtualize, createVirtualizer, type VirtualizeOptions } from './virtualize.js';\n"]}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import { type TemplateResult } from 'lit';
|
8
|
+
export interface VirtualizeOptions {
|
9
|
+
items: any[];
|
10
|
+
renderItem: (item: any, index: number) => TemplateResult;
|
11
|
+
scroller?: boolean;
|
12
|
+
itemHeight?: number;
|
13
|
+
containerHeight?: number;
|
14
|
+
overscan?: number;
|
15
|
+
}
|
16
|
+
/**
|
17
|
+
* Custom virtualize function that mimics the @lit-labs/virtualizer API
|
18
|
+
* but uses our own implementation for better control and customization
|
19
|
+
*/
|
20
|
+
export declare function virtualize(options: VirtualizeOptions): TemplateResult;
|
21
|
+
/**
|
22
|
+
* Enhanced virtualize function with better performance and scroll handling
|
23
|
+
*/
|
24
|
+
export declare function createVirtualizer(options: VirtualizeOptions): {
|
25
|
+
handleScroll: (e: Event) => void;
|
26
|
+
getVisibleRange: () => {
|
27
|
+
start: number;
|
28
|
+
end: number;
|
29
|
+
};
|
30
|
+
getTotalHeight: () => number;
|
31
|
+
scrollToItem: (index: number, container: HTMLElement) => void;
|
32
|
+
};
|
@@ -0,0 +1,105 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import { html } from 'lit';
|
8
|
+
/**
|
9
|
+
* Custom virtualize function that mimics the @lit-labs/virtualizer API
|
10
|
+
* but uses our own implementation for better control and customization
|
11
|
+
*/
|
12
|
+
export function virtualize(options) {
|
13
|
+
const { items = [], renderItem, scroller = true, itemHeight = 40, containerHeight = 300, overscan = 5 } = options;
|
14
|
+
// If no items, return empty template
|
15
|
+
if (!items.length) {
|
16
|
+
return html ``;
|
17
|
+
}
|
18
|
+
// For small datasets, render all items without virtualization
|
19
|
+
if (items.length < 10) {
|
20
|
+
return html `
|
21
|
+
${items.map((item, index) => renderItem(item, index))}
|
22
|
+
`;
|
23
|
+
}
|
24
|
+
// Create a unique ID for this virtualizer instance
|
25
|
+
const virtualizerId = `virtualizer-${Math.random().toString(36).substr(2, 9)}`;
|
26
|
+
return html `
|
27
|
+
<div
|
28
|
+
id="${virtualizerId}"
|
29
|
+
class="custom-virtualizer"
|
30
|
+
style="
|
31
|
+
height: ${containerHeight}px;
|
32
|
+
overflow-y: auto;
|
33
|
+
position: relative;
|
34
|
+
contain: layout style paint;
|
35
|
+
"
|
36
|
+
@scroll=${(e) => {
|
37
|
+
const container = e.target;
|
38
|
+
const scrollTop = container.scrollTop;
|
39
|
+
// Calculate visible range
|
40
|
+
const start = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);
|
41
|
+
const end = Math.min(start + Math.ceil(containerHeight / itemHeight) + (overscan * 2), items.length);
|
42
|
+
// Update the virtualized content
|
43
|
+
updateVirtualizedContent(container, items, renderItem, start, end, itemHeight);
|
44
|
+
}}
|
45
|
+
>
|
46
|
+
${(() => {
|
47
|
+
// Initial render - show first visible items
|
48
|
+
const start = 0;
|
49
|
+
const end = Math.min(Math.ceil(containerHeight / itemHeight) + (overscan * 2), items.length);
|
50
|
+
return html `
|
51
|
+
${updateVirtualizedContent(null, items, renderItem, start, end, itemHeight)}
|
52
|
+
`;
|
53
|
+
})()}
|
54
|
+
</div>
|
55
|
+
`;
|
56
|
+
}
|
57
|
+
/**
|
58
|
+
* Update the virtualized content based on scroll position
|
59
|
+
*/
|
60
|
+
function updateVirtualizedContent(container, items, renderItem, start, end, itemHeight) {
|
61
|
+
const visibleItems = items.slice(start, end);
|
62
|
+
const spacerBefore = start * itemHeight;
|
63
|
+
const spacerAfter = (items.length - end) * itemHeight;
|
64
|
+
return html `
|
65
|
+
${spacerBefore > 0 ? html `<div style="height: ${spacerBefore}px; flex-shrink: 0;"></div>` : ''}
|
66
|
+
${visibleItems.map((item, index) => html `<div style="height: ${itemHeight}px; flex-shrink: 0;">${renderItem(item, start + index)}</div>`)}
|
67
|
+
${spacerAfter > 0 ? html `<div style="height: ${spacerAfter}px; flex-shrink: 0;"></div>` : ''}
|
68
|
+
`;
|
69
|
+
}
|
70
|
+
/**
|
71
|
+
* Enhanced virtualize function with better performance and scroll handling
|
72
|
+
*/
|
73
|
+
export function createVirtualizer(options) {
|
74
|
+
const { items = [], renderItem, scroller = true, itemHeight = 40, containerHeight = 300, overscan = 5 } = options;
|
75
|
+
let scrollTop = 0;
|
76
|
+
let isScrolling = false;
|
77
|
+
let scrollTimeout;
|
78
|
+
const handleScroll = (e) => {
|
79
|
+
const container = e.target;
|
80
|
+
scrollTop = container.scrollTop;
|
81
|
+
isScrolling = true;
|
82
|
+
// Debounce scroll end detection
|
83
|
+
if (scrollTimeout) {
|
84
|
+
clearTimeout(scrollTimeout);
|
85
|
+
}
|
86
|
+
scrollTimeout = setTimeout(() => {
|
87
|
+
isScrolling = false;
|
88
|
+
}, 150);
|
89
|
+
};
|
90
|
+
return {
|
91
|
+
handleScroll,
|
92
|
+
getVisibleRange: () => {
|
93
|
+
const start = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);
|
94
|
+
const end = Math.min(start + Math.ceil(containerHeight / itemHeight) + (overscan * 2), items.length);
|
95
|
+
return { start, end };
|
96
|
+
},
|
97
|
+
getTotalHeight: () => items.length * itemHeight,
|
98
|
+
scrollToItem: (index, container) => {
|
99
|
+
const scrollPosition = index * itemHeight;
|
100
|
+
container.scrollTop = scrollPosition;
|
101
|
+
scrollTop = scrollPosition;
|
102
|
+
}
|
103
|
+
};
|
104
|
+
}
|
105
|
+
//# sourceMappingURL=virtualize.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtualize.js","sourceRoot":"","sources":["../../../src/lib/virtualize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAA+B,MAAM,KAAK,CAAC;AAWxD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAA0B;IACnD,MAAM,EACJ,KAAK,GAAG,EAAE,EACV,UAAU,EACV,QAAQ,GAAG,IAAI,EACf,UAAU,GAAG,EAAE,EACf,eAAe,GAAG,GAAG,EACrB,QAAQ,GAAG,CAAC,EACb,GAAG,OAAO,CAAC;IAEZ,qCAAqC;IACrC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,IAAI,CAAA,EAAE,CAAC;IAChB,CAAC;IAED,8DAA8D;IAC9D,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACtB,OAAO,IAAI,CAAA;QACP,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KACtD,CAAC;IACJ,CAAC;IAED,mDAAmD;IACnD,MAAM,aAAa,GAAG,eAAe,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,C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AC;QACtB,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,eAAe,EAAE,GAAG,EAAE;YACpB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,UAAU,CAAC,GAAG,QAAQ,CAAC,CAAC;YACzE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAClB,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,EAChE,KAAK,CAAC,MAAM,CACb,CAAC;YACF,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QACxB,CAAC;QACD,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,UAAU;QAC/C,YAAY,EAAE,CAAC,KAAa,EAAE,SAAsB,EAAE,EAAE;YACtD,MAAM,cAAc,GAAG,KAAK,GAAG,UAAU,CAAC;YAC1C,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC;YACrC,SAAS,GAAG,cAAc,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, type TemplateResult, render } from 'lit';\n\nexport interface VirtualizeOptions {\n items: any[];\n renderItem: (item: any, index: number) => TemplateResult;\n scroller?: boolean;\n itemHeight?: number;\n containerHeight?: number;\n overscan?: number;\n}\n\n/**\n * Custom virtualize function that mimics the @lit-labs/virtualizer API\n * but uses our own implementation for better control and customization\n */\nexport function virtualize(options: VirtualizeOptions): TemplateResult {\n const {\n items = [],\n renderItem,\n scroller = true,\n itemHeight = 40,\n containerHeight = 300,\n overscan = 5\n } = options;\n\n // If no items, return empty template\n if (!items.length) {\n return html``;\n }\n\n // For small datasets, render all items without virtualization\n if (items.length < 10) {\n return html`\n ${items.map((item, index) => renderItem(item, index))}\n `;\n }\n\n // Create a unique ID for this virtualizer instance\n const virtualizerId = `virtualizer-${Math.random().toString(36).substr(2, 9)}`;\n \n return html`\n <div \n id=\"${virtualizerId}\"\n class=\"custom-virtualizer\"\n style=\"\n height: ${containerHeight}px; \n overflow-y: auto; \n position: relative;\n contain: layout style paint;\n \"\n @scroll=${(e: Event) => {\n const container = e.target as HTMLElement;\n const scrollTop = container.scrollTop;\n \n // Calculate visible range\n const start = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);\n const end = Math.min(\n start + Math.ceil(containerHeight / itemHeight) + (overscan * 2),\n items.length\n );\n \n // Update the virtualized content\n updateVirtualizedContent(container, items, renderItem, start, end, itemHeight);\n }}\n >\n ${(() => {\n // Initial render - show first visible items\n const start = 0;\n const end = Math.min(\n Math.ceil(containerHeight / itemHeight) + (overscan * 2),\n items.length\n );\n \n return html`\n ${updateVirtualizedContent(null, items, renderItem, start, end, itemHeight)}\n `;\n })()}\n </div>\n `;\n}\n\n/**\n * Update the virtualized content based on scroll position\n */\nfunction updateVirtualizedContent(\n container: HTMLElement | null,\n items: any[],\n renderItem: (item: any, index: number) => TemplateResult,\n start: number,\n end: number,\n itemHeight: number\n): TemplateResult {\n const visibleItems = items.slice(start, end);\n const spacerBefore = start * itemHeight;\n const spacerAfter = (items.length - end) * itemHeight;\n \n return html`\n ${spacerBefore > 0 ? html`<div style=\"height: ${spacerBefore}px; flex-shrink: 0;\"></div>` : ''}\n ${visibleItems.map((item, index) => \n html`<div style=\"height: ${itemHeight}px; flex-shrink: 0;\">${renderItem(item, start + index)}</div>`\n )}\n ${spacerAfter > 0 ? html`<div style=\"height: ${spacerAfter}px; flex-shrink: 0;\"></div>` : ''}\n `;\n}\n\n/**\n * Enhanced virtualize function with better performance and scroll handling\n */\nexport function createVirtualizer(options: VirtualizeOptions) {\n const {\n items = [],\n renderItem,\n scroller = true,\n itemHeight = 40,\n containerHeight = 300,\n overscan = 5\n } = options;\n\n let scrollTop = 0;\n let isScrolling = false;\n let scrollTimeout: ReturnType<typeof setTimeout> | undefined;\n\n const handleScroll = (e: Event) => {\n const container = e.target as HTMLElement;\n scrollTop = container.scrollTop;\n isScrolling = true;\n\n // Debounce scroll end detection\n if (scrollTimeout) {\n clearTimeout(scrollTimeout);\n }\n \n scrollTimeout = setTimeout(() => {\n isScrolling = false;\n }, 150);\n };\n\n return {\n handleScroll,\n getVisibleRange: () => {\n const start = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);\n const end = Math.min(\n start + Math.ceil(containerHeight / itemHeight) + (overscan * 2),\n items.length\n );\n return { start, end };\n },\n getTotalHeight: () => items.length * itemHeight,\n scrollToItem: (index: number, container: HTMLElement) => {\n const scrollPosition = index * itemHeight;\n container.scrollTop = scrollPosition;\n scrollTop = scrollPosition;\n }\n };\n}\n"]}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import { expect } from '@open-wc/testing';
|
8
|
+
import { html } from 'lit';
|
9
|
+
import { virtualize } from './virtualize.js';
|
10
|
+
describe('Custom Virtualize', () => {
|
11
|
+
it('should render empty template for empty items array', () => {
|
12
|
+
const result = virtualize({
|
13
|
+
items: [],
|
14
|
+
renderItem: () => html `<div>test</div>`
|
15
|
+
});
|
16
|
+
expect(result).to.exist;
|
17
|
+
});
|
18
|
+
it('should render all items for small datasets without virtualization', () => {
|
19
|
+
const items = Array.from({ length: 5 }, (_, i) => ({ id: i, name: `Item ${i}` }));
|
20
|
+
const result = virtualize({
|
21
|
+
items,
|
22
|
+
renderItem: (item) => html `<div>${item.name}</div>`
|
23
|
+
});
|
24
|
+
expect(result).to.exist;
|
25
|
+
});
|
26
|
+
it('should use virtualization for large datasets', () => {
|
27
|
+
const items = Array.from({ length: 100 }, (_, i) => ({ id: i, name: `Item ${i}` }));
|
28
|
+
const result = virtualize({
|
29
|
+
items,
|
30
|
+
renderItem: (item) => html `<div>${item.name}</div>`,
|
31
|
+
itemHeight: 40,
|
32
|
+
containerHeight: 300
|
33
|
+
});
|
34
|
+
expect(result).to.exist;
|
35
|
+
});
|
36
|
+
it('should accept scroller option', () => {
|
37
|
+
const items = Array.from({ length: 50 }, (_, i) => ({ id: i, name: `Item ${i}` }));
|
38
|
+
const result = virtualize({
|
39
|
+
items,
|
40
|
+
renderItem: (item) => html `<div>${item.name}</div>`,
|
41
|
+
scroller: true
|
42
|
+
});
|
43
|
+
expect(result).to.exist;
|
44
|
+
});
|
45
|
+
it('should accept custom itemHeight and containerHeight', () => {
|
46
|
+
const items = Array.from({ length: 50 }, (_, i) => ({ id: i, name: `Item ${i}` }));
|
47
|
+
const result = virtualize({
|
48
|
+
items,
|
49
|
+
renderItem: (item) => html `<div>${item.name}</div>`,
|
50
|
+
itemHeight: 60,
|
51
|
+
containerHeight: 400,
|
52
|
+
overscan: 10
|
53
|
+
});
|
54
|
+
expect(result).to.exist;
|
55
|
+
});
|
56
|
+
});
|
57
|
+
//# sourceMappingURL=virtualize.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtualize.test.js","sourceRoot":"","sources":["../../../src/lib/virtualize.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,MAAM,GAAG,UAAU,CAAC;YACxB,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA,iBA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AAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAEnF,MAAM,MAAM,GAAG,UAAU,CAAC;YACxB,KAAK;YACL,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA,QAAQ,IAAI,CAAC,IAAI,QAAQ;YACnD,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAEnF,MAAM,MAAM,GAAG,UAAU,CAAC;YACxB,KAAK;YACL,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA,QAAQ,IAAI,CAAC,IAAI,QAAQ;YACnD,UAAU,EAAE,EAAE;YACd,eAAe,EAAE,GAAG;YACpB,QAAQ,EAAE,EAAE;SACb,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { expect } from '@open-wc/testing';\nimport { html } from 'lit';\nimport { virtualize } from './virtualize.js';\n\ndescribe('Custom Virtualize', () => {\n it('should render empty template for empty items array', () => {\n const result = virtualize({\n items: [],\n renderItem: () => html`<div>test</div>`\n });\n \n expect(result).to.exist;\n });\n\n it('should render all items for small datasets without virtualization', () => {\n const items = Array.from({ length: 5 }, (_, i) => ({ id: i, name: `Item ${i}` }));\n \n const result = virtualize({\n items,\n renderItem: (item) => html`<div>${item.name}</div>`\n });\n \n expect(result).to.exist;\n });\n\n it('should use virtualization for large datasets', () => {\n const items = Array.from({ length: 100 }, (_, i) => ({ id: i, name: `Item ${i}` }));\n \n const result = virtualize({\n items,\n renderItem: (item) => html`<div>${item.name}</div>`,\n itemHeight: 40,\n containerHeight: 300\n });\n \n expect(result).to.exist;\n });\n\n it('should accept scroller option', () => {\n const items = Array.from({ length: 50 }, (_, i) => ({ id: i, name: `Item ${i}` }));\n \n const result = virtualize({\n items,\n renderItem: (item) => html`<div>${item.name}</div>`,\n scroller: true\n });\n \n expect(result).to.exist;\n });\n\n it('should accept custom itemHeight and containerHeight', () => {\n const items = Array.from({ length: 50 }, (_, i) => ({ id: i, name: `Item ${i}` }));\n \n const result = virtualize({\n items,\n renderItem: (item) => html`<div>${item.name}</div>`,\n itemHeight: 60,\n containerHeight: 400,\n overscan: 10\n });\n \n expect(result).to.exist;\n });\n});\n"]}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/* @web/test-runner snapshot v1 */
|
2
|
+
export const snapshots = {};
|
3
|
+
|
4
|
+
snapshots["NileBadge should display the default slot content"] =
|
5
|
+
`<span
|
6
|
+
class="badge badge--badge-color badge--normal"
|
7
|
+
part="base"
|
8
|
+
>
|
9
|
+
<slot
|
10
|
+
class="badge__content"
|
11
|
+
part="content"
|
12
|
+
>
|
13
|
+
</slot>
|
14
|
+
</span>
|
15
|
+
`;
|
16
|
+
/* end snapshot NileBadge should display the default slot content */
|
17
|
+
|