@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.
- package/LICENSE +190 -0
- package/README.md +369 -0
- package/dist/cjs/af-validation-message-BzY5H0xU.js +16 -0
- package/dist/cjs/core-selector.cjs.entry.js +476 -0
- package/dist/cjs/digi-service-job-selector.cjs.entry.js +1619 -0
- package/dist/cjs/fuse-BTLNKxuL.js +1631 -0
- package/dist/cjs/geo-valjaren.cjs.entry.js +14910 -0
- package/dist/cjs/index-BOuTGlEp.js +1817 -0
- package/dist/cjs/index.cjs.js +14 -0
- package/dist/cjs/job-selector-demo.cjs.entry.js +692 -0
- package/dist/cjs/loader.cjs.js +12 -0
- package/dist/cjs/neobrutal-search.cjs.entry.js +171 -0
- package/dist/cjs/search.engine-D0cMelRi.js +489 -0
- package/dist/cjs/taxonomy-registry-DVmuDUpM.js +435 -0
- package/dist/cjs/types-CtHBl6Ra.js +14 -0
- package/dist/cjs/yrkesvaljaren.cjs.js +24 -0
- package/dist/collection/collection-manifest.json +15 -0
- package/dist/collection/components/core-selector/core-selector.css +803 -0
- package/dist/collection/components/core-selector/core-selector.js +761 -0
- package/dist/collection/components/core-selector/types.js +1 -0
- package/dist/collection/components/design-compat/af-icon.js +13 -0
- package/dist/collection/components/design-compat/af-label.js +2 -0
- package/dist/collection/components/design-compat/af-tag.js +6 -0
- package/dist/collection/components/design-compat/af-validation-message.js +11 -0
- package/dist/collection/components/design-compat/index.js +4 -0
- package/dist/collection/components/geovaljaren/geovaljaren.css +21 -0
- package/dist/collection/components/geovaljaren/geovaljaren.js +304 -0
- package/dist/collection/components/geovaljaren/logic/adapter.utils.js +20 -0
- package/dist/collection/components/geovaljaren/logic/data.utils.js +12 -0
- package/dist/collection/components/geovaljaren/logic/history-service.js +25 -0
- package/dist/collection/components/geovaljaren/logic/search.engine.js +28 -0
- package/dist/collection/components/job-selector/constants.js +26 -0
- package/dist/collection/components/job-selector/history-service.js +41 -0
- package/dist/collection/components/job-selector/job-selector-controller.js +835 -0
- package/dist/collection/components/job-selector/job-selector.css +318 -0
- package/dist/collection/components/job-selector/job-selector.js +1378 -0
- package/dist/collection/components/job-selector/keyboard-handlers.js +84 -0
- package/dist/collection/components/job-selector/logic/adapter.utils.js +75 -0
- package/dist/collection/components/job-selector/logic/label-formatter.js +118 -0
- package/dist/collection/components/job-selector/logic/search.engine.js +50 -0
- package/dist/collection/components/job-selector/search-logic.js +35 -0
- package/dist/collection/components/job-selector/search.utils.js +224 -0
- package/dist/collection/components/job-selector/suggestions-list.js +31 -0
- package/dist/collection/components/job-selector/taxonomy-registry.js +60 -0
- package/dist/collection/components/job-selector/test-data.mock.js +33 -0
- package/dist/collection/components/job-selector/types.js +10 -0
- package/dist/collection/components/job-selector/validation-message.js +24 -0
- package/dist/collection/demo-data.js +20 -0
- package/dist/collection/index.js +7 -0
- package/dist/collection/verkstad/verkstad.js +407 -0
- package/dist/components/core-selector.d.ts +11 -0
- package/dist/components/core-selector.js +1 -0
- package/dist/components/core-selector2.js +1 -0
- package/dist/components/digi-service-job-selector.d.ts +11 -0
- package/dist/components/digi-service-job-selector.js +1 -0
- package/dist/components/fuse.js +1 -0
- package/dist/components/geo-valjaren.d.ts +11 -0
- package/dist/components/geo-valjaren.js +1 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/job-selector-demo.d.ts +11 -0
- package/dist/components/job-selector-demo.js +1 -0
- package/dist/components/job-selector.js +1 -0
- package/dist/components/neobrutal-search.d.ts +11 -0
- package/dist/components/neobrutal-search.js +1 -0
- package/dist/components/search.engine.js +1 -0
- package/dist/components/types.js +1 -0
- package/dist/esm/af-validation-message-F8NIH2rC.js +14 -0
- package/dist/esm/core-selector.entry.js +474 -0
- package/dist/esm/digi-service-job-selector.entry.js +1617 -0
- package/dist/esm/fuse-BPnhMTul.js +1629 -0
- package/dist/esm/geo-valjaren.entry.js +14908 -0
- package/dist/esm/index-CGXZllj2.js +1806 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/job-selector-demo.entry.js +690 -0
- package/dist/esm/loader.js +10 -0
- package/dist/esm/neobrutal-search.entry.js +169 -0
- package/dist/esm/search.engine-nZ7AcXba.js +479 -0
- package/dist/esm/taxonomy-registry-Dw0VR9Aw.js +430 -0
- package/dist/esm/types-DHUftoZJ.js +12 -0
- package/dist/esm/yrkesvaljaren.js +20 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/components/core-selector/core-selector.d.ts +46 -0
- package/dist/types/components/core-selector/types.d.ts +1 -0
- package/dist/types/components/design-compat/af-icon.d.ts +7 -0
- package/dist/types/components/design-compat/af-label.d.ts +8 -0
- package/dist/types/components/design-compat/af-tag.d.ts +8 -0
- package/dist/types/components/design-compat/af-validation-message.d.ts +9 -0
- package/dist/types/components/design-compat/index.d.ts +5 -0
- package/dist/types/components/geovaljaren/geovaljaren.d.ts +24 -0
- package/dist/types/components/geovaljaren/logic/adapter.utils.d.ts +7 -0
- package/dist/types/components/geovaljaren/logic/data.utils.d.ts +7 -0
- package/dist/types/components/geovaljaren/logic/history-service.d.ts +6 -0
- package/dist/types/components/geovaljaren/logic/search.engine.d.ts +7 -0
- package/dist/types/components/job-selector/ambient.d.ts +4 -0
- package/dist/types/components/job-selector/constants.d.ts +13 -0
- package/dist/types/components/job-selector/history-service.d.ts +6 -0
- package/dist/types/components/job-selector/job-selector-controller.d.ts +82 -0
- package/dist/types/components/job-selector/job-selector.d.ts +140 -0
- package/dist/types/components/job-selector/keyboard-handlers.d.ts +13 -0
- package/dist/types/components/job-selector/logic/adapter.utils.d.ts +12 -0
- package/dist/types/components/job-selector/logic/label-formatter.d.ts +4 -0
- package/dist/types/components/job-selector/logic/search.engine.d.ts +21 -0
- package/dist/types/components/job-selector/search-logic.d.ts +17 -0
- package/dist/types/components/job-selector/search.utils.d.ts +10 -0
- package/dist/types/components/job-selector/suggestions-list.d.ts +13 -0
- package/dist/types/components/job-selector/taxonomy-registry.d.ts +20 -0
- package/dist/types/components/job-selector/test-data.mock.d.ts +7 -0
- package/dist/types/components/job-selector/types.d.ts +107 -0
- package/dist/types/components/job-selector/validation-message.d.ts +8 -0
- package/dist/types/components/job-selector-demo/job-selector-demo.d.ts +55 -0
- package/dist/types/components/neobrutal-search/neobrutal-search.d.ts +18 -0
- package/dist/types/components.d.ts +425 -0
- package/dist/types/demo-data.d.ts +16 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/stencil-public-runtime.d.ts +1873 -0
- package/dist/types/verkstad/verkstad.d.ts +1 -0
- package/dist/yrkesvaljaren/fuse-B0eHOxow.js.map +1 -0
- package/dist/yrkesvaljaren/index-Cy4BCo5s.js.map +1 -0
- package/dist/yrkesvaljaren/index-DfJXTQqL.js.map +1 -0
- package/dist/yrkesvaljaren/index.esm.js +1 -0
- package/dist/yrkesvaljaren/index.esm.js.map +1 -0
- package/dist/yrkesvaljaren/p-16636162.entry.js +1 -0
- package/dist/yrkesvaljaren/p-273cf6df.entry.js +1 -0
- package/dist/yrkesvaljaren/p-9e48afa4.entry.js +1 -0
- package/dist/yrkesvaljaren/p-BPnhMTul.js +1 -0
- package/dist/yrkesvaljaren/p-CGXZllj2.js +3 -0
- package/dist/yrkesvaljaren/p-DHUftoZJ.js +1 -0
- package/dist/yrkesvaljaren/p-DYFAzvqX.js +1 -0
- package/dist/yrkesvaljaren/p-Dw0VR9Aw.js +1 -0
- package/dist/yrkesvaljaren/p-aef7b5ae.entry.js +1 -0
- package/dist/yrkesvaljaren/p-b0f16abd.entry.js +1 -0
- package/dist/yrkesvaljaren/p-uBrs3sSs.js +1 -0
- package/dist/yrkesvaljaren/search.engine-DPT6roRm.js.map +1 -0
- package/dist/yrkesvaljaren/taxonomy-registry-s5khf6s4.js.map +1 -0
- package/dist/yrkesvaljaren/types-DHUftoZJ.js.map +1 -0
- package/dist/yrkesvaljaren/yrkesvaljaren.css +1 -0
- package/dist/yrkesvaljaren/yrkesvaljaren.esm.js +1 -0
- package/dist/yrkesvaljaren/yrkesvaljaren.esm.js.map +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +126 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ComponentState, TaxonomyItem, SearchResult, JobSelectionItem, JobSelectionReference } from './types';
|
|
2
|
+
export interface ControllerCallbacks {
|
|
3
|
+
onStateChange: (state: ComponentState) => void;
|
|
4
|
+
onEmitSelection: (selection: JobSelectionItem | JobSelectionItem[]) => void;
|
|
5
|
+
onEmitValidation: (payload: {
|
|
6
|
+
isValid: boolean;
|
|
7
|
+
errorType: 'required' | 'invalidInput' | null;
|
|
8
|
+
}) => void;
|
|
9
|
+
onEmitDataLoadFailed: (error: Error) => void;
|
|
10
|
+
onEmitStatusChange: (payload: {
|
|
11
|
+
status: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface ControllerConfig {
|
|
16
|
+
enableMultiple: boolean;
|
|
17
|
+
required: boolean;
|
|
18
|
+
requireSelection: boolean;
|
|
19
|
+
history: boolean;
|
|
20
|
+
maxHistoryItems: number;
|
|
21
|
+
minLength: number;
|
|
22
|
+
maxResults: number;
|
|
23
|
+
popular?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type SetSelectionResult = {
|
|
26
|
+
ok: true;
|
|
27
|
+
selection: JobSelectionItem[];
|
|
28
|
+
} | {
|
|
29
|
+
ok: false;
|
|
30
|
+
invalidIds: string[];
|
|
31
|
+
};
|
|
32
|
+
export declare class JobSelectorController {
|
|
33
|
+
private callbacks;
|
|
34
|
+
private config;
|
|
35
|
+
private state;
|
|
36
|
+
private taxonomyData;
|
|
37
|
+
private popularItems;
|
|
38
|
+
private searchEngine;
|
|
39
|
+
private debounceTimer?;
|
|
40
|
+
private validationTimer?;
|
|
41
|
+
private isTouched;
|
|
42
|
+
private activeErrorType;
|
|
43
|
+
constructor(callbacks: ControllerCallbacks, config: ControllerConfig);
|
|
44
|
+
getState(): ComponentState;
|
|
45
|
+
getActiveErrorType(): 'required' | 'invalidInput' | null;
|
|
46
|
+
updateConfig(newConfig: Partial<ControllerConfig>): void;
|
|
47
|
+
getTaxonomyData(): TaxonomyItem[];
|
|
48
|
+
destroy(): void;
|
|
49
|
+
initialize(initialData?: TaxonomyItem[]): Promise<void>;
|
|
50
|
+
handleFocus(): void;
|
|
51
|
+
private setStateToActive;
|
|
52
|
+
handleInput(value: string): void;
|
|
53
|
+
private performSearch;
|
|
54
|
+
addToHistory(item: SearchResult): void;
|
|
55
|
+
clearHistory(): void;
|
|
56
|
+
private computePopularItems;
|
|
57
|
+
showHistory(force?: boolean): void;
|
|
58
|
+
selectItem(item: SearchResult): void;
|
|
59
|
+
clearSelection(): void;
|
|
60
|
+
removeItem(item: SearchResult): void;
|
|
61
|
+
handleBlur(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Validerar nuvarande värde och sätter eventuella valideringsfel.
|
|
64
|
+
* @param forceTouch - Tvingar valideringen att köras (och därmed visa fel) även om fältet inte tidigare blivit rört (touched). Default är false.
|
|
65
|
+
*/
|
|
66
|
+
runValidation(forceTouch?: boolean): boolean;
|
|
67
|
+
selectItemById(id: string): void;
|
|
68
|
+
selectItemsByIds(ids?: string[]): void;
|
|
69
|
+
setSelection(selection: JobSelectionReference[]): SetSelectionResult;
|
|
70
|
+
editSelection(): void;
|
|
71
|
+
private checkHasValue;
|
|
72
|
+
private getCommonState;
|
|
73
|
+
resetMultiSelection(): void;
|
|
74
|
+
private updateState;
|
|
75
|
+
private toSearchResult;
|
|
76
|
+
toPublicSelection(item: SearchResult): JobSelectionItem;
|
|
77
|
+
private createManualInputItem;
|
|
78
|
+
private findExactMatch;
|
|
79
|
+
handleFreeTextSelection(value: string): void;
|
|
80
|
+
loadMore(): void;
|
|
81
|
+
resetSearch(): void;
|
|
82
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
|
+
import { ComponentState, TaxonomyItem, JobSelectionItem, JobSelectionInput, JobSelectorMetadata } from './types';
|
|
3
|
+
import { GenericItem } from '../core-selector/types';
|
|
4
|
+
export declare class JobSelector {
|
|
5
|
+
hostElement: HTMLElement;
|
|
6
|
+
internals: ElementInternals;
|
|
7
|
+
/**
|
|
8
|
+
* HTML-formulärets fältnamn. Följer standardattributet `name`, på samma sätt som
|
|
9
|
+
* `<input name="...">`, och används som nyckel när värdet läses via `FormData`.
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Fullständig, explicit URL till en egenhostad datafil.
|
|
14
|
+
* Utelämna attributet för att använda senaste data automatiskt.
|
|
15
|
+
*/
|
|
16
|
+
taxonomyUrl?: string;
|
|
17
|
+
placeholder: string;
|
|
18
|
+
label: string;
|
|
19
|
+
/** Om satt till true kan väljaren inte användas med mus eller tangentbord. */
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
enableMultiple: boolean;
|
|
22
|
+
showSearchIcon: boolean;
|
|
23
|
+
errorMessage?: string;
|
|
24
|
+
labelDescription?: string;
|
|
25
|
+
/** Om satt till `true` måste fältet ha ett värde för att vara giltigt. */
|
|
26
|
+
required: boolean;
|
|
27
|
+
/** Om satt till `true` tillåts fritext som inte finns i taxonomin. */
|
|
28
|
+
manualInput: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Aktiverar historiken.
|
|
31
|
+
* Använder Local Storage för att spara valda yrken i webbläsaren.
|
|
32
|
+
* Integritet: Data lagras bara lokalt i webbläsaren.
|
|
33
|
+
* Räckvidd: Historiken delas mellan sidor på samma domän.
|
|
34
|
+
*/
|
|
35
|
+
history: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Om satt till true visas populära yrken initialt när historiken är tom.
|
|
38
|
+
*/
|
|
39
|
+
popular: boolean;
|
|
40
|
+
private maxHistoryItems;
|
|
41
|
+
private enableSelectionAnimation;
|
|
42
|
+
private afFocused;
|
|
43
|
+
private populateInputOnSelect;
|
|
44
|
+
private maxVisibleRows?;
|
|
45
|
+
private minLength;
|
|
46
|
+
private maxResults;
|
|
47
|
+
private get requireSelection();
|
|
48
|
+
/**
|
|
49
|
+
* Storleken på inputfältet.
|
|
50
|
+
* 'small' | 'medium' | 'large'
|
|
51
|
+
*/
|
|
52
|
+
size: 'small' | 'medium' | 'large';
|
|
53
|
+
constructor();
|
|
54
|
+
state: ComponentState;
|
|
55
|
+
/**
|
|
56
|
+
* Spårar vilken typ av fel som är aktivt,
|
|
57
|
+
* för att kunna visa rätt meddelande.
|
|
58
|
+
*/
|
|
59
|
+
private activeErrorType;
|
|
60
|
+
private animatingItemId;
|
|
61
|
+
private animationTimer?;
|
|
62
|
+
private cloneSelection;
|
|
63
|
+
private rebuildValidJobIds;
|
|
64
|
+
private validateSelectionCandidate;
|
|
65
|
+
private describeSelectionRejection;
|
|
66
|
+
private errorCodeForRejection;
|
|
67
|
+
private rejectSelection;
|
|
68
|
+
private syncAcceptedSelection;
|
|
69
|
+
private applySelection;
|
|
70
|
+
watchRequired(newValue: boolean): void;
|
|
71
|
+
watchManualInput(newValue: boolean): void;
|
|
72
|
+
watchHistory(newValue: boolean): void;
|
|
73
|
+
watchPopular(newValue: boolean): void;
|
|
74
|
+
watchEnableMultiple(newValue: boolean): void;
|
|
75
|
+
watchDisabled(newValue: boolean): void;
|
|
76
|
+
watchTaxonomyData(newValue: TaxonomyItem[]): void;
|
|
77
|
+
/**
|
|
78
|
+
* Yrkesdata (taxonomi). Kan injiceras av integratören för deterministisk laddning (t.ex. i testmiljöer).
|
|
79
|
+
* Om den lämnas tom populeras den internt via det globala registret eller auto-fetch för att exponera aktuell data.
|
|
80
|
+
*/
|
|
81
|
+
taxonomyData: TaxonomyItem[];
|
|
82
|
+
afJobSelectedEmitter: EventEmitter<JobSelectionItem[]>;
|
|
83
|
+
private syncFormValue;
|
|
84
|
+
handleFormValidationSync(event: CustomEvent<{
|
|
85
|
+
isValid: boolean;
|
|
86
|
+
errorType: 'required' | 'invalidInput' | null;
|
|
87
|
+
}>): void;
|
|
88
|
+
dataLoadFailedEmitter: EventEmitter<{
|
|
89
|
+
error: Error;
|
|
90
|
+
}>;
|
|
91
|
+
validationChangeEmitter: EventEmitter<{
|
|
92
|
+
isValid: boolean;
|
|
93
|
+
errorType: 'required' | 'invalidInput' | null;
|
|
94
|
+
}>;
|
|
95
|
+
static nextId: number;
|
|
96
|
+
private readonly componentId;
|
|
97
|
+
private observer;
|
|
98
|
+
private controller;
|
|
99
|
+
private validJobIds;
|
|
100
|
+
private lastAcceptedSelection;
|
|
101
|
+
private restoreAcceptedSelectionAfterDataUpdate;
|
|
102
|
+
componentWillLoad(): Promise<void>;
|
|
103
|
+
componentDidLoad(): void;
|
|
104
|
+
disconnectedCallback(): void;
|
|
105
|
+
handleHashFocus(): void;
|
|
106
|
+
handleInput(event: CustomEvent<string>): void;
|
|
107
|
+
handleCsSelect(event: CustomEvent<GenericItem<JobSelectorMetadata>>): void;
|
|
108
|
+
handleCsClear(): void;
|
|
109
|
+
handleCsClearHistory(): void;
|
|
110
|
+
handleCsRequestHistory(): void;
|
|
111
|
+
handleCsLoadMore(): void;
|
|
112
|
+
handleCsRemoveItem(event: CustomEvent<GenericItem<JobSelectorMetadata>>): void;
|
|
113
|
+
handleCsFocus(): void;
|
|
114
|
+
handleCsBlur(): void;
|
|
115
|
+
handleCsEditSelection(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Uppdaterar taxonomidatan genom att läsa om från registret.
|
|
118
|
+
* Används efter att registerTaxonomy() har anropats med ny data.
|
|
119
|
+
*/
|
|
120
|
+
updateData(): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Sätter ett programatiskt val och returnerar YV:s normaliserade, rika selection.
|
|
123
|
+
* Strängar som matchar Concept ID-formatet tolkas som taxonomi-id:n; övriga som fritext.
|
|
124
|
+
*/
|
|
125
|
+
setSelection(input: JobSelectionInput): Promise<JobSelectionItem[]>;
|
|
126
|
+
setFocus(): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Validerar komponenten manuellt.
|
|
129
|
+
* @param forceTouch - Om true, tvingas valideringsfel att visas även om användaren inte interagerat med fältet.
|
|
130
|
+
*/
|
|
131
|
+
validate(forceTouch?: boolean): Promise<boolean>;
|
|
132
|
+
checkValidity(): Promise<boolean>;
|
|
133
|
+
reportValidity(): Promise<boolean>;
|
|
134
|
+
getValidity(): Promise<ValidityState>;
|
|
135
|
+
getValidationMessage(): Promise<string>;
|
|
136
|
+
private updateValidity;
|
|
137
|
+
private _mapSearchResultToGenericItem;
|
|
138
|
+
private _mapStateToSelectorState;
|
|
139
|
+
render(): any;
|
|
140
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentState, SearchResult } from './types';
|
|
2
|
+
export interface KeyboardNavigationContext {
|
|
3
|
+
state: ComponentState;
|
|
4
|
+
requireSelection: boolean;
|
|
5
|
+
activeIndex: number;
|
|
6
|
+
listId: string;
|
|
7
|
+
listRef: HTMLDivElement;
|
|
8
|
+
onNavigate: (newIndex: number) => void;
|
|
9
|
+
onSelect: (item: SearchResult) => void;
|
|
10
|
+
onClearSuggestions: () => void;
|
|
11
|
+
onEnterWithoutSelection: (value: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function handleKeyboardNavigation(event: KeyboardEvent, context: KeyboardNavigationContext): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GenericItem } from '../../core-selector/types';
|
|
2
|
+
import { TaxonomyItem, SearchResult, JobSelectionItem, JobSelectorMetadata } from '../types';
|
|
3
|
+
export declare const TaxonomyAdapter: {
|
|
4
|
+
/** Maps a raw TaxonomyItem to a GenericItem for the CoreSelector */
|
|
5
|
+
toGenericItem(item: TaxonomyItem): GenericItem<JobSelectorMetadata>;
|
|
6
|
+
/** Maps a SearchResult (from our engine) to a GenericItem */
|
|
7
|
+
searchResultToGenericItem(result: SearchResult, query: string): GenericItem<JobSelectorMetadata>;
|
|
8
|
+
/** Maps a GenericItem back to our internal SearchResult format */
|
|
9
|
+
fromGenericItem(item: GenericItem<JobSelectorMetadata>): Partial<SearchResult>;
|
|
10
|
+
/** Maps an internal item to the public event format */
|
|
11
|
+
toPublicSelection(item: SearchResult | Partial<SearchResult>): JobSelectionItem;
|
|
12
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TaxonomyItem, JobSelectionItem, JobSelectorMetadata } from '../types';
|
|
2
|
+
import { GenericItem } from '../../core-selector/types';
|
|
3
|
+
export interface IPublicSearchEngine {
|
|
4
|
+
search(query: string, maxResults?: number): JobSelectionItem[];
|
|
5
|
+
}
|
|
6
|
+
export declare class TaxonomySearchEngine implements IPublicSearchEngine {
|
|
7
|
+
private fuseInstance;
|
|
8
|
+
private items;
|
|
9
|
+
constructor(data: TaxonomyItem[]);
|
|
10
|
+
/**
|
|
11
|
+
* Public API: Performs a search and returns clean, official domain objects.
|
|
12
|
+
* This is what external consumers (headless) should use.
|
|
13
|
+
*/
|
|
14
|
+
search(query: string, maxResults?: number): JobSelectionItem[];
|
|
15
|
+
/**
|
|
16
|
+
* Internal API: Performs a search and returns GenericItems for the CoreSelector UI ("Bucky").
|
|
17
|
+
* Includes highlighting, grouping and internal metadata.
|
|
18
|
+
*/
|
|
19
|
+
searchAsGeneric(query: string, maxResults?: number): GenericItem<JobSelectorMetadata>[];
|
|
20
|
+
updateData(newData: TaxonomyItem[]): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SearchResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Determines whether the "Manual Input" option should be shown in the suggestions list.
|
|
4
|
+
*
|
|
5
|
+
* Logic:
|
|
6
|
+
* 1. If requireSelection is true, never show manual input option.
|
|
7
|
+
* 2. If input is empty/whitespace, never show manual input option.
|
|
8
|
+
* 3. If there's an exact match (case-insensitive) in suggestions, don't show (avoid duplicates).
|
|
9
|
+
* 4. If the best suggestion has a "good" direct score, don't show.
|
|
10
|
+
* 5. Otherwise, show the manual input option.
|
|
11
|
+
*
|
|
12
|
+
* @param suggestions - Array of search results from the taxonomy search
|
|
13
|
+
* @param inputValue - Current user input value
|
|
14
|
+
* @param requireSelection - Whether selection from taxonomy is required
|
|
15
|
+
* @returns true if manual input option should be displayed
|
|
16
|
+
*/
|
|
17
|
+
export declare function shouldShowManualInputOption(suggestions: SearchResult[], inputValue: string, requireSelection: boolean): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Fuse from 'fuse.js';
|
|
2
|
+
import { TaxonomyItem, SearchResult } from './types';
|
|
3
|
+
import { FormattedText } from '../core-selector/types';
|
|
4
|
+
export declare const normalizeForComparison: (text: string | undefined | null) => string;
|
|
5
|
+
export declare function formatDisplayLabel(item: TaxonomyItem): string;
|
|
6
|
+
export declare function getLabel(item: TaxonomyItem): string;
|
|
7
|
+
export declare function sortResultsStrict(results: SearchResult[]): SearchResult[];
|
|
8
|
+
export declare function segmentsToHtml(segments: FormattedText): string;
|
|
9
|
+
export declare const styleParentheticalText: (text: string | undefined | null) => string;
|
|
10
|
+
export declare function searchConcepts(query: string, items: TaxonomyItem[], fuseInstance: Fuse<TaxonomyItem>, maxResults: number): SearchResult[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SearchResult } from './types';
|
|
2
|
+
interface SuggestionsListProps {
|
|
3
|
+
suggestions: SearchResult[];
|
|
4
|
+
inputValue: string;
|
|
5
|
+
activeIndex: number;
|
|
6
|
+
listId: string;
|
|
7
|
+
requireSelection: boolean;
|
|
8
|
+
onSelect: (item: SearchResult) => void;
|
|
9
|
+
onMouseEnter: (index: number) => void;
|
|
10
|
+
setListRef: (el: HTMLDivElement | undefined) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const SuggestionsList: (props: SuggestionsListProps) => any;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TaxonomyItem } from './types';
|
|
2
|
+
interface TaxonomyRegistration {
|
|
3
|
+
data: TaxonomyItem[];
|
|
4
|
+
metadata?: {
|
|
5
|
+
labour_market_taxonomy_version?: unknown;
|
|
6
|
+
};
|
|
7
|
+
taxonomyVersion?: unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare function isTaxonomyItem(value: unknown): value is TaxonomyItem;
|
|
10
|
+
export declare function isTaxonomyRegistration(value: unknown): value is TaxonomyRegistration;
|
|
11
|
+
/**
|
|
12
|
+
* Registrerar validerad taxonomidata för webbkomponenten.
|
|
13
|
+
* Ogiltig data ersätter aldrig en tidigare giltig registrering.
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerTaxonomy(data: unknown): void;
|
|
16
|
+
/** Hämtar den registrerade taxonomin. */
|
|
17
|
+
export declare function getRegisteredTaxonomy(): TaxonomyItem[];
|
|
18
|
+
/** Endast för testning: återställer registret. */
|
|
19
|
+
export declare function __resetRegistry(): void;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TaxonomyItem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* En kontrollerad och statisk datamängd för enhetstester.
|
|
4
|
+
* Denna data är designad för att testa specifika logikregler
|
|
5
|
+
* och ska inte ändras om inte logiken den testar ändras.
|
|
6
|
+
*/
|
|
7
|
+
export declare const mockSearchTestData: TaxonomyItem[];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { FormattedText } from '../core-selector/types';
|
|
2
|
+
export type ComponentStatus = 'loading' | 'error' | 'searching' | 'showingHistory' | 'itemSelected' | 'multiSelect' | 'multiSelectShowingHistory';
|
|
3
|
+
export type ValidationStatus = 'idle' | 'error' | 'success';
|
|
4
|
+
export interface BaseState {
|
|
5
|
+
status: ComponentStatus;
|
|
6
|
+
dataSource?: 'registry' | 'api';
|
|
7
|
+
dataSourceDate?: string;
|
|
8
|
+
validation?: ValidationStatus;
|
|
9
|
+
validationContext?: 'from-error';
|
|
10
|
+
isPopularView?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface LoadingState extends BaseState {
|
|
13
|
+
status: 'loading';
|
|
14
|
+
}
|
|
15
|
+
export interface ErrorState extends BaseState {
|
|
16
|
+
status: 'error';
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SearchingState extends BaseState {
|
|
20
|
+
status: 'searching';
|
|
21
|
+
inputValue: string;
|
|
22
|
+
suggestions: SearchResult[];
|
|
23
|
+
}
|
|
24
|
+
export interface ShowingHistoryState extends BaseState {
|
|
25
|
+
status: 'showingHistory';
|
|
26
|
+
inputValue: string;
|
|
27
|
+
historyItems: SearchResult[];
|
|
28
|
+
validation: ValidationStatus;
|
|
29
|
+
}
|
|
30
|
+
export interface ItemSelectedState extends BaseState {
|
|
31
|
+
status: 'itemSelected';
|
|
32
|
+
selectedItem: SearchResult;
|
|
33
|
+
inputValue: string;
|
|
34
|
+
}
|
|
35
|
+
export interface MultiSelectState extends BaseState {
|
|
36
|
+
status: 'multiSelect';
|
|
37
|
+
inputValue: string;
|
|
38
|
+
selectedItems: SearchResult[];
|
|
39
|
+
suggestions: SearchResult[];
|
|
40
|
+
}
|
|
41
|
+
export interface MultiSelectShowingHistoryState extends BaseState {
|
|
42
|
+
status: 'multiSelectShowingHistory';
|
|
43
|
+
inputValue: string;
|
|
44
|
+
selectedItems: SearchResult[];
|
|
45
|
+
historyItems: SearchResult[];
|
|
46
|
+
}
|
|
47
|
+
export type ComponentState = LoadingState | ErrorState | SearchingState | ShowingHistoryState | ItemSelectedState | MultiSelectState | MultiSelectShowingHistoryState;
|
|
48
|
+
export interface TaxonomyItem {
|
|
49
|
+
id: string;
|
|
50
|
+
type: 'job-title' | 'occupation-name';
|
|
51
|
+
preferred_label: string;
|
|
52
|
+
ssyk_level_4_id?: string;
|
|
53
|
+
ssyk_code_2012?: string;
|
|
54
|
+
occupation_name_id?: string;
|
|
55
|
+
occupation_name_preferred_label?: string;
|
|
56
|
+
weight?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface SearchResult extends Omit<TaxonomyItem, 'type'> {
|
|
59
|
+
type: TaxonomyItem['type'] | 'ManualInput' | 'unknown';
|
|
60
|
+
rawLabel: string;
|
|
61
|
+
displayLabel: string;
|
|
62
|
+
highlightedLabel: string;
|
|
63
|
+
score: number;
|
|
64
|
+
displaySegments?: FormattedText;
|
|
65
|
+
occupationLabel?: string;
|
|
66
|
+
occupationId?: string;
|
|
67
|
+
isSelected?: boolean;
|
|
68
|
+
weight?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface JobSelectorMetadata {
|
|
71
|
+
original?: SearchResult | TaxonomyItem;
|
|
72
|
+
originalResult?: SearchResult;
|
|
73
|
+
type?: string;
|
|
74
|
+
weight?: number;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
export interface RawTaxonomyDataResponse {
|
|
78
|
+
concepts: TaxonomyItem[];
|
|
79
|
+
}
|
|
80
|
+
export interface OccupationNameSelectionItem {
|
|
81
|
+
type: 'occupation-name';
|
|
82
|
+
id: string;
|
|
83
|
+
preferred_label: string;
|
|
84
|
+
}
|
|
85
|
+
export type JobSelectionItem = {
|
|
86
|
+
type: 'job-title' | 'occupation-name';
|
|
87
|
+
id: string;
|
|
88
|
+
preferred_label: string;
|
|
89
|
+
ssyk_code_2012?: string;
|
|
90
|
+
related?: OccupationNameSelectionItem;
|
|
91
|
+
} | {
|
|
92
|
+
type: 'manual-input';
|
|
93
|
+
id: null;
|
|
94
|
+
preferred_label: string;
|
|
95
|
+
};
|
|
96
|
+
export type JobSelectionReference = {
|
|
97
|
+
id: string;
|
|
98
|
+
} | Extract<JobSelectionItem, {
|
|
99
|
+
type: 'manual-input';
|
|
100
|
+
}>;
|
|
101
|
+
export type JobSelectionInput = string | string[] | JobSelectionItem[];
|
|
102
|
+
export type InvalidSelectionErrorCode = 'unknown-id' | 'invalid-input' | 'manual-input-disabled' | 'multiple-disabled';
|
|
103
|
+
export declare class InvalidSelectionError extends Error {
|
|
104
|
+
readonly code: InvalidSelectionErrorCode;
|
|
105
|
+
readonly invalidIds?: string[];
|
|
106
|
+
constructor(message: string, code: InvalidSelectionErrorCode, invalidIds?: string[]);
|
|
107
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface ValidationMessageProps {
|
|
2
|
+
validation: 'idle' | 'error' | 'success';
|
|
3
|
+
activeErrorType: 'required' | 'invalidInput' | null;
|
|
4
|
+
errorMessage?: string;
|
|
5
|
+
errorMessageId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const ValidationMessage: (props: ValidationMessageProps) => any;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare class YrkesvaljarenDemo {
|
|
2
|
+
el: HTMLElement;
|
|
3
|
+
variant: 'single' | 'multi';
|
|
4
|
+
version: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
allowFreeText: boolean;
|
|
7
|
+
history: boolean;
|
|
8
|
+
size: 'small' | 'medium' | 'large';
|
|
9
|
+
framework: 'html' | 'angular' | 'react';
|
|
10
|
+
codeInstallationMode: 'latest' | 'versioned';
|
|
11
|
+
afHideHeader: boolean;
|
|
12
|
+
afHidePreamble: boolean;
|
|
13
|
+
lastSingleSelection: string;
|
|
14
|
+
lastMultiSelection: string;
|
|
15
|
+
implementationCode: string;
|
|
16
|
+
readmeMainContent: string;
|
|
17
|
+
readmeCodeContent: any[];
|
|
18
|
+
availableYvVersions: string[];
|
|
19
|
+
latestYvDataVersion: string;
|
|
20
|
+
latestVersion: string;
|
|
21
|
+
latestDate: string;
|
|
22
|
+
latestType: string;
|
|
23
|
+
latestChanges: string;
|
|
24
|
+
isTaxonomyLoading: boolean;
|
|
25
|
+
private singleBox;
|
|
26
|
+
private multiBox;
|
|
27
|
+
private latestYvDataUrl;
|
|
28
|
+
componentWillLoad(): Promise<void>;
|
|
29
|
+
loadDataPackageManifest(): Promise<void>;
|
|
30
|
+
getTaxonomyUrls(): string[];
|
|
31
|
+
fetchFirstOk(urls: string[]): Promise<Response>;
|
|
32
|
+
getExampleDataPackageName(): string;
|
|
33
|
+
refreshTaxonomy(): Promise<void>;
|
|
34
|
+
loadChangelog(): Promise<void>;
|
|
35
|
+
componentDidLoad(): void;
|
|
36
|
+
componentDidUpdate(): void;
|
|
37
|
+
triggerHighlight(): void;
|
|
38
|
+
handleSelection(event: CustomEvent): void;
|
|
39
|
+
loadMarkdown(): Promise<void>;
|
|
40
|
+
updateCodeBlock(): void;
|
|
41
|
+
handleVariantChange(e: any): void;
|
|
42
|
+
handleVersionChange(e: any): Promise<void>;
|
|
43
|
+
handleRequiredChange(e: any): void;
|
|
44
|
+
handleFreeTextChange(e: any): void;
|
|
45
|
+
handleHistoryChange(e: any): void;
|
|
46
|
+
handleSizeChange(e: any): void;
|
|
47
|
+
handleFrameworkChange(e: any): void;
|
|
48
|
+
handleCodeInstallationModeChange(e: any): void;
|
|
49
|
+
handleCopyCode(): void;
|
|
50
|
+
render(): any;
|
|
51
|
+
getInstallationCommandPart1(): string;
|
|
52
|
+
getInstallationCommandPart2(): string;
|
|
53
|
+
getSetupCommand(): string;
|
|
54
|
+
getUsageCommand(): string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TaxonomySearchEngine } from '../job-selector/logic/search.engine';
|
|
2
|
+
export declare class NeobrutalSearch {
|
|
3
|
+
el: HTMLElement;
|
|
4
|
+
engine: TaxonomySearchEngine | null;
|
|
5
|
+
results: any[];
|
|
6
|
+
inputValue: string;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
error: string;
|
|
9
|
+
selectedItem: any | null;
|
|
10
|
+
isFlipped: boolean;
|
|
11
|
+
componentWillLoad(): Promise<void>;
|
|
12
|
+
componentDidUpdate(): void;
|
|
13
|
+
highlightCode(): void;
|
|
14
|
+
handleInput(event: Event): void;
|
|
15
|
+
handleSelect(item: any): void;
|
|
16
|
+
toggleFlip(): void;
|
|
17
|
+
render(): any;
|
|
18
|
+
}
|