@faceless-ui/jumplist
Advanced tools
Comparing version 2.0.0-rc.0 to 2.0.0-rc.1
@@ -1,13 +0,1 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -24,16 +12,11 @@ var t = {}; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DotNav = void 0; | ||
var react_1 = __importDefault(require("react")); | ||
var context_1 = require("../JumplistProvider/context"); | ||
var DotNav = function (props) { | ||
var _a = props.htmlElement, Tag = _a === void 0 ? 'div' : _a, dotClassName = props.dotClassName, activeDotClassName = props.activeDotClassName, _b = props.buttonProps, buttonProps = _b === void 0 ? {} : _b, rest = __rest(props, ["htmlElement", "dotClassName", "activeDotClassName", "buttonProps"]); | ||
var _c = (0, context_1.useJumplist)(), scrollToID = _c.scrollToID, jumplist = _c.jumplist; | ||
var dotsArray = Array.from(Array(jumplist.length || 0).keys()); | ||
return (react_1.default.createElement(Tag, __assign({}, rest), dotsArray.map(function (dot, index) { | ||
var _a = jumplist[index], nodeID = _a.nodeID, isIntersecting = _a.isIntersecting; | ||
return (react_1.default.createElement("button", __assign({ "aria-label": "Scroll to node ".concat(nodeID), key: index }, buttonProps, { onClick: function (e) { | ||
import React from 'react'; | ||
import { useJumplist } from '../JumplistProvider/context.js'; | ||
export const DotNav = (props) => { | ||
const { htmlElement: Tag = 'div', dotClassName, activeDotClassName, buttonProps = {} } = props, rest = __rest(props, ["htmlElement", "dotClassName", "activeDotClassName", "buttonProps"]); | ||
const { scrollToID, jumplist } = useJumplist(); | ||
const dotsArray = Array.from(Array(jumplist.length || 0).keys()); | ||
return (React.createElement(Tag, Object.assign({}, rest), dotsArray.map((dot, index) => { | ||
const { nodeID, isIntersecting } = jumplist[index]; | ||
return (React.createElement("button", Object.assign({ "aria-label": `Scroll to node ${nodeID}`, key: index }, buttonProps, { onClick: (e) => { | ||
scrollToID(nodeID); | ||
@@ -50,3 +33,2 @@ if (typeof (buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.onClick) === 'function') { | ||
}; | ||
exports.DotNav = DotNav; | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,5 @@ | ||
export { JumplistContext, useJumplist } from './JumplistProvider/context'; | ||
export { JumplistNode } from './JumplistNode'; | ||
export { JumplistProvider } from './JumplistProvider'; | ||
export { JumplistButton } from './JumplistButton'; | ||
export { DotNav } from './DotNav'; | ||
export { JumplistContext, useJumplist } from './JumplistProvider/context.js'; | ||
export { JumplistNode } from './JumplistNode/index.js'; | ||
export { JumplistProvider } from './JumplistProvider/index.js'; | ||
export { JumplistButton } from './JumplistButton/index.js'; | ||
export { DotNav } from './DotNav/index.js'; |
@@ -1,15 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DotNav = exports.JumplistButton = exports.JumplistProvider = exports.JumplistNode = exports.useJumplist = exports.JumplistContext = void 0; | ||
var context_1 = require("./JumplistProvider/context"); | ||
Object.defineProperty(exports, "JumplistContext", { enumerable: true, get: function () { return context_1.JumplistContext; } }); | ||
Object.defineProperty(exports, "useJumplist", { enumerable: true, get: function () { return context_1.useJumplist; } }); | ||
var JumplistNode_1 = require("./JumplistNode"); | ||
Object.defineProperty(exports, "JumplistNode", { enumerable: true, get: function () { return JumplistNode_1.JumplistNode; } }); | ||
var JumplistProvider_1 = require("./JumplistProvider"); | ||
Object.defineProperty(exports, "JumplistProvider", { enumerable: true, get: function () { return JumplistProvider_1.JumplistProvider; } }); | ||
var JumplistButton_1 = require("./JumplistButton"); | ||
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; } }); | ||
export { JumplistContext, useJumplist } from './JumplistProvider/context.js'; | ||
export { JumplistNode } from './JumplistNode/index.js'; | ||
export { JumplistProvider } from './JumplistProvider/index.js'; | ||
export { JumplistButton } from './JumplistButton/index.js'; | ||
export { DotNav } from './DotNav/index.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,36 +0,1 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -47,11 +12,9 @@ var t = {}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.JumplistButton = void 0; | ||
var react_1 = __importStar(require("react")); | ||
var context_1 = require("../JumplistProvider/context"); | ||
var JumplistButton = function (props) { | ||
var _a = props.htmlElement, Tag = _a === void 0 ? 'button' : _a, children = props.children, nodeID = props.nodeID, onClick = props.onClick, activeClassName = props.activeClassName, className = props.className, rest = __rest(props, ["htmlElement", "children", "nodeID", "onClick", "activeClassName", "className"]); | ||
var _b = (0, context_1.useJumplist)(), scrollToID = _b.scrollToID, jumplist = _b.jumplist; | ||
var nodeState = jumplist === null || jumplist === void 0 ? void 0 : jumplist.find(function (item) { return item.nodeID === nodeID; }); | ||
var handleClick = (0, react_1.useCallback)(function (e) { | ||
import React, { useCallback } from 'react'; | ||
import { useJumplist } from '../JumplistProvider/context.js'; | ||
export const JumplistButton = (props) => { | ||
const { htmlElement: Tag = 'button', children, nodeID, onClick, activeClassName, className } = props, rest = __rest(props, ["htmlElement", "children", "nodeID", "onClick", "activeClassName", "className"]); | ||
const { scrollToID, jumplist, } = useJumplist(); | ||
const nodeState = jumplist === null || jumplist === void 0 ? void 0 : jumplist.find((item) => item.nodeID === nodeID); | ||
const handleClick = useCallback((e) => { | ||
if (nodeID) { | ||
@@ -68,3 +31,3 @@ scrollToID(nodeID); | ||
]); | ||
return (react_1.default.createElement(Tag, __assign({ id: nodeID ? "jumplist-button_".concat(nodeID) : undefined, type: "button", "aria-label": "Scroll to ".concat(nodeID), className: [ | ||
return (React.createElement(Tag, Object.assign({ id: nodeID ? `jumplist-button_${nodeID}` : undefined, type: "button", "aria-label": `Scroll to ${nodeID}`, className: [ | ||
className, | ||
@@ -74,3 +37,2 @@ (nodeState === null || nodeState === void 0 ? void 0 : nodeState.isIntersecting) && activeClassName | ||
}; | ||
exports.JumplistButton = JumplistButton; | ||
//# sourceMappingURL=index.js.map |
@@ -1,36 +0,1 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -47,22 +12,17 @@ var t = {}; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.JumplistNode = void 0; | ||
var react_1 = __importStar(require("react")); | ||
var context_1 = require("../JumplistProvider/context"); | ||
var useIntersection_1 = __importDefault(require("./useIntersection")); | ||
var JumplistNode = function (props) { | ||
var nodeID = props.nodeID, _a = props.htmlElement, Tag = _a === void 0 ? 'div' : _a, children = props.children, rest = __rest(props, ["nodeID", "htmlElement", "children"]); | ||
var _b = (0, context_1.useJumplist)(), syncJumplistItem = _b.syncJumplistItem, rootMargin = _b.rootMargin, threshold = _b.threshold, scrollTarget = _b.scrollTarget, clearScrollTarget = _b.clearScrollTarget; | ||
var nodeRef = (0, react_1.useRef)(null); | ||
var isIntersecting = (0, useIntersection_1.default)(nodeRef, { | ||
rootMargin: rootMargin, | ||
threshold: threshold | ||
}).isIntersecting; | ||
(0, react_1.useEffect)(function () { | ||
import React, { useEffect, useRef } from 'react'; | ||
import { useJumplist } from '../JumplistProvider/context.js'; | ||
import { useIntersection } from './useIntersection.js'; | ||
export const JumplistNode = (props) => { | ||
const { nodeID, htmlElement: Tag = 'div', children } = props, rest = __rest(props, ["nodeID", "htmlElement", "children"]); | ||
const { syncJumplistItem, rootMargin, threshold, scrollTarget, clearScrollTarget } = useJumplist(); | ||
const nodeRef = useRef(null); | ||
const { isIntersecting } = useIntersection(nodeRef, { | ||
rootMargin, | ||
threshold | ||
}); | ||
useEffect(() => { | ||
syncJumplistItem({ | ||
nodeID: nodeID, | ||
isIntersecting: isIntersecting | ||
nodeID, | ||
isIntersecting | ||
}); | ||
@@ -74,5 +34,5 @@ }, [ | ||
]); | ||
(0, react_1.useEffect)(function () { | ||
useEffect(() => { | ||
if (scrollTarget !== undefined && scrollTarget === nodeID) { | ||
var currentNode = nodeRef.current; | ||
const currentNode = nodeRef.current; | ||
if (currentNode) { | ||
@@ -88,5 +48,4 @@ currentNode.scrollIntoView(); | ||
]); | ||
return (react_1.default.createElement(Tag, __assign({ role: "region", "aria-labelledby": "jumplist-button_".concat(nodeID) }, rest, { ref: nodeRef }), children && children)); | ||
return (React.createElement(Tag, Object.assign({ role: "region", "aria-labelledby": `jumplist-button_${nodeID}` }, rest, { ref: nodeRef }), children && children)); | ||
}; | ||
exports.JumplistNode = JumplistNode; | ||
//# sourceMappingURL=index.js.map |
import React from 'react'; | ||
declare type Options = { | ||
type Options = { | ||
root?: React.MutableRefObject<HTMLElement | null>; | ||
@@ -7,3 +7,3 @@ rootMargin?: string; | ||
}; | ||
declare const useIntersection: (ref: React.MutableRefObject<HTMLElement | null>, options?: Options | undefined) => IntersectionObserverEntry; | ||
export default useIntersection; | ||
export declare const useIntersection: (ref: React.MutableRefObject<HTMLElement | null>, options?: Options) => IntersectionObserverEntry; | ||
export {}; |
@@ -1,13 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = require("react"); | ||
var useIntersection = function (ref, options) { | ||
var _a = options || {}, root = _a.root, rootMargin = _a.rootMargin, threshold = _a.threshold; | ||
var _b = (0, react_1.useState)({}), intersection = _b[0], setIntersection = _b[1]; | ||
(0, react_1.useEffect)(function () { | ||
var observer; | ||
var currentRef = ref.current; | ||
import { useEffect, useState } from 'react'; | ||
export const useIntersection = (ref, options) => { | ||
const { root, rootMargin, threshold, } = options || {}; | ||
const [intersection, setIntersection] = useState({}); | ||
useEffect(() => { | ||
let observer; | ||
const { current: currentRef, } = ref; | ||
if (currentRef) { | ||
observer = new IntersectionObserver(function (entries) { | ||
entries.forEach(function (entry) { | ||
observer = new IntersectionObserver((entries) => { | ||
entries.forEach((entry) => { | ||
setIntersection(entry); | ||
@@ -22,3 +20,3 @@ }); | ||
} | ||
return function () { | ||
return () => { | ||
if (observer && currentRef) { | ||
@@ -36,3 +34,2 @@ observer.unobserve(currentRef); | ||
}; | ||
exports.default = useIntersection; | ||
//# sourceMappingURL=useIntersection.js.map |
/// <reference types="react" /> | ||
export declare type JumplistNode = { | ||
export type JumplistNode = { | ||
nodeID: string; | ||
isIntersecting?: boolean; | ||
}; | ||
export declare type JumplistNodes = JumplistNode[]; | ||
export type JumplistNodes = JumplistNode[]; | ||
export interface IJumplistContext { | ||
@@ -23,2 +23,1 @@ jumplist: JumplistNodes; | ||
export declare const JumplistContext: import("react").Context<IJumplistContext>; | ||
export default JumplistContext; |
@@ -1,9 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.JumplistContext = exports.useJumplist = void 0; | ||
var react_1 = require("react"); | ||
var useJumplist = function () { return (0, react_1.useContext)(exports.JumplistContext); }; | ||
exports.useJumplist = useJumplist; | ||
exports.JumplistContext = (0, react_1.createContext)({}); | ||
exports.default = exports.JumplistContext; | ||
import { createContext, useContext } from 'react'; | ||
export const useJumplist = () => useContext(JumplistContext); | ||
export const JumplistContext = createContext({}); | ||
//# sourceMappingURL=context.js.map |
import React from 'react'; | ||
import { IJumplistContext, JumplistNodes } from './context'; | ||
export declare type ChildFunction = (context: IJumplistContext) => React.ReactNode; | ||
export declare type JumplistProviderProps = { | ||
import { type IJumplistContext, JumplistNodes } from './context.js'; | ||
export type ChildFunction = (context: IJumplistContext) => React.ReactNode; | ||
export type JumplistProviderProps = { | ||
classPrefix?: string; | ||
@@ -6,0 +6,0 @@ nodes?: JumplistNodes; |
@@ -1,53 +0,13 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.JumplistProvider = void 0; | ||
var react_1 = __importStar(require("react")); | ||
var context_1 = __importDefault(require("./context")); | ||
var reducer_1 = require("./reducer"); | ||
var JumplistProvider = function (props) { | ||
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]; | ||
var _b = (0, react_1.useState)(), scrollTarget = _b[0], setScrollTarget = _b[1]; // when defined, the matching jumplist node will scroll itself into view | ||
var currentJumplistIndex = nodes.findIndex(function (node) { return node.isIntersecting; }); // could be -1 if no nodes are intersecting | ||
var activeJumplistIndex = typeof currentJumplistIndex === 'number' && currentJumplistIndex > -1 | ||
import React, { useCallback, useEffect, useReducer, useState } from 'react'; | ||
import { JumplistContext } from './context.js'; | ||
import { jumplistReducer } from './reducer.js'; | ||
export const JumplistProvider = (props) => { | ||
const { children, classPrefix, rootMargin, threshold, smoothScroll } = props; | ||
const [nodes, dispatchNodes] = useReducer(jumplistReducer, []); | ||
const [scrollTarget, setScrollTarget] = useState(); // when defined, the matching jumplist node will scroll itself into view | ||
const currentJumplistIndex = nodes.findIndex((node) => node.isIntersecting); // could be -1 if no nodes are intersecting | ||
const activeJumplistIndex = typeof currentJumplistIndex === 'number' && currentJumplistIndex > -1 | ||
? currentJumplistIndex | ||
: undefined; | ||
var syncJumplistItem = (0, react_1.useCallback)(function (incomingNode) { | ||
const syncJumplistItem = useCallback((incomingNode) => { | ||
dispatchNodes({ | ||
@@ -58,3 +18,3 @@ type: 'sync', | ||
}, []); | ||
var removeJumplistItem = (0, react_1.useCallback)(function (incomingID) { | ||
const removeJumplistItem = useCallback((incomingID) => { | ||
dispatchNodes({ | ||
@@ -67,3 +27,3 @@ type: 'remove', | ||
}, []); | ||
var clearJumplist = (0, react_1.useCallback)(function () { | ||
const clearJumplist = useCallback(() => { | ||
dispatchNodes({ | ||
@@ -73,6 +33,6 @@ type: 'clear' | ||
}, []); | ||
var clearScrollTarget = (0, react_1.useCallback)(function () { | ||
const clearScrollTarget = useCallback(() => { | ||
setScrollTarget(undefined); | ||
}, []); | ||
(0, react_1.useEffect)(function () { | ||
useEffect(() => { | ||
if (smoothScroll) { | ||
@@ -84,26 +44,25 @@ document.documentElement.style.scrollBehavior = 'smooth'; | ||
} | ||
return function () { | ||
return () => { | ||
document.documentElement.style.removeProperty('scroll-behavior'); | ||
}; | ||
}, [smoothScroll]); | ||
var scrollToID = (0, react_1.useCallback)(function (incomingID) { | ||
const scrollToID = useCallback((incomingID) => { | ||
setScrollTarget(incomingID); | ||
}, []); | ||
var context = { | ||
classPrefix: classPrefix, | ||
const context = { | ||
classPrefix, | ||
jumplist: nodes, | ||
syncJumplistItem: syncJumplistItem, | ||
removeJumplistItem: removeJumplistItem, | ||
currentJumplistIndex: currentJumplistIndex, | ||
activeJumplistIndex: activeJumplistIndex, | ||
clearJumplist: clearJumplist, | ||
rootMargin: rootMargin, | ||
threshold: threshold, | ||
scrollTarget: scrollTarget, | ||
scrollToID: scrollToID, | ||
clearScrollTarget: clearScrollTarget | ||
syncJumplistItem, | ||
removeJumplistItem, | ||
currentJumplistIndex, | ||
activeJumplistIndex, | ||
clearJumplist, | ||
rootMargin, | ||
threshold, | ||
scrollTarget, | ||
scrollToID, | ||
clearScrollTarget | ||
}; | ||
return (react_1.default.createElement(context_1.default.Provider, { value: context }, (children && (typeof children === 'function' ? children(__assign({}, context)) : children)))); | ||
return (React.createElement(JumplistContext.Provider, { value: context }, (children && (typeof children === 'function' ? children(Object.assign({}, context)) : children)))); | ||
}; | ||
exports.JumplistProvider = JumplistProvider; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import { JumplistNode, JumplistNodes } from "./context"; | ||
declare type Action = { | ||
import { JumplistNode, JumplistNodes } from "./context.js"; | ||
type Action = { | ||
type: 'sync'; | ||
@@ -4,0 +4,0 @@ payload: JumplistNode; |
@@ -1,26 +0,3 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.jumplistReducer = void 0; | ||
var jumplistReducer = function (state, action) { | ||
var newState = __spreadArray([], state || [], true); | ||
export const jumplistReducer = (state, action) => { | ||
let newState = [...state || []]; | ||
switch (action.type) { | ||
@@ -36,8 +13,8 @@ case 'clear': { | ||
case 'sync': { | ||
var incomingID_1 = action.payload.nodeID; | ||
var indexOfItem = newState.findIndex(function (item) { return item.nodeID === incomingID_1; }); | ||
var itemExists = indexOfItem > -1; | ||
const { payload: { nodeID: incomingID, } } = action; | ||
const indexOfItem = newState.findIndex(item => item.nodeID === incomingID); | ||
const itemExists = indexOfItem > -1; | ||
if (itemExists) { | ||
var foundItem = newState[indexOfItem]; | ||
newState.splice(indexOfItem, 1, __assign(__assign({}, foundItem), action.payload)); | ||
const foundItem = newState[indexOfItem]; | ||
newState.splice(indexOfItem, 1, Object.assign(Object.assign({}, foundItem), action.payload)); | ||
} | ||
@@ -50,5 +27,5 @@ else { | ||
case 'remove': { | ||
var incomingID_2 = action.payload.nodeID; | ||
var indexOfItem = newState.findIndex(function (item) { return item.nodeID === incomingID_2; }); | ||
var foundItem = indexOfItem > -1; | ||
const { payload: { nodeID: incomingID } } = action; | ||
const indexOfItem = newState.findIndex(item => item.nodeID === incomingID); | ||
const foundItem = indexOfItem > -1; | ||
if (foundItem) { | ||
@@ -65,3 +42,2 @@ newState = newState.splice(indexOfItem, 1); | ||
}; | ||
exports.jumplistReducer = jumplistReducer; | ||
//# sourceMappingURL=reducer.js.map |
@@ -1,5 +0,5 @@ | ||
export { JumplistButtonProps } from './JumplistButton'; | ||
export { JumplistNodeProps } from './JumplistNode'; | ||
export { IJumplistContext, JumplistNode, JumplistNodes } from './JumplistProvider/context'; | ||
export { JumplistProviderProps } from './JumplistProvider'; | ||
export { DotNavProps } from './DotNav'; | ||
export type { JumplistButtonProps } from './JumplistButton/index.js'; | ||
export type { JumplistNodeProps } from './JumplistNode/index.js'; | ||
export type { IJumplistContext, JumplistNode, JumplistNodes } from './JumplistProvider/context.js'; | ||
export type { JumplistProviderProps } from './JumplistProvider/index.js'; | ||
export type { DotNavProps } from './DotNav/index.js'; |
@@ -1,3 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@faceless-ui/jumplist", | ||
"version": "2.0.0-rc.0", | ||
"version": "2.0.0-rc.1", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
@@ -41,6 +42,7 @@ "types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "yarn lint && tsc", | ||
"build-demo": "yarn lint && webpack --config webpack.demo.config.js", | ||
"dev": "webpack-dev-server --hot --config webpack.development.config.js", | ||
"lint": "eslint .", | ||
"build": "yarn lint:src && tsc --project tsconfig.build.json", | ||
"build:demo": "webpack --config webpack.build-demo.config.js", | ||
"dev": "webpack serve --config webpack.dev.config.js", | ||
"lint:src": "eslint ./src", | ||
"lint:demo": "eslint ./demo", | ||
"test": "jest" | ||
@@ -54,9 +56,9 @@ }, | ||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5", | ||
"@types/jest": "^27.4.1", | ||
"@types/node": "^14.14.22", | ||
"@types/react": "^18.0.0", | ||
"@types/react-dom": "^18.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.18.0", | ||
"@typescript-eslint/parser": "^5.18.0", | ||
"eslint": "^8.14.0", | ||
"@typescript-eslint/eslint-plugin": "^7.3.1", | ||
"@typescript-eslint/parser": "^7.3.1", | ||
"@types/webpack": "^5.28.5", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
@@ -76,7 +78,7 @@ "eslint-plugin-jest": "^26.1.5", | ||
"react-refresh-typescript": "^2.0.4", | ||
"ts-loader": "^9.2.9", | ||
"typescript": "^4.6.3", | ||
"webpack": "^5.72.0", | ||
"webpack-cli": "^4.9.2", | ||
"webpack-dev-server": "^4.8.1" | ||
"ts-loader": "^9.5.1", | ||
"typescript": "^5.4.5", | ||
"webpack": "^5.91.0", | ||
"webpack-cli": "^5.1.4", | ||
"webpack-dev-server": "^5.0.4" | ||
}, | ||
@@ -83,0 +85,0 @@ "files": [ |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
27297
346
1