@kws3/ui 1.6.0 → 1.6.4
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.
|
@@ -28,6 +28,10 @@ Instead of listing all the selected items inside the input., Default: `false`
|
|
|
28
28
|
@param {string} [no_options_msg="No matching options"] - Message to display when no matching options are found, Default: `"No matching options"`
|
|
29
29
|
@param {string} [remove_btn_tip="Remove"] - Tooltip text for Remove Item button. This `string` will precede the selected Item Name in the tooltip., Default: `"Remove"`
|
|
30
30
|
@param {string} [remove_all_tip="Remove all"] - Tooltip text for the Clear All button, Default: `"Remove all"`
|
|
31
|
+
@param {HTMLElement|string} [dropdown_portal=undefined] - Where to render the dropdown list.
|
|
32
|
+
Can be a DOM element or a `string` with the CSS selector of the element.
|
|
33
|
+
|
|
34
|
+
By default it renders in a custom container appended to `document.body`., Default: `undefined`
|
|
31
35
|
@param {string} [class=""] - CSS classes for input container, Default: `""`
|
|
32
36
|
|
|
33
37
|
### Events
|
|
@@ -105,38 +109,41 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
105
109
|
on:click|stopPropagation={removeAll}
|
|
106
110
|
style={shouldShowClearAll ? "" : "display: none;"} />
|
|
107
111
|
{/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
|
-
|
|
112
|
+
{#if rootContainer}
|
|
113
|
+
<div class="kws-searchableselect" use:portal={dropdown_portal}>
|
|
114
|
+
<ul
|
|
115
|
+
bind:this={dropdown}
|
|
116
|
+
class="options {single ? 'is-single' : 'is-multi'}"
|
|
117
|
+
class:hidden={!showOptions}>
|
|
118
|
+
{#each filteredOptions as option}
|
|
119
|
+
<li
|
|
120
|
+
on:mousedown|preventDefault|stopPropagation={() =>
|
|
121
|
+
handleOptionMouseDown(option)}
|
|
122
|
+
on:mouseenter|preventDefault|stopPropagation={() => {
|
|
123
|
+
activeOption = option;
|
|
124
|
+
}}
|
|
125
|
+
class:selected={isSelected(option)}
|
|
126
|
+
class:active={activeOption === option}>
|
|
127
|
+
<span class="kws-selected-icon"
|
|
128
|
+
><Icon icon={selected_icon} size="small" /></span
|
|
129
|
+
><!--
|
|
130
|
+
Slot containing text for each selectable item
|
|
131
|
+
|
|
132
|
+
Default value: `<span>{option[search_key] || option}</span>`
|
|
133
|
+
--><slot
|
|
134
|
+
search_key={used_search_key}
|
|
135
|
+
{option}>{option[used_search_key] || option}</slot>
|
|
136
|
+
</li>
|
|
137
|
+
{:else}
|
|
138
|
+
<li class="no-options">{no_options_msg}</li>
|
|
139
|
+
{/each}
|
|
140
|
+
</ul>
|
|
141
|
+
</div>
|
|
142
|
+
{/if}
|
|
136
143
|
</div>
|
|
137
144
|
|
|
138
145
|
<script>
|
|
139
|
-
import { Icon } from "@kws3/ui";
|
|
146
|
+
import { Icon, portal } from "@kws3/ui";
|
|
140
147
|
import { createEventDispatcher, onMount } from "svelte";
|
|
141
148
|
import { createPopper } from "@popperjs/core";
|
|
142
149
|
|
|
@@ -156,6 +163,8 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
156
163
|
},
|
|
157
164
|
};
|
|
158
165
|
|
|
166
|
+
const rootContainerId = "kws-overlay-root";
|
|
167
|
+
|
|
159
168
|
/**
|
|
160
169
|
* Value of the Input
|
|
161
170
|
*
|
|
@@ -233,6 +242,15 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
233
242
|
* Tooltip text for the Clear All button
|
|
234
243
|
*/
|
|
235
244
|
export let remove_all_tip = "Remove all";
|
|
245
|
+
/**
|
|
246
|
+
* Where to render the dropdown list.
|
|
247
|
+
* Can be a DOM element or a `string` with the CSS selector of the element.
|
|
248
|
+
*
|
|
249
|
+
* By default it renders in a custom container appended to `document.body`.
|
|
250
|
+
*
|
|
251
|
+
* @type { HTMLElement|string}
|
|
252
|
+
*/
|
|
253
|
+
export let dropdown_portal = "#" + rootContainerId;
|
|
236
254
|
|
|
237
255
|
/**
|
|
238
256
|
* CSS classes for input container
|
|
@@ -247,7 +265,7 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
247
265
|
}
|
|
248
266
|
|
|
249
267
|
//ensure we have a root container for all our hoisitng related stuff
|
|
250
|
-
|
|
268
|
+
|
|
251
269
|
let rootContainer = document.getElementById(rootContainerId);
|
|
252
270
|
if (!rootContainer) {
|
|
253
271
|
rootContainer = document.createElement("div");
|
|
@@ -255,9 +273,6 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
255
273
|
document.body.appendChild(rootContainer);
|
|
256
274
|
}
|
|
257
275
|
|
|
258
|
-
//this is the container that will hold the dropdown
|
|
259
|
-
let container;
|
|
260
|
-
|
|
261
276
|
const fire = createEventDispatcher();
|
|
262
277
|
|
|
263
278
|
let el, //whole wrapping element
|
|
@@ -386,22 +401,7 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
386
401
|
POPPER && POPPER.update();
|
|
387
402
|
}
|
|
388
403
|
|
|
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
404
|
onMount(() => {
|
|
403
|
-
hoistDropdown();
|
|
404
|
-
|
|
405
405
|
POPPER = createPopper(el, dropdown, {
|
|
406
406
|
strategy: "fixed",
|
|
407
407
|
placement: "bottom-start",
|
|
@@ -416,10 +416,6 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
416
416
|
|
|
417
417
|
return () => {
|
|
418
418
|
POPPER.destroy();
|
|
419
|
-
//remove hoisted items
|
|
420
|
-
container &&
|
|
421
|
-
container.parentNode &&
|
|
422
|
-
container.parentNode.removeChild(container);
|
|
423
419
|
};
|
|
424
420
|
});
|
|
425
421
|
|
|
@@ -513,6 +509,7 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
513
509
|
}
|
|
514
510
|
|
|
515
511
|
if (event.key === `Enter`) {
|
|
512
|
+
event.preventDefault();
|
|
516
513
|
if (activeOption) {
|
|
517
514
|
handleOptionMouseDown(activeOption);
|
|
518
515
|
if (!single) {
|
|
@@ -20,6 +20,10 @@ this property of each object will be returned as the value, Default: `"id"`
|
|
|
20
20
|
@param {string} [selected_icon="check"] - Icon used to mark selected items in dropdown list, Default: `"check"`
|
|
21
21
|
@param {string} [no_options_msg="No matching options"] - Message to display when no matching options are found, Default: `"No matching options"`
|
|
22
22
|
@param {string} [remove_all_tip="Clear Selection"] - Tooltip text for the Clear selection button, Default: `"Clear Selection"`
|
|
23
|
+
@param {HTMLElement|string} [dropdown_portal=undefined] - Where to render the dropdown list.
|
|
24
|
+
Can be a DOM element or a `string` with the CSS selector of the element.
|
|
25
|
+
|
|
26
|
+
By default it renders in a custom container appended to `document.body`., Default: `undefined`
|
|
23
27
|
@param {string} [class=""] - CSS classes for input container, Default: `""`
|
|
24
28
|
|
|
25
29
|
### Events
|
|
@@ -48,6 +52,7 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
48
52
|
{selected_icon}
|
|
49
53
|
{remove_all_tip}
|
|
50
54
|
{no_options_msg}
|
|
55
|
+
{dropdown_portal}
|
|
51
56
|
on:change={change}
|
|
52
57
|
on:blur={blur}
|
|
53
58
|
let:option
|
|
@@ -67,6 +72,8 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
67
72
|
|
|
68
73
|
const fire = createEventDispatcher();
|
|
69
74
|
|
|
75
|
+
const rootContainerId = "kws-overlay-root";
|
|
76
|
+
|
|
70
77
|
/**
|
|
71
78
|
* Value of the Input
|
|
72
79
|
*
|
|
@@ -127,6 +134,15 @@ Default value: `<span>{option[search_key] || option}</span>`
|
|
|
127
134
|
* Tooltip text for the Clear selection button
|
|
128
135
|
*/
|
|
129
136
|
export let remove_all_tip = "Clear Selection";
|
|
137
|
+
/**
|
|
138
|
+
* Where to render the dropdown list.
|
|
139
|
+
* Can be a DOM element or a `string` with the CSS selector of the element.
|
|
140
|
+
*
|
|
141
|
+
* By default it renders in a custom container appended to `document.body`.
|
|
142
|
+
*
|
|
143
|
+
* @type { HTMLElement|string}
|
|
144
|
+
*/
|
|
145
|
+
export let dropdown_portal = "#" + rootContainerId;
|
|
130
146
|
|
|
131
147
|
/**
|
|
132
148
|
* CSS classes for input container
|
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.4",
|
|
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": "ffa4c66eba9bcb4efe022f39ac288c3bee9295da"
|
|
32
33
|
}
|