@cypress-design/react-docmenu 0.5.2 → 0.5.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @cypress-design/react-docmenu
2
2
 
3
+ ## 0.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9f750c5`](https://github.com/cypress-io/cypress-design/commit/9f750c57722351c43d8dda136796a1ea98c203c8) Thanks [@elevatebart](https://github.com/elevatebart)! - adjust colors according to designs and refactor react side to use context
8
+
3
9
  ## 0.5.2
4
10
 
5
11
  ### Patch Changes
package/DocMenu.tsx CHANGED
@@ -2,7 +2,6 @@ import * as React from 'react'
2
2
  import { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'
3
3
  import type { LinkComponentType } from './_DocLink'
4
4
  import { DocGroupElements } from './_DocGroup'
5
- import { MarkerIsMovingContext } from './markerIsMoving'
6
5
 
7
6
  export type NavItem = NavGroup | NavItemLink
8
7
 
@@ -38,7 +37,7 @@ export const DocMenu: React.FC<DocMenuProps> = ({
38
37
  [],
39
38
  )
40
39
 
41
- const setShowMarkerFalse = React.useCallback(() => setShowMarker(false), [])
40
+ const hideMarker = React.useCallback(() => setShowMarker(false), [])
42
41
  const setMarkerIsMoving = React.useCallback(
43
42
  (val: boolean) => {
44
43
  localSetMarkerIsMoving(val)
@@ -54,34 +53,35 @@ export const DocMenu: React.FC<DocMenuProps> = ({
54
53
  )
55
54
 
56
55
  return (
57
- <MarkerIsMovingContext.Provider
58
- value={{ markerIsMoving, setMarkerIsMoving }}
59
- >
60
- <div ref={container} className="relative">
61
- {showMarker && !markerIsMoving && collapsible ? (
62
- <div
63
- className="absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 ml-[6.5px] mt-[4px]"
64
- style={{
65
- top: `${activeTop}px`,
66
- height: `${activeHeight - 8}px`,
67
- transition: hasCSSTransition
68
- ? 'height .3s ease-in-out, top .3s ease-in-out'
69
- : 'none',
70
- }}
71
- />
72
- ) : null}
73
- <DocGroupElements
74
- {...rest}
75
- items={items}
76
- activePath={activePath}
77
- collapsible={collapsible}
78
- depth={-1}
79
- onActivePosition={setActivePosition}
80
- LinkComponent={LinkComponent}
81
- hideMarker={setShowMarkerFalse}
56
+ <div ref={container} className="relative">
57
+ {showMarker && !markerIsMoving && collapsible ? (
58
+ <div
59
+ data-cy="doc-menu-active-marker"
60
+ className="absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 dark:bg-indigo-400 ml-[6.5px] mt-[4px]"
61
+ style={{
62
+ top: `${activeTop}px`,
63
+ height: `${activeHeight - 8}px`,
64
+ transition: hasCSSTransition
65
+ ? 'height .3s ease-in-out, top .3s ease-in-out'
66
+ : 'none',
67
+ }}
82
68
  />
83
- </div>
84
- </MarkerIsMovingContext.Provider>
69
+ ) : null}
70
+ <DocGroupElements
71
+ {...rest}
72
+ items={items}
73
+ depth={-1}
74
+ markerIsMoving={markerIsMoving}
75
+ onActivePosition={setActivePosition}
76
+ LinkComponent={LinkComponent}
77
+ context={{
78
+ setMarkerIsMoving,
79
+ activePath,
80
+ collapsible,
81
+ hideMarker,
82
+ }}
83
+ />
84
+ </div>
85
85
  )
86
86
  }
87
87
 
@@ -39,13 +39,13 @@ describe('<DocMenu/>', () => {
39
39
 
40
40
  it(
41
41
  'wraps items correctly',
42
- { viewportHeight: 950, viewportWidth: 350 },
42
+ { viewportHeight: 950, viewportWidth: 550 },
43
43
  () => {
44
44
  const Sut = () => {
45
45
  const [activeHref, setActiveHref] = React.useState<string | undefined>()
46
46
 
47
47
  return (
48
- <div className="w-[200px] mt-[60px] absolute">
48
+ <div className="w-[400px] mt-[60px] mx-[24px] absolute">
49
49
  <DocMenu
50
50
  activePath={activeHref}
51
51
  LinkComponent={({ href, className, children, style }) => (
@@ -133,10 +133,12 @@ describe('<DocMenu/>', () => {
133
133
  mount(<Sut />)
134
134
 
135
135
  cy.findByText('Bar').click()
136
- cy.findByText('Code').click()
136
+ cy.findByText('Code').click().click()
137
137
  cy.findByText(
138
138
  'lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos',
139
139
  ).click()
140
+ cy.findByText('Code').click()
141
+ cy.get('[data-cy=doc-menu-active-marker]').should('not.exist')
140
142
  },
141
143
  )
142
144
 
package/_DocGroup.tsx CHANGED
@@ -8,63 +8,74 @@ import {
8
8
  } from '@cypress-design/constants-docmenu'
9
9
  import {
10
10
  DocLink,
11
+ type Context,
11
12
  type DocLinkForward,
12
13
  type LinkComponentType,
13
14
  } from './_DocLink'
14
- import { MarkerIsMovingContext } from './markerIsMoving'
15
15
 
16
16
  export interface DocGroupProps {
17
17
  group: NavGroup
18
- activePath: string
19
- collapsible: boolean
18
+ context: Context
20
19
  onActivePosition: (opts: { top: number; height: number }) => void
21
- updateMarkerPosition?: () => void
20
+ updateMarkerPosition: () => void
21
+ markerIsMoving: boolean
22
22
  depth?: number
23
23
  LinkComponent?: LinkComponentType
24
- hideMarker: () => void
25
24
  }
26
25
 
27
26
  export interface DocGroupForward {
28
27
  reTriggerSetActiveGroup: () => void
29
28
  }
30
29
 
30
+ const hasActiveItemRecursively = (
31
+ items: (NavGroup | NavItemLink)[],
32
+ localActivePath: string,
33
+ ): boolean => {
34
+ return items.some((item) => {
35
+ if ('items' in item) {
36
+ return hasActiveItemRecursively(item.items, localActivePath)
37
+ }
38
+ return item.href === localActivePath
39
+ })
40
+ }
41
+
31
42
  export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
32
43
  (
33
44
  {
34
45
  group,
35
- activePath,
36
- collapsible,
37
46
  depth = 0,
38
47
  onActivePosition,
48
+ markerIsMoving,
49
+ context,
39
50
  updateMarkerPosition,
40
51
  LinkComponent = 'a',
41
- hideMarker,
42
52
  },
43
53
  ref,
44
54
  ) => {
45
- const [open, setOpen] = React.useState(group.collapsed !== true)
55
+ const { setMarkerIsMoving, activePath, collapsible, hideMarker } = context
56
+
57
+ const hasActiveItemRecursivelyMemo = React.useMemo(() => {
58
+ return hasActiveItemRecursively(group.items, activePath)
59
+ }, [group.items, activePath])
60
+
61
+ const [open, setOpen] = React.useState(!group.collapsed)
62
+ const [markerIsMovingTimeout, setMarkerIsMovingTimeout] =
63
+ React.useState<NodeJS.Timeout>()
46
64
  const $groupElements = React.useRef<DocGroupElementsForward>(null)
47
- const $listWrapper = React.useRef<HTMLDivElement>(null)
48
65
 
49
- function toggleMenu(localOpen: boolean) {
50
- if (!collapsible) return
51
- hideShowAbsoluteMarker(localOpen)
66
+ const toggleMenu = (localOpen: boolean) => {
67
+ if (!collapsible || markerIsMoving) return
68
+ setMarkerIsMoving(true)
69
+ // on browsers than do not support transitionend event
70
+ // we need to set a timeout to remove the markerIsMoving
71
+ const timeout = setTimeout(function () {
72
+ setMarkerIsMoving(false)
73
+ }, 350)
74
+ setMarkerIsMovingTimeout(timeout)
52
75
  setOpen(localOpen)
53
76
  readjustMarkerPosition(localOpen)
54
77
  }
55
78
 
56
- const hasActiveItemRecursively = React.useCallback(
57
- (items = group.items): boolean => {
58
- return items.some((item) => {
59
- if ('items' in item) {
60
- return hasActiveItemRecursively(item.items)
61
- }
62
- return item.href === activePath
63
- })
64
- },
65
- [group.items, activePath],
66
- )
67
-
68
79
  const Head = collapsible ? 'button' : group.href ? 'a' : 'div'
69
80
 
70
81
  const setActivePosition = React.useCallback(
@@ -76,8 +87,6 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
76
87
  [onActivePosition, open],
77
88
  )
78
89
 
79
- const { setMarkerIsMoving } = React.useContext(MarkerIsMovingContext)
80
-
81
90
  function reTriggerSetActiveGroupParent() {
82
91
  $groupElements.current?.reTriggerSetActiveGroup()
83
92
  }
@@ -87,35 +96,25 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
87
96
  * We replace the absolute marker by one in the link. After the transition, the
88
97
  * marker is replaced by the absolute one again.
89
98
  */
90
- function hideShowAbsoluteMarker(localOpen: boolean) {
91
- $listWrapper.current?.addEventListener(
92
- 'transitionstart',
93
- () => {
94
- setMarkerIsMoving(true)
95
- },
96
- { once: true },
97
- )
98
- $listWrapper.current?.addEventListener(
99
- 'transitionend',
100
- () => {
101
- if (localOpen || !hasActiveItemRecursively()) {
102
- updateMarkerPosition?.()
103
- }
104
- setMarkerIsMoving(false)
105
- },
106
- { once: true },
107
- )
99
+ const restoreActiveMarkerAfterTransition = () => {
100
+ if (!markerIsMovingTimeout) {
101
+ clearTimeout(markerIsMovingTimeout)
102
+ }
103
+ if (open || !hasActiveItemRecursivelyMemo) {
104
+ updateMarkerPosition()
105
+ }
106
+ setMarkerIsMoving(false)
108
107
  }
109
108
 
110
109
  function readjustMarkerPosition(localOpen: boolean) {
111
- if (hasActiveItemRecursively()) {
110
+ if (hasActiveItemRecursivelyMemo) {
112
111
  if (localOpen) {
113
112
  reTriggerSetActiveGroupParent()
114
113
  } else {
115
114
  hideMarker()
116
115
  }
117
116
  } else {
118
- updateMarkerPosition?.()
117
+ updateMarkerPosition()
119
118
  }
120
119
  }
121
120
 
@@ -124,12 +123,12 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
124
123
  }))
125
124
 
126
125
  const onUpdateMarkerPosition = React.useCallback(() => {
127
- if (hasActiveItemRecursively()) {
126
+ if (hasActiveItemRecursivelyMemo) {
128
127
  reTriggerSetActiveGroupParent()
129
128
  } else {
130
129
  updateMarkerPosition?.()
131
130
  }
132
- }, [hasActiveItemRecursively, updateMarkerPosition])
131
+ }, [hasActiveItemRecursivelyMemo, updateMarkerPosition])
133
132
 
134
133
  return (
135
134
  <>
@@ -139,7 +138,11 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
139
138
  className={clsx(classes.button, {
140
139
  [classes.topButton]: depth === 0,
141
140
  [classes.leafButton]: depth,
142
- 'text-indigo-500': activePath === group.href,
141
+ 'text-indigo-500 dark:text-indigo-400': activePath === group.href,
142
+ 'text-gray-900 dark:text-gray-100':
143
+ hasActiveItemRecursivelyMemo && activePath !== group.href,
144
+ 'text-gray-800 dark:text-gray-200':
145
+ !hasActiveItemRecursivelyMemo && activePath !== group.href,
143
146
  })}
144
147
  >
145
148
  {collapsible ? (
@@ -156,11 +159,17 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
156
159
  {group.label}
157
160
  </Head>
158
161
  <div
159
- className={clsx('grid transition-all relative', {
160
- 'grid-rows-[0fr]': !open && collapsible,
161
- 'grid-rows-[1fr]': open || !collapsible,
162
- })}
163
- ref={$listWrapper}
162
+ className={clsx(
163
+ 'relative',
164
+ collapsible
165
+ ? {
166
+ 'transition-all grid': true,
167
+ 'grid-rows-[0fr]': !open,
168
+ 'grid-rows-[1fr]': open,
169
+ }
170
+ : null,
171
+ )}
172
+ onTransitionEnd={restoreActiveMarkerAfterTransition}
164
173
  >
165
174
  {open && collapsible && depth === 0 ? (
166
175
  <div className={classes.openListBorderLeft} />
@@ -169,13 +178,12 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
169
178
  ref={$groupElements}
170
179
  className="overflow-hidden"
171
180
  items={group.items}
172
- activePath={activePath}
173
- collapsible={collapsible}
174
181
  depth={depth}
182
+ context={context}
183
+ markerIsMoving={markerIsMoving}
175
184
  onActivePosition={setActivePosition}
176
185
  updateMarkerPosition={onUpdateMarkerPosition}
177
186
  LinkComponent={LinkComponent}
178
- hideMarker={hideMarker}
179
187
  />
180
188
  </div>
181
189
  </>
@@ -186,14 +194,13 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
186
194
  export interface DocGroupElementsProps
187
195
  extends React.HTMLAttributes<HTMLUListElement> {
188
196
  items: (NavGroup | NavItemLink)[]
189
- activePath: string
190
- collapsible: boolean
191
197
  onActivePosition: (opts: { top: number; height: number }) => void
198
+ markerIsMoving: boolean
192
199
  updateMarkerPosition?: () => void
193
200
  depth: number
194
201
  LinkComponent: LinkComponentType
195
- hideMarker: () => void
196
202
  className?: string
203
+ context: Context
197
204
  }
198
205
 
199
206
  export interface DocGroupElementsForward {
@@ -207,14 +214,13 @@ export const DocGroupElements = React.forwardRef<
207
214
  (
208
215
  {
209
216
  items,
210
- activePath,
211
- collapsible,
212
217
  depth = 0,
213
218
  onActivePosition,
214
219
  updateMarkerPosition,
220
+ markerIsMoving,
215
221
  LinkComponent,
216
- hideMarker,
217
222
  className,
223
+ context,
218
224
  ...rest
219
225
  },
220
226
  ref,
@@ -222,18 +228,6 @@ export const DocGroupElements = React.forwardRef<
222
228
  const $groups = React.useRef<DocGroupForward[]>([])
223
229
  const $items = React.useRef<DocLinkForward[]>([])
224
230
 
225
- const hasActiveItemRecursively = React.useCallback(
226
- (localItems = items): boolean => {
227
- return localItems.some((item) => {
228
- if ('items' in item) {
229
- return hasActiveItemRecursively(item.items)
230
- }
231
- return item.href === activePath
232
- })
233
- },
234
- [items, activePath],
235
- )
236
-
237
231
  const reTriggerSetActiveGroup = React.useCallback(
238
232
  (index: number = 0) => {
239
233
  $items.current.forEach((item) => {
@@ -260,15 +254,17 @@ export const DocGroupElements = React.forwardRef<
260
254
  reTriggerSetActiveGroup,
261
255
  }))
262
256
 
257
+ const { activePath, hideMarker } = context
258
+
263
259
  const onUpdateMarkerPosition = React.useCallback(
264
260
  (index: number) => {
265
- if (hasActiveItemRecursively()) {
261
+ if (hasActiveItemRecursively(items, activePath)) {
266
262
  reTriggerSetActiveGroup(index)
267
263
  } else {
268
264
  updateMarkerPosition?.()
269
265
  }
270
266
  },
271
- [hasActiveItemRecursively, updateMarkerPosition, reTriggerSetActiveGroup],
267
+ [updateMarkerPosition, reTriggerSetActiveGroup, items, activePath],
272
268
  )
273
269
 
274
270
  return (
@@ -281,11 +277,10 @@ export const DocGroupElements = React.forwardRef<
281
277
  $groups.current[index] = el
282
278
  }}
283
279
  group={item}
284
- activePath={activePath}
285
280
  depth={depth + 1}
286
- collapsible={collapsible}
287
281
  LinkComponent={LinkComponent}
288
- hideMarker={hideMarker}
282
+ markerIsMoving={markerIsMoving}
283
+ context={context}
289
284
  onActivePosition={onActivePosition}
290
285
  updateMarkerPosition={() => onUpdateMarkerPosition(index)}
291
286
  />
@@ -297,9 +292,9 @@ export const DocGroupElements = React.forwardRef<
297
292
  }}
298
293
  key={index}
299
294
  item={item}
300
- active={item.href === activePath}
301
- collapsible={collapsible}
302
295
  depth={depth}
296
+ markerIsMoving={markerIsMoving}
297
+ context={context}
303
298
  onActive={(opts) =>
304
299
  depth < 0 ? hideMarker() : onActivePosition(opts)
305
300
  }
package/_DocLink.tsx CHANGED
@@ -1,7 +1,13 @@
1
1
  import * as React from 'react'
2
2
  import clsx from 'clsx'
3
3
  import { NavItemLink } from '@cypress-design/constants-docmenu'
4
- import { MarkerIsMovingContext } from './markerIsMoving'
4
+
5
+ export interface Context {
6
+ setMarkerIsMoving: (markerIsMoving: boolean) => void
7
+ collapsible: boolean
8
+ activePath: string
9
+ hideMarker: () => void
10
+ }
5
11
 
6
12
  export type LinkComponentType = React.ElementType<{
7
13
  href: string
@@ -12,11 +18,11 @@ export type LinkComponentType = React.ElementType<{
12
18
 
13
19
  export interface DocLinkProps {
14
20
  item: NavItemLink
15
- active: boolean
16
- collapsible: boolean
17
- depth?: number
18
- onActive?: (opts: { top: number; height: number }) => void
19
- LinkComponent?: LinkComponentType
21
+ depth: number
22
+ markerIsMoving: boolean
23
+ context: Context
24
+ onActive: (opts: { top: number; height: number }) => void
25
+ LinkComponent: LinkComponentType
20
26
  }
21
27
 
22
28
  export interface DocLinkForward {
@@ -24,19 +30,18 @@ export interface DocLinkForward {
24
30
  }
25
31
 
26
32
  export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
27
- (
28
- { item, active, collapsible, depth = -1, onActive, LinkComponent = 'a' },
29
- ref,
30
- ) => {
33
+ ({ item, depth, markerIsMoving, context, onActive, LinkComponent }, ref) => {
31
34
  const activeLIRef = React.useRef<HTMLLIElement>(null)
32
35
 
33
- const { markerIsMoving } = React.useContext(MarkerIsMovingContext)
36
+ const { collapsible, activePath } = context
37
+
38
+ const active = item.href === activePath
34
39
 
35
40
  const setActiveMarkerPosition = () => {
36
41
  if (active) {
37
42
  const box = activeLIRef?.current?.getBoundingClientRect()
38
43
 
39
- onActive?.({
44
+ onActive({
40
45
  top: box?.top || 0,
41
46
  height: box?.height || 0,
42
47
  })
@@ -55,7 +60,7 @@ export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
55
60
  <li ref={activeLIRef} className="list-none p-0">
56
61
  <LinkComponent
57
62
  className={clsx('group relative block w-full pl-[24px]', {
58
- 'text-indigo-500': active,
63
+ 'text-indigo-500 dark:text-indigo-400': active,
59
64
  'text-gray-700 dark:text-gray-500': !active,
60
65
  'py-[8px] text-[16px] leading-[24px]': depth < 0,
61
66
  'leading-[20px] text-[14px] py-[12px]': depth >= 0,
@@ -72,7 +77,7 @@ export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
72
77
  {
73
78
  hidden: !markerIsMoving || !active,
74
79
  'group-hover:block bg-gray-300': !active && collapsible,
75
- 'bg-indigo-500': active && markerIsMoving,
80
+ 'bg-indigo-500 dark:bg-indigo-400': active && markerIsMoving,
76
81
  },
77
82
  )}
78
83
  />
@@ -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;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAInD,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,CAsE1C,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,CAuE1C,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -1,18 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import { type NavGroup, type NavItemLink } from '@cypress-design/constants-docmenu';
3
- import { type LinkComponentType } from './_DocLink';
3
+ import { type Context, type LinkComponentType } from './_DocLink';
4
4
  export interface DocGroupProps {
5
5
  group: NavGroup;
6
- activePath: string;
7
- collapsible: boolean;
6
+ context: Context;
8
7
  onActivePosition: (opts: {
9
8
  top: number;
10
9
  height: number;
11
10
  }) => void;
12
- updateMarkerPosition?: () => void;
11
+ updateMarkerPosition: () => void;
12
+ markerIsMoving: boolean;
13
13
  depth?: number;
14
14
  LinkComponent?: LinkComponentType;
15
- hideMarker: () => void;
16
15
  }
17
16
  export interface DocGroupForward {
18
17
  reTriggerSetActiveGroup: () => void;
@@ -20,17 +19,16 @@ export interface DocGroupForward {
20
19
  export declare const DocGroup: React.ForwardRefExoticComponent<DocGroupProps & React.RefAttributes<DocGroupForward>>;
21
20
  export interface DocGroupElementsProps extends React.HTMLAttributes<HTMLUListElement> {
22
21
  items: (NavGroup | NavItemLink)[];
23
- activePath: string;
24
- collapsible: boolean;
25
22
  onActivePosition: (opts: {
26
23
  top: number;
27
24
  height: number;
28
25
  }) => void;
26
+ markerIsMoving: boolean;
29
27
  updateMarkerPosition?: () => void;
30
28
  depth: number;
31
29
  LinkComponent: LinkComponentType;
32
- hideMarker: () => void;
33
30
  className?: string;
31
+ context: Context;
34
32
  }
35
33
  export interface DocGroupElementsForward {
36
34
  reTriggerSetActiveGroup: (index?: number) => void;
@@ -1 +1 @@
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;AAGnB,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,uFAyJpB,CAAA;AAED,MAAM,WAAW,qBACf,SAAQ,KA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AClC;AAED,MAAM,WAAW,eAAe;IAC9B,uBAAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAcD,eAAO,MAAM,QAAQ,uFAsJpB,CAAA;AAED,MAAM,WAAW,qBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAC9C,KAAK,EAAE,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,CAAA;IACjC,gBAAgB,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACjE,cAAc,EAAE,OAAO,CAAA;IACvB,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAA;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,iBAAiB,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC,uBAAuB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAClD;AAED,eAAO,MAAM,gBAAgB,uGAkG5B,CAAA"}
@@ -1,5 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { NavItemLink } from '@cypress-design/constants-docmenu';
3
+ export interface Context {
4
+ setMarkerIsMoving: (markerIsMoving: boolean) => void;
5
+ collapsible: boolean;
6
+ activePath: string;
7
+ hideMarker: () => void;
8
+ }
3
9
  export type LinkComponentType = React.ElementType<{
4
10
  href: string;
5
11
  className: string;
@@ -8,14 +14,14 @@ export type LinkComponentType = React.ElementType<{
8
14
  }>;
9
15
  export interface DocLinkProps {
10
16
  item: NavItemLink;
11
- active: boolean;
12
- collapsible: boolean;
13
- depth?: number;
14
- onActive?: (opts: {
17
+ depth: number;
18
+ markerIsMoving: boolean;
19
+ context: Context;
20
+ onActive: (opts: {
15
21
  top: number;
16
22
  height: number;
17
23
  }) => void;
18
- LinkComponent?: LinkComponentType;
24
+ LinkComponent: LinkComponentType;
19
25
  }
20
26
  export interface DocLinkForward {
21
27
  setActiveMarkerPosition: () => void;
@@ -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;AAG/D,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,KAAK,CAAC,aAAa,CAAA;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,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,qFA2DnB,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,WAAW,OAAO;IACtB,iBAAiB,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,IAAI,CAAA;IACpD,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,U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