slim-select 3.6.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ export interface NavLink {
2
+ label: string;
3
+ path: string;
4
+ }
5
+ export interface HeaderItem {
6
+ id: string;
7
+ label: string;
8
+ /** Direct link (no dropdown) */
9
+ path?: string;
10
+ /** Dropdown of pages */
11
+ children?: NavLink[];
12
+ }
13
+ /**
14
+ * Top header is intentionally short. "Docs" and "Frameworks" open a dropdown of
15
+ * pages; each page renders its own "On this page" sidebar (see page_nav.vue).
16
+ */
17
+ export declare const headerItems: HeaderItem[];
18
+ export declare function hasSidebar(path: string): boolean;
19
+ /** Which header item should appear active for the current route. */
20
+ export declare function activeHeaderId(path: string): string | null;
package/dist/store.d.ts CHANGED
@@ -20,7 +20,6 @@ export declare class Optgroup {
20
20
  id: string;
21
21
  label: string;
22
22
  selectAll: boolean;
23
- selectAllText: string;
24
23
  closable: 'off' | 'open' | 'close';
25
24
  options: Partial<Option>[];
26
25
  constructor(optgroup: Partial<Optgroup>);
@@ -29,13 +28,22 @@ export default class Store {
29
28
  private selectType;
30
29
  private data;
31
30
  private selectedOrder;
31
+ /** Baseline option list — restored when search is cleared (API results are temporary). */
32
+ private catalog;
32
33
  constructor(type: 'single' | 'multiple', data: (Partial<Option> | Partial<Optgroup>)[]);
33
34
  validateDataArray(data: (Partial<Option> | Partial<Optgroup>)[]): Error | null;
34
35
  validateOption(option: Partial<Option>): Error | null;
35
36
  partialToFullData(data: (Partial<Option> | Partial<Optgroup>)[]): (Option | Optgroup)[];
37
+ /** Snapshot the current data as the catalog baseline (not called for API search results). */
38
+ snapshotCatalog(): void;
39
+ /** Catalog baseline used when clearing search. */
40
+ getCatalogData(): (Option | Optgroup)[];
41
+ private cloneData;
42
+ private optionMatchesSelected;
43
+ private findOptionInData;
36
44
  setData(data: (Partial<Option> | Partial<Optgroup>)[], preserveSelected?: boolean): void;
37
- getData(): Option[] | Optgroup[];
38
- getDataOptions(): Option[];
45
+ getData(clone?: boolean): Option[] | Optgroup[];
46
+ getDataOptions(clone?: boolean): Option[];
39
47
  addOption(option: Partial<Option>, addToStart?: boolean): void;
40
48
  setSelectedBy(selectedType: 'id' | 'value', selectedValues: string[], allowEmptySelection?: boolean): void;
41
49
  getSelected(): string[];
@@ -46,8 +54,9 @@ export default class Store {
46
54
  getSelectType(): string;
47
55
  getFirstOption(): Option | null;
48
56
  search(search: string, searchFilter: (opt: Option, search: string) => boolean): (Option | Optgroup)[];
57
+ private createOptgroupView;
49
58
  filter(filter: {
50
59
  (opt: Option): boolean;
51
- } | null, includeOptgroup: boolean): (Option | Optgroup)[];
60
+ } | null, includeOptgroup: boolean, clone?: boolean): (Option | Optgroup)[];
52
61
  selectedOrderOptions(options: Option[]): Option[];
53
62
  }
package/dist/sync.d.ts ADDED
@@ -0,0 +1,78 @@
1
+ import { default as Render } from './render';
2
+ import { default as Select } from './select';
3
+ import { default as Store, Optgroup, Option } from './store';
4
+ /** Where a change originated — affects batching and render behavior. */
5
+ export type ChangeSource = 'native' | 'ui' | 'api';
6
+ export interface SyncEvents {
7
+ afterChange?: (newVal: Option[]) => void;
8
+ error?: (err: Error) => void;
9
+ }
10
+ /**
11
+ * A single unit of work in the sync queue.
12
+ * Structure = replace option list; selection = change selected only; addOption = append one.
13
+ */
14
+ export type SyncChange = {
15
+ type: 'structure';
16
+ data: (Partial<Option> | Partial<Optgroup>)[];
17
+ source: ChangeSource;
18
+ /** Keep current selection when replacing data (async search results). */
19
+ preserveSelection?: boolean;
20
+ /** API search results — do not update the catalog baseline. */
21
+ isSearchResult?: boolean;
22
+ } | {
23
+ type: 'selection';
24
+ values: string | string[];
25
+ source: ChangeSource;
26
+ /** false when Vue/parent is pushing modelValue down (avoid emit loop). */
27
+ runAfterChange?: boolean;
28
+ } | {
29
+ type: 'addOption';
30
+ option: Partial<Option>;
31
+ source: ChangeSource;
32
+ };
33
+ export interface SyncDeps {
34
+ select: Select;
35
+ store: Store;
36
+ render: Render;
37
+ events: SyncEvents;
38
+ search?: (value: string) => void;
39
+ onError?: (err: Error) => void;
40
+ }
41
+ /** Skip structure sync when incoming data matches what's already in the store. */
42
+ export declare function shouldSkipStructureUpdate(store: Store, data: (Partial<Option> | Partial<Optgroup>)[]): boolean;
43
+ /**
44
+ * Resolve setSelected() arguments to option ids.
45
+ * Accepts either ids or values for backward compatibility.
46
+ */
47
+ export declare function resolveSelectedIds(store: Store, values: string | string[]): string[];
48
+ export default class SyncCoordinator {
49
+ private deps;
50
+ private queue;
51
+ private flushScheduled;
52
+ /** True while applyChange is running — prevents re-entrant flush loops. */
53
+ isSyncing: boolean;
54
+ constructor(deps: SyncDeps);
55
+ enqueue(change: SyncChange): void;
56
+ /** Process everything in the queue. Callable from tests for deterministic native sync. */
57
+ flush(): void;
58
+ /**
59
+ * Collapse a batch into the minimum work needed.
60
+ * Structure sync already includes selection from getData(), so drop redundant
61
+ * selection changes in the same batch. When multiple structure updates arrive,
62
+ * only the last one wins.
63
+ */
64
+ private coalesceBatch;
65
+ private applyChange;
66
+ /**
67
+ * Full sync: store → native <select> rebuild → render values + options.
68
+ * Used when the option list itself changes (setData, native DOM edits, search results).
69
+ */
70
+ private applyStructure;
71
+ /**
72
+ * Lightweight selection sync: flip option.selected on native DOM only.
73
+ * Avoids select.updateOptions() (innerHTML rebuild) for selection-only changes.
74
+ */
75
+ private applySelection;
76
+ /** Append a single option then full-sync native + render (same as legacy addOption). */
77
+ private applyAddOption;
78
+ }