@faceless-ui/jumplist
Advanced tools
Comparing version 1.0.10 to 2.0.0-alpha.1
@@ -5,1 +5,2 @@ export { JumplistContext, useJumplist } from './JumplistProvider/context'; | ||
export { JumplistButton } from './JumplistButton'; | ||
export { DotNav } from './DotNav'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.JumplistButton = exports.JumplistProvider = exports.JumplistNode = exports.useJumplist = exports.JumplistContext = void 0; | ||
exports.DotNav = exports.JumplistButton = exports.JumplistProvider = exports.JumplistNode = exports.useJumplist = exports.JumplistContext = void 0; | ||
var context_1 = require("./JumplistProvider/context"); | ||
@@ -13,2 +13,4 @@ Object.defineProperty(exports, "JumplistContext", { enumerable: true, get: function () { return context_1.JumplistContext; } }); | ||
Object.defineProperty(exports, "JumplistButton", { enumerable: true, get: function () { return JumplistButton_1.JumplistButton; } }); | ||
var DotNav_1 = require("./DotNav"); | ||
Object.defineProperty(exports, "DotNav", { enumerable: true, get: function () { return DotNav_1.DotNav; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,4 @@ import React, { HTMLProps } from 'react'; | ||
direction?: 'prev' | 'next'; | ||
nodeID?: string; | ||
} | ||
export declare const JumplistButton: React.FC<JumplistButtonProps>; |
@@ -52,3 +52,3 @@ "use strict"; | ||
var JumplistButton = function (props) { | ||
var _a = props.htmlElement, Tag = _a === void 0 ? 'button' : _a, children = props.children, direction = props.direction, onClick = props.onClick, rest = __rest(props, ["htmlElement", "children", "direction", "onClick"]); | ||
var _a = props.htmlElement, Tag = _a === void 0 ? 'button' : _a, children = props.children, direction = props.direction, nodeID = props.nodeID, onClick = props.onClick, rest = __rest(props, ["htmlElement", "children", "direction", "nodeID", "onClick"]); | ||
var _b = (0, context_1.useJumplist)(), scrollToID = _b.scrollToID, jumplist = _b.jumplist, activeJumplistIndex = _b.activeJumplistIndex; | ||
@@ -69,2 +69,5 @@ var handleClick = (0, react_1.useCallback)(function (e) { | ||
} | ||
if (!direction && nodeID !== undefined) { | ||
scrollToID(nodeID); | ||
} | ||
} | ||
@@ -79,7 +82,12 @@ if (typeof onClick === 'function') { | ||
jumplist, | ||
activeJumplistIndex | ||
activeJumplistIndex, | ||
nodeID | ||
]); | ||
return (react_1.default.createElement(Tag, __assign({ type: "button" }, rest, { onClick: handleClick }), children && children)); | ||
var ariaLabel = direction === 'prev' ? 'Scroll to previous item' : 'Scroll to next item'; | ||
if (!direction && nodeID !== undefined) { | ||
ariaLabel = "Scroll to ".concat(nodeID); | ||
} | ||
return (react_1.default.createElement(Tag, __assign({ id: nodeID ? "jumplist-button_".concat(nodeID) : undefined, type: "button", "aria-label": ariaLabel }, rest, { onClick: handleClick }), children && children)); | ||
}; | ||
exports.JumplistButton = JumplistButton; | ||
//# sourceMappingURL=index.js.map |
@@ -86,5 +86,5 @@ "use strict"; | ||
]); | ||
return (react_1.default.createElement(Tag, __assign({}, rest, { ref: nodeRef }), children && children)); | ||
return (react_1.default.createElement(Tag, __assign({ role: "region", "aria-labelledby": "jumplist-button_".concat(nodeID) }, rest, { ref: nodeRef }), children && children)); | ||
}; | ||
exports.JumplistNode = JumplistNode; | ||
//# sourceMappingURL=index.js.map |
/// <reference types="react" /> | ||
export declare type JumplistNode = { | ||
nodeID: string; | ||
label?: string; | ||
isIntersecting?: boolean; | ||
@@ -11,3 +10,2 @@ }; | ||
classPrefix?: string; | ||
setJumplist: (nodes: JumplistNodes) => void; | ||
syncJumplistItem: (node: JumplistNode) => void; | ||
@@ -14,0 +12,0 @@ removeJumplistItem: (id: string) => void; |
@@ -45,3 +45,3 @@ "use strict"; | ||
var JumplistProvider = function (props) { | ||
var children = props.children, classPrefix = props.classPrefix, nodesFromProps = props.nodes, rootMargin = props.rootMargin, threshold = props.threshold, smoothScroll = props.smoothScroll; | ||
var children = props.children, classPrefix = props.classPrefix, rootMargin = props.rootMargin, threshold = props.threshold, smoothScroll = props.smoothScroll; | ||
var _a = (0, react_1.useReducer)(reducer_1.jumplistReducer, []), nodes = _a[0], dispatchNodes = _a[1]; | ||
@@ -76,9 +76,2 @@ var _b = (0, react_1.useState)(), currentJumplistIndex = _b[0], setCurrentJumplistIndex = _b[1]; // could be -1 if no nodes are intersecting | ||
}, []); | ||
var setJumplist = (0, react_1.useCallback)(function (incomingJumplist) { | ||
dispatchNodes({ | ||
type: 'reset', | ||
// @ts-ignore TODO: type this better | ||
payload: incomingJumplist | ||
}); | ||
}, []); | ||
var clearJumplist = (0, react_1.useCallback)(function () { | ||
@@ -89,10 +82,2 @@ dispatchNodes({ | ||
}, []); | ||
(0, react_1.useEffect)(function () { | ||
if (nodesFromProps) { | ||
setJumplist(nodesFromProps); | ||
} | ||
}, [ | ||
nodesFromProps, | ||
setJumplist | ||
]); | ||
var clearScrollTarget = (0, react_1.useCallback)(function () { | ||
@@ -120,3 +105,2 @@ setScrollTarget(undefined); | ||
removeJumplistItem: removeJumplistItem, | ||
setJumplist: setJumplist, | ||
currentJumplistIndex: currentJumplistIndex, | ||
@@ -123,0 +107,0 @@ activeJumplistIndex: activeJumplistIndex, |
@@ -43,2 +43,5 @@ "use strict"; | ||
} | ||
else { | ||
newState.push(action.payload); | ||
} | ||
break; | ||
@@ -45,0 +48,0 @@ } |
@@ -5,1 +5,2 @@ export { JumplistButtonProps } from './JumplistButton'; | ||
export { JumplistProviderProps } from './JumplistProvider'; | ||
export { DotNavProps } from './DotNav'; |
{ | ||
"name": "@faceless-ui/jumplist", | ||
"version": "1.0.10", | ||
"version": "2.0.0-alpha.1", | ||
"main": "dist/index.js", | ||
@@ -10,5 +10,5 @@ "types": "dist/index.d.ts", | ||
"author": { | ||
"email": "jacobsfletch@gmail.com", | ||
"name": "Jacob Fletcher", | ||
"url": "https://jacobsfletch.com" | ||
"email": "dev@facelessui.com", | ||
"name": "Faceless UI", | ||
"url": "https://facelessui.com" | ||
}, | ||
@@ -25,3 +25,9 @@ "bugs": { | ||
], | ||
"contributors": [], | ||
"contributors": [ | ||
{ | ||
"email": "jacobsfletch@gmail.com", | ||
"name": "Jacob Fletcher", | ||
"url": "https://jacobsfletch.com" | ||
} | ||
], | ||
"license": "MIT", | ||
@@ -28,0 +34,0 @@ "keywords": [ |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
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
37884
30
556
0
1