@hashrytech/quick-components-kit 0.10.0 → 0.11.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @hashrytech/quick-components-kit
2
2
 
3
+ ## 0.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: Adding missing imports for lock scroll and scroll to
8
+
9
+ ## 0.11.0
10
+
11
+ ### Minor Changes
12
+
13
+ - feat: Adding scroll to action
14
+
3
15
  ## 0.10.0
4
16
 
5
17
  ### Minor Changes
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Svelte action to scroll smoothly to the top, a specific Y position, or a DOM element on click.
3
+ *
4
+ * @param node - The element the action is applied to
5
+ * @param target - Can be:
6
+ * - `undefined` → scroll to top
7
+ * - `number` → scroll to Y position
8
+ * - `string` → interpreted as element ID to scroll to
9
+ * - `HTMLElement` → scroll directly to that element
10
+ */
11
+ export declare function scrollTo(node: HTMLElement, target?: number | string | HTMLElement): {
12
+ update(newTarget?: number | string | HTMLElement): void;
13
+ destroy(): void;
14
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Svelte action to scroll smoothly to the top, a specific Y position, or a DOM element on click.
3
+ *
4
+ * @param node - The element the action is applied to
5
+ * @param target - Can be:
6
+ * - `undefined` → scroll to top
7
+ * - `number` → scroll to Y position
8
+ * - `string` → interpreted as element ID to scroll to
9
+ * - `HTMLElement` → scroll directly to that element
10
+ */
11
+ export function scrollTo(node, target) {
12
+ function handleClick(e) {
13
+ e.preventDefault();
14
+ if (typeof target === 'number') {
15
+ window.scrollTo({ top: target, behavior: 'smooth' });
16
+ }
17
+ else if (typeof target === 'string') {
18
+ const el = document.getElementById(target);
19
+ if (el)
20
+ el.scrollIntoView({ behavior: 'smooth' });
21
+ }
22
+ else if (target instanceof HTMLElement) {
23
+ target.scrollIntoView({ behavior: 'smooth' });
24
+ }
25
+ else {
26
+ // Default: scroll to top
27
+ window.scrollTo({ top: 0, behavior: 'smooth' });
28
+ }
29
+ }
30
+ node.addEventListener('click', handleClick);
31
+ return {
32
+ update(newTarget) {
33
+ target = newTarget;
34
+ },
35
+ destroy() {
36
+ node.removeEventListener('click', handleClick);
37
+ }
38
+ };
39
+ }
package/dist/index.d.ts CHANGED
@@ -7,3 +7,5 @@ export * from './modal/index.js';
7
7
  export * from './overlay/index.js';
8
8
  export * from './actions/disable-scroll.js';
9
9
  export * from './actions/on-keydown.js';
10
+ export * from './actions/lock-scroll.js';
11
+ export * from './actions/scroll-to.js';
package/dist/index.js CHANGED
@@ -9,4 +9,6 @@ export * from './modal/index.js';
9
9
  export * from './overlay/index.js';
10
10
  export * from './actions/disable-scroll.js';
11
11
  export * from './actions/on-keydown.js';
12
+ export * from './actions/lock-scroll.js';
13
+ export * from './actions/scroll-to.js';
12
14
  // Add more components here...
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.10.0",
8
+ "version": "0.11.1",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [