@hashrytech/quick-components-kit 0.16.3 → 0.16.5
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
|
@@ -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,15 @@ The `<Overlay>` component is used to darken the background and optionally block
|
|
|
103
103
|
</script>
|
|
104
104
|
|
|
105
105
|
{#if open}
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
<div role="dialog" aria-modal="true" aria-label={ariaLabel} tabindex="{open ? 0 : -1}" aria-hidden="{!open}"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
<div class="">
|
|
107
|
+
<Overlay {transitionDuration} {disableBodyScroll} class={overlayClasses} onclick={() => open = false} />
|
|
108
|
+
<div role="dialog" aria-modal="true" aria-label={ariaLabel} tabindex="{open ? 0 : -1}" aria-hidden="{!open}"
|
|
109
|
+
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)}
|
|
110
|
+
in:fly={transitionProperties}
|
|
111
|
+
out:fly={transitionProperties}
|
|
112
|
+
use:onKeydown={{key: "Escape", callback: handleKeydown}}>
|
|
113
|
+
{@render children?.()}
|
|
114
|
+
</div>
|
|
114
115
|
</div>
|
|
115
116
|
{/if}
|
|
116
117
|
|