@phatvu/web-component-poc 1.0.6 → 1.0.7
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/dist/cjs/fast-button.cjs.entry.js +46 -0
- package/dist/cjs/{fast-button_4.cjs.entry.js → fast-carousel.cjs.entry.js} +1 -231
- package/dist/cjs/fast-input_4.cjs.entry.js +499 -0
- package/dist/cjs/{index-B2BTpdbN.js → index-BEvZs91D.js} +2 -2
- package/dist/cjs/job-card.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/web-component-poc.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/fast-input/fast-input.css +55 -0
- package/dist/collection/components/fast-input/fast-input.js +335 -0
- package/dist/collection/components/jobs-list-only/jobs-list-only.js +180 -3
- package/dist/collection/components/jobs-list-reactive/jobs-list-reactive.css +8 -0
- package/dist/collection/components/jobs-list-reactive/jobs-list-reactive.js +203 -0
- package/dist/components/fast-button.js +1 -1
- package/dist/components/fast-carousel.js +1 -1
- package/dist/components/fast-input.d.ts +11 -0
- package/dist/components/fast-input.js +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/job-card.js +1 -1
- package/dist/components/jobs-item.js +1 -1
- package/dist/components/jobs-list-only.js +1 -1
- package/dist/components/jobs-list-reactive.d.ts +11 -0
- package/dist/components/jobs-list-reactive.js +1 -0
- package/dist/components/{p-ClQDwJJB.js → p-DQiaLjLf.js} +1 -1
- package/dist/esm/fast-button.entry.js +44 -0
- package/dist/esm/{fast-button_4.entry.js → fast-carousel.entry.js} +2 -229
- package/dist/esm/fast-input_4.entry.js +494 -0
- package/dist/esm/{index-Dk5CvWmb.js → index-C_ZLQIpp.js} +2 -2
- package/dist/esm/job-card.entry.js +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/web-component-poc.js +3 -3
- package/dist/types/components/fast-input/fast-input.d.ts +37 -0
- package/dist/types/components/jobs-list-only/jobs-list-only.d.ts +22 -0
- package/dist/types/components/jobs-list-reactive/jobs-list-reactive.d.ts +26 -0
- package/dist/types/components.d.ts +223 -0
- package/dist/web-component-poc/p-618fba28.entry.js +1 -0
- package/dist/web-component-poc/p-7d45772f.entry.js +1 -0
- package/dist/web-component-poc/{p-52c85341.entry.js → p-bef7c8e2.entry.js} +1 -1
- package/dist/web-component-poc/p-cfb9aed9.entry.js +1 -0
- package/dist/web-component-poc/web-component-poc.esm.js +1 -1
- package/hydrate/index.js +354 -6
- package/hydrate/index.mjs +354 -6
- package/package.json +5 -1
- package/dist/web-component-poc/p-96761988.entry.js +0 -1
- /package/dist/components/{p-UM9TUfe3.js → p-BiaJAQXY.js} +0 -0
- /package/dist/web-component-poc/{p-Dk5CvWmb.js → p-C_ZLQIpp.js} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.fast-input {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
gap: 0.5rem;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.fast-input__field {
|
|
8
|
+
flex: 1;
|
|
9
|
+
padding: 0.5rem 0.75rem;
|
|
10
|
+
font-size: 1rem;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.fast-input__button {
|
|
16
|
+
padding: 0.5rem 1rem;
|
|
17
|
+
font-size: 1rem;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
background: #0070f3;
|
|
20
|
+
color: #fff;
|
|
21
|
+
border: none;
|
|
22
|
+
border-radius: 4px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.fast-input__dropdown {
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 100%;
|
|
28
|
+
left: 0;
|
|
29
|
+
right: 0;
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
list-style: none;
|
|
33
|
+
background: #fff;
|
|
34
|
+
border: 1px solid #ccc;
|
|
35
|
+
border-top: none;
|
|
36
|
+
border-radius: 0 0 4px 4px;
|
|
37
|
+
z-index: 100;
|
|
38
|
+
max-height: 200px;
|
|
39
|
+
overflow-y: auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.fast-input__dropdown-item {
|
|
43
|
+
padding: 0.5rem 0.75rem;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.fast-input__dropdown-item:hover {
|
|
48
|
+
background: #f0f0f0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.fast-input__dropdown-loading {
|
|
52
|
+
padding: 0.5rem 0.75rem;
|
|
53
|
+
color: #999;
|
|
54
|
+
font-style: italic;
|
|
55
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
export class FastInput {
|
|
3
|
+
placeholder = 'Search...';
|
|
4
|
+
value = '';
|
|
5
|
+
paramName = 'keyword';
|
|
6
|
+
enableAutocomplete = false;
|
|
7
|
+
autocompleteUrl = '/api/jobs/autocomplete';
|
|
8
|
+
targetPath;
|
|
9
|
+
debounceMs = 300;
|
|
10
|
+
minChars = 3;
|
|
11
|
+
searchExecuted;
|
|
12
|
+
inputChanged;
|
|
13
|
+
inputValue = '';
|
|
14
|
+
suggestions = [];
|
|
15
|
+
showDropdown = false;
|
|
16
|
+
autocompleteLoading = false;
|
|
17
|
+
debounceTimer;
|
|
18
|
+
popstateHandler;
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
const urlValue = this.getUrlParam();
|
|
21
|
+
this.inputValue = urlValue !== null ? urlValue : this.value;
|
|
22
|
+
this.popstateHandler = () => {
|
|
23
|
+
this.inputValue = this.getUrlParam() ?? '';
|
|
24
|
+
};
|
|
25
|
+
window.addEventListener('popstate', this.popstateHandler);
|
|
26
|
+
}
|
|
27
|
+
disconnectedCallback() {
|
|
28
|
+
window.removeEventListener('popstate', this.popstateHandler);
|
|
29
|
+
clearTimeout(this.debounceTimer);
|
|
30
|
+
}
|
|
31
|
+
getUrlParam() {
|
|
32
|
+
const params = new URLSearchParams(window.location.search);
|
|
33
|
+
return params.get(this.paramName);
|
|
34
|
+
}
|
|
35
|
+
updateUrlParam(value) {
|
|
36
|
+
const params = new URLSearchParams(window.location.search);
|
|
37
|
+
if (value) {
|
|
38
|
+
params.set(this.paramName, value);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
params.delete(this.paramName);
|
|
42
|
+
}
|
|
43
|
+
const qs = params.toString();
|
|
44
|
+
const newUrl = qs
|
|
45
|
+
? `${window.location.pathname}?${qs}`
|
|
46
|
+
: window.location.pathname;
|
|
47
|
+
history.pushState({}, '', newUrl);
|
|
48
|
+
}
|
|
49
|
+
submit() {
|
|
50
|
+
this.updateUrlParam(this.inputValue);
|
|
51
|
+
document.dispatchEvent(new CustomEvent('search-executed', {
|
|
52
|
+
detail: { keyword: this.inputValue },
|
|
53
|
+
bubbles: true,
|
|
54
|
+
composed: true,
|
|
55
|
+
}));
|
|
56
|
+
this.searchExecuted.emit({ keyword: this.inputValue });
|
|
57
|
+
this.showDropdown = false;
|
|
58
|
+
}
|
|
59
|
+
handleInput = (e) => {
|
|
60
|
+
const value = e.target.value;
|
|
61
|
+
this.inputValue = value;
|
|
62
|
+
this.inputChanged.emit({ value });
|
|
63
|
+
if (this.enableAutocomplete) {
|
|
64
|
+
this.scheduleAutocomplete(value);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
handleKeydown = (e) => {
|
|
68
|
+
if (e.key === 'Enter') {
|
|
69
|
+
this.submit();
|
|
70
|
+
}
|
|
71
|
+
else if (e.key === 'Escape') {
|
|
72
|
+
this.showDropdown = false;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
handleBlur = () => {
|
|
76
|
+
this.showDropdown = false;
|
|
77
|
+
};
|
|
78
|
+
scheduleAutocomplete(value) {
|
|
79
|
+
clearTimeout(this.debounceTimer);
|
|
80
|
+
if (value.length < this.minChars) {
|
|
81
|
+
this.showDropdown = false;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.debounceTimer = setTimeout(() => this.fetchSuggestions(value), this.debounceMs);
|
|
85
|
+
}
|
|
86
|
+
async fetchSuggestions(keyword) {
|
|
87
|
+
if (!this.targetPath) {
|
|
88
|
+
console.warn('[fast-input] target-path is required for autocomplete');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.autocompleteLoading = true;
|
|
92
|
+
this.showDropdown = true;
|
|
93
|
+
try {
|
|
94
|
+
const res = await fetch(this.autocompleteUrl, {
|
|
95
|
+
method: 'POST',
|
|
96
|
+
headers: { 'Content-Type': 'application/json' },
|
|
97
|
+
body: JSON.stringify({ keyword, target_path: this.targetPath }),
|
|
98
|
+
});
|
|
99
|
+
if (!res.ok)
|
|
100
|
+
throw new Error('autocomplete request failed');
|
|
101
|
+
const data = await res.json();
|
|
102
|
+
this.suggestions = data;
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
this.showDropdown = false;
|
|
106
|
+
this.suggestions = [];
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
this.autocompleteLoading = false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
selectSuggestion(title) {
|
|
113
|
+
this.inputValue = title;
|
|
114
|
+
this.showDropdown = false;
|
|
115
|
+
this.submit();
|
|
116
|
+
}
|
|
117
|
+
render() {
|
|
118
|
+
return (h("div", { key: '3a9d31c7b109205600addc326d63979585f10bcd', class: "fast-input" }, h("input", { key: '8f238fe9e002f367d4939616be8c06d938d76045', type: "text", class: "fast-input__field", placeholder: this.placeholder, value: this.inputValue, onInput: this.handleInput, onKeyDown: this.handleKeydown, onBlur: this.handleBlur }), h("button", { key: '7b7404f13432750ece669da8ce68be15179921de', class: "fast-input__button", type: "button", onClick: () => this.submit() }, "Search"), this.enableAutocomplete && this.showDropdown && (h("ul", { key: '1438bacadc21c183842a8bdaa3f336bffb152e14', class: "fast-input__dropdown" }, this.autocompleteLoading ? (h("li", { class: "fast-input__dropdown-loading" }, "Loading...")) : (this.suggestions.map(s => (h("li", { class: "fast-input__dropdown-item", onMouseDown: e => { e.preventDefault(); }, onClick: () => this.selectSuggestion(s.title) }, s.title))))))));
|
|
119
|
+
}
|
|
120
|
+
static get is() { return "fast-input"; }
|
|
121
|
+
static get originalStyleUrls() {
|
|
122
|
+
return {
|
|
123
|
+
"$": ["fast-input.css"]
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
static get styleUrls() {
|
|
127
|
+
return {
|
|
128
|
+
"$": ["fast-input.css"]
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
static get properties() {
|
|
132
|
+
return {
|
|
133
|
+
"placeholder": {
|
|
134
|
+
"type": "string",
|
|
135
|
+
"mutable": false,
|
|
136
|
+
"complexType": {
|
|
137
|
+
"original": "string",
|
|
138
|
+
"resolved": "string",
|
|
139
|
+
"references": {}
|
|
140
|
+
},
|
|
141
|
+
"required": false,
|
|
142
|
+
"optional": false,
|
|
143
|
+
"docs": {
|
|
144
|
+
"tags": [],
|
|
145
|
+
"text": ""
|
|
146
|
+
},
|
|
147
|
+
"getter": false,
|
|
148
|
+
"setter": false,
|
|
149
|
+
"reflect": false,
|
|
150
|
+
"attribute": "placeholder",
|
|
151
|
+
"defaultValue": "'Search...'"
|
|
152
|
+
},
|
|
153
|
+
"value": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"mutable": false,
|
|
156
|
+
"complexType": {
|
|
157
|
+
"original": "string",
|
|
158
|
+
"resolved": "string",
|
|
159
|
+
"references": {}
|
|
160
|
+
},
|
|
161
|
+
"required": false,
|
|
162
|
+
"optional": false,
|
|
163
|
+
"docs": {
|
|
164
|
+
"tags": [],
|
|
165
|
+
"text": ""
|
|
166
|
+
},
|
|
167
|
+
"getter": false,
|
|
168
|
+
"setter": false,
|
|
169
|
+
"reflect": false,
|
|
170
|
+
"attribute": "value",
|
|
171
|
+
"defaultValue": "''"
|
|
172
|
+
},
|
|
173
|
+
"paramName": {
|
|
174
|
+
"type": "string",
|
|
175
|
+
"mutable": false,
|
|
176
|
+
"complexType": {
|
|
177
|
+
"original": "string",
|
|
178
|
+
"resolved": "string",
|
|
179
|
+
"references": {}
|
|
180
|
+
},
|
|
181
|
+
"required": false,
|
|
182
|
+
"optional": false,
|
|
183
|
+
"docs": {
|
|
184
|
+
"tags": [],
|
|
185
|
+
"text": ""
|
|
186
|
+
},
|
|
187
|
+
"getter": false,
|
|
188
|
+
"setter": false,
|
|
189
|
+
"reflect": false,
|
|
190
|
+
"attribute": "param-name",
|
|
191
|
+
"defaultValue": "'keyword'"
|
|
192
|
+
},
|
|
193
|
+
"enableAutocomplete": {
|
|
194
|
+
"type": "boolean",
|
|
195
|
+
"mutable": false,
|
|
196
|
+
"complexType": {
|
|
197
|
+
"original": "boolean",
|
|
198
|
+
"resolved": "boolean",
|
|
199
|
+
"references": {}
|
|
200
|
+
},
|
|
201
|
+
"required": false,
|
|
202
|
+
"optional": false,
|
|
203
|
+
"docs": {
|
|
204
|
+
"tags": [],
|
|
205
|
+
"text": ""
|
|
206
|
+
},
|
|
207
|
+
"getter": false,
|
|
208
|
+
"setter": false,
|
|
209
|
+
"reflect": false,
|
|
210
|
+
"attribute": "enable-autocomplete",
|
|
211
|
+
"defaultValue": "false"
|
|
212
|
+
},
|
|
213
|
+
"autocompleteUrl": {
|
|
214
|
+
"type": "string",
|
|
215
|
+
"mutable": false,
|
|
216
|
+
"complexType": {
|
|
217
|
+
"original": "string",
|
|
218
|
+
"resolved": "string",
|
|
219
|
+
"references": {}
|
|
220
|
+
},
|
|
221
|
+
"required": false,
|
|
222
|
+
"optional": false,
|
|
223
|
+
"docs": {
|
|
224
|
+
"tags": [],
|
|
225
|
+
"text": ""
|
|
226
|
+
},
|
|
227
|
+
"getter": false,
|
|
228
|
+
"setter": false,
|
|
229
|
+
"reflect": false,
|
|
230
|
+
"attribute": "autocomplete-url",
|
|
231
|
+
"defaultValue": "'/api/jobs/autocomplete'"
|
|
232
|
+
},
|
|
233
|
+
"targetPath": {
|
|
234
|
+
"type": "string",
|
|
235
|
+
"mutable": false,
|
|
236
|
+
"complexType": {
|
|
237
|
+
"original": "string | undefined",
|
|
238
|
+
"resolved": "string",
|
|
239
|
+
"references": {}
|
|
240
|
+
},
|
|
241
|
+
"required": false,
|
|
242
|
+
"optional": false,
|
|
243
|
+
"docs": {
|
|
244
|
+
"tags": [],
|
|
245
|
+
"text": ""
|
|
246
|
+
},
|
|
247
|
+
"getter": false,
|
|
248
|
+
"setter": false,
|
|
249
|
+
"reflect": false,
|
|
250
|
+
"attribute": "target-path"
|
|
251
|
+
},
|
|
252
|
+
"debounceMs": {
|
|
253
|
+
"type": "number",
|
|
254
|
+
"mutable": false,
|
|
255
|
+
"complexType": {
|
|
256
|
+
"original": "number",
|
|
257
|
+
"resolved": "number",
|
|
258
|
+
"references": {}
|
|
259
|
+
},
|
|
260
|
+
"required": false,
|
|
261
|
+
"optional": false,
|
|
262
|
+
"docs": {
|
|
263
|
+
"tags": [],
|
|
264
|
+
"text": ""
|
|
265
|
+
},
|
|
266
|
+
"getter": false,
|
|
267
|
+
"setter": false,
|
|
268
|
+
"reflect": false,
|
|
269
|
+
"attribute": "debounce-ms",
|
|
270
|
+
"defaultValue": "300"
|
|
271
|
+
},
|
|
272
|
+
"minChars": {
|
|
273
|
+
"type": "number",
|
|
274
|
+
"mutable": false,
|
|
275
|
+
"complexType": {
|
|
276
|
+
"original": "number",
|
|
277
|
+
"resolved": "number",
|
|
278
|
+
"references": {}
|
|
279
|
+
},
|
|
280
|
+
"required": false,
|
|
281
|
+
"optional": false,
|
|
282
|
+
"docs": {
|
|
283
|
+
"tags": [],
|
|
284
|
+
"text": ""
|
|
285
|
+
},
|
|
286
|
+
"getter": false,
|
|
287
|
+
"setter": false,
|
|
288
|
+
"reflect": false,
|
|
289
|
+
"attribute": "min-chars",
|
|
290
|
+
"defaultValue": "3"
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
static get states() {
|
|
295
|
+
return {
|
|
296
|
+
"inputValue": {},
|
|
297
|
+
"suggestions": {},
|
|
298
|
+
"showDropdown": {},
|
|
299
|
+
"autocompleteLoading": {}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
static get events() {
|
|
303
|
+
return [{
|
|
304
|
+
"method": "searchExecuted",
|
|
305
|
+
"name": "searchExecuted",
|
|
306
|
+
"bubbles": true,
|
|
307
|
+
"cancelable": true,
|
|
308
|
+
"composed": true,
|
|
309
|
+
"docs": {
|
|
310
|
+
"tags": [],
|
|
311
|
+
"text": ""
|
|
312
|
+
},
|
|
313
|
+
"complexType": {
|
|
314
|
+
"original": "{ keyword: string }",
|
|
315
|
+
"resolved": "{ keyword: string; }",
|
|
316
|
+
"references": {}
|
|
317
|
+
}
|
|
318
|
+
}, {
|
|
319
|
+
"method": "inputChanged",
|
|
320
|
+
"name": "inputChanged",
|
|
321
|
+
"bubbles": true,
|
|
322
|
+
"cancelable": true,
|
|
323
|
+
"composed": true,
|
|
324
|
+
"docs": {
|
|
325
|
+
"tags": [],
|
|
326
|
+
"text": ""
|
|
327
|
+
},
|
|
328
|
+
"complexType": {
|
|
329
|
+
"original": "{ value: string }",
|
|
330
|
+
"resolved": "{ value: string; }",
|
|
331
|
+
"references": {}
|
|
332
|
+
}
|
|
333
|
+
}];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
@@ -25,16 +25,84 @@ export class JobsListOnly {
|
|
|
25
25
|
enableKilometers = false;
|
|
26
26
|
/** Extra CSS class on the root element (avoid prop name "class" / "classname" reserved). */
|
|
27
27
|
rootClass = '';
|
|
28
|
+
/** Template string for count display. Tokens: {count} = jobs on page, {total} = total from API. */
|
|
29
|
+
showCountText = '';
|
|
28
30
|
showSuggestions = false;
|
|
29
31
|
clearResultSuggestionsTitleText = 'Suggestions';
|
|
30
32
|
clearResultSuggestionsLine1 = 'Try different keywords';
|
|
31
33
|
clearResultSuggestionsLine2 = 'Make sure everything is spelled correctly';
|
|
32
34
|
clearResultSuggestionsLine3 = 'Try other locations';
|
|
33
35
|
clearResultSuggestionsLine4 = '';
|
|
36
|
+
/** When true, component manages its own data fetching */
|
|
37
|
+
autoFetch = false;
|
|
38
|
+
/** Jobs search endpoint */
|
|
39
|
+
apiUrl = '/api/get-jobs';
|
|
40
|
+
/** Comma-separated URL param names to watch and forward to the API */
|
|
41
|
+
watchParams = 'keyword';
|
|
42
|
+
fetchedJobs = [];
|
|
43
|
+
fetchedTotal = 0;
|
|
44
|
+
fetchLoading = false;
|
|
45
|
+
fetchComplete;
|
|
46
|
+
searchExecutedHandler;
|
|
47
|
+
popstateHandler;
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
if (this.autoFetch) {
|
|
50
|
+
this.fetchJobs();
|
|
51
|
+
this.searchExecutedHandler = () => this.fetchJobs();
|
|
52
|
+
this.popstateHandler = () => this.fetchJobs();
|
|
53
|
+
document.addEventListener('search-executed', this.searchExecutedHandler);
|
|
54
|
+
window.addEventListener('popstate', this.popstateHandler);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
disconnectedCallback() {
|
|
58
|
+
if (this.autoFetch) {
|
|
59
|
+
document.removeEventListener('search-executed', this.searchExecutedHandler);
|
|
60
|
+
window.removeEventListener('popstate', this.popstateHandler);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async fetchJobs() {
|
|
64
|
+
this.fetchLoading = true;
|
|
65
|
+
const params = new URLSearchParams(window.location.search);
|
|
66
|
+
const watchList = this.watchParams.split(',').map(p => p.trim()).filter(Boolean);
|
|
67
|
+
const query = new URLSearchParams();
|
|
68
|
+
for (const key of watchList) {
|
|
69
|
+
const val = params.get(key);
|
|
70
|
+
if (val !== null)
|
|
71
|
+
query.set(key, val);
|
|
72
|
+
}
|
|
73
|
+
const url = `${this.apiUrl}?${query.toString()}`;
|
|
74
|
+
try {
|
|
75
|
+
const res = await fetch(url, {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: { 'Content-Type': 'application/json' },
|
|
78
|
+
body: JSON.stringify({ disable_switch_search_mode: false }),
|
|
79
|
+
});
|
|
80
|
+
if (!res.ok)
|
|
81
|
+
throw new Error('fetch failed');
|
|
82
|
+
const data = await res.json();
|
|
83
|
+
this.fetchedJobs = data.jobs;
|
|
84
|
+
this.fetchedTotal = data.totalJob;
|
|
85
|
+
this.fetchComplete.emit({ jobs: data.jobs, totalJob: data.totalJob });
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// preserve stale data, just stop loading
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
this.fetchLoading = false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
renderCountText(count, total) {
|
|
95
|
+
return this.showCountText
|
|
96
|
+
.replace('{count}', String(count))
|
|
97
|
+
.replace('{total}', String(total));
|
|
98
|
+
}
|
|
34
99
|
getJobsArray() {
|
|
35
100
|
if (this.mockData) {
|
|
36
101
|
return mockJobsListOnly;
|
|
37
102
|
}
|
|
103
|
+
if (this.autoFetch) {
|
|
104
|
+
return this.fetchedJobs;
|
|
105
|
+
}
|
|
38
106
|
const j = this.jobs;
|
|
39
107
|
if (Array.isArray(j))
|
|
40
108
|
return j;
|
|
@@ -54,11 +122,15 @@ export class JobsListOnly {
|
|
|
54
122
|
}
|
|
55
123
|
render() {
|
|
56
124
|
const jobsArray = this.getJobsArray();
|
|
57
|
-
const loading = this.mockData ? false : this.loading;
|
|
58
|
-
const totalJob = this.mockData
|
|
125
|
+
const loading = this.mockData ? false : (this.autoFetch ? this.fetchLoading : this.loading);
|
|
126
|
+
const totalJob = this.mockData
|
|
127
|
+
? jobsArray.length
|
|
128
|
+
: this.autoFetch
|
|
129
|
+
? this.fetchedTotal
|
|
130
|
+
: (this.totalJob || jobsArray.length);
|
|
59
131
|
const showNoResults = !loading && totalJob === 0 && !this.showSuggestions;
|
|
60
132
|
const showSuggestionsBlock = !loading && totalJob === 0 && this.showSuggestions;
|
|
61
|
-
return (h("div", { key: '
|
|
133
|
+
return (h("div", { key: '1116855473d28d650641b9d962243bfcdcb434ec', class: `jobs-list-root ${this.rootClass}`.trim() }, h("div", { key: 'fcef04f1da9ad4e150af9f59921688f5781d9d43', class: "results-container" }, this.autoFetch && this.fetchLoading && (h("div", { key: '75b157c82c89691c7ce73d12ea0144b3b45485c3', class: "jobs-list-only__loading" }, "Loading...")), h("div", { key: 'b09f9879e10ee4a93e32177611912da5f19f3526', class: loading ? 'loader' : 'loader hide', "aria-hidden": !loading }), totalJob > 0 && this.showCountText && (h("p", { key: 'd10f800fb0a33d82531d5f1728bac4ceba2ed577', class: "jobs-list-only__count" }, this.renderCountText(jobsArray.length, totalJob))), totalJob > 0 && (h("div", { key: '18153ed1338bd48f7be4f043b11ce15e3271f27b', class: "card" }, h("ul", { key: '766e128b1fd5adb456530ae39e92ba8eb0b5d6cf', class: "results-list front" }, jobsArray.map((job, index) => this.renderJobItem(job, index))))), showNoResults && (h("div", { key: 'ed6f3d2bd2bbedabd6e69d508ea1425580e6941f', class: "share-jobs__no-results" }, h("h2", { key: '2302656e33340c69e84cb949afb7256b8f35f440' }, this.noResultsLine1), h("h3", { key: '1c7e6642441a96c04ee26883fdec4f81b0fe6cec' }, this.noResultsLine2))), showSuggestionsBlock && (h("div", { key: 'be7af85f64455918545e88952ca6ff00f0a970c5', class: "card primary-color" }, h("h4", { key: '2f63deb8131190eff882308544b15f767b6f3edc', class: "result-suggestions-title" }, this.clearResultSuggestionsTitleText, ":"), h("ul", { key: 'cb18daaa9e2c2c442c5b906ed370dcd653b5262d', class: "results-list front" }, h("li", { key: 'ff1d5c6518b75c0daa35b43df7162b0dfecde25e', class: "result-suggestions-line" }, this.clearResultSuggestionsLine1), h("li", { key: '4099fd7bf8dcf114eca28702a498ab0938f5de46', class: "result-suggestions-line" }, this.clearResultSuggestionsLine2), h("li", { key: 'fb65b54c3c0b14bc58112977eb4c7c56c1246a45', class: "result-suggestions-line" }, this.clearResultSuggestionsLine3), this.clearResultSuggestionsLine4 && (h("li", { key: '10f745e74cf68a2b1c42e6f49f810a8b59eb27b6', class: "result-suggestions-line" }, this.clearResultSuggestionsLine4))))))));
|
|
62
134
|
}
|
|
63
135
|
static get is() { return "jobs-list-only"; }
|
|
64
136
|
static get originalStyleUrls() {
|
|
@@ -380,6 +452,26 @@ export class JobsListOnly {
|
|
|
380
452
|
"attribute": "root-class",
|
|
381
453
|
"defaultValue": "''"
|
|
382
454
|
},
|
|
455
|
+
"showCountText": {
|
|
456
|
+
"type": "string",
|
|
457
|
+
"mutable": false,
|
|
458
|
+
"complexType": {
|
|
459
|
+
"original": "string",
|
|
460
|
+
"resolved": "string",
|
|
461
|
+
"references": {}
|
|
462
|
+
},
|
|
463
|
+
"required": false,
|
|
464
|
+
"optional": false,
|
|
465
|
+
"docs": {
|
|
466
|
+
"tags": [],
|
|
467
|
+
"text": "Template string for count display. Tokens: {count} = jobs on page, {total} = total from API."
|
|
468
|
+
},
|
|
469
|
+
"getter": false,
|
|
470
|
+
"setter": false,
|
|
471
|
+
"reflect": false,
|
|
472
|
+
"attribute": "show-count-text",
|
|
473
|
+
"defaultValue": "''"
|
|
474
|
+
},
|
|
383
475
|
"showSuggestions": {
|
|
384
476
|
"type": "boolean",
|
|
385
477
|
"mutable": false,
|
|
@@ -499,7 +591,92 @@ export class JobsListOnly {
|
|
|
499
591
|
"reflect": false,
|
|
500
592
|
"attribute": "clear-result-suggestions-line-4",
|
|
501
593
|
"defaultValue": "''"
|
|
594
|
+
},
|
|
595
|
+
"autoFetch": {
|
|
596
|
+
"type": "boolean",
|
|
597
|
+
"mutable": false,
|
|
598
|
+
"complexType": {
|
|
599
|
+
"original": "boolean",
|
|
600
|
+
"resolved": "boolean",
|
|
601
|
+
"references": {}
|
|
602
|
+
},
|
|
603
|
+
"required": false,
|
|
604
|
+
"optional": false,
|
|
605
|
+
"docs": {
|
|
606
|
+
"tags": [],
|
|
607
|
+
"text": "When true, component manages its own data fetching"
|
|
608
|
+
},
|
|
609
|
+
"getter": false,
|
|
610
|
+
"setter": false,
|
|
611
|
+
"reflect": false,
|
|
612
|
+
"attribute": "auto-fetch",
|
|
613
|
+
"defaultValue": "false"
|
|
614
|
+
},
|
|
615
|
+
"apiUrl": {
|
|
616
|
+
"type": "string",
|
|
617
|
+
"mutable": false,
|
|
618
|
+
"complexType": {
|
|
619
|
+
"original": "string",
|
|
620
|
+
"resolved": "string",
|
|
621
|
+
"references": {}
|
|
622
|
+
},
|
|
623
|
+
"required": false,
|
|
624
|
+
"optional": false,
|
|
625
|
+
"docs": {
|
|
626
|
+
"tags": [],
|
|
627
|
+
"text": "Jobs search endpoint"
|
|
628
|
+
},
|
|
629
|
+
"getter": false,
|
|
630
|
+
"setter": false,
|
|
631
|
+
"reflect": false,
|
|
632
|
+
"attribute": "api-url",
|
|
633
|
+
"defaultValue": "'/api/get-jobs'"
|
|
634
|
+
},
|
|
635
|
+
"watchParams": {
|
|
636
|
+
"type": "string",
|
|
637
|
+
"mutable": false,
|
|
638
|
+
"complexType": {
|
|
639
|
+
"original": "string",
|
|
640
|
+
"resolved": "string",
|
|
641
|
+
"references": {}
|
|
642
|
+
},
|
|
643
|
+
"required": false,
|
|
644
|
+
"optional": false,
|
|
645
|
+
"docs": {
|
|
646
|
+
"tags": [],
|
|
647
|
+
"text": "Comma-separated URL param names to watch and forward to the API"
|
|
648
|
+
},
|
|
649
|
+
"getter": false,
|
|
650
|
+
"setter": false,
|
|
651
|
+
"reflect": false,
|
|
652
|
+
"attribute": "watch-params",
|
|
653
|
+
"defaultValue": "'keyword'"
|
|
502
654
|
}
|
|
503
655
|
};
|
|
504
656
|
}
|
|
657
|
+
static get states() {
|
|
658
|
+
return {
|
|
659
|
+
"fetchedJobs": {},
|
|
660
|
+
"fetchedTotal": {},
|
|
661
|
+
"fetchLoading": {}
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
static get events() {
|
|
665
|
+
return [{
|
|
666
|
+
"method": "fetchComplete",
|
|
667
|
+
"name": "fetchComplete",
|
|
668
|
+
"bubbles": true,
|
|
669
|
+
"cancelable": true,
|
|
670
|
+
"composed": true,
|
|
671
|
+
"docs": {
|
|
672
|
+
"tags": [],
|
|
673
|
+
"text": ""
|
|
674
|
+
},
|
|
675
|
+
"complexType": {
|
|
676
|
+
"original": "{ jobs: any[]; totalJob: number }",
|
|
677
|
+
"resolved": "{ jobs: any[]; totalJob: number; }",
|
|
678
|
+
"references": {}
|
|
679
|
+
}
|
|
680
|
+
}];
|
|
681
|
+
}
|
|
505
682
|
}
|