@arbetsformedlingen/yrkesvaljaren 2.0.5

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 (146) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +369 -0
  3. package/dist/cjs/af-validation-message-BzY5H0xU.js +16 -0
  4. package/dist/cjs/core-selector.cjs.entry.js +476 -0
  5. package/dist/cjs/digi-service-job-selector.cjs.entry.js +1619 -0
  6. package/dist/cjs/fuse-BTLNKxuL.js +1631 -0
  7. package/dist/cjs/geo-valjaren.cjs.entry.js +14910 -0
  8. package/dist/cjs/index-BOuTGlEp.js +1817 -0
  9. package/dist/cjs/index.cjs.js +14 -0
  10. package/dist/cjs/job-selector-demo.cjs.entry.js +692 -0
  11. package/dist/cjs/loader.cjs.js +12 -0
  12. package/dist/cjs/neobrutal-search.cjs.entry.js +171 -0
  13. package/dist/cjs/search.engine-D0cMelRi.js +489 -0
  14. package/dist/cjs/taxonomy-registry-DVmuDUpM.js +435 -0
  15. package/dist/cjs/types-CtHBl6Ra.js +14 -0
  16. package/dist/cjs/yrkesvaljaren.cjs.js +24 -0
  17. package/dist/collection/collection-manifest.json +15 -0
  18. package/dist/collection/components/core-selector/core-selector.css +803 -0
  19. package/dist/collection/components/core-selector/core-selector.js +761 -0
  20. package/dist/collection/components/core-selector/types.js +1 -0
  21. package/dist/collection/components/design-compat/af-icon.js +13 -0
  22. package/dist/collection/components/design-compat/af-label.js +2 -0
  23. package/dist/collection/components/design-compat/af-tag.js +6 -0
  24. package/dist/collection/components/design-compat/af-validation-message.js +11 -0
  25. package/dist/collection/components/design-compat/index.js +4 -0
  26. package/dist/collection/components/geovaljaren/geovaljaren.css +21 -0
  27. package/dist/collection/components/geovaljaren/geovaljaren.js +304 -0
  28. package/dist/collection/components/geovaljaren/logic/adapter.utils.js +20 -0
  29. package/dist/collection/components/geovaljaren/logic/data.utils.js +12 -0
  30. package/dist/collection/components/geovaljaren/logic/history-service.js +25 -0
  31. package/dist/collection/components/geovaljaren/logic/search.engine.js +28 -0
  32. package/dist/collection/components/job-selector/constants.js +26 -0
  33. package/dist/collection/components/job-selector/history-service.js +41 -0
  34. package/dist/collection/components/job-selector/job-selector-controller.js +835 -0
  35. package/dist/collection/components/job-selector/job-selector.css +318 -0
  36. package/dist/collection/components/job-selector/job-selector.js +1378 -0
  37. package/dist/collection/components/job-selector/keyboard-handlers.js +84 -0
  38. package/dist/collection/components/job-selector/logic/adapter.utils.js +75 -0
  39. package/dist/collection/components/job-selector/logic/label-formatter.js +118 -0
  40. package/dist/collection/components/job-selector/logic/search.engine.js +50 -0
  41. package/dist/collection/components/job-selector/search-logic.js +35 -0
  42. package/dist/collection/components/job-selector/search.utils.js +224 -0
  43. package/dist/collection/components/job-selector/suggestions-list.js +31 -0
  44. package/dist/collection/components/job-selector/taxonomy-registry.js +60 -0
  45. package/dist/collection/components/job-selector/test-data.mock.js +33 -0
  46. package/dist/collection/components/job-selector/types.js +10 -0
  47. package/dist/collection/components/job-selector/validation-message.js +24 -0
  48. package/dist/collection/demo-data.js +20 -0
  49. package/dist/collection/index.js +7 -0
  50. package/dist/collection/verkstad/verkstad.js +407 -0
  51. package/dist/components/core-selector.d.ts +11 -0
  52. package/dist/components/core-selector.js +1 -0
  53. package/dist/components/core-selector2.js +1 -0
  54. package/dist/components/digi-service-job-selector.d.ts +11 -0
  55. package/dist/components/digi-service-job-selector.js +1 -0
  56. package/dist/components/fuse.js +1 -0
  57. package/dist/components/geo-valjaren.d.ts +11 -0
  58. package/dist/components/geo-valjaren.js +1 -0
  59. package/dist/components/index.d.ts +35 -0
  60. package/dist/components/index.js +1 -0
  61. package/dist/components/job-selector-demo.d.ts +11 -0
  62. package/dist/components/job-selector-demo.js +1 -0
  63. package/dist/components/job-selector.js +1 -0
  64. package/dist/components/neobrutal-search.d.ts +11 -0
  65. package/dist/components/neobrutal-search.js +1 -0
  66. package/dist/components/search.engine.js +1 -0
  67. package/dist/components/types.js +1 -0
  68. package/dist/esm/af-validation-message-F8NIH2rC.js +14 -0
  69. package/dist/esm/core-selector.entry.js +474 -0
  70. package/dist/esm/digi-service-job-selector.entry.js +1617 -0
  71. package/dist/esm/fuse-BPnhMTul.js +1629 -0
  72. package/dist/esm/geo-valjaren.entry.js +14908 -0
  73. package/dist/esm/index-CGXZllj2.js +1806 -0
  74. package/dist/esm/index.js +10 -0
  75. package/dist/esm/job-selector-demo.entry.js +690 -0
  76. package/dist/esm/loader.js +10 -0
  77. package/dist/esm/neobrutal-search.entry.js +169 -0
  78. package/dist/esm/search.engine-nZ7AcXba.js +479 -0
  79. package/dist/esm/taxonomy-registry-Dw0VR9Aw.js +430 -0
  80. package/dist/esm/types-DHUftoZJ.js +12 -0
  81. package/dist/esm/yrkesvaljaren.js +20 -0
  82. package/dist/index.cjs.js +1 -0
  83. package/dist/index.js +1 -0
  84. package/dist/types/components/core-selector/core-selector.d.ts +46 -0
  85. package/dist/types/components/core-selector/types.d.ts +1 -0
  86. package/dist/types/components/design-compat/af-icon.d.ts +7 -0
  87. package/dist/types/components/design-compat/af-label.d.ts +8 -0
  88. package/dist/types/components/design-compat/af-tag.d.ts +8 -0
  89. package/dist/types/components/design-compat/af-validation-message.d.ts +9 -0
  90. package/dist/types/components/design-compat/index.d.ts +5 -0
  91. package/dist/types/components/geovaljaren/geovaljaren.d.ts +24 -0
  92. package/dist/types/components/geovaljaren/logic/adapter.utils.d.ts +7 -0
  93. package/dist/types/components/geovaljaren/logic/data.utils.d.ts +7 -0
  94. package/dist/types/components/geovaljaren/logic/history-service.d.ts +6 -0
  95. package/dist/types/components/geovaljaren/logic/search.engine.d.ts +7 -0
  96. package/dist/types/components/job-selector/ambient.d.ts +4 -0
  97. package/dist/types/components/job-selector/constants.d.ts +13 -0
  98. package/dist/types/components/job-selector/history-service.d.ts +6 -0
  99. package/dist/types/components/job-selector/job-selector-controller.d.ts +82 -0
  100. package/dist/types/components/job-selector/job-selector.d.ts +140 -0
  101. package/dist/types/components/job-selector/keyboard-handlers.d.ts +13 -0
  102. package/dist/types/components/job-selector/logic/adapter.utils.d.ts +12 -0
  103. package/dist/types/components/job-selector/logic/label-formatter.d.ts +4 -0
  104. package/dist/types/components/job-selector/logic/search.engine.d.ts +21 -0
  105. package/dist/types/components/job-selector/search-logic.d.ts +17 -0
  106. package/dist/types/components/job-selector/search.utils.d.ts +10 -0
  107. package/dist/types/components/job-selector/suggestions-list.d.ts +13 -0
  108. package/dist/types/components/job-selector/taxonomy-registry.d.ts +20 -0
  109. package/dist/types/components/job-selector/test-data.mock.d.ts +7 -0
  110. package/dist/types/components/job-selector/types.d.ts +107 -0
  111. package/dist/types/components/job-selector/validation-message.d.ts +8 -0
  112. package/dist/types/components/job-selector-demo/job-selector-demo.d.ts +55 -0
  113. package/dist/types/components/neobrutal-search/neobrutal-search.d.ts +18 -0
  114. package/dist/types/components.d.ts +425 -0
  115. package/dist/types/demo-data.d.ts +16 -0
  116. package/dist/types/index.d.ts +5 -0
  117. package/dist/types/stencil-public-runtime.d.ts +1873 -0
  118. package/dist/types/verkstad/verkstad.d.ts +1 -0
  119. package/dist/yrkesvaljaren/fuse-B0eHOxow.js.map +1 -0
  120. package/dist/yrkesvaljaren/index-Cy4BCo5s.js.map +1 -0
  121. package/dist/yrkesvaljaren/index-DfJXTQqL.js.map +1 -0
  122. package/dist/yrkesvaljaren/index.esm.js +1 -0
  123. package/dist/yrkesvaljaren/index.esm.js.map +1 -0
  124. package/dist/yrkesvaljaren/p-16636162.entry.js +1 -0
  125. package/dist/yrkesvaljaren/p-273cf6df.entry.js +1 -0
  126. package/dist/yrkesvaljaren/p-9e48afa4.entry.js +1 -0
  127. package/dist/yrkesvaljaren/p-BPnhMTul.js +1 -0
  128. package/dist/yrkesvaljaren/p-CGXZllj2.js +3 -0
  129. package/dist/yrkesvaljaren/p-DHUftoZJ.js +1 -0
  130. package/dist/yrkesvaljaren/p-DYFAzvqX.js +1 -0
  131. package/dist/yrkesvaljaren/p-Dw0VR9Aw.js +1 -0
  132. package/dist/yrkesvaljaren/p-aef7b5ae.entry.js +1 -0
  133. package/dist/yrkesvaljaren/p-b0f16abd.entry.js +1 -0
  134. package/dist/yrkesvaljaren/p-uBrs3sSs.js +1 -0
  135. package/dist/yrkesvaljaren/search.engine-DPT6roRm.js.map +1 -0
  136. package/dist/yrkesvaljaren/taxonomy-registry-s5khf6s4.js.map +1 -0
  137. package/dist/yrkesvaljaren/types-DHUftoZJ.js.map +1 -0
  138. package/dist/yrkesvaljaren/yrkesvaljaren.css +1 -0
  139. package/dist/yrkesvaljaren/yrkesvaljaren.esm.js +1 -0
  140. package/dist/yrkesvaljaren/yrkesvaljaren.esm.js.map +1 -0
  141. package/loader/cdn.js +1 -0
  142. package/loader/index.cjs.js +1 -0
  143. package/loader/index.d.ts +24 -0
  144. package/loader/index.es2017.js +1 -0
  145. package/loader/index.js +2 -0
  146. package/package.json +126 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2024 Arbetsförmedlingen
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,369 @@
1
+ # Yrkesväljaren webbkomponent
2
+
3
+ En robust och intelligent sökkomponent för svenska yrken, designad för hög prestanda och tillförlitlighet. Den integrerar yrken från Arbetsförmedlingens taxonomi i valfri webbapplikation.
4
+
5
+ ---
6
+
7
+
8
+ ### Beskrivning
9
+
10
+ * **Enkelt hitta rätt yrke för användaren** <br>Sökalgoritmen prioriterar exakta träffar, prefix, flerdelade direktträffar och innehåller-träffar. Om inga direktträffar finns kan upp till tre fuzzy-träffar visas. Viktdata används som sekundär sortering.
11
+ * **Hög prestanda:** <br>Sökningen sker lokalt i webbläsaren mot inläst yrkesdata. Komponenten gör inga sökanrop till Taxonomy API.
12
+ * **Flexibel datahantering:** <br>Välj mellan automatiskt uppdaterad data, ett versionerat npm-datapaket eller en egen URL.
13
+
14
+ ---
15
+
16
+ ### Installation
17
+
18
+ Runtime-komponenten kräver inte `@designsystem-se/af`. Den följer Arbetsförmedlingens visuella designsystem via lokala tokens och primitives, men registrerar inga designsystem-webbkomponenter.
19
+
20
+ 1. **Konfigurera NPM-scope:** Skapa en `.npmrc`-fil i roten av ditt projekt.
21
+ ```ini
22
+ @taxonomy:registry=https://gitlab.com/api/v4/projects/74569456/packages/npm/
23
+
24
+ ```
25
+ 2. **Installera komponenten med senaste data:**
26
+ ```bash
27
+ npm install @taxonomy/yrkesvaljaren
28
+ ```
29
+
30
+ När ingen datakälla anges hämtar komponenten senaste publicerade yrkesdata automatiskt.
31
+
32
+ 3. **Alternativ: installera ett versionerat datapaket:**
33
+ ```bash
34
+ npm install @taxonomy/yrkesvaljaren @taxonomy/yrkesvaljaren-data-v30
35
+ ```
36
+
37
+ Detta låser taxonomiversionen vid build time. Registrera paketets data innan komponenten används:
38
+
39
+ ```javascript
40
+ import { registerTaxonomy } from '@taxonomy/yrkesvaljaren';
41
+ import {
42
+ taxonomyData,
43
+ metadata
44
+ } from '@taxonomy/yrkesvaljaren-data-v30';
45
+
46
+ registerTaxonomy({ data: taxonomyData, metadata });
47
+ ```
48
+
49
+ `af-taxonomy-url` är ett tredje, avancerat alternativ. Ange då en fullständig, explicit URL till den datafil som ska användas.
50
+
51
+ ### Användning
52
+
53
+ För att snabbt komma igång, här är ett komplett HTML-exempel som visar hur du inkluderar och använder Yrkesväljaren:
54
+
55
+ ```html
56
+ <!DOCTYPE html>
57
+ <html lang="sv">
58
+ <head>
59
+ <meta charset="UTF-8">
60
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
61
+ <title>Yrkesväljaren exempel</title>
62
+ </head>
63
+ <body>
64
+
65
+ <h1>Yrkesväljaren exempel</h1>
66
+
67
+ <!-- Komponenten -->
68
+ <digi-service-job-selector af-label="Välj yrke"></digi-service-job-selector>
69
+ <script type="module">
70
+
71
+ // Imports (sökväg beror på ditt byggverktyg)
72
+ import { defineCustomElements as defineYrkesvaljaren } from "@taxonomy/yrkesvaljaren/loader";
73
+ defineYrkesvaljaren(window);
74
+ document.querySelector("digi-service-job-selector")
75
+ .addEventListener("afJobSelected", (e) => {
76
+ console.log("Valt yrke:", e.detail);
77
+ });
78
+ </script>
79
+
80
+ </body>
81
+ </html>
82
+ ```
83
+
84
+ ### Vite
85
+
86
+ Yrkesväljaren använder en Stencil-loader som hämtar komponenternas entry-filer dynamiskt. I Vite ska loader-paketet därför undantas från dependency optimizer, annars kan Vite flytta loadern till `.vite/deps` och de dynamiska importerna får fel sökväg.
87
+
88
+ ```javascript
89
+ // vite.config.js
90
+ export default {
91
+ optimizeDeps: {
92
+ exclude: [
93
+ '@taxonomy/yrkesvaljaren/loader',
94
+ ],
95
+ },
96
+ };
97
+ ```
98
+
99
+ ### Designsystem-kompatibilitet
100
+
101
+ Runtime-komponenten kräver inte `@designsystem-se/af`, registrerar inga designsystem-webbkomponenter och krockar inte om host-appen redan använder det riktiga designsystemet. Komponenten innehåller en liten lokal kompatibilitetsyta med AF-liknande design tokens, typografi, färger, fokusramar och ikoner. Demosidan i repo:t använder fortfarande designsystemet för dokumentationslayout och visuell referens.
102
+
103
+ De lokala tokenvärdena och primitive-stilarna är anpassade från Arbetsförmedlingens designsystem under Apache-2.0 och används bara för att runtime-komponenterna ska rendera fristående.
104
+
105
+ ### Attribut
106
+
107
+ | Attribut | Beskrivning | Typ | Standardvärde |
108
+ |:---|:---|:---|:---|
109
+ | `af-label` | Etikettext som visas ovanför sökfältet. | `string` | `'Välj yrke'` |
110
+ | `disabled` | Om satt till `true`, kan väljaren inte användas med mus eller tangentbord. | `boolean` | `false` |
111
+ | `af-label-description`| En valfri beskrivningstext som visas under etiketten. | `string` | `undefined` |
112
+ | `af-placeholder` | Hjälptext som visas inuti sökfältet. Denna är ett bra stöd för de med kognitiv funktionsvariation - rekommendationen är att behålla denna text, och att inte flytta den till `description`. | `string` | `'T.ex. frisör, vårdbiträde, snickare'` |
113
+ | `af-error-message` | Ett anpassat felmeddelande som visas vid valideringsfel. | `string` | `undefined` |
114
+ | `af-enable-multiple` | Om satt till `true`, tillåts val av flera yrken. | `boolean` | `false` |
115
+ | `af-history` | Sparar användarval lokalt i webbläsarens Local Storage och visar historiken på samma domän. | `boolean` | `true` |
116
+ | `af-required` | Om satt till `true`, måste användaren göra ett val för att fältet ska vara giltigt (obligatoriskt fält). | `boolean` | `false` |
117
+ | `af-manual-input` | Om satt till `true`, tillåts användaren att ange ett yrke fritt via fritext som inte finns i listan. Om satt till `false` måste ett fördefinierat yrke väljas. | `boolean` | `false` |
118
+ | `af-size` | Storleken på inputfältet. Möjliga värden: `'small'`, `'medium'`, `'large'`. | `string` | `'medium'` |
119
+ | `af-popular` | Om satt till `true`, visas sektionen "Populära sökningar" när historiken är tom. | `boolean` | `true` |
120
+ | `af-taxonomy-url` | Fullständig, explicit URL till en egenhostad datafil. Utelämna attributet för att använda senaste data automatiskt. | `string` | `undefined` |
121
+
122
+ ### Riktlinjer och rekommendationer
123
+
124
+ Tre centrala inställningar styr användarupplevelsen och datakvaliteten i Yrkesväljaren:
125
+
126
+ #### Obligatorisk (`af-required`)
127
+ * **Hur man kan resonera:** När `af-required="true"` måste användaren välja minst ett yrke för att fältet ska betraktas som giltigt. Komponenten fungerar som ett standardenligt *Form-Associated Custom Element* (FACE). Det innebär att webbläsaren automatiskt validerar fältet vid formulärinskick, förhindrar att formuläret skickas in om det är tomt, och integrerar med formulärets `validity`-status.
128
+ * **När det rekommenderas:** I formulär och flöden där ett yrkesval är ett obligatoriskt steg i ett ärende (t.ex. registrering av profil, jobbansökan eller behörighetskontroll).
129
+ * **När det bör undvikas:** I öppna sök- eller filtreringsvyer där användaren ska kunna söka brett, filtrera på andra parametrar (t.ex. enbart ort/geografi) eller frivilligt specificera yrke.
130
+
131
+ #### Tillåt fritext (`af-manual-input`)
132
+ * **Hur man kan resonera:** Avgör om användaren strikt måste välja ett strukturerat yrkesbegrepp ur Arbetsförmedlingens taxonomi (vilket garanterar Concept ID och SSYK-kod), eller om användaren även tillåts mata in egna fritextvärden som inte finns i taxonomin. Vid fritext visas valet *"Använd '{inmatning}'"* i listan som användaren aktivt väljer eller bekräftar med Enter.
133
+ * **När det rekommenderas:**
134
+ * **Strikt taxonomi (`af-manual-input="false"` – standard & rekommenderas):** När yrkesdatan ska användas för automatisk matchning, statistiska analyser, maskininlärning eller integration mot backend-system som förutsätter Concept ID. Detta säkerställer hög datakvalitet.
135
+ * **Fritext tillåten (`af-manual-input="true"`):** I öppna fritextprofiler, fritextenkäter eller intresseanmälningar där det är viktigare att fånga upp vad användaren själv kallar sin roll än att få ett taxonomi-ID, eller där man inte vill blockera användare med ovanliga, nischade eller internationella titlar.
136
+
137
+ #### Tillåt historik (`af-history`)
138
+ * **Hur man kan resonera:** Sparar gjorda val i webbläsarens `localStorage` per domän och visar dem som *"Tidigare val"* när användaren fokuserar ett tomt sökfält.
139
+ * **När det rekommenderas:** I flöden där användaren ofta gör återkommande sökningar (t.ex. jobbsökare eller handläggare).
140
+ * **När det bör undvikas:** På delade publika terminaler eller kioskdatorer (t.ex. på Arbetsförmedlingens servicekontor eller bibliotek) där personers tidigare sökningar inte ska sparas eller exponeras för efterföljande besökare på samma dator.
141
+
142
+ ### Välj datakälla
143
+
144
+ Välj ett av följande sätt:
145
+
146
+ 1. Registrera ett versionerat datapaket med `registerTaxonomy(...)`.
147
+ 2. Ange en fullständig URL med `af-taxonomy-url` för en egenhostad datafil.
148
+ 3. Utelämna båda för att använda senaste data automatiskt.
149
+
150
+ En angiven `af-taxonomy-url` är den valda datakällan. Om URL:en inte kan laddas
151
+ går komponenten till felläge och skickar `afJobDataLoadFailed`.
152
+ <br>
153
+
154
+ ### Events
155
+
156
+ | Händelse | Beskrivning |
157
+ |:---|:---|
158
+ | `afJobSelected` | Skickas ut när användaren ändrar valet. `event.detail` innehåller `JobSelectionItem[]` som kan skickas tillbaka till `setSelection()`. |
159
+ | `afJobDataLoadFailed` | Skickas när laddningen av yrkesdata misslyckas. |
160
+ | `afJobValidationChange` | Skickas när komponenten kör validering efter att fältet har berörts. `event.detail` innehåller `{ isValid: boolean, errorType: 'required'|'invalidInput'|null }`. |
161
+
162
+ ### Metoder
163
+
164
+ Yrkesväljaren exponerar några metoder för värdapplikationer som behöver styra
165
+ komponenten från JavaScript. De vanligaste är `setSelection(...)` och
166
+ `setFocus()`. Övriga metoder finns för formulärintegration och dynamisk
167
+ dataladdning.
168
+
169
+ #### Primära metoder
170
+
171
+ | Metod | Returvärde | Beskrivning |
172
+ |:---|:---|:---|
173
+ | `setSelection(input)` | `Promise<JobSelectionItem[]>` | Sätter eller rensar ett programmatiskt val. Returnerar komponentens normaliserade selection. |
174
+ | `setFocus()` | `Promise<void>` | Flyttar fokus till sökfältet. Används när värdappen till exempel öppnar en modal eller vill fokusera fältet efter ett fel. |
175
+
176
+ #### Formulärvalidering
177
+
178
+ Yrkesväljaren är ett form-associated custom element. Det betyder att den kan
179
+ delta i vanliga HTML-formulär ungefär som ett inbyggt inputfält. Metoderna
180
+ nedan är till för värdapplikationer som behöver läsa eller trigga den
181
+ valideringen manuellt.
182
+
183
+ | Metod | Returvärde | Beskrivning |
184
+ |:---|:---|:---|
185
+ | `validate(forceTouch?)` | `Promise<boolean>` | Kör Yrkesväljarens egen validering. Returnerar `true` om fältet är giltigt. Med `forceTouch=true` visas valideringsfel även om användaren inte hunnit interagera med fältet. |
186
+ | `checkValidity()` | `Promise<boolean>` | Returnerar om komponenten är giltig enligt webbläsarens formulärvalidering. Visar inget felmeddelande i UI. |
187
+ | `reportValidity()` | `Promise<boolean>` | Kör webbläsarens formulärvalidering och låter webbläsaren visa valideringsfeedback om fältet är ogiltigt. |
188
+ | `getValidity()` | `Promise<ValidityState>` | Returnerar webbläsarens detaljerade giltighetsstatus, till exempel om värdet saknas eller om komponenten har satt ett eget fel. De flesta integrationer behöver bara `validate()` eller `checkValidity()`. |
189
+ | `getValidationMessage()` | `Promise<string>` | Returnerar texten som webbläsaren skulle använda som valideringsmeddelande just nu. |
190
+
191
+ #### Dynamisk dataladdning
192
+
193
+ | Metod | Returvärde | Beskrivning |
194
+ |:---|:---|:---|
195
+ | `updateData()` | `Promise<void>` | Läser om data efter ett nytt anrop till `registerTaxonomy(...)`. Behövs bara om värdappen byter taxonomidata efter att komponenten redan har renderats. |
196
+ <br>
197
+
198
+ ### Input och output - programmatisk värdesättning
199
+
200
+ Programmatisk input går endast genom `setSelection()`. Metoden accepterar:
201
+
202
+ * en sträng
203
+ * en array där alla värden är strängar
204
+ * den rika `JobSelectionItem[]` som `afJobSelected` tidigare har returnerat
205
+
206
+ Output är alltid en rik `JobSelectionItem[]`, både från metodens returvärde och från `afJobSelected.detail`.
207
+
208
+ ```typescript
209
+ type JobSelectionItem =
210
+ | {
211
+ type: 'job-title' | 'occupation-name';
212
+ id: string;
213
+ preferred_label: string;
214
+ ssyk_code_2012?: string;
215
+ related?: {
216
+ type: 'occupation-name';
217
+ id: string;
218
+ preferred_label: string;
219
+ };
220
+ }
221
+ | {
222
+ type: 'manual-input';
223
+ id: null;
224
+ preferred_label: string;
225
+ };
226
+ ```
227
+
228
+ För vanliga formulär hämtas värdet lämpligen via `new FormData(form)`. För applikationsstate sparar värdappen metodens returvärde eller `afJobSelected.detail`.
229
+
230
+ `afJobSelected` använder samma format som metoden returnerar. Output kan därför sparas av värdappen och senare skickas tillbaka utan konvertering:
231
+
232
+ ```javascript
233
+ yrkesvaljaren.addEventListener("afJobSelected", async (event) => {
234
+ await annanYrkesvaljare.setSelection(event.detail);
235
+ });
236
+ ```
237
+
238
+ * **Inget valt:** `await yrkesvaljaren.setSelection([])`
239
+ * **Taxonomival in:** `await yrkesvaljaren.setSelection('jrjV_wcz_fxg')`
240
+ * **Taxonomival ut:** `{ type: 'job-title', id: 'jrjV_wcz_fxg', preferred_label: 'Sjuksköterska', ssyk_code_2012: '2221', related: { type: 'occupation-name', id: 'bXNH_MNX_dUR', preferred_label: 'Sjuksköterska, grundutbildad' } }`
241
+ * **Fritext in:** `await yrkesvaljaren.setSelection('Pensionär')` kräver `af-manual-input="true"`
242
+ * **Fritext ut:** `{ type: 'manual-input', id: null, preferred_label: 'Pensionär' }`
243
+
244
+ En sträng som matchar Concept ID-formatet tolkas alltid som ett taxonomi-id och verifieras mot det laddade YV-datasetet. Övriga strängar tolkas som fritext. Fritext kräver `af-manual-input="true"`.
245
+
246
+ Komponenten gör inget anrop till Taxonomy API. För ett rikt taxonomiobjekt identifierar `id` yrket; YV returnerar aktuell metadata från det redan laddade datasetet.
247
+ `ssyk_code_2012` är SSYK 2012-koden när den finns i YV-datat. Komponenten returnerar inget fält som heter `ssyk` och returnerar inte SSYK-nivåns taxonomi-id.
248
+
249
+ Samma input-array får inte blanda strängar och objekt. Flera värden kräver `af-enable-multiple="true"`; metoden aktiverar aldrig flervalsläge automatiskt.
250
+
251
+ ```javascript
252
+ import { InvalidSelectionError } from '@taxonomy/yrkesvaljaren';
253
+
254
+ const yrkesvaljaren = document.querySelector('digi-service-job-selector');
255
+
256
+ try {
257
+ const selection = await yrkesvaljaren.setSelection([
258
+ 'iW55_9hv_bNp',
259
+ 'Pensionär'
260
+ ]);
261
+ console.log('Valda yrken:', selection);
262
+ } catch (error) {
263
+ if (error instanceof InvalidSelectionError) {
264
+ console.error(error.code, error.invalidIds);
265
+ }
266
+ }
267
+ ```
268
+
269
+ Om inputen är ogiltig avvisas Promise-anropet med `InvalidSelectionError`. Senaste giltiga val behålls, ett tydligt fel skrivs med `console.error`, och Yrkesväljaren markeras som `invalidInput` via `afJobValidationChange`. `setSelection()` skickar inte `afJobSelected`; eventet representerar endast användarens val.
270
+
271
+ <br>
272
+
273
+ #### Rensa val (både singel- och flervalsläge)
274
+
275
+ För att programmatiskt rensa gjorda val, anropa `setSelection([])`:
276
+
277
+ ```javascript
278
+ const yrkesvaljaren = document.querySelector('digi-service-job-selector');
279
+ await yrkesvaljaren.setSelection([]);
280
+ ```
281
+
282
+ ---
283
+ <br>
284
+
285
+ ### Validering
286
+
287
+ Komponenten har ett inbyggt, autonomt valideringssystem.
288
+
289
+ #### Obligatoriskt fält
290
+
291
+ För att göra fältet obligatoriskt, använd `af-required`-attributet och ställ in `af-manual-input` på `false`.
292
+
293
+ ```html
294
+ <digi-service-job-selector
295
+ af-label="Välj ett yrke (obligatoriskt)"
296
+ af-required="true"
297
+ af-manual-input="false"
298
+ ></digi-service-job-selector>
299
+ ```
300
+
301
+ När detta är inställt kommer komponenten att visa ett felmeddelande om användaren klickar i och sedan lämnar fältet utan att göra ett giltigt val. Om `af-manual-input` istället är satt till `true` tillåts användaren att ange ett yrke manuellt via fritext.
302
+ <br>
303
+ #### Lyssna på valideringsstatus (`afJobValidationChange`)
304
+
305
+ För att i realtid veta om komponenten är giltig kan du lyssna på `afJobValidationChange`-händelsen.
306
+
307
+ ```javascript
308
+ const yrkesvaljarenElement = document.querySelector('digi-service-job-selector');
309
+
310
+ yrkesvaljarenElement.addEventListener('afJobValidationChange', (event) => {
311
+ const { isValid, errorType } = event.detail;
312
+ console.log(`Är komponenten giltig? ${isValid}`);
313
+ if (!isValid) {
314
+ console.log(`Typ av fel: ${errorType}`); // 'required' eller 'invalidInput'
315
+ }
316
+ });
317
+ ```
318
+ <br>
319
+ #### Manuell validering (`validate()`)
320
+
321
+ För att manuellt trigga en validering, till exempel vid ett formulär-submit, kan du anropa den publika metoden `validate()`.
322
+ <br>
323
+ #### Formulärstöd (FACE)
324
+
325
+ Komponenten agerar som ett inbyggt HTML-formulärelement (`Form-Associated Custom Element`). Detta innebär att om komponenten ligger i ett `<form>` och har `af-required="true"` kommer webbläsaren automatiskt att stoppa inskick av formuläret om fältet är tomt. Det går även bra att hämta värdet via `new FormData(form)`.
326
+
327
+ `name` följer HTML-standard och fungerar som på `<input name="...">`. Det är
328
+ därför inte prefixat med `af-`. Värdet används som fältnamn och nyckel i
329
+ `FormData`.
330
+
331
+ ```html
332
+ <form id="job-form">
333
+ <digi-service-job-selector
334
+ name="occupation"
335
+ af-label="Välj yrke"
336
+ af-required="true">
337
+ </digi-service-job-selector>
338
+ </form>
339
+ ```
340
+
341
+ ```javascript
342
+ const form = document.querySelector('#job-form');
343
+ const yrkesvaljarenElement = document.querySelector('digi-service-job-selector');
344
+
345
+ form.addEventListener('submit', async (e) => {
346
+ e.preventDefault();
347
+ const isComponentValid = await yrkesvaljarenElement.validate();
348
+
349
+ if (isComponentValid) {
350
+ const formData = new FormData(form);
351
+ console.log(formData.get('occupation'));
352
+ console.log('Formuläret är giltigt och kan skickas!');
353
+ // Skicka formulär...
354
+ } else {
355
+ console.log('Formuläret är ogiltigt.');
356
+ }
357
+ });
358
+ ```
359
+ <br>
360
+ ### Utveckling och release
361
+
362
+ Lokala utvecklingskommandon och releaseinstruktioner finns i [CONTRIBUTING.md](CONTRIBUTING.md).
363
+ Komponentpaket publiceras automatiskt av CI från taggar:
364
+ * `vX.Y.Z` publicerar Yrkesväljaren till officiella npm som `@arbetsformedlingen/yrkesvaljaren` (samt till GitLab som `@taxonomy/yrkesvaljaren`).
365
+ * `kv-vX.Y.Z` publicerar Kompetensväljaren.
366
+
367
+ `npm run build` använder endast versionshanterad data och kräver ingen
368
+ nätverksåtkomst. `npm run refresh:data` bygger om samtliga versionerade
369
+ data-workspaces och hämtar då YV-data från upstream.
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-BOuTGlEp.js');
4
+
5
+ const AfValidationMessage = (props, children) => {
6
+ const extraClass = props.class || '';
7
+ return (index.h("div", { id: props.id, role: props.role, class: { [extraClass]: !!extraClass } }, index.h("div", { class: {
8
+ 'af-validation-message': true,
9
+ [`af-validation-message--${props.variant}`]: true,
10
+ } }, index.h("span", { class: {
11
+ 'af-validation-message__icon': true,
12
+ [`af-validation-message__icon--${props.variant}`]: true,
13
+ }, "aria-hidden": "true" }), index.h("span", { class: "af-validation-message__text" }, children))));
14
+ };
15
+
16
+ exports.AfValidationMessage = AfValidationMessage;