@local-civics/mgmt-ui 0.1.74 → 0.1.76

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.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useState } from 'react';
3
- import { createStyles, Navbar as Navbar$1, Center, Avatar, Image, Stack as Stack$3, Tooltip, UnstyledButton, Group, Text, Box, Badge as Badge$1, ThemeIcon, Collapse, Code, Burger, ScrollArea, Card, Modal, Loader, SimpleGrid, Tabs as Tabs$1, Button, Menu, ActionIcon, Title, Grid, Table as Table$h, Container, LoadingOverlay, Select, Autocomplete, Drawer, Divider, TextInput, Paper, Overlay, Anchor, Progress, Checkbox, createEmotionCache, MantineProvider, AppShell } from '@mantine/core';
4
- import { IconSwitchHorizontal, IconLogout, IconHome2, IconGauge, IconCategory2, IconAlbum, IconLambda, IconChevronRight, IconChevronLeft, IconBuilding, IconBatteryEco, IconBooks, IconBackpack, IconChevronDown, IconClipboardCopy, IconTableExport, IconArrowLeft, IconPlaylistAdd, IconCheck, IconTrash, IconDownload, IconX, IconCloudUpload, IconInfoCircle, IconColorSwatch, IconPointer, IconBadge, IconCopy, IconHistory, IconLego, IconNews, IconTools, IconPodium, IconAffiliate, IconGrowth, IconBrandInstagram, IconBrandLinkedin, IconBrandFacebook } from '@tabler/icons';
3
+ import { createStyles, Group, Avatar, Text, Box, Badge as Badge$1, ThemeIcon, Collapse, Navbar as Navbar$1, Center, Image, Code, Burger, ScrollArea, UnstyledButton, Card, Modal, Loader, SimpleGrid, Tabs as Tabs$1, Button, Menu, ActionIcon, Title, Grid, Table as Table$h, Container, Stack as Stack$3, LoadingOverlay, Select, Autocomplete, Drawer, Divider, TextInput, Tooltip, Paper, Overlay, Anchor, Progress, Checkbox, createEmotionCache, MantineProvider, AppShell } from '@mantine/core';
4
+ import { IconChevronRight, IconChevronLeft, IconSwitchHorizontal, IconLogout, IconHome2, IconGauge, IconCategory2, IconAlbum, IconLambda, IconBuilding, IconBatteryEco, IconBooks, IconBackpack, IconChevronDown, IconClipboardCopy, IconTableExport, IconArrowLeft, IconPlaylistAdd, IconCheck, IconTrash, IconDownload, IconX, IconCloudUpload, IconInfoCircle, IconColorSwatch, IconPointer, IconBadge, IconCopy, IconHistory, IconLego, IconNews, IconTools, IconPodium, IconAffiliate, IconGrowth, IconBrandInstagram, IconBrandLinkedin, IconBrandFacebook } from '@tabler/icons';
5
5
  import { Link } from 'react-router-dom';
6
6
  import { NotificationsProvider } from '@mantine/notifications';
7
7
  export { showNotification, updateNotification } from '@mantine/notifications';
@@ -14,65 +14,6 @@ import { Chart } from 'react-charts';
14
14
  import AvatarInit from 'avatar-initials';
15
15
  import { useUncontrolled } from '@mantine/hooks';
16
16
 
17
- const useStyles$p = createStyles((theme) => ({
18
- link: {
19
- width: 50,
20
- height: 50,
21
- borderRadius: theme.radius.md,
22
- display: "flex",
23
- alignItems: "center",
24
- justifyContent: "center",
25
- color: theme.colorScheme === "dark" ? theme.colors.dark[0] : theme.colors.gray[7],
26
- "&:hover": {
27
- backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[5] : theme.colors.gray[0]
28
- }
29
- },
30
- active: {
31
- "&, &:hover": {
32
- backgroundColor: theme.fn.variant({ variant: "light", color: theme.primaryColor }).background,
33
- color: theme.fn.variant({ variant: "light", color: theme.primaryColor }).color
34
- }
35
- }
36
- }));
37
- const data$1 = [
38
- { icon: IconHome2, label: "Home", href: "/home" },
39
- { icon: IconGauge, label: "Dashboard", href: "/dashboard" },
40
- { icon: IconCategory2, label: "Classes", href: "/classes" },
41
- { icon: IconAlbum, label: "Badges", href: "/badges" },
42
- { icon: IconLambda, label: "Lessons", href: "/lessons" }
43
- ];
44
- const NavbarLink = ({ icon: Icon, label, active, onClick }) => {
45
- const { classes, cx } = useStyles$p();
46
- return /* @__PURE__ */ React.createElement(Tooltip, { label, position: "right", transitionDuration: 0 }, /* @__PURE__ */ React.createElement(UnstyledButton, { onClick, className: cx(classes.link, { [classes.active]: active }) }, /* @__PURE__ */ React.createElement(Icon, { stroke: 1.5 })));
47
- };
48
- const Navbar = (props) => {
49
- const links = data$1.map((link) => /* @__PURE__ */ React.createElement(
50
- NavbarLink,
51
- {
52
- key: link.label,
53
- label: link.label,
54
- icon: link.icon,
55
- active: link.label === props.active,
56
- onClick: () => props.navigate(link.href)
57
- }
58
- ));
59
- return /* @__PURE__ */ React.createElement(Navbar$1, { width: { base: 80 }, p: "md" }, /* @__PURE__ */ React.createElement(Center, null, /* @__PURE__ */ React.createElement(Avatar, { color: "blue", radius: "sm" }, /* @__PURE__ */ React.createElement("div", { style: { width: 15, marginLeft: "auto", marginRight: "auto" } }, /* @__PURE__ */ React.createElement(Image, { fit: "contain", src: "https://cdn.localcivics.io/brand/l.png" })))), /* @__PURE__ */ React.createElement(Navbar$1.Section, { grow: true, mt: 50 }, /* @__PURE__ */ React.createElement(Stack$3, { justify: "center", spacing: 0 }, links)), /* @__PURE__ */ React.createElement(Navbar$1.Section, null, /* @__PURE__ */ React.createElement(Stack$3, { justify: "center", spacing: 0 }, /* @__PURE__ */ React.createElement(
60
- NavbarLink,
61
- {
62
- icon: IconSwitchHorizontal,
63
- label: "Switch accounts",
64
- onClick: props.onSwitchAccounts
65
- }
66
- ), /* @__PURE__ */ React.createElement(
67
- NavbarLink,
68
- {
69
- icon: IconLogout,
70
- label: "Logout",
71
- onClick: props.onLogout
72
- }
73
- ))));
74
- };
75
-
76
17
  var __defProp$9 = Object.defineProperty;
77
18
  var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
78
19
  var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
@@ -333,7 +274,7 @@ const data = [
333
274
  ]
334
275
  }
335
276
  ];
336
- function NestedNavbar(props) {
277
+ function Navbar(props) {
337
278
  const { classes, cx } = useStyles$m();
338
279
  const [burgerOpen, setBurgerOpen] = React.useState(false);
339
280
  const toggle = () => setBurgerOpen(!burgerOpen);
@@ -2764,7 +2705,15 @@ const TrialRegistration = (props) => {
2764
2705
  const [firstName, setFirstName] = React.useState("");
2765
2706
  const [lastName, setLastName] = React.useState("");
2766
2707
  const [interests, setInterests] = React.useState({});
2767
- return /* @__PURE__ */ React.createElement("div", { className: classes.wrapper }, /* @__PURE__ */ React.createElement(SimpleGrid, { maw: 960, ml: "auto", mr: "auto", cols: 1, spacing: 15, breakpoints: [{ maxWidth: "sm", cols: 1 }] }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Title, { className: classes.title }, "Trial Educator"), /* @__PURE__ */ React.createElement(Text, { className: classes.description, mt: "sm", mb: 30 }, "Try out a some of the features we can bring to your classroom. No commitment required.")), /* @__PURE__ */ React.createElement("div", { className: classes.form }, /* @__PURE__ */ React.createElement(Group, { mb: "md", spacing: "md", grow: true }, /* @__PURE__ */ React.createElement(
2708
+ return /* @__PURE__ */ React.createElement("div", { className: classes.wrapper }, /* @__PURE__ */ React.createElement(SimpleGrid, { maw: 960, ml: "auto", mr: "auto", cols: 1, spacing: 15, breakpoints: [{ maxWidth: "sm", cols: 1 }] }, /* @__PURE__ */ React.createElement(Group, { spacing: "sm" }, /* @__PURE__ */ React.createElement(
2709
+ Image,
2710
+ {
2711
+ height: 100,
2712
+ width: "auto",
2713
+ fit: "contain",
2714
+ src: "https://cdn.localcivics.io/brand/l.png"
2715
+ }
2716
+ ), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Title, { className: classes.title }, "Trial Educator"), /* @__PURE__ */ React.createElement(Text, { className: classes.description, mt: "sm" }, "Try out a few of the features we can bring to your classroom. No commitment required."))), /* @__PURE__ */ React.createElement("div", { className: classes.form }, /* @__PURE__ */ React.createElement(Group, { mb: "md", spacing: "md", grow: true }, /* @__PURE__ */ React.createElement(
2768
2717
  TextInput,
2769
2718
  {
2770
2719
  label: "First Name",
@@ -2836,17 +2785,17 @@ var __spreadValues = (a, b) => {
2836
2785
  return a;
2837
2786
  };
2838
2787
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2839
- const useStyles = createStyles((theme) => ({
2788
+ const useStyles = createStyles((theme, props) => ({
2840
2789
  footer: {
2841
2790
  paddingTop: theme.spacing.md,
2842
2791
  paddingBottom: theme.spacing.md,
2843
- paddingLeft: theme.spacing.md,
2792
+ paddingLeft: props.navbar ? theme.spacing.md : 0,
2844
2793
  backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.colors.gray[0],
2845
2794
  borderTop: `1px solid ${theme.colorScheme === "dark" ? theme.colors.dark[5] : theme.colors.gray[2]}`,
2846
2795
  [theme.fn.largerThan("sm")]: {
2847
2796
  paddingTop: theme.spacing.xl * 2,
2848
2797
  paddingBottom: theme.spacing.xl * 2,
2849
- paddingLeft: theme.spacing.xl * 13
2798
+ paddingLeft: props.navbar ? theme.spacing.xl * 13 : 0
2850
2799
  }
2851
2800
  },
2852
2801
  logo: {
@@ -2918,14 +2867,14 @@ const useStyles = createStyles((theme) => ({
2918
2867
  }
2919
2868
  }));
2920
2869
  const App = (props) => {
2921
- const { classes } = useStyles();
2870
+ const { classes } = useStyles(props);
2922
2871
  const account = useAccount(props.account, props.accounts, props.onAccountChange);
2923
2872
  return /* @__PURE__ */ React.createElement(
2924
2873
  AppShell,
2925
2874
  {
2926
2875
  padding: "xs",
2927
- navbar: /* @__PURE__ */ React.createElement(
2928
- NestedNavbar,
2876
+ navbar: props.navbar && /* @__PURE__ */ React.createElement(
2877
+ Navbar,
2929
2878
  __spreadProps(__spreadValues({}, props.navbar.props), {
2930
2879
  onSwitchAccounts: account.accounts && account.accounts.length > 1 ? () => account.setChangeModalOpen(true) : void 0
2931
2880
  })
@@ -2972,7 +2921,7 @@ const App = (props) => {
2972
2921
  })
2973
2922
  },
2974
2923
  /* @__PURE__ */ React.createElement("div", { style: { position: "relative" } }, (props.loading || account.opened) && /* @__PURE__ */ React.createElement(Center, { style: { height: 400 } }, /* @__PURE__ */ React.createElement(Loader, null)), !props.loading && !account.opened && props.page),
2975
- /* @__PURE__ */ React.createElement(
2924
+ !!account.accounts && !!account.account && /* @__PURE__ */ React.createElement(
2976
2925
  SwitchAccount,
2977
2926
  {
2978
2927
  opened: account.opened,
@@ -3001,6 +2950,9 @@ const useAccount = (account, accounts, onAccountChange) => {
3001
2950
  setChangeModalOpen,
3002
2951
  onAccountChange: (account2) => {
3003
2952
  setLoading(true);
2953
+ if (!onAccountChange) {
2954
+ return;
2955
+ }
3004
2956
  onAccountChange(account2).then(() => {
3005
2957
  setActive(account2);
3006
2958
  setLoading(false);
@@ -3010,5 +2962,5 @@ const useAccount = (account, accounts, onAccountChange) => {
3010
2962
  };
3011
2963
  };
3012
2964
 
3013
- export { AdminProvider, App, Badge, Badges, Class, Classes, Dashboard, Home, Lesson, Lessons, Navbar, NestedNavbar, Organization, People, StartAnonymousLesson, Student, SwitchAccount, TrialHome, TrialRegistration };
2965
+ export { AdminProvider, App, Badge, Badges, Class, Classes, Dashboard, Home, Lesson, Lessons, Navbar, Organization, People, StartAnonymousLesson, Student, SwitchAccount, TrialHome, TrialRegistration };
3014
2966
  //# sourceMappingURL=index.mjs.map