@jump-section/react 1.0.0

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.
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { ScrollManager } from '@jump-section/core';
3
+
4
+ interface ScrollSectionProviderProps {
5
+ children: React.ReactNode;
6
+ offset?: number;
7
+ behavior?: ScrollBehavior;
8
+ }
9
+ declare const ScrollSectionProvider: React.FC<ScrollSectionProviderProps>;
10
+ declare const useScrollManager: () => ScrollManager;
11
+
12
+ declare const useScrollSection: (sectionId?: string) => {
13
+ registerRef: (element: HTMLElement | null) => void;
14
+ scrollTo: (id: string) => void;
15
+ activeId: string | null;
16
+ isActive: boolean;
17
+ };
18
+
19
+ export { ScrollSectionProvider, useScrollManager, useScrollSection };
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { ScrollManager } from '@jump-section/core';
3
+
4
+ interface ScrollSectionProviderProps {
5
+ children: React.ReactNode;
6
+ offset?: number;
7
+ behavior?: ScrollBehavior;
8
+ }
9
+ declare const ScrollSectionProvider: React.FC<ScrollSectionProviderProps>;
10
+ declare const useScrollManager: () => ScrollManager;
11
+
12
+ declare const useScrollSection: (sectionId?: string) => {
13
+ registerRef: (element: HTMLElement | null) => void;
14
+ scrollTo: (id: string) => void;
15
+ activeId: string | null;
16
+ isActive: boolean;
17
+ };
18
+
19
+ export { ScrollSectionProvider, useScrollManager, useScrollSection };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ 'use strict';var react=require('react'),core=require('@jump-section/core'),jsxRuntime=require('react/jsx-runtime');var c=react.createContext(null),d=({children:r,offset:e,behavior:n})=>{let t=react.useRef(null);return t.current||(t.current=new core.ScrollManager({offset:e,behavior:n})),react.useEffect(()=>()=>{var l;(l=t.current)==null||l.destroy();},[]),jsxRuntime.jsx(c.Provider,{value:t.current,children:r})},i=()=>{let r=react.useContext(c);if(!r)throw new Error("useScrollManager must be used within a ScrollSectionProvider");return r};var E=r=>{let e=i(),[n,t]=react.useState(null);return react.useEffect(()=>{let o=e.onActiveChange(s=>{t(s);});return ()=>{o();}},[e]),{registerRef:o=>{r&&o?e.registerSection(r,o):r&&!o&&e.unregisterSection(r);},scrollTo:o=>e.scrollTo(o),activeId:n,isActive:r?n===r:false}};exports.ScrollSectionProvider=d;exports.useScrollManager=i;exports.useScrollSection=E;
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import {createContext,useRef,useEffect,useContext,useState}from'react';import {ScrollManager}from'@jump-section/core';import {jsx}from'react/jsx-runtime';var c=createContext(null),d=({children:r,offset:e,behavior:n})=>{let t=useRef(null);return t.current||(t.current=new ScrollManager({offset:e,behavior:n})),useEffect(()=>()=>{var l;(l=t.current)==null||l.destroy();},[]),jsx(c.Provider,{value:t.current,children:r})},i=()=>{let r=useContext(c);if(!r)throw new Error("useScrollManager must be used within a ScrollSectionProvider");return r};var E=r=>{let e=i(),[n,t]=useState(null);return useEffect(()=>{let o=e.onActiveChange(s=>{t(s);});return ()=>{o();}},[e]),{registerRef:o=>{r&&o?e.registerSection(r,o):r&&!o&&e.unregisterSection(r);},scrollTo:o=>e.scrollTo(o),activeId:n,isActive:r?n===r:false}};export{d as ScrollSectionProvider,i as useScrollManager,E as useScrollSection};
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@jump-section/react",
3
+ "version": "1.0.0",
4
+ "description": "React hooks for jump-section scroll management",
5
+ "keywords": [
6
+ "scroll",
7
+ "navigation",
8
+ "section",
9
+ "jump",
10
+ "react",
11
+ "hooks"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/bae080311/jump-section.git",
16
+ "directory": "packages/react"
17
+ },
18
+ "license": "ISC",
19
+ "author": "k_jin.0",
20
+ "main": "dist/index.js",
21
+ "module": "dist/index.mjs",
22
+ "types": "dist/index.d.ts",
23
+ "sideEffects": false,
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "dependencies": {
28
+ "@jump-section/core": "workspace:*"
29
+ },
30
+ "scripts": {
31
+ "build": "tsup",
32
+ "test": "vitest run --environment jsdom"
33
+ },
34
+ "peerDependencies": {
35
+ "react": ">=16.8.0",
36
+ "react-dom": ">=16.8.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ }
41
+ }