@colisweb/rescript-toolkit 4.11.3 → 4.12.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "4.11.3",
3
+ "version": "4.12.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -210,7 +210,7 @@ module Make = (Config: RouterConfig) => {
210
210
  and groupInfo = {
211
211
  label: React.element,
212
212
  icon: React.element,
213
- activeForCurrentRoute?: Config.t => bool,
213
+ hideContentWhenClosed?: bool,
214
214
  }
215
215
  and appLink = {
216
216
  route: Config.t,
@@ -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
- {links
392
- ->Array.mapWithIndex((i, link) => {
393
- let isActive = switch (relativeRoute, link) {
394
- | (Some(App({route: relativeRoute})), App({route})) =>
395
- relativeRoute->isRouteEqual(route)
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
  }