@cypress-design/react-docmenu 0.3.1 → 0.4.1

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/_DocGroup.tsx CHANGED
@@ -1,122 +1,262 @@
1
1
  import * as React from 'react'
2
2
  import { IconChevronDownSmall } from '@cypress-design/react-icon'
3
3
  import clsx from 'clsx'
4
- import { NavGroup, classes } from '@cypress-design/constants-docmenu'
5
- import { DocLink } from './_DocLink'
4
+ import {
5
+ type NavGroup,
6
+ type NavItemLink,
7
+ classes,
8
+ } from '@cypress-design/constants-docmenu'
9
+ import {
10
+ DocLink,
11
+ type DocLinkForward,
12
+ type LinkComponentType,
13
+ } from './_DocLink'
6
14
 
7
15
  export interface DocGroupProps {
8
16
  group: NavGroup
17
+ activePath: string
9
18
  collapsible: boolean
19
+ onActivePosition: (opts: { top: number; height: number }) => void
20
+ updateMarkerPosition?: () => void
10
21
  depth?: number
11
- setHeight?: (height: number) => void
22
+ LinkComponent?: LinkComponentType
23
+ hideMarker: () => void
12
24
  }
13
25
 
14
- export const DocGroup: React.FC<DocGroupProps> = ({
15
- group,
16
- collapsible,
17
- depth = 0,
18
- setHeight,
19
- }) => {
20
- const [open, setOpen] = React.useState(depth === 0)
21
- const [itemsHeights, setItemsHeights] = React.useState<number[]>(
22
- Array(group.items.length).fill(1),
23
- )
24
-
25
- React.useEffect(() => {
26
- setHeight?.(open ? itemsHeights.reduce((a, b) => a + b, 1) : 1)
27
- }, [itemsHeights, open, setHeight])
28
-
29
- const [activeTop, setActiveTop] = React.useState(0)
30
-
31
- React.useEffect(() => {
32
- const activeItem = group.items.findIndex(
33
- (item) => 'href' in item && item.active,
26
+ export interface DocGroupForward {
27
+ reTriggerSetActiveGroup: () => void
28
+ }
29
+
30
+ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
31
+ (
32
+ {
33
+ group,
34
+ activePath,
35
+ collapsible,
36
+ depth = 0,
37
+ onActivePosition,
38
+ updateMarkerPosition,
39
+ LinkComponent = 'a',
40
+ hideMarker,
41
+ },
42
+ ref,
43
+ ) => {
44
+ const [open, setOpen] = React.useState(group.collapsed !== true)
45
+ const $groupElements = React.useRef<DocGroupElementsForward>(null)
46
+
47
+ function toggleMenu(open: boolean) {
48
+ if (!collapsible) return
49
+ setOpen(open)
50
+ }
51
+
52
+ const hasActiveItemRecursively = React.useCallback(
53
+ (items = group.items): boolean => {
54
+ return items.some((item) => {
55
+ if ('items' in item) {
56
+ return hasActiveItemRecursively(item.items)
57
+ }
58
+ return item.href === activePath
59
+ })
60
+ },
61
+ [group.items, activePath],
62
+ )
63
+
64
+ const Head = collapsible ? 'button' : group.href ? 'a' : 'div'
65
+
66
+ const setActivePosition = React.useCallback(
67
+ ({ top, height }: { top: number; height: number }) => {
68
+ if (open) {
69
+ onActivePosition({ top, height })
70
+ }
71
+ },
72
+ [onActivePosition, open],
34
73
  )
35
- if (activeItem >= 0) {
36
- setActiveTop(
37
- itemsHeights.slice(0, activeItem).reduce((a, b) => a + b, 1) * 44,
38
- )
74
+
75
+ function reTriggerSetActiveGroup() {
76
+ $groupElements.current?.reTriggerSetActiveGroup()
39
77
  }
40
- }, [itemsHeights, group.items])
41
-
42
- function toggleMenu(open: boolean) {
43
- if (!collapsible) return
44
- setOpen(open)
45
- }
46
-
47
- function onSetHeight(index: number, height: number) {
48
- setItemsHeights((prev) => {
49
- const newHeights = [...prev]
50
- newHeights[index] = height
51
- return newHeights
52
- })
53
- }
54
-
55
- const Head = collapsible ? 'button' : group.href ? 'a' : 'div'
56
-
57
- return (
58
- <>
59
- <Head
60
- onClick={() => toggleMenu(!open)}
61
- href={group.href}
62
- className={clsx(classes.button, {
63
- 'text-indigo-500': group.active,
64
- [classes.topButton]: depth === 0,
65
- [classes.leafButton]: depth,
66
- })}
67
- >
68
- {collapsible ? (
69
- <IconChevronDownSmall
70
- stroke-color="gray-400"
71
- size={depth ? '8' : '16'}
72
- className={clsx('absolute transform transition-transform left-0', {
73
- 'rotate-0': open,
74
- '-rotate-90': !open,
75
- 'ml-[16px]': depth,
76
- })}
77
- />
78
- ) : null}
79
- {group.text}
80
- </Head>
81
- {collapsible &&
82
- depth >= 0 &&
83
- open &&
84
- group.items.some((item) => 'href' in item && item.active) ? (
85
- <div
86
- className="absolute h-[36px] w-[4px] z-10 rounded-full bg-indigo-500 transition-all duration-300 ml-[6px] mt-[4px]"
87
- style={{
88
- top: `${activeTop}px`,
89
- left: `${depth === 0 ? 0.5 : -(depth * 8) - 0.5}px`,
90
- }}
78
+
79
+ React.useEffect(() => {
80
+ if (hasActiveItemRecursively()) {
81
+ if (open) {
82
+ reTriggerSetActiveGroup()
83
+ } else {
84
+ hideMarker()
85
+ }
86
+ } else {
87
+ updateMarkerPosition?.()
88
+ }
89
+ }, [open, updateMarkerPosition, hideMarker, hasActiveItemRecursively])
90
+
91
+ React.useImperativeHandle(ref, () => ({
92
+ reTriggerSetActiveGroup,
93
+ }))
94
+
95
+ const onUpdateMarkerPosition = React.useCallback(() => {
96
+ if (hasActiveItemRecursively()) {
97
+ reTriggerSetActiveGroup()
98
+ } else {
99
+ updateMarkerPosition?.()
100
+ }
101
+ }, [hasActiveItemRecursively, updateMarkerPosition])
102
+
103
+ return (
104
+ <>
105
+ <Head
106
+ onClick={() => toggleMenu(!open)}
107
+ href={group.href}
108
+ className={clsx(classes.button, {
109
+ [classes.topButton]: depth === 0,
110
+ [classes.leafButton]: depth,
111
+ 'text-indigo-500': activePath === group.href,
112
+ })}
113
+ >
114
+ {collapsible ? (
115
+ <IconChevronDownSmall
116
+ stroke-color="gray-400"
117
+ size={depth ? '8' : '16'}
118
+ className={clsx(
119
+ 'absolute transform transition-transform left-0',
120
+ {
121
+ 'rotate-0': open,
122
+ '-rotate-90': !open,
123
+ 'ml-[16px]': depth,
124
+ },
125
+ )}
126
+ />
127
+ ) : null}
128
+ {group.label}
129
+ </Head>
130
+ <DocGroupElements
131
+ ref={$groupElements}
132
+ className={!open ? 'hidden' : undefined}
133
+ items={group.items}
134
+ activePath={activePath}
135
+ collapsible={collapsible}
136
+ depth={depth}
137
+ onActivePosition={setActivePosition}
138
+ updateMarkerPosition={onUpdateMarkerPosition}
139
+ LinkComponent={LinkComponent}
140
+ hideMarker={hideMarker}
91
141
  />
92
- ) : null}
142
+ </>
143
+ )
144
+ },
145
+ )
146
+
147
+ export interface DocGroupElementsProps
148
+ extends React.HTMLAttributes<HTMLUListElement> {
149
+ items: (NavGroup | NavItemLink)[]
150
+ activePath: string
151
+ collapsible: boolean
152
+ onActivePosition: (opts: { top: number; height: number }) => void
153
+ updateMarkerPosition?: () => void
154
+ depth: number
155
+ LinkComponent: LinkComponentType
156
+ hideMarker: () => void
157
+ className: string | undefined
158
+ }
159
+
160
+ export interface DocGroupElementsForward {
161
+ reTriggerSetActiveGroup: () => void
162
+ }
163
+
164
+ export const DocGroupElements = React.forwardRef<
165
+ DocGroupElementsForward,
166
+ DocGroupElementsProps
167
+ >(
168
+ (
169
+ {
170
+ items,
171
+ activePath,
172
+ collapsible,
173
+ depth = 0,
174
+ onActivePosition,
175
+ updateMarkerPosition,
176
+ LinkComponent,
177
+ hideMarker,
178
+ className,
179
+ ...rest
180
+ },
181
+ ref,
182
+ ) => {
183
+ const $groups = React.useRef<DocGroupForward[]>([])
184
+ const $items = React.useRef<DocLinkForward[]>([])
185
+
186
+ const hasActiveItemRecursively = React.useCallback(
187
+ (localItems = items): boolean => {
188
+ return localItems.some((item) => {
189
+ if ('items' in item) {
190
+ return hasActiveItemRecursively(item.items)
191
+ }
192
+ return item.href === activePath
193
+ })
194
+ },
195
+ [items, activePath],
196
+ )
197
+
198
+ function reTriggerSetActiveGroup() {
199
+ $groups.current.forEach((group) => {
200
+ group?.reTriggerSetActiveGroup()
201
+ })
202
+ $items.current.forEach((item) => {
203
+ item?.setActiveMarkerPosition()
204
+ })
205
+ }
206
+
207
+ React.useImperativeHandle(ref, () => ({
208
+ reTriggerSetActiveGroup,
209
+ }))
210
+
211
+ const onUpdateMarkerPosition = React.useCallback(() => {
212
+ if (hasActiveItemRecursively()) {
213
+ reTriggerSetActiveGroup()
214
+ } else {
215
+ updateMarkerPosition?.()
216
+ }
217
+ }, [hasActiveItemRecursively, updateMarkerPosition])
218
+
219
+ return (
93
220
  <ul
94
- className={clsx('ml-[8px] list-none p-0', {
221
+ {...rest}
222
+ className={clsx('list-none p-0', className, {
95
223
  'border-l border-gray-100': depth === 0 && collapsible,
96
- hidden: !open,
224
+ 'ml-[8px]': depth >= 0,
97
225
  })}
98
226
  >
99
- {group.items.map((item, index) =>
227
+ {items.map((item, index) =>
100
228
  'items' in item ? (
101
229
  <li key={index} className="relative list-none p-0">
102
230
  <DocGroup
231
+ ref={(el: DocGroupForward) => {
232
+ $groups.current[index] = el
233
+ }}
103
234
  group={item}
235
+ activePath={activePath}
104
236
  depth={depth + 1}
105
- setHeight={(height) => onSetHeight(index, height)}
106
237
  collapsible={collapsible}
238
+ LinkComponent={LinkComponent}
239
+ hideMarker={hideMarker}
240
+ onActivePosition={onActivePosition}
241
+ updateMarkerPosition={onUpdateMarkerPosition}
107
242
  />
108
243
  </li>
109
244
  ) : (
110
245
  <DocLink
246
+ ref={(el: DocLinkForward) => {
247
+ $items.current[index] = el
248
+ }}
111
249
  key={index}
112
250
  item={item}
251
+ active={item.href === activePath}
113
252
  collapsible={collapsible}
114
253
  depth={depth}
115
- onActive={(top) => setActiveTop(top)}
254
+ onActive={onActivePosition}
255
+ LinkComponent={LinkComponent}
116
256
  />
117
257
  ),
118
258
  )}
119
259
  </ul>
120
- </>
121
- )
122
- }
260
+ )
261
+ },
262
+ )
package/_DocLink.tsx CHANGED
@@ -2,61 +2,81 @@ import * as React from 'react'
2
2
  import clsx from 'clsx'
3
3
  import { NavItemLink } from '@cypress-design/constants-docmenu'
4
4
 
5
+ export type LinkComponentType = React.ElementType<{
6
+ href: string
7
+ className?: string
8
+ children?: React.ReactNode
9
+ }>
10
+
5
11
  export interface DocLinkProps {
6
12
  item: NavItemLink
13
+ active: boolean
7
14
  collapsible: boolean
8
15
  depth?: number
9
- onActive?: (top: number) => void
16
+ onActive?: (opts: { top: number; height: number }) => void
17
+ LinkComponent?: LinkComponentType
18
+ }
19
+
20
+ export interface DocLinkForward {
21
+ setActiveMarkerPosition: () => void
10
22
  }
11
23
 
12
- export const DocLink: React.FC<DocLinkProps> = ({
13
- item,
14
- collapsible,
15
- depth = -1,
16
- onActive,
17
- }) => {
18
- const activeLIRef = React.useRef<HTMLLIElement>(null)
19
-
20
- // on mount, if the item is active,
21
- // send the top position to the parent
22
- React.useEffect(() => {
23
- if (item.active) {
24
- onActive?.(activeLIRef?.current?.offsetTop || 0)
24
+ export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
25
+ (
26
+ { item, active, collapsible, depth = -1, onActive, LinkComponent = 'a' },
27
+ ref,
28
+ ) => {
29
+ const activeLIRef = React.useRef<HTMLLIElement>(null)
30
+
31
+ // on mount, if the item is active,
32
+ // send the top position to the parent
33
+ React.useEffect(setActiveMarkerPosition, [onActive, active])
34
+
35
+ function setActiveMarkerPosition() {
36
+ if (active) {
37
+ const box = activeLIRef?.current?.getBoundingClientRect()
38
+ onActive?.({
39
+ top: box?.top || 0,
40
+ height: box?.height || 0,
41
+ })
42
+ }
25
43
  }
26
- // supposed to happen only on mount
27
- // eslint-disable-next-line react-hooks/exhaustive-deps
28
- }, [])
29
-
30
- return (
31
- <li
32
- ref={activeLIRef}
33
- className={clsx('list-none p-0', {
34
- 'pl-[16px]': depth >= 0,
35
- })}
36
- >
37
- <a
38
- className={clsx('group relative inline-block pl-[24px]', {
39
- 'text-indigo-500': item.active,
40
- 'py-[8px] text-[16px] leading-[24px]': depth < 0,
41
- 'py-[12px] leading-[20px] text-[14px]': depth >= 0,
44
+
45
+ React.useImperativeHandle(ref, () => ({
46
+ setActiveMarkerPosition,
47
+ }))
48
+
49
+ return (
50
+ <li
51
+ ref={activeLIRef}
52
+ className={clsx('list-none p-0', {
53
+ 'pl-[16px]': depth >= 0,
42
54
  })}
43
- href={item.href}
44
55
  >
45
- {depth >= 0 ? (
46
- <div
47
- className={clsx(
48
- 'absolute w-[4px] z-10 top-[10%] h-[80%] rounded-full hidden',
49
- {
50
- 'group-hover:block bg-gray-300': !item.active && collapsible,
51
- },
52
- )}
53
- style={{
54
- left: `-${18.5 + depth * 8}px`,
55
- }}
56
- />
57
- ) : null}
58
- {item.text}
59
- </a>
60
- </li>
61
- )
62
- }
56
+ <LinkComponent
57
+ className={clsx('group relative inline-block pl-[24px]', {
58
+ 'text-indigo-500': active,
59
+ 'py-[8px] text-[16px] leading-[24px]': depth < 0,
60
+ 'py-[12px] leading-[20px] text-[14px]': depth >= 0,
61
+ })}
62
+ href={item.href}
63
+ >
64
+ {depth >= 0 ? (
65
+ <div
66
+ className={clsx(
67
+ 'absolute w-[4px] z-10 top-[4px] bottom-[4px] rounded-full hidden',
68
+ {
69
+ 'group-hover:block bg-gray-300': !active && collapsible,
70
+ },
71
+ )}
72
+ style={{
73
+ left: `-${18.5 + depth * 8}px`,
74
+ }}
75
+ />
76
+ ) : null}
77
+ {item.label}
78
+ </LinkComponent>
79
+ </li>
80
+ )
81
+ },
82
+ )
package/dist/DocMenu.d.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu';
3
+ import type { LinkComponentType } from './_DocLink';
3
4
  export type NavItem = NavGroup | NavItemLink;
4
5
  export interface DocMenuProps extends React.HTMLAttributes<HTMLUListElement> {
5
6
  items: NavItem[];
7
+ activePath?: string;
6
8
  collapsible?: boolean;
9
+ LinkComponent?: LinkComponentType;
7
10
  }
8
11
  export declare const DocMenu: React.FC<DocMenuProps>;
9
12
  export default DocMenu;
@@ -1 +1 @@
1
- {"version":3,"file":"DocMenu.d.ts","sourceRoot":"./","sources":["DocMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAKzE,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE5C,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAC1E,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAkB1C,CAAA;AAED,eAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"DocMenu.d.ts","sourceRoot":"./","sources":["DocMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAGnD,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE5C,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAC1E,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,aAAa,CAAC,EAAE,iBAAiB,CAAA;CAClC;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA+C1C,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -1,10 +1,39 @@
1
1
  import * as React from 'react';
2
- import { NavGroup } from '@cypress-design/constants-docmenu';
2
+ import { type NavGroup, type NavItemLink } from '@cypress-design/constants-docmenu';
3
+ import { type LinkComponentType } from './_DocLink';
3
4
  export interface DocGroupProps {
4
5
  group: NavGroup;
6
+ activePath: string;
5
7
  collapsible: boolean;
8
+ onActivePosition: (opts: {
9
+ top: number;
10
+ height: number;
11
+ }) => void;
12
+ updateMarkerPosition?: () => void;
6
13
  depth?: number;
7
- setHeight?: (height: number) => void;
14
+ LinkComponent?: LinkComponentType;
15
+ hideMarker: () => void;
8
16
  }
9
- export declare const DocGroup: React.FC<DocGroupProps>;
17
+ export interface DocGroupForward {
18
+ reTriggerSetActiveGroup: () => void;
19
+ }
20
+ export declare const DocGroup: React.ForwardRefExoticComponent<DocGroupProps & React.RefAttributes<DocGroupForward>>;
21
+ export interface DocGroupElementsProps extends React.HTMLAttributes<HTMLUListElement> {
22
+ items: (NavGroup | NavItemLink)[];
23
+ activePath: string;
24
+ collapsible: boolean;
25
+ onActivePosition: (opts: {
26
+ top: number;
27
+ height: number;
28
+ }) => void;
29
+ updateMarkerPosition?: () => void;
30
+ depth: number;
31
+ LinkComponent: LinkComponentType;
32
+ hideMarker: () => void;
33
+ className: string | undefined;
34
+ }
35
+ export interface DocGroupElementsForward {
36
+ reTriggerSetActiveGroup: () => void;
37
+ }
38
+ export declare const DocGroupElements: React.ForwardRefExoticComponent<DocGroupElementsProps & React.RefAttributes<DocGroupElementsForward>>;
10
39
  //# sourceMappingURL=_DocGroup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_DocGroup.d.ts","sourceRoot":"./","sources":["_DocGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAE,QAAQ,EAAW,MAAM,mCAAmC,CAAA;AAGrE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,QAAQ,CAAA;IACf,WAAW,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CACrC;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA4G5C,CAAA"}
1
+ {"version":3,"file":"_DocGroup.d.ts","sourceRoot":"./","sources":["_DocGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,QAAQ,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB,gBAAgB,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACjE,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAA;IACjC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,iBAAiB,CAAA;IACjC,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,uBAAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAED,eAAO,MAAM,QAAQ,uFAmHpB,CAAA;AAED,MAAM,WAAW,qBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAC9C,KAAK,EAAE,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,CAAA;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB,gBAAgB,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACjE,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAA;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,iBAAiB,CAAA;IAChC,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B;AAED,MAAM,WAAW,uBAAuB;IACtC,uBAAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAED,eAAO,MAAM,gBAAgB,uGAkG5B,CAAA"}
@@ -1,10 +1,23 @@
1
1
  import * as React from 'react';
2
2
  import { NavItemLink } from '@cypress-design/constants-docmenu';
3
+ export type LinkComponentType = React.ElementType<{
4
+ href: string;
5
+ className?: string;
6
+ children?: React.ReactNode;
7
+ }>;
3
8
  export interface DocLinkProps {
4
9
  item: NavItemLink;
10
+ active: boolean;
5
11
  collapsible: boolean;
6
12
  depth?: number;
7
- onActive?: (top: number) => void;
13
+ onActive?: (opts: {
14
+ top: number;
15
+ height: number;
16
+ }) => void;
17
+ LinkComponent?: LinkComponentType;
8
18
  }
9
- export declare const DocLink: React.FC<DocLinkProps>;
19
+ export interface DocLinkForward {
20
+ setActiveMarkerPosition: () => void;
21
+ }
22
+ export declare const DocLink: React.ForwardRefExoticComponent<DocLinkProps & React.RefAttributes<DocLinkForward>>;
10
23
  //# sourceMappingURL=_DocLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_DocLink.d.ts","sourceRoot":"./","sources":["_DocLink.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE/D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAA;IACjB,WAAW,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACjC;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAkD1C,CAAA"}
1
+ {"version":3,"file":"_DocLink.d.ts","sourceRoot":"./","sources":["_DocLink.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE/D,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAC,CAAA;AAEF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAA;IACjB,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAC1D,aAAa,CAAC,EAAE,iBAAiB,CAAA;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,uBAAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAED,eAAO,MAAM,OAAO,qFA0DnB,CAAA"}