@rationalbloks/frontblok-components 0.1.0 → 0.2.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/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Reusable React components for RationalBloks frontends.
4
4
 
5
- ## Philosophy
5
+ ## Design Principles
6
6
 
7
- **THE ONE WAY: Props-based API**
7
+ **Props-based API**
8
8
 
9
9
  - All customization via props (no hidden context)
10
10
  - Each component is self-contained
@@ -21,8 +21,8 @@ npm install @rationalbloks/frontblok-components
21
21
 
22
22
  ```json
23
23
  {
24
- "@mui/material": "^5.0.0 || ^6.0.0",
25
- "@mui/icons-material": "^5.0.0 || ^6.0.0",
24
+ "@mui/material": "^5.0.0 || ^6.0.0 || ^7.0.0",
25
+ "@mui/icons-material": "^5.0.0 || ^6.0.0 || ^7.0.0",
26
26
  "@emotion/react": "^11.0.0",
27
27
  "@emotion/styled": "^11.0.0",
28
28
  "@react-oauth/google": "^0.12.0",
@@ -49,7 +49,7 @@ npm install @rationalbloks/frontblok-components
49
49
  | Component | Props | Description |
50
50
  |-----------|-------|-------------|
51
51
  | `ErrorBoundary` | `children`, `supportEmail?` | React error boundary |
52
- | `ErrorFallback` | `error`, `resetErrorBoundary`, ... | Error display component |
52
+ | `ErrorFallback` | `error`, `errorInfo`, `resetError`, `supportEmail` | Error display component |
53
53
  | `ConfirmationModal` | `open`, `onClose`, `onConfirm`, `title`, `message`, ... | Confirmation dialog |
54
54
  | `createNavbar(config)` | Factory function | Creates configured navbar component |
55
55
 
package/dist/index.cjs CHANGED
@@ -6529,13 +6529,315 @@ const SupportView = () => {
6529
6529
  ] })
6530
6530
  ] });
6531
6531
  };
6532
+ const SettingsView = ({
6533
+ authApi,
6534
+ useAuth,
6535
+ homeRoute = "/",
6536
+ children
6537
+ }) => {
6538
+ var _a;
6539
+ const navigate = reactRouterDom.useNavigate();
6540
+ const { user, logout } = useAuth();
6541
+ const [deleteDialogOpen, setDeleteDialogOpen] = React.useState(false);
6542
+ const [deleteConfirmation, setDeleteConfirmation] = React.useState("");
6543
+ const [deletePassword, setDeletePassword] = React.useState("");
6544
+ const [error, setError] = React.useState(null);
6545
+ const [loading, setLoading] = React.useState(false);
6546
+ const handleLogout = () => {
6547
+ logout();
6548
+ navigate(homeRoute);
6549
+ };
6550
+ const handleDeleteAccount = async () => {
6551
+ if (deleteConfirmation !== "DELETE") {
6552
+ setError("Please type DELETE to confirm");
6553
+ return;
6554
+ }
6555
+ if (!deletePassword) {
6556
+ setError("Please enter your password");
6557
+ return;
6558
+ }
6559
+ setLoading(true);
6560
+ setError(null);
6561
+ try {
6562
+ await authApi.deleteAccount(deletePassword, deleteConfirmation);
6563
+ logout();
6564
+ navigate(homeRoute);
6565
+ } catch (err) {
6566
+ setError(err instanceof Error ? err.message : "Failed to delete account");
6567
+ } finally {
6568
+ setLoading(false);
6569
+ }
6570
+ };
6571
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.Container, { maxWidth: "md", sx: { py: 4 }, children: [
6572
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h4", fontWeight: 700, gutterBottom: true, children: "Settings" }),
6573
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body1", color: "text.secondary", paragraph: true, children: "Manage your account settings and preferences." }),
6574
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Paper, { sx: { p: 3, mb: 3 }, children: [
6575
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h6", fontWeight: 600, gutterBottom: true, children: "Profile Information" }),
6576
+ /* @__PURE__ */ jsxRuntime.jsx(material.Divider, { sx: { mb: 3 } }),
6577
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 3, alignItems: "center", children: [
6578
+ /* @__PURE__ */ jsxRuntime.jsx(
6579
+ material.Avatar,
6580
+ {
6581
+ sx: {
6582
+ width: 80,
6583
+ height: 80,
6584
+ bgcolor: "primary.main",
6585
+ fontSize: "2rem"
6586
+ },
6587
+ children: ((_a = user == null ? void 0 : user.first_name) == null ? void 0 : _a.charAt(0).toUpperCase()) || /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.Person, {})
6588
+ }
6589
+ ),
6590
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { children: [
6591
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Typography, { variant: "h5", fontWeight: 600, children: [
6592
+ user == null ? void 0 : user.first_name,
6593
+ " ",
6594
+ user == null ? void 0 : user.last_name
6595
+ ] }),
6596
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { color: "text.secondary", children: user == null ? void 0 : user.email })
6597
+ ] })
6598
+ ] })
6599
+ ] }),
6600
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Paper, { sx: { p: 3, mb: 3 }, children: [
6601
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h6", fontWeight: 600, gutterBottom: true, children: "Account Actions" }),
6602
+ /* @__PURE__ */ jsxRuntime.jsx(material.Divider, { sx: { mb: 3 } }),
6603
+ /* @__PURE__ */ jsxRuntime.jsx(material.Stack, { spacing: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
6604
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { children: [
6605
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { fontWeight: 500, children: "Sign Out" }),
6606
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", color: "text.secondary", children: "Sign out of your account on this device." })
6607
+ ] }),
6608
+ /* @__PURE__ */ jsxRuntime.jsx(
6609
+ material.Button,
6610
+ {
6611
+ variant: "outlined",
6612
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.ExitToApp, {}),
6613
+ onClick: handleLogout,
6614
+ children: "Sign Out"
6615
+ }
6616
+ )
6617
+ ] }) })
6618
+ ] }),
6619
+ children,
6620
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Paper, { sx: { p: 3, border: "1px solid", borderColor: "error.main" }, children: [
6621
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h6", fontWeight: 600, color: "error", gutterBottom: true, children: "Danger Zone" }),
6622
+ /* @__PURE__ */ jsxRuntime.jsx(material.Divider, { sx: { mb: 3 } }),
6623
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
6624
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { children: [
6625
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { fontWeight: 500, children: "Delete Account" }),
6626
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", color: "text.secondary", children: "Permanently delete your account and all associated data." })
6627
+ ] }),
6628
+ /* @__PURE__ */ jsxRuntime.jsx(
6629
+ material.Button,
6630
+ {
6631
+ variant: "outlined",
6632
+ color: "error",
6633
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.DeleteForever, {}),
6634
+ onClick: () => setDeleteDialogOpen(true),
6635
+ children: "Delete Account"
6636
+ }
6637
+ )
6638
+ ] })
6639
+ ] }),
6640
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Dialog, { open: deleteDialogOpen, onClose: () => setDeleteDialogOpen(false), children: [
6641
+ /* @__PURE__ */ jsxRuntime.jsx(material.DialogTitle, { children: "Delete Account" }),
6642
+ /* @__PURE__ */ jsxRuntime.jsxs(material.DialogContent, { children: [
6643
+ /* @__PURE__ */ jsxRuntime.jsx(material.Alert, { severity: "error", sx: { mb: 2 }, children: "This action cannot be undone. All your data will be permanently deleted." }),
6644
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Typography, { paragraph: true, children: [
6645
+ "Enter your password and type ",
6646
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "DELETE" }),
6647
+ " to confirm:"
6648
+ ] }),
6649
+ /* @__PURE__ */ jsxRuntime.jsx(
6650
+ material.TextField,
6651
+ {
6652
+ fullWidth: true,
6653
+ type: "password",
6654
+ value: deletePassword,
6655
+ onChange: (e) => setDeletePassword(e.target.value),
6656
+ placeholder: "Enter your password",
6657
+ sx: { mb: 2 }
6658
+ }
6659
+ ),
6660
+ /* @__PURE__ */ jsxRuntime.jsx(
6661
+ material.TextField,
6662
+ {
6663
+ fullWidth: true,
6664
+ value: deleteConfirmation,
6665
+ onChange: (e) => setDeleteConfirmation(e.target.value),
6666
+ placeholder: "Type DELETE to confirm"
6667
+ }
6668
+ ),
6669
+ error && /* @__PURE__ */ jsxRuntime.jsx(material.Alert, { severity: "error", sx: { mt: 2 }, children: error })
6670
+ ] }),
6671
+ /* @__PURE__ */ jsxRuntime.jsxs(material.DialogActions, { children: [
6672
+ /* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: () => setDeleteDialogOpen(false), children: "Cancel" }),
6673
+ /* @__PURE__ */ jsxRuntime.jsx(
6674
+ material.Button,
6675
+ {
6676
+ color: "error",
6677
+ variant: "contained",
6678
+ onClick: handleDeleteAccount,
6679
+ disabled: loading,
6680
+ children: loading ? "Deleting..." : "Delete My Account"
6681
+ }
6682
+ )
6683
+ ] })
6684
+ ] })
6685
+ ] });
6686
+ };
6687
+ const defaultPalette = {
6688
+ primary: {
6689
+ main: "#1e40af",
6690
+ 50: "#eff6ff",
6691
+ 100: "#dbeafe",
6692
+ 500: "#3b82f6",
6693
+ 600: "#2563eb",
6694
+ 700: "#1d4ed8",
6695
+ 900: "#1e3a8a"
6696
+ },
6697
+ secondary: {
6698
+ main: "#6b7280"
6699
+ },
6700
+ success: {
6701
+ main: "#10b981"
6702
+ },
6703
+ warning: {
6704
+ main: "#f59e0b"
6705
+ },
6706
+ error: {
6707
+ main: "#ef4444"
6708
+ },
6709
+ background: {
6710
+ default: "hsl(33.3, 60%, 97.1%)",
6711
+ // Beautiful warm beige
6712
+ paper: "#FCFAF7"
6713
+ // Warm white for cards
6714
+ }
6715
+ };
6716
+ const defaultTypography = {
6717
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif',
6718
+ h1: {
6719
+ fontWeight: 700,
6720
+ letterSpacing: "-0.5px"
6721
+ },
6722
+ h2: {
6723
+ fontWeight: 700,
6724
+ letterSpacing: "-0.4px"
6725
+ },
6726
+ h3: {
6727
+ fontWeight: 600,
6728
+ letterSpacing: "-0.3px"
6729
+ },
6730
+ h4: {
6731
+ fontWeight: 700,
6732
+ letterSpacing: "-0.2px"
6733
+ },
6734
+ h5: {
6735
+ fontWeight: 600,
6736
+ letterSpacing: "-0.1px"
6737
+ },
6738
+ h6: {
6739
+ fontWeight: 600,
6740
+ letterSpacing: "-0.08px"
6741
+ }
6742
+ };
6743
+ const defaultComponents = {
6744
+ MuiButton: {
6745
+ styleOverrides: {
6746
+ root: {
6747
+ textTransform: "none",
6748
+ fontWeight: 600,
6749
+ borderRadius: "8px"
6750
+ }
6751
+ }
6752
+ },
6753
+ MuiCard: {
6754
+ styleOverrides: {
6755
+ root: {
6756
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.05)",
6757
+ border: "1px solid #f3f4f6"
6758
+ }
6759
+ }
6760
+ },
6761
+ MuiChip: {
6762
+ styleOverrides: {
6763
+ root: {
6764
+ fontWeight: 600
6765
+ }
6766
+ }
6767
+ },
6768
+ MuiSelect: {
6769
+ styleOverrides: {
6770
+ select: {
6771
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif'
6772
+ }
6773
+ }
6774
+ },
6775
+ MuiTextField: {
6776
+ styleOverrides: {
6777
+ root: {
6778
+ "& .MuiInputBase-input": {
6779
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif'
6780
+ }
6781
+ }
6782
+ }
6783
+ },
6784
+ MuiInputBase: {
6785
+ styleOverrides: {
6786
+ root: {
6787
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif'
6788
+ }
6789
+ }
6790
+ },
6791
+ MuiMenuItem: {
6792
+ styleOverrides: {
6793
+ root: {
6794
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif'
6795
+ }
6796
+ }
6797
+ }
6798
+ };
6799
+ const defaultNavbarGradient = {
6800
+ start: "#1800ad",
6801
+ end: "#0d0067"
6802
+ };
6803
+ function createAppTheme(options = {}) {
6804
+ const {
6805
+ paletteOverrides = {},
6806
+ typographyOverrides = {},
6807
+ componentsOverrides = {},
6808
+ borderRadius: borderRadius2 = 12
6809
+ } = options;
6810
+ return createTheme({
6811
+ palette: {
6812
+ ...defaultPalette,
6813
+ ...paletteOverrides
6814
+ },
6815
+ typography: {
6816
+ ...defaultTypography,
6817
+ ...typographyOverrides
6818
+ },
6819
+ shape: {
6820
+ borderRadius: borderRadius2
6821
+ },
6822
+ components: {
6823
+ ...defaultComponents,
6824
+ ...componentsOverrides
6825
+ }
6826
+ });
6827
+ }
6532
6828
  exports.AuthView = AuthView;
6533
6829
  exports.ConfirmationModal = ConfirmationModal;
6534
6830
  exports.ErrorBoundary = ErrorBoundary;
6535
6831
  exports.ErrorFallback = ErrorFallback;
6536
6832
  exports.ForgotPasswordView = ForgotPasswordView;
6537
6833
  exports.ResetPasswordView = ResetPasswordView;
6834
+ exports.SettingsView = SettingsView;
6538
6835
  exports.SupportView = SupportView;
6539
6836
  exports.VerifyEmailView = VerifyEmailView;
6837
+ exports.createAppTheme = createAppTheme;
6540
6838
  exports.createNavbar = createNavbar;
6839
+ exports.defaultComponents = defaultComponents;
6840
+ exports.defaultNavbarGradient = defaultNavbarGradient;
6841
+ exports.defaultPalette = defaultPalette;
6842
+ exports.defaultTypography = defaultTypography;
6541
6843
  //# sourceMappingURL=index.cjs.map