@arbetsformedlingen/yrkesvaljaren 2.0.12 → 2.2.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/README.md +52 -21
- package/dist/cjs/{af-validation-message-Cy89nVEv.js → af-validation-message-BdR9X_qh.js} +1 -1
- package/dist/cjs/core-selector.cjs.entry.js +342 -23
- package/dist/cjs/digi-service-job-selector.cjs.entry.js +352 -61
- package/dist/cjs/{index-hZgOvC17.js → index-DMQDFAL7.js} +0 -22
- package/dist/cjs/index.cjs.js +4 -7
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/{esm/fuse-BPnhMTul.js → cjs/types-DdzCbiye.js} +965 -1
- package/dist/cjs/yrkesvaljaren.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +0 -1
- package/dist/collection/components/core-selector/core-selector.css +70 -49
- package/dist/collection/components/core-selector/core-selector.js +309 -14
- package/dist/collection/components/design-compat/af-icon.js +8 -7
- package/dist/collection/components/job-selector/job-selector-controller.js +13 -3
- package/dist/collection/components/job-selector/job-selector.css +188 -34
- package/dist/collection/components/job-selector/job-selector.js +199 -10
- package/dist/components/core-selector2.js +1 -1
- package/dist/components/digi-service-job-selector.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/types.js +1 -1
- package/dist/esm/{af-validation-message-BgoGzzBf.js → af-validation-message-DMoOu-0k.js} +1 -1
- package/dist/esm/core-selector.entry.js +342 -23
- package/dist/esm/digi-service-job-selector.entry.js +310 -19
- package/dist/esm/{index-HNd02eQb.js → index-vJ-tamti.js} +1 -22
- package/dist/esm/index.js +2 -4
- package/dist/esm/loader.js +3 -3
- package/dist/{cjs/fuse-BTLNKxuL.js → esm/types-DVos4HHS.js} +948 -2
- package/dist/esm/yrkesvaljaren.js +3 -3
- package/dist/types/components/core-selector/core-selector.d.ts +68 -0
- package/dist/types/components/job-selector/job-selector-controller.d.ts +5 -0
- package/dist/types/components/job-selector/job-selector.d.ts +21 -3
- package/dist/types/components/job-selector/types.d.ts +12 -0
- package/dist/types/components.d.ts +20 -99
- package/dist/types/index.d.ts +1 -1
- package/dist/vendor/taxonomy-core/af-data-layer.d.ts +16 -0
- package/dist/vendor/taxonomy-core/af-data-layer.js +24 -0
- package/dist/vendor/taxonomy-core/index.d.ts +1 -1
- package/dist/vendor/taxonomy-core/index.js +1 -1
- package/dist/vendor/taxonomy-core/pii-sanitizer.d.ts +25 -0
- package/dist/vendor/taxonomy-core/pii-sanitizer.js +137 -0
- package/dist/vendor/taxonomy-core/selector-navigation.d.ts +9 -1
- package/dist/vendor/taxonomy-core/selector-navigation.js +28 -1
- package/dist/vendor/taxonomy-core/selector-types.d.ts +12 -0
- package/dist/yrkesvaljaren/index.esm.js +1 -1
- package/dist/yrkesvaljaren/p-0f19a308.entry.js +1 -0
- package/dist/yrkesvaljaren/{p-BUviBbwX.js → p-DHK95AvZ.js} +1 -1
- package/dist/yrkesvaljaren/p-DVos4HHS.js +1 -0
- package/dist/yrkesvaljaren/p-b81496c8.entry.js +1 -0
- package/dist/yrkesvaljaren/p-vJ-tamti.js +3 -0
- package/dist/yrkesvaljaren/yrkesvaljaren.esm.js +1 -1
- package/package.json +12 -10
- package/dist/cjs/geo-valjaren.cjs.entry.js +0 -14910
- package/dist/cjs/job-selector-demo.cjs.entry.js +0 -690
- package/dist/cjs/neobrutal-search.cjs.entry.js +0 -171
- package/dist/cjs/search.engine-D4cpbVzd.js +0 -504
- package/dist/cjs/taxonomy-registry-Dzt0SPzT.js +0 -454
- package/dist/cjs/types-CtHBl6Ra.js +0 -14
- package/dist/collection/components/geovaljaren/geovaljaren.css +0 -21
- package/dist/collection/components/geovaljaren/geovaljaren.js +0 -304
- package/dist/collection/components/geovaljaren/logic/adapter.utils.js +0 -20
- package/dist/collection/components/geovaljaren/logic/data.utils.js +0 -12
- package/dist/collection/components/geovaljaren/logic/history-service.js +0 -25
- package/dist/collection/components/geovaljaren/logic/search.engine.js +0 -28
- package/dist/collection/verkstad/verkstad.js +0 -408
- package/dist/components/fuse.js +0 -1
- package/dist/components/geo-valjaren.d.ts +0 -11
- package/dist/components/geo-valjaren.js +0 -1
- package/dist/components/job-selector-demo.d.ts +0 -11
- package/dist/components/job-selector-demo.js +0 -1
- package/dist/components/job-selector.js +0 -1
- package/dist/components/neobrutal-search.d.ts +0 -11
- package/dist/components/neobrutal-search.js +0 -1
- package/dist/components/search.engine.js +0 -1
- package/dist/esm/geo-valjaren.entry.js +0 -14908
- package/dist/esm/job-selector-demo.entry.js +0 -688
- package/dist/esm/neobrutal-search.entry.js +0 -169
- package/dist/esm/search.engine-BaWUTc3r.js +0 -493
- package/dist/esm/taxonomy-registry-C-pSh51L.js +0 -449
- package/dist/esm/types-DHUftoZJ.js +0 -12
- package/dist/types/components/geovaljaren/geovaljaren.d.ts +0 -24
- package/dist/types/components/geovaljaren/logic/adapter.utils.d.ts +0 -7
- package/dist/types/components/geovaljaren/logic/data.utils.d.ts +0 -7
- package/dist/types/components/geovaljaren/logic/history-service.d.ts +0 -6
- package/dist/types/components/geovaljaren/logic/search.engine.d.ts +0 -7
- package/dist/types/components/job-selector-demo/job-selector-demo.d.ts +0 -65
- package/dist/types/components/neobrutal-search/neobrutal-search.d.ts +0 -18
- package/dist/types/verkstad/verkstad.d.ts +0 -1
- package/dist/types/vitest-globals.d.ts +0 -1
- package/dist/yrkesvaljaren/p-5c3a5308.entry.js +0 -1
- package/dist/yrkesvaljaren/p-9ecd5177.entry.js +0 -1
- package/dist/yrkesvaljaren/p-BPnhMTul.js +0 -1
- package/dist/yrkesvaljaren/p-C-pSh51L.js +0 -1
- package/dist/yrkesvaljaren/p-CjMoDiZD.js +0 -1
- package/dist/yrkesvaljaren/p-DHUftoZJ.js +0 -1
- package/dist/yrkesvaljaren/p-HNd02eQb.js +0 -3
- package/dist/yrkesvaljaren/p-b6130085.entry.js +0 -1
- package/dist/yrkesvaljaren/p-dbbea724.entry.js +0 -1
- package/dist/yrkesvaljaren/p-df3fa43b.entry.js +0 -1
|
@@ -1,11 +1,146 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
var index = require('./index-DMQDFAL7.js');
|
|
4
|
+
var types = require('./types-DdzCbiye.js');
|
|
5
|
+
var afValidationMessage = require('./af-validation-message-BdR9X_qh.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* PII-sanitering för fritext och användarförslag.
|
|
9
|
+
*
|
|
10
|
+
* Tvättar bort personnummer, e-post, webbadresser, telefonnummer, kontonummer,
|
|
11
|
+
* gatu- och postadresser och personnamnsfraser från förslagstermer och motiveringar innan de
|
|
12
|
+
* emitteras till värdappen. Mönstertvätt minskar risk men garanterar inte anonymitet.
|
|
13
|
+
*/
|
|
14
|
+
const MAX_TERM_LENGTH = 120;
|
|
15
|
+
const MAX_MOTIVATION_LENGTH = 160;
|
|
16
|
+
/** Maskar svenska personnummer och samordningsnummer, även med fel kontrollsiffra. */
|
|
17
|
+
function sanitizePersonalIdentityNumbers(text) {
|
|
18
|
+
return text.replace(/\b(?:(?:19|20)\d{2}|\d{2})(?:0[1-9]|1[0-2])(?:0[1-9]|[1-2][0-9]|3[0-1]|6[1-9]|[7-8][0-9]|9[0-1]) ?[-+]? ?\d{4}\b/g, '[personnummer]');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sanerar e-postadresser, även med svenska tecken.
|
|
22
|
+
*/
|
|
23
|
+
function sanitizeEmails(text) {
|
|
24
|
+
return text.replace(/(?<![\p{L}\p{N}._%+-])[\p{L}\p{N}._%+-]+@(?:[\p{L}\p{N}-]+\.)+\p{L}{2,}(?![\p{L}\p{N}])/gu, '[e-post]');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sanerar webbadresser och profiler (t.ex. LinkedIn, Facebook).
|
|
28
|
+
*/
|
|
29
|
+
function sanitizeUrls(text) {
|
|
30
|
+
return text
|
|
31
|
+
.replace(/\b(?:https?:\/\/|www\.)\S+/gi, '[url]')
|
|
32
|
+
// Utan i-flagga, så att t.ex. "ASP.NET/Core" inte tolkas som domänen asp.net.
|
|
33
|
+
.replace(/\b[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:se|com|nu|org|net|io|eu|info)\/\S*/g, '[url]');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sanerar svenska telefonnummer (mobil, fasta nät, internationellt format).
|
|
37
|
+
*/
|
|
38
|
+
function sanitizePhoneNumbers(text) {
|
|
39
|
+
// Hantera internationellt riktnummer och valfri svensk nolla först.
|
|
40
|
+
const international = /(?:\+46|\b0046|\b46)[ .-]*(?:\(0\)[ .-]*)?[1-9](?:[ ./-]*\d){6,9}\b/g;
|
|
41
|
+
let result = text.replace(international, '[telefonnummer]');
|
|
42
|
+
// Riktnummer inom parentes, t.ex. (08) 123 456 78.
|
|
43
|
+
const parenthesized = /\(0\d{1,3}\)[ .-]*\d(?:[ ./-]*\d){4,7}\b/g;
|
|
44
|
+
result = result.replace(parenthesized, '[telefonnummer]');
|
|
45
|
+
// Ett svenskt nummer börjar med 0 och innehåller 8–11 siffror totalt.
|
|
46
|
+
// Datumformen dd.mm.åååå och dd/mm/åå ska inte tolkas som telefonnummer.
|
|
47
|
+
const domestic = /\b(?!\d{1,2}[./]\d{1,2}[./]\d{2,4}\b)0[1-9](?:[ ./-]*\d){6,9}\b/g;
|
|
48
|
+
result = result.replace(domestic, '[telefonnummer]');
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
/** Sanerar svenska IBAN-nummer, med eller utan mellanslag. */
|
|
52
|
+
function sanitizeIban(text) {
|
|
53
|
+
return text.replace(/\bSE ?\d{2}(?: ?\d{4}){5}\b/gi, '[kontonummer]');
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sanerar kontonummer och andra långa nummerserier (8 siffror eller fler).
|
|
57
|
+
* Årtal, ISO-standarder och yrkeskoder har färre siffror och berörs inte.
|
|
58
|
+
*/
|
|
59
|
+
function sanitizeLongNumbers(text) {
|
|
60
|
+
return text
|
|
61
|
+
// Inget komma som avgränsare ("ISO 9001,14001"), och datumformerna ÅÅÅÅ-MM-DD och dd.mm.åååå undantas.
|
|
62
|
+
.replace(/(?<![\p{L}\p{N}])(?!\d{4}-\d{2}-\d{2}(?!\p{N})|\d{1,2}[./]\d{1,2}[./]\d{2,4}(?!\p{N}))\d(?:[ .-]?\d){7,}(?![\p{N}])/gu, '[nummer]');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Sanerar gatuadresser (t.ex. Storgatan 12, Sveavägen 44 B, Södra vägen 5) och postadresser (111 22 Stockholm).
|
|
66
|
+
* Ord som "plan", "platsen" och "backen" ingår inte, eftersom de ger falska träffar som "Läroplan 2011".
|
|
67
|
+
*/
|
|
68
|
+
function sanitizeAddresses(text) {
|
|
69
|
+
const suffixes = 'gatan|vägen|gränd|stigen|allén|torget|gata';
|
|
70
|
+
const streetPattern = new RegExp(`(?<![\\p{L}\\p{N}_])(?:\\p{L}+(?:${suffixes})|\\p{L}+\\s+(?:${suffixes}))\\s+\\d{1,4}(?:\\s?[A-Za-z])?(?![\\p{L}\\p{N}_])`, 'giu');
|
|
71
|
+
// Vanliga enheter efter ett femsiffrigt tal ("12000 Kronor") är inte postorter.
|
|
72
|
+
const postalPattern = /\b\d{3} ?\d{2}\s+(?!(?:[Kk]r|[Kk]ronor|SEK|[Ee]uro|[Tt]immar|[Ss]tycken|[Ss]t)(?![\p{L}]))[A-ZÅÄÖ]\p{Ll}+/gu;
|
|
73
|
+
return text.replace(streetPattern, '[adress]').replace(postalPattern, '[postadress]');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Maskerar personnamnsfraser (t.ex. "Jag heter Anna Karlsson", "Mitt namn är Anna-Karin Ek", "Mvh Anna").
|
|
77
|
+
* "Heter" ensamt och "Jag är" ingår inte: de träffar yrken, kurser och organisationer.
|
|
78
|
+
*/
|
|
79
|
+
function sanitizeNamePhrases(text) {
|
|
80
|
+
const name = '[A-ZÅÄÖÉ]\\p{Ll}+(?:-[A-ZÅÄÖÉ]\\p{Ll}+)?';
|
|
81
|
+
const boundary = '(?<![\\p{L}\\p{N}_])';
|
|
82
|
+
const end = '(?![\\p{L}\\p{N}_])';
|
|
83
|
+
const introPattern = new RegExp(`${boundary}((?:[Jj]ag\\s+heter|[Mm]itt\\s+(?:för|efter)?namn\\s+(?:är|e)|[Mm]vh|[Hh]älsningar|[Vv]änliga\\s+hälsningar|[Mm]ed\\s+vänlig\\s+hälsning)[,:]?\\s+)${name}(?:\\s+${name})?${end}`, 'gu');
|
|
84
|
+
return text.replace(introPattern, (_match, prefix) => `${prefix}[namn]`);
|
|
85
|
+
}
|
|
86
|
+
function normalizeText(text) {
|
|
87
|
+
return text
|
|
88
|
+
.normalize('NFKC')
|
|
89
|
+
.replace(/[\u00AD\u200B-\u200D\u2060\uFEFF]/g, '')
|
|
90
|
+
.replace(/[\u2010-\u2015\u2212\uFE58\uFE63\uFF0D]/g, '-')
|
|
91
|
+
.replace(/\s+/g, ' ')
|
|
92
|
+
.trim();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Sant bara för uppgifter som alltid är personuppgifter: personnummer, e-post, telefonnummer och IBAN.
|
|
96
|
+
* Då ska texten stoppas. Osäkrare mönster (namnfraser, adresser, webbadresser, långa nummer)
|
|
97
|
+
* maskeras av sanitizePiiText i stället, så att användaren inte stoppas av falska träffar.
|
|
98
|
+
*/
|
|
99
|
+
function containsPii(text) {
|
|
100
|
+
const normalized = normalizeText(text);
|
|
101
|
+
let masked = sanitizeEmails(normalized);
|
|
102
|
+
masked = sanitizeIban(masked);
|
|
103
|
+
masked = sanitizePersonalIdentityNumbers(masked);
|
|
104
|
+
masked = sanitizePhoneNumbers(masked);
|
|
105
|
+
return masked !== normalized;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Sanerar en enskild textsträng från PII (personnummer, e-post, telefon, adresser, namninledningar).
|
|
109
|
+
*/
|
|
110
|
+
function sanitizePiiText(text, maxLength = MAX_MOTIVATION_LENGTH) {
|
|
111
|
+
if (!text || typeof text !== 'string')
|
|
112
|
+
return '';
|
|
113
|
+
let sanitized = normalizeText(text);
|
|
114
|
+
if (sanitized.length === 0)
|
|
115
|
+
return '';
|
|
116
|
+
sanitized = sanitizeUrls(sanitized);
|
|
117
|
+
sanitized = sanitizeEmails(sanitized);
|
|
118
|
+
sanitized = sanitizeIban(sanitized);
|
|
119
|
+
sanitized = sanitizePersonalIdentityNumbers(sanitized);
|
|
120
|
+
sanitized = sanitizePhoneNumbers(sanitized);
|
|
121
|
+
sanitized = sanitizeLongNumbers(sanitized);
|
|
122
|
+
sanitized = sanitizeAddresses(sanitized);
|
|
123
|
+
sanitized = sanitizeNamePhrases(sanitized);
|
|
124
|
+
// Normalisera multipla mellanslag
|
|
125
|
+
sanitized = sanitized.replace(/\s+/g, ' ').trim();
|
|
126
|
+
// Begränsa maxlängd
|
|
127
|
+
if (sanitized.length > maxLength) {
|
|
128
|
+
sanitized = sanitized.slice(0, maxLength).trim();
|
|
129
|
+
}
|
|
130
|
+
return sanitized;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Sanerar ett förslagsord/termer (max 120 tecken).
|
|
134
|
+
*/
|
|
135
|
+
function sanitizeSuggestionTerm(term) {
|
|
136
|
+
return sanitizePiiText(term, MAX_TERM_LENGTH);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Sanerar en förslagsmotivering (max 160 tecken).
|
|
140
|
+
*/
|
|
141
|
+
function sanitizeSuggestionMotivation(motivation) {
|
|
142
|
+
return sanitizePiiText(motivation, MAX_MOTIVATION_LENGTH);
|
|
143
|
+
}
|
|
9
144
|
|
|
10
145
|
let memoryCache = null;
|
|
11
146
|
const HistoryService = {
|
|
@@ -13,10 +148,10 @@ const HistoryService = {
|
|
|
13
148
|
memoryCache = history; // Omedelbar uppdatering av UI-state
|
|
14
149
|
try {
|
|
15
150
|
localStorage.setItem('job-selector_history', JSON.stringify(history));
|
|
16
|
-
|
|
151
|
+
types.log.debug('[HistoryService] saveHistory - History saved.');
|
|
17
152
|
}
|
|
18
153
|
catch (e) {
|
|
19
|
-
|
|
154
|
+
types.log.error('Kunde inte spara historik.', e);
|
|
20
155
|
}
|
|
21
156
|
},
|
|
22
157
|
loadHistory() {
|
|
@@ -31,7 +166,7 @@ const HistoryService = {
|
|
|
31
166
|
}
|
|
32
167
|
}
|
|
33
168
|
catch (e) {
|
|
34
|
-
|
|
169
|
+
types.log.error('Kunde inte läsa historik.', e);
|
|
35
170
|
}
|
|
36
171
|
memoryCache = [];
|
|
37
172
|
return memoryCache;
|
|
@@ -40,10 +175,10 @@ const HistoryService = {
|
|
|
40
175
|
memoryCache = [];
|
|
41
176
|
try {
|
|
42
177
|
localStorage.removeItem('job-selector_history');
|
|
43
|
-
|
|
178
|
+
types.log.debug('[HistoryService] clearHistory - History cleared.');
|
|
44
179
|
}
|
|
45
180
|
catch (e) {
|
|
46
|
-
|
|
181
|
+
types.log.error('Kunde inte rensa historik.', e);
|
|
47
182
|
}
|
|
48
183
|
}
|
|
49
184
|
};
|
|
@@ -51,6 +186,8 @@ const HistoryService = {
|
|
|
51
186
|
class JobSelectorController {
|
|
52
187
|
callbacks;
|
|
53
188
|
config;
|
|
189
|
+
/** Förslagen från den senaste sökningen som kortades av vid maxResults. */
|
|
190
|
+
cappedResults;
|
|
54
191
|
state = { status: 'loading' };
|
|
55
192
|
taxonomyData = [];
|
|
56
193
|
popularItems = [];
|
|
@@ -84,12 +221,12 @@ class JobSelectorController {
|
|
|
84
221
|
if (this.taxonomyData.length > 0)
|
|
85
222
|
return this.taxonomyData;
|
|
86
223
|
// Try to fetch from registry (handles late registration)
|
|
87
|
-
const registeredData =
|
|
224
|
+
const registeredData = types.getRegisteredTaxonomy();
|
|
88
225
|
if (registeredData && registeredData.length > 0) {
|
|
89
|
-
|
|
226
|
+
types.log.debug('[Controller] getTaxonomyData - Late initializing from registry');
|
|
90
227
|
this.taxonomyData = registeredData;
|
|
91
228
|
this.popularItems = this.computePopularItems(this.taxonomyData);
|
|
92
|
-
this.searchEngine = new
|
|
229
|
+
this.searchEngine = new types.TaxonomySearchEngine(this.taxonomyData);
|
|
93
230
|
}
|
|
94
231
|
return this.taxonomyData;
|
|
95
232
|
}
|
|
@@ -105,15 +242,15 @@ class JobSelectorController {
|
|
|
105
242
|
}
|
|
106
243
|
// --- INITIALIZATION ---
|
|
107
244
|
async initialize(initialData) {
|
|
108
|
-
|
|
245
|
+
types.log.debug('[Controller] initialize - START', { hasInitialData: !!initialData });
|
|
109
246
|
this.updateState({ status: 'loading' });
|
|
110
|
-
const registeredData = (initialData && initialData.length > 0) ? initialData :
|
|
247
|
+
const registeredData = (initialData && initialData.length > 0) ? initialData : types.getRegisteredTaxonomy();
|
|
111
248
|
if (registeredData && registeredData.length > 0) {
|
|
112
|
-
|
|
249
|
+
types.log.debug('[Controller] initialize - Loaded taxonomy from registry');
|
|
113
250
|
this.setStateToActive(registeredData, 'registry', new Date().toISOString());
|
|
114
251
|
}
|
|
115
252
|
else {
|
|
116
|
-
|
|
253
|
+
types.log.warn('[Controller] initialize - No taxonomy found in registry. Has registerTaxonomy() been called?');
|
|
117
254
|
this.updateState({ status: 'error', message: 'Kunde inte hitta yrkesdata. Kontrollera att komponenten är initierad korrekt.' });
|
|
118
255
|
}
|
|
119
256
|
}
|
|
@@ -124,7 +261,7 @@ class JobSelectorController {
|
|
|
124
261
|
this.taxonomyData = data;
|
|
125
262
|
this.popularItems = this.computePopularItems(this.taxonomyData);
|
|
126
263
|
// NEW: Initialize the separated SearchEngine
|
|
127
|
-
this.searchEngine = new
|
|
264
|
+
this.searchEngine = new types.TaxonomySearchEngine(this.taxonomyData);
|
|
128
265
|
// OLD: this.fuseInstance = new Fuse(this.taxonomyData, FUSE_OPTIONS);
|
|
129
266
|
const commonState = { dataSource: source, dataSourceDate: sourceDate };
|
|
130
267
|
if (this.config.enableMultiple) {
|
|
@@ -143,7 +280,7 @@ class JobSelectorController {
|
|
|
143
280
|
// --- SEARCH ---
|
|
144
281
|
handleInput(value) {
|
|
145
282
|
this.isTouched = true;
|
|
146
|
-
|
|
283
|
+
types.log.debug('[Controller] handleInput - Value:', value);
|
|
147
284
|
// Reset validation on input
|
|
148
285
|
const wasInError = this.state.validation === 'error';
|
|
149
286
|
const validationContext = wasInError || this.state.validationContext === 'from-error' ? 'from-error' : undefined;
|
|
@@ -219,7 +356,7 @@ class JobSelectorController {
|
|
|
219
356
|
}
|
|
220
357
|
}
|
|
221
358
|
if (value.length >= this.config.minLength) {
|
|
222
|
-
this.debounceTimer = setTimeout(() => this.performSearch(value),
|
|
359
|
+
this.debounceTimer = setTimeout(() => this.performSearch(value), types.DEBOUNCE_TIME);
|
|
223
360
|
}
|
|
224
361
|
}
|
|
225
362
|
performSearch(value) {
|
|
@@ -228,8 +365,11 @@ class JobSelectorController {
|
|
|
228
365
|
switch (this.state.status) {
|
|
229
366
|
case 'searching':
|
|
230
367
|
case 'multiSelect': {
|
|
231
|
-
|
|
232
|
-
const
|
|
368
|
+
// En träff extra visar om det finns fler än som visas ("Minst N förslag").
|
|
369
|
+
const limit = this.config.maxResults;
|
|
370
|
+
const genericResults = this.searchEngine.searchAsGeneric(value, limit + 1);
|
|
371
|
+
const results = genericResults.slice(0, limit).flatMap(g => g.metadata?.originalResult ? [g.metadata.originalResult] : []);
|
|
372
|
+
this.cappedResults = genericResults.length > limit ? results : undefined;
|
|
233
373
|
// Do not filter out selected items here - allow UI to handle grey-out
|
|
234
374
|
this.updateState({ ...this.state, suggestions: results });
|
|
235
375
|
break;
|
|
@@ -254,15 +394,15 @@ class JobSelectorController {
|
|
|
254
394
|
const historyItems = HistoryService.loadHistory();
|
|
255
395
|
// Clone item and reset highlightedLabel to displayLabel (removes bolding)
|
|
256
396
|
// AND apply grey styling to parenthesis (via DisplaySegments)
|
|
257
|
-
const unhighlightedSegments =
|
|
397
|
+
const unhighlightedSegments = types.LabelFormatter.format(item.rawLabel, '', item.occupationLabel);
|
|
258
398
|
const historyItem = {
|
|
259
399
|
...item,
|
|
260
400
|
displaySegments: unhighlightedSegments,
|
|
261
401
|
// Legacy support: construct HTML string for fallback
|
|
262
|
-
highlightedLabel:
|
|
402
|
+
highlightedLabel: types.segmentsToHtml(unhighlightedSegments)
|
|
263
403
|
};
|
|
264
404
|
// Filter out existing item with same ID (to move it to top)
|
|
265
|
-
const filtered = historyItems.filter((h) => !
|
|
405
|
+
const filtered = historyItems.filter((h) => !types.isSameSearchResult(h, historyItem));
|
|
266
406
|
// Add to top and limit
|
|
267
407
|
const newHistory = [historyItem, ...filtered].slice(0, this.config.maxHistoryItems);
|
|
268
408
|
HistoryService.saveHistory(newHistory);
|
|
@@ -271,7 +411,7 @@ class JobSelectorController {
|
|
|
271
411
|
HistoryService.clearHistory();
|
|
272
412
|
this.showHistory(true);
|
|
273
413
|
}
|
|
274
|
-
computePopularItems(data, limit = this.config.maxResults ||
|
|
414
|
+
computePopularItems(data, limit = this.config.maxResults || types.MAX_RESULTS) {
|
|
275
415
|
if (!data || data.length === 0)
|
|
276
416
|
return [];
|
|
277
417
|
const hasWeights = data.some(t => typeof t.weight === 'number' && t.weight > 0);
|
|
@@ -317,7 +457,8 @@ class JobSelectorController {
|
|
|
317
457
|
const validatedHistory = displayItems.filter((item) => {
|
|
318
458
|
// 1. Check if it's a ManualInput item
|
|
319
459
|
if (item.type === 'ManualInput') {
|
|
320
|
-
|
|
460
|
+
// Fritext från historiken visas bara när integratören tillåter fritext.
|
|
461
|
+
return this.config.manualInput === true;
|
|
321
462
|
}
|
|
322
463
|
// 2. Check if it's a valid Taxonomy item (must exist in current data)
|
|
323
464
|
// Note: We use this.taxonomyData which is already loaded
|
|
@@ -325,11 +466,11 @@ class JobSelectorController {
|
|
|
325
466
|
return exists;
|
|
326
467
|
});
|
|
327
468
|
const filteredHistory = validatedHistory.map((item) => {
|
|
328
|
-
const unhighlightedSegments =
|
|
469
|
+
const unhighlightedSegments = types.LabelFormatter.format(item.rawLabel, '', item.occupationLabel);
|
|
329
470
|
return {
|
|
330
471
|
...item,
|
|
331
472
|
displaySegments: unhighlightedSegments,
|
|
332
|
-
highlightedLabel:
|
|
473
|
+
highlightedLabel: types.segmentsToHtml(unhighlightedSegments)
|
|
333
474
|
};
|
|
334
475
|
});
|
|
335
476
|
const { dataSource, dataSourceDate } = this.getCommonState();
|
|
@@ -374,7 +515,7 @@ class JobSelectorController {
|
|
|
374
515
|
}
|
|
375
516
|
// --- SELECTION ---
|
|
376
517
|
selectItem(item) {
|
|
377
|
-
|
|
518
|
+
types.log.debug('[Controller] selectItem', item);
|
|
378
519
|
// Add to history
|
|
379
520
|
this.isTouched = true;
|
|
380
521
|
this.addToHistory(item);
|
|
@@ -390,7 +531,7 @@ class JobSelectorController {
|
|
|
390
531
|
const dataSourceDate = 'dataSourceDate' in this.state ? this.state.dataSourceDate : undefined;
|
|
391
532
|
const currentSelected = 'selectedItems' in this.state ? this.state.selectedItems : [];
|
|
392
533
|
// Prevent duplicates
|
|
393
|
-
const existingIndex = currentSelected.findIndex(existing =>
|
|
534
|
+
const existingIndex = currentSelected.findIndex(existing => types.isSameSearchResult(existing, item));
|
|
394
535
|
if (existingIndex > -1) {
|
|
395
536
|
// Already selected - skip to avoid double addition or accidental removal in this context
|
|
396
537
|
return;
|
|
@@ -453,7 +594,7 @@ class JobSelectorController {
|
|
|
453
594
|
}
|
|
454
595
|
default: {
|
|
455
596
|
const _exhaustive = this.state;
|
|
456
|
-
|
|
597
|
+
types.log.warn('[Controller] selectItem - Unexpected state:', _exhaustive);
|
|
457
598
|
}
|
|
458
599
|
}
|
|
459
600
|
this.runValidation();
|
|
@@ -479,7 +620,7 @@ class JobSelectorController {
|
|
|
479
620
|
switch (this.state.status) {
|
|
480
621
|
case 'multiSelect':
|
|
481
622
|
case 'multiSelectShowingHistory': {
|
|
482
|
-
const newItems = this.state.selectedItems.filter(i => !
|
|
623
|
+
const newItems = this.state.selectedItems.filter(i => !types.isSameSearchResult(i, item));
|
|
483
624
|
this.isTouched = true;
|
|
484
625
|
this.updateState({ ...this.state, selectedItems: newItems });
|
|
485
626
|
this.callbacks.onEmitSelection(newItems.map(i => this.toPublicSelection(i)));
|
|
@@ -816,7 +957,7 @@ class JobSelectorController {
|
|
|
816
957
|
};
|
|
817
958
|
}
|
|
818
959
|
toPublicSelection(item) {
|
|
819
|
-
return
|
|
960
|
+
return types.TaxonomyAdapter.toPublicSelection(item);
|
|
820
961
|
}
|
|
821
962
|
createManualInputItem(value) {
|
|
822
963
|
return {
|
|
@@ -854,6 +995,10 @@ class JobSelectorController {
|
|
|
854
995
|
this.selectItem(this.createManualInputItem(value));
|
|
855
996
|
}
|
|
856
997
|
}
|
|
998
|
+
/** Om sökningen bakom just dessa förslag hittade fler träffar än som visas. */
|
|
999
|
+
hasMoreResults(suggestions) {
|
|
1000
|
+
return !!this.cappedResults && suggestions === this.cappedResults;
|
|
1001
|
+
}
|
|
857
1002
|
loadMore() {
|
|
858
1003
|
// Increment maxResults or handle paging if supported by searchEngine
|
|
859
1004
|
this.config.maxResults += 10;
|
|
@@ -884,22 +1029,22 @@ class JobSelectorController {
|
|
|
884
1029
|
const YV_LATEST_DATA_URL = 'https://d3hng02m5bee8m.cloudfront.net/yrkesvaljaren/latest.json';
|
|
885
1030
|
async function loadTaxonomy({ taxonomyUrl, fetcher = (url) => fetch(url), }) {
|
|
886
1031
|
const dataUrl = taxonomyUrl ?? YV_LATEST_DATA_URL;
|
|
887
|
-
|
|
1032
|
+
types.log.debug(`[JobSelector] Hämtar yrkesdata från: ${dataUrl}`);
|
|
888
1033
|
const response = await fetcher(dataUrl);
|
|
889
1034
|
if (!response.ok) {
|
|
890
1035
|
throw new Error(`Kunde inte ladda yrkesdata från ${dataUrl}: ${response.status} ${response.statusText}`);
|
|
891
1036
|
}
|
|
892
1037
|
const data = await response.json();
|
|
893
|
-
if (!
|
|
1038
|
+
if (!types.isTaxonomyRegistration(data)) {
|
|
894
1039
|
throw new Error('Yrkesdatan har ett ogiltigt format.');
|
|
895
1040
|
}
|
|
896
1041
|
return data;
|
|
897
1042
|
}
|
|
898
1043
|
|
|
899
|
-
const jobSelectorCss = () => `:host{--digi--grayscale-0:#ffffff;--digi--grayscale-50:#fbfbfb;--digi--grayscale-100:#f4f4f4;--digi--grayscale-200:#ededed;--digi--grayscale-300:#e4e4e4;--digi--grayscale-400:#dddddd;--digi--grayscale-500:#cacaca;--digi--grayscale-600:#acacac;--digi--grayscale-700:#757575;--digi--grayscale-800:#5c5c5c;--digi--grayscale-900:#333333;--digi--grayscale-1000:#000000;--digi--global--color--cta--link--base:#1616b2;--digi--global--color--function--danger--base:#da0000;--digi--global--color--function--success--base:#008a20;--digi--global--color--function--success--lightest-3:#d4edda;--digi--global--color--function--warning--base:#ffe200;--digi--color--text--primary:var(--digi--grayscale-900);--digi--color--text--secondary:var(--digi--grayscale-700);--digi--color--text--link:var(--digi--global--color--cta--link--base);--digi--color--icons--success:var(--digi--global--color--function--success--base);--digi--color--icons--warning:#8a7a00;--digi--color--icons--danger:var(--digi--global--color--function--danger--base);--digi--global--typography--font-family--default:"Open Sans", Arial, sans-serif;--digi--global--typography--font-size--base:1rem;--digi--global--typography--font-size--small:0.875rem;--digi--global--typography--font-weight--regular:400;--digi--global--typography--font-weight--semibold:600;--digi--global--typography--font-weight--bold:700;--digi--global--typography--line-height--base:1.5;--digi--typography--label--font-size--desktop:1rem;--digi--typography--label--font-weight--desktop:600;--digi--typography--label--line-height--desktop:1.5;--digi--typography--label-description--font-size--desktop:1rem;--digi--typography--label-description--line-height--desktop:1.5;--digi--typography--tag--font-size--desktop:0.875rem;--digi--gutter--icon:0.625rem;--digi--gutter--smaller:0.75rem;--digi--gutter--small:0.875rem;--digi--gutter--medium:1rem;--digi--border-width--primary:1px;--digi--border-style--primary:solid;--digi--border-radius--primary:0;--digi--border-radius--secondary:6px;--af-tag-color:#091d54;--af-tag-hover-background:#ddf1fc}.af-form-label{color:var(--digi--color--text--primary);display:flex;flex-direction:column;font-family:var(--digi--global--typography--font-family--default);font-size:var(--digi--typography--label--font-size--desktop);margin-bottom:0.5rem}.af-form-label__label{cursor:pointer;display:block;font-weight:var(--digi--typography--label--font-weight--desktop);line-height:var(--digi--typography--label--line-height--desktop)}.af-form-label__description{display:block;font-size:var(--digi--typography--label-description--font-size--desktop);line-height:var(--digi--typography--label-description--line-height--desktop);max-width:35rem}.af-validation-message{align-items:center;display:flex;flex-wrap:wrap}.af-validation-message__icon{flex:0 0 auto;height:1.25em;margin-inline-end:var(--digi--gutter--icon);width:1.25em}.af-validation-message__icon--success,.af-validation-message__icon--error{background-color:var(--af-validation-icon-color, currentColor);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain}.af-validation-message__icon--success{--af-validation-icon-color:var(--digi--color--icons--success);-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 25'%3E%3Cpath d='M25 12.5C25 19.404 19.404 25 12.5 25S0 19.404 0 12.5 5.596 0 12.5 0 25 5.596 25 12.5zm-13.946 6.619l9.274-9.275a.806.806 0 000-1.14l-1.14-1.14a.806.806 0 00-1.14 0l-7.564 7.563-3.531-3.531a.807.807 0 00-1.14 0l-1.141 1.14a.806.806 0 000 1.14l5.242 5.243a.806.806 0 001.14 0z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 25'%3E%3Cpath d='M25 12.5C25 19.404 19.404 25 12.5 25S0 19.404 0 12.5 5.596 0 12.5 0 25 5.596 25 12.5zm-13.946 6.619l9.274-9.275a.806.806 0 000-1.14l-1.14-1.14a.806.806 0 00-1.14 0l-7.564 7.563-3.531-3.531a.807.807 0 00-1.14 0l-1.141 1.14a.806.806 0 000 1.14l5.242 5.243a.806.806 0 001.14 0z'/%3E%3C/svg%3E")}.af-validation-message__icon--error{--af-validation-icon-color:var(--digi--color--icons--danger);-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M34.4328058,0 C35.5494848,0 36.5900526,0.609146757 37.1483921,1.58958113 L47.5812454,19.9104189 C48.1395849,20.8909496 48.1395849,22.1090504 47.5812454,23.0895811 L37.1483921,41.4104189 C36.5900526,42.3908532 35.5494848,43 34.4328058,43 L13.5671942,43 C12.4505152,43 11.4099474,42.3908532 10.8516079,41.4104189 L0.41875464,23.0895811 C-0.13958488,22.1090504 -0.13958488,20.8909496 0.41875464,19.9104189 L10.8516079,1.58958113 C11.4099474,0.609146757 12.4505152,0 13.5671942,0 Z M18.6736823,12.3728178 C18.2711762,11.964729 17.6203819,11.964729 17.2178757,12.3728178 L15.2825964,14.334939 C14.8800903,14.7430278 14.8800903,15.4028485 15.2825964,15.8109373 L20.6089616,21.2111779 L15.2825964,26.6114185 C14.8800903,27.0195074 14.8800903,27.6793281 15.2825964,28.0874169 L17.2178757,30.049538 C17.6203819,30.4576269 18.2711762,30.4576269 18.6736823,30.049538 L24.0000475,24.6492974 L29.3264127,30.049538 C29.7289188,30.4576269 30.3797132,30.4576269 30.7822193,30.049538 L32.7174986,28.0874169 C33.1200048,27.6793281 33.1200048,27.0195074 32.7174986,26.6114185 L27.3911334,21.2111779 L32.7174986,15.8109373 C33.1200048,15.4028485 33.1200048,14.7430278 32.7174986,14.334939 L30.7822193,12.3728178 C30.3797132,11.964729 29.7289188,11.964729 29.3264127,12.3728178 L24.0000475,17.7730584 Z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M34.4328058,0 C35.5494848,0 36.5900526,0.609146757 37.1483921,1.58958113 L47.5812454,19.9104189 C48.1395849,20.8909496 48.1395849,22.1090504 47.5812454,23.0895811 L37.1483921,41.4104189 C36.5900526,42.3908532 35.5494848,43 34.4328058,43 L13.5671942,43 C12.4505152,43 11.4099474,42.3908532 10.8516079,41.4104189 L0.41875464,23.0895811 C-0.13958488,22.1090504 -0.13958488,20.8909496 0.41875464,19.9104189 L10.8516079,1.58958113 C11.4099474,0.609146757 12.4505152,0 13.5671942,0 Z M18.6736823,12.3728178 C18.2711762,11.964729 17.6203819,11.964729 17.2178757,12.3728178 L15.2825964,14.334939 C14.8800903,14.7430278 14.8800903,15.4028485 15.2825964,15.8109373 L20.6089616,21.2111779 L15.2825964,26.6114185 C14.8800903,27.0195074 14.8800903,27.6793281 15.2825964,28.0874169 L17.2178757,30.049538 C17.6203819,30.4576269 18.2711762,30.4576269 18.6736823,30.049538 L24.0000475,24.6492974 L29.3264127,30.049538 C29.7289188,30.4576269 30.3797132,30.4576269 30.7822193,30.049538 L32.7174986,28.0874169 C33.1200048,27.6793281 33.1200048,27.0195074 32.7174986,26.6114185 L27.3911334,21.2111779 L32.7174986,15.8109373 C33.1200048,15.4028485 33.1200048,14.7430278 32.7174986,14.334939 L30.7822193,12.3728178 C30.3797132,11.964729 29.7289188,11.964729 29.3264127,12.3728178 L24.0000475,17.7730584 Z'/%3E%3C/svg%3E")}.af-validation-message__icon--warning{background:center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Ccircle cx='9' cy='9' r='6.75' fill='%23333'/%3E%3Cpath d='m18 9c0 4.9717-4.0298 9-9 9-4.9702 0-9-4.0283-9-9 0-4.9688 4.0298-9 9-9 4.9702 0 9 4.0312 9 9zm-9 1.8145c-0.92196 0-1.6694 0.7474-1.6694 1.6694 0 0.92196 0.7474 1.6694 1.6694 1.6694s1.6694-0.7474 1.6694-1.6694c0-0.92196-0.7474-1.6694-1.6694-1.6694zm-1.3157-1.065c0.012593 0.23095 0.20355 0.41175 0.43483 0.41175h1.7618c0.23128 0 0.42224-0.1808 0.43483-0.41175l0.2692-4.9355c0.013609-0.24946-0.18501-0.45922-0.43483-0.45922h-2.3002c-0.24982 0-0.4484 0.20976-0.43479 0.45922l0.2692 4.9355z' fill='%23FFE200'/%3E%3C/svg%3E");position:relative;top:3px}.af-validation-message__text{color:var(--digi--color--text--primary);flex:1;font-family:var(--digi--global--typography--font-family--default);font-size:var(--digi--typography--tag--font-size--desktop);transform:translateY(1px)}.af-tag{display:block;max-width:100%;min-width:0}.af-tag__button{align-items:center;background:var(--digi--grayscale-0);border:var(--digi--border-width--primary) var(--digi--border-style--primary) var(--af-tag-color);border-radius:var(--digi--border-radius--secondary);color:var(--af-tag-color);cursor:pointer;display:inline-flex;font-family:var(--digi--global--typography--font-family--default);font-size:0.875rem;font-weight:var(--digi--global--typography--font-weight--semibold);gap:10px;height:auto;max-width:100%;min-height:unset;min-width:0;padding:6px 8px;text-align:left;white-space:normal}.af-tag__button:hover{background:var(--af-tag-hover-background)}.af-tag__button:focus-visible{background:var(--af-tag-hover-background);border-color:var(--af-tag-color);outline:2px solid var(--digi--grayscale-1000);outline-offset:2px;box-shadow:0 0 0 5px var(--digi--grayscale-0)}.af-tag__button:active{background:var(--af-tag-hover-background)}.af-tag__text{display:inline-block;max-width:100%;min-width:0;white-space:normal}.af-tag__text--break{overflow-wrap:anywhere;word-break:break-word}.af-tag__remove-icon{flex:0 0 auto;height:1em;min-height:0 !important;width:1em}:host{--yrkesvaljaren-width:var(--af-width, 100%);--yrkesvaljaren-min-width:var(--af-min-width, 200px);--yrkesvaljaren-max-width:var(--af-max-width, none);--yrkesvaljaren-height:var(--af-height, auto);--yrkesvaljaren-min-height:var(--af-min-height, auto);--yrkesvaljaren-max-height:var(--af-max-height, none);--selector-width:var(--yrkesvaljaren-width);--selector-min-width:var(--yrkesvaljaren-min-width);--selector-max-width:var(--yrkesvaljaren-max-width);--selector-height:var(--yrkesvaljaren-height);--selector-min-height:var(--yrkesvaljaren-min-height);--selector-max-height:var(--yrkesvaljaren-max-height);--selector-font-family:var(--global-font-family, 'Open Sans', sans-serif);--selector-font-size:var(--sok-font-size, 1rem);--selector-text-color:var(--sok-text-color, #212529);--selector-placeholder-color:var(--sok-placeholder-color, #6c757d);--selector-border-color:var(--sok-border-color, #d1d5db);--selector-focus-border-color:var(--sok-focus-border-color, #86b7fe);--selector-focus-shadow:var(--sok-focus-shadow, 0 0 0 0.25rem rgba(13, 110, 253, 0.25));--selector-background-color:var(--sok-background-color, #fff);--selector-icon-color:var(--sok-icon-color, #6c757d);--selector-clear-button-color:var(--sok-clear-button-color, #6c757d);--selector-clear-button-hover-color:var(--sok-clear-button-hover-color, #212529);--selector-suggestion-background-color:var(--sok-suggestion-background-color, #fff);--selector-suggestion-border-color:var(--sok-suggestion-border-color, #ced4da);--selector-suggestion-hover-background:var(--sok-suggestion-hover-background, #e9ecef);--selector-suggestion-active-background:var(--sok-suggestion-active-background, #dde4eb);--selector-suggestion-text-color:var(--sok-suggestion-text-color, #212529);--selector-suggestion-highlight-weight:var(--sok-suggestion-highlight-weight, bold);--selector-error-color:var(--sok-error-color, #dc3545);--selector-loading-color:var(--sok-loading-color, #6c757d);display:flex;flex-direction:column;width:var(--yrkesvaljaren-width);min-width:var(--yrkesvaljaren-min-width);max-width:var(--yrkesvaljaren-max-width);height:var(--yrkesvaljaren-height);min-height:var(--yrkesvaljaren-min-height);max-height:var(--yrkesvaljaren-max-height);position:relative}:host([af-size="small"]){--cs-size:small;--selector-container-min-height:32px;--selector-padding-y:2px;--selector-icon-size:1em;--selector-gap:4px}:host([af-size="medium"]){--selector-container-min-height:40px;--selector-padding-y:6px}:host([af-size="large"]){--selector-container-min-height:48px;--selector-padding-y:10px;--selector-icon-size:1.25em;--selector-gap:8px}*{box-sizing:border-box}.yrkesvaljaren-wrapper{display:flex;flex-direction:column;flex:1;min-height:inherit}core-selector{margin-top:0.5rem}.status-message{margin-top:0.5rem;font-size:0.9em;font-style:italic;color:var(--sok-loading-color, #6c757d)}.history-header{font-size:0.875rem;color:var(--digi--grayscale-700, #757575);border-bottom:1px solid var(--selector-suggestion-border-color, #ced4da);margin-bottom:0px}.history-header a{color:inherit;text-decoration:underline}.history-header a:hover{color:var(--digi--global--color--cta--link--base, #1616B2)}`;
|
|
1044
|
+
const jobSelectorCss = () => `:host{--digi--grayscale-0:#ffffff;--digi--grayscale-50:#fbfbfb;--digi--grayscale-100:#f4f4f4;--digi--grayscale-200:#ededed;--digi--grayscale-300:#e4e4e4;--digi--grayscale-400:#dddddd;--digi--grayscale-500:#cacaca;--digi--grayscale-600:#acacac;--digi--grayscale-700:#757575;--digi--grayscale-800:#5c5c5c;--digi--grayscale-900:#333333;--digi--grayscale-1000:#000000;--digi--global--color--cta--link--base:#1616b2;--digi--global--color--function--danger--base:#da0000;--digi--global--color--function--success--base:#008a20;--digi--global--color--function--success--lightest-3:#d4edda;--digi--global--color--function--warning--base:#ffe200;--af-text-color:var(--digi--color--text--primary, var(--digi--grayscale-900));--digi--global--typography--font-family--default:"Open Sans", Arial, sans-serif;--digi--global--typography--font-size--base:1rem;--digi--global--typography--font-size--small:0.875rem;--digi--global--typography--font-weight--regular:400;--digi--global--typography--font-weight--semibold:600;--digi--global--typography--font-weight--bold:700;--digi--global--typography--line-height--base:1.5;--digi--typography--label--font-size--desktop:1rem;--digi--typography--label--font-weight--desktop:600;--digi--typography--label--line-height--desktop:1.5;--digi--typography--label-description--font-size--desktop:1rem;--digi--typography--label-description--line-height--desktop:1.5;--digi--typography--tag--font-size--desktop:0.875rem;--digi--gutter--icon:0.625rem;--digi--gutter--smaller:0.75rem;--digi--gutter--small:0.875rem;--digi--gutter--medium:1rem;--digi--border-width--primary:1px;--digi--border-style--primary:solid;--digi--border-radius--primary:0;--digi--border-radius--secondary:6px;--af-tag-color:var(--digi--color--text--interactive--brand-primary, #091d54);--af-tag-background:var(--digi--color--background--interactive--default--secondary, var(--digi--grayscale-0));--af-tag-hover-background:var(--digi--color--background--interactive--hover--secondary, #ddf1fc)}.af-form-label{color:var(--af-text-color);display:flex;flex-direction:column;font-family:var(--digi--global--typography--font-family--default);font-size:var(--digi--typography--label--font-size--desktop);margin-bottom:0.5rem}.af-form-label__label{cursor:pointer;display:block;font-weight:var(--digi--typography--label--font-weight--desktop);line-height:var(--digi--typography--label--line-height--desktop)}.af-form-label__description{display:block;font-size:var(--digi--typography--label-description--font-size--desktop);line-height:var(--digi--typography--label-description--line-height--desktop);max-width:35rem}.af-validation-message{align-items:center;display:flex;flex-wrap:wrap}.af-validation-message__icon{flex:0 0 auto;height:1.25em;margin-inline-end:var(--digi--gutter--icon);width:1.25em}.af-validation-message__icon--success,.af-validation-message__icon--error{background-color:var(--af-validation-icon-color, currentColor);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain}.af-validation-message__icon--success{--af-validation-icon-color:var(--digi--color--icon--validation--success, var(--digi--global--color--function--success--base));-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 25'%3E%3Cpath d='M25 12.5C25 19.404 19.404 25 12.5 25S0 19.404 0 12.5 5.596 0 12.5 0 25 5.596 25 12.5zm-13.946 6.619l9.274-9.275a.806.806 0 000-1.14l-1.14-1.14a.806.806 0 00-1.14 0l-7.564 7.563-3.531-3.531a.807.807 0 00-1.14 0l-1.141 1.14a.806.806 0 000 1.14l5.242 5.243a.806.806 0 001.14 0z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25 25'%3E%3Cpath d='M25 12.5C25 19.404 19.404 25 12.5 25S0 19.404 0 12.5 5.596 0 12.5 0 25 5.596 25 12.5zm-13.946 6.619l9.274-9.275a.806.806 0 000-1.14l-1.14-1.14a.806.806 0 00-1.14 0l-7.564 7.563-3.531-3.531a.807.807 0 00-1.14 0l-1.141 1.14a.806.806 0 000 1.14l5.242 5.243a.806.806 0 001.14 0z'/%3E%3C/svg%3E")}.af-validation-message__icon--error{--af-validation-icon-color:var(--digi--color--icon--validation--error, var(--digi--global--color--function--danger--base));-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M34.4328058,0 C35.5494848,0 36.5900526,0.609146757 37.1483921,1.58958113 L47.5812454,19.9104189 C48.1395849,20.8909496 48.1395849,22.1090504 47.5812454,23.0895811 L37.1483921,41.4104189 C36.5900526,42.3908532 35.5494848,43 34.4328058,43 L13.5671942,43 C12.4505152,43 11.4099474,42.3908532 10.8516079,41.4104189 L0.41875464,23.0895811 C-0.13958488,22.1090504 -0.13958488,20.8909496 0.41875464,19.9104189 L10.8516079,1.58958113 C11.4099474,0.609146757 12.4505152,0 13.5671942,0 Z M18.6736823,12.3728178 C18.2711762,11.964729 17.6203819,11.964729 17.2178757,12.3728178 L15.2825964,14.334939 C14.8800903,14.7430278 14.8800903,15.4028485 15.2825964,15.8109373 L20.6089616,21.2111779 L15.2825964,26.6114185 C14.8800903,27.0195074 14.8800903,27.6793281 15.2825964,28.0874169 L17.2178757,30.049538 C17.6203819,30.4576269 18.2711762,30.4576269 18.6736823,30.049538 L24.0000475,24.6492974 L29.3264127,30.049538 C29.7289188,30.4576269 30.3797132,30.4576269 30.7822193,30.049538 L32.7174986,28.0874169 C33.1200048,27.6793281 33.1200048,27.0195074 32.7174986,26.6114185 L27.3911334,21.2111779 L32.7174986,15.8109373 C33.1200048,15.4028485 33.1200048,14.7430278 32.7174986,14.334939 L30.7822193,12.3728178 C30.3797132,11.964729 29.7289188,11.964729 29.3264127,12.3728178 L24.0000475,17.7730584 Z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M34.4328058,0 C35.5494848,0 36.5900526,0.609146757 37.1483921,1.58958113 L47.5812454,19.9104189 C48.1395849,20.8909496 48.1395849,22.1090504 47.5812454,23.0895811 L37.1483921,41.4104189 C36.5900526,42.3908532 35.5494848,43 34.4328058,43 L13.5671942,43 C12.4505152,43 11.4099474,42.3908532 10.8516079,41.4104189 L0.41875464,23.0895811 C-0.13958488,22.1090504 -0.13958488,20.8909496 0.41875464,19.9104189 L10.8516079,1.58958113 C11.4099474,0.609146757 12.4505152,0 13.5671942,0 Z M18.6736823,12.3728178 C18.2711762,11.964729 17.6203819,11.964729 17.2178757,12.3728178 L15.2825964,14.334939 C14.8800903,14.7430278 14.8800903,15.4028485 15.2825964,15.8109373 L20.6089616,21.2111779 L15.2825964,26.6114185 C14.8800903,27.0195074 14.8800903,27.6793281 15.2825964,28.0874169 L17.2178757,30.049538 C17.6203819,30.4576269 18.2711762,30.4576269 18.6736823,30.049538 L24.0000475,24.6492974 L29.3264127,30.049538 C29.7289188,30.4576269 30.3797132,30.4576269 30.7822193,30.049538 L32.7174986,28.0874169 C33.1200048,27.6793281 33.1200048,27.0195074 32.7174986,26.6114185 L27.3911334,21.2111779 L32.7174986,15.8109373 C33.1200048,15.4028485 33.1200048,14.7430278 32.7174986,14.334939 L30.7822193,12.3728178 C30.3797132,11.964729 29.7289188,11.964729 29.3264127,12.3728178 L24.0000475,17.7730584 Z'/%3E%3C/svg%3E")}.af-validation-message__icon--warning{background:center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Ccircle cx='9' cy='9' r='6.75' fill='%23333'/%3E%3Cpath d='m18 9c0 4.9717-4.0298 9-9 9-4.9702 0-9-4.0283-9-9 0-4.9688 4.0298-9 9-9 4.9702 0 9 4.0312 9 9zm-9 1.8145c-0.92196 0-1.6694 0.7474-1.6694 1.6694 0 0.92196 0.7474 1.6694 1.6694 1.6694s1.6694-0.7474 1.6694-1.6694c0-0.92196-0.7474-1.6694-1.6694-1.6694zm-1.3157-1.065c0.012593 0.23095 0.20355 0.41175 0.43483 0.41175h1.7618c0.23128 0 0.42224-0.1808 0.43483-0.41175l0.2692-4.9355c0.013609-0.24946-0.18501-0.45922-0.43483-0.45922h-2.3002c-0.24982 0-0.4484 0.20976-0.43479 0.45922l0.2692 4.9355z' fill='%23FFE200'/%3E%3C/svg%3E");position:relative;top:3px}.af-validation-message__text{color:var(--af-text-color);flex:1;font-family:var(--digi--global--typography--font-family--default);font-size:var(--digi--typography--tag--font-size--desktop);transform:translateY(1px)}.af-validation-message__placeholder{visibility:hidden}.af-tag{display:block;max-width:100%;min-width:0}.af-tag__button{align-items:center;background:var(--af-tag-background);border:var(--digi--border-width--primary) var(--digi--border-style--primary) var(--af-tag-color);border-radius:var(--digi--border-radius--secondary);color:var(--af-tag-color);cursor:pointer;display:inline-flex;font-family:var(--digi--global--typography--font-family--default);font-size:0.875rem;font-weight:var(--digi--global--typography--font-weight--semibold);gap:10px;height:auto;max-width:100%;min-height:unset;min-width:0;padding:6px 8px;text-align:left;white-space:normal}.af-tag__button:hover{background:var(--af-tag-hover-background)}.af-tag__button:focus-visible{background:var(--af-tag-hover-background);border-color:var(--af-tag-color);outline:2px solid var(--digi--color--text--primary, var(--digi--grayscale-1000));outline-offset:2px;box-shadow:0 0 0 5px var(--digi--color--background--primary, var(--digi--grayscale-0))}.af-tag__button:active{background:var(--af-tag-hover-background)}.af-tag__text{display:inline-block;max-width:100%;min-width:0;white-space:normal}.af-tag__text--break{overflow-wrap:anywhere;word-break:break-word}.af-icon{display:flex !important;min-height:1.4em !important;align-items:center !important}.af-icon--default-size{width:12px !important;height:12px !important}.af-tag__remove-icon{flex:0 0 auto;height:1em;width:1em}.af-icon.af-tag__remove-icon{min-height:0 !important}:host{--yrkesvaljaren-width:var(--af-width, 100%);--yrkesvaljaren-min-width:var(--af-min-width, 200px);--yrkesvaljaren-max-width:var(--af-max-width, none);--yrkesvaljaren-height:var(--af-height, auto);--yrkesvaljaren-min-height:var(--af-min-height, auto);--yrkesvaljaren-max-height:var(--af-max-height, none);--selector-width:var(--yrkesvaljaren-width);--selector-min-width:var(--yrkesvaljaren-min-width);--selector-max-width:var(--yrkesvaljaren-max-width);--selector-height:var(--yrkesvaljaren-height);--selector-min-height:var(--yrkesvaljaren-min-height);--selector-max-height:var(--yrkesvaljaren-max-height);--selector-font-family:var(--global-font-family, 'Open Sans', sans-serif);--selector-font-size:var(--sok-font-size, 1rem);--selector-text-color:var(--sok-text-color, var(--digi--color--text--primary, #212529));--selector-placeholder-color:var(--sok-placeholder-color, var(--digi--color--text--description, #6c757d));--selector-border-color:var(--sok-border-color, var(--digi--color--border--interactive--default--on-input, #d1d5db));--selector-focus-border-color:var(--sok-focus-border-color, #86b7fe);--selector-focus-shadow:var(--sok-focus-shadow, 0 0 0 0.25rem rgba(13, 110, 253, 0.25));--selector-background-color:var(--sok-background-color, var(--digi--color--background--interactive--default--input-elements, #fff));--selector-icon-color:var(--sok-icon-color, var(--digi--color--icon--primary, #6c757d));--selector-clear-button-color:var(--sok-clear-button-color, var(--digi--color--icon--primary, #6c757d));--selector-clear-button-hover-color:var(--sok-clear-button-hover-color, var(--digi--color--icon--primary, #212529));--selector-suggestion-background-color:var(--sok-suggestion-background-color, var(--digi--color--background--dropdown, #fff));--selector-suggestion-border-color:var(--sok-suggestion-border-color, var(--digi--color--divider--primary, #ced4da));--selector-suggestion-hover-background:var(--sok-suggestion-hover-background, var(--digi--color--background--interactive--hover--quarternary, #e9ecef));--selector-suggestion-active-background:var(--sok-suggestion-active-background, var(--digi--color--background--interactive--hover--quarternary, #dde4eb));--selector-suggestion-text-color:var(--sok-suggestion-text-color, var(--digi--color--text--primary, #212529));--selector-suggestion-highlight-weight:var(--sok-suggestion-highlight-weight, bold);--selector-error-color:var(--sok-error-color, var(--digi--color--border--interactive--validation--error, #dc3545));--selector-loading-color:var(--sok-loading-color, var(--digi--color--text--description, #6c757d));display:flex;flex-direction:column;width:var(--yrkesvaljaren-width);min-width:var(--yrkesvaljaren-min-width);max-width:var(--yrkesvaljaren-max-width);height:var(--yrkesvaljaren-height);min-height:var(--yrkesvaljaren-min-height);max-height:var(--yrkesvaljaren-max-height);position:relative}:host([af-size="small"]){--cs-size:small;--selector-container-min-height:32px;--selector-padding-y:2px;--selector-icon-size:1em;--selector-gap:4px}:host([af-size="medium"]){--selector-container-min-height:40px;--selector-padding-y:6px}:host([af-size="large"]){--selector-container-min-height:48px;--selector-padding-y:10px;--selector-icon-size:1.25em;--selector-gap:8px}*{box-sizing:border-box}.yrkesvaljaren-wrapper{display:flex;flex-direction:column;flex:1;min-height:inherit}core-selector{margin-top:0.5rem}.status-message{margin-top:0.5rem;font-size:0.9em;font-style:italic;color:var(--sok-loading-color, var(--digi--color--text--description, #6c757d))}.history-header{font-size:0.875rem;color:var(--digi--color--text--description, var(--digi--grayscale-700, #757575));border-bottom:1px solid var(--selector-suggestion-border-color, #ced4da);margin-bottom:0px}.history-header a{color:inherit;text-decoration:underline}.history-header a:hover{color:var(--digi--color--text--interactive--primary, var(--digi--global--color--cta--link--base, #1616B2))}.yv-suggestion-box{margin-top:16px;padding:16px 20px;background:var(--digi--color--background--pop-out, var(--digi--grayscale-50, #fbfbfb));border:1px solid var(--digi--color--divider--secondary, var(--digi--grayscale-300, #e4e4e4));border-radius:var(--digi--border-radius--secondary, 6px);font-family:var(--digi--global--typography--font-family--default, "Open Sans", Arial, sans-serif);font-size:0.9375rem;line-height:1.4;color:var(--digi--color--text--primary, #333333)}.yv-suggestion-title{font-weight:var(--digi--global--typography--font-weight--semibold, 600);margin-bottom:10px}.yv-motivation-container{display:flex;flex-direction:column;gap:8px}.yv-motivation-field-wrapper{display:flex;flex-direction:column;gap:4px}.yv-motivation-input{width:100%;box-sizing:border-box;min-height:44px;max-height:180px;padding:8px 12px;font:inherit;color:inherit;background:var(--digi--color--background--interactive--default--input-elements, var(--digi--grayscale-0, #ffffff));border:1px solid var(--digi--color--border--interactive--default--on-input, var(--digi--grayscale-400, #dddddd));border-radius:var(--digi--border-radius--secondary, 6px);resize:vertical}.yv-motivation-input:focus-visible{outline:2px solid var(--digi--color--text--primary, var(--digi--grayscale-1000, #000000));outline-offset:1px}.yv-motivation-counter{align-self:flex-end;font-size:0.75rem;color:var(--digi--color--text--description, var(--digi--grayscale-800, #5c5c5c))}.yv-suggestion-actions{display:flex;gap:12px;align-items:center}.yv-suggestion-submit-btn,.yv-suggestion-cancel-btn,.yv-suggestion-close-btn{min-height:38px;padding:8px 16px;font:inherit;font-size:0.875rem;font-weight:var(--digi--global--typography--font-weight--semibold, 600);border:1px solid transparent;border-radius:var(--digi--border-radius--secondary, 6px);cursor:pointer;white-space:nowrap}.yv-suggestion-submit-btn{background:var(--digi--color--background--interactive--default--primary, #000048);color:var(--digi--color--text--interactive--secondary, #ffffff)}.yv-suggestion-submit-btn:hover{background:var(--digi--color--background--interactive--hover--primary, #000028)}.yv-suggestion-cancel-btn{background:transparent;color:var(--digi--color--text--interactive--primary, #1616b2);text-decoration:underline}.yv-suggestion-close-btn{background:var(--digi--color--background--primary, var(--digi--grayscale-0, #ffffff));border-color:var(--digi--color--border--interactive--default--on-input, var(--digi--grayscale-600, #acacac));color:inherit}.yv-suggestion-submit-btn:focus-visible,.yv-suggestion-cancel-btn:focus-visible,.yv-suggestion-close-btn:focus-visible{outline:2px solid var(--digi--color--text--primary, var(--digi--grayscale-1000, #000000));outline-offset:2px}.yv-suggestion-pii-error{color:var(--cs-error-color, var(--digi--color--text--primary, #b10e1e))}.yv-suggestion-success{display:flex;justify-content:space-between;align-items:center;gap:16px;color:var(--digi--color--text--primary, #007a1c);font-weight:var(--digi--global--typography--font-weight--semibold, 600)}.yv-sr-only{position:absolute;top:0;left:0;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap}`;
|
|
900
1045
|
|
|
901
1046
|
{
|
|
902
|
-
|
|
1047
|
+
types.log.setLevel(types.log.levels.SILENT);
|
|
903
1048
|
}
|
|
904
1049
|
const CONCEPT_ID_PATTERN = /^[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{4}_[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{3}_[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{3}$/;
|
|
905
1050
|
const JobSelector = class {
|
|
@@ -915,7 +1060,7 @@ const JobSelector = class {
|
|
|
915
1060
|
* Utelämna attributet för att använda senaste data automatiskt.
|
|
916
1061
|
*/
|
|
917
1062
|
taxonomyUrl;
|
|
918
|
-
placeholder =
|
|
1063
|
+
placeholder = types.PLACEHOLDER_TEXT;
|
|
919
1064
|
label = 'Välj yrke';
|
|
920
1065
|
/** Om satt till true kan väljaren inte användas med mus eller tangentbord. */
|
|
921
1066
|
disabled = false;
|
|
@@ -925,8 +1070,15 @@ const JobSelector = class {
|
|
|
925
1070
|
labelDescription;
|
|
926
1071
|
/** Om satt till `true` måste fältet ha ett värde för att vara giltigt. */
|
|
927
1072
|
required = false;
|
|
928
|
-
/** Om satt till `true`
|
|
1073
|
+
/** Om satt till `true` kan användaren ange ett yrke som fritext när det inte finns i listan. */
|
|
929
1074
|
manualInput = false;
|
|
1075
|
+
/** Om satt till `true` kan användaren föreslå ett saknat yrke med motivering. */
|
|
1076
|
+
feedback = false;
|
|
1077
|
+
/**
|
|
1078
|
+
* Emitteras när användaren skickar in ett förslag på saknat yrke via förslagsformuläret (`af-feedback`).
|
|
1079
|
+
*/
|
|
1080
|
+
afOnSubmitJobSuggestion;
|
|
1081
|
+
suggestionState = null;
|
|
930
1082
|
/**
|
|
931
1083
|
* Aktiverar historiken.
|
|
932
1084
|
* Använder Local Storage för att spara valda yrken i webbläsaren.
|
|
@@ -944,10 +1096,20 @@ const JobSelector = class {
|
|
|
944
1096
|
afFocused = false;
|
|
945
1097
|
populateInputOnSelect = false;
|
|
946
1098
|
maxVisibleRows;
|
|
947
|
-
minLength =
|
|
1099
|
+
minLength = types.MIN_INPUT_LENGTH;
|
|
948
1100
|
maxResults = 20;
|
|
1101
|
+
shouldFocusSuggestionInput = false;
|
|
1102
|
+
shouldFocusConfirmation = false;
|
|
1103
|
+
timers = new Set();
|
|
1104
|
+
schedule(callback, delay) {
|
|
1105
|
+
const timer = setTimeout(() => {
|
|
1106
|
+
this.timers.delete(timer);
|
|
1107
|
+
callback();
|
|
1108
|
+
}, delay);
|
|
1109
|
+
this.timers.add(timer);
|
|
1110
|
+
}
|
|
949
1111
|
get requireSelection() {
|
|
950
|
-
return !this.manualInput;
|
|
1112
|
+
return !(this.manualInput || this.feedback);
|
|
951
1113
|
}
|
|
952
1114
|
/**
|
|
953
1115
|
* Storleken på inputfältet.
|
|
@@ -956,6 +1118,7 @@ const JobSelector = class {
|
|
|
956
1118
|
size = 'medium';
|
|
957
1119
|
constructor(hostRef) {
|
|
958
1120
|
index.registerInstance(this, hostRef);
|
|
1121
|
+
this.afOnSubmitJobSuggestion = index.createEvent(this, "afOnSubmitJobSuggestion");
|
|
959
1122
|
this.afJobSelectedEmitter = index.createEvent(this, "afJobSelected");
|
|
960
1123
|
this.dataLoadFailedEmitter = index.createEvent(this, "afJobDataLoadFailed");
|
|
961
1124
|
this.validationChangeEmitter = index.createEvent(this, "afJobValidationChange");
|
|
@@ -966,7 +1129,7 @@ const JobSelector = class {
|
|
|
966
1129
|
this.internals = hostRef.$hostElement$.attachInternals();
|
|
967
1130
|
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
968
1131
|
}
|
|
969
|
-
|
|
1132
|
+
types.log.debug('[JobSelector] Constructor - enableMultiple:', this.enableMultiple);
|
|
970
1133
|
}
|
|
971
1134
|
state = { status: 'loading' };
|
|
972
1135
|
/**
|
|
@@ -1155,8 +1318,14 @@ const JobSelector = class {
|
|
|
1155
1318
|
watchRequired(newValue) {
|
|
1156
1319
|
this.controller.updateConfig({ required: newValue });
|
|
1157
1320
|
}
|
|
1158
|
-
|
|
1159
|
-
this.
|
|
1321
|
+
watchManualInputOrFeedback() {
|
|
1322
|
+
if (!this.feedback) {
|
|
1323
|
+
this.suggestionState = null;
|
|
1324
|
+
}
|
|
1325
|
+
this.controller.updateConfig({
|
|
1326
|
+
requireSelection: this.requireSelection,
|
|
1327
|
+
manualInput: this.manualInput
|
|
1328
|
+
});
|
|
1160
1329
|
}
|
|
1161
1330
|
watchHistory(newValue) {
|
|
1162
1331
|
this.controller.updateConfig({ history: newValue });
|
|
@@ -1231,10 +1400,10 @@ const JobSelector = class {
|
|
|
1231
1400
|
}
|
|
1232
1401
|
// --- LIVSCYKEL-METODER ---
|
|
1233
1402
|
async componentWillLoad() {
|
|
1234
|
-
|
|
1403
|
+
types.log.setLevel(types.log.levels.WARN);
|
|
1235
1404
|
// Använd registrerad data om den finns. Annars används en explicit URL
|
|
1236
1405
|
// eller senaste publicerade data.
|
|
1237
|
-
const registeredData =
|
|
1406
|
+
const registeredData = types.getRegisteredTaxonomy();
|
|
1238
1407
|
const hasData = (this.taxonomyData && this.taxonomyData.length > 0) || (registeredData && registeredData.length > 0);
|
|
1239
1408
|
if (!hasData) {
|
|
1240
1409
|
this.state = { status: 'loading' };
|
|
@@ -1242,11 +1411,11 @@ const JobSelector = class {
|
|
|
1242
1411
|
const data = await loadTaxonomy({
|
|
1243
1412
|
taxonomyUrl: this.taxonomyUrl,
|
|
1244
1413
|
});
|
|
1245
|
-
|
|
1246
|
-
|
|
1414
|
+
types.registerTaxonomy(data);
|
|
1415
|
+
types.log.debug('[JobSelector] Data-laddning lyckades.');
|
|
1247
1416
|
}
|
|
1248
1417
|
catch (error) {
|
|
1249
|
-
|
|
1418
|
+
types.log.error('[JobSelector] Fel vid data-laddning:', error);
|
|
1250
1419
|
this.state = { status: 'error', message: 'Kunde inte ladda yrkesdata.' };
|
|
1251
1420
|
this.dataLoadFailedEmitter.emit({ error: error instanceof Error ? error : new Error(String(error)) });
|
|
1252
1421
|
return;
|
|
@@ -1274,6 +1443,7 @@ const JobSelector = class {
|
|
|
1274
1443
|
enableMultiple: this.enableMultiple,
|
|
1275
1444
|
required: this.required,
|
|
1276
1445
|
requireSelection: this.requireSelection,
|
|
1446
|
+
manualInput: this.manualInput,
|
|
1277
1447
|
history: this.history,
|
|
1278
1448
|
popular: this.popular,
|
|
1279
1449
|
maxHistoryItems: this.maxHistoryItems,
|
|
@@ -1298,6 +1468,19 @@ const JobSelector = class {
|
|
|
1298
1468
|
componentDidLoad() {
|
|
1299
1469
|
this.handleHashFocus();
|
|
1300
1470
|
}
|
|
1471
|
+
componentDidRender() {
|
|
1472
|
+
if (this.shouldFocusSuggestionInput && this.suggestionState?.status === 'form') {
|
|
1473
|
+
this.shouldFocusSuggestionInput = false;
|
|
1474
|
+
const input = this.hostElement.shadowRoot?.querySelector(`#${this.componentId}-suggestion-motivation-input`);
|
|
1475
|
+
if (input) {
|
|
1476
|
+
this.schedule(() => input.focus(), 50);
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
if (this.shouldFocusConfirmation && this.suggestionState?.status === 'submitted') {
|
|
1480
|
+
this.shouldFocusConfirmation = false;
|
|
1481
|
+
this.hostElement.shadowRoot?.querySelector('.yv-suggestion-close-btn')?.focus();
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1301
1484
|
disconnectedCallback() {
|
|
1302
1485
|
if (this.observer) {
|
|
1303
1486
|
this.observer.disconnect();
|
|
@@ -1307,6 +1490,8 @@ const JobSelector = class {
|
|
|
1307
1490
|
}
|
|
1308
1491
|
clearTimeout(this.animationTimer);
|
|
1309
1492
|
this.animationTimer = undefined;
|
|
1493
|
+
this.timers.forEach(t => clearTimeout(t));
|
|
1494
|
+
this.timers.clear();
|
|
1310
1495
|
}
|
|
1311
1496
|
handleHashFocus() {
|
|
1312
1497
|
const hash = window.location.hash;
|
|
@@ -1320,9 +1505,48 @@ const JobSelector = class {
|
|
|
1320
1505
|
history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
1321
1506
|
}
|
|
1322
1507
|
}
|
|
1508
|
+
/** Manuella val skickas tvättade, och inte alls om de innehåller personuppgifter. */
|
|
1509
|
+
trackedSelectedJobs() {
|
|
1510
|
+
return this.lastAcceptedSelection.flatMap((item) => {
|
|
1511
|
+
if (item.type !== 'manual-input')
|
|
1512
|
+
return [item];
|
|
1513
|
+
return containsPii(item.preferred_label) ? [] : [{ ...item, preferred_label: sanitizeSuggestionTerm(item.preferred_label) }];
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
emitJobSuggestion(term, motivation) {
|
|
1517
|
+
const payload = {
|
|
1518
|
+
selectedJobs: this.trackedSelectedJobs(),
|
|
1519
|
+
suggestionJob: sanitizeSuggestionTerm(term),
|
|
1520
|
+
suggestionMotivation: sanitizeSuggestionMotivation(motivation),
|
|
1521
|
+
};
|
|
1522
|
+
this.afOnSubmitJobSuggestion.emit(payload);
|
|
1523
|
+
}
|
|
1524
|
+
/** Stänger förslagsrutan och lämnar tillbaka fokus till sökfältet. */
|
|
1525
|
+
closeSuggestion() {
|
|
1526
|
+
this.suggestionState = null;
|
|
1527
|
+
this.shouldFocusSuggestionInput = false;
|
|
1528
|
+
void this.setFocus();
|
|
1529
|
+
}
|
|
1530
|
+
submitSuggestion() {
|
|
1531
|
+
if (!this.suggestionState || !this.feedback)
|
|
1532
|
+
return;
|
|
1533
|
+
const { term, motivation } = this.suggestionState;
|
|
1534
|
+
if (containsPii(motivation || '')) {
|
|
1535
|
+
this.suggestionState = { ...this.suggestionState, piiError: true };
|
|
1536
|
+
this.shouldFocusSuggestionInput = true;
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
this.emitJobSuggestion(term, motivation);
|
|
1540
|
+
this.shouldFocusSuggestionInput = false;
|
|
1541
|
+
this.shouldFocusConfirmation = true;
|
|
1542
|
+
this.suggestionState = { status: 'submitted', term: (term || '').trim(), motivation: '' };
|
|
1543
|
+
}
|
|
1323
1544
|
// --- ANVÄNDARINTERAKTIONER OCH LOGIK (Delegerat till Controller via CoreSelector events) ---
|
|
1324
1545
|
handleInput(event) {
|
|
1325
1546
|
this.afFocused = true;
|
|
1547
|
+
if (this.suggestionState?.status === 'pii-blocked') {
|
|
1548
|
+
this.suggestionState = null;
|
|
1549
|
+
}
|
|
1326
1550
|
this.controller.handleInput(event.detail);
|
|
1327
1551
|
}
|
|
1328
1552
|
handleCsSelect(event) {
|
|
@@ -1339,12 +1563,37 @@ const JobSelector = class {
|
|
|
1339
1563
|
// Hämta originalobjektet från metadata om det finns, annars bygg ett baserat på genericItem
|
|
1340
1564
|
const originalItem = genericItem.metadata?.original;
|
|
1341
1565
|
if (originalItem && 'displayLabel' in originalItem) {
|
|
1566
|
+
if (this.suggestionState?.status === 'pii-blocked') {
|
|
1567
|
+
this.suggestionState = null;
|
|
1568
|
+
}
|
|
1342
1569
|
this.controller.selectItem(originalItem);
|
|
1343
1570
|
}
|
|
1344
1571
|
else {
|
|
1345
1572
|
// Fallback för manuell inmatning eller om metadata saknas
|
|
1346
1573
|
if (genericItem.metadata?.type === 'ManualInput') {
|
|
1347
|
-
|
|
1574
|
+
const term = genericItem.label;
|
|
1575
|
+
if (this.feedback && containsPii(term)) {
|
|
1576
|
+
// Behåll texten i fältet så att användaren kan rätta den.
|
|
1577
|
+
this.suggestionState = { status: 'pii-blocked', term: '', motivation: '' };
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
if (this.manualInput) {
|
|
1581
|
+
this.controller.handleFreeTextSelection(term);
|
|
1582
|
+
}
|
|
1583
|
+
if (this.feedback) {
|
|
1584
|
+
this.afFocused = false;
|
|
1585
|
+
this.shouldFocusSuggestionInput = true;
|
|
1586
|
+
this.suggestionState = {
|
|
1587
|
+
status: 'form',
|
|
1588
|
+
term,
|
|
1589
|
+
motivation: '',
|
|
1590
|
+
};
|
|
1591
|
+
if (!this.manualInput) {
|
|
1592
|
+
this.controller.resetSearch();
|
|
1593
|
+
}
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
return;
|
|
1348
1597
|
}
|
|
1349
1598
|
else {
|
|
1350
1599
|
// Detta borde inte hända med data från suggestions, men för säkerhets skull
|
|
@@ -1362,6 +1611,9 @@ const JobSelector = class {
|
|
|
1362
1611
|
}
|
|
1363
1612
|
}
|
|
1364
1613
|
handleCsClear() {
|
|
1614
|
+
if (this.suggestionState?.status === 'pii-blocked') {
|
|
1615
|
+
this.suggestionState = null;
|
|
1616
|
+
}
|
|
1365
1617
|
this.controller.resetSearch();
|
|
1366
1618
|
}
|
|
1367
1619
|
handleCsClearHistory() {
|
|
@@ -1398,7 +1650,7 @@ const JobSelector = class {
|
|
|
1398
1650
|
* Används efter att registerTaxonomy() har anropats med ny data.
|
|
1399
1651
|
*/
|
|
1400
1652
|
async updateData() {
|
|
1401
|
-
|
|
1653
|
+
types.log.debug('[JobSelector] updateData called');
|
|
1402
1654
|
await this.controller.initialize();
|
|
1403
1655
|
this.taxonomyData = this.controller.getTaxonomyData();
|
|
1404
1656
|
this.rebuildValidJobIds();
|
|
@@ -1453,8 +1705,8 @@ const JobSelector = class {
|
|
|
1453
1705
|
_mapSearchResultToGenericItem(item) {
|
|
1454
1706
|
const isSelectedResult = this.enableMultiple
|
|
1455
1707
|
? (this.state.status === 'multiSelect' || this.state.status === 'multiSelectShowingHistory') &&
|
|
1456
|
-
this.state.selectedItems.some(si =>
|
|
1457
|
-
: this.state.status === 'itemSelected' && !!this.state.selectedItem &&
|
|
1708
|
+
this.state.selectedItems.some(si => types.isSameSearchResult(si, item))
|
|
1709
|
+
: this.state.status === 'itemSelected' && !!this.state.selectedItem && types.isSameSearchResult(this.state.selectedItem, item);
|
|
1458
1710
|
return {
|
|
1459
1711
|
id: item.id,
|
|
1460
1712
|
label: item.displayLabel, // Use the formatted label
|
|
@@ -1471,6 +1723,7 @@ const JobSelector = class {
|
|
|
1471
1723
|
let coreStatus = 'loading';
|
|
1472
1724
|
let inputValue = '';
|
|
1473
1725
|
let suggestions = [];
|
|
1726
|
+
let hasMoreResults;
|
|
1474
1727
|
let selectedItem;
|
|
1475
1728
|
let selectedItems = [];
|
|
1476
1729
|
let validation = 'idle';
|
|
@@ -1514,6 +1767,7 @@ const JobSelector = class {
|
|
|
1514
1767
|
coreStatus = 'searching';
|
|
1515
1768
|
inputValue = componentState.inputValue;
|
|
1516
1769
|
suggestions = componentState.suggestions.map(s => this._mapSearchResultToGenericItem(s));
|
|
1770
|
+
hasMoreResults = this.controller?.hasMoreResults(componentState.suggestions);
|
|
1517
1771
|
break;
|
|
1518
1772
|
case 'showingHistory':
|
|
1519
1773
|
coreStatus = 'searching';
|
|
@@ -1523,7 +1777,7 @@ const JobSelector = class {
|
|
|
1523
1777
|
case 'itemSelected':
|
|
1524
1778
|
coreStatus = 'itemSelected';
|
|
1525
1779
|
selectedItem = this._mapSearchResultToGenericItem(componentState.selectedItem);
|
|
1526
|
-
selectedItem.highlightedLabel =
|
|
1780
|
+
selectedItem.highlightedLabel = types.styleParentheticalText(selectedItem.label);
|
|
1527
1781
|
inputValue = componentState.inputValue || '';
|
|
1528
1782
|
break;
|
|
1529
1783
|
case 'multiSelect':
|
|
@@ -1531,6 +1785,7 @@ const JobSelector = class {
|
|
|
1531
1785
|
inputValue = componentState.inputValue;
|
|
1532
1786
|
suggestions = componentState.suggestions.map(s => this._mapSearchResultToGenericItem(s));
|
|
1533
1787
|
selectedItems = componentState.selectedItems.map(s => this._mapSearchResultToGenericItem(s));
|
|
1788
|
+
hasMoreResults = this.controller?.hasMoreResults(componentState.suggestions);
|
|
1534
1789
|
break;
|
|
1535
1790
|
case 'multiSelectShowingHistory':
|
|
1536
1791
|
coreStatus = 'multiSelect';
|
|
@@ -1548,7 +1803,7 @@ const JobSelector = class {
|
|
|
1548
1803
|
const selectedOriginal = si.metadata?.original;
|
|
1549
1804
|
const suggestionOriginal = s.metadata?.original;
|
|
1550
1805
|
if (selectedOriginal && suggestionOriginal && 'rawLabel' in selectedOriginal && 'rawLabel' in suggestionOriginal) {
|
|
1551
|
-
return
|
|
1806
|
+
return types.isSameSearchResult(selectedOriginal, suggestionOriginal);
|
|
1552
1807
|
}
|
|
1553
1808
|
return (si.id && s.id) ? si.id === s.id : si.label === s.label;
|
|
1554
1809
|
});
|
|
@@ -1578,6 +1833,11 @@ const JobSelector = class {
|
|
|
1578
1833
|
listHeader = undefined;
|
|
1579
1834
|
showHistoryHeader = false;
|
|
1580
1835
|
}
|
|
1836
|
+
// PII-spärren visas som valideringsfel i sökfältet, så att det kopplas med aria-describedby.
|
|
1837
|
+
if (this.suggestionState?.status === 'pii-blocked') {
|
|
1838
|
+
validation = 'error';
|
|
1839
|
+
message = 'Texten verkar innehålla personuppgifter, till exempel personnummer, e-post eller telefonnummer. Skriv bara yrket du vill föreslå.';
|
|
1840
|
+
}
|
|
1581
1841
|
return {
|
|
1582
1842
|
status: coreStatus,
|
|
1583
1843
|
inputValue,
|
|
@@ -1589,7 +1849,11 @@ const JobSelector = class {
|
|
|
1589
1849
|
message,
|
|
1590
1850
|
listHeader,
|
|
1591
1851
|
showHistoryHeader,
|
|
1592
|
-
isHistoryView
|
|
1852
|
+
isHistoryView,
|
|
1853
|
+
// Det spärrade förslaget erbjuds inte igen förrän texten har ändrats.
|
|
1854
|
+
manualInputBlocked: this.suggestionState?.status === 'pii-blocked',
|
|
1855
|
+
// Om det finns fler träffar än som visas ("Minst N förslag" för skärmläsare).
|
|
1856
|
+
hasMoreResults,
|
|
1593
1857
|
};
|
|
1594
1858
|
}
|
|
1595
1859
|
render() {
|
|
@@ -1610,11 +1874,35 @@ const JobSelector = class {
|
|
|
1610
1874
|
manualInputBehavior: 'select',
|
|
1611
1875
|
showHistoryHeader: this.history && !selectorState.listHeader, // Only show default if not override
|
|
1612
1876
|
listHeader: selectorState.listHeader,
|
|
1613
|
-
enableInfiniteScroll: true
|
|
1877
|
+
enableInfiniteScroll: true,
|
|
1878
|
+
isFeedback: this.feedback,
|
|
1879
|
+
manualInputMode: (this.manualInput && this.feedback)
|
|
1880
|
+
? 'combined'
|
|
1881
|
+
: this.feedback
|
|
1882
|
+
? 'feedback'
|
|
1883
|
+
: 'manual',
|
|
1884
|
+
feedbackTargetName: 'yrke',
|
|
1614
1885
|
};
|
|
1615
1886
|
// Pass external error message if present and we are not in loading/error state
|
|
1616
1887
|
// (This logic is now moved to _mapStateToSelectorState to respect validation state)
|
|
1617
|
-
return (index.h("div", { key: '
|
|
1888
|
+
return (index.h("div", { key: '12dea63f349ce625d4ea7041533dd328391532c2', class: "job-selector-wrapper" }, this.state.status === 'error' ? (index.h("div", { class: "error-message" }, index.h(afValidationMessage.AfValidationMessage, { variant: "error", role: "alert" }, this.state.message || 'Ett fel uppstod.'))) : (index.h(index.Fragment, null, index.h("core-selector", { id: this.componentId, componentId: this.componentId, state: selectorState, config: config, label: this.label, labelDescription: this.labelDescription, size: this.size, afFocused: this.afFocused }), this.suggestionState && this.suggestionState.status !== 'pii-blocked' && (index.h("div", { key: "yv-suggestion-box", class: "yv-suggestion-box", role: "region", "aria-label": "F\u00F6resl\u00E5 saknat yrke" }, this.suggestionState.status === 'form' ? (index.h("div", { class: "yv-suggestion-form" }, index.h("div", { class: "yv-suggestion-title", id: `${this.componentId}-suggestion-title` }, "Motivera varf\u00F6r \"", index.h("strong", null, this.suggestionState.term), "\" b\u00F6r l\u00E4ggas till som yrke (frivilligt):"), index.h("div", { class: "yv-motivation-container" }, index.h("div", { class: "yv-motivation-field-wrapper" }, index.h("textarea", { id: `${this.componentId}-suggestion-motivation-input`, "aria-labelledby": `${this.componentId}-suggestion-title`, "aria-describedby": this.suggestionState.piiError
|
|
1889
|
+
? `${this.componentId}-motivation-pii-error ${this.componentId}-motivation-counter`
|
|
1890
|
+
: `${this.componentId}-motivation-counter`, "aria-invalid": this.suggestionState.piiError ? 'true' : 'false', class: "yv-motivation-input", value: this.suggestionState.motivation, maxLength: 160, rows: 2, ref: (el) => {
|
|
1891
|
+
if (el) {
|
|
1892
|
+
el.style.height = 'auto';
|
|
1893
|
+
el.style.height = `${Math.max(el.scrollHeight, 44)}px`;
|
|
1894
|
+
}
|
|
1895
|
+
}, onInput: (e) => {
|
|
1896
|
+
const target = e.target;
|
|
1897
|
+
target.style.height = 'auto';
|
|
1898
|
+
target.style.height = `${Math.max(target.scrollHeight, 44)}px`;
|
|
1899
|
+
const val = target.value;
|
|
1900
|
+
if (this.suggestionState) {
|
|
1901
|
+
this.suggestionState = { ...this.suggestionState, motivation: val, piiError: false };
|
|
1902
|
+
}
|
|
1903
|
+
} }), index.h("div", { id: `${this.componentId}-motivation-counter`, class: "yv-motivation-counter" }, (this.suggestionState.motivation || '').length, "/160")), this.suggestionState.piiError && (index.h("div", { id: `${this.componentId}-motivation-pii-error`, class: "yv-suggestion-pii-error", role: "alert" }, "Motiveringen verkar inneh\u00E5lla personuppgifter, till exempel personnummer, e-post eller telefonnummer. Ta bort dem f\u00F6r att kunna skicka.")), index.h("div", { class: "yv-suggestion-actions" }, index.h("button", { type: "button", class: "yv-suggestion-submit-btn", "aria-label": `Skicka förslag för "${this.suggestionState.term}" till Arbetsförmedlingen`, onClick: () => this.submitSuggestion() }, "Skicka"), index.h("button", { type: "button", class: "yv-suggestion-cancel-btn", "aria-label": "Avbryt f\u00F6rslag", onClick: () => this.closeSuggestion() }, "Avbryt"))))) : this.suggestionState.status === 'submitted' ? (index.h("div", { class: "yv-suggestion-success" }, index.h("span", null, "F\u00F6rslaget \"", index.h("strong", null, this.suggestionState.term), "\" har skickats in till Arbetsf\u00F6rmedlingen."), index.h("button", { type: "button", class: "yv-suggestion-close-btn", "aria-label": "St\u00E4ng bekr\u00E4ftelse", onClick: () => this.closeSuggestion() }, "St\u00E4ng"))) : null)), index.h("div", { key: "yv-suggestion-live-region", class: "yv-sr-only", role: "status", "aria-live": "polite" }, this.suggestionState?.status === 'submitted'
|
|
1904
|
+
? `Förslaget "${this.suggestionState.term}" har skickats in till Arbetsförmedlingen.`
|
|
1905
|
+
: '')))));
|
|
1618
1906
|
}
|
|
1619
1907
|
static get delegatesFocus() { return true; }
|
|
1620
1908
|
static get formAssociated() { return true; }
|
|
@@ -1623,7 +1911,10 @@ const JobSelector = class {
|
|
|
1623
1911
|
"watchRequired": 0
|
|
1624
1912
|
}],
|
|
1625
1913
|
"manualInput": [{
|
|
1626
|
-
"
|
|
1914
|
+
"watchManualInputOrFeedback": 0
|
|
1915
|
+
}],
|
|
1916
|
+
"feedback": [{
|
|
1917
|
+
"watchManualInputOrFeedback": 0
|
|
1627
1918
|
}],
|
|
1628
1919
|
"history": [{
|
|
1629
1920
|
"watchHistory": 0
|