@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.
Files changed (98) hide show
  1. package/README.md +52 -21
  2. package/dist/cjs/{af-validation-message-Cy89nVEv.js → af-validation-message-BdR9X_qh.js} +1 -1
  3. package/dist/cjs/core-selector.cjs.entry.js +342 -23
  4. package/dist/cjs/digi-service-job-selector.cjs.entry.js +352 -61
  5. package/dist/cjs/{index-hZgOvC17.js → index-DMQDFAL7.js} +0 -22
  6. package/dist/cjs/index.cjs.js +4 -7
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/{esm/fuse-BPnhMTul.js → cjs/types-DdzCbiye.js} +965 -1
  9. package/dist/cjs/yrkesvaljaren.cjs.js +2 -2
  10. package/dist/collection/collection-manifest.json +0 -1
  11. package/dist/collection/components/core-selector/core-selector.css +70 -49
  12. package/dist/collection/components/core-selector/core-selector.js +309 -14
  13. package/dist/collection/components/design-compat/af-icon.js +8 -7
  14. package/dist/collection/components/job-selector/job-selector-controller.js +13 -3
  15. package/dist/collection/components/job-selector/job-selector.css +188 -34
  16. package/dist/collection/components/job-selector/job-selector.js +199 -10
  17. package/dist/components/core-selector2.js +1 -1
  18. package/dist/components/digi-service-job-selector.js +1 -1
  19. package/dist/components/index.js +1 -1
  20. package/dist/components/types.js +1 -1
  21. package/dist/esm/{af-validation-message-BgoGzzBf.js → af-validation-message-DMoOu-0k.js} +1 -1
  22. package/dist/esm/core-selector.entry.js +342 -23
  23. package/dist/esm/digi-service-job-selector.entry.js +310 -19
  24. package/dist/esm/{index-HNd02eQb.js → index-vJ-tamti.js} +1 -22
  25. package/dist/esm/index.js +2 -4
  26. package/dist/esm/loader.js +3 -3
  27. package/dist/{cjs/fuse-BTLNKxuL.js → esm/types-DVos4HHS.js} +948 -2
  28. package/dist/esm/yrkesvaljaren.js +3 -3
  29. package/dist/types/components/core-selector/core-selector.d.ts +68 -0
  30. package/dist/types/components/job-selector/job-selector-controller.d.ts +5 -0
  31. package/dist/types/components/job-selector/job-selector.d.ts +21 -3
  32. package/dist/types/components/job-selector/types.d.ts +12 -0
  33. package/dist/types/components.d.ts +20 -99
  34. package/dist/types/index.d.ts +1 -1
  35. package/dist/vendor/taxonomy-core/af-data-layer.d.ts +16 -0
  36. package/dist/vendor/taxonomy-core/af-data-layer.js +24 -0
  37. package/dist/vendor/taxonomy-core/index.d.ts +1 -1
  38. package/dist/vendor/taxonomy-core/index.js +1 -1
  39. package/dist/vendor/taxonomy-core/pii-sanitizer.d.ts +25 -0
  40. package/dist/vendor/taxonomy-core/pii-sanitizer.js +137 -0
  41. package/dist/vendor/taxonomy-core/selector-navigation.d.ts +9 -1
  42. package/dist/vendor/taxonomy-core/selector-navigation.js +28 -1
  43. package/dist/vendor/taxonomy-core/selector-types.d.ts +12 -0
  44. package/dist/yrkesvaljaren/index.esm.js +1 -1
  45. package/dist/yrkesvaljaren/p-0f19a308.entry.js +1 -0
  46. package/dist/yrkesvaljaren/{p-BUviBbwX.js → p-DHK95AvZ.js} +1 -1
  47. package/dist/yrkesvaljaren/p-DVos4HHS.js +1 -0
  48. package/dist/yrkesvaljaren/p-b81496c8.entry.js +1 -0
  49. package/dist/yrkesvaljaren/p-vJ-tamti.js +3 -0
  50. package/dist/yrkesvaljaren/yrkesvaljaren.esm.js +1 -1
  51. package/package.json +12 -10
  52. package/dist/cjs/geo-valjaren.cjs.entry.js +0 -14910
  53. package/dist/cjs/job-selector-demo.cjs.entry.js +0 -690
  54. package/dist/cjs/neobrutal-search.cjs.entry.js +0 -171
  55. package/dist/cjs/search.engine-D4cpbVzd.js +0 -504
  56. package/dist/cjs/taxonomy-registry-Dzt0SPzT.js +0 -454
  57. package/dist/cjs/types-CtHBl6Ra.js +0 -14
  58. package/dist/collection/components/geovaljaren/geovaljaren.css +0 -21
  59. package/dist/collection/components/geovaljaren/geovaljaren.js +0 -304
  60. package/dist/collection/components/geovaljaren/logic/adapter.utils.js +0 -20
  61. package/dist/collection/components/geovaljaren/logic/data.utils.js +0 -12
  62. package/dist/collection/components/geovaljaren/logic/history-service.js +0 -25
  63. package/dist/collection/components/geovaljaren/logic/search.engine.js +0 -28
  64. package/dist/collection/verkstad/verkstad.js +0 -408
  65. package/dist/components/fuse.js +0 -1
  66. package/dist/components/geo-valjaren.d.ts +0 -11
  67. package/dist/components/geo-valjaren.js +0 -1
  68. package/dist/components/job-selector-demo.d.ts +0 -11
  69. package/dist/components/job-selector-demo.js +0 -1
  70. package/dist/components/job-selector.js +0 -1
  71. package/dist/components/neobrutal-search.d.ts +0 -11
  72. package/dist/components/neobrutal-search.js +0 -1
  73. package/dist/components/search.engine.js +0 -1
  74. package/dist/esm/geo-valjaren.entry.js +0 -14908
  75. package/dist/esm/job-selector-demo.entry.js +0 -688
  76. package/dist/esm/neobrutal-search.entry.js +0 -169
  77. package/dist/esm/search.engine-BaWUTc3r.js +0 -493
  78. package/dist/esm/taxonomy-registry-C-pSh51L.js +0 -449
  79. package/dist/esm/types-DHUftoZJ.js +0 -12
  80. package/dist/types/components/geovaljaren/geovaljaren.d.ts +0 -24
  81. package/dist/types/components/geovaljaren/logic/adapter.utils.d.ts +0 -7
  82. package/dist/types/components/geovaljaren/logic/data.utils.d.ts +0 -7
  83. package/dist/types/components/geovaljaren/logic/history-service.d.ts +0 -6
  84. package/dist/types/components/geovaljaren/logic/search.engine.d.ts +0 -7
  85. package/dist/types/components/job-selector-demo/job-selector-demo.d.ts +0 -65
  86. package/dist/types/components/neobrutal-search/neobrutal-search.d.ts +0 -18
  87. package/dist/types/verkstad/verkstad.d.ts +0 -1
  88. package/dist/types/vitest-globals.d.ts +0 -1
  89. package/dist/yrkesvaljaren/p-5c3a5308.entry.js +0 -1
  90. package/dist/yrkesvaljaren/p-9ecd5177.entry.js +0 -1
  91. package/dist/yrkesvaljaren/p-BPnhMTul.js +0 -1
  92. package/dist/yrkesvaljaren/p-C-pSh51L.js +0 -1
  93. package/dist/yrkesvaljaren/p-CjMoDiZD.js +0 -1
  94. package/dist/yrkesvaljaren/p-DHUftoZJ.js +0 -1
  95. package/dist/yrkesvaljaren/p-HNd02eQb.js +0 -3
  96. package/dist/yrkesvaljaren/p-b6130085.entry.js +0 -1
  97. package/dist/yrkesvaljaren/p-dbbea724.entry.js +0 -1
  98. package/dist/yrkesvaljaren/p-df3fa43b.entry.js +0 -1
@@ -1,304 +0,0 @@
1
- import { h } from "@stencil/core";
2
- import { GeoDataService } from "./logic/data.utils";
3
- import { SearchEngine } from "./logic/search.engine";
4
- import { GeoHistoryService } from "./logic/history-service";
5
- export class Geovaljaren {
6
- label = 'Din kommun';
7
- placeholder = 'Vilken kommun bor du i?';
8
- selectorState = {
9
- status: 'loading',
10
- inputValue: '',
11
- suggestions: [],
12
- selectedItems: [],
13
- validation: 'idle'
14
- };
15
- selectionEmitter;
16
- config = {
17
- placeholder: this.placeholder,
18
- minLength: 1,
19
- maxResults: 10,
20
- enableMultiple: false,
21
- showSearchIcon: true,
22
- requireSelection: true,
23
- size: 'medium',
24
- enableToast: false,
25
- showHistoryHeader: true
26
- };
27
- engine = null;
28
- allGeoItems = [];
29
- async componentWillLoad() {
30
- this.selectorState = { ...this.selectorState, status: 'loading' };
31
- try {
32
- this.allGeoItems = await GeoDataService.fetchAll();
33
- this.engine = new SearchEngine(this.allGeoItems);
34
- this.selectorState = { ...this.selectorState, status: 'searching' };
35
- }
36
- catch (err) {
37
- console.error('Failed to load geo data', err);
38
- this.selectorState = { ...this.selectorState, status: 'error', message: 'Kunde inte ladda kommuner.' };
39
- }
40
- }
41
- showHistory() {
42
- if (!this.allGeoItems.length)
43
- return;
44
- // Don't show history if there's typed text
45
- if (this.selectorState.inputValue.trim() !== '')
46
- return;
47
- const historyItems = GeoHistoryService.loadHistory();
48
- // Lazy Validation: Only show items that still exist in our current dataset
49
- const validatedHistory = historyItems.filter(hItem => this.allGeoItems.some(item => item.id === hItem.id));
50
- this.selectorState = {
51
- ...this.selectorState,
52
- status: 'searching',
53
- suggestions: validatedHistory,
54
- inputValue: this.selectorState.inputValue
55
- };
56
- }
57
- addToHistory(item) {
58
- const currentHistory = GeoHistoryService.loadHistory();
59
- const filtered = currentHistory.filter(h => h.id !== item.id);
60
- const newHistory = [item, ...filtered].slice(0, 10);
61
- GeoHistoryService.saveHistory(newHistory);
62
- }
63
- clearHistory() {
64
- GeoHistoryService.clearHistory();
65
- this.selectorState = {
66
- ...this.selectorState,
67
- suggestions: []
68
- };
69
- }
70
- handleInput(event) {
71
- const query = event.detail;
72
- if (!this.engine)
73
- return;
74
- if (query.trim() === '') {
75
- this.selectorState = { ...this.selectorState, inputValue: '' };
76
- this.showHistory();
77
- return;
78
- }
79
- const suggestions = query.length >= this.config.minLength ? this.engine.search(query) : [];
80
- const wasInError = this.selectorState.validation === 'error' || this.selectorState.validationContext === 'from-error';
81
- this.selectorState = {
82
- ...this.selectorState,
83
- inputValue: query,
84
- suggestions,
85
- status: 'searching',
86
- validation: 'idle',
87
- validationContext: wasInError ? 'from-error' : undefined
88
- };
89
- }
90
- handleFocus() {
91
- // Handled by csRequestHistory
92
- }
93
- handleRequestHistory() {
94
- this.showHistory();
95
- }
96
- handleSelect(event) {
97
- const selection = event.detail;
98
- const wasInError = this.selectorState.validation === 'error' || this.selectorState.validationContext === 'from-error';
99
- this.addToHistory(selection);
100
- this.selectorState = {
101
- ...this.selectorState,
102
- status: 'itemSelected',
103
- selectedItem: selection,
104
- suggestions: [],
105
- inputValue: selection.label, // Keep label as input value
106
- validation: wasInError ? 'success' : 'idle',
107
- message: wasInError ? 'Klart!' : '',
108
- validationContext: wasInError ? 'from-error' : undefined
109
- };
110
- this.selectionEmitter.emit(selection);
111
- if (wasInError) {
112
- setTimeout(() => {
113
- if (this.selectorState.status === 'itemSelected' && this.selectorState.validation === 'success') {
114
- this.selectorState = { ...this.selectorState, validation: 'idle' };
115
- }
116
- }, 3000);
117
- }
118
- }
119
- handleBlur() {
120
- if (this.selectorState.status === 'searching' && this.selectorState.inputValue.trim() !== '') {
121
- const suggestions = this.selectorState.suggestions;
122
- if (suggestions.length === 0) {
123
- this.selectorState = {
124
- ...this.selectorState,
125
- validation: 'error',
126
- message: 'Du måste välja ett alternativ från listan.'
127
- };
128
- }
129
- }
130
- }
131
- handleClear() {
132
- // Only clear if explicitly triggered by the X button
133
- this.selectorState = {
134
- ...this.selectorState,
135
- status: 'searching',
136
- inputValue: '',
137
- suggestions: [],
138
- selectedItem: undefined,
139
- validation: 'idle',
140
- validationContext: undefined
141
- };
142
- this.showHistory();
143
- }
144
- handleCsClearHistory() {
145
- this.clearHistory();
146
- }
147
- handleEdit() {
148
- const wasInError = this.selectorState.validation === 'error' || this.selectorState.validationContext === 'from-error';
149
- // When clicking to edit, keep the label of the item as search text
150
- const currentLabel = this.selectorState.selectedItem?.label || '';
151
- this.selectorState = {
152
- ...this.selectorState,
153
- status: 'searching',
154
- inputValue: currentLabel,
155
- suggestions: [],
156
- validation: 'idle',
157
- validationContext: wasInError ? 'from-error' : undefined
158
- };
159
- // Don't show history if we have text
160
- if (currentLabel === '') {
161
- this.showHistory();
162
- }
163
- }
164
- render() {
165
- return (h("div", { key: '5f7e4f0fb8fa815145ddd5690894ec7906dc2f1a', class: "geo-valjaren-wrapper" }, h("core-selector", { key: '73940c1ae5092f5f5f84bbd53edc6112e4374310', state: this.selectorState, config: { ...this.config, placeholder: this.placeholder }, label: this.label, labelDescription: "Ange den kommun du bor i f\u00F6r att se pendlingsalternativ" })));
166
- }
167
- static get is() { return "geo-valjaren"; }
168
- static get encapsulation() { return "shadow"; }
169
- static get originalStyleUrls() {
170
- return {
171
- "$": ["geovaljaren.css"]
172
- };
173
- }
174
- static get styleUrls() {
175
- return {
176
- "$": ["geovaljaren.css"]
177
- };
178
- }
179
- static get properties() {
180
- return {
181
- "label": {
182
- "type": "string",
183
- "mutable": false,
184
- "complexType": {
185
- "original": "string",
186
- "resolved": "string",
187
- "references": {}
188
- },
189
- "required": false,
190
- "optional": false,
191
- "docs": {
192
- "tags": [],
193
- "text": ""
194
- },
195
- "getter": false,
196
- "setter": false,
197
- "reflect": true,
198
- "attribute": "af-label",
199
- "defaultValue": "'Din kommun'"
200
- },
201
- "placeholder": {
202
- "type": "string",
203
- "mutable": false,
204
- "complexType": {
205
- "original": "string",
206
- "resolved": "string",
207
- "references": {}
208
- },
209
- "required": false,
210
- "optional": false,
211
- "docs": {
212
- "tags": [],
213
- "text": ""
214
- },
215
- "getter": false,
216
- "setter": false,
217
- "reflect": true,
218
- "attribute": "af-placeholder",
219
- "defaultValue": "'Vilken kommun bor du i?'"
220
- }
221
- };
222
- }
223
- static get states() {
224
- return {
225
- "selectorState": {}
226
- };
227
- }
228
- static get events() {
229
- return [{
230
- "method": "selectionEmitter",
231
- "name": "afGeoSelected",
232
- "bubbles": true,
233
- "cancelable": true,
234
- "composed": true,
235
- "docs": {
236
- "tags": [],
237
- "text": ""
238
- },
239
- "complexType": {
240
- "original": "GenericItem | null",
241
- "resolved": "GenericItem<unknown> | null",
242
- "references": {
243
- "GenericItem": {
244
- "location": "import",
245
- "path": "../core-selector/types",
246
- "id": "src/components/core-selector/types.ts::GenericItem",
247
- "referenceLocation": "GenericItem"
248
- }
249
- }
250
- }
251
- }];
252
- }
253
- static get listeners() {
254
- return [{
255
- "name": "csInput",
256
- "method": "handleInput",
257
- "target": undefined,
258
- "capture": false,
259
- "passive": false
260
- }, {
261
- "name": "csFocus",
262
- "method": "handleFocus",
263
- "target": undefined,
264
- "capture": false,
265
- "passive": false
266
- }, {
267
- "name": "csRequestHistory",
268
- "method": "handleRequestHistory",
269
- "target": undefined,
270
- "capture": false,
271
- "passive": false
272
- }, {
273
- "name": "csSelect",
274
- "method": "handleSelect",
275
- "target": undefined,
276
- "capture": false,
277
- "passive": false
278
- }, {
279
- "name": "csBlur",
280
- "method": "handleBlur",
281
- "target": undefined,
282
- "capture": false,
283
- "passive": false
284
- }, {
285
- "name": "csClear",
286
- "method": "handleClear",
287
- "target": undefined,
288
- "capture": false,
289
- "passive": false
290
- }, {
291
- "name": "csClearHistory",
292
- "method": "handleCsClearHistory",
293
- "target": undefined,
294
- "capture": false,
295
- "passive": false
296
- }, {
297
- "name": "csEditSelection",
298
- "method": "handleEdit",
299
- "target": undefined,
300
- "capture": false,
301
- "passive": false
302
- }];
303
- }
304
- }
@@ -1,20 +0,0 @@
1
- export const GeoAdapter = {
2
- /**
3
- * Transforms the pendlingskommuner JSON data structure into GenericItems.
4
- */
5
- toGenericItems: (jsonData) => {
6
- if (!jsonData || !jsonData.data) {
7
- console.warn("Invalid JSON data structure for GeoAdapter");
8
- return [];
9
- }
10
- // jsonData.data is an object where keys are IDs
11
- return Object.entries(jsonData.data).map(([id, value]) => {
12
- return {
13
- id: id,
14
- label: value.preferred_label || 'Okänd kommun',
15
- description: `Kommun-ID: ${id}`, // We don't have much else to show right now
16
- metadata: value // Keep original for destinations access later if needed
17
- };
18
- });
19
- }
20
- };
@@ -1,12 +0,0 @@
1
- import geoData from "../assets/pendlingskommuner.json";
2
- import { GeoAdapter } from "./adapter.utils";
3
- export const GeoDataService = {
4
- /**
5
- * Simulates an async fetch of geo data
6
- */
7
- fetchAll: async () => {
8
- // Simulate network delay
9
- await new Promise(resolve => setTimeout(resolve, 500));
10
- return GeoAdapter.toGenericItems(geoData);
11
- }
12
- };
@@ -1,25 +0,0 @@
1
- export const GeoHistoryService = {
2
- saveHistory(history) {
3
- try {
4
- localStorage.setItem('geovaljaren_history', JSON.stringify(history));
5
- }
6
- catch (e) {
7
- console.error('[GeoHistoryService] Kunde inte spara historik.', e);
8
- }
9
- },
10
- loadHistory() {
11
- try {
12
- const historyString = localStorage.getItem('geovaljaren_history');
13
- if (historyString) {
14
- return JSON.parse(historyString);
15
- }
16
- }
17
- catch (e) {
18
- console.error('[GeoHistoryService] Kunde inte läsa historik.', e);
19
- }
20
- return [];
21
- },
22
- clearHistory() {
23
- localStorage.removeItem('geovaljaren_history');
24
- }
25
- };
@@ -1,28 +0,0 @@
1
- import Fuse from "fuse.js";
2
- const FUSE_OPTIONS = {
3
- includeScore: true,
4
- threshold: 0.3,
5
- keys: [
6
- { name: 'label', weight: 2 },
7
- { name: 'description', weight: 1 }
8
- ],
9
- shouldSort: true,
10
- minMatchCharLength: 1,
11
- };
12
- export class SearchEngine {
13
- fuse = null;
14
- constructor(data) {
15
- this.updateIndex(data);
16
- }
17
- search(query, maxResults = 10) {
18
- if (!this.fuse || !query)
19
- return [];
20
- // Fuse search
21
- const results = this.fuse.search(query);
22
- // Map back to item
23
- return results.map(r => r.item).slice(0, maxResults);
24
- }
25
- updateIndex(newData) {
26
- this.fuse = new Fuse(newData, FUSE_OPTIONS);
27
- }
28
- }