@colisweb/rescript-toolkit 4.11.3 → 4.12.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/package.json +1 -1
- package/src/router/Toolkit__Router.res +29 -19
package/package.json
CHANGED
|
@@ -210,7 +210,7 @@ module Make = (Config: RouterConfig) => {
|
|
|
210
210
|
and groupInfo = {
|
|
211
211
|
label: React.element,
|
|
212
212
|
icon: React.element,
|
|
213
|
-
|
|
213
|
+
hideContentWhenClosed?: bool,
|
|
214
214
|
}
|
|
215
215
|
and appLink = {
|
|
216
216
|
route: Config.t,
|
|
@@ -282,7 +282,7 @@ module Make = (Config: RouterConfig) => {
|
|
|
282
282
|
"sidenav-link",
|
|
283
283
|
isActive && !disabledActiveLink ? "bg-primary-100/75 text-neutral-700" : "",
|
|
284
284
|
])}
|
|
285
|
-
activeClassName="bg-primary-100/75 text-neutral-700"
|
|
285
|
+
activeClassName={disabledActiveLink ? "" : "bg-primary-100/75 text-neutral-700"}
|
|
286
286
|
onClick={_ => onLinkClick()}>
|
|
287
287
|
<span className="overflow-hidden flex">
|
|
288
288
|
{config.icon->Option.mapWithDefault(React.null, icon =>
|
|
@@ -308,6 +308,28 @@ module Make = (Config: RouterConfig) => {
|
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
module GroupedLinks = {
|
|
311
|
+
module LinksList = {
|
|
312
|
+
@react.component
|
|
313
|
+
let make = (~links, ~relativeRoute, ~isNavOpen, ~onLinkClick) => {
|
|
314
|
+
links
|
|
315
|
+
->Array.mapWithIndex((i, link) => {
|
|
316
|
+
let isActive = switch (relativeRoute, link) {
|
|
317
|
+
| (Some(App({route: relativeRoute})), App({route})) => relativeRoute->isRouteEqual(route)
|
|
318
|
+
| _ => false
|
|
319
|
+
}
|
|
320
|
+
<SingleLink
|
|
321
|
+
key={"sidenav-grouped-" ++ i->Int.toString}
|
|
322
|
+
link
|
|
323
|
+
isNavOpen
|
|
324
|
+
isSubLink=true
|
|
325
|
+
onLinkClick
|
|
326
|
+
isActive
|
|
327
|
+
/>
|
|
328
|
+
})
|
|
329
|
+
->React.array
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
311
333
|
@react.component
|
|
312
334
|
let make = (
|
|
313
335
|
~groupInfo: groupInfo,
|
|
@@ -388,23 +410,11 @@ module Make = (Config: RouterConfig) => {
|
|
|
388
410
|
"transition ease-linear duration-300",
|
|
389
411
|
isOpen ? "h-auto" : "h-0 overflow-hidden",
|
|
390
412
|
])}>
|
|
391
|
-
{
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
| _ => false
|
|
397
|
-
}
|
|
398
|
-
<SingleLink
|
|
399
|
-
key={"sidenav-grouped-" ++ i->Int.toString}
|
|
400
|
-
link
|
|
401
|
-
isNavOpen
|
|
402
|
-
isSubLink=true
|
|
403
|
-
onLinkClick
|
|
404
|
-
isActive
|
|
405
|
-
/>
|
|
406
|
-
})
|
|
407
|
-
->React.array}
|
|
413
|
+
{switch groupInfo.hideContentWhenClosed {
|
|
414
|
+
| Some(true) =>
|
|
415
|
+
isOpen ? <LinksList links relativeRoute onLinkClick isNavOpen /> : React.null
|
|
416
|
+
| _ => <LinksList links relativeRoute onLinkClick isNavOpen />
|
|
417
|
+
}}
|
|
408
418
|
</div>
|
|
409
419
|
</>
|
|
410
420
|
}
|