jsl-ui 10.2.3 → 10.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/SelectComponent.md +21 -0
- package/examples/showcase/fonts/BricolageGrotesque-Variable.ttf +0 -0
- package/examples/showcase/fonts/Figtree-Variable.ttf +0 -0
- package/examples/showcase/fonts/OFL-BricolageGrotesque.txt +93 -0
- package/examples/showcase/fonts/OFL-Figtree.txt +93 -0
- package/examples/showcase/selects.ts +28 -0
- package/examples/showcase/showcase-sources.ts +1 -0
- package/examples/showcase/themes.ts +2 -0
- package/examples/showcase/wirtshans.css +65 -0
- package/lib/components/select/SelectComponent.d.ts +35 -0
- package/lib/components/select/SelectComponent.js +82 -8
- package/lib/components/select/SelectDDAreaComponent.d.ts +6 -0
- package/lib/components/select/SelectDDAreaComponent.js +49 -3
- package/lib/components/select/SelectStyle.scss +3 -1
- package/lib/grid.css +3514 -838
- package/lib/index.css +16 -0
- package/lib/index.css.map +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,6 +9,16 @@ export class SelectDDAreaComponent {
|
|
|
9
9
|
this.onRender = new EventHandler();
|
|
10
10
|
this.optionPositions = new Map();
|
|
11
11
|
this.optionCount = 0;
|
|
12
|
+
this.removed = false;
|
|
13
|
+
this.checkLoadMore = () => {
|
|
14
|
+
const list = this.scrollContainer;
|
|
15
|
+
if (!list || this.removed) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (list.scrollTop + list.clientHeight >= list.scrollHeight - this.options.rowHeight * 3) {
|
|
19
|
+
this.component.requestMore();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
12
22
|
this.searchText = (_a = args.searchTxt) !== null && _a !== void 0 ? _a : "";
|
|
13
23
|
if (this.searchText) {
|
|
14
24
|
this.search(this.searchText);
|
|
@@ -28,6 +38,13 @@ export class SelectDDAreaComponent {
|
|
|
28
38
|
this.scrollContainer = this.dom.querySelector(".sel-dd-items");
|
|
29
39
|
this.scrollToFocus();
|
|
30
40
|
this.renderer.refresh();
|
|
41
|
+
this.scrollContainer.addEventListener("scroll", this.checkLoadMore);
|
|
42
|
+
this.checkLoadMoreSoon();
|
|
43
|
+
}
|
|
44
|
+
onRemove() {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = this.scrollContainer) === null || _a === void 0 ? void 0 : _a.removeEventListener("scroll", this.checkLoadMore);
|
|
47
|
+
this.removed = true;
|
|
31
48
|
}
|
|
32
49
|
render() {
|
|
33
50
|
var _a, _b, _c, _d;
|
|
@@ -60,6 +77,7 @@ export class SelectDDAreaComponent {
|
|
|
60
77
|
this.virtualList.setData(data);
|
|
61
78
|
this.onRender.notify(data);
|
|
62
79
|
const label = (_d = (_c = (_b = this.options.ariaLabel) !== null && _b !== void 0 ? _b : this.options.placeholder) !== null && _c !== void 0 ? _c : this.options.placehoder) !== null && _d !== void 0 ? _d : "Options";
|
|
80
|
+
const loading = this.component.isLoading();
|
|
63
81
|
return {
|
|
64
82
|
tag: "div", attr: {
|
|
65
83
|
class: "sel-dd-panel" + (this.options.enableAnimation ? " sel-dd-animate" : ""),
|
|
@@ -86,8 +104,12 @@ export class SelectDDAreaComponent {
|
|
|
86
104
|
"aria-activedescendant": this.options.enableSearch ? undefined : activeId
|
|
87
105
|
}, children: [
|
|
88
106
|
this.virtualList,
|
|
89
|
-
{ tag: "div", attr: { class: "sel-empty", role: "status", hidden: data.length ? "hidden" : undefined }, content: this.options.emptyText }
|
|
107
|
+
{ tag: "div", attr: { class: "sel-empty", role: "status", hidden: data.length || loading ? "hidden" : undefined }, content: this.options.emptyText }
|
|
90
108
|
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
tag: "div", attr: { class: "sel-status", role: "status", hidden: loading ? undefined : "hidden" },
|
|
112
|
+
content: loading ? this.options.loadingText : undefined
|
|
91
113
|
}
|
|
92
114
|
]
|
|
93
115
|
};
|
|
@@ -97,17 +119,41 @@ export class SelectDDAreaComponent {
|
|
|
97
119
|
search(term) {
|
|
98
120
|
var _a;
|
|
99
121
|
this.searchText = term;
|
|
100
|
-
|
|
122
|
+
// With server-side search the owner replaces the data (dataChanged); nothing is filtered here.
|
|
123
|
+
const remote = this.options.onSearch != null;
|
|
124
|
+
this.filteredData = term && !remote ? this.options.data.filter(item => this.options.matchSearch(item, term)) : null;
|
|
101
125
|
if (this.scrollContainer) {
|
|
102
126
|
this.scrollContainer.scrollTop = 0;
|
|
103
127
|
}
|
|
104
128
|
if (this.virtualList) {
|
|
105
129
|
this.virtualList.State.scrollPos = 0;
|
|
106
130
|
}
|
|
107
|
-
|
|
131
|
+
if (remote) {
|
|
132
|
+
this.component.requestSearch(term);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.focusFirst();
|
|
136
|
+
}
|
|
137
|
+
(_a = this.renderer) === null || _a === void 0 ? void 0 : _a.refresh();
|
|
138
|
+
}
|
|
139
|
+
/** The owner replaced the data: keep the focused item if it is still listed, otherwise focus the first. */
|
|
140
|
+
dataChanged() {
|
|
141
|
+
var _a;
|
|
142
|
+
const key = this.options.keyColumn;
|
|
143
|
+
const focus = this.component.getFocus();
|
|
144
|
+
const same = focus == null ? undefined : this.options.data.find(item => item[key] === focus[key]);
|
|
145
|
+
if (same) {
|
|
146
|
+
this.component.setFocus(same);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
this.focusFirst();
|
|
150
|
+
}
|
|
108
151
|
(_a = this.renderer) === null || _a === void 0 ? void 0 : _a.refresh();
|
|
152
|
+
this.checkLoadMoreSoon();
|
|
109
153
|
}
|
|
110
154
|
clearSearch() { this.search(""); }
|
|
155
|
+
// After a render: a list too short to scroll would otherwise never ask for more.
|
|
156
|
+
checkLoadMoreSoon() { requestAnimationFrame(this.checkLoadMore); }
|
|
111
157
|
isGroup(item) { return this.options.groupProperty != null && (item === null || item === void 0 ? void 0 : item.__isGroup) === true; }
|
|
112
158
|
renderRow(item, index) {
|
|
113
159
|
var _a, _b;
|
|
@@ -191,8 +191,10 @@
|
|
|
191
191
|
font-weight: 600;
|
|
192
192
|
cursor: default;
|
|
193
193
|
}
|
|
194
|
-
.sel-empty { padding: 1.25rem .625rem; color: var(--jsl-color-text-muted); font-size: .8125rem; text-align: center; }
|
|
194
|
+
.sel-empty { position: absolute; left: 0; right: 0; top: 0; padding: 1.25rem .625rem; color: var(--jsl-color-text-muted); font-size: .8125rem; text-align: center; }
|
|
195
195
|
.sel-empty[hidden] { display: none; }
|
|
196
|
+
.sel-status { flex: 0 0 auto; padding: .375rem .625rem; color: var(--jsl-color-text-muted); font-size: .75rem; text-align: center; }
|
|
197
|
+
.sel-status[hidden] { display: none; }
|
|
196
198
|
.sel-dd-animate { animation: jsl-select-appear .12s ease-out; }
|
|
197
199
|
@keyframes jsl-select-appear { from { opacity: 0; } to { opacity: 1; } }
|
|
198
200
|
@media (prefers-reduced-motion: reduce) {
|