@rationalbloks/frontblok-components 0.1.1 → 0.2.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/dist/index.d.ts CHANGED
@@ -6,6 +6,19 @@ import { JSXElementConstructor } from 'react';
6
6
  import { ReactElement } from 'react';
7
7
  import { ReactNode } from 'react';
8
8
  import { ReactPortal } from 'react';
9
+ import { Theme } from '@mui/material';
10
+ import { ThemeOptions } from '@mui/material/styles';
11
+
12
+ export declare interface AppThemeOptions {
13
+ /** Override default palette colors */
14
+ paletteOverrides?: Record<string, unknown>;
15
+ /** Override default typography settings */
16
+ typographyOverrides?: Record<string, unknown>;
17
+ /** Override default component styles */
18
+ componentsOverrides?: ThemeOptions['components'];
19
+ /** Border radius for shapes. Default: 12 */
20
+ borderRadius?: number;
21
+ }
9
22
 
10
23
  /**
11
24
  * Auth API interface - matches frontblok-auth's authApi.
@@ -124,8 +137,97 @@ export declare type ConfirmationModalSeverity = 'info' | 'warning' | 'error' | '
124
137
 
125
138
  declare type ConfirmationModalSeverity_2 = 'info' | 'warning' | 'error' | 'success';
126
139
 
140
+ /**
141
+ * Creates a MUI theme with RationalBloks defaults.
142
+ *
143
+ * All defaults can be overridden per-app via the options parameter.
144
+ * The defaults include:
145
+ * - Warm beige background
146
+ * - Professional blue primary palette
147
+ * - System font typography with tight letter-spacing
148
+ * - Polished component overrides (no uppercase buttons, rounded cards, etc.)
149
+ *
150
+ * @param options - Customization options
151
+ * @returns A MUI Theme object
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * // Use defaults
156
+ * const theme = createAppTheme();
157
+ *
158
+ * // Override primary color
159
+ * const theme = createAppTheme({
160
+ * paletteOverrides: { primary: { main: '#e91e63' } },
161
+ * });
162
+ * ```
163
+ */
164
+ export declare function createAppTheme(options?: AppThemeOptions): Theme;
165
+
127
166
  export declare function createNavbar(config: NavbarConfig): () => JSX.Element;
128
167
 
168
+ export declare const defaultComponents: ThemeOptions['components'];
169
+
170
+ export declare const defaultNavbarGradient: {
171
+ start: string;
172
+ end: string;
173
+ };
174
+
175
+ export declare const defaultPalette: {
176
+ primary: {
177
+ main: string;
178
+ 50: string;
179
+ 100: string;
180
+ 500: string;
181
+ 600: string;
182
+ 700: string;
183
+ 900: string;
184
+ };
185
+ secondary: {
186
+ main: string;
187
+ };
188
+ success: {
189
+ main: string;
190
+ };
191
+ warning: {
192
+ main: string;
193
+ };
194
+ error: {
195
+ main: string;
196
+ };
197
+ background: {
198
+ default: string;
199
+ paper: string;
200
+ };
201
+ };
202
+
203
+ export declare const defaultTypography: {
204
+ fontFamily: string;
205
+ h1: {
206
+ fontWeight: number;
207
+ letterSpacing: string;
208
+ };
209
+ h2: {
210
+ fontWeight: number;
211
+ letterSpacing: string;
212
+ };
213
+ h3: {
214
+ fontWeight: number;
215
+ letterSpacing: string;
216
+ };
217
+ h4: {
218
+ fontWeight: number;
219
+ letterSpacing: string;
220
+ };
221
+ h5: {
222
+ fontWeight: number;
223
+ letterSpacing: string;
224
+ };
225
+ h6: {
226
+ fontWeight: number;
227
+ letterSpacing: string;
228
+ };
229
+ };
230
+
129
231
  export declare class ErrorBoundary extends Component<Props, State> {
130
232
  constructor(props: Props);
131
233
  static getDerivedStateFromError(error: Error): Partial<State>;
@@ -214,6 +316,35 @@ export declare interface ResetPasswordViewProps {
214
316
  authRoute?: string;
215
317
  }
216
318
 
319
+ export declare const SettingsView: default_2.FC<SettingsViewProps>;
320
+
321
+ export declare interface SettingsViewAuthApi {
322
+ deleteAccount: (password: string, confirmText: string) => Promise<{
323
+ message: string;
324
+ note: string;
325
+ }>;
326
+ }
327
+
328
+ export declare interface SettingsViewProps {
329
+ /** The auth API instance (must have deleteAccount method) */
330
+ authApi: SettingsViewAuthApi;
331
+ /** The useAuth hook from your app */
332
+ useAuth: () => {
333
+ user: SettingsViewUser | null;
334
+ logout: () => void;
335
+ };
336
+ /** Route to navigate to after logout/delete. Default: '/' */
337
+ homeRoute?: string;
338
+ /** Optional additional content to render between profile and danger zone */
339
+ children?: default_2.ReactNode;
340
+ }
341
+
342
+ export declare interface SettingsViewUser {
343
+ first_name?: string;
344
+ last_name?: string;
345
+ email?: string;
346
+ }
347
+
217
348
  declare interface State {
218
349
  hasError: boolean;
219
350
  error: Error | null;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import React__default, { Component, useState, useEffect } from "react";
7
7
  import { Container, Box, Paper, Typography, Button, Dialog, DialogTitle, alpha as alpha$1, DialogContent, Alert, Divider, DialogActions, CircularProgress, AppBar, Toolbar, IconButton, Avatar, Menu, Chip, MenuItem, useTheme, Card, CardContent, Stack, TextField, InputAdornment, Link as Link$1 } from "@mui/material";
8
8
  import emStyled from "@emotion/styled";
9
9
  import "@emotion/react";
10
- import { CheckCircle, Error as Error$1, Warning, Info, Settings, ExitToApp, Person, Business, Email, VisibilityOff, Visibility, Lock, Security, ArrowBack, Send } from "@mui/icons-material";
10
+ import { CheckCircle, Error as Error$1, Warning, Info, Settings, ExitToApp, Person, Business, Email, VisibilityOff, Visibility, Lock, Security, ArrowBack, Send, DeleteForever } from "@mui/icons-material";
11
11
  import { useNavigate, useLocation, Link, useSearchParams } from "react-router-dom";
12
12
  import { GoogleLogin } from "@react-oauth/google";
13
13
  function getDefaultExportFromCjs(x) {
@@ -6511,6 +6511,302 @@ const SupportView = () => {
6511
6511
  ] })
6512
6512
  ] });
6513
6513
  };
6514
+ const SettingsView = ({
6515
+ authApi,
6516
+ useAuth,
6517
+ homeRoute = "/",
6518
+ children
6519
+ }) => {
6520
+ var _a;
6521
+ const navigate = useNavigate();
6522
+ const { user, logout } = useAuth();
6523
+ const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
6524
+ const [deleteConfirmation, setDeleteConfirmation] = useState("");
6525
+ const [deletePassword, setDeletePassword] = useState("");
6526
+ const [error, setError] = useState(null);
6527
+ const [loading, setLoading] = useState(false);
6528
+ const handleLogout = () => {
6529
+ logout();
6530
+ navigate(homeRoute);
6531
+ };
6532
+ const handleDeleteAccount = async () => {
6533
+ if (deleteConfirmation !== "DELETE") {
6534
+ setError("Please type DELETE to confirm");
6535
+ return;
6536
+ }
6537
+ if (!deletePassword) {
6538
+ setError("Please enter your password");
6539
+ return;
6540
+ }
6541
+ setLoading(true);
6542
+ setError(null);
6543
+ try {
6544
+ await authApi.deleteAccount(deletePassword, deleteConfirmation);
6545
+ logout();
6546
+ navigate(homeRoute);
6547
+ } catch (err) {
6548
+ setError(err instanceof Error ? err.message : "Failed to delete account");
6549
+ } finally {
6550
+ setLoading(false);
6551
+ }
6552
+ };
6553
+ return /* @__PURE__ */ jsxs(Container, { maxWidth: "md", sx: { py: 4 }, children: [
6554
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", fontWeight: 700, gutterBottom: true, children: "Settings" }),
6555
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", color: "text.secondary", paragraph: true, children: "Manage your account settings and preferences." }),
6556
+ /* @__PURE__ */ jsxs(Paper, { sx: { p: 3, mb: 3 }, children: [
6557
+ /* @__PURE__ */ jsx(Typography, { variant: "h6", fontWeight: 600, gutterBottom: true, children: "Profile Information" }),
6558
+ /* @__PURE__ */ jsx(Divider, { sx: { mb: 3 } }),
6559
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 3, alignItems: "center", children: [
6560
+ /* @__PURE__ */ jsx(
6561
+ Avatar,
6562
+ {
6563
+ sx: {
6564
+ width: 80,
6565
+ height: 80,
6566
+ bgcolor: "primary.main",
6567
+ fontSize: "2rem"
6568
+ },
6569
+ children: ((_a = user == null ? void 0 : user.first_name) == null ? void 0 : _a.charAt(0).toUpperCase()) || /* @__PURE__ */ jsx(Person, {})
6570
+ }
6571
+ ),
6572
+ /* @__PURE__ */ jsxs(Box, { children: [
6573
+ /* @__PURE__ */ jsxs(Typography, { variant: "h5", fontWeight: 600, children: [
6574
+ user == null ? void 0 : user.first_name,
6575
+ " ",
6576
+ user == null ? void 0 : user.last_name
6577
+ ] }),
6578
+ /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: user == null ? void 0 : user.email })
6579
+ ] })
6580
+ ] })
6581
+ ] }),
6582
+ /* @__PURE__ */ jsxs(Paper, { sx: { p: 3, mb: 3 }, children: [
6583
+ /* @__PURE__ */ jsx(Typography, { variant: "h6", fontWeight: 600, gutterBottom: true, children: "Account Actions" }),
6584
+ /* @__PURE__ */ jsx(Divider, { sx: { mb: 3 } }),
6585
+ /* @__PURE__ */ jsx(Stack, { spacing: 2, children: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
6586
+ /* @__PURE__ */ jsxs(Box, { children: [
6587
+ /* @__PURE__ */ jsx(Typography, { fontWeight: 500, children: "Sign Out" }),
6588
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: "Sign out of your account on this device." })
6589
+ ] }),
6590
+ /* @__PURE__ */ jsx(
6591
+ Button,
6592
+ {
6593
+ variant: "outlined",
6594
+ startIcon: /* @__PURE__ */ jsx(ExitToApp, {}),
6595
+ onClick: handleLogout,
6596
+ children: "Sign Out"
6597
+ }
6598
+ )
6599
+ ] }) })
6600
+ ] }),
6601
+ children,
6602
+ /* @__PURE__ */ jsxs(Paper, { sx: { p: 3, border: "1px solid", borderColor: "error.main" }, children: [
6603
+ /* @__PURE__ */ jsx(Typography, { variant: "h6", fontWeight: 600, color: "error", gutterBottom: true, children: "Danger Zone" }),
6604
+ /* @__PURE__ */ jsx(Divider, { sx: { mb: 3 } }),
6605
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
6606
+ /* @__PURE__ */ jsxs(Box, { children: [
6607
+ /* @__PURE__ */ jsx(Typography, { fontWeight: 500, children: "Delete Account" }),
6608
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: "Permanently delete your account and all associated data." })
6609
+ ] }),
6610
+ /* @__PURE__ */ jsx(
6611
+ Button,
6612
+ {
6613
+ variant: "outlined",
6614
+ color: "error",
6615
+ startIcon: /* @__PURE__ */ jsx(DeleteForever, {}),
6616
+ onClick: () => setDeleteDialogOpen(true),
6617
+ children: "Delete Account"
6618
+ }
6619
+ )
6620
+ ] })
6621
+ ] }),
6622
+ /* @__PURE__ */ jsxs(Dialog, { open: deleteDialogOpen, onClose: () => setDeleteDialogOpen(false), children: [
6623
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Delete Account" }),
6624
+ /* @__PURE__ */ jsxs(DialogContent, { children: [
6625
+ /* @__PURE__ */ jsx(Alert, { severity: "error", sx: { mb: 2 }, children: "This action cannot be undone. All your data will be permanently deleted." }),
6626
+ /* @__PURE__ */ jsxs(Typography, { paragraph: true, children: [
6627
+ "Enter your password and type ",
6628
+ /* @__PURE__ */ jsx("strong", { children: "DELETE" }),
6629
+ " to confirm:"
6630
+ ] }),
6631
+ /* @__PURE__ */ jsx(
6632
+ TextField,
6633
+ {
6634
+ fullWidth: true,
6635
+ type: "password",
6636
+ value: deletePassword,
6637
+ onChange: (e) => setDeletePassword(e.target.value),
6638
+ placeholder: "Enter your password",
6639
+ sx: { mb: 2 }
6640
+ }
6641
+ ),
6642
+ /* @__PURE__ */ jsx(
6643
+ TextField,
6644
+ {
6645
+ fullWidth: true,
6646
+ value: deleteConfirmation,
6647
+ onChange: (e) => setDeleteConfirmation(e.target.value),
6648
+ placeholder: "Type DELETE to confirm"
6649
+ }
6650
+ ),
6651
+ error && /* @__PURE__ */ jsx(Alert, { severity: "error", sx: { mt: 2 }, children: error })
6652
+ ] }),
6653
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
6654
+ /* @__PURE__ */ jsx(Button, { onClick: () => setDeleteDialogOpen(false), children: "Cancel" }),
6655
+ /* @__PURE__ */ jsx(
6656
+ Button,
6657
+ {
6658
+ color: "error",
6659
+ variant: "contained",
6660
+ onClick: handleDeleteAccount,
6661
+ disabled: loading,
6662
+ children: loading ? "Deleting..." : "Delete My Account"
6663
+ }
6664
+ )
6665
+ ] })
6666
+ ] })
6667
+ ] });
6668
+ };
6669
+ const defaultPalette = {
6670
+ primary: {
6671
+ main: "#1e40af",
6672
+ 50: "#eff6ff",
6673
+ 100: "#dbeafe",
6674
+ 500: "#3b82f6",
6675
+ 600: "#2563eb",
6676
+ 700: "#1d4ed8",
6677
+ 900: "#1e3a8a"
6678
+ },
6679
+ secondary: {
6680
+ main: "#6b7280"
6681
+ },
6682
+ success: {
6683
+ main: "#10b981"
6684
+ },
6685
+ warning: {
6686
+ main: "#f59e0b"
6687
+ },
6688
+ error: {
6689
+ main: "#ef4444"
6690
+ },
6691
+ background: {
6692
+ default: "hsl(33.3, 60%, 97.1%)",
6693
+ // Beautiful warm beige
6694
+ paper: "#FCFAF7"
6695
+ // Warm white for cards
6696
+ }
6697
+ };
6698
+ const defaultTypography = {
6699
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif',
6700
+ h1: {
6701
+ fontWeight: 700,
6702
+ letterSpacing: "-0.5px"
6703
+ },
6704
+ h2: {
6705
+ fontWeight: 700,
6706
+ letterSpacing: "-0.4px"
6707
+ },
6708
+ h3: {
6709
+ fontWeight: 600,
6710
+ letterSpacing: "-0.3px"
6711
+ },
6712
+ h4: {
6713
+ fontWeight: 700,
6714
+ letterSpacing: "-0.2px"
6715
+ },
6716
+ h5: {
6717
+ fontWeight: 600,
6718
+ letterSpacing: "-0.1px"
6719
+ },
6720
+ h6: {
6721
+ fontWeight: 600,
6722
+ letterSpacing: "-0.08px"
6723
+ }
6724
+ };
6725
+ const defaultComponents = {
6726
+ MuiButton: {
6727
+ styleOverrides: {
6728
+ root: {
6729
+ textTransform: "none",
6730
+ fontWeight: 600,
6731
+ borderRadius: "8px"
6732
+ }
6733
+ }
6734
+ },
6735
+ MuiCard: {
6736
+ styleOverrides: {
6737
+ root: {
6738
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.05)",
6739
+ border: "1px solid #f3f4f6"
6740
+ }
6741
+ }
6742
+ },
6743
+ MuiChip: {
6744
+ styleOverrides: {
6745
+ root: {
6746
+ fontWeight: 600
6747
+ }
6748
+ }
6749
+ },
6750
+ MuiSelect: {
6751
+ styleOverrides: {
6752
+ select: {
6753
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif'
6754
+ }
6755
+ }
6756
+ },
6757
+ MuiTextField: {
6758
+ styleOverrides: {
6759
+ root: {
6760
+ "& .MuiInputBase-input": {
6761
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif'
6762
+ }
6763
+ }
6764
+ }
6765
+ },
6766
+ MuiInputBase: {
6767
+ styleOverrides: {
6768
+ root: {
6769
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif'
6770
+ }
6771
+ }
6772
+ },
6773
+ MuiMenuItem: {
6774
+ styleOverrides: {
6775
+ root: {
6776
+ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif'
6777
+ }
6778
+ }
6779
+ }
6780
+ };
6781
+ const defaultNavbarGradient = {
6782
+ start: "#1800ad",
6783
+ end: "#0d0067"
6784
+ };
6785
+ function createAppTheme(options = {}) {
6786
+ const {
6787
+ paletteOverrides = {},
6788
+ typographyOverrides = {},
6789
+ componentsOverrides = {},
6790
+ borderRadius: borderRadius2 = 12
6791
+ } = options;
6792
+ return createTheme({
6793
+ palette: {
6794
+ ...defaultPalette,
6795
+ ...paletteOverrides
6796
+ },
6797
+ typography: {
6798
+ ...defaultTypography,
6799
+ ...typographyOverrides
6800
+ },
6801
+ shape: {
6802
+ borderRadius: borderRadius2
6803
+ },
6804
+ components: {
6805
+ ...defaultComponents,
6806
+ ...componentsOverrides
6807
+ }
6808
+ });
6809
+ }
6514
6810
  export {
6515
6811
  AuthView,
6516
6812
  ConfirmationModal,
@@ -6518,8 +6814,14 @@ export {
6518
6814
  ErrorFallback,
6519
6815
  ForgotPasswordView,
6520
6816
  ResetPasswordView,
6817
+ SettingsView,
6521
6818
  SupportView,
6522
6819
  VerifyEmailView,
6523
- createNavbar
6820
+ createAppTheme,
6821
+ createNavbar,
6822
+ defaultComponents,
6823
+ defaultNavbarGradient,
6824
+ defaultPalette,
6825
+ defaultTypography
6524
6826
  };
6525
6827
  //# sourceMappingURL=index.js.map