@hashrytech/quick-components-kit 0.16.2 → 0.16.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.
package/CHANGELOG.md
CHANGED
package/dist/actions/portal.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export type PortalOptions = {
|
|
|
2
2
|
target?: HTMLElement;
|
|
3
3
|
prepend?: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function portalAction(node: HTMLElement, { target, prepend }?: PortalOptions): {
|
|
6
6
|
destroy(): void;
|
|
7
7
|
};
|
package/dist/actions/portal.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* - `prepend`: Whether to insert at the beginning instead of appending (default: true)
|
|
25
25
|
*/
|
|
26
26
|
import { browser } from '$app/environment';
|
|
27
|
-
export function
|
|
27
|
+
export function portalAction(node, { target = browser ? document.body : undefined, prepend = true } = {}) {
|
|
28
28
|
if (prepend) {
|
|
29
29
|
target?.prepend(node);
|
|
30
30
|
}
|
|
@@ -14,15 +14,7 @@
|
|
|
14
14
|
* @example
|
|
15
15
|
* ```svelte
|
|
16
16
|
* <div use:stopInteraction />
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```svelte
|
|
21
17
|
* <div use:stopInteraction={{ prevent: true }} />
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```svelte
|
|
26
18
|
* <div use:stopInteraction={{ stop: true, prevent: true, events: ['click', 'touchstart'] }} />
|
|
27
19
|
* ```
|
|
28
20
|
*/
|
|
@@ -32,5 +24,6 @@ export type StopInteractionOptions = {
|
|
|
32
24
|
events?: string[];
|
|
33
25
|
};
|
|
34
26
|
export declare function stopInteraction(node: HTMLElement, options?: StopInteractionOptions): {
|
|
27
|
+
update(newOptions: StopInteractionOptions): void;
|
|
35
28
|
destroy(): void;
|
|
36
29
|
};
|
|
@@ -14,31 +14,33 @@
|
|
|
14
14
|
* @example
|
|
15
15
|
* ```svelte
|
|
16
16
|
* <div use:stopInteraction />
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```svelte
|
|
21
17
|
* <div use:stopInteraction={{ prevent: true }} />
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```svelte
|
|
26
18
|
* <div use:stopInteraction={{ stop: true, prevent: true, events: ['click', 'touchstart'] }} />
|
|
27
19
|
* ```
|
|
28
20
|
*/
|
|
29
|
-
export function stopInteraction(node, options = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
export function stopInteraction(node, options = {}) {
|
|
22
|
+
let cleanups = [];
|
|
23
|
+
function apply(options) {
|
|
24
|
+
// Remove old listeners
|
|
25
|
+
cleanups.forEach((fn) => fn());
|
|
26
|
+
// Normalize options
|
|
27
|
+
const { stop = true, prevent = false, events = ['clicka', 'mousedown', 'mouseup', 'touchstart'] } = typeof options === 'object' && options !== null ? options : {};
|
|
28
|
+
cleanups = events.map((event) => {
|
|
29
|
+
const handler = (e) => {
|
|
30
|
+
if (stop)
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
if (prevent)
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
};
|
|
35
|
+
node.addEventListener(event, handler, true); // capture phase
|
|
36
|
+
return () => node.removeEventListener(event, handler, true);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
apply(options);
|
|
41
40
|
return {
|
|
41
|
+
update(newOptions) {
|
|
42
|
+
apply(newOptions);
|
|
43
|
+
},
|
|
42
44
|
destroy() {
|
|
43
45
|
cleanups.forEach((fn) => fn());
|
|
44
46
|
}
|
|
@@ -103,14 +103,16 @@ The `<Overlay>` component is used to darken the background and optionally block
|
|
|
103
103
|
</script>
|
|
104
104
|
|
|
105
105
|
{#if open}
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
<div class="fixed inset-0 flex items-center justify-center" role="dialog" aria-modal="true" aria-label={ariaLabel} tabindex="{open ? 0 : -1}" aria-hidden="{!open}">
|
|
107
|
+
|
|
108
|
+
<Overlay {transitionDuration} {disableBodyScroll} class={overlayClasses} onclick={() => open = false} />
|
|
109
|
+
|
|
110
|
+
<div class={twMerge("fixed flex flex-col items-center gap-2 bg-white outline-0 focus:outline-0 active:outline-focus-primary focus:outline-focus-primary overflow-y-auto z-50", postionClasses[position], props.class)}
|
|
111
|
+
in:fly={transitionProperties}
|
|
112
|
+
out:fly={transitionProperties}
|
|
113
|
+
use:onKeydown={{key: "Escape", callback: handleKeydown}}>
|
|
114
|
+
{@render children?.()}
|
|
115
|
+
</div>
|
|
114
116
|
</div>
|
|
115
117
|
{/if}
|
|
116
118
|
|