@phatvu/web-component-poc 1.0.5 → 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.
Files changed (55) hide show
  1. package/dist/cjs/fast-button.cjs.entry.js +46 -0
  2. package/dist/cjs/{fast-button_4.cjs.entry.js → fast-carousel.cjs.entry.js} +1 -231
  3. package/dist/cjs/fast-input_4.cjs.entry.js +499 -0
  4. package/dist/cjs/{index-B2BTpdbN.js → index-BEvZs91D.js} +2 -2
  5. package/dist/cjs/job-card.cjs.entry.js +138 -0
  6. package/dist/cjs/loader.cjs.js +2 -2
  7. package/dist/cjs/web-component-poc.cjs.js +2 -2
  8. package/dist/collection/collection-manifest.json +4 -1
  9. package/dist/collection/components/button/button.js +2 -2
  10. package/dist/collection/components/fast-input/fast-input.css +55 -0
  11. package/dist/collection/components/fast-input/fast-input.js +335 -0
  12. package/dist/collection/components/job-card/job-card.css +247 -0
  13. package/dist/collection/components/job-card/job-card.js +435 -0
  14. package/dist/collection/components/jobs-item/jobs-item.js +5 -5
  15. package/dist/collection/components/jobs-list-only/jobs-list-only.js +185 -8
  16. package/dist/collection/components/jobs-list-reactive/jobs-list-reactive.css +8 -0
  17. package/dist/collection/components/jobs-list-reactive/jobs-list-reactive.js +203 -0
  18. package/dist/components/fast-button.js +1 -1
  19. package/dist/components/fast-carousel.js +1 -1
  20. package/dist/components/fast-input.d.ts +11 -0
  21. package/dist/components/fast-input.js +1 -0
  22. package/dist/components/index.js +1 -1
  23. package/dist/components/job-card.d.ts +11 -0
  24. package/dist/components/job-card.js +1 -0
  25. package/dist/components/jobs-item.js +1 -1
  26. package/dist/components/jobs-list-only.js +1 -1
  27. package/dist/components/jobs-list-reactive.d.ts +11 -0
  28. package/dist/components/jobs-list-reactive.js +1 -0
  29. package/dist/components/{p-ClQDwJJB.js → p-DQiaLjLf.js} +1 -1
  30. package/dist/esm/fast-button.entry.js +44 -0
  31. package/dist/esm/{fast-button_4.entry.js → fast-carousel.entry.js} +2 -229
  32. package/dist/esm/fast-input_4.entry.js +494 -0
  33. package/dist/esm/{index-Dk5CvWmb.js → index-C_ZLQIpp.js} +2 -2
  34. package/dist/esm/job-card.entry.js +136 -0
  35. package/dist/esm/loader.js +3 -3
  36. package/dist/esm/web-component-poc.js +3 -3
  37. package/dist/types/components/fast-input/fast-input.d.ts +37 -0
  38. package/dist/types/components/job-card/job-card.d.ts +93 -0
  39. package/dist/types/components/jobs-item/jobs-item.d.ts +2 -2
  40. package/dist/types/components/jobs-list-only/jobs-list-only.d.ts +24 -2
  41. package/dist/types/components/jobs-list-reactive/jobs-list-reactive.d.ts +26 -0
  42. package/dist/types/components.d.ts +469 -7
  43. package/dist/types/mock/jobs-list-only.mock.d.ts +2 -2
  44. package/dist/types/types/jobs-list.d.ts +6 -2
  45. package/dist/web-component-poc/p-618fba28.entry.js +1 -0
  46. package/dist/web-component-poc/p-7d45772f.entry.js +1 -0
  47. package/dist/web-component-poc/p-bef7c8e2.entry.js +1 -0
  48. package/dist/web-component-poc/p-cfb9aed9.entry.js +1 -0
  49. package/dist/web-component-poc/web-component-poc.esm.js +1 -1
  50. package/hydrate/index.js +534 -6
  51. package/hydrate/index.mjs +534 -6
  52. package/package.json +9 -1
  53. package/dist/web-component-poc/p-df843533.entry.js +0 -1
  54. /package/dist/components/{p-UM9TUfe3.js → p-BiaJAQXY.js} +0 -0
  55. /package/dist/web-component-poc/{p-Dk5CvWmb.js → p-C_ZLQIpp.js} +0 -0
@@ -0,0 +1,499 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-BEvZs91D.js');
4
+
5
+ const fastInputCss = () => `.fast-input{position:relative;display:inline-flex;gap:0.5rem}.fast-input__field{flex:1;padding:0.5rem 0.75rem;font-size:1rem;border:1px solid #ccc;border-radius:4px}.fast-input__button{padding:0.5rem 1rem;font-size:1rem;cursor:pointer;background:#0070f3;color:#fff;border:none;border-radius:4px}.fast-input__dropdown{position:absolute;top:100%;left:0;right:0;margin:0;padding:0;list-style:none;background:#fff;border:1px solid #ccc;border-top:none;border-radius:0 0 4px 4px;z-index:100;max-height:200px;overflow-y:auto}.fast-input__dropdown-item{padding:0.5rem 0.75rem;cursor:pointer}.fast-input__dropdown-item:hover{background:#f0f0f0}.fast-input__dropdown-loading{padding:0.5rem 0.75rem;color:#999;font-style:italic}`;
6
+
7
+ const FastInput = class {
8
+ constructor(hostRef) {
9
+ index.registerInstance(this, hostRef);
10
+ this.searchExecuted = index.createEvent(this, "searchExecuted");
11
+ this.inputChanged = index.createEvent(this, "inputChanged");
12
+ }
13
+ placeholder = 'Search...';
14
+ value = '';
15
+ paramName = 'keyword';
16
+ enableAutocomplete = false;
17
+ autocompleteUrl = '/api/jobs/autocomplete';
18
+ targetPath;
19
+ debounceMs = 300;
20
+ minChars = 3;
21
+ searchExecuted;
22
+ inputChanged;
23
+ inputValue = '';
24
+ suggestions = [];
25
+ showDropdown = false;
26
+ autocompleteLoading = false;
27
+ debounceTimer;
28
+ popstateHandler;
29
+ connectedCallback() {
30
+ const urlValue = this.getUrlParam();
31
+ this.inputValue = urlValue !== null ? urlValue : this.value;
32
+ this.popstateHandler = () => {
33
+ this.inputValue = this.getUrlParam() ?? '';
34
+ };
35
+ window.addEventListener('popstate', this.popstateHandler);
36
+ }
37
+ disconnectedCallback() {
38
+ window.removeEventListener('popstate', this.popstateHandler);
39
+ clearTimeout(this.debounceTimer);
40
+ }
41
+ getUrlParam() {
42
+ const params = new URLSearchParams(window.location.search);
43
+ return params.get(this.paramName);
44
+ }
45
+ updateUrlParam(value) {
46
+ const params = new URLSearchParams(window.location.search);
47
+ if (value) {
48
+ params.set(this.paramName, value);
49
+ }
50
+ else {
51
+ params.delete(this.paramName);
52
+ }
53
+ const qs = params.toString();
54
+ const newUrl = qs
55
+ ? `${window.location.pathname}?${qs}`
56
+ : window.location.pathname;
57
+ history.pushState({}, '', newUrl);
58
+ }
59
+ submit() {
60
+ this.updateUrlParam(this.inputValue);
61
+ document.dispatchEvent(new CustomEvent('search-executed', {
62
+ detail: { keyword: this.inputValue },
63
+ bubbles: true,
64
+ composed: true,
65
+ }));
66
+ this.searchExecuted.emit({ keyword: this.inputValue });
67
+ this.showDropdown = false;
68
+ }
69
+ handleInput = (e) => {
70
+ const value = e.target.value;
71
+ this.inputValue = value;
72
+ this.inputChanged.emit({ value });
73
+ if (this.enableAutocomplete) {
74
+ this.scheduleAutocomplete(value);
75
+ }
76
+ };
77
+ handleKeydown = (e) => {
78
+ if (e.key === 'Enter') {
79
+ this.submit();
80
+ }
81
+ else if (e.key === 'Escape') {
82
+ this.showDropdown = false;
83
+ }
84
+ };
85
+ handleBlur = () => {
86
+ this.showDropdown = false;
87
+ };
88
+ scheduleAutocomplete(value) {
89
+ clearTimeout(this.debounceTimer);
90
+ if (value.length < this.minChars) {
91
+ this.showDropdown = false;
92
+ return;
93
+ }
94
+ this.debounceTimer = setTimeout(() => this.fetchSuggestions(value), this.debounceMs);
95
+ }
96
+ async fetchSuggestions(keyword) {
97
+ if (!this.targetPath) {
98
+ console.warn('[fast-input] target-path is required for autocomplete');
99
+ return;
100
+ }
101
+ this.autocompleteLoading = true;
102
+ this.showDropdown = true;
103
+ try {
104
+ const res = await fetch(this.autocompleteUrl, {
105
+ method: 'POST',
106
+ headers: { 'Content-Type': 'application/json' },
107
+ body: JSON.stringify({ keyword, target_path: this.targetPath }),
108
+ });
109
+ if (!res.ok)
110
+ throw new Error('autocomplete request failed');
111
+ const data = await res.json();
112
+ this.suggestions = data;
113
+ }
114
+ catch {
115
+ this.showDropdown = false;
116
+ this.suggestions = [];
117
+ }
118
+ finally {
119
+ this.autocompleteLoading = false;
120
+ }
121
+ }
122
+ selectSuggestion(title) {
123
+ this.inputValue = title;
124
+ this.showDropdown = false;
125
+ this.submit();
126
+ }
127
+ render() {
128
+ return (index.h("div", { key: '3a9d31c7b109205600addc326d63979585f10bcd', class: "fast-input" }, index.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 }), index.h("button", { key: '7b7404f13432750ece669da8ce68be15179921de', class: "fast-input__button", type: "button", onClick: () => this.submit() }, "Search"), this.enableAutocomplete && this.showDropdown && (index.h("ul", { key: '1438bacadc21c183842a8bdaa3f336bffb152e14', class: "fast-input__dropdown" }, this.autocompleteLoading ? (index.h("li", { class: "fast-input__dropdown-loading" }, "Loading...")) : (this.suggestions.map(s => (index.h("li", { class: "fast-input__dropdown-item", onMouseDown: e => { e.preventDefault(); }, onClick: () => this.selectSuggestion(s.title) }, s.title))))))));
129
+ }
130
+ };
131
+ FastInput.style = fastInputCss();
132
+
133
+ const jobsItemCss = () => `.results-list__item{list-style:none;padding:10px 0;border-bottom:1px solid #ddd;margin:15px 0;display:inline-block;width:100%;position:relative}.results-list__item:last-child{border-bottom:none}.results-list__item-header{margin:10px 0;font-size:18px;font-weight:700;display:flex;flex-direction:column}.results-list__item-title{margin:0}.results-list__item-title--link{text-decoration:none;color:#1f9755}.results-list__item-title--link:hover{text-decoration:underline}.reference{margin-left:8px;font-size:0.9em;color:#666}.reference.empty{display:none}.remote{background:#f3f3f3;color:#808285;border-radius:100px;padding:6px 16px;text-transform:uppercase;font-size:12px;font-weight:700;line-height:24px;margin-left:8px}.remote--empty{display:none}.results-list__item-distance{display:inline-flex;align-items:center;gap:4px;margin-top:4px;font-size:14px;font-weight:400}.results-list__item-distance--icon{display:inline-flex}.results-list__item-distance--icon svg{width:16px;height:16px}.results-list__item-content{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-top:8px}.results-list__item-info{flex:1}.results-list__item-street,.results-list__item-brand,.results-list__item-employment-type{margin:10px 0;display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px}.results-list__item-street--empty,.results-list__item-brand--empty,.results-list__item-employment-type--empty{color:#999}.results-list__item-street--icon,.results-list__item-brand--icon,.results-list__item-employment-type--icon{margin-right:6px;display:inline-flex}.results-list__item-street--icon svg,.results-list__item-brand--icon svg,.results-list__item-employment-type--icon svg{width:16px;height:16px}.results-list__item-street--more-locations__wrapper{margin-left:8px}.results-list__item-street--amount{font-weight:600}.results-list__item-apply{margin:10px 0;padding:10px 20px;display:inline-flex;align-items:center;gap:8px;background-color:#198754;color:#fff;border-radius:3px;text-decoration:none;font-weight:600;flex-shrink:0}.results-list__item-apply:hover{background-color:#1f9755;color:#fff}.results-list__item-apply--icon svg{width:14px;height:14px}`;
134
+
135
+ function getLocationLabel(loc) {
136
+ if (loc.cityStateAbbr)
137
+ return loc.cityStateAbbr;
138
+ const parts = [loc.streetAddress, loc.city, loc.stateAbbr || loc.state, loc.countryAbbr || loc.country].filter(Boolean);
139
+ return parts.join(', ') || loc.locationText || '';
140
+ }
141
+ function getFirstLocation(job) {
142
+ const locs = job.locations;
143
+ if (!locs?.length)
144
+ return undefined;
145
+ return locs[0];
146
+ }
147
+ const JobsItem = class {
148
+ constructor(hostRef) {
149
+ index.registerInstance(this, hostRef);
150
+ }
151
+ job;
152
+ index = 0;
153
+ applyButtonText = 'Apply Now';
154
+ showBrand = true;
155
+ showReference = false;
156
+ showEmploymentType = true;
157
+ multiLocationText = 'More locations';
158
+ remoteLocationText = 'Remote';
159
+ enableKilometers = false;
160
+ formatDistance(distance) {
161
+ const value = this.enableKilometers ? distance * 1.60934 : distance;
162
+ const unit = this.enableKilometers ? 'Km' : 'Miles';
163
+ const str = `${value.toFixed(1)} ${unit}`.replace('.0', '');
164
+ return str;
165
+ }
166
+ render() {
167
+ if (!this.job)
168
+ return null;
169
+ const firstLoc = getFirstLocation(this.job);
170
+ const locationLabel = firstLoc ? getLocationLabel(firstLoc) : '';
171
+ const distance = firstLoc?.distance ?? 0;
172
+ const distanceLabel = distance > 0 ? this.formatDistance(distance) : '';
173
+ const applyHref = this.job.applyURL ||
174
+ (this.job.originalURL ? `${typeof window !== 'undefined' ? window.location.origin : ''}${this.job.originalURL}` : '#');
175
+ const applyLabel = `${this.applyButtonText}, ${this.job.title || ''}`;
176
+ const locs = this.job.locations ?? [];
177
+ const hasMultipleLocations = locs.length > 1;
178
+ return (index.h("li", { class: "results-list__item" }, index.h("div", { class: "results-list__item-header" }, index.h("h3", { class: "results-list__item-title" }, index.h("a", { class: "results-list__item-title--link", href: applyHref, target: "_blank", rel: "noopener noreferrer" }, this.job.title || ''), this.showReference && (index.h("span", { class: `reference ${this.job.reference ? '' : 'empty'}` }, this.job.reference || '')), this.job.isRemote && (index.h("span", { class: this.remoteLocationText ? 'remote' : 'remote remote--empty' }, this.remoteLocationText))), distanceLabel && (index.h("div", { class: "results-list__item-distance" }, index.h("span", { class: "results-list__item-distance--icon" }, index.h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "1.5" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z" }), index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M12 8v4l2 2" }))), index.h("span", { class: "results-list__item-distance--label" }, distanceLabel)))), index.h("div", { class: "results-list__item-content" }, index.h("div", { class: "results-list__item-info" }, index.h("div", { class: locs.length
179
+ ? 'results-list__item-street'
180
+ : 'results-list__item-street results-list__item-street--empty' }, index.h("div", { class: "results-list__item-street--label__wrapper" }, index.h("span", { class: "results-list__item-street--icon" }, index.h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "1.5" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M15 10.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0z" }), index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1 1 15 0z" }))), index.h("span", { class: "results-list__item-street--label" }, locationLabel || '—')), hasMultipleLocations && (index.h("div", { class: "results-list__item-street--more-locations__wrapper" }, index.h("span", { class: "results-list__item-street--amount" }, "+", locs.length - 1), index.h("span", { class: "results-list__item-street--more-locations" }, this.multiLocationText)))), this.showBrand && (index.h("div", { class: this.job.brandName
181
+ ? 'results-list__item-brand'
182
+ : 'results-list__item-brand results-list__item-brand--empty' }, index.h("span", { class: "results-list__item-brand--icon" }, index.h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "1.5" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 3h12m-.75 4.5H21m-3.75 3.75h.008v.008h-.008v-.008zm0 3h.008v.008h-.008v-.008zm0 3h.008v.008h-.008v-.008z" }))), index.h("span", { class: "results-list__item-brand--label" }, this.job.brandName || '—'))), this.showEmploymentType && (index.h("div", { class: this.job.employmentType?.length
183
+ ? 'results-list__item-employment-type'
184
+ : 'results-list__item-employment-type results-list__item-employment-type--empty' }, index.h("span", { class: "results-list__item-employment-type--icon" }, index.h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "1.5" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0z" }))), (this.job.employmentType?.length ? this.job.employmentType : ['—']).map((type) => (index.h("span", { key: type, class: "results-list__item-employment-type--label" }, type))))), (this.job.jobCardExtraFields ?? []).map((field, i) => (index.h("div", { key: i, class: (Array.isArray(field.value) ? field.value.length : field.value)
185
+ ? field.classname
186
+ : `${field.classname}--empty` }, Array.isArray(field.value)
187
+ ? field.value.map((v, j) => (index.h("span", { key: j, class: `${field.classname}--label` }, v)))
188
+ : (index.h("span", { class: `${field.classname}--label` }, String(field.value))))))), index.h("a", { class: "results-list__item-apply", href: applyHref, target: "_blank", rel: "noopener noreferrer", "aria-label": applyLabel }, index.h("span", { class: "results-list__item-apply--label" }, this.applyButtonText), index.h("span", { class: "results-list__item-apply--icon" }, index.h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, index.h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M13 7l5 5m0 0l-5 5m5-5H6" })))))));
189
+ }
190
+ };
191
+ JobsItem.style = jobsItemCss();
192
+
193
+ /**
194
+ * Mock jobs for local development and docs.
195
+ * Use in www or static HTML: jobs='...' (JSON.stringify(mockJobs)).
196
+ */
197
+ const mockJobsListOnly = [
198
+ {
199
+ title: 'Senior Software Engineer',
200
+ reference: 'REF-001',
201
+ originalURL: '/jobs/senior-software-engineer',
202
+ applyURL: 'https://apply.example.com/1',
203
+ brandName: 'Engineering',
204
+ isRemote: false,
205
+ locations: [
206
+ {
207
+ city: 'San Francisco',
208
+ stateAbbr: 'CA',
209
+ countryAbbr: 'US',
210
+ distance: 5.2,
211
+ streetAddress: '123 Market St',
212
+ cityStateAbbr: 'San Francisco, CA',
213
+ },
214
+ ],
215
+ employmentType: ['Full-time', 'Permanent'],
216
+ },
217
+ {
218
+ title: 'Product Manager',
219
+ reference: '',
220
+ originalURL: '/jobs/product-manager',
221
+ brandName: 'Product',
222
+ isRemote: true,
223
+ locations: [],
224
+ employmentType: ['Full-time'],
225
+ },
226
+ {
227
+ title: 'UX Designer',
228
+ reference: 'REF-003',
229
+ originalURL: '/jobs/ux-designer',
230
+ brandName: 'Design',
231
+ isRemote: false,
232
+ locations: [
233
+ {
234
+ city: 'New York',
235
+ stateAbbr: 'NY',
236
+ countryAbbr: 'US',
237
+ distance: 0,
238
+ cityStateAbbr: 'New York, NY',
239
+ },
240
+ {
241
+ city: 'Boston',
242
+ stateAbbr: 'MA',
243
+ countryAbbr: 'US',
244
+ cityStateAbbr: 'Boston, MA',
245
+ },
246
+ ],
247
+ employmentType: ['Full-time', 'Contract'],
248
+ },
249
+ ];
250
+
251
+ const jobsListOnlyCss = () => `:host{display:block}.jobs-list-root{list-style:none}.results-container{position:relative}.loader{display:inline-block;width:24px;height:24px;border:2px solid #ddd;border-top-color:#1f9755;border-radius:50%;animation:jobs-list-spin 0.8s linear infinite}.loader.hide{display:none}@keyframes jobs-list-spin{to{transform:rotate(360deg)}}.card{border:0}.results-list{list-style:none;margin:0;padding:0;display:block}.results-list.front{margin:3px 0}.share-jobs__no-results{padding:24px;text-align:center}.share-jobs__no-results h2,.share-jobs__no-results h3{margin:8px 0;font-weight:600}.card.primary-color{padding:16px;border-radius:4px;background:#f8f9fa}.result-suggestions-title{margin:0 0 12px 0;font-size:16px}.results-list .result-suggestions-line{list-style:none;margin:4px 0}`;
252
+
253
+ const defaultNoResultsLine1 = "Sorry, we're not able to load results for your search.";
254
+ const defaultNoResultsLine2 = 'Please refine your keywords in the search bar above and try again.';
255
+ const JobsListOnly = class {
256
+ constructor(hostRef) {
257
+ index.registerInstance(this, hostRef);
258
+ this.fetchComplete = index.createEvent(this, "fetchComplete");
259
+ }
260
+ /**
261
+ * When "true", use built-in mock data (for local/dev/docs). Otherwise use `jobs` from API/parent.
262
+ */
263
+ mockData = false;
264
+ /** List of jobs to display. Pass as JSON string from attribute or as array via property (e.g. from React). Ignored when mock-data="true". */
265
+ jobs = [];
266
+ /** Show loading spinner. Ignored when mock-data="true" (mock shows data immediately). */
267
+ loading = false;
268
+ /** Total job count (for screen readers / schema). */
269
+ totalJob = 0;
270
+ noResultsLine1 = defaultNoResultsLine1;
271
+ noResultsLine2 = defaultNoResultsLine2;
272
+ applyButtonText = 'Apply Now';
273
+ showBrand = true;
274
+ showReference = false;
275
+ showEmploymentType = true;
276
+ streetFormat = '{street}, {city_state_abbr}';
277
+ multiLocationText = 'More locations';
278
+ remoteLocationText = 'Remote';
279
+ enableKilometers = false;
280
+ /** Extra CSS class on the root element (avoid prop name "class" / "classname" reserved). */
281
+ rootClass = '';
282
+ /** Template string for count display. Tokens: {count} = jobs on page, {total} = total from API. */
283
+ showCountText = '';
284
+ showSuggestions = false;
285
+ clearResultSuggestionsTitleText = 'Suggestions';
286
+ clearResultSuggestionsLine1 = 'Try different keywords';
287
+ clearResultSuggestionsLine2 = 'Make sure everything is spelled correctly';
288
+ clearResultSuggestionsLine3 = 'Try other locations';
289
+ clearResultSuggestionsLine4 = '';
290
+ /** When true, component manages its own data fetching */
291
+ autoFetch = false;
292
+ /** Jobs search endpoint */
293
+ apiUrl = '/api/get-jobs';
294
+ /** Comma-separated URL param names to watch and forward to the API */
295
+ watchParams = 'keyword';
296
+ fetchedJobs = [];
297
+ fetchedTotal = 0;
298
+ fetchLoading = false;
299
+ fetchComplete;
300
+ searchExecutedHandler;
301
+ popstateHandler;
302
+ connectedCallback() {
303
+ if (this.autoFetch) {
304
+ this.fetchJobs();
305
+ this.searchExecutedHandler = () => this.fetchJobs();
306
+ this.popstateHandler = () => this.fetchJobs();
307
+ document.addEventListener('search-executed', this.searchExecutedHandler);
308
+ window.addEventListener('popstate', this.popstateHandler);
309
+ }
310
+ }
311
+ disconnectedCallback() {
312
+ if (this.autoFetch) {
313
+ document.removeEventListener('search-executed', this.searchExecutedHandler);
314
+ window.removeEventListener('popstate', this.popstateHandler);
315
+ }
316
+ }
317
+ async fetchJobs() {
318
+ this.fetchLoading = true;
319
+ const params = new URLSearchParams(window.location.search);
320
+ const watchList = this.watchParams.split(',').map(p => p.trim()).filter(Boolean);
321
+ const query = new URLSearchParams();
322
+ for (const key of watchList) {
323
+ const val = params.get(key);
324
+ if (val !== null)
325
+ query.set(key, val);
326
+ }
327
+ const url = `${this.apiUrl}?${query.toString()}`;
328
+ try {
329
+ const res = await fetch(url, {
330
+ method: 'POST',
331
+ headers: { 'Content-Type': 'application/json' },
332
+ body: JSON.stringify({ disable_switch_search_mode: false }),
333
+ });
334
+ if (!res.ok)
335
+ throw new Error('fetch failed');
336
+ const data = await res.json();
337
+ this.fetchedJobs = data.jobs;
338
+ this.fetchedTotal = data.totalJob;
339
+ this.fetchComplete.emit({ jobs: data.jobs, totalJob: data.totalJob });
340
+ }
341
+ catch {
342
+ // preserve stale data, just stop loading
343
+ }
344
+ finally {
345
+ this.fetchLoading = false;
346
+ }
347
+ }
348
+ renderCountText(count, total) {
349
+ return this.showCountText
350
+ .replace('{count}', String(count))
351
+ .replace('{total}', String(total));
352
+ }
353
+ getJobsArray() {
354
+ if (this.mockData) {
355
+ return mockJobsListOnly;
356
+ }
357
+ if (this.autoFetch) {
358
+ return this.fetchedJobs;
359
+ }
360
+ const j = this.jobs;
361
+ if (Array.isArray(j))
362
+ return j;
363
+ if (typeof j === 'string') {
364
+ try {
365
+ const parsed = JSON.parse(j);
366
+ return Array.isArray(parsed) ? parsed : [];
367
+ }
368
+ catch {
369
+ return [];
370
+ }
371
+ }
372
+ return [];
373
+ }
374
+ renderJobItem(job, index$1) {
375
+ return (index.h("jobs-item", { job: job, index: index$1, applyButtonText: this.applyButtonText, showBrand: this.showBrand, showReference: this.showReference, showEmploymentType: this.showEmploymentType, multiLocationText: this.multiLocationText, remoteLocationText: this.remoteLocationText, enableKilometers: this.enableKilometers }));
376
+ }
377
+ render() {
378
+ const jobsArray = this.getJobsArray();
379
+ const loading = this.mockData ? false : (this.autoFetch ? this.fetchLoading : this.loading);
380
+ const totalJob = this.mockData
381
+ ? jobsArray.length
382
+ : this.autoFetch
383
+ ? this.fetchedTotal
384
+ : (this.totalJob || jobsArray.length);
385
+ const showNoResults = !loading && totalJob === 0 && !this.showSuggestions;
386
+ const showSuggestionsBlock = !loading && totalJob === 0 && this.showSuggestions;
387
+ return (index.h("div", { key: '1116855473d28d650641b9d962243bfcdcb434ec', class: `jobs-list-root ${this.rootClass}`.trim() }, index.h("div", { key: 'fcef04f1da9ad4e150af9f59921688f5781d9d43', class: "results-container" }, this.autoFetch && this.fetchLoading && (index.h("div", { key: '75b157c82c89691c7ce73d12ea0144b3b45485c3', class: "jobs-list-only__loading" }, "Loading...")), index.h("div", { key: 'b09f9879e10ee4a93e32177611912da5f19f3526', class: loading ? 'loader' : 'loader hide', "aria-hidden": !loading }), totalJob > 0 && this.showCountText && (index.h("p", { key: 'd10f800fb0a33d82531d5f1728bac4ceba2ed577', class: "jobs-list-only__count" }, this.renderCountText(jobsArray.length, totalJob))), totalJob > 0 && (index.h("div", { key: '18153ed1338bd48f7be4f043b11ce15e3271f27b', class: "card" }, index.h("ul", { key: '766e128b1fd5adb456530ae39e92ba8eb0b5d6cf', class: "results-list front" }, jobsArray.map((job, index) => this.renderJobItem(job, index))))), showNoResults && (index.h("div", { key: 'ed6f3d2bd2bbedabd6e69d508ea1425580e6941f', class: "share-jobs__no-results" }, index.h("h2", { key: '2302656e33340c69e84cb949afb7256b8f35f440' }, this.noResultsLine1), index.h("h3", { key: '1c7e6642441a96c04ee26883fdec4f81b0fe6cec' }, this.noResultsLine2))), showSuggestionsBlock && (index.h("div", { key: 'be7af85f64455918545e88952ca6ff00f0a970c5', class: "card primary-color" }, index.h("h4", { key: '2f63deb8131190eff882308544b15f767b6f3edc', class: "result-suggestions-title" }, this.clearResultSuggestionsTitleText, ":"), index.h("ul", { key: 'cb18daaa9e2c2c442c5b906ed370dcd653b5262d', class: "results-list front" }, index.h("li", { key: 'ff1d5c6518b75c0daa35b43df7162b0dfecde25e', class: "result-suggestions-line" }, this.clearResultSuggestionsLine1), index.h("li", { key: '4099fd7bf8dcf114eca28702a498ab0938f5de46', class: "result-suggestions-line" }, this.clearResultSuggestionsLine2), index.h("li", { key: 'fb65b54c3c0b14bc58112977eb4c7c56c1246a45', class: "result-suggestions-line" }, this.clearResultSuggestionsLine3), this.clearResultSuggestionsLine4 && (index.h("li", { key: '10f745e74cf68a2b1c42e6f49f810a8b59eb27b6', class: "result-suggestions-line" }, this.clearResultSuggestionsLine4))))))));
388
+ }
389
+ };
390
+ JobsListOnly.style = jobsListOnlyCss();
391
+
392
+ const jobsListReactiveCss = () => `jobs-list-reactive{display:block}jobs-list-reactive.loading{opacity:0.6;pointer-events:none}`;
393
+
394
+ const JobsListReactive = class {
395
+ constructor(hostRef) {
396
+ index.registerInstance(this, hostRef);
397
+ this.fetchComplete = index.createEvent(this, "fetchComplete");
398
+ }
399
+ get el() { return index.getElement(this); }
400
+ /** Jobs search endpoint */
401
+ apiUrl = '/api/get-jobs';
402
+ /** Comma-separated URL param names to watch and forward to the API */
403
+ watchParams = 'keyword,location_name';
404
+ /** CSS class added to container while fetching */
405
+ loadingClass = 'loading';
406
+ isLoading = false;
407
+ fetchComplete;
408
+ templateEl = null;
409
+ searchExecutedHandler;
410
+ popstateHandler;
411
+ connectedCallback() {
412
+ this.templateEl = this.el.querySelector('template');
413
+ this.searchExecutedHandler = () => this.fetchJobs();
414
+ this.popstateHandler = () => this.fetchJobs();
415
+ document.addEventListener('search-executed', this.searchExecutedHandler);
416
+ window.addEventListener('popstate', this.popstateHandler);
417
+ }
418
+ disconnectedCallback() {
419
+ document.removeEventListener('search-executed', this.searchExecutedHandler);
420
+ window.removeEventListener('popstate', this.popstateHandler);
421
+ }
422
+ buildQueryString() {
423
+ const urlParams = new URLSearchParams(window.location.search);
424
+ const watchList = this.watchParams.split(',').map(p => p.trim()).filter(Boolean);
425
+ const query = new URLSearchParams();
426
+ for (const key of watchList) {
427
+ const val = urlParams.get(key);
428
+ if (val !== null && val !== '') {
429
+ query.set(key, val);
430
+ }
431
+ }
432
+ return query.toString();
433
+ }
434
+ async fetchJobs() {
435
+ this.isLoading = true;
436
+ this.el.classList.add(this.loadingClass);
437
+ const queryString = this.buildQueryString();
438
+ const url = queryString ? `${this.apiUrl}?${queryString}` : this.apiUrl;
439
+ try {
440
+ const res = await fetch(url, {
441
+ method: 'POST',
442
+ headers: { 'Content-Type': 'application/json' },
443
+ body: JSON.stringify({ disable_switch_search_mode: false }),
444
+ });
445
+ if (!res.ok)
446
+ throw new Error('fetch failed');
447
+ const data = await res.json();
448
+ this.renderJobs(data.jobs);
449
+ this.updateCountElements(data.jobs.length, data.totalJob);
450
+ this.fetchComplete.emit({ jobs: data.jobs, totalJob: data.totalJob });
451
+ }
452
+ catch {
453
+ // Preserve stale data on error
454
+ }
455
+ finally {
456
+ this.isLoading = false;
457
+ this.el.classList.remove(this.loadingClass);
458
+ }
459
+ }
460
+ renderJobs(jobs) {
461
+ if (!this.templateEl)
462
+ return;
463
+ // Remove all children except the template
464
+ const children = Array.from(this.el.children);
465
+ for (const child of children) {
466
+ if (child !== this.templateEl) {
467
+ child.remove();
468
+ }
469
+ }
470
+ // Clone template and render each job
471
+ for (const job of jobs) {
472
+ const clone = this.templateEl.content.cloneNode(true);
473
+ const jobCard = clone.querySelector('job-card');
474
+ if (jobCard) {
475
+ jobCard.setAttribute('job', JSON.stringify(job));
476
+ }
477
+ this.el.appendChild(clone);
478
+ }
479
+ }
480
+ updateCountElements(count, total) {
481
+ const countEls = document.querySelectorAll('[data-job-count]');
482
+ const totalEls = document.querySelectorAll('[data-job-total]');
483
+ countEls.forEach(el => {
484
+ el.textContent = String(count);
485
+ });
486
+ totalEls.forEach(el => {
487
+ el.textContent = String(total);
488
+ });
489
+ }
490
+ render() {
491
+ return index.h("slot", { key: '30a6fe9727eb877b6aafb99072c40811df121ba6' });
492
+ }
493
+ };
494
+ JobsListReactive.style = jobsListReactiveCss();
495
+
496
+ exports.fast_input = FastInput;
497
+ exports.jobs_item = JobsItem;
498
+ exports.jobs_list_only = JobsListOnly;
499
+ exports.jobs_list_reactive = JobsListReactive;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const NAMESPACE = 'web-component-poc';
4
- const BUILD = /* web-component-poc */ { hotModuleReplacement: false, hydratedSelectorName: "hydrated", lazyLoad: true, prop: true, propChangeCallback: false, shadowDom: false, slotRelocation: true, updatable: true};
4
+ const BUILD = /* web-component-poc */ { hotModuleReplacement: false, hydratedSelectorName: "hydrated", lazyLoad: true, propChangeCallback: false, shadowDom: false, slotRelocation: true, state: true, updatable: true};
5
5
 
6
6
  /*
7
7
  Stencil Client Platform v4.43.2 | MIT Licensed | https://stenciljs.com
@@ -88,7 +88,7 @@ var registerInstance = (lazyInstance, hostRef) => {
88
88
  if (!hostRef) return;
89
89
  lazyInstance.__stencil__getHostRef = () => hostRef;
90
90
  hostRef.$lazyInstance$ = lazyInstance;
91
- if (hostRef.$cmpMeta$.$flags$ & 512 /* hasModernPropertyDecls */ && (BUILD.prop)) {
91
+ if (hostRef.$cmpMeta$.$flags$ & 512 /* hasModernPropertyDecls */ && (BUILD.state)) {
92
92
  reWireGetterSetter(lazyInstance, hostRef);
93
93
  }
94
94
  };