@sikka/hawa 0.0.9 → 0.0.12

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.
Files changed (68) hide show
  1. package/es/index.es.js +1 -1
  2. package/lib/index.js +1 -1
  3. package/package.json +5 -4
  4. package/src/blocks/Account/UserProfileForm.js +80 -0
  5. package/src/blocks/Account/UserSettingsForm.js +17 -0
  6. package/src/blocks/Account/index.js +2 -2
  7. package/src/blocks/AuthForms/NewPasswordForm.js +57 -85
  8. package/src/blocks/AuthForms/ResetPasswordForm.js +43 -42
  9. package/src/blocks/AuthForms/SignInForm.js +99 -98
  10. package/src/blocks/AuthForms/SignUpForm.js +106 -104
  11. package/src/blocks/Payment/ChargeWalletForm.js +40 -37
  12. package/src/blocks/Payment/CreditCardForm.js +49 -44
  13. package/src/blocks/Payment/PayWithWallet.js +16 -6
  14. package/src/blocks/Payment/PaymentMethod.js +0 -1
  15. package/src/blocks/Payment/SelectPayment.js +53 -55
  16. package/src/index.js +0 -1
  17. package/src/layout/Box.js +36 -33
  18. package/src/stories/BlocksStories/Account/UserProfile.stories.js +21 -0
  19. package/src/stories/BlocksStories/Account/UserSettings.stories.js +21 -0
  20. package/src/stories/BlocksStories/Auth/NewPassword.stories.js +60 -0
  21. package/src/stories/BlocksStories/Auth/ResetPassword.stories.js +59 -0
  22. package/src/stories/BlocksStories/Auth/SignIn.stories.js +89 -0
  23. package/src/stories/BlocksStories/Auth/SignUp.stories.js +90 -0
  24. package/src/stories/BlocksStories/Payment/ChargeWallet.stories.js +30 -0
  25. package/src/stories/BlocksStories/Payment/PayWithCreditCard.stories.js +37 -0
  26. package/src/stories/BlocksStories/Payment/PayWithWallet.stories.js +17 -0
  27. package/src/stories/BlocksStories/Payment/PaymentSelection.stories.js +60 -0
  28. package/src/stories/LayoutStories/Box.stories.js +9 -20
  29. package/src/stories/UIStories/ActionButton.stories.js +1 -6
  30. package/src/stories/UIStories/AdaptiveButton.stories.js +1 -6
  31. package/src/stories/UIStories/Alert.stories.js +2 -3
  32. package/src/stories/UIStories/LogoButtons.stories.js +47 -64
  33. package/src/stories/UIStories/RadioSelector.stories.js +15 -44
  34. package/src/stories/UIStories/SettingsRow.stories.js +3 -16
  35. package/src/themes/HawaProvider.js +187 -178
  36. package/src/themes/QawaimTheme.js +199 -0
  37. package/src/ui/ActionButton.js +32 -35
  38. package/src/ui/AdaptiveButton.js +3 -8
  39. package/src/ui/HawaAlert.js +22 -24
  40. package/src/ui/HawaButton.js +43 -44
  41. package/src/ui/HawaInputLabel.js +22 -23
  42. package/src/ui/HawaLogoButton.js +7 -45
  43. package/src/ui/HawaRadio.js +18 -61
  44. package/src/ui/HawaSettingsRow.js +1 -27
  45. package/src/ui/HawaTextArea.js +1 -1
  46. package/src/ui/HawaTextField.js +146 -93
  47. package/src/ui/HawaTypography.js +19 -21
  48. package/src/ui/Row.js +1 -1
  49. package/src/ui/StyledTooltip.js +1 -1
  50. package/src/ui/TabPanel.js +1 -1
  51. package/storybook-static/8.1bf48ea7.iframe.bundle.js +1 -0
  52. package/storybook-static/iframe.html +1 -1
  53. package/storybook-static/index.html +1 -1
  54. package/storybook-static/main.a9a16923.iframe.bundle.js +1 -0
  55. package/storybook-static/{runtime~main.cfefe972.iframe.bundle.js → runtime~main.f1ebae9b.iframe.bundle.js} +1 -1
  56. package/storybook-static/vendors~main.f8d30727.iframe.bundle.js +76 -0
  57. package/storybook-static/{vendors~main.aa1d952a.iframe.bundle.js.LICENSE.txt → vendors~main.f8d30727.iframe.bundle.js.LICENSE.txt} +0 -0
  58. package/storybook-static/vendors~main.f8d30727.iframe.bundle.js.map +1 -0
  59. package/src/blocks/Account/UserProfile.js +0 -65
  60. package/src/blocks/Account/UserSettings.js +0 -15
  61. package/src/stories/BlocksStories/AuthForm.stories.js +0 -105
  62. package/src/stories/BlocksStories/PaymentForm.stories.js +0 -86
  63. package/src/stories/BlocksStories/UserForm.stories.js +0 -41
  64. package/src/stories/HawaProvider.stories.js +0 -22
  65. package/storybook-static/8.c4cb6081.iframe.bundle.js +0 -1
  66. package/storybook-static/main.5731dbe3.iframe.bundle.js +0 -1
  67. package/storybook-static/vendors~main.aa1d952a.iframe.bundle.js +0 -76
  68. package/storybook-static/vendors~main.aa1d952a.iframe.bundle.js.map +0 -1
@@ -1,17 +1,14 @@
1
1
  import React from "react";
2
- import {
3
- HawaTextField,
4
- ActionButton,
5
- HawaAlert,
6
- HawaTypography,
7
- HawaLogoButton
8
- } from "../../ui";
9
- import { Box } from "../../layout";
2
+ import { HawaTextField, HawaTypography, HawaLogoButton } from "../../ui";
10
3
  import { FormProvider, useForm } from "react-hook-form";
11
-
12
4
  import InputAdornment from "@mui/material/InputAdornment";
13
5
  import EmailIcon from "@mui/icons-material/MailOutline";
14
6
  import PasswordIcon from "@mui/icons-material/HttpsOutlined";
7
+ import Container from "@mui/material/Container";
8
+ import Typography from "@mui/material/Typography";
9
+ import Button from "@mui/material/Button";
10
+ import Alert from "@mui/material/Alert";
11
+ import AlertTitle from "@mui/material/AlertTitle";
15
12
 
16
13
  export const SignInForm = (props) => {
17
14
  const methods = useForm();
@@ -21,110 +18,114 @@ export const SignInForm = (props) => {
21
18
  } = methods;
22
19
 
23
20
  return (
24
- <Box maxWidth={400} noColor noMargin noPadding>
25
- <Box noMargin>
26
- {props.error && (
27
- <HawaAlert text="This is a sign in alert" severity="error" />
28
- )}
29
- <FormProvider {...methods}>
30
- <form onSubmit={handleSubmit(props.handleSignIn)}>
31
- <HawaTextField
32
- type="text"
33
- name="email"
34
- inputLabel="Email"
35
- placeholder="Enter your email"
36
- startAdornment={
37
- <InputAdornment position="start">
38
- <EmailIcon />
39
- </InputAdornment>
21
+ <Container maxWidth="xs" variant="auth">
22
+ {props.error && (
23
+ <Alert severity="error">
24
+ {props.errorTitle && <AlertTitle>{props.errorTitle}</AlertTitle>}
25
+ {props.errorText}
26
+ </Alert>
27
+ )}
28
+ <FormProvider {...methods}>
29
+ <form onSubmit={handleSubmit(props.handleSignIn)}>
30
+ <HawaTextField
31
+ fullWidth
32
+ type="text"
33
+ name="email"
34
+ label={props.texts.emailLabel}
35
+ placeholder={props.texts.emailPlaceholder}
36
+ startAdornment={
37
+ <InputAdornment position="start">
38
+ <EmailIcon />
39
+ </InputAdornment>
40
+ }
41
+ rules={{
42
+ required: props.texts.emailRequired,
43
+ pattern: {
44
+ value:
45
+ /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
46
+ message: props.texts.emailInvalidText
40
47
  }
41
- rules={{
42
- required: "Email is required",
43
- pattern: {
44
- value:
45
- /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
46
- message: "Invalid email address"
47
- }
48
- }}
49
- helperText={errors.email?.message}
50
- />
48
+ }}
49
+ helperText={errors.email?.message}
50
+ />
51
51
 
52
- <HawaTextField
53
- name="password"
54
- placeholder="Enter password"
55
- type="password"
56
- inputLabel="Password"
57
- startAdornment={
58
- <InputAdornment position="start">
59
- <PasswordIcon />
60
- </InputAdornment>
61
- }
62
- rules={{
63
- required: "Password is rquired"
64
- }}
65
- helperText={errors.password?.message}
66
- />
67
- <HawaTypography
68
- style={{
69
- cursor: "pointer",
70
- marginTop: 5,
71
- width: "max-content",
72
- padding: 5
73
- }}
74
- onClick={() => console.log("res")}
75
- >
76
- Forgot password?
77
- </HawaTypography>
78
- <ActionButton
79
- type="submit"
80
- fullWidth
81
- last={"true"}
82
- text={"Sign In"}
83
- />
84
- </form>
85
- </FormProvider>
86
- </Box>
87
- <HawaTypography
52
+ <HawaTextField
53
+ fullWidth
54
+ name="password"
55
+ placeholder={props.texts.passwordPlaceholder}
56
+ type="password"
57
+ label={props.texts.passwordLabel}
58
+ startAdornment={
59
+ <InputAdornment position="start">
60
+ <PasswordIcon />
61
+ </InputAdornment>
62
+ }
63
+ rules={{
64
+ required: props.texts.passwordRequired
65
+ }}
66
+ helperText={errors.password?.message}
67
+ />
68
+ <Typography
69
+ style={{
70
+ cursor: "pointer",
71
+ marginTop: 5,
72
+ width: "max-content",
73
+ fontSize: 15,
74
+ padding: 5
75
+ }}
76
+ onClick={props.handleForgotPassword}
77
+ >
78
+ {props.texts.forgotPasswordText}
79
+ </Typography>
80
+ <Button type="submit" fullWidth variant="last">
81
+ {props.texts.signInText}
82
+ </Button>
83
+ </form>
84
+ </FormProvider>
85
+ <Typography
86
+ variant="subtitle2"
88
87
  style={{
88
+ // fontSize: 15,
89
89
  marginTop: 5,
90
- // width: "max-content",
91
90
  textAlign: "center",
92
91
  padding: 5
93
92
  }}
94
93
  >
95
- New user?{" "}
94
+ {props.texts.newUserText}{" "}
96
95
  <span
97
- onClick={() => console.log("res")}
96
+ onClick={props.handleRouteToSignUp}
98
97
  style={{
99
98
  cursor: "pointer",
100
99
  color: "blue",
101
100
  textAlign: "center"
102
101
  }}
103
102
  >
104
- Sign up
103
+ {props.texts.signUpText}
105
104
  </span>
106
- </HawaTypography>
107
- {props.viaGoogle && (
108
- <HawaLogoButton
109
- logo="google"
110
- buttonText={props.googleButtonLabel}
111
- handleClick={props.handleGoogleSignIn}
112
- />
113
- )}
114
- {props.viaGithub && (
115
- <HawaLogoButton
116
- logo="github"
117
- buttonText={props.githubButtonLabel}
118
- handleClick={props.handleGithubSignIn}
119
- />
120
- )}
121
- {props.viaTwitter && (
122
- <HawaLogoButton
123
- logo="twitter"
124
- buttonText={props.twitterButtonLabel}
125
- handleClick={props.handleTwitterSignIn}
126
- />
127
- )}
128
- </Box>
105
+ </Typography>
106
+ <div style={{ display: "flex", flexDirection: "column" }}>
107
+ {props.viaGoogle && (
108
+ <HawaLogoButton
109
+ logo="google"
110
+ buttonText={props.texts.googleButtonLabel}
111
+ onClick={props.handleGoogleSignIn}
112
+ />
113
+ )}
114
+ {props.viaGithub && (
115
+ <HawaLogoButton
116
+ logo="github"
117
+ buttonText={props.texts.githubButtonLabel}
118
+ onClick={props.handleGithubSignIn}
119
+ />
120
+ )}
121
+ {props.viaTwitter && (
122
+ <HawaLogoButton
123
+ logo="twitter"
124
+ buttonText={props.texts.twitterButtonLabel}
125
+ onClick={props.handleTwitterSignIn}
126
+ />
127
+ )}
128
+ </div>
129
+ </Container>
129
130
  );
130
131
  };
@@ -1,142 +1,144 @@
1
1
  import React from "react";
2
- import { Box } from "../../layout";
3
- import {
4
- HawaTextField,
5
- ActionButton,
6
- HawaAlert,
7
- HawaTypography,
8
- HawaLogoButton
9
- } from "../../ui";
2
+ import { HawaTextField, HawaLogoButton } from "../../ui";
10
3
  import PropTypes from "prop-types";
11
4
  import { FormProvider, useForm } from "react-hook-form";
12
-
13
5
  import PersonIcon from "@mui/icons-material/PermIdentityOutlined";
14
6
  import InputAdornment from "@mui/material/InputAdornment";
15
7
  import EmailIcon from "@mui/icons-material/MailOutline";
16
8
  import PasswordIcon from "@mui/icons-material/HttpsOutlined";
9
+ import Container from "@mui/material/Container";
10
+ import Typography from "@mui/material/Typography";
11
+ import Button from "@mui/material/Button";
12
+ import Alert from "@mui/material/Alert";
13
+ import AlertTitle from "@mui/material/AlertTitle";
17
14
 
18
15
  export const SignUpForm = (props) => {
19
16
  const methods = useForm();
20
17
  const {
21
18
  formState: { errors },
22
- handleSubmit,
23
- getValues,
24
- register,
25
- watch,
26
- reset,
27
- setValue
19
+ handleSubmit
28
20
  } = methods;
29
21
 
30
22
  return (
31
- <Box maxWidth={400} noColor noMargin noPadding>
32
- <Box noMargin>
33
- {props.error && (
23
+ <Container maxWidth="xs" variant="auth">
24
+ {props.error && (
25
+ <Alert severity="error">
26
+ {props.errorTitle && <AlertTitle>{props.errorTitle}</AlertTitle>}
27
+ {props.errorText}
28
+ </Alert>
29
+ )}
30
+ {/* {props.error && (
34
31
  <HawaAlert text="This is a sign in alert" severity="error" />
35
- )}
36
- <FormProvider {...methods}>
37
- <form onSubmit={handleSubmit(props.handleSignUp)}>
38
- <HawaTextField
39
- name="fullName"
40
- placeholder="Fulan AlFulani"
41
- type="text"
42
- inputLabel="Full Name"
43
- startAdornment={
44
- <InputAdornment position="start">
45
- <PersonIcon />
46
- </InputAdornment>
47
- }
48
- rules={{
49
- required: "Full name rquired"
50
- }}
51
- helperText={errors.fullName?.message}
52
- />
32
+ )} */}
33
+ <FormProvider {...methods}>
34
+ <form onSubmit={handleSubmit(props.handleSignUp)}>
35
+ <HawaTextField
36
+ fullWidth
37
+ type="text"
38
+ label={props.texts.fullNameLabel}
39
+ name="fullName"
40
+ placeholder={props.texts.fullNamePlaceholder}
41
+ inputLabel={props.texts.fullNameLabel}
42
+ startAdornment={
43
+ <InputAdornment position="start">
44
+ <PersonIcon />
45
+ </InputAdornment>
46
+ }
47
+ helperText={errors.fullName?.message}
48
+ />
53
49
 
54
- <HawaTextField
55
- type="text"
56
- inputLabel="Email"
57
- placeholder="Enter your email"
58
- name="email"
59
- startAdornment={
60
- <InputAdornment position="start">
61
- <EmailIcon />
62
- </InputAdornment>
50
+ <HawaTextField
51
+ fullWidth
52
+ type="text"
53
+ label={props.texts.emailLabel}
54
+ placeholder={props.texts.emailPlaceholder}
55
+ name="email"
56
+ startAdornment={
57
+ <InputAdornment position="start">
58
+ <EmailIcon />
59
+ </InputAdornment>
60
+ }
61
+ rules={{
62
+ required: props.texts.emailRequiredText,
63
+ pattern: {
64
+ value:
65
+ /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
66
+ message: props.texts.emailInvalidText
63
67
  }
64
- rules={{
65
- required: "Email required",
66
- pattern: {
67
- value:
68
- /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
69
- message: "Invalid email address"
70
- }
71
- }}
72
- helperText={errors.email?.message}
73
- />
74
- <HawaTextField
75
- name="password"
76
- placeholder="Minimum 8 characters"
77
- type="password"
78
- inputLabel="Password"
79
- startAdornment={
80
- <InputAdornment position="start">
81
- <PasswordIcon />
82
- </InputAdornment>
68
+ }}
69
+ helperText={errors.email?.message}
70
+ />
71
+ <HawaTextField
72
+ fullWidth
73
+ name="password"
74
+ placeholder={props.texts.passwordPlaceholder}
75
+ type="password"
76
+ label={props.texts.passwordLabel}
77
+ startAdornment={
78
+ <InputAdornment position="start">
79
+ <PasswordIcon />
80
+ </InputAdornment>
81
+ }
82
+ rules={{
83
+ required: props.texts.passwordRequiredText,
84
+ minLength: {
85
+ value: 8,
86
+ message: props.texts.passwordTooShortText
83
87
  }
84
- rules={{
85
- required: "Password rquired",
86
- minLength: {
87
- value: 8,
88
- message: "Password too short"
89
- }
90
- }}
91
- helperText={errors.password?.message}
92
- />
88
+ }}
89
+ helperText={errors.password?.message}
90
+ />
91
+
92
+ <Button fullWidth variant="last" type="submit">
93
+ {props.texts.signUpText}
94
+ </Button>
95
+ </form>
96
+ </FormProvider>
93
97
 
94
- <ActionButton fullWidth type="submit" text="Sign Up" last />
95
- </form>
96
- </FormProvider>
97
- </Box>
98
- <HawaTypography
98
+ <Typography
99
+ variant="subtitle2"
99
100
  style={{
100
101
  marginTop: 5,
101
- // width: "max-content",
102
102
  textAlign: "center",
103
103
  padding: 5
104
104
  }}
105
105
  >
106
106
  Existing user?{" "}
107
107
  <span
108
- onClick={() => console.log("res")}
108
+ onClick={props.handleRouteToSignIn}
109
109
  style={{
110
110
  cursor: "pointer",
111
111
  color: "blue",
112
112
  textAlign: "center"
113
113
  }}
114
114
  >
115
- Sign in
115
+ {props.texts.signInText}
116
116
  </span>
117
- </HawaTypography>
118
- {props.viaGoogle && (
119
- <HawaLogoButton
120
- logo="google"
121
- buttonText={props.googleButtonLabel}
122
- handleClick={props.handleGoogleSignIn}
123
- />
124
- )}
125
- {props.viaGithub && (
126
- <HawaLogoButton
127
- logo="github"
128
- buttonText={props.githubButtonLabel}
129
- handleClick={props.handleGithubSignIn}
130
- />
131
- )}
132
- {props.viaTwitter && (
133
- <HawaLogoButton
134
- logo="twitter"
135
- buttonText={props.twitterButtonLabel}
136
- handleClick={props.handleTwitterSignIn}
137
- />
138
- )}
139
- </Box>
117
+ </Typography>
118
+ <div style={{ display: "flex", flexDirection: "column" }}>
119
+ {props.viaGoogle && (
120
+ <HawaLogoButton
121
+ logo="google"
122
+ buttonText={props.texts.googleButtonLabel}
123
+ onClick={props.handleGoogleSignUp}
124
+ />
125
+ )}
126
+ {props.viaGithub && (
127
+ <HawaLogoButton
128
+ logo="github"
129
+ buttonText={props.texts.githubButtonLabel}
130
+ onClick={props.handleGithubSignUp}
131
+ />
132
+ )}
133
+ {props.viaTwitter && (
134
+ <HawaLogoButton
135
+ logo="twitter"
136
+ buttonText={props.texts.twitterButtonLabel}
137
+ onClick={props.handleTwitterSignUp}
138
+ />
139
+ )}
140
+ </div>
141
+ </Container>
140
142
  );
141
143
  };
142
144
 
@@ -1,7 +1,9 @@
1
1
  import React, { useState } from "react";
2
- import { HawaTextField, ActionButton, HawaTypography } from "../../ui";
3
- import { Box } from "../../layout";
2
+ import { HawaTextField } from "../../ui";
4
3
  import { FormProvider, useForm } from "react-hook-form";
4
+ import Container from "@mui/material/Container";
5
+ import Button from "@mui/material/Button";
6
+ import Typography from "@mui/material/Typography";
5
7
 
6
8
  export const ChargeWalletForm = (props) => {
7
9
  const [walletAmount, setWalletAmount] = useState(0);
@@ -12,42 +14,43 @@ export const ChargeWalletForm = (props) => {
12
14
  } = methods;
13
15
 
14
16
  return (
15
- <Box maxWidth={400} noColor noMargin noPadding>
16
- <Box noMargin>
17
- <HawaTypography variant="h2" align="center">
18
- {Number(walletAmount).toLocaleString("en")}{" "}
19
- <span style={{ fontSize: 20, letterSpacing: 1 }}>
20
- {props.currency}
21
- </span>
22
- </HawaTypography>
23
- <FormProvider {...methods}>
24
- <form
25
- onChange={(e) => {
26
- e.preventDefault();
27
- setWalletAmount(methods.getValues().amount);
17
+ <Container maxWidth="xs">
18
+ <Typography align="center" variant="h1">
19
+ {Number(walletAmount).toLocaleString("en") || "0"}
20
+ <Typography>{props.currency || "SAR"}</Typography>
21
+ </Typography>
22
+ <FormProvider {...methods}>
23
+ <form
24
+ onChange={(e) => {
25
+ e.preventDefault();
26
+ setWalletAmount(methods.getValues().amount);
27
+ }}
28
+ style={{ marginTop: 10 }}
29
+ onSubmit={handleSubmit(props.handleChargeWallet)}
30
+ >
31
+ <HawaTextField
32
+ fullWidth
33
+ name="amount"
34
+ placeholder="Enter amount"
35
+ type="number"
36
+ value={walletAmount}
37
+ rules={{
38
+ required: "Password is rquired"
28
39
  }}
29
- style={{ marginTop: 10 }}
30
- onSubmit={handleSubmit(props.handleChargeWallet)}
40
+ helperText={errors.amount?.message}
41
+ />
42
+
43
+ <Button
44
+ type="submit"
45
+ fullWidth
46
+ variant="last"
47
+ onClick={props.handleSignIn}
31
48
  >
32
- <HawaTextField
33
- name="amount"
34
- placeholder="Enter amount"
35
- type="number"
36
- value={walletAmount}
37
- rules={{
38
- required: "Password is rquired"
39
- }}
40
- helperText={errors.amount?.message}
41
- />
42
- <ActionButton
43
- last
44
- fullWidth
45
- text={"Charge Wallet"} //move this to props
46
- onClick={props.handleSignIn}
47
- />
48
- </form>
49
- </FormProvider>
50
- </Box>
51
- </Box>
49
+ {/* {props.texts.signInText} */}
50
+ {"Charge Wallet"}
51
+ </Button>
52
+ </form>
53
+ </FormProvider>
54
+ </Container>
52
55
  );
53
56
  };