@faceless-ui/jumplist
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -1,4 +0,3 @@ | ||
export { JumplistButton } from './JumplistButton'; | ||
export { JumplistContext, useJumplist } from './JumplistContext'; | ||
export { JumplistNode } from './JumplistNode'; | ||
export { JumplistProvider } from './JumplistProvider'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.JumplistProvider = exports.JumplistNode = exports.useJumplist = exports.JumplistContext = exports.JumplistButton = void 0; | ||
var JumplistButton_1 = require("./JumplistButton"); | ||
Object.defineProperty(exports, "JumplistButton", { enumerable: true, get: function () { return JumplistButton_1.JumplistButton; } }); | ||
exports.JumplistProvider = exports.JumplistNode = exports.useJumplist = exports.JumplistContext = void 0; | ||
var JumplistContext_1 = require("./JumplistContext"); | ||
@@ -7,0 +5,0 @@ Object.defineProperty(exports, "JumplistContext", { enumerable: true, get: function () { return JumplistContext_1.JumplistContext; } }); |
/// <reference types="react" /> | ||
import { IJumplistContext } from './types'; | ||
export declare type JumplistNode = { | ||
nodeID: string; | ||
label?: string; | ||
isIntersecting?: boolean; | ||
}; | ||
export declare type JumplistNodes = JumplistNode[]; | ||
export interface IJumplistContext { | ||
jumplist: JumplistNodes; | ||
classPrefix?: string; | ||
setJumplist: (nodes: JumplistNodes) => void; | ||
syncJumplistItem: (node: JumplistNode) => void; | ||
removeJumplistItem: (id: string) => void; | ||
activeJumplistIndex?: number; | ||
setActiveJumplistIndex: (index: number) => void; | ||
currentJumplistIndex?: number; | ||
clearJumplist: () => void; | ||
rootMargin?: string; | ||
threshold?: number; | ||
} | ||
export declare const JumplistContext: import("react").Context<IJumplistContext>; | ||
export declare const useJumplist: () => IJumplistContext; |
@@ -56,3 +56,3 @@ "use strict"; | ||
syncJumplistItem({ | ||
id: nodeID, | ||
nodeID: nodeID, | ||
isIntersecting: isIntersecting | ||
@@ -59,0 +59,0 @@ }); |
import React from 'react'; | ||
declare type Options = { | ||
root?: React.MutableRefObject<HTMLElement>; | ||
root?: React.MutableRefObject<HTMLElement | null>; | ||
rootMargin?: string; | ||
threshold?: number; | ||
}; | ||
declare const useIntersection: (ref: React.MutableRefObject<HTMLElement>, options?: Options) => IntersectionObserverEntry; | ||
declare const useIntersection: (ref: React.MutableRefObject<HTMLElement | null>, options?: Options | undefined) => IntersectionObserverEntry; | ||
export default useIntersection; |
@@ -23,3 +23,3 @@ "use strict"; | ||
return function () { | ||
if (observer) { | ||
if (observer && currentRef) { | ||
observer.unobserve(currentRef); | ||
@@ -26,0 +26,0 @@ } |
import React from 'react'; | ||
import { JumplistNodes } from '../JumplistContext/types'; | ||
import { IJumplistContext, JumplistNodes } from '../JumplistContext'; | ||
export declare type ChildFunction = (context: IJumplistContext) => React.ReactNode; | ||
export declare const JumplistProvider: React.FC<{ | ||
children: React.ReactNode; | ||
classPrefix?: string; | ||
@@ -9,2 +9,3 @@ nodes?: JumplistNodes; | ||
threshold?: number; | ||
children: React.ReactNode | ChildFunction; | ||
}>; |
@@ -53,3 +53,3 @@ "use strict"; | ||
(0, react_1.useEffect)(function () { | ||
if (currentJumplistIndex > -1) { | ||
if (currentJumplistIndex !== undefined && currentJumplistIndex > -1) { | ||
setActiveJumplistIndex(currentJumplistIndex); | ||
@@ -68,3 +68,3 @@ } | ||
payload: { | ||
id: incomingID | ||
nodeID: incomingID | ||
} | ||
@@ -71,0 +71,0 @@ }); |
@@ -1,5 +0,15 @@ | ||
import { JumplistNode, JumplistNodes } from "../JumplistContext/types"; | ||
export declare const jumplistReducer: (state: JumplistNodes, action: { | ||
type: 'sync' | 'remove' | 'reset' | 'clear'; | ||
payload?: Partial<JumplistNode>; | ||
}) => JumplistNodes; | ||
import { JumplistNode, JumplistNodes } from "../JumplistContext"; | ||
declare type Action = { | ||
type: 'sync'; | ||
payload: JumplistNode; | ||
} | { | ||
type: 'remove'; | ||
payload: JumplistNode; | ||
} | { | ||
type: 'reset'; | ||
payload: JumplistNodes; | ||
} | { | ||
type: 'clear'; | ||
}; | ||
export declare const jumplistReducer: (state: JumplistNodes, action: Action) => JumplistNodes; | ||
export {}; |
@@ -36,4 +36,4 @@ "use strict"; | ||
case 'sync': { | ||
var incomingID_1 = action.payload.id; | ||
var indexOfItem = newState.findIndex(function (item) { return item.id === incomingID_1; }); | ||
var incomingID_1 = action.payload.nodeID; | ||
var indexOfItem = newState.findIndex(function (item) { return item.nodeID === incomingID_1; }); | ||
var itemExists = indexOfItem > -1; | ||
@@ -47,4 +47,4 @@ if (itemExists) { | ||
case 'remove': { | ||
var incomingID_2 = action.payload.id; | ||
var indexOfItem = newState.findIndex(function (item) { return item.id === incomingID_2; }); | ||
var incomingID_2 = action.payload.nodeID; | ||
var indexOfItem = newState.findIndex(function (item) { return item.nodeID === incomingID_2; }); | ||
var foundItem = indexOfItem > -1; | ||
@@ -51,0 +51,0 @@ if (foundItem) { |
{ | ||
"name": "@faceless-ui/jumplist", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"main": "dist/index.js", | ||
@@ -27,12 +27,10 @@ "types": "dist/index.d.ts", | ||
"peerDependencies": { | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0" | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0" | ||
}, | ||
"dependencies": { | ||
"animated-scroll-to": "^2.0.4" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.20", | ||
"@types/node": "^14.14.22", | ||
"@types/react": "^17.0.0", | ||
"@types/react": "^18.0.0", | ||
"@types/react-dom": "^18.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.18.0", | ||
@@ -53,4 +51,4 @@ "@typescript-eslint/parser": "^5.18.0", | ||
"jest": "^25.1.0", | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0", | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0", | ||
"react-hot-loader": "^4.12.19", | ||
@@ -57,0 +55,0 @@ "ts-loader": "^8.0.14", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
754985
2
1269
0
27
+ Addedreact@18.3.1(transitive)
+ Addedreact-dom@18.3.1(transitive)
+ Addedscheduler@0.23.2(transitive)
- Removedanimated-scroll-to@^2.0.4
- Removedanimated-scroll-to@2.3.2(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedreact@17.0.2(transitive)
- Removedreact-dom@17.0.2(transitive)
- Removedscheduler@0.20.2(transitive)