@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
@@ -0,0 +1,474 @@
1
+ import { h, r as registerInstance, c as createEvent, a as getElement } from './index-CGXZllj2.js';
2
+ import { A as AfValidationMessage } from './af-validation-message-F8NIH2rC.js';
3
+
4
+ const svgMarkup = {
5
+ search: '<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" style="width:100%;height:100%"><path d="M25.645 22.437l-5.063-5.053a1.22 1.22 0 00-.864-.355h-.827a10.477 10.477 0 002.234-6.487C21.125 4.719 16.397 0 10.562 0 4.729 0 0 4.719 0 10.542c0 5.823 4.728 10.542 10.563 10.542 2.452 0 4.707-.831 6.5-2.23v.826c0 .324.126.633.355.862l5.063 5.053c.477.476 1.25.476 1.721 0l1.437-1.435a1.22 1.22 0 00.006-1.723zm-15.082-5.408c-3.59 0-6.5-2.899-6.5-6.487a6.49 6.49 0 016.5-6.487c3.59 0 6.5 2.899 6.5 6.487a6.49 6.49 0 01-6.5 6.487z" fill="currentColor" fill-rule="nonzero"/></svg>',
6
+ check: '<svg width="23" height="18" viewBox="0 0 23 18" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" style="width:100%;height:100%"><path d="M20.547.18L7.315 13.627 2.453 8.686a.597.597 0 00-.853 0L.177 10.132a.62.62 0 000 .868l6.711 6.82c.236.24.618.24.854 0L22.823 2.493a.62.62 0 000-.867L21.4.18a.597.597 0 00-.853 0z" fill="currentColor"/></svg>',
7
+ x: '<svg width="12" height="12" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" style="width:100%;height:100%"><g stroke="currentColor" stroke-width="2" fill="none" fill-rule="evenodd" stroke-linecap="square"><path d="M2 2l7.986 7.986M9.986 2L2 9.986"/></g></svg>',
8
+ };
9
+ const AfIcon = ({ name, class: className }) => (h("span", { class: className, "aria-hidden": "true", innerHTML: svgMarkup[name], style: {
10
+ display: 'flex',
11
+ width: className ? undefined : '12px',
12
+ height: className ? undefined : '12px',
13
+ minHeight: '1.4em',
14
+ alignItems: 'center',
15
+ } }));
16
+
17
+ const AfLabel = ({ label, forId, description, required = false }) => (h("div", { class: "af-form-label" }, h("label", { class: "af-form-label__label", htmlFor: forId }, label, required ? ' *' : ''), description && h("span", { class: "af-form-label__description" }, description)));
18
+
19
+ const AfTag = ({ text, breakWords = false, onRemove }) => (h("span", { class: "af-tag" }, h("button", { type: "button", class: "af-tag__button", "aria-label": `Ta bort ${text}`, onClick: (event) => {
20
+ event.preventDefault();
21
+ onRemove();
22
+ } }, h("span", { class: { 'af-tag__text': true, 'af-tag__text--break': breakWords } }, text), h(AfIcon, { name: "x", class: "af-tag__remove-icon" }))));
23
+
24
+ function shouldShowManualInput(state, requireSelection = false) {
25
+ if (!state || requireSelection)
26
+ return false;
27
+ const inputValue = state.inputValue.trim();
28
+ if (inputValue === '')
29
+ return false;
30
+ return !state.suggestions.some((suggestion) => suggestion.label.toLowerCase() === inputValue.toLowerCase());
31
+ }
32
+ function reconcileActiveIndex({ activeIndex, newState, oldState, requireSelection = false, }) {
33
+ if (oldState && newState.inputValue !== oldState.inputValue) {
34
+ return { activeIndex: -1, shouldRestoreFocus: false };
35
+ }
36
+ let nextActiveIndex = activeIndex;
37
+ if (newState.status === 'multiSelect'
38
+ && oldState?.status === 'multiSelect'
39
+ && newState.selectedItems.length > oldState.selectedItems.length) {
40
+ nextActiveIndex = 0;
41
+ }
42
+ const oldShowManualInput = shouldShowManualInput(oldState, requireSelection);
43
+ const wasManualInputActive = Boolean(oldState && oldShowManualInput && activeIndex === oldState.suggestions.length);
44
+ const showManualInput = shouldShowManualInput(newState, requireSelection);
45
+ const optionCount = newState.suggestions.length + (showManualInput ? 1 : 0);
46
+ if (wasManualInputActive) {
47
+ nextActiveIndex = showManualInput ? newState.suggestions.length : -1;
48
+ }
49
+ else if (optionCount === 0) {
50
+ nextActiveIndex = -1;
51
+ }
52
+ else if (nextActiveIndex >= optionCount) {
53
+ nextActiveIndex = optionCount - 1;
54
+ }
55
+ return {
56
+ activeIndex: nextActiveIndex,
57
+ shouldRestoreFocus: newState.status === 'itemSelected' && oldState?.status !== 'itemSelected',
58
+ };
59
+ }
60
+
61
+ const coreSelectorCss = () => `: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{--selector-width:var(--cs-width, 100%);--selector-min-width:var(--cs-min-width, 200px);--selector-max-width:var(--cs-max-width, none);--selector-height:var(--cs-height, auto);--selector-min-height:var(--cs-min-height, auto);--selector-max-height:var(--cs-max-height, none);--selector-font-family:var(--global-font-family, 'Open Sans', sans-serif);--selector-font-size:var(--cs-font-size, 1rem);--selector-text-color:var(--cs-text-color, #212529);--selector-placeholder-color:var(--cs-placeholder-color, #6c757d);--selector-border-color:var(--cs-border-color, #d1d5db);--selector-focus-border-color:var(--cs-focus-border-color, #86b7fe);--selector-focus-shadow:var(--cs-focus-shadow, 0 0 0 0.25rem rgba(13, 110, 253, 0.25));--selector-background-color:var(--cs-background-color, #fff);--selector-icon-color:var(--cs-icon-color, #6c757d);--selector-clear-button-color:var(--cs-clear-button-color, #6c757d);--selector-clear-button-hover-color:var(--cs-clear-button-hover-color, #212529);--selector-suggestion-background-color:var(--cs-suggestion-background-color, #fff);--selector-suggestion-border-color:var(--cs-suggestion-border-color, #ced4da);--selector-suggestion-hover-background:var(--cs-suggestion-hover-background, #e9ecef);--selector-suggestion-active-background:var(--cs-suggestion-active-background, #dde4eb);--selector-suggestion-text-color:var(--cs-suggestion-text-color, #212529);--selector-suggestion-highlight-weight:var(--cs-suggestion-highlight-weight, bold);--selector-error-color:var(--cs-error-color, #dc3545);--selector-loading-color:var(--cs-loading-color, #6c757d);--selector-container-min-height:40px;--selector-padding-y:6px;--selector-padding-x:10px;--selector-icon-size:1.1em;--selector-gap:6px;--cs-row-height:32px;display:flex;flex-direction:column;width:var(--selector-width);min-width:var(--selector-min-width);max-width:var(--selector-max-width);height:var(--selector-height);min-height:var(--selector-min-height);max-height:var(--selector-max-height);font-family:var(--selector-font-family);font-size:var(--selector-font-size);color:var(--selector-text-color);position:relative}:host([cs-size="small"]){--selector-container-min-height:32px;--selector-padding-y:2px;--selector-icon-size:1em;--selector-gap:4px;--cs-row-height:28px}:host([cs-size="medium"]){--selector-container-min-height:40px;--selector-padding-y:6px;--cs-row-height:32px}:host([cs-size="large"]){--selector-container-min-height:48px;--selector-padding-y:10px;--selector-icon-size:1.25em;--selector-gap:8px;--cs-row-height:40px}*{box-sizing:border-box}.core-selector-wrapper{display:flex;flex-direction:column;flex:1;min-height:inherit}.af-form-label{margin-bottom:0.5rem}.search-container{display:flex;align-items:center;flex-wrap:wrap;gap:6px;border:1px solid #757575;border-radius:0px;padding:var(--selector-padding-y) var(--selector-padding-x);flex:1;min-height:var(--selector-container-min-height);cursor:text;background-color:var(--selector-background-color);position:relative;overflow:hidden}.search-container:focus-within{outline:2px solid black;outline-offset:2px}.search-container.is-inactive-selected .selector-input-field{caret-color:transparent;cursor:default}.is-inactive-selected+.suggestions-box-container{display:none !important}.search-container.is-inactive-selected .search-icon-container{display:none}.search-container.is-inactive-selected .input-area{padding-left:0}.input-controls-wrapper{position:relative;width:100%;display:flex;align-items:center}.search-icon-container{position:absolute;left:0;top:50%;width:20px;height:20px;transform:translateY(-50%);z-index:1;pointer-events:none;display:flex;align-items:center;justify-content:center;transition:transform 0.2s ease-in-out, opacity 0.2s ease-in-out;opacity:1;max-height:100%}.search-icon-container.is-hidden{opacity:0;transform:translateY(-50%) scale(0.7)}.selector-search-icon{color:var(--digi--color--icon--primary, #333);display:block;flex:0 0 auto;width:20px;height:20px}.clear-button>span{color:var(--digi--color--icon--primary, #333)}.input-area{flex:1;min-width:0;padding-left:27px;display:flex;align-items:center;transition:padding-left 0.2s ease-in-out}.input-area.has-value{padding-left:0}.selector-input-field{width:100%;font-family:inherit;font-size:var(--selector-font-size);color:inherit;border:none;outline:none;background:transparent;transition:padding-right 0.2s ease-in-out}.search-container.has-input .selector-input-field{padding-right:0}.selector-input-field::placeholder{color:var(--selector-placeholder-color);opacity:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.clear-button{position:static;flex-shrink:0;opacity:0;pointer-events:none;z-index:2;background:none;border:none;padding:0;margin:0;height:20px;width:20px;cursor:pointer;color:var(--selector-clear-button-color);line-height:1;display:flex;align-items:center;transition:color 0.2s ease-in-out, opacity 0.2s ease-in-out}.clear-button.is-visible{opacity:1;pointer-events:auto}.clear-button:hover,.clear-button:focus{color:var(--selector-clear-button-hover-color);outline:none}.search-container.multi-search-container{display:flex;flex-direction:column;gap:0.5rem;align-items:stretch;padding-top:var(--selector-padding-y);padding-bottom:var(--selector-padding-y);width:100%;max-width:100%}.selected-tags-wrapper{display:flex;flex-wrap:wrap;gap:0.5rem;width:100%;max-width:100%;box-sizing:border-box}.selected-tags-wrapper .af-tag{display:block;max-width:100%;min-width:0}.selected-tags-wrapper .af-tag__button{white-space:normal !important;height:auto !important;text-align:left !important;word-break:break-word !important;overflow-wrap:anywhere !important;max-width:100% !important}.search-container.single-value-display{display:flex;align-items:center;flex-wrap:nowrap;gap:0.5rem;min-height:var(--selector-container-min-height);padding:var(--selector-padding-y) var(--selector-padding-x)}.selected-text-in-box{flex-grow:1;white-space:normal;word-break:break-word;min-width:0;line-height:inherit}.search-container.single-value-display .clear-button{position:static;transform:none;opacity:1;pointer-events:auto;flex-shrink:0}.combobox-container{position:relative;margin-top:0;display:flex;flex-direction:column;flex:1}.suggestions-box-container{position:absolute;top:100%;left:0;right:0;z-index:100}.suggestions-box-container.is-hidden-list{z-index:101;pointer-events:none}.suggestions-box{position:relative;background-color:white;border:1px solid var(--selector-suggestion-border-color);border-radius:4px;box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);overflow-y:auto;margin:2px 0px;max-height:calc(var(--max-visible-rows, 10) * var(--cs-row-height) + 40px)}.suggestion-item{display:flex;align-items:center;min-height:var(--cs-row-height);height:auto;padding:6px 1rem;font-size:inherit;line-height:1.25;cursor:pointer;color:var(--selector-suggestion-text-color);list-style:none;transition:background-color 0.15s ease, color 0.15s ease;white-space:normal !important;word-break:break-word !important;overflow-wrap:anywhere !important;position:relative;z-index:1;box-sizing:border-box}.suggestion-item>span{transition:font-weight 0.2s ease, transform 0.2s ease;display:inline;vertical-align:middle;white-space:normal;word-break:break-word;overflow-wrap:anywhere}.suggestion-item:hover,.suggestion-item.active-suggestion{background-color:var(--selector-suggestion-active-background)}.suggestion-item.active-suggestion.is-keyboard-focus{outline:1px solid black;outline-offset:-1px}.suggestion-item.is-selected{color:var(--selector-suggestion-text-color) !important;cursor:default;background-color:#f2f2f2 !important}.suggestion-item.is-selected span{font-weight:600}.selection-indicator-icon{width:0;height:20px;opacity:0;transform:scale(0.5);margin-right:0;transition:width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), margin-right 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);color:var(--digi--grayscale-800, #333);flex-shrink:0;display:flex;align-items:center;justify-content:center;overflow:hidden}.suggestion-item.is-selected .selection-indicator-icon{width:24px;opacity:1;transform:scale(1);margin-right:8px}.suggestion-item.is-selected.active-suggestion{background-color:#f2f2f2 !important}.suggestion-item .suggestion-text strong,.suggestion-item .match-highlight{font-weight:var(--selector-suggestion-highlight-weight);color:inherit;display:inline}.metadata-dimmed,.occupation-variant-label{font-size:1rem;color:var(--digi--grayscale-700, #757575);margin-left:0.25rem;display:inline;vertical-align:baseline;line-height:inherit;white-space:normal}.suggestion-item.no-results{color:var(--selector-placeholder-color);cursor:default;padding:0.5rem 1rem;font-style:italic;text-align:center;height:auto}.search-container.has-validation-error{border-color:var(--selector-error-color);border-width:2px;background-color:#fef3f2}.search-container.has-positive-validation{border-color:#155724;background-color:#d4edda}.status-message{margin-top:0.5rem}.selector-validation-message{margin-top:0.5rem;display:block}.visually-hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}input::-webkit-search-decoration,input::-webkit-search-cancel-button,input::-webkit-search-results-button,input::-webkit-search-results-decoration{-webkit-appearance:none;display:none}input::-ms-clear{display:none;width:0;height:0}.list-header-container{position:sticky;top:0;z-index:10;background-color:#f8f9fa;border-bottom:1px solid var(--selector-suggestion-border-color);min-height:auto;display:flex;flex-direction:column}.list-header-container ::slotted([slot="suggestions-overlay"]){position:absolute !important;top:0;left:0;width:100%;height:100%;z-index:20}.suggestions-box>::slotted([slot="suggestions-overlay"]){position:sticky !important;top:0;left:0;width:100%;z-index:20}.list-header{display:flex;align-items:center;min-height:var(--cs-row-height);padding:6px 1rem;font-size:0.875rem;line-height:1.25;color:var(--digi--grayscale-700, #757575);border-bottom:1px solid var(--selector-suggestion-border-color, #ced4da)}.list-header span{font-size:0.875rem;font-weight:normal}.history-clear-link{color:var(--digi--grayscale-700, #757575);text-decoration:underline;cursor:pointer;margin-left:0.25rem;background:transparent;border:0;padding:0;font:inherit}.history-clear-link:hover{color:var(--digi--grayscale-900, #222)}@keyframes cs-shrink-fade{from{opacity:1}to{opacity:1}}@keyframes cs-collapse{from{height:auto}to{height:auto}}.cs-toast{position:absolute;top:0;left:0;width:100%;height:100%;z-index:20;display:flex;align-items:center;justify-content:center;gap:8px;background-color:#f8fdf0;animation:cs-toastSlideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;pointer-events:none;box-sizing:border-box}.cs-toast.is-closing{animation:cs-toastSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards}.cs-toast-text{margin:0;font-size:0.875rem;font-weight:500;color:#2e7d32}@keyframes cs-toastSlideDown{from{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes cs-toastSlideUp{from{transform:translateY(0)}to{transform:translateY(-100%)}}.selector-input-field.visually-hidden-selected{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden}`;
62
+
63
+ const CoreSelector = class {
64
+ constructor(hostRef) {
65
+ registerInstance(this, hostRef);
66
+ this.csInput = createEvent(this, "csInput");
67
+ this.csSelect = createEvent(this, "csSelect");
68
+ this.csClear = createEvent(this, "csClear");
69
+ this.csRemoveItem = createEvent(this, "csRemoveItem");
70
+ this.csBlur = createEvent(this, "csBlur");
71
+ this.csEditSelection = createEvent(this, "csEditSelection");
72
+ this.csFocus = createEvent(this, "csFocus");
73
+ this.csLoadMore = createEvent(this, "csLoadMore");
74
+ this.csClearHistory = createEvent(this, "csClearHistory");
75
+ this.csRequestHistory = createEvent(this, "csRequestHistory");
76
+ }
77
+ historyRequestTimer;
78
+ disconnectedCallback() {
79
+ clearTimeout(this.historyRequestTimer);
80
+ this.historyRequestTimer = undefined;
81
+ }
82
+ static nextId = 0;
83
+ get hostElement() { return getElement(this); }
84
+ state;
85
+ config = {
86
+ disabled: false,
87
+ placeholder: 'Sök...',
88
+ minLength: 1,
89
+ maxResults: 10,
90
+ enableMultiple: false,
91
+ showSearchIcon: true,
92
+ requireSelection: true,
93
+ size: 'medium'
94
+ };
95
+ label = '';
96
+ labelDescription;
97
+ componentId = `cs-${CoreSelector.nextId++}`;
98
+ size = 'medium';
99
+ csInput;
100
+ csSelect;
101
+ csClear;
102
+ csRemoveItem;
103
+ csBlur;
104
+ csEditSelection;
105
+ csFocus;
106
+ csLoadMore;
107
+ csClearHistory;
108
+ csRequestHistory;
109
+ afFocused = false;
110
+ activeIndex = -1;
111
+ isFocusedInternal = false;
112
+ isNavigatingWithKeyboard = false;
113
+ async setFocus() {
114
+ if (this.inputRef) {
115
+ this.inputRef.focus();
116
+ const len = this.inputRef.value.length;
117
+ this.inputRef.setSelectionRange(len, len);
118
+ }
119
+ else {
120
+ this.shouldFocusAfterRender = true;
121
+ }
122
+ }
123
+ inputRef;
124
+ listRef;
125
+ shouldFocusAfterRender = false;
126
+ handleKeyDown = (event) => {
127
+ if (this.config.disabled) {
128
+ event.preventDefault();
129
+ return;
130
+ }
131
+ if (!this.state)
132
+ return;
133
+ if (event.target.tagName === 'BUTTON')
134
+ return;
135
+ if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown' && event.key !== 'Enter' && event.key !== 'Escape') {
136
+ this.isNavigatingWithKeyboard = false;
137
+ }
138
+ if (this.state.status === 'itemSelected') {
139
+ if (event.key !== 'Tab' && event.key !== 'Shift' && !event.ctrlKey && !event.metaKey) {
140
+ this.csEditSelection.emit();
141
+ return;
142
+ }
143
+ }
144
+ if (this.state.status !== 'searching' && this.state.status !== 'multiSelect')
145
+ return;
146
+ const suggestions = this.state.suggestions;
147
+ const showManualInput = shouldShowManualInput(this.state, this.config.requireSelection);
148
+ const totalOptions = suggestions.length + (showManualInput ? 1 : 0);
149
+ switch (event.key) {
150
+ case 'ArrowDown':
151
+ if (totalOptions > 0) {
152
+ event.preventDefault();
153
+ this.isNavigatingWithKeyboard = true;
154
+ if (this.activeIndex < totalOptions - 1) {
155
+ this.activeIndex = this.activeIndex + 1;
156
+ this.scrollToActive();
157
+ }
158
+ if (this.activeIndex >= suggestions.length - 3) {
159
+ this.csLoadMore.emit();
160
+ }
161
+ }
162
+ else {
163
+ this.csFocus.emit();
164
+ }
165
+ break;
166
+ case 'ArrowUp':
167
+ if (totalOptions > 0) {
168
+ event.preventDefault();
169
+ this.isNavigatingWithKeyboard = true;
170
+ if (this.activeIndex > 0) {
171
+ this.activeIndex = this.activeIndex - 1;
172
+ this.scrollToActive();
173
+ }
174
+ else if (this.activeIndex === 0 || this.activeIndex === -1) {
175
+ // Wrap around to the last option (which might be manual input)
176
+ this.activeIndex = totalOptions - 1;
177
+ this.scrollToActive();
178
+ }
179
+ }
180
+ break;
181
+ case ' ':
182
+ case 'Enter':
183
+ // Only handle Space if we have an active suggestion (keyboard navigation)
184
+ // If index is -1, let the space go through to the input field
185
+ if (event.key === ' ' && this.activeIndex === -1) {
186
+ return;
187
+ }
188
+ if (this.activeIndex >= 0 && this.activeIndex < suggestions.length) {
189
+ event.preventDefault();
190
+ const item = suggestions[this.activeIndex];
191
+ this.shouldFocusAfterRender = true;
192
+ if (item.isSelected) {
193
+ this.csRemoveItem.emit(item);
194
+ }
195
+ else {
196
+ this.csSelect.emit(item);
197
+ }
198
+ }
199
+ else if (showManualInput && this.activeIndex === suggestions.length && this.isNavigatingWithKeyboard) {
200
+ event.preventDefault();
201
+ this.handleManualSelect();
202
+ }
203
+ else if (event.key === 'Enter') {
204
+ // If Enter is pressed but no item is active,
205
+ // we prevent default to avoid accidental form submission
206
+ // and ensure the dropdown stays open if manual input is available.
207
+ if (showManualInput || suggestions.length > 0) {
208
+ event.preventDefault();
209
+ this.isNavigatingWithKeyboard = true;
210
+ }
211
+ }
212
+ break;
213
+ case 'Escape':
214
+ this.activeIndex = -1;
215
+ this.csClear.emit();
216
+ break;
217
+ }
218
+ };
219
+ onWrapperFocusIn = () => {
220
+ if (this.config.disabled)
221
+ return;
222
+ if (!this.state || !this.isFocusedInternal) {
223
+ if (this.state) {
224
+ this.isFocusedInternal = true;
225
+ this.activeIndex = -1;
226
+ this.csFocus.emit();
227
+ if (this.state.inputValue.trim() === '') {
228
+ this.csRequestHistory.emit();
229
+ }
230
+ }
231
+ }
232
+ };
233
+ onWrapperFocusOut = () => {
234
+ if (this.shouldFocusAfterRender)
235
+ return;
236
+ // Use requestAnimationFrame to wait for the next frame where focus
237
+ // will have settled on the new element.
238
+ requestAnimationFrame(() => {
239
+ const root = this.hostElement.shadowRoot;
240
+ const activeElement = root?.activeElement || document.activeElement;
241
+ // Check if the currently focused element is inside the component or its shadow DOM
242
+ const isInside = (activeElement && this.hostElement.contains(activeElement)) ||
243
+ (root && root.contains(activeElement));
244
+ if (!isInside) {
245
+ this.isFocusedInternal = false;
246
+ this.activeIndex = -1;
247
+ this.csBlur.emit();
248
+ }
249
+ });
250
+ };
251
+ handleAfFocusedChange(newValue) {
252
+ this.isFocusedInternal = newValue;
253
+ if (newValue) {
254
+ this.shouldFocusAfterRender = true;
255
+ }
256
+ }
257
+ handleConfigChange(newConfig) {
258
+ if (newConfig.disabled) {
259
+ this.isFocusedInternal = false;
260
+ this.activeIndex = -1;
261
+ this.shouldFocusAfterRender = false;
262
+ }
263
+ }
264
+ handleStateChange(newState, oldState) {
265
+ const result = reconcileActiveIndex({
266
+ activeIndex: this.activeIndex,
267
+ newState,
268
+ oldState,
269
+ requireSelection: this.config.requireSelection,
270
+ });
271
+ this.activeIndex = result.activeIndex;
272
+ if (result.shouldRestoreFocus) {
273
+ this.shouldFocusAfterRender = true;
274
+ }
275
+ }
276
+ componentDidUpdate() {
277
+ if (this.shouldFocusAfterRender) {
278
+ this.performFocusRestoration();
279
+ }
280
+ }
281
+ performFocusRestoration(retryCount = 0) {
282
+ if (this.config.disabled) {
283
+ this.shouldFocusAfterRender = false;
284
+ return;
285
+ }
286
+ if (this.inputRef) {
287
+ this.isFocusedInternal = true; // Ensure UI thinks it's focused to show suggestions
288
+ this.inputRef.focus();
289
+ const currentActive = this.hostElement.shadowRoot?.activeElement;
290
+ if (currentActive === this.inputRef || retryCount > 20) {
291
+ const len = this.inputRef.value.length;
292
+ this.inputRef.setSelectionRange(len, len);
293
+ this.shouldFocusAfterRender = false;
294
+ }
295
+ else {
296
+ requestAnimationFrame(() => this.performFocusRestoration(retryCount + 1));
297
+ }
298
+ }
299
+ }
300
+ handleScroll(event) {
301
+ if (!this.config.enableInfiniteScroll)
302
+ return;
303
+ const target = event.target;
304
+ const threshold = 50;
305
+ const remaining = target.scrollHeight - (target.scrollTop + target.clientHeight);
306
+ if (remaining < threshold) {
307
+ this.csLoadMore.emit();
308
+ }
309
+ }
310
+ scrollToActive() {
311
+ if (!this.listRef || !this.state)
312
+ return;
313
+ const optionId = this.activeIndex === this.state.suggestions.length
314
+ ? `${this.componentId}-list-option-manual-input`
315
+ : `${this.componentId}-list-option-${this.activeIndex}`;
316
+ const activeElement = this.listRef.querySelector(`#${optionId}`);
317
+ activeElement?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
318
+ }
319
+ handleManualSelect() {
320
+ const item = { id: '', label: this.state.inputValue.trim(), metadata: { type: 'ManualInput' } };
321
+ this.shouldFocusAfterRender = true;
322
+ this.csSelect.emit(item);
323
+ if (this.config.enableMultiple && this.state?.inputValue?.trim() === '') {
324
+ this.csRequestHistory.emit();
325
+ }
326
+ }
327
+ render() {
328
+ if (!this.state)
329
+ return null;
330
+ const isSelected = this.state.status === 'itemSelected';
331
+ return (h("div", { class: { 'core-selector-wrapper': true, 'is-disabled': !!this.config.disabled }, "aria-disabled": this.config.disabled ? 'true' : 'false', onKeyDown: (e) => this.handleKeyDown(e), onMouseMove: () => { this.isNavigatingWithKeyboard = false; }, onFocusin: this.onWrapperFocusIn, onFocusout: this.onWrapperFocusOut }, this.label && (h(AfLabel, { label: this.label, forId: `${this.componentId}-input`, description: this.labelDescription })), this.labelDescription && (h("div", { id: `${this.componentId}-description`, class: "visually-hidden" }, this.labelDescription)), this.state && this.state.status === 'loading' && h("div", { class: "loading-indicator" }, "Laddar..."), this.state && this.state.status === 'error' && h("div", { class: "error-message" }, this.state.message), this.state && ['searching', 'itemSelected', 'multiSelect'].includes(this.state.status) && (h("div", { class: "combobox-container" }, this.renderSearchContainer(), this.isFocusedInternal && !isSelected && this.renderSuggestionsList())), this.state && this.state.validation !== 'idle' && this.state.status !== 'itemSelected' && (h(AfValidationMessage, { id: `${this.componentId}-validation-message`, variant: this.state.validation === 'error' ? 'error' : 'success', role: this.state.validation === 'error' ? 'alert' : undefined, class: "selector-validation-message" }, this.state.message))));
332
+ }
333
+ renderSearchContainer() {
334
+ const isSelected = this.state.status === 'itemSelected';
335
+ const displayValue = isSelected ? (this.state.selectedItem?.label || '') : this.state.inputValue;
336
+ const isMulti = this.state.status === 'multiSelect';
337
+ const hasInput = displayValue.length > 0;
338
+ const hasTags = isMulti && this.state.selectedItems.length > 0;
339
+ const hasSuggestions = this.state && (this.state.suggestions.length > 0 || shouldShowManualInput(this.state, this.config.requireSelection));
340
+ const activeDescendantId = (this.activeIndex >= 0 && this.isNavigatingWithKeyboard)
341
+ ? (this.activeIndex === this.state.suggestions.length
342
+ ? `${this.componentId}-list-option-manual-input`
343
+ : `${this.componentId}-list-option-${this.activeIndex}`)
344
+ : undefined;
345
+ const descriptionId = `${this.componentId}-description`;
346
+ const validationMessageId = `${this.componentId}-validation-message`;
347
+ const hasDescription = !!this.labelDescription;
348
+ const hasError = this.state && this.state.validation === 'error' && this.state.message;
349
+ const describedByList = [];
350
+ if (hasDescription && displayValue.length === 0)
351
+ describedByList.push(descriptionId);
352
+ if (hasError)
353
+ describedByList.push(validationMessageId);
354
+ const ariaDescribedBy = describedByList.length > 0 ? describedByList.join(' ') : undefined;
355
+ return (h("div", { class: {
356
+ 'search-container': true,
357
+ 'is-inactive-selected': isSelected,
358
+ 'multi-search-container': isMulti,
359
+ 'has-tags': hasTags,
360
+ 'has-validation-error': this.state?.validation === 'error',
361
+ 'has-positive-validation': !isSelected && this.state?.validation === 'success',
362
+ }, onClick: () => {
363
+ if (this.config.disabled)
364
+ return;
365
+ if (isSelected) {
366
+ this.csEditSelection.emit();
367
+ }
368
+ else if (this.state.inputValue.trim() === '') {
369
+ this.csRequestHistory.emit();
370
+ }
371
+ } }, isMulti && this.state.selectedItems.length > 0 && (h("div", { class: "selected-tags-wrapper" }, this.state.selectedItems.map((item) => (h(AfTag, { key: item.id, text: item.label, breakWords: true, onRemove: () => {
372
+ this.shouldFocusAfterRender = true;
373
+ this.csRemoveItem.emit(item);
374
+ } }))))), h("div", { class: "input-controls-wrapper" }, h(AfIcon, { name: "search", class: {
375
+ 'search-icon-container': true,
376
+ 'selector-search-icon': true,
377
+ 'is-hidden': !this.config.showSearchIcon || hasInput || hasTags,
378
+ } }), h("div", { class: { 'input-area': true, 'has-value': !this.config.showSearchIcon || hasInput || hasTags } }, isSelected && (h("span", { class: "selected-text-in-box" }, displayValue)), h("input", { class: {
379
+ 'selector-input-field': true,
380
+ 'visually-hidden-selected': isSelected
381
+ }, ref: (el) => this.inputRef = el, id: `${this.componentId}-input`, type: "text", placeholder: this.config.placeholder, value: displayValue, onInput: (e) => {
382
+ if (this.config.disabled)
383
+ return;
384
+ this.isNavigatingWithKeyboard = false;
385
+ this.csInput.emit(e.target.value);
386
+ }, autocomplete: "off", role: "combobox", "aria-label": this.label, "aria-autocomplete": "list", "aria-haspopup": "listbox", "aria-expanded": !isSelected && hasSuggestions && this.isNavigatingWithKeyboard ? 'true' : 'false', "aria-controls": !isSelected && hasSuggestions && this.isNavigatingWithKeyboard ? `${this.componentId}-listbox` : undefined, "aria-activedescendant": activeDescendantId, "aria-invalid": hasError ? 'true' : 'false', "aria-describedby": ariaDescribedBy, readOnly: isSelected, disabled: !!this.config.disabled })), h("button", { type: "button", class: { 'clear-button': true, 'is-visible': hasInput || isSelected }, tabIndex: hasInput || isSelected ? 0 : -1, disabled: !!this.config.disabled, "aria-label": "Rensa inmatad text", onMouseDown: (e) => e.preventDefault(), onClick: () => {
387
+ if (this.config.disabled)
388
+ return;
389
+ this.csInput.emit('');
390
+ this.shouldFocusAfterRender = true;
391
+ this.csClear.emit();
392
+ this.csRequestHistory.emit();
393
+ } }, h(AfIcon, { name: "x" })))));
394
+ }
395
+ renderSuggestionsList() {
396
+ if (this.state.status === 'itemSelected')
397
+ return null;
398
+ const hasSearchInput = Boolean(this.state.inputValue && this.state.inputValue.trim().length > 0);
399
+ const showManualInput = shouldShowManualInput(this.state, this.config.requireSelection);
400
+ const hasSuggestions = Boolean(this.state.suggestions && this.state.suggestions.length > 0);
401
+ const noResults = hasSearchInput && !hasSuggestions && !showManualInput;
402
+ if (!hasSuggestions && !showManualInput && !noResults) {
403
+ return null;
404
+ }
405
+ const listHeader = this.state.listHeader || this.config.listHeader;
406
+ const showHistoryHeader = this.state.showHistoryHeader || (this.state.isHistoryView && this.config.showHistoryHeader);
407
+ return (h("div", { class: "suggestions-box-container" }, h("div", { class: "suggestions-box", ref: (el) => (this.listRef = el), onScroll: (e) => this.handleScroll(e) }, (listHeader || showHistoryHeader) && (h("div", { class: "list-header-container" }, h("slot", { name: "suggestions-overlay" }), listHeader && (h("div", { class: "list-header" }, h("span", null, listHeader))), showHistoryHeader && (h("div", { class: "list-header history-header" }, h("span", null, "Din privata historik"), " - ", h("button", { type: "button", class: "history-clear-link", "aria-label": "Rensa historik", disabled: !!this.config.disabled, onMouseDown: (e) => e.preventDefault(), onClick: () => {
408
+ if (!this.config.disabled)
409
+ this.csClearHistory.emit();
410
+ } }, "Rensa"))))), !listHeader && !showHistoryHeader && h("slot", { name: "suggestions-overlay" }), h("div", { id: `${this.componentId}-listbox`, role: "listbox" }, noResults && (h("div", { class: "suggestion-item no-results" }, "Inga resultat matchade din s\u00F6kning")), !noResults && this.state.suggestions.map((item, index) => (h("div", { key: item.id || index, role: "option", id: `${this.componentId}-list-option-${index}`, "aria-selected": !!item.isSelected, "aria-current": index === this.activeIndex ? 'true' : 'false', class: {
411
+ 'suggestion-item': true,
412
+ 'active-suggestion': index === this.activeIndex,
413
+ 'is-selected': !!item.isSelected,
414
+ 'is-keyboard-focus': index === this.activeIndex && this.isNavigatingWithKeyboard
415
+ }, onMouseDown: (e) => {
416
+ e.preventDefault();
417
+ if (this.config.disabled)
418
+ return;
419
+ this.shouldFocusAfterRender = true;
420
+ if (item.isSelected) {
421
+ this.csRemoveItem.emit(item);
422
+ }
423
+ else {
424
+ this.csSelect.emit(item);
425
+ }
426
+ if (this.config.enableMultiple) {
427
+ // Trigger history refresh if we are in multi-mode
428
+ clearTimeout(this.historyRequestTimer);
429
+ this.historyRequestTimer = setTimeout(() => {
430
+ this.csRequestHistory.emit();
431
+ this.historyRequestTimer = undefined;
432
+ }, 50);
433
+ }
434
+ }, onMouseEnter: () => {
435
+ if (this.config.disabled)
436
+ return;
437
+ if (!item.isSelected) {
438
+ this.activeIndex = index;
439
+ this.isNavigatingWithKeyboard = false;
440
+ }
441
+ } }, h(AfIcon, { name: "check", class: "selection-indicator-icon" }), item.displaySegments ? (h("span", null, item.displaySegments.map((segment, segmentIndex) => (h("span", { key: segmentIndex, class: {
442
+ 'match-highlight': !!segment.isMatch,
443
+ 'metadata-dimmed': !!segment.isMetadata
444
+ } }, segment.text))))) : (h("span", null, item.label))))), !noResults && shouldShowManualInput(this.state, this.config.requireSelection) && (h("div", { role: "option", id: `${this.componentId}-list-option-manual-input`, class: {
445
+ 'suggestion-item': true,
446
+ 'active-suggestion': this.activeIndex === this.state.suggestions.length,
447
+ 'is-keyboard-focus': this.activeIndex === this.state.suggestions.length && this.isNavigatingWithKeyboard
448
+ }, onMouseDown: (e) => {
449
+ e.preventDefault();
450
+ if (!this.config.disabled)
451
+ this.handleManualSelect();
452
+ }, onMouseEnter: () => {
453
+ if (this.config.disabled)
454
+ return;
455
+ this.activeIndex = this.state.suggestions.length;
456
+ this.isNavigatingWithKeyboard = false;
457
+ } }, h("span", null, "Anv\u00E4nd \"", h("strong", null, this.state.inputValue.trim()), "\"")))))));
458
+ }
459
+ static get delegatesFocus() { return true; }
460
+ static get watchers() { return {
461
+ "afFocused": [{
462
+ "handleAfFocusedChange": 0
463
+ }],
464
+ "config": [{
465
+ "handleConfigChange": 0
466
+ }],
467
+ "state": [{
468
+ "handleStateChange": 0
469
+ }]
470
+ }; }
471
+ };
472
+ CoreSelector.style = coreSelectorCss();
473
+
474
+ export { CoreSelector as core_selector };