@sikka/hawa 0.0.82 → 0.0.83

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "description": "UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -88,12 +88,14 @@ export const SignInForm = (props) => {
88
88
  )}
89
89
  rules={{ required: props.texts.passwordRequiredText }}
90
90
  />
91
- <div
92
- className="text-xs cursor-pointer w-fit mb-3"
93
- onClick={props.handleForgotPassword}
94
- >
95
- {props.texts.forgotPasswordText}
96
- </div>
91
+ {!props.withoutResetPassword && (
92
+ <div
93
+ className="text-xs cursor-pointer w-fit mb-3"
94
+ onClick={props.handleForgotPassword}
95
+ >
96
+ {props.texts.forgotPasswordText}
97
+ </div>
98
+ )}
97
99
  <HawaButton fullWidth type="submit" text={props.texts.signInText} />{" "}
98
100
  {!props.withoutSignUp && (
99
101
  <div className="font-semibold p-3 text-center text-sm">
@@ -146,7 +148,7 @@ SignInForm.propTypes = {
146
148
  emailPlaceholder: PropTypes.string,
147
149
  emailRequiredText: PropTypes.string,
148
150
  emailInvalidText: PropTypes.string,
149
- usernameLabel:PropTypes.string,
151
+ usernameLabel: PropTypes.string,
150
152
  usernamePlaceholder: PropTypes.string,
151
153
  usernameRequired: PropTypes.string,
152
154
  passwordLabel: PropTypes.string,
@@ -1,7 +1,6 @@
1
1
  import { useState } from "react";
2
2
  import { Controller, useForm } from "react-hook-form";
3
- import { HawaButton } from "../../elements";
4
- import HawaPhoneInput from "../../elements/HawaPhoneInput";
3
+ import { HawaButton, HawaPhoneInput } from "../../elements";
5
4
  import { HawaContainer } from "../../layout";
6
5
 
7
6
  export const SignInPhone = (props) => {
@@ -4,7 +4,8 @@ import {
4
4
  HawaLogoButton,
5
5
  HawaAlert,
6
6
  HawaButton,
7
- HawaCheckbox
7
+ HawaCheckbox,
8
+ HawaSelect
8
9
  } from "../../elements";
9
10
  import PropTypes from "prop-types";
10
11
  import { Controller, FormProvider, useForm } from "react-hook-form";
@@ -48,41 +49,79 @@ export const SignUpForm = (props) => {
48
49
  required: props.texts.fullNameRequiredText
49
50
  }}
50
51
  />
52
+ {props.signUpType === "email" ? (
53
+ <Controller
54
+ control={control}
55
+ name="email"
56
+ render={({ field }) => (
57
+ <HawaTextField
58
+ fullWidth
59
+ type="text"
60
+ value={field.value ?? ""}
61
+ label={props.texts.emailLabel}
62
+ helperText={errors.email?.message}
63
+ placeholder={props.texts.emailPlaceholder}
64
+ {...field}
65
+ />
66
+ )}
67
+ rules={{
68
+ required: props.texts.emailRequiredText,
69
+ pattern: {
70
+ value:
71
+ /^(([^<>()[\]\\.,;:\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,}))$/,
72
+ message: props.texts.emailInvalidText
73
+ }
74
+ }}
75
+ />
76
+ ) : (
77
+ <Controller
78
+ control={control}
79
+ name="username"
80
+ render={({ field }) => (
81
+ <HawaTextField
82
+ fullWidth
83
+ type="text"
84
+ value={field.value ?? ""}
85
+ label={props.texts.usernameLabel}
86
+ helperText={errors.username?.message}
87
+ placeholder={props.texts.usernamePlaceholder}
88
+ {...field}
89
+ />
90
+ )}
91
+ rules={{
92
+ required: props.texts.usernameRequired
93
+ }}
94
+ />
95
+ )}
51
96
  <Controller
52
97
  control={control}
53
- name="email"
98
+ name="password"
54
99
  render={({ field }) => (
55
100
  <HawaTextField
56
101
  fullWidth
57
- type="text"
102
+ type="password"
103
+ defaultValue={field.value ?? ""}
58
104
  value={field.value ?? ""}
59
- label={props.texts.emailLabel}
60
- helperText={errors.email?.message}
61
- placeholder={props.texts.emailPlaceholder}
105
+ label={props.texts.passwordLabel}
106
+ placeholder={props.texts.passwordPlaceholder}
107
+ helperText={errors.password?.message}
62
108
  {...field}
63
109
  />
64
110
  )}
65
- rules={{
66
- required: props.texts.emailRequiredText,
67
- pattern: {
68
- value:
69
- /^(([^<>()[\]\\.,;:\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,}))$/,
70
- message: props.texts.emailInvalidText
71
- }
72
- }}
111
+ rules={{ required: props.texts.passwordRequiredText }}
73
112
  />
74
113
  <Controller
75
114
  control={control}
76
- name="password"
115
+ name="confirm_password"
77
116
  render={({ field }) => (
78
117
  <HawaTextField
79
118
  fullWidth
80
119
  type="password"
81
120
  defaultValue={field.value ?? ""}
82
121
  value={field.value ?? ""}
83
- label={props.texts.passwordLabel}
84
- placeholder={props.texts.passwordPlaceholder}
85
- helperText={errors.password?.message}
122
+ label={props.texts.confirmPasswordLabel}
123
+ placeholder={props.texts.confirmPasswordPlaceholder}
124
+ helperText={errors.confirm_password?.message}
86
125
  {...field}
87
126
  />
88
127
  )}
@@ -107,6 +146,24 @@ export const SignUpForm = (props) => {
107
146
  rules={{ required: props.texts.passwordRequiredText }}
108
147
  />
109
148
  )}
149
+ {props.showUserSource && (
150
+ <div className="py-2">
151
+ <HawaSelect
152
+ label="How did you learn about us?"
153
+ isCreatable={false}
154
+ isMulti={false ?? false}
155
+ isSearchable={false}
156
+ isClearable={false ?? false}
157
+ options={[
158
+ { value: "chocolate", label: "Chocolate" },
159
+ { value: "strawberry", label: "Strawberry" },
160
+ { value: "vanilla", label: "Vanilla" }
161
+ ]}
162
+ onChange={(e, o) => console.log("chooo", e)}
163
+ onInputChange={(e, o) => console.log("changing", e)}
164
+ />
165
+ </div>
166
+ )}
110
167
  {props.showTermsOption && (
111
168
  <div className="py-2">
112
169
  <HawaCheckbox
@@ -121,7 +178,7 @@ export const SignUpForm = (props) => {
121
178
  />
122
179
  </div>
123
180
  )}
124
- {props.showNewletterOption && (
181
+ {props.showNewsletterOption && (
125
182
  <div className="py-2">
126
183
  <HawaCheckbox label="Subscribe to newsletter?" />
127
184
  </div>
@@ -180,10 +237,15 @@ SignUpForm.propTypes = {
180
237
  emailPlaceholder: PropTypes.string,
181
238
  emailRequiredText: PropTypes.string,
182
239
  emailInvalidText: PropTypes.string,
240
+ usernameLabel: PropTypes.string,
241
+ usernamePlaceholder: PropTypes.string,
242
+ usernameRequired: PropTypes.string,
183
243
  passwordLabel: PropTypes.string,
184
244
  passwordPlaceholder: PropTypes.string,
185
245
  passwordRequiredText: PropTypes.string,
186
246
  passwordTooShortText: PropTypes.string,
247
+ confirmPasswordLabel: PropTypes.string,
248
+ confirmPasswordPlaceholder: PropTypes.string,
187
249
  forgotPasswordText: PropTypes.string,
188
250
  newUserText: PropTypes.string,
189
251
  signUpText: PropTypes.string,
@@ -196,6 +258,9 @@ SignUpForm.propTypes = {
196
258
  viaGoogle: PropTypes.bool,
197
259
  viaGithub: PropTypes.bool,
198
260
  viaTwitter: PropTypes.bool,
261
+ showNewsletterOption: PropTypes.bool,
262
+ showRefCode: PropTypes.bool,
263
+ showTermsOption: PropTypes.bool,
199
264
  handleSignUp: PropTypes.func,
200
265
  handleRouteToSignIn: PropTypes.func,
201
266
  handleGoogleSignUp: PropTypes.func,
@@ -1,17 +1,25 @@
1
1
  import { useState } from "react";
2
2
  import Countries from "../../countries";
3
3
  import Select from "react-select";
4
- const Option = ({ cx, children, getStyles, innerRef, ...props }) => (
4
+ const Option = ({
5
+ cx,
6
+ children,
7
+ getStyles,
8
+ innerProps,
9
+ innerRef,
10
+ ...props
11
+ }) => (
5
12
  <div
6
13
  ref={innerRef}
7
14
  className="m-2 p-1 px-3 rounded-lg flex flex-row items-center justify-between hover:bg-blue-200"
15
+ {...innerProps}
8
16
  >
9
17
  <img className="h-8 w-8" src={props.data.image}></img>
10
18
  {children}
11
19
  </div>
12
20
  );
13
21
 
14
- export default function HawaPhoneInput({ preferredCountry }) {
22
+ export const HawaPhoneInput = ({ preferredCountry }) => {
15
23
  const [code, setCode] = useState(preferredCountry ?? "");
16
24
  const [selectedCountry, setSelectedCountry] = useState("+966");
17
25
  const [tel, setTel] = useState("");
@@ -54,9 +62,14 @@ export default function HawaPhoneInput({ preferredCountry }) {
54
62
  lineHeight: "1.25rem",
55
63
  padding: "0.37rem"
56
64
  }),
65
+ singleValue: (base) => ({
66
+ ...base,
67
+ fontSize: "0.875rem",
68
+ textAlign: "right"
69
+ }),
57
70
  control: (base) => ({
58
71
  ...base,
59
- width: 80,
72
+ width: 64,
60
73
  borderRadius: "0.75rem",
61
74
  borderTopRightRadius: 0,
62
75
  borderBottomRightRadius: 0
@@ -76,16 +89,19 @@ export default function HawaPhoneInput({ preferredCountry }) {
76
89
  isCreatable={false}
77
90
  isMulti={false}
78
91
  isSearchable={true}
79
- isClearable={true}
92
+ isClearable={false}
80
93
  placeholder="+966"
81
- // value={selectedCountry}
82
- // inputValue={selectedCountry}
94
+ defaultValue={Countries[0]}
95
+ onInputChange={() => console.log("changed to")}
83
96
  onChange={(newValue, action) => {
84
97
  console.log("test n", newValue);
85
98
  setSelectedCountry(newValue);
86
99
  }}
87
100
  />
88
- <input className="bg-gray-50 border rounded-l-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 border-l-0" />
101
+ <input
102
+ type="number"
103
+ className="bg-gray-50 appearance-none border rounded-l-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 border-l-0"
104
+ />
89
105
  </div>
90
106
  );
91
- }
107
+ };
@@ -1,36 +1,177 @@
1
- import React from "react";
1
+ import Select from "react-select";
2
+ import CreatableSelect from "react-select/creatable";
2
3
 
3
- export const HawaSelect = (props) => {
4
- return (
5
- <div style={{ width: "100%" }}>
6
- <label
7
- htmlFor="first_name"
8
- className="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300"
9
- >
10
- {props.label}
11
- </label>
4
+ const Option = ({
5
+ cx,
6
+ children,
7
+ getStyles,
8
+ innerProps,
9
+ innerRef,
10
+ ...props
11
+ }) => (
12
+ <div
13
+ ref={innerRef}
14
+ className="m-2 p-1 px-3 rounded-lg flex flex-row items-center justify-between hover:bg-blue-200"
15
+ {...innerProps}
16
+ >
17
+ {children}
18
+ </div>
19
+ );
12
20
 
13
- {/* <div
14
- style={{
15
- display: "flex",
16
- flexDirection: "row",
17
- justifyContent: "space-between",
18
- alignItems: "center"
19
- }}
20
- >
21
+ const Control = ({
22
+ cx,
23
+ children,
24
+ getStyles,
25
+ innerProps,
26
+ innerRef,
27
+ ...props
28
+ }) => {
29
+ return (
30
+ <div
31
+ ref={innerRef}
32
+ className="mb-2
33
+ flex
34
+ bg-gray-50 border
35
+ border-gray-300
36
+ text-gray-900
37
+ text-sm rounded-lg
38
+ h-11
39
+ focus:ring-blue-500
40
+ focus:border-blue-500
41
+ w-full
42
+ dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
43
+ {...innerProps}
44
+ // {...props}
45
+ >
46
+ {children}
47
+ </div>
48
+ );
49
+ };
50
+ const Menu = ({ cx, children, getStyles, innerProps, innerRef, ...props }) => {
51
+ return (
52
+ <div
53
+ className="bg-white rounded-lg absolute w-full"
54
+ ref={innerRef}
55
+ {...innerProps}
56
+ // {...props}
57
+ >
58
+ {children}
59
+ </div>
60
+ );
61
+ };
21
62
 
22
- {props.helperText && (
23
- <Typography variant="validation">{props.helperText}</Typography>
24
- )}
25
- </div> */}
26
- {/* <Select {...props}>{props.children}</Select> */}
63
+ export const HawaSelect = (props) => {
64
+ return (
65
+ <>
66
+ {props.label && (
67
+ <label className="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300">
68
+ {props.label}
69
+ </label>
70
+ )}
71
+ {!props.isCreatable && (
72
+ <Select
73
+ styles={
74
+ {
75
+ // input: (base) => ({
76
+ // ...base,
77
+ // "input:focus": {
78
+ // boxShadow: "none"
79
+ // }
80
+ // }),
81
+ // control: (base) => ({
82
+ // ...base,
83
+ // borderRadius: "0.75rem"
84
+ // }),
85
+ // menu: (base) => ({
86
+ // ...base,
87
+ // borderRadius: "0.75rem",
88
+ // padding: 0,
89
+ // display: "flex",
90
+ // justifyContent: "center"
91
+ // }),
92
+ // menuList: (base) => ({
93
+ // ...base,
94
+ // display: "flex",
95
+ // flexDirection: "column",
96
+ // justifyContent: "center",
97
+ // alignItems: "center",
98
+ // width: "100%"
99
+ // }),
100
+ // option: (base) => ({
101
+ // ...base,
102
+ // borderRadius: "0.75rem",
103
+ // margin: 3,
104
+ // width: "98%"
105
+ // }),
106
+ // multiValue: (base) => ({
107
+ // ...base,
108
+ // borderRadius: "0.4rem"
109
+ // })
110
+ }
111
+ }
112
+ options={props.options}
113
+ isClearable={props.isClearable}
114
+ isMulti={props.isMulti}
115
+ isSearchable={props.isSearchable}
116
+ onChange={(newValue, action) => props.onChange(newValue, action)}
117
+ components={{
118
+ Control,
119
+ Option,
120
+ Menu
121
+ }}
122
+ />
123
+ )}
124
+ {props.isCreatable && (
125
+ <CreatableSelect
126
+ styles={{
127
+ input: (base) => ({
128
+ ...base,
129
+ "input:focus": {
130
+ boxShadow: "none"
131
+ }
132
+ }),
27
133
 
28
- <select
29
- id="countries"
30
- className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
31
- >
32
- {props.children}
33
- </select>
34
- </div>
134
+ control: (base) => ({
135
+ ...base,
136
+ borderRadius: "0.75rem"
137
+ }),
138
+ menu: (base) => ({
139
+ ...base,
140
+ borderRadius: "0.75rem",
141
+ padding: 0,
142
+ display: "flex",
143
+ justifyContent: "center"
144
+ }),
145
+ menuList: (base) => ({
146
+ ...base,
147
+ display: "flex",
148
+ flexDirection: "column",
149
+ justifyContent: "center",
150
+ alignItems: "center",
151
+ width: "100%"
152
+ }),
153
+ option: (base) => ({
154
+ ...base,
155
+ borderRadius: "0.75rem",
156
+ margin: 3,
157
+ width: "98%"
158
+ })
159
+ }}
160
+ options={props.options}
161
+ isClearable={props.isClearable}
162
+ isMulti={props.isMulti}
163
+ isSearchable={props.isSearchable}
164
+ onCreateOption={() => console.log("im changing")}
165
+ onChange={(newValue, action) => {
166
+ console.log("this is onChange", newValue);
167
+ props.onChange(newValue, action);
168
+ }}
169
+ onInputChange={(newValue, action) => {
170
+ console.log("onInputChange====", newValue);
171
+ props.onInputChange(newValue, action);
172
+ }}
173
+ />
174
+ )}
175
+ </>
35
176
  );
36
177
  };
package/src/styles.css CHANGED
@@ -372,6 +372,11 @@ video {
372
372
  [hidden] {
373
373
  display: none;
374
374
  }
375
+ input[type="number"]::-webkit-inner-spin-button,
376
+ input[type="number"]::-webkit-outer-spin-button {
377
+ -webkit-appearance: none;
378
+ margin: 0;
379
+ }
375
380
 
376
381
  *, ::before, ::after {
377
382
  --tw-border-spacing-x: 0;
package/src/tailwind.css CHANGED
@@ -2,6 +2,14 @@
2
2
  @import "tailwindcss/components";
3
3
  @import "tailwindcss/utilities";
4
4
 
5
+ @layer base {
6
+ input[type="number"]::-webkit-inner-spin-button,
7
+ input[type="number"]::-webkit-outer-spin-button {
8
+ -webkit-appearance: none;
9
+ margin: 0;
10
+ }
11
+ }
12
+
5
13
  body {
6
14
  font-family: "IBM Plex Sans Arabic";
7
15
  }
@@ -1,67 +0,0 @@
1
- import Select from "react-select";
2
- import CreatableSelect from "react-select/creatable";
3
-
4
- export default function HawaSelectInput(props) {
5
- return (
6
- <>
7
- {!props.isCreatable && (
8
- <Select
9
- styles={{
10
- input: (base) => ({
11
- ...base,
12
- "input:focus": {
13
- boxShadow: "none"
14
- }
15
- }),
16
- control: (base) => ({
17
- ...base,
18
- borderRadius: "0.75rem",
19
- padding: 3
20
- }),
21
- menu: (base) => ({
22
- ...base,
23
- borderRadius: "0.75rem"
24
- })
25
- }}
26
- options={props.options}
27
- isClearable={props.isClearable}
28
- isMulti={props.isMulti}
29
- isSearchable={props.isSearchable}
30
- onChange={(newValue, action) => props.onChange(newValue, action)}
31
- components={props.components}
32
- />
33
- )}
34
- {props.isCreatable && (
35
- <CreatableSelect
36
- styles={{
37
- input: (base) => ({
38
- ...base,
39
- "input:focus": {
40
- padding: 20,
41
- boxShadow: "none"
42
- }
43
- }),
44
- control: (base) => ({
45
- ...base,
46
- borderRadius: "0.75rem",
47
- padding: 8
48
- })
49
- }}
50
- options={props.options}
51
- isClearable={props.isClearable}
52
- isMulti={props.isMulti}
53
- isSearchable={props.isSearchable}
54
- onCreateOption={() => console.log("im changing")}
55
- onChange={(newValue, action) => {
56
- console.log("this is onChange", newValue);
57
- props.onChange(newValue, action);
58
- }}
59
- onInputChange={(newValue, action) => {
60
- console.log("onInputChange====", newValue);
61
- props.onInputChange(newValue, action);
62
- }}
63
- />
64
- )}
65
- </>
66
- );
67
- }