@natoora-libs/drawer-menu 0.0.7 → 0.0.8

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/dist/index.d.cts CHANGED
@@ -10,26 +10,35 @@ interface LeftDrawerProps {
10
10
  last_name: string;
11
11
  username: string;
12
12
  };
13
+ reloadOnNavigate?: boolean;
13
14
  handleOpen: () => void;
14
15
  handleClose: () => void;
15
16
  onLogout: () => void;
16
17
  onTogglePinnedApp: (name: string, new_value: boolean) => void;
17
18
  }
18
- declare const LeftDrawer: ({ enabledFeatures, pinnedApps, open, user, handleClose, handleOpen, onLogout, onTogglePinnedApp, }: LeftDrawerProps) => react_jsx_runtime.JSX.Element;
19
+ declare const LeftDrawer: ({ enabledFeatures, pinnedApps, open, user, reloadOnNavigate, handleClose, handleOpen, onLogout, onTogglePinnedApp, }: LeftDrawerProps) => react_jsx_runtime.JSX.Element;
19
20
 
20
- declare const useGetDrawerAppList: (enabledFeatures: string[]) => ({
21
- apps: any[];
22
- groupName: string;
23
- } | {
24
- apps: any[];
25
- groupName: string;
26
- } | {
27
- apps: any[];
28
- groupName: string;
29
- } | {
30
- apps: any[];
21
+ interface DrawerAppChild {
22
+ name: string;
23
+ routeName: string;
24
+ pinned: string;
25
+ url: string;
26
+ featureName?: string;
27
+ shouldReload?: boolean;
28
+ }
29
+ declare const useGetDrawerAppList: (enabledFeatures: string[]) => {
30
+ apps: {
31
+ children: DrawerAppChild[] | undefined;
32
+ name: string;
33
+ routeName: string;
34
+ featureNames: string[];
35
+ pinned: string | null;
36
+ icon: React.ReactElement;
37
+ url: string;
38
+ shouldReload?: boolean;
39
+ }[];
31
40
  groupName: string;
32
- })[];
41
+ }[];
33
42
 
34
43
  declare const featureNames: {
35
44
  ACCOUNTS: string;
@@ -75,15 +84,8 @@ declare const uiFeatureNames: {
75
84
  CUSTOMER_ESTIMATED_BASKET_SETTING: string;
76
85
  ORDER_ISSUE_REPORTING: string;
77
86
  CUSTOMER_PAYMENTS_SECTION: string;
78
- CUSTOMER_DASHBOARD_TAB: string;
79
- CUSTOMER_DETAILS_TAB: string;
80
- CUSTOMER_TRANSPORT_TAB: string;
81
- CUSTOMER_FINANCE_TAB: string;
82
- CUSTOMER_ACTIVITY_TAB: string;
83
- CUSTOMER_APP_TAB: string;
84
- CUSTOMER_STANDING_ORDERS_TAB: string;
85
- CUSTOMER_SUBSTITUTIONS_TAB: string;
86
87
  CUSTOMER_PREFERENCES_TAB: string;
88
+ CUSTOMER_SUBSTITUTIONS_TAB: string;
87
89
  PRODUCT_PREFERENCES_SECTION: string;
88
90
  };
89
91
  declare const uiFeaturesAreEnabled: (enabledUIFeatures: string[] | undefined, feature: string) => boolean | undefined;
package/dist/index.d.ts CHANGED
@@ -10,26 +10,35 @@ interface LeftDrawerProps {
10
10
  last_name: string;
11
11
  username: string;
12
12
  };
13
+ reloadOnNavigate?: boolean;
13
14
  handleOpen: () => void;
14
15
  handleClose: () => void;
15
16
  onLogout: () => void;
16
17
  onTogglePinnedApp: (name: string, new_value: boolean) => void;
17
18
  }
18
- declare const LeftDrawer: ({ enabledFeatures, pinnedApps, open, user, handleClose, handleOpen, onLogout, onTogglePinnedApp, }: LeftDrawerProps) => react_jsx_runtime.JSX.Element;
19
+ declare const LeftDrawer: ({ enabledFeatures, pinnedApps, open, user, reloadOnNavigate, handleClose, handleOpen, onLogout, onTogglePinnedApp, }: LeftDrawerProps) => react_jsx_runtime.JSX.Element;
19
20
 
20
- declare const useGetDrawerAppList: (enabledFeatures: string[]) => ({
21
- apps: any[];
22
- groupName: string;
23
- } | {
24
- apps: any[];
25
- groupName: string;
26
- } | {
27
- apps: any[];
28
- groupName: string;
29
- } | {
30
- apps: any[];
21
+ interface DrawerAppChild {
22
+ name: string;
23
+ routeName: string;
24
+ pinned: string;
25
+ url: string;
26
+ featureName?: string;
27
+ shouldReload?: boolean;
28
+ }
29
+ declare const useGetDrawerAppList: (enabledFeatures: string[]) => {
30
+ apps: {
31
+ children: DrawerAppChild[] | undefined;
32
+ name: string;
33
+ routeName: string;
34
+ featureNames: string[];
35
+ pinned: string | null;
36
+ icon: React.ReactElement;
37
+ url: string;
38
+ shouldReload?: boolean;
39
+ }[];
31
40
  groupName: string;
32
- })[];
41
+ }[];
33
42
 
34
43
  declare const featureNames: {
35
44
  ACCOUNTS: string;
@@ -75,15 +84,8 @@ declare const uiFeatureNames: {
75
84
  CUSTOMER_ESTIMATED_BASKET_SETTING: string;
76
85
  ORDER_ISSUE_REPORTING: string;
77
86
  CUSTOMER_PAYMENTS_SECTION: string;
78
- CUSTOMER_DASHBOARD_TAB: string;
79
- CUSTOMER_DETAILS_TAB: string;
80
- CUSTOMER_TRANSPORT_TAB: string;
81
- CUSTOMER_FINANCE_TAB: string;
82
- CUSTOMER_ACTIVITY_TAB: string;
83
- CUSTOMER_APP_TAB: string;
84
- CUSTOMER_STANDING_ORDERS_TAB: string;
85
- CUSTOMER_SUBSTITUTIONS_TAB: string;
86
87
  CUSTOMER_PREFERENCES_TAB: string;
88
+ CUSTOMER_SUBSTITUTIONS_TAB: string;
87
89
  PRODUCT_PREFERENCES_SECTION: string;
88
90
  };
89
91
  declare const uiFeaturesAreEnabled: (enabledUIFeatures: string[] | undefined, feature: string) => boolean | undefined;
package/dist/index.js CHANGED
@@ -326,7 +326,6 @@ var drawerAppList = [
326
326
  {
327
327
  name: "Home",
328
328
  routeName: "home",
329
- alwaysDisplay: true,
330
329
  featureNames: [],
331
330
  pinned: null,
332
331
  icon: /* @__PURE__ */ jsx(icons.SvgIconHome, {}),
@@ -340,7 +339,6 @@ var drawerAppList = [
340
339
  {
341
340
  name: "Notifications",
342
341
  routeName: "appNotifications",
343
- alwaysDisplay: false,
344
342
  featureNames: [featureNames.NOTIFICATIONS],
345
343
  pinned: "notifications",
346
344
  icon: /* @__PURE__ */ jsx(icons.SvgIconNotification, {}),
@@ -350,7 +348,6 @@ var drawerAppList = [
350
348
  {
351
349
  name: "Promo Codes",
352
350
  routeName: "promo_codes",
353
- alwaysDisplay: false,
354
351
  featureNames: [featureNames.PROMO_CODES],
355
352
  pinned: "promo_codes",
356
353
  icon: /* @__PURE__ */ jsx(icons.SvgIconPromoCode, {}),
@@ -359,7 +356,6 @@ var drawerAppList = [
359
356
  {
360
357
  name: "Search Categories",
361
358
  routeName: "search-categories",
362
- alwaysDisplay: false,
363
359
  featureNames: [featureNames.SEARCH_CATEGORIES],
364
360
  pinned: "search_categories",
365
361
  icon: /* @__PURE__ */ jsx(icons.SvgIconSearchCategories, {}),
@@ -368,7 +364,6 @@ var drawerAppList = [
368
364
  {
369
365
  name: "Content Management",
370
366
  routeName: "content-management",
371
- alwaysDisplay: false,
372
367
  featureNames: [featureNames.CONTENT_MANAGEMENT],
373
368
  pinned: "content_management",
374
369
  icon: /* @__PURE__ */ jsx(icons.SvgIconContentManagement, {}),
@@ -382,7 +377,6 @@ var drawerAppList = [
382
377
  {
383
378
  name: "Aircall",
384
379
  routeName: "recordedcalls",
385
- alwaysDisplay: false,
386
380
  featureNames: [featureNames.AIRCALL],
387
381
  pinned: "aircall",
388
382
  icon: /* @__PURE__ */ jsx(icons.SvgIconPhone, {}),
@@ -391,7 +385,6 @@ var drawerAppList = [
391
385
  {
392
386
  name: "Customers",
393
387
  routeName: "customers",
394
- alwaysDisplay: false,
395
388
  featureNames: [featureNames.CUSTOMERS],
396
389
  pinned: "customers",
397
390
  icon: /* @__PURE__ */ jsx(icons.SvgIconAccount, {}),
@@ -414,7 +407,6 @@ var drawerAppList = [
414
407
  {
415
408
  name: "Orders",
416
409
  routeName: "orders",
417
- alwaysDisplay: false,
418
410
  featureNames: [featureNames.ORDERS],
419
411
  pinned: "orders",
420
412
  icon: /* @__PURE__ */ jsx(icons.SvgIconOrders, {}),
@@ -424,7 +416,6 @@ var drawerAppList = [
424
416
  {
425
417
  name: "Price Lists",
426
418
  routeName: "price_list",
427
- alwaysDisplay: false,
428
419
  featureNames: [featureNames.PRICE_LIST],
429
420
  pinned: "price_list",
430
421
  icon: /* @__PURE__ */ jsx(icons.SvgIconPriceList, {}),
@@ -434,7 +425,6 @@ var drawerAppList = [
434
425
  {
435
426
  name: "Special Prices",
436
427
  routeName: "special_prices",
437
- alwaysDisplay: false,
438
428
  featureNames: [featureNames.SPECIAL_PRICES],
439
429
  pinned: "special_prices",
440
430
  icon: /* @__PURE__ */ jsx(icons.SvgIconSpecialPrice, {}),
@@ -449,7 +439,6 @@ var drawerAppList = [
449
439
  {
450
440
  name: "Purchase Orders",
451
441
  routeName: "purchaseOrders",
452
- alwaysDisplay: false,
453
442
  featureNames: [featureNames.PURCHASE_ORDERS],
454
443
  pinned: "purchase_orders",
455
444
  icon: /* @__PURE__ */ jsx(icons.SvgIconBuying, {}),
@@ -459,7 +448,6 @@ var drawerAppList = [
459
448
  {
460
449
  name: "Products",
461
450
  routeName: "products",
462
- alwaysDisplay: false,
463
451
  featureNames: [featureNames.PRODUCTS],
464
452
  pinned: "products",
465
453
  icon: /* @__PURE__ */ jsx(icons.SvgIconProducts, {}),
@@ -469,7 +457,6 @@ var drawerAppList = [
469
457
  {
470
458
  name: "Suppliers",
471
459
  routeName: "suppliers",
472
- alwaysDisplay: false,
473
460
  featureNames: [featureNames.SUPPLIERS],
474
461
  pinned: "suppliers",
475
462
  icon: /* @__PURE__ */ jsx(icons.SvgIconSupplier, {}),
@@ -478,7 +465,6 @@ var drawerAppList = [
478
465
  {
479
466
  name: "Supplier Prices",
480
467
  routeName: "supplier_prices",
481
- alwaysDisplay: false,
482
468
  featureNames: [featureNames.SUPPLIER_PRICES],
483
469
  pinned: "supplier_prices",
484
470
  icon: /* @__PURE__ */ jsx(icons.SvgIconSupplierPrices, {}),
@@ -488,7 +474,6 @@ var drawerAppList = [
488
474
  {
489
475
  name: "Product Bulk Update",
490
476
  routeName: "bulk-update",
491
- alwaysDisplay: false,
492
477
  featureNames: [featureNames.BULK_UPDATE],
493
478
  pinned: "product_bulk_update",
494
479
  icon: /* @__PURE__ */ jsx(icons.SvgIconImport, {}),
@@ -502,7 +487,6 @@ var drawerAppList = [
502
487
  {
503
488
  name: "Retail",
504
489
  routeName: "retail",
505
- alwaysDisplay: false,
506
490
  featureNames: [featureNames.RETAIL],
507
491
  pinned: "retail",
508
492
  icon: /* @__PURE__ */ jsx(icons.SvgIconRetail, {}),
@@ -512,7 +496,6 @@ var drawerAppList = [
512
496
  {
513
497
  name: "Goods In",
514
498
  routeName: "goodsin-list",
515
- alwaysDisplay: false,
516
499
  featureNames: [featureNames.GOODS_IN],
517
500
  pinned: "goods_in",
518
501
  icon: /* @__PURE__ */ jsx(icons.SvgIconGoodsin, {}),
@@ -521,24 +504,23 @@ var drawerAppList = [
521
504
  {
522
505
  name: "Returns",
523
506
  routeName: "goods-in-list",
524
- alwaysDisplay: false,
525
507
  featureNames: [featureNames.RETURNS],
526
508
  pinned: "returns",
527
509
  icon: /* @__PURE__ */ jsx(icons.SvgIconGoodsin, {}),
528
510
  url: "/returns"
529
511
  },
530
512
  {
531
- icon: /* @__PURE__ */ jsx(icons.SvgIconLocation, {}),
532
513
  name: "Stock and Locations",
533
- pinned: "stock",
534
514
  routeName: "locations",
535
515
  featureNames: [featureNames.STOCK, featureNames.LOCATIONS],
536
- alwaysDisplay: false,
516
+ pinned: "stock",
517
+ icon: /* @__PURE__ */ jsx(icons.SvgIconLocation, {}),
537
518
  url: "/locations",
538
519
  children: [
539
520
  {
540
521
  name: "Movements",
541
522
  routeName: "movements",
523
+ pinned: "movements",
542
524
  url: "/movements",
543
525
  featureName: featureNames.STOCK_MOVEMENTS
544
526
  }
@@ -547,7 +529,6 @@ var drawerAppList = [
547
529
  {
548
530
  name: "Kanban Cards",
549
531
  routeName: "kanban",
550
- alwaysDisplay: false,
551
532
  featureNames: [featureNames.KANBAN],
552
533
  pinned: "kanban_cards",
553
534
  icon: /* @__PURE__ */ jsx(icons.SvgIconVkc, {}),
@@ -557,7 +538,6 @@ var drawerAppList = [
557
538
  {
558
539
  name: "Picking Stations",
559
540
  routeName: "picking",
560
- alwaysDisplay: false,
561
541
  featureNames: [featureNames.PICKING_STATIONS],
562
542
  pinned: "picking_stations",
563
543
  icon: /* @__PURE__ */ jsx(icons.SvgIconScales, {}),
@@ -567,7 +547,6 @@ var drawerAppList = [
567
547
  {
568
548
  name: "Quality Control",
569
549
  routeName: "qualityControl",
570
- alwaysDisplay: false,
571
550
  featureNames: [featureNames.QUALITY_CONTROL],
572
551
  pinned: "quality_control",
573
552
  icon: /* @__PURE__ */ jsx(icons.SvgIconQc, {}),
@@ -577,7 +556,6 @@ var drawerAppList = [
577
556
  {
578
557
  name: "Service Delivery",
579
558
  routeName: "runs",
580
- alwaysDisplay: false,
581
559
  featureNames: [featureNames.SERVICE_DELIVERY],
582
560
  pinned: "service_delivery",
583
561
  icon: /* @__PURE__ */ jsx(icons.SvgIconRuns, {}),
@@ -587,7 +565,6 @@ var drawerAppList = [
587
565
  {
588
566
  name: "Ops Metrics",
589
567
  routeName: "ops-metrics",
590
- alwaysDisplay: false,
591
568
  featureNames: [featureNames.OPS_METRICS],
592
569
  pinned: "ops_metrics",
593
570
  icon: /* @__PURE__ */ jsx(icons.SvgIconOpsMetrics, {}),
@@ -601,7 +578,6 @@ var drawerAppList = [
601
578
  {
602
579
  name: "Accounts",
603
580
  routeName: "accounts",
604
- alwaysDisplay: false,
605
581
  featureNames: [featureNames.ACCOUNTS],
606
582
  pinned: "accounts",
607
583
  icon: /* @__PURE__ */ jsx(icons.SvgIconAccounts, {}),
@@ -611,7 +587,6 @@ var drawerAppList = [
611
587
  {
612
588
  name: "Reports",
613
589
  routeName: "reports",
614
- alwaysDisplay: false,
615
590
  featureNames: [featureNames.REPORTS],
616
591
  pinned: "reports",
617
592
  icon: /* @__PURE__ */ jsx(icons.SvgIconReports, {}),
@@ -626,7 +601,6 @@ var drawerAppList = [
626
601
  {
627
602
  name: "Admin",
628
603
  routeName: "admin",
629
- alwaysDisplay: false,
630
604
  featureNames: [featureNames.ADMIN],
631
605
  pinned: "admin",
632
606
  icon: /* @__PURE__ */ jsx(icons.SvgIconSetting, {}),
@@ -636,7 +610,6 @@ var drawerAppList = [
636
610
  {
637
611
  name: "User Management",
638
612
  routeName: "user-management",
639
- alwaysDisplay: false,
640
613
  featureNames: [featureNames.USER_MANAGEMENT],
641
614
  pinned: "users",
642
615
  icon: /* @__PURE__ */ jsx(icons.SvgIconUserManagement, {}),
@@ -645,7 +618,6 @@ var drawerAppList = [
645
618
  {
646
619
  name: "Logout",
647
620
  routeName: "logout",
648
- alwaysDisplay: true,
649
621
  featureNames: [],
650
622
  pinned: null,
651
623
  icon: /* @__PURE__ */ jsx(icons.SvgIconLogin, {}),
@@ -659,7 +631,6 @@ var drawerAppList = [
659
631
  {
660
632
  name: "Release Notes",
661
633
  routeName: "release-notes",
662
- alwaysDisplay: true,
663
634
  featureNames: [],
664
635
  pinned: null,
665
636
  // icon: <icons.SvgIconReleaseNote />,
@@ -677,24 +648,19 @@ var useGetDrawerAppList = (enabledFeatures) => {
677
648
  }
678
649
  return drawerAppList.map((group) => {
679
650
  const enabledApps = group.apps.filter(
680
- (app) => app.alwaysDisplay || featuresAreEnabled({
651
+ (app) => app.routeName === "home" || app.routeName === "release-notes" || app.routeName === "logout" || featuresAreEnabled({
681
652
  enabledFeatures,
682
653
  featureNames: app.featureNames,
683
654
  requireAll: false
684
655
  })
685
656
  ).map((app) => {
686
- if (app.children) {
687
- const filteredChildren = app.children.filter(
688
- (child) => {
689
- if (child.featureName) {
690
- return enabledFeatures.includes(child.featureName);
691
- }
692
- return true;
693
- }
694
- );
695
- return { ...app, children: filteredChildren };
696
- }
697
- return app;
657
+ const filteredChildren = app.children?.filter((child) => {
658
+ if (child.featureName) {
659
+ return enabledFeatures.includes(child.featureName);
660
+ }
661
+ return true;
662
+ });
663
+ return { ...app, children: filteredChildren };
698
664
  });
699
665
  return { ...group, apps: enabledApps };
700
666
  }).filter((group) => group.apps.length > 0);
@@ -708,16 +674,6 @@ var useStyles = makeStyles()((theme) => ({
708
674
  textTransform: "uppercase",
709
675
  fontSize: theme.spacing(1.5)
710
676
  },
711
- menuButton: {
712
- marginRight: theme.spacing(2)
713
- },
714
- inputRoot: {
715
- color: "inherit"
716
- },
717
- inputInput: {
718
- transition: theme.transitions.create("width"),
719
- width: "100%"
720
- },
721
677
  topBar: {
722
678
  backgroundColor: theme.palette.secondary.dark,
723
679
  width: theme.spacing(40),
@@ -731,18 +687,6 @@ var useStyles = makeStyles()((theme) => ({
731
687
  flexDirection: "column",
732
688
  minWidth: theme.spacing(80)
733
689
  },
734
- drawerBody: {
735
- minWidth: "300px",
736
- flexGrow: 1,
737
- padding: theme.spacing(3)
738
- },
739
- drawerItem: {
740
- width: "300px",
741
- marginBottom: theme.spacing(1)
742
- },
743
- button: {
744
- color: theme.palette.primary.contrastText
745
- },
746
690
  iconMenu: {
747
691
  height: "40px",
748
692
  width: "40px",
@@ -779,6 +723,7 @@ var LeftDrawer = ({
779
723
  pinnedApps,
780
724
  open,
781
725
  user,
726
+ reloadOnNavigate,
782
727
  handleClose,
783
728
  handleOpen,
784
729
  onLogout,
@@ -789,7 +734,7 @@ var LeftDrawer = ({
789
734
  const drawerAppList2 = useGetDrawerAppList(enabledFeatures);
790
735
  const { classes } = useStyles();
791
736
  const navigateTo = (url, shouldReload) => {
792
- if (shouldReload) {
737
+ if (reloadOnNavigate || shouldReload) {
793
738
  const fullUrl = `${window.location.origin}${url}`;
794
739
  window.location.href = fullUrl;
795
740
  return;
@@ -859,7 +804,7 @@ var LeftDrawer = ({
859
804
  alignItems: "center",
860
805
  justifyContent: "center",
861
806
  children: [
862
- app.children?.length > 0 && /* @__PURE__ */ jsx2(
807
+ !!app.children?.length && /* @__PURE__ */ jsx2(
863
808
  ExpandLess,
864
809
  {
865
810
  className: classes.expandIcon,
@@ -882,6 +827,9 @@ var LeftDrawer = ({
882
827
  className: classes.pinIcon,
883
828
  style: { opacity: pinnedApps[app.pinned] ? 1 : 0.3 },
884
829
  onClick: (event) => {
830
+ if (!app.pinned) {
831
+ return;
832
+ }
885
833
  event.stopPropagation();
886
834
  onTogglePinnedApp(
887
835
  app.pinned,
@@ -897,11 +845,10 @@ var LeftDrawer = ({
897
845
  },
898
846
  app.name
899
847
  ),
900
- app.children?.length > 0 && /* @__PURE__ */ jsx2(Collapse, { in: openCollapse[app.routeName], children: /* @__PURE__ */ jsx2(List, { children: app.children.map((child) => /* @__PURE__ */ jsxs(
848
+ !!app.children?.length && /* @__PURE__ */ jsx2(Collapse, { in: openCollapse[app.routeName], children: /* @__PURE__ */ jsx2(List, { children: app.children.map((child) => /* @__PURE__ */ jsxs(
901
849
  ListItemButton,
902
850
  {
903
851
  className: classes.nested,
904
- disabled: child.disabled,
905
852
  onClick: () => navigateTo(child.url, child.shouldReload),
906
853
  title: child.url,
907
854
  children: [
@@ -933,15 +880,8 @@ var uiFeatureNames = {
933
880
  CUSTOMER_ESTIMATED_BASKET_SETTING: "customers_estimated_basket_setting",
934
881
  ORDER_ISSUE_REPORTING: "customers_order_issue_report_setting",
935
882
  CUSTOMER_PAYMENTS_SECTION: "customers_payments_section",
936
- CUSTOMER_DASHBOARD_TAB: "customers_dashboard_tab",
937
- CUSTOMER_DETAILS_TAB: "customers_details_tab",
938
- CUSTOMER_TRANSPORT_TAB: "customers_transport_tab",
939
- CUSTOMER_FINANCE_TAB: "customers_finance_tab",
940
- CUSTOMER_ACTIVITY_TAB: "customers_activity_tab",
941
- CUSTOMER_APP_TAB: "customers_app_tab",
942
- CUSTOMER_STANDING_ORDERS_TAB: "customers_standing_orders_tab",
943
- CUSTOMER_SUBSTITUTIONS_TAB: "customers_substitutions_tab",
944
883
  CUSTOMER_PREFERENCES_TAB: "customers_preferences_tab",
884
+ CUSTOMER_SUBSTITUTIONS_TAB: "customers_substitutions_tab",
945
885
  PRODUCT_PREFERENCES_SECTION: "product_preferences_section"
946
886
  };
947
887
  var uiFeaturesAreEnabled = (enabledUIFeatures, feature) => enabledUIFeatures?.includes(feature);