@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
@@ -1,5 +1,17 @@
1
1
  # @hashrytech/quick-components-kit
2
2
 
3
+ ## 0.16.4
4
+
5
+ ### Patch Changes
6
+
7
+ - patch: update for drawer
8
+
9
+ ## 0.16.3
10
+
11
+ ### Patch Changes
12
+
13
+ - rename: portal action to portalAction
14
+
3
15
  ## 0.16.2
4
16
 
5
17
  ### Patch Changes
@@ -2,6 +2,6 @@ export type PortalOptions = {
2
2
  target?: HTMLElement;
3
3
  prepend?: boolean;
4
4
  };
5
- export declare function portal(node: HTMLElement, { target, prepend }?: PortalOptions): {
5
+ export declare function portalAction(node: HTMLElement, { target, prepend }?: PortalOptions): {
6
6
  destroy(): void;
7
7
  };
@@ -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 portal(node, { target = browser ? document.body : undefined, prepend = true } = {}) {
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 = { stop: true, prevent: false }) {
30
- const { stop = true, prevent = false, events = ['click'] } = options;
31
- const cleanups = events.map((event) => {
32
- const handler = (e) => {
33
- if (stop)
34
- e.stopPropagation();
35
- if (prevent)
36
- e.preventDefault();
37
- };
38
- node.addEventListener(event, handler, true); // capture
39
- return () => node.removeEventListener(event, handler, true);
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
- <Overlay {transitionDuration} {disableBodyScroll} class={overlayClasses} onclick={() => open = false} />
107
-
108
- <div role="dialog" aria-modal="true" aria-label={ariaLabel} tabindex="{open ? 0 : -1}" aria-hidden="{!open}" use:stopInteraction={{ stop: true, prevent: true, events: [''] }}
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?.()}
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
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hashrytech/quick-components-kit.git"
7
7
  },
8
- "version": "0.16.2",
8
+ "version": "0.16.4",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [