@cypress-design/react-docmenu 0.5.2 → 0.5.4

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.
@@ -2,5 +2,5 @@ $ yarn build:module && yarn build:types
2
2
  $ rollup -c ./rollup.config.mjs
3
3
  
4
4
  ./index.ts → ./dist/index.umd.js, ./dist/index.es.mjs...
5
- created ./dist/index.umd.js, ./dist/index.es.mjs in 12.9s
5
+ created ./dist/index.umd.js, ./dist/index.es.mjs in 11.7s
6
6
  $ tsc --project ./tsconfig.build.json
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @cypress-design/react-docmenu
2
2
 
3
+ ## 0.5.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`fe2f9f0`](https://github.com/cypress-io/cypress-design/commit/fe2f9f0435117454b3d81ce22ec3e9258330a725) Thanks [@elevatebart](https://github.com/elevatebart)! - make margin of button on depth button
8
+
9
+ ## 0.5.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`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
14
+
3
15
  ## 0.5.2
4
16
 
5
17
  ### 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
 
@@ -161,7 +163,11 @@ describe('<DocMenu/>', () => {
161
163
  })
162
164
 
163
165
  function mountStory(items: (NavItemLink | NavGroup)[] = [], activePath = '') {
164
- mount(<DocMenu items={items} activePath={activePath} />)
166
+ mount(
167
+ <div className="p-4">
168
+ <DocMenu items={items} activePath={activePath} />
169
+ </div>,
170
+ )
165
171
  }
166
172
  assertions(mountStory)
167
173
  })
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,8 +138,15 @@ 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
  })}
147
+ style={{
148
+ paddingLeft: depth >= 1 ? `${(depth - 1) * 12 + 48}px` : undefined,
149
+ }}
144
150
  >
145
151
  {collapsible ? (
146
152
  <IconChevronDownSmall
@@ -149,18 +155,27 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
149
155
  className={clsx(classes.expandedIcon, {
150
156
  'rotate-0': open,
151
157
  '-rotate-90': !open,
152
- 'ml-[28px]': depth,
153
158
  })}
159
+ style={{
160
+ marginLeft:
161
+ depth >= 1 ? `${(depth - 1) * 12 + 28}px` : undefined,
162
+ }}
154
163
  />
155
164
  ) : null}
156
165
  {group.label}
157
166
  </Head>
158
167
  <div
159
- className={clsx('grid transition-all relative', {
160
- 'grid-rows-[0fr]': !open && collapsible,
161
- 'grid-rows-[1fr]': open || !collapsible,
162
- })}
163
- ref={$listWrapper}
168
+ className={clsx(
169
+ 'relative',
170
+ collapsible
171
+ ? {
172
+ 'transition-all grid': true,
173
+ 'grid-rows-[0fr]': !open,
174
+ 'grid-rows-[1fr]': open,
175
+ }
176
+ : null,
177
+ )}
178
+ onTransitionEnd={restoreActiveMarkerAfterTransition}
164
179
  >
165
180
  {open && collapsible && depth === 0 ? (
166
181
  <div className={classes.openListBorderLeft} />
@@ -169,13 +184,12 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
169
184
  ref={$groupElements}
170
185
  className="overflow-hidden"
171
186
  items={group.items}
172
- activePath={activePath}
173
- collapsible={collapsible}
174
187
  depth={depth}
188
+ context={context}
189
+ markerIsMoving={markerIsMoving}
175
190
  onActivePosition={setActivePosition}
176
191
  updateMarkerPosition={onUpdateMarkerPosition}
177
192
  LinkComponent={LinkComponent}
178
- hideMarker={hideMarker}
179
193
  />
180
194
  </div>
181
195
  </>
@@ -186,14 +200,13 @@ export const DocGroup = React.forwardRef<DocGroupForward, DocGroupProps>(
186
200
  export interface DocGroupElementsProps
187
201
  extends React.HTMLAttributes<HTMLUListElement> {
188
202
  items: (NavGroup | NavItemLink)[]
189
- activePath: string
190
- collapsible: boolean
191
203
  onActivePosition: (opts: { top: number; height: number }) => void
204
+ markerIsMoving: boolean
192
205
  updateMarkerPosition?: () => void
193
206
  depth: number
194
207
  LinkComponent: LinkComponentType
195
- hideMarker: () => void
196
208
  className?: string
209
+ context: Context
197
210
  }
198
211
 
199
212
  export interface DocGroupElementsForward {
@@ -207,14 +220,13 @@ export const DocGroupElements = React.forwardRef<
207
220
  (
208
221
  {
209
222
  items,
210
- activePath,
211
- collapsible,
212
223
  depth = 0,
213
224
  onActivePosition,
214
225
  updateMarkerPosition,
226
+ markerIsMoving,
215
227
  LinkComponent,
216
- hideMarker,
217
228
  className,
229
+ context,
218
230
  ...rest
219
231
  },
220
232
  ref,
@@ -222,18 +234,6 @@ export const DocGroupElements = React.forwardRef<
222
234
  const $groups = React.useRef<DocGroupForward[]>([])
223
235
  const $items = React.useRef<DocLinkForward[]>([])
224
236
 
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
237
  const reTriggerSetActiveGroup = React.useCallback(
238
238
  (index: number = 0) => {
239
239
  $items.current.forEach((item) => {
@@ -260,15 +260,17 @@ export const DocGroupElements = React.forwardRef<
260
260
  reTriggerSetActiveGroup,
261
261
  }))
262
262
 
263
+ const { activePath, hideMarker } = context
264
+
263
265
  const onUpdateMarkerPosition = React.useCallback(
264
266
  (index: number) => {
265
- if (hasActiveItemRecursively()) {
267
+ if (hasActiveItemRecursively(items, activePath)) {
266
268
  reTriggerSetActiveGroup(index)
267
269
  } else {
268
270
  updateMarkerPosition?.()
269
271
  }
270
272
  },
271
- [hasActiveItemRecursively, updateMarkerPosition, reTriggerSetActiveGroup],
273
+ [updateMarkerPosition, reTriggerSetActiveGroup, items, activePath],
272
274
  )
273
275
 
274
276
  return (
@@ -281,11 +283,10 @@ export const DocGroupElements = React.forwardRef<
281
283
  $groups.current[index] = el
282
284
  }}
283
285
  group={item}
284
- activePath={activePath}
285
286
  depth={depth + 1}
286
- collapsible={collapsible}
287
287
  LinkComponent={LinkComponent}
288
- hideMarker={hideMarker}
288
+ markerIsMoving={markerIsMoving}
289
+ context={context}
289
290
  onActivePosition={onActivePosition}
290
291
  updateMarkerPosition={() => onUpdateMarkerPosition(index)}
291
292
  />
@@ -297,9 +298,9 @@ export const DocGroupElements = React.forwardRef<
297
298
  }}
298
299
  key={index}
299
300
  item={item}
300
- active={item.href === activePath}
301
- collapsible={collapsible}
302
301
  depth={depth}
302
+ markerIsMoving={markerIsMoving}
303
+ context={context}
303
304
  onActive={(opts) =>
304
305
  depth < 0 ? hideMarker() : onActivePosition(opts)
305
306
  }
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 {
@@ -25,18 +31,27 @@ export interface DocLinkForward {
25
31
 
26
32
  export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
27
33
  (
28
- { item, active, collapsible, depth = -1, onActive, LinkComponent = 'a' },
34
+ {
35
+ item: { label, ...itemRest },
36
+ depth,
37
+ markerIsMoving,
38
+ context,
39
+ onActive,
40
+ LinkComponent,
41
+ },
29
42
  ref,
30
43
  ) => {
31
44
  const activeLIRef = React.useRef<HTMLLIElement>(null)
32
45
 
33
- const { markerIsMoving } = React.useContext(MarkerIsMovingContext)
46
+ const { collapsible, activePath } = context
47
+
48
+ const active = itemRest.href === activePath
34
49
 
35
50
  const setActiveMarkerPosition = () => {
36
51
  if (active) {
37
52
  const box = activeLIRef?.current?.getBoundingClientRect()
38
53
 
39
- onActive?.({
54
+ onActive({
40
55
  top: box?.top || 0,
41
56
  height: box?.height || 0,
42
57
  })
@@ -54,13 +69,13 @@ export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
54
69
  return (
55
70
  <li ref={activeLIRef} className="list-none p-0">
56
71
  <LinkComponent
72
+ {...itemRest}
57
73
  className={clsx('group relative block w-full pl-[24px]', {
58
- 'text-indigo-500': active,
74
+ 'text-indigo-500 dark:text-indigo-400': active,
59
75
  'text-gray-700 dark:text-gray-500': !active,
60
76
  'py-[8px] text-[16px] leading-[24px]': depth < 0,
61
77
  'leading-[20px] text-[14px] py-[12px]': depth >= 0,
62
78
  })}
63
- href={item.href}
64
79
  style={{
65
80
  paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,
66
81
  }}
@@ -72,12 +87,12 @@ export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
72
87
  {
73
88
  hidden: !markerIsMoving || !active,
74
89
  'group-hover:block bg-gray-300': !active && collapsible,
75
- 'bg-indigo-500': active && markerIsMoving,
90
+ 'bg-indigo-500 dark:bg-indigo-400': active && markerIsMoving,
76
91
  },
77
92
  )}
78
93
  />
79
94
  ) : null}
80
- {item.label}
95
+ {label}
81
96
  </LinkComponent>
82
97
  </li>
83
98
  )
@@ -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,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,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,uBAAuB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAClD;AAED,eAAO,MAAM,gBAAgB,uGA8G5B,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,EAEL,KAAK,OAAO,EAEZ,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,QAAQ,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,gBAAgB,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACjE,oBAAoB,EAAE,MAAM,IAAI,CAAA;IAChC,cAAc,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,iBAAiB,CAAA;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,uBAAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAcD,eAAO,MAAM,QAAQ,uFA4JpB,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,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,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,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,OAAO,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACzD,aAAa,EAAE,iBAAiB,CAAA;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B,uBAAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAED,eAAO,MAAM,OAAO,qFAoEnB,CAAA"}