@kws3/ui 1.6.0 → 1.6.1
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/forms/select/MultiSelect.svelte +33 -52
- package/index.js +2 -0
- package/package.json +3 -2
|
@@ -105,38 +105,41 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
105
105
|
on:click|stopPropagation={removeAll}
|
|
106
106
|
style={shouldShowClearAll ? "" : "display: none;"} />
|
|
107
107
|
{/if}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
108
|
+
{#if rootContainer}
|
|
109
|
+
<div class="kws-searchableselect" use:portal={"#" + rootContainerId}>
|
|
110
|
+
<ul
|
|
111
|
+
bind:this={dropdown}
|
|
112
|
+
class="options {single ? 'is-single' : 'is-multi'}"
|
|
113
|
+
class:hidden={!showOptions}>
|
|
114
|
+
{#each filteredOptions as option}
|
|
115
|
+
<li
|
|
116
|
+
on:mousedown|preventDefault|stopPropagation={() =>
|
|
117
|
+
handleOptionMouseDown(option)}
|
|
118
|
+
on:mouseenter|preventDefault|stopPropagation={() => {
|
|
119
|
+
activeOption = option;
|
|
120
|
+
}}
|
|
121
|
+
class:selected={isSelected(option)}
|
|
122
|
+
class:active={activeOption === option}>
|
|
123
|
+
<span class="kws-selected-icon"
|
|
124
|
+
><Icon icon={selected_icon} size="small" /></span
|
|
125
|
+
><!--
|
|
126
|
+
Slot containing text for each selectable item
|
|
127
|
+
|
|
128
|
+
Default value: `<span>{option[search_key] || option}</span>`
|
|
129
|
+
--><slot
|
|
130
|
+
search_key={used_search_key}
|
|
131
|
+
{option}>{option[used_search_key] || option}</slot>
|
|
132
|
+
</li>
|
|
133
|
+
{:else}
|
|
134
|
+
<li class="no-options">{no_options_msg}</li>
|
|
135
|
+
{/each}
|
|
136
|
+
</ul>
|
|
137
|
+
</div>
|
|
138
|
+
{/if}
|
|
136
139
|
</div>
|
|
137
140
|
|
|
138
141
|
<script>
|
|
139
|
-
import { Icon } from "@kws3/ui";
|
|
142
|
+
import { Icon, portal } from "@kws3/ui";
|
|
140
143
|
import { createEventDispatcher, onMount } from "svelte";
|
|
141
144
|
import { createPopper } from "@popperjs/core";
|
|
142
145
|
|
|
@@ -247,7 +250,7 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
//ensure we have a root container for all our hoisitng related stuff
|
|
250
|
-
|
|
253
|
+
const rootContainerId = "kws-overlay-root";
|
|
251
254
|
let rootContainer = document.getElementById(rootContainerId);
|
|
252
255
|
if (!rootContainer) {
|
|
253
256
|
rootContainer = document.createElement("div");
|
|
@@ -255,9 +258,6 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
255
258
|
document.body.appendChild(rootContainer);
|
|
256
259
|
}
|
|
257
260
|
|
|
258
|
-
//this is the container that will hold the dropdown
|
|
259
|
-
let container;
|
|
260
|
-
|
|
261
261
|
const fire = createEventDispatcher();
|
|
262
262
|
|
|
263
263
|
let el, //whole wrapping element
|
|
@@ -386,22 +386,7 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
386
386
|
POPPER && POPPER.update();
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
-
/**
|
|
390
|
-
* Moves dropdown to rootContainer, so that
|
|
391
|
-
* overflows etc do not mess with it
|
|
392
|
-
*/
|
|
393
|
-
function hoistDropdown() {
|
|
394
|
-
if (!container) {
|
|
395
|
-
container = document.createElement("div");
|
|
396
|
-
container.className = "kws-searchableselect";
|
|
397
|
-
rootContainer.appendChild(container);
|
|
398
|
-
container.appendChild(dropdown);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
389
|
onMount(() => {
|
|
403
|
-
hoistDropdown();
|
|
404
|
-
|
|
405
390
|
POPPER = createPopper(el, dropdown, {
|
|
406
391
|
strategy: "fixed",
|
|
407
392
|
placement: "bottom-start",
|
|
@@ -416,10 +401,6 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
416
401
|
|
|
417
402
|
return () => {
|
|
418
403
|
POPPER.destroy();
|
|
419
|
-
//remove hoisted items
|
|
420
|
-
container &&
|
|
421
|
-
container.parentNode &&
|
|
422
|
-
container.parentNode.removeChild(container);
|
|
423
404
|
};
|
|
424
405
|
});
|
|
425
406
|
|
package/index.js
CHANGED
|
@@ -21,6 +21,8 @@ export {
|
|
|
21
21
|
} from "./helpers/FloatingUI";
|
|
22
22
|
export { default as FloatingUIOutput } from "./helpers/FloatingUI/FloatingUIOutput.svelte";
|
|
23
23
|
export { default as Floatie } from "./helpers/FloatingUI/Floatie.svelte";
|
|
24
|
+
export { portal } from "svelte-portal";
|
|
25
|
+
export { default as Portal } from "svelte-portal";
|
|
24
26
|
|
|
25
27
|
export { default as ConfirmButton } from "./buttons/ConfirmButton.svelte";
|
|
26
28
|
export { default as DeleteButton } from "./buttons/DeleteButton.svelte";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kws3/ui",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "UI components for use with Svelte v3 applications.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"apexcharts": "^3.32.0",
|
|
27
27
|
"flatpickr": "^4.5.2",
|
|
28
|
+
"svelte-portal": "^2.1.2",
|
|
28
29
|
"text-mask-core": "^5.1.2",
|
|
29
30
|
"tippy.js": "^6.3.1"
|
|
30
31
|
},
|
|
31
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "ea18e1e71037d787675491be9c0260b901bf9e7a"
|
|
32
33
|
}
|