@conveyorhq/arrow-ds 1.36.0 → 1.39.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.
- package/package.json +1 -1
- package/public/components/Accordion/Accordion.d.ts +3 -3
- package/public/components/Accordion/Accordion.js +12 -7
- package/public/components/Accordion/context.d.ts +4 -2
- package/public/components/Accordion/context.js +2 -0
- package/public/components/Accordion/types.d.ts +1 -1
- package/public/components/Icon/Icon.d.ts +2 -1
- package/public/components/Icon/Icon.js +3 -1
- package/public/components/ScrollSpy/ScrollSpy.d.ts +59 -0
- package/public/components/ScrollSpy/ScrollSpy.js +190 -0
- package/public/components/ScrollSpy/index.d.ts +1 -0
- package/public/components/ScrollSpy/index.js +13 -0
- package/public/css/styles.css +4 -0
- package/public/css/styles.min.css +1 -1
- package/public/css/styles.min.css.map +1 -1
- package/public/hooks/index.d.ts +1 -0
- package/public/hooks/index.js +3 -1
- package/public/hooks/useIntersection.d.ts +6 -0
- package/public/hooks/useIntersection.js +23 -0
- package/public/index.d.ts +1 -0
- package/public/index.js +1 -0
- package/src/components/Accordion/Accordion.tsx +28 -9
- package/src/components/Accordion/context.ts +5 -1
- package/src/components/Accordion/types.ts +1 -1
- package/src/components/Icon/Icon.tsx +3 -0
- package/src/components/ScrollSpy/ScrollSpy.story.mdx +14 -0
- package/src/components/ScrollSpy/ScrollSpy.tsx +344 -0
- package/src/components/ScrollSpy/index.css +3 -0
- package/src/components/ScrollSpy/index.ts +1 -0
- package/src/css/components.css +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useIntersection.ts +37 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@ import React from "react";
|
|
|
2
2
|
import { BoxProps } from "../Box";
|
|
3
3
|
import { StackProps } from "../Stack";
|
|
4
4
|
import type { AccordionOwnProps, AccordionItemOwnProps, AccordionDisclosureProps, AccordionGroupOwnProps } from "./types";
|
|
5
|
-
export declare type AccordionGroupProps = AccordionGroupOwnProps & Pick<StackProps, "children" | "spacing">;
|
|
6
|
-
export declare const AccordionGroup: ({ children, spacing, defaultValue, disableAnimation, ...rest }: AccordionGroupProps) => JSX.Element;
|
|
5
|
+
export declare type AccordionGroupProps = AccordionGroupOwnProps & Pick<StackProps, "children" | "spacing" | "className">;
|
|
6
|
+
export declare const AccordionGroup: ({ children, spacing, defaultValue, disableAnimation, className, ...rest }: AccordionGroupProps) => JSX.Element;
|
|
7
7
|
export declare type AccordionItemProps = AccordionItemOwnProps & BoxProps;
|
|
8
8
|
export declare const AccordionItem: ({ value, defaultIsOpen: defaultIsOpenProp, children, className, ...rest }: AccordionItemProps) => JSX.Element;
|
|
9
9
|
declare type AccordionButtonChildProps = Omit<AccordionDisclosureProps, "onToggle">;
|
|
@@ -25,7 +25,7 @@ export declare const AccordionContent: ({ children, maxHeight, style, className,
|
|
|
25
25
|
export declare type AccordionProps = AccordionOwnProps & BoxProps;
|
|
26
26
|
export declare const Accordion: {
|
|
27
27
|
(props: AccordionProps): JSX.Element;
|
|
28
|
-
Group: ({ children, spacing, defaultValue, disableAnimation, ...rest }: AccordionGroupProps) => JSX.Element;
|
|
28
|
+
Group: ({ children, spacing, defaultValue, disableAnimation, className, ...rest }: AccordionGroupProps) => JSX.Element;
|
|
29
29
|
Item: ({ value, defaultIsOpen: defaultIsOpenProp, children, className, ...rest }: AccordionItemProps) => JSX.Element;
|
|
30
30
|
Button: React.ForwardRefExoticComponent<AccordionButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
31
31
|
Content: ({ children, maxHeight, style, className, ...rest }: AccordionContentProps) => JSX.Element;
|
|
@@ -20,9 +20,10 @@ const Heading_1 = require("../Heading");
|
|
|
20
20
|
const Icon_1 = require("../Icon");
|
|
21
21
|
const context_1 = require("./context");
|
|
22
22
|
const cn = utilities_1.bemHOF("Accordion");
|
|
23
|
-
const AccordionGroup = ({ children, spacing = 0, defaultValue, disableAnimation, ...rest }) => {
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const AccordionGroup = ({ children, spacing = 0, defaultValue, disableAnimation, className, ...rest }) => {
|
|
24
|
+
const totalItems = react_1.default.Children.count(children);
|
|
25
|
+
return (react_1.default.createElement(context_1.AccordionGroupContext.Provider, { value: { defaultValue, disableAnimation, totalItems } },
|
|
26
|
+
react_1.default.createElement(Stack_1.Stack, Object.assign({ orientation: types_1.ORIENTATION.VERTICAL, spacing: spacing, className: className }, rest), children)));
|
|
26
27
|
};
|
|
27
28
|
exports.AccordionGroup = AccordionGroup;
|
|
28
29
|
const AccordionItem = ({ value, defaultIsOpen: defaultIsOpenProp, children, className, ...rest }) => {
|
|
@@ -31,7 +32,7 @@ const AccordionItem = ({ value, defaultIsOpen: defaultIsOpenProp, children, clas
|
|
|
31
32
|
const defaultIsOpen = typeof defaultIsOpenProp === "undefined"
|
|
32
33
|
? hasDefaultValue
|
|
33
34
|
: defaultIsOpenProp;
|
|
34
|
-
const { isOpen, onToggle } = hooks_1.useDisclosure(defaultIsOpen);
|
|
35
|
+
const { isOpen, onToggle, onClose } = hooks_1.useDisclosure(defaultIsOpen);
|
|
35
36
|
const id = `accordion-${auto_id_1.useId()}`;
|
|
36
37
|
const buttonId = `${id}-button`;
|
|
37
38
|
const contentId = `${id}-content`;
|
|
@@ -39,8 +40,10 @@ const AccordionItem = ({ value, defaultIsOpen: defaultIsOpenProp, children, clas
|
|
|
39
40
|
defaultIsOpen,
|
|
40
41
|
isOpen,
|
|
41
42
|
onToggle,
|
|
43
|
+
onClose,
|
|
42
44
|
buttonId,
|
|
43
45
|
contentId,
|
|
46
|
+
value,
|
|
44
47
|
} },
|
|
45
48
|
react_1.default.createElement(Box_1.Box, Object.assign({ "data-component": "accordion", className: classnames_1.default(cn(), className, {
|
|
46
49
|
[cn({ m: "isOpen" })]: isOpen,
|
|
@@ -49,7 +52,7 @@ const AccordionItem = ({ value, defaultIsOpen: defaultIsOpenProp, children, clas
|
|
|
49
52
|
exports.AccordionItem = AccordionItem;
|
|
50
53
|
exports.AccordionButton = react_1.default.forwardRef((props, forwardedRef) => {
|
|
51
54
|
const { children, className, onClick, disabled = false, ...rest } = props;
|
|
52
|
-
const { buttonId, contentId, isOpen, onToggle } = context_1.useAccordionItemContext();
|
|
55
|
+
const { buttonId, contentId, isOpen, onToggle, onClose, } = context_1.useAccordionItemContext();
|
|
53
56
|
const buttonRef = react_1.default.useRef(null);
|
|
54
57
|
const ref = react_merge_refs_1.default([forwardedRef, buttonRef]);
|
|
55
58
|
return (react_1.default.createElement("button", Object.assign({ ref: ref, type: "button", className: className, id: buttonId, "aria-controls": contentId, "aria-expanded": isOpen, "aria-disabled": disabled, disabled: disabled, onClick: (event) => {
|
|
@@ -59,7 +62,9 @@ exports.AccordionButton = react_1.default.forwardRef((props, forwardedRef) => {
|
|
|
59
62
|
if (onToggle) {
|
|
60
63
|
onToggle();
|
|
61
64
|
}
|
|
62
|
-
} }, rest), typeof children === "function"
|
|
65
|
+
} }, rest), typeof children === "function"
|
|
66
|
+
? children({ isOpen, onClose })
|
|
67
|
+
: children));
|
|
63
68
|
});
|
|
64
69
|
const AccordionContent = ({ children, maxHeight, style, className, ...rest }) => {
|
|
65
70
|
const { disableAnimation } = context_1.useAccordionGroupContext();
|
|
@@ -73,7 +78,7 @@ const AccordionContent = ({ children, maxHeight, style, className, ...rest }) =>
|
|
|
73
78
|
const { height } = component_size_1.default(childrenRef);
|
|
74
79
|
const heightObj = { height };
|
|
75
80
|
const [enableTransition, setEnableTransition] = react_1.default.useState(!defaultIsOpen);
|
|
76
|
-
return (react_1.default.createElement(renderprops_1.Transition, { items: isOpen, from: { height: 0 }, enter: { height }, leave: { height: 0 }, update: heightObj, onRest: () => {
|
|
81
|
+
return (react_1.default.createElement(renderprops_1.Transition, { items: isOpen, from: { height: 0, opacity: 0 }, enter: { height, opacity: 1 }, leave: { height: 0, opacity: 0 }, update: heightObj, onRest: () => {
|
|
77
82
|
if (defaultIsOpen && isOpen) {
|
|
78
83
|
setEnableTransition(true);
|
|
79
84
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Context } from "react";
|
|
2
2
|
import type { AccordionGroupOwnProps, AccordionItemOwnProps, AccordionDisclosureProps } from "./types";
|
|
3
|
-
declare type AccordionGroupContextType =
|
|
3
|
+
declare type AccordionGroupContextType = {
|
|
4
|
+
totalItems?: number;
|
|
5
|
+
} & AccordionGroupOwnProps;
|
|
4
6
|
export declare const AccordionGroupContext: Context<AccordionGroupContextType>;
|
|
5
|
-
export declare function useAccordionGroupContext():
|
|
7
|
+
export declare function useAccordionGroupContext(): AccordionGroupContextType;
|
|
6
8
|
declare type AccordionItemContextType = AccordionItemOwnProps & AccordionDisclosureProps & {
|
|
7
9
|
buttonId: string;
|
|
8
10
|
contentId: string;
|
|
@@ -5,6 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const defaultGroupContext = {
|
|
6
6
|
defaultValue: undefined,
|
|
7
7
|
disableAnimation: false,
|
|
8
|
+
totalItems: 0,
|
|
8
9
|
};
|
|
9
10
|
exports.AccordionGroupContext = react_1.createContext(defaultGroupContext);
|
|
10
11
|
function useAccordionGroupContext() {
|
|
@@ -18,6 +19,7 @@ const defaultContext = {
|
|
|
18
19
|
defaultIsOpen: false,
|
|
19
20
|
isOpen: false,
|
|
20
21
|
onToggle: () => { },
|
|
22
|
+
onClose: () => { },
|
|
21
23
|
buttonId: "accordion-0-button",
|
|
22
24
|
contentId: "accordion-0-content",
|
|
23
25
|
};
|
|
@@ -15,4 +15,4 @@ export declare type AccordionOwnProps = Pick<AccordionItemOwnProps, "defaultIsOp
|
|
|
15
15
|
iconSlot?: ReactNode;
|
|
16
16
|
removePadding?: ReactNode;
|
|
17
17
|
};
|
|
18
|
-
export declare type AccordionDisclosureProps = Pick<DisclosureProps, "isOpen" | "onToggle">;
|
|
18
|
+
export declare type AccordionDisclosureProps = Pick<DisclosureProps, "isOpen" | "onToggle" | "onClose">;
|
|
@@ -112,7 +112,8 @@ export declare enum ICON_TYPE {
|
|
|
112
112
|
USER_ASTRONAUT = "user-astronaut",
|
|
113
113
|
USER_PLUS = "user-plus",
|
|
114
114
|
USERS = "users",
|
|
115
|
-
USER_FRIENDS = "user-friends"
|
|
115
|
+
USER_FRIENDS = "user-friends",
|
|
116
|
+
USER_SHIELD = "user-shield"
|
|
116
117
|
}
|
|
117
118
|
export declare enum ICON_STYLE_PREFIX {
|
|
118
119
|
SOLID = "fas",
|
|
@@ -138,12 +138,13 @@ const faUserAstronaut_1 = require("@fortawesome/free-solid-svg-icons/faUserAstro
|
|
|
138
138
|
const faUserPlus_1 = require("@fortawesome/free-solid-svg-icons/faUserPlus");
|
|
139
139
|
const faUsers_1 = require("@fortawesome/free-solid-svg-icons/faUsers");
|
|
140
140
|
const faUserFriends_1 = require("@fortawesome/free-solid-svg-icons/faUserFriends");
|
|
141
|
+
const faUserShield_1 = require("@fortawesome/free-solid-svg-icons/faUserShield");
|
|
141
142
|
const svg_1 = require("./svg");
|
|
142
143
|
const status_1 = require("../../contexts/status");
|
|
143
144
|
const types_1 = require("../../types");
|
|
144
145
|
const utilities_1 = require("../../utilities");
|
|
145
146
|
const cn = utilities_1.bemHOF("Icon");
|
|
146
|
-
fontawesome_svg_core_1.library.add(faArchive_1.faArchive, faArrowDown_1.faArrowDown, faArrowLeft_1.faArrowLeft, faArrowRight_1.faArrowRight, faArrowUp_1.faArrowUp, faBackward_1.faBackward, faBan_1.faBan, faBatteryHalf_1.faBatteryHalf, faBed_1.faBed, faBell_1.faBell, faBolt_1.faBolt, faCalculator_1.faCalculator, faCalendar_1.faCalendar, faCaretDown_1.faCaretDown, faCaretUp_1.faCaretUp, faChartLine_1.faChartLine, faCheck_1.faCheck, faCheckCircle_2.faCheckCircle, faCheckCircle_1.faCheckCircle, faChevronDown_1.faChevronDown, faChevronLeft_1.faChevronLeft, faChevronRight_1.faChevronRight, faChevronUp_1.faChevronUp, faCircle_2.faCircle, faCircleNotch_1.faCircleNotch, faCircle_1.faCircle, faClipboard_1.faClipboard, faClock_1.faClock, faClock_2.faClock, faCog_1.faCog, faColumns_1.faColumns, faCommentAlt_1.faCommentAlt, faCompress_1.faCompress, faCrown_1.faCrown, faEllipsisH_1.faEllipsisH, faEllipsisV_1.faEllipsisV, faEnvelope_1.faEnvelope, faExclamationCircle_1.faExclamationCircle, faExclamationTriangle_1.faExclamationTriangle, faExpand_1.faExpand, faExternalLinkAlt_1.faExternalLinkAlt, faExternalLinkSquareAlt_1.faExternalLinkSquareAlt, faEye_1.faEye, faEyeSlash_1.faEyeSlash, faFastBackward_1.faFastBackward, faFastForward_1.faFastForward, faFileAlt_1.faFileAlt, faFileAlt_2.faFileAlt, faFileImport_1.faFileImport, faFileSignature_1.faFileSignature, faFilter_1.faFilter, faFlag_1.faFlag, faFolder_1.faFolder, faForward_1.faForward, faGripLines_1.faGripLines, faGripLinesVertical_1.faGripLinesVertical, faHashtag_1.faHashtag, faInfoCircle_1.faInfoCircle, faKey_1.faKey, faKeyboard_1.faKeyboard, faLayerGroup_1.faLayerGroup, faLevelUpAlt_1.faLevelUpAlt, faListUl_1.faListUl, faLock_1.faLock, faLongArrowAltRight_1.faLongArrowAltRight, faMagic_1.faMagic, faMapSigns_1.faMapSigns, faMinus_1.faMinus, faMousePointer_1.faMousePointer, faPaperclip_1.faPaperclip, faPause_1.faPause, faPen_1.faPen, faPlay_1.faPlay, faPlus_1.faPlus, faPlusCircle_1.faPlusCircle, faPooStorm_1.faPooStorm, faQuestion_1.faQuestion, faQuestionCircle_2.faQuestionCircle, faQuestionCircle_1.faQuestionCircle, faScroll_1.faScroll, faSearch_1.faSearch, faShareAlt_1.faShareAlt, faShieldAlt_1.faShieldAlt, faSignOutAlt_1.faSignOutAlt, faSignature_1.faSignature, faSlidersH_1.faSlidersH, faSort_1.faSort, faSortDown_1.faSortDown, faSortUp_1.faSortUp, faSpinner_1.faSpinner, faSquare_1.faSquare, faStar_1.faStar, faStar_2.faStar, faSync_1.faSync, faTasks_1.faTasks, faThLarge_1.faThLarge, faThumbsDown_1.faThumbsDown, faThumbsDown_2.faThumbsDown, faThumbsUp_1.faThumbsUp, faThumbsUp_2.faThumbsUp, faTicketAlt_1.faTicketAlt, faTimes_1.faTimes, faTimesCircle_1.faTimesCircle, faTrash_1.faTrash, faUnlock_1.faUnlock, faUser_2.faUser, faUserAstronaut_1.faUserAstronaut, faUserPlus_1.faUserPlus, faUser_1.faUser, faUsers_1.faUsers, faUserFriends_1.faUserFriends);
|
|
147
|
+
fontawesome_svg_core_1.library.add(faArchive_1.faArchive, faArrowDown_1.faArrowDown, faArrowLeft_1.faArrowLeft, faArrowRight_1.faArrowRight, faArrowUp_1.faArrowUp, faBackward_1.faBackward, faBan_1.faBan, faBatteryHalf_1.faBatteryHalf, faBed_1.faBed, faBell_1.faBell, faBolt_1.faBolt, faCalculator_1.faCalculator, faCalendar_1.faCalendar, faCaretDown_1.faCaretDown, faCaretUp_1.faCaretUp, faChartLine_1.faChartLine, faCheck_1.faCheck, faCheckCircle_2.faCheckCircle, faCheckCircle_1.faCheckCircle, faChevronDown_1.faChevronDown, faChevronLeft_1.faChevronLeft, faChevronRight_1.faChevronRight, faChevronUp_1.faChevronUp, faCircle_2.faCircle, faCircleNotch_1.faCircleNotch, faCircle_1.faCircle, faClipboard_1.faClipboard, faClock_1.faClock, faClock_2.faClock, faCog_1.faCog, faColumns_1.faColumns, faCommentAlt_1.faCommentAlt, faCompress_1.faCompress, faCrown_1.faCrown, faEllipsisH_1.faEllipsisH, faEllipsisV_1.faEllipsisV, faEnvelope_1.faEnvelope, faExclamationCircle_1.faExclamationCircle, faExclamationTriangle_1.faExclamationTriangle, faExpand_1.faExpand, faExternalLinkAlt_1.faExternalLinkAlt, faExternalLinkSquareAlt_1.faExternalLinkSquareAlt, faEye_1.faEye, faEyeSlash_1.faEyeSlash, faFastBackward_1.faFastBackward, faFastForward_1.faFastForward, faFileAlt_1.faFileAlt, faFileAlt_2.faFileAlt, faFileImport_1.faFileImport, faFileSignature_1.faFileSignature, faFilter_1.faFilter, faFlag_1.faFlag, faFolder_1.faFolder, faForward_1.faForward, faGripLines_1.faGripLines, faGripLinesVertical_1.faGripLinesVertical, faHashtag_1.faHashtag, faInfoCircle_1.faInfoCircle, faKey_1.faKey, faKeyboard_1.faKeyboard, faLayerGroup_1.faLayerGroup, faLevelUpAlt_1.faLevelUpAlt, faListUl_1.faListUl, faLock_1.faLock, faLongArrowAltRight_1.faLongArrowAltRight, faMagic_1.faMagic, faMapSigns_1.faMapSigns, faMinus_1.faMinus, faMousePointer_1.faMousePointer, faPaperclip_1.faPaperclip, faPause_1.faPause, faPen_1.faPen, faPlay_1.faPlay, faPlus_1.faPlus, faPlusCircle_1.faPlusCircle, faPooStorm_1.faPooStorm, faQuestion_1.faQuestion, faQuestionCircle_2.faQuestionCircle, faQuestionCircle_1.faQuestionCircle, faScroll_1.faScroll, faSearch_1.faSearch, faShareAlt_1.faShareAlt, faShieldAlt_1.faShieldAlt, faSignOutAlt_1.faSignOutAlt, faSignature_1.faSignature, faSlidersH_1.faSlidersH, faSort_1.faSort, faSortDown_1.faSortDown, faSortUp_1.faSortUp, faSpinner_1.faSpinner, faSquare_1.faSquare, faStar_1.faStar, faStar_2.faStar, faSync_1.faSync, faTasks_1.faTasks, faThLarge_1.faThLarge, faThumbsDown_1.faThumbsDown, faThumbsDown_2.faThumbsDown, faThumbsUp_1.faThumbsUp, faThumbsUp_2.faThumbsUp, faTicketAlt_1.faTicketAlt, faTimes_1.faTimes, faTimesCircle_1.faTimesCircle, faTrash_1.faTrash, faUnlock_1.faUnlock, faUser_2.faUser, faUserAstronaut_1.faUserAstronaut, faUserPlus_1.faUserPlus, faUser_1.faUser, faUsers_1.faUsers, faUserFriends_1.faUserFriends, faUserShield_1.faUserShield);
|
|
147
148
|
var CUSTOM_ICON_TYPE;
|
|
148
149
|
(function (CUSTOM_ICON_TYPE) {
|
|
149
150
|
CUSTOM_ICON_TYPE["ARROW_TO_BOTTOM"] = "arrow-to-bottom";
|
|
@@ -267,6 +268,7 @@ var ICON_TYPE;
|
|
|
267
268
|
ICON_TYPE["USER_PLUS"] = "user-plus";
|
|
268
269
|
ICON_TYPE["USERS"] = "users";
|
|
269
270
|
ICON_TYPE["USER_FRIENDS"] = "user-friends";
|
|
271
|
+
ICON_TYPE["USER_SHIELD"] = "user-shield";
|
|
270
272
|
})(ICON_TYPE = exports.ICON_TYPE || (exports.ICON_TYPE = {}));
|
|
271
273
|
var ICON_STYLE_PREFIX;
|
|
272
274
|
(function (ICON_STYLE_PREFIX) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { ReactNode, Context, MutableRefObject, Dispatch, SetStateAction, HTMLAttributes, ReactElement, AnchorHTMLAttributes, MouseEvent, ChangeEvent, KeyboardEvent, FocusEvent, InputHTMLAttributes } from "react";
|
|
2
|
+
declare type ScrollSpyContextType = {
|
|
3
|
+
currentIndex: number;
|
|
4
|
+
setCurrentIndex: Dispatch<SetStateAction<number>>;
|
|
5
|
+
currentPage: number;
|
|
6
|
+
setCurrentPage: Dispatch<SetStateAction<number>>;
|
|
7
|
+
refList: MutableRefObject<HTMLElement[]>;
|
|
8
|
+
updateCurrentRef(index: number, refItem: HTMLElement): void;
|
|
9
|
+
scrollToRef(refToScrollTo: HTMLElement): void;
|
|
10
|
+
scrollToFirst(event: MouseEvent): void;
|
|
11
|
+
scrollToLast(event: MouseEvent): void;
|
|
12
|
+
onAnchorClick(event: MouseEvent<HTMLAnchorElement>, index: number): void;
|
|
13
|
+
onInputChange(event: ChangeEvent<HTMLInputElement>): void;
|
|
14
|
+
onInputKeyUp(event: KeyboardEvent<HTMLInputElement>): void;
|
|
15
|
+
onInputFocus(event: FocusEvent<HTMLInputElement>): void;
|
|
16
|
+
items: number;
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const ScrollSpyContext: Context<ScrollSpyContextType>;
|
|
20
|
+
export declare function useScrollSpyContext(): ScrollSpyContextType;
|
|
21
|
+
export declare type ScrollSpyInputProps = InputHTMLAttributes<HTMLInputElement>;
|
|
22
|
+
export declare const ScrollSpyInput: React.ForwardRefExoticComponent<ScrollSpyInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
23
|
+
export interface ScrollSpyPageProps extends HTMLAttributes<HTMLDivElement> {
|
|
24
|
+
children: ReactElement;
|
|
25
|
+
threshold: number | number[] | undefined;
|
|
26
|
+
index: number;
|
|
27
|
+
}
|
|
28
|
+
export declare type ScrollSpyPageUsePropsHookProps = {
|
|
29
|
+
index: number;
|
|
30
|
+
id?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const useScrollSpyPageProps: ({ index, id }?: ScrollSpyPageUsePropsHookProps) => {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
export declare const ScrollSpyPage: React.ForwardRefExoticComponent<ScrollSpyPageProps & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
export interface ScrollSpyAnchorProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
index: number;
|
|
39
|
+
}
|
|
40
|
+
export declare type ScrollSpyAnchorUsePropsHookProps = {
|
|
41
|
+
index: number;
|
|
42
|
+
id?: string;
|
|
43
|
+
href?: string;
|
|
44
|
+
onClick?(event: MouseEvent<HTMLAnchorElement>): void;
|
|
45
|
+
};
|
|
46
|
+
export declare const useScrollSpyAnchorProps: ({ index, id, href, onClick }?: ScrollSpyAnchorUsePropsHookProps) => {
|
|
47
|
+
id: string;
|
|
48
|
+
href: string;
|
|
49
|
+
onClick: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
50
|
+
isActive: boolean;
|
|
51
|
+
};
|
|
52
|
+
export declare const ScrollSpyAnchor: React.ForwardRefExoticComponent<ScrollSpyAnchorProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
53
|
+
export declare type ScrollSpyRootProps = {
|
|
54
|
+
children: ReactNode | ((props: ScrollSpyContextType) => JSX.Element);
|
|
55
|
+
items: number;
|
|
56
|
+
defaultIndex?: number;
|
|
57
|
+
};
|
|
58
|
+
export declare const ScrollSpyRoot: ({ children, items, defaultIndex, }: ScrollSpyRootProps) => JSX.Element;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ScrollSpyRoot = exports.ScrollSpyAnchor = exports.useScrollSpyAnchorProps = exports.ScrollSpyPage = exports.useScrollSpyPageProps = exports.ScrollSpyInput = exports.useScrollSpyContext = exports.ScrollSpyContext = void 0;
|
|
26
|
+
const react_1 = __importStar(require("react"));
|
|
27
|
+
const react_merge_refs_1 = __importDefault(require("react-merge-refs"));
|
|
28
|
+
const auto_id_1 = require("@reach/auto-id");
|
|
29
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
30
|
+
const utilities_1 = require("../../utilities");
|
|
31
|
+
const hooks_1 = require("../../hooks");
|
|
32
|
+
const cn = utilities_1.bemHOF("ScrollSpy");
|
|
33
|
+
const defaultRootContext = {
|
|
34
|
+
currentIndex: 0,
|
|
35
|
+
setCurrentIndex: (index) => index,
|
|
36
|
+
currentPage: 1,
|
|
37
|
+
setCurrentPage: (index) => index,
|
|
38
|
+
refList: { current: [] },
|
|
39
|
+
updateCurrentRef: () => { },
|
|
40
|
+
scrollToRef: () => { },
|
|
41
|
+
scrollToFirst: () => { },
|
|
42
|
+
scrollToLast: () => { },
|
|
43
|
+
onAnchorClick: () => { },
|
|
44
|
+
onInputChange: () => { },
|
|
45
|
+
onInputKeyUp: () => { },
|
|
46
|
+
onInputFocus: () => { },
|
|
47
|
+
items: 1,
|
|
48
|
+
id: "scroll-spy-1",
|
|
49
|
+
};
|
|
50
|
+
exports.ScrollSpyContext = react_1.createContext(defaultRootContext);
|
|
51
|
+
function useScrollSpyContext() {
|
|
52
|
+
const context = react_1.useContext(exports.ScrollSpyContext) || {
|
|
53
|
+
...defaultRootContext,
|
|
54
|
+
};
|
|
55
|
+
return context;
|
|
56
|
+
}
|
|
57
|
+
exports.useScrollSpyContext = useScrollSpyContext;
|
|
58
|
+
exports.ScrollSpyInput = react_1.forwardRef(({ className, ...rest }, forwardedRef) => {
|
|
59
|
+
return (react_1.default.createElement("input", Object.assign({ className: classnames_1.default(cn({ e: "input" }), className), ref: forwardedRef, type: "number" }, rest)));
|
|
60
|
+
});
|
|
61
|
+
const useScrollSpyPageProps = ({ index, id } = { index: 0 }) => {
|
|
62
|
+
const { id: rootId } = useScrollSpyContext();
|
|
63
|
+
const pageId = `${rootId}-page-${index + 1}`;
|
|
64
|
+
return {
|
|
65
|
+
id: id || pageId,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
exports.useScrollSpyPageProps = useScrollSpyPageProps;
|
|
69
|
+
exports.ScrollSpyPage = react_1.forwardRef(({ id: idProp, children, index, threshold = 0.5, ...rest }, forwardedRef) => {
|
|
70
|
+
const ref = react_1.useRef(null);
|
|
71
|
+
const combinedRef = react_merge_refs_1.default([ref, forwardedRef]);
|
|
72
|
+
const isVisible = hooks_1.useIntersection(ref, {
|
|
73
|
+
threshold,
|
|
74
|
+
});
|
|
75
|
+
const { updateCurrentRef, setCurrentIndex, setCurrentPage, } = useScrollSpyContext();
|
|
76
|
+
const { id } = exports.useScrollSpyPageProps({ index, id: idProp });
|
|
77
|
+
const pageNumber = index + 1;
|
|
78
|
+
react_1.useEffect(() => {
|
|
79
|
+
if (ref && ref.current) {
|
|
80
|
+
updateCurrentRef(index, ref.current);
|
|
81
|
+
}
|
|
82
|
+
}, [ref, index, updateCurrentRef]);
|
|
83
|
+
react_1.useEffect(() => {
|
|
84
|
+
if (isVisible) {
|
|
85
|
+
setCurrentIndex(index);
|
|
86
|
+
setCurrentPage(pageNumber);
|
|
87
|
+
}
|
|
88
|
+
}, [isVisible, index, pageNumber, setCurrentIndex, setCurrentPage]);
|
|
89
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, react_1.default.cloneElement(react_1.default.Children.only(children), {
|
|
90
|
+
...rest,
|
|
91
|
+
...children.props,
|
|
92
|
+
id,
|
|
93
|
+
ref: combinedRef,
|
|
94
|
+
})));
|
|
95
|
+
});
|
|
96
|
+
const useScrollSpyAnchorProps = ({ index, id, href, onClick } = { index: 0 }) => {
|
|
97
|
+
const { id: rootId, currentIndex, onAnchorClick } = useScrollSpyContext();
|
|
98
|
+
const { id: pageId } = exports.useScrollSpyPageProps({ index });
|
|
99
|
+
const anchorId = `${rootId}-anchor-${index + 1}`;
|
|
100
|
+
return {
|
|
101
|
+
id: id || anchorId,
|
|
102
|
+
href: href || `#${pageId}`,
|
|
103
|
+
onClick: (event) => {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
if (onClick)
|
|
106
|
+
onClick(event);
|
|
107
|
+
onAnchorClick(event, index);
|
|
108
|
+
},
|
|
109
|
+
isActive: currentIndex === index,
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
exports.useScrollSpyAnchorProps = useScrollSpyAnchorProps;
|
|
113
|
+
exports.ScrollSpyAnchor = react_1.forwardRef(({ id, children, onClick, index = 0, ...rest }, forwardedRef) => {
|
|
114
|
+
const { isActive, ...anchorProps } = exports.useScrollSpyAnchorProps({
|
|
115
|
+
index,
|
|
116
|
+
id,
|
|
117
|
+
onClick,
|
|
118
|
+
});
|
|
119
|
+
return (react_1.default.createElement("a", Object.assign({ ref: forwardedRef }, anchorProps, rest), children));
|
|
120
|
+
});
|
|
121
|
+
const ScrollSpyRoot = ({ children, items, defaultIndex = 0, }) => {
|
|
122
|
+
const defaultPageNumber = defaultIndex + 1;
|
|
123
|
+
const [currentIndex, setCurrentIndex] = react_1.useState(defaultIndex);
|
|
124
|
+
const [currentPage, setCurrentPage] = react_1.useState(defaultPageNumber);
|
|
125
|
+
const refList = react_1.useRef([]);
|
|
126
|
+
const id = `scroll-spy-${auto_id_1.useId()}`;
|
|
127
|
+
react_1.useEffect(() => {
|
|
128
|
+
refList.current = refList.current.slice(0, items);
|
|
129
|
+
}, [items]);
|
|
130
|
+
const updateCurrentRef = (index, refItem) => {
|
|
131
|
+
refList.current[index] = refItem;
|
|
132
|
+
};
|
|
133
|
+
const scrollToRef = (refToScrollTo) => {
|
|
134
|
+
refToScrollTo.scrollIntoView({ behavior: "smooth" });
|
|
135
|
+
};
|
|
136
|
+
const scrollToFirst = (event) => {
|
|
137
|
+
event.stopPropagation();
|
|
138
|
+
scrollToRef(refList.current[0]);
|
|
139
|
+
};
|
|
140
|
+
const scrollToLast = (event) => {
|
|
141
|
+
event.stopPropagation();
|
|
142
|
+
scrollToRef(refList.current[items - 1]);
|
|
143
|
+
};
|
|
144
|
+
const onAnchorClick = (event, index) => {
|
|
145
|
+
event.stopPropagation();
|
|
146
|
+
scrollToRef(refList.current[index]);
|
|
147
|
+
setCurrentPage(index + 1);
|
|
148
|
+
};
|
|
149
|
+
const onInputFocus = (event) => event.target.select();
|
|
150
|
+
const onInputChange = (event) => {
|
|
151
|
+
event.stopPropagation();
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
const { value } = event.target;
|
|
154
|
+
const pageNumber = parseInt(value, 10);
|
|
155
|
+
const index = pageNumber - 1;
|
|
156
|
+
setCurrentPage(pageNumber);
|
|
157
|
+
if (pageNumber && pageNumber >= 1 && pageNumber <= items) {
|
|
158
|
+
scrollToRef(refList.current[index]);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const onInputKeyUp = (event) => {
|
|
162
|
+
event.stopPropagation();
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
const { value } = event.currentTarget;
|
|
165
|
+
const pageNumber = parseInt(value, 10);
|
|
166
|
+
const index = pageNumber - 1;
|
|
167
|
+
if (pageNumber && pageNumber >= 1 && pageNumber <= items) {
|
|
168
|
+
scrollToRef(refList.current[index]);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const context = {
|
|
172
|
+
currentIndex,
|
|
173
|
+
setCurrentIndex,
|
|
174
|
+
currentPage,
|
|
175
|
+
setCurrentPage,
|
|
176
|
+
refList,
|
|
177
|
+
updateCurrentRef,
|
|
178
|
+
scrollToRef,
|
|
179
|
+
scrollToFirst,
|
|
180
|
+
scrollToLast,
|
|
181
|
+
onAnchorClick,
|
|
182
|
+
onInputChange,
|
|
183
|
+
onInputKeyUp,
|
|
184
|
+
onInputFocus,
|
|
185
|
+
items,
|
|
186
|
+
id,
|
|
187
|
+
};
|
|
188
|
+
return (react_1.default.createElement(exports.ScrollSpyContext.Provider, { value: context }, typeof children === "function" ? children(context) : children));
|
|
189
|
+
};
|
|
190
|
+
exports.ScrollSpyRoot = ScrollSpyRoot;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ScrollSpy";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./ScrollSpy"), exports);
|
package/public/css/styles.css
CHANGED
|
@@ -5264,6 +5264,10 @@ override built-in Image component classes */
|
|
|
5264
5264
|
overflow-y: auto;
|
|
5265
5265
|
}
|
|
5266
5266
|
|
|
5267
|
+
.ads-ScrollSpy-input::-webkit-inner-spin-button {
|
|
5268
|
+
display: none;
|
|
5269
|
+
}
|
|
5270
|
+
|
|
5267
5271
|
.ads-SearchFilter {
|
|
5268
5272
|
position: relative;
|
|
5269
5273
|
display: inline-flex;
|