svelte-multiselect 11.0.0-rc.1 → 11.1.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.
@@ -1,108 +1,19 @@
1
- import { SvelteComponent } from "svelte";
2
- import type { MultiSelectEvents, Option as T } from './types';
1
+ import type { MultiSelectProps } from './props';
2
+ import type { Option as T } from './types';
3
3
  declare class __sveltets_Render<Option extends T> {
4
- props(): {
5
- activeIndex?: number | null;
6
- activeOption?: Option | null | undefined;
7
- createOptionMsg?: string | null;
8
- allowUserOptions?: boolean | "append";
9
- allowEmpty?: boolean;
10
- autocomplete?: string;
11
- autoScroll?: boolean;
12
- breakpoint?: number;
13
- defaultDisabledTitle?: string;
14
- disabled?: boolean;
15
- disabledInputTitle?: string;
16
- duplicateOptionMsg?: string;
17
- duplicates?: boolean;
18
- key?: ((opt: T) => unknown) | undefined;
19
- filterFunc?: ((opt: Option, searchText: string) => boolean) | undefined;
20
- closeDropdownOnSelect?: boolean | "desktop";
21
- form_input?: HTMLInputElement | null;
22
- highlightMatches?: boolean;
23
- id?: string | null;
24
- input?: HTMLInputElement | null;
25
- inputClass?: string;
26
- inputStyle?: string | null;
27
- inputmode?: string | null;
28
- invalid?: boolean;
29
- liActiveOptionClass?: string;
30
- liActiveUserMsgClass?: string;
31
- liOptionClass?: string;
32
- liOptionStyle?: string | null;
33
- liSelectedClass?: string;
34
- liSelectedStyle?: string | null;
35
- liUserMsgClass?: string;
36
- loading?: boolean;
37
- matchingOptions?: Option[] | undefined;
38
- maxOptions?: number | undefined;
39
- maxSelect?: number | null;
40
- maxSelectMsg?: ((current: number, max: number) => string) | null | undefined;
41
- maxSelectMsgClass?: string;
42
- name?: string | null;
43
- noMatchingOptionsMsg?: string;
44
- open?: boolean;
45
- options: Option[];
46
- outerDiv?: HTMLDivElement | null;
47
- outerDivClass?: string;
48
- parseLabelsAsHtml?: boolean;
49
- pattern?: string | null;
50
- placeholder?: string | null;
51
- removeAllTitle?: string;
52
- removeBtnTitle?: string;
53
- minSelect?: number | null;
54
- required?: boolean | number;
55
- resetFilterOnAdd?: boolean;
56
- searchText?: string;
57
- selected?: Option[] | undefined;
58
- sortSelected?: boolean | ((op1: Option, op2: Option) => number) | undefined;
59
- selectedOptionsDraggable?: boolean;
60
- style?: string | null;
61
- ulOptionsClass?: string;
62
- ulSelectedClass?: string;
63
- ulSelectedStyle?: string | null;
64
- ulOptionsStyle?: string | null;
65
- value?: Option | Option[] | null | undefined;
66
- };
67
- events(): MultiSelectEvents;
68
- slots(): {
69
- 'expand-icon': {
70
- open: boolean;
71
- };
72
- selected: {
73
- option: Option;
74
- idx: any;
75
- };
76
- default: {
77
- option: Option;
78
- idx: any;
79
- };
80
- 'remove-icon': {};
81
- 'after-input': {
82
- selected: Option[];
83
- disabled: boolean;
84
- invalid: boolean;
85
- id: string | null;
86
- placeholder: string | null;
87
- open: boolean;
88
- required: number | boolean;
89
- };
90
- spinner: {};
91
- 'disabled-icon': {};
92
- option: {
93
- option: Option;
94
- idx: any;
95
- };
96
- 'user-msg': {
97
- searchText: string;
98
- msgType: any;
99
- msg: any;
100
- };
101
- };
4
+ props(): MultiSelectProps<T>;
5
+ events(): {};
6
+ slots(): {};
7
+ bindings(): "value" | "selected" | "invalid" | "open" | "activeIndex" | "activeOption" | "form_input" | "input" | "matchingOptions" | "options" | "outerDiv" | "searchText";
8
+ exports(): {};
102
9
  }
103
- export type MultiSelectProps<Option extends T> = ReturnType<__sveltets_Render<Option>['props']>;
104
- export type MultiSelectEvents_<Option extends T> = ReturnType<__sveltets_Render<Option>['events']>;
105
- export type MultiSelectSlots<Option extends T> = ReturnType<__sveltets_Render<Option>['slots']>;
106
- export default class MultiSelect<Option extends T> extends SvelteComponent<MultiSelectProps<Option>, MultiSelectEvents_<Option>, MultiSelectSlots<Option>> {
10
+ interface $$IsomorphicComponent {
11
+ new <Option extends T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Option>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Option>['props']>, ReturnType<__sveltets_Render<Option>['events']>, ReturnType<__sveltets_Render<Option>['slots']>> & {
12
+ $$bindings?: ReturnType<__sveltets_Render<Option>['bindings']>;
13
+ } & ReturnType<__sveltets_Render<Option>['exports']>;
14
+ <Option extends T>(internal: unknown, props: ReturnType<__sveltets_Render<Option>['props']> & {}): ReturnType<__sveltets_Render<Option>['exports']>;
15
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
107
16
  }
108
- export {};
17
+ declare const MultiSelect: $$IsomorphicComponent;
18
+ type MultiSelect<Option extends T> = InstanceType<typeof MultiSelect<Option>>;
19
+ export default MultiSelect;
@@ -1,24 +1,15 @@
1
- <script>import { spring } from 'svelte/motion';
2
- // bind to this state and set it to true from parent
3
- export let wiggle = false;
4
- // intended use case: set max value during wiggle for one of angle, scale, dx, dy through props
5
- export let angle = 0; // try 20
6
- export let scale = 1; // try 1.2
7
- export let dx = 0; // try 10
8
- export let dy = 0; // try 10
9
- export let duration = 200;
10
- export let stiffness = 0.05;
11
- export let damping = 0.1;
12
- let rest_state = { angle: 0, scale: 1, dx: 0, dy: 0 };
13
- let store = spring(rest_state, { stiffness, damping });
14
- $: store.set(wiggle ? { scale, angle, dx, dy } : rest_state);
15
- $: if (wiggle)
16
- setTimeout(() => (wiggle = false), duration);
1
+ <script lang="ts">import { Spring } from 'svelte/motion';
2
+ let { wiggle = $bindable(false), angle = 0, scale = 1, dx = 0, dy = 0, duration = 200, stiffness = 0.05, damping = 0.1, children, } = $props();
3
+ const store = Spring.of(() => (wiggle ? { scale, angle, dx, dy } : { angle: 0, scale: 1, dx: 0, dy: 0 }), { stiffness, damping });
4
+ $effect.pre(() => {
5
+ if (wiggle)
6
+ setTimeout(() => (wiggle = false), duration);
7
+ });
17
8
  </script>
18
9
 
19
10
  <span
20
- style:transform="rotate({$store.angle}deg) scale({$store.scale}) translate({$store.dx}px,
21
- {$store.dy}px)"
11
+ style:transform="rotate({store.current.angle}deg) scale({store.current.scale})
12
+ translate({store.current.dx}px, {store.current.dy}px)"
22
13
  >
23
- <slot />
14
+ {@render children?.()}
24
15
  </span>
@@ -1,27 +1,15 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- wiggle?: boolean;
5
- angle?: number;
6
- scale?: number;
7
- dx?: number;
8
- dy?: number;
9
- duration?: number;
10
- stiffness?: number;
11
- damping?: number;
12
- };
13
- events: {
14
- [evt: string]: CustomEvent<any>;
15
- };
16
- slots: {
17
- default: {};
18
- };
19
- exports?: {} | undefined;
20
- bindings?: string | undefined;
21
- };
22
- export type WiggleProps = typeof __propDef.props;
23
- export type WiggleEvents = typeof __propDef.events;
24
- export type WiggleSlots = typeof __propDef.slots;
25
- export default class Wiggle extends SvelteComponent<WiggleProps, WiggleEvents, WiggleSlots> {
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ wiggle?: boolean;
4
+ angle?: number;
5
+ scale?: number;
6
+ dx?: number;
7
+ dy?: number;
8
+ duration?: number;
9
+ stiffness?: number;
10
+ damping?: number;
11
+ children?: Snippet;
26
12
  }
27
- export {};
13
+ declare const Wiggle: import("svelte").Component<Props, {}, "wiggle">;
14
+ type Wiggle = ReturnType<typeof Wiggle>;
15
+ export default Wiggle;
@@ -1,4 +1,8 @@
1
- <svg {...$$props} fill="currentColor" viewBox="0 0 16 16">
1
+ <script lang="ts">let { ...props } = $props();
2
+ export {};
3
+ </script>
4
+
5
+ <svg {...props} fill="currentColor" viewBox="0 0 16 16">
2
6
  <path
3
7
  d="M3.646 9.146a.5.5 0 0 1 .708 0L8 12.793l3.646-3.647a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 0-.708zm0-2.292a.5.5 0 0 0 .708 0L8 3.207l3.646 3.647a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 0 0 0 .708z"
4
8
  />
@@ -1,25 +1,4 @@
1
- /** @typedef {typeof __propDef.props} ChevronExpandProps */
2
- /** @typedef {typeof __propDef.events} ChevronExpandEvents */
3
- /** @typedef {typeof __propDef.slots} ChevronExpandSlots */
4
- export default class ChevronExpand extends SvelteComponent<{
5
- [x: string]: any;
6
- }, {
7
- [evt: string]: CustomEvent<any>;
8
- }, {}> {
9
- }
10
- export type ChevronExpandProps = typeof __propDef.props;
11
- export type ChevronExpandEvents = typeof __propDef.events;
12
- export type ChevronExpandSlots = typeof __propDef.slots;
13
- import { SvelteComponent } from "svelte";
14
- declare const __propDef: {
15
- props: {
16
- [x: string]: any;
17
- };
18
- events: {
19
- [evt: string]: CustomEvent<any>;
20
- };
21
- slots: {};
22
- exports?: undefined;
23
- bindings?: undefined;
24
- };
25
- export {};
1
+ import type { SVGAttributes } from 'svelte/elements';
2
+ declare const ChevronExpand: import("svelte").Component<SVGAttributes<EventTarget>, {}, "">;
3
+ type ChevronExpand = ReturnType<typeof ChevronExpand>;
4
+ export default ChevronExpand;
@@ -1,6 +1,10 @@
1
- <svg {...$$props} viewBox="0 0 24 24" fill="currentColor">
1
+ <script lang="ts">let { ...props } = $props();
2
+ export {};
3
+ </script>
4
+
5
+ <!-- https://api.iconify.design/ic:round-clear.svg -->
6
+ <svg {...props} viewBox="0 0 24 24" fill="currentColor">
2
7
  <path
3
8
  d="M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59L7.11 5.7A.996.996 0 1 0 5.7 7.11L10.59 12L5.7 16.89a.996.996 0 1 0 1.41 1.41L12 13.41l4.89 4.89a.996.996 0 1 0 1.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z"
4
9
  />
5
10
  </svg>
6
- <!-- https://api.iconify.design/ic:round-clear.svg -->
@@ -1,25 +1,4 @@
1
- /** @typedef {typeof __propDef.props} CrossProps */
2
- /** @typedef {typeof __propDef.events} CrossEvents */
3
- /** @typedef {typeof __propDef.slots} CrossSlots */
4
- export default class Cross extends SvelteComponent<{
5
- [x: string]: any;
6
- }, {
7
- [evt: string]: CustomEvent<any>;
8
- }, {}> {
9
- }
10
- export type CrossProps = typeof __propDef.props;
11
- export type CrossEvents = typeof __propDef.events;
12
- export type CrossSlots = typeof __propDef.slots;
13
- import { SvelteComponent } from "svelte";
14
- declare const __propDef: {
15
- props: {
16
- [x: string]: any;
17
- };
18
- events: {
19
- [evt: string]: CustomEvent<any>;
20
- };
21
- slots: {};
22
- exports?: undefined;
23
- bindings?: undefined;
24
- };
25
- export {};
1
+ import type { SVGAttributes } from 'svelte/elements';
2
+ declare const Cross: import("svelte").Component<SVGAttributes<EventTarget>, {}, "">;
3
+ type Cross = ReturnType<typeof Cross>;
4
+ export default Cross;
@@ -1,5 +1,9 @@
1
+ <script lang="ts">let { ...props } = $props();
2
+ export {};
3
+ </script>
4
+
1
5
  <!-- https://api.iconify.design/fe:disabled.svg -->
2
- <svg {...$$props} viewBox="0 0 24 24" fill="currentColor">
6
+ <svg {...props} viewBox="0 0 24 24" fill="currentColor">
3
7
  <path
4
8
  d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2S2 6.477 2 12s4.477 10 10 10Zm-4.906-3.68L18.32 7.094A8 8 0 0 1 7.094 18.32ZM5.68 16.906A8 8 0 0 1 16.906 5.68L5.68 16.906Z"
5
9
  />
@@ -1,25 +1,4 @@
1
- /** @typedef {typeof __propDef.props} DisabledProps */
2
- /** @typedef {typeof __propDef.events} DisabledEvents */
3
- /** @typedef {typeof __propDef.slots} DisabledSlots */
4
- export default class Disabled extends SvelteComponent<{
5
- [x: string]: any;
6
- }, {
7
- [evt: string]: CustomEvent<any>;
8
- }, {}> {
9
- }
10
- export type DisabledProps = typeof __propDef.props;
11
- export type DisabledEvents = typeof __propDef.events;
12
- export type DisabledSlots = typeof __propDef.slots;
13
- import { SvelteComponent } from "svelte";
14
- declare const __propDef: {
15
- props: {
16
- [x: string]: any;
17
- };
18
- events: {
19
- [evt: string]: CustomEvent<any>;
20
- };
21
- slots: {};
22
- exports?: undefined;
23
- bindings?: undefined;
24
- };
25
- export {};
1
+ import type { SVGAttributes } from 'svelte/elements';
2
+ declare const Disabled: import("svelte").Component<SVGAttributes<EventTarget>, {}, "">;
3
+ type Disabled = ReturnType<typeof Disabled>;
4
+ export default Disabled;
@@ -1,4 +1,8 @@
1
- <svg {...$$props} viewBox="0 0 24 24" fill="currentColor">
1
+ <script lang="ts">let { ...props } = $props();
2
+ export {};
3
+ </script>
4
+
5
+ <svg {...props} viewBox="0 0 24 24" fill="currentColor">
2
6
  <path
3
7
  d="M8.422 20.081c0 .896.01 1.753.016 2.285a.617.617 0 0 0 .422.58c2.078.686 4.317.718 6.414.091l.292-.087a.67.67 0 0 0 .478-.638c.005-.733.017-2.017.017-3.53c0-1.372-.477-2.25-1.031-2.707c3.399-.366 6.97-1.61 6.97-7.227c0-1.61-.592-2.91-1.566-3.934c.153-.366.688-1.866-.153-3.878c0 0-1.28-.403-4.201 1.5a14.76 14.76 0 0 0-3.82-.494c-1.298 0-2.597.165-3.819.494C5.52.65 4.24 1.036 4.24 1.036c-.84 2.012-.306 3.512-.153 3.878a5.565 5.565 0 0 0-1.566 3.934c0 5.598 3.552 6.86 6.951 7.227c-.439.366-.84 1.006-.973 1.957c-.879.384-3.075 1.006-4.45-1.207c-.286-.44-1.146-1.519-2.349-1.5c-1.28.018-.516.695.02.97c.648.347 1.393 1.646 1.565 2.067c.306.823 1.299 2.396 5.137 1.72Z"
4
8
  />
@@ -1,25 +1,4 @@
1
- /** @typedef {typeof __propDef.props} OctocatProps */
2
- /** @typedef {typeof __propDef.events} OctocatEvents */
3
- /** @typedef {typeof __propDef.slots} OctocatSlots */
4
- export default class Octocat extends SvelteComponent<{
5
- [x: string]: any;
6
- }, {
7
- [evt: string]: CustomEvent<any>;
8
- }, {}> {
9
- }
10
- export type OctocatProps = typeof __propDef.props;
11
- export type OctocatEvents = typeof __propDef.events;
12
- export type OctocatSlots = typeof __propDef.slots;
13
- import { SvelteComponent } from "svelte";
14
- declare const __propDef: {
15
- props: {
16
- [x: string]: any;
17
- };
18
- events: {
19
- [evt: string]: CustomEvent<any>;
20
- };
21
- slots: {};
22
- exports?: undefined;
23
- bindings?: undefined;
24
- };
25
- export {};
1
+ import type { SVGAttributes } from 'svelte/elements';
2
+ declare const Octocat: import("svelte").Component<SVGAttributes<EventTarget>, {}, "">;
3
+ type Octocat = ReturnType<typeof Octocat>;
4
+ export default Octocat;
package/dist/index.d.ts CHANGED
@@ -2,5 +2,6 @@ export { default as CircleSpinner } from './CircleSpinner.svelte';
2
2
  export { default as CmdPalette } from './CmdPalette.svelte';
3
3
  export { default as MultiSelect, default } from './MultiSelect.svelte';
4
4
  export { default as Wiggle } from './Wiggle.svelte';
5
+ export * from './props';
5
6
  export * from './types';
6
- export declare function scroll_into_view_if_needed_polyfill(centerIfNeeded?: boolean): IntersectionObserver;
7
+ export declare function scroll_into_view_if_needed_polyfill(element: Element, centerIfNeeded?: boolean): IntersectionObserver;
package/dist/index.js CHANGED
@@ -2,30 +2,32 @@ export { default as CircleSpinner } from './CircleSpinner.svelte';
2
2
  export { default as CmdPalette } from './CmdPalette.svelte';
3
3
  export { default as MultiSelect, default } from './MultiSelect.svelte';
4
4
  export { default as Wiggle } from './Wiggle.svelte';
5
+ export * from './props';
5
6
  export * from './types';
6
7
  // Firefox lacks support for scrollIntoViewIfNeeded (https://caniuse.com/scrollintoviewifneeded).
7
8
  // See https://github.com/janosh/svelte-multiselect/issues/87
8
9
  // Polyfill copied from
9
10
  // https://github.com/nuxodin/lazyfill/blob/a8e63/polyfills/Element/prototype/scrollIntoViewIfNeeded.js
10
11
  // exported for testing
11
- export function scroll_into_view_if_needed_polyfill(centerIfNeeded = true) {
12
- const elem = this;
13
- const observer = new IntersectionObserver(function ([entry]) {
12
+ export function scroll_into_view_if_needed_polyfill(element, centerIfNeeded = true) {
13
+ const observer = new IntersectionObserver(([entry], obs) => {
14
14
  const ratio = entry.intersectionRatio;
15
15
  if (ratio < 1) {
16
16
  const place = ratio <= 0 && centerIfNeeded ? `center` : `nearest`;
17
- elem.scrollIntoView({
17
+ element.scrollIntoView({
18
18
  block: place,
19
19
  inline: place,
20
20
  });
21
21
  }
22
- this.disconnect();
22
+ obs.disconnect();
23
23
  });
24
- observer.observe(elem);
24
+ observer.observe(element);
25
25
  return observer; // return for testing
26
26
  }
27
27
  if (typeof Element !== `undefined` &&
28
28
  !Element.prototype?.scrollIntoViewIfNeeded &&
29
29
  typeof IntersectionObserver !== `undefined`) {
30
- Element.prototype.scrollIntoViewIfNeeded = scroll_into_view_if_needed_polyfill;
30
+ Element.prototype.scrollIntoViewIfNeeded = function scrollIntoViewIfNeeded() {
31
+ scroll_into_view_if_needed_polyfill(this);
32
+ };
31
33
  }
@@ -0,0 +1,143 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { FocusEventHandler, HTMLInputAttributes, KeyboardEventHandler, MouseEventHandler, TouchEventHandler } from 'svelte/elements';
3
+ import type { Option } from './types';
4
+ export interface MultiSelectNativeEvents {
5
+ onblur?: FocusEventHandler<HTMLInputElement>;
6
+ onclick?: MouseEventHandler<HTMLInputElement>;
7
+ onfocus?: FocusEventHandler<HTMLInputElement>;
8
+ onkeydown?: KeyboardEventHandler<HTMLInputElement>;
9
+ onkeyup?: KeyboardEventHandler<HTMLInputElement>;
10
+ onmousedown?: MouseEventHandler<HTMLInputElement>;
11
+ onmouseenter?: MouseEventHandler<HTMLInputElement>;
12
+ onmouseleave?: MouseEventHandler<HTMLInputElement>;
13
+ ontouchcancel?: TouchEventHandler<HTMLInputElement>;
14
+ ontouchend?: TouchEventHandler<HTMLInputElement>;
15
+ ontouchmove?: TouchEventHandler<HTMLInputElement>;
16
+ ontouchstart?: TouchEventHandler<HTMLInputElement>;
17
+ }
18
+ export interface MultiSelectComponentEvents<T extends Option = Option> {
19
+ onadd?: (data: {
20
+ option: T;
21
+ }) => unknown;
22
+ oncreate?: (data: {
23
+ option: T;
24
+ }) => unknown;
25
+ onremove?: (data: {
26
+ option: T;
27
+ }) => unknown;
28
+ onremoveAll?: (data: {
29
+ options: T[];
30
+ }) => unknown;
31
+ onchange?: (data: {
32
+ option?: T;
33
+ options?: T[];
34
+ type: `add` | `remove` | `removeAll`;
35
+ }) => unknown;
36
+ onopen?: (data: {
37
+ event: Event;
38
+ }) => unknown;
39
+ onclose?: (data: {
40
+ event: Event;
41
+ }) => unknown;
42
+ }
43
+ export interface MultiSelectSnippets<T extends Option = Option> {
44
+ expandIcon?: Snippet<[{
45
+ open: boolean;
46
+ }]>;
47
+ selectedItem?: Snippet<[{
48
+ option: T;
49
+ idx: number;
50
+ }]>;
51
+ children?: Snippet<[{
52
+ option: T;
53
+ idx: number;
54
+ }]>;
55
+ removeIcon?: Snippet;
56
+ afterInput?: Snippet<[
57
+ Pick<MultiSelectParameters, `selected` | `disabled` | `invalid` | `id` | `placeholder` | `open` | `required`>
58
+ ]>;
59
+ spinner?: Snippet;
60
+ disabledIcon?: Snippet;
61
+ option?: Snippet<[{
62
+ option: T;
63
+ idx: number;
64
+ }]>;
65
+ userMsg?: Snippet<[
66
+ {
67
+ searchText: string;
68
+ msgType: false | `dupe` | `create` | `no-match`;
69
+ msg: null | string;
70
+ }
71
+ ]>;
72
+ }
73
+ export interface PortalParams {
74
+ target_node?: HTMLElement | null;
75
+ active?: boolean;
76
+ }
77
+ export interface MultiSelectParameters<T extends Option = Option> {
78
+ activeIndex?: number | null;
79
+ activeOption?: T | null;
80
+ createOptionMsg?: string | null;
81
+ allowUserOptions?: boolean | `append`;
82
+ allowEmpty?: boolean;
83
+ autocomplete?: HTMLInputAttributes[`autocomplete`];
84
+ autoScroll?: boolean;
85
+ breakpoint?: number;
86
+ defaultDisabledTitle?: string;
87
+ disabled?: boolean;
88
+ disabledInputTitle?: string;
89
+ duplicateOptionMsg?: string;
90
+ duplicates?: boolean;
91
+ key?: (opt: T) => unknown;
92
+ filterFunc?: (opt: T, searchText: string) => boolean;
93
+ closeDropdownOnSelect?: boolean | `desktop`;
94
+ form_input?: HTMLInputElement | null;
95
+ highlightMatches?: boolean;
96
+ id?: string | null;
97
+ input?: HTMLInputElement | null;
98
+ inputClass?: string;
99
+ inputStyle?: string | null;
100
+ inputmode?: HTMLInputAttributes[`inputmode`] | null;
101
+ invalid?: boolean;
102
+ liActiveOptionClass?: string;
103
+ liActiveUserMsgClass?: string;
104
+ liOptionClass?: string;
105
+ liOptionStyle?: string | null;
106
+ liSelectedClass?: string;
107
+ liSelectedStyle?: string | null;
108
+ liUserMsgClass?: string;
109
+ loading?: boolean;
110
+ matchingOptions?: T[];
111
+ maxOptions?: number | undefined;
112
+ maxSelect?: number | null;
113
+ maxSelectMsg?: ((current: number, max: number) => string) | null;
114
+ maxSelectMsgClass?: string;
115
+ name?: string | null;
116
+ noMatchingOptionsMsg?: string;
117
+ open?: boolean;
118
+ options: T[];
119
+ outerDiv?: HTMLDivElement | null;
120
+ outerDivClass?: string;
121
+ parseLabelsAsHtml?: boolean;
122
+ pattern?: string | null;
123
+ placeholder?: string | null;
124
+ removeAllTitle?: string;
125
+ removeBtnTitle?: string;
126
+ minSelect?: number | null;
127
+ required?: boolean | number;
128
+ resetFilterOnAdd?: boolean;
129
+ searchText?: string;
130
+ selected?: T[];
131
+ sortSelected?: boolean | ((op1: T, op2: T) => number);
132
+ selectedOptionsDraggable?: boolean;
133
+ style?: string | null;
134
+ ulOptionsClass?: string;
135
+ ulSelectedClass?: string;
136
+ ulSelectedStyle?: string | null;
137
+ ulOptionsStyle?: string | null;
138
+ value?: T | T[] | null;
139
+ portal?: PortalParams;
140
+ [key: string]: unknown;
141
+ }
142
+ export interface MultiSelectProps<T extends Option = Option> extends MultiSelectNativeEvents, MultiSelectComponentEvents<T>, MultiSelectSnippets<T>, MultiSelectParameters<T> {
143
+ }
package/dist/props.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/types.d.ts CHANGED
@@ -14,43 +14,3 @@ export type ObjectOption = {
14
14
  style?: OptionStyle;
15
15
  [key: string]: unknown;
16
16
  };
17
- export type DispatchEvents<T = Option> = {
18
- add: {
19
- option: T;
20
- };
21
- create: {
22
- option: T;
23
- };
24
- remove: {
25
- option: T;
26
- };
27
- removeAll: {
28
- options: T[];
29
- };
30
- change: {
31
- option?: T;
32
- options?: T[];
33
- type: 'add' | 'remove' | 'removeAll';
34
- };
35
- open: {
36
- event: Event;
37
- };
38
- close: {
39
- event: Event;
40
- };
41
- };
42
- export type MultiSelectEvents = {
43
- [key in keyof DispatchEvents]: CustomEvent<DispatchEvents[key]>;
44
- } & {
45
- blur: FocusEvent;
46
- click: MouseEvent;
47
- focus: FocusEvent;
48
- keydown: KeyboardEvent;
49
- keyup: KeyboardEvent;
50
- mouseenter: MouseEvent;
51
- mouseleave: MouseEvent;
52
- touchcancel: TouchEvent;
53
- touchend: TouchEvent;
54
- touchmove: TouchEvent;
55
- touchstart: TouchEvent;
56
- };
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,25 @@
1
- import type { Option, OptionStyle } from './types';
2
- export declare const get_label: (opt: Option) => string | number;
1
+ import type { Option, OptionStyle } from '../types';
2
+ /**
3
+ * Get the label key from an option object or the option itself if it's a string or number
4
+ * @param opt Option
5
+ * @returns Label
6
+ */
7
+ export declare const get_label: (opt: Option) => any;
8
+ /**
9
+ * This function is used extract CSS strings from a {selected, option} style object to be used in the style attribute of the option.
10
+ * If the style is a string, it will be returned as is
11
+ * @param option Option
12
+ * @param key
13
+ * @returns CSS string
14
+ */
3
15
  export declare function get_style(option: {
4
16
  style?: OptionStyle;
5
17
  [key: string]: unknown;
6
- } | string | number, key?: 'selected' | 'option' | null): string;
18
+ } | string | number, key?: `selected` | `option` | null): any;
19
+ /**
20
+ * Highlights text nodes that matching the string query
21
+ * @param element Parent element
22
+ * @param query Search query
23
+ * @param noMatchingOptionsMsg Text for empty node
24
+ */
25
+ export declare function highlight_matching_nodes(element: HTMLElement, query?: string, noMatchingOptionsMsg?: string): void;