@bosonprotocol/react-kit 0.32.0 → 0.33.0-alpha.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/dist/cjs/components/form/BaseInput.js +1 -1
- package/dist/cjs/components/form/BaseInput.js.map +1 -1
- package/dist/cjs/components/form/BaseTagsInput.d.ts.map +1 -1
- package/dist/cjs/components/form/BaseTagsInput.js +1 -1
- package/dist/cjs/components/form/BaseTagsInput.js.map +1 -1
- package/dist/cjs/components/form/BaseTextArea.d.ts.map +1 -1
- package/dist/cjs/components/form/BaseTextArea.js +1 -1
- package/dist/cjs/components/form/BaseTextArea.js.map +1 -1
- package/dist/cjs/components/form/Checkbox.d.ts.map +1 -1
- package/dist/cjs/components/form/Checkbox.js +1 -1
- package/dist/cjs/components/form/Checkbox.js.map +1 -1
- package/dist/cjs/components/form/CountrySelect.d.ts +16 -3
- package/dist/cjs/components/form/CountrySelect.d.ts.map +1 -1
- package/dist/cjs/components/form/CountrySelect.js +26 -18
- package/dist/cjs/components/form/CountrySelect.js.map +1 -1
- package/dist/cjs/components/form/Datepicker.d.ts.map +1 -1
- package/dist/cjs/components/form/Datepicker.js +1 -1
- package/dist/cjs/components/form/Datepicker.js.map +1 -1
- package/dist/cjs/components/form/InputColor.d.ts.map +1 -1
- package/dist/cjs/components/form/InputColor.js +1 -1
- package/dist/cjs/components/form/InputColor.js.map +1 -1
- package/dist/cjs/components/form/Phone.d.ts.map +1 -1
- package/dist/cjs/components/form/Phone.js +1 -1
- package/dist/cjs/components/form/Phone.js.map +1 -1
- package/dist/cjs/components/form/Select.d.ts.map +1 -1
- package/dist/cjs/components/form/Select.js +1 -2
- package/dist/cjs/components/form/Select.js.map +1 -1
- package/dist/cjs/components/form/Upload/Upload.js +0 -1
- package/dist/cjs/components/form/Upload/Upload.js.map +1 -1
- package/dist/cjs/components/form/index.d.ts +1 -0
- package/dist/cjs/components/form/index.d.ts.map +1 -1
- package/dist/cjs/components/form/index.js +1 -0
- package/dist/cjs/components/form/index.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/form/BaseInput.js +1 -1
- package/dist/esm/components/form/BaseInput.js.map +1 -1
- package/dist/esm/components/form/BaseTagsInput.d.ts.map +1 -1
- package/dist/esm/components/form/BaseTagsInput.js +1 -1
- package/dist/esm/components/form/BaseTagsInput.js.map +1 -1
- package/dist/esm/components/form/BaseTextArea.d.ts.map +1 -1
- package/dist/esm/components/form/BaseTextArea.js +1 -1
- package/dist/esm/components/form/BaseTextArea.js.map +1 -1
- package/dist/esm/components/form/Checkbox.d.ts.map +1 -1
- package/dist/esm/components/form/Checkbox.js +1 -1
- package/dist/esm/components/form/Checkbox.js.map +1 -1
- package/dist/esm/components/form/CountrySelect.d.ts +16 -3
- package/dist/esm/components/form/CountrySelect.d.ts.map +1 -1
- package/dist/esm/components/form/CountrySelect.js +58 -30
- package/dist/esm/components/form/CountrySelect.js.map +1 -1
- package/dist/esm/components/form/Datepicker.d.ts.map +1 -1
- package/dist/esm/components/form/Datepicker.js +1 -1
- package/dist/esm/components/form/Datepicker.js.map +1 -1
- package/dist/esm/components/form/InputColor.d.ts.map +1 -1
- package/dist/esm/components/form/InputColor.js +1 -1
- package/dist/esm/components/form/InputColor.js.map +1 -1
- package/dist/esm/components/form/Phone.d.ts.map +1 -1
- package/dist/esm/components/form/Phone.js +1 -1
- package/dist/esm/components/form/Phone.js.map +1 -1
- package/dist/esm/components/form/Select.d.ts.map +1 -1
- package/dist/esm/components/form/Select.js +1 -2
- package/dist/esm/components/form/Select.js.map +1 -1
- package/dist/esm/components/form/Upload/Upload.js +0 -1
- package/dist/esm/components/form/Upload/Upload.js.map +1 -1
- package/dist/esm/components/form/index.d.ts +1 -0
- package/dist/esm/components/form/index.d.ts.map +1 -1
- package/dist/esm/components/form/index.js +1 -0
- package/dist/esm/components/form/index.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/form/BaseInput.tsx +1 -1
- package/src/components/form/BaseTagsInput.tsx +1 -2
- package/src/components/form/BaseTextArea.tsx +1 -2
- package/src/components/form/Checkbox.tsx +1 -2
- package/src/components/form/CountrySelect.tsx +96 -43
- package/src/components/form/Datepicker.tsx +1 -2
- package/src/components/form/InputColor.tsx +1 -2
- package/src/components/form/Phone.tsx +1 -2
- package/src/components/form/Select.tsx +1 -2
- package/src/components/form/Upload/Upload.tsx +1 -1
- package/src/components/form/index.ts +1 -0
- package/src/index.tsx +1 -0
- package/src/stories/selects/CountrySelect.stories.tsx +118 -0
|
@@ -10,8 +10,7 @@ export default function Checkbox({ name, text, ...props }: CheckboxProps) {
|
|
|
10
10
|
const [field, meta, helpers] = useField(name);
|
|
11
11
|
const ref = useRef(field.value);
|
|
12
12
|
const errorMessage = meta.error && meta.touched ? meta.error : "";
|
|
13
|
-
const displayError =
|
|
14
|
-
typeof errorMessage === typeof "string" && errorMessage !== "";
|
|
13
|
+
const displayError = typeof errorMessage === "string" && errorMessage !== "";
|
|
15
14
|
const checkboxId = `checkbox-${name}`;
|
|
16
15
|
|
|
17
16
|
useEffect(() => {
|
|
@@ -4,15 +4,16 @@ import { GlobeHemisphereWest } from "phosphor-react";
|
|
|
4
4
|
import React, { forwardRef, useState, useEffect } from "react";
|
|
5
5
|
import type { Country as CountryCode } from "react-phone-number-input";
|
|
6
6
|
import PhoneInput from "react-phone-number-input";
|
|
7
|
-
import Select, { components } from "react-select";
|
|
8
|
-
import styled from "styled-components";
|
|
7
|
+
import Select, { GroupBase, StylesConfig, components } from "react-select";
|
|
8
|
+
import styled, { CSSProperties } from "styled-components";
|
|
9
9
|
import { zIndex } from "../ui/zIndex";
|
|
10
10
|
import Error from "./Error";
|
|
11
11
|
import type { InputProps } from "./types";
|
|
12
12
|
import { SelectDataProps } from "./types";
|
|
13
|
-
import { theme } from "../../theme";
|
|
13
|
+
import { theme as importedTheme } from "../../theme";
|
|
14
|
+
export type { Country as CountryCode } from "react-phone-number-input";
|
|
14
15
|
|
|
15
|
-
const colors =
|
|
16
|
+
const colors = importedTheme.colors.light;
|
|
16
17
|
const customStyles = {
|
|
17
18
|
control: (provided: any, state: any) => {
|
|
18
19
|
const before = state.selectProps.label
|
|
@@ -24,45 +25,61 @@ const customStyles = {
|
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
: null;
|
|
28
|
+
const { theme } = state;
|
|
27
29
|
return {
|
|
28
30
|
...provided,
|
|
29
|
-
borderRadius:
|
|
30
|
-
|
|
31
|
+
borderRadius: theme.borderRadius,
|
|
32
|
+
height: theme.controlHeight,
|
|
33
|
+
alignContent: "center",
|
|
34
|
+
padding: "0.4rem 1rem",
|
|
31
35
|
boxShadow: "none",
|
|
32
36
|
":hover": {
|
|
33
|
-
borderColor: colors.
|
|
37
|
+
borderColor: theme.colors.controlHoverBorderColor,
|
|
34
38
|
borderWidth: "1px"
|
|
35
39
|
},
|
|
36
|
-
background: colors.
|
|
40
|
+
background: theme.colors.controlBackground,
|
|
37
41
|
border: state.isFocused
|
|
38
|
-
? `1px solid ${colors.
|
|
39
|
-
: `1px solid ${colors.
|
|
42
|
+
? `1px solid ${theme.colors.controlFocusBorderColor}`
|
|
43
|
+
: `1px solid ${theme.colors.controlUnfocusedBorderColor}`,
|
|
40
44
|
...before
|
|
41
45
|
};
|
|
42
46
|
},
|
|
43
|
-
container: (provided: any, state: any) =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
container: (provided: any, state: any) => {
|
|
48
|
+
return {
|
|
49
|
+
...provided,
|
|
50
|
+
zIndex: state.isFocused ? zIndex.Select + 1 : zIndex.Select,
|
|
51
|
+
position: "relative",
|
|
52
|
+
width: "100%"
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
option: (provided: any, state: any) => {
|
|
56
|
+
const { theme } = state;
|
|
57
|
+
return {
|
|
58
|
+
...provided,
|
|
59
|
+
cursor: state.isDisabled ? "not-allowed" : "pointer",
|
|
60
|
+
opacity: state.isDisabled ? "0.5" : "1",
|
|
61
|
+
background:
|
|
62
|
+
state.isOptionSelected || state.isSelected || state.isFocused
|
|
63
|
+
? theme.colors.selectedOptionBackground
|
|
64
|
+
: theme.colors.unselectedOptionBackground,
|
|
65
|
+
color:
|
|
66
|
+
state.isOptionSelected || state.isSelected
|
|
67
|
+
? theme.colors.selectedOptionColor
|
|
68
|
+
: theme.colors.unselectedOptionColor
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
menu: (provided) => ({
|
|
50
72
|
...provided,
|
|
51
|
-
|
|
52
|
-
opacity: state.isDisabled ? "0.5" : "1",
|
|
53
|
-
background:
|
|
54
|
-
state.isOptionSelected || state.isSelected || state.isFocused
|
|
55
|
-
? colors.lightGrey
|
|
56
|
-
: colors.white,
|
|
57
|
-
color:
|
|
58
|
-
state.isOptionSelected || state.isSelected
|
|
59
|
-
? colors.secondary
|
|
60
|
-
: colors.black
|
|
73
|
+
overflow: "hidden"
|
|
61
74
|
}),
|
|
62
75
|
indicatorSeparator: () => ({
|
|
63
76
|
display: "none"
|
|
64
77
|
})
|
|
65
|
-
}
|
|
78
|
+
} satisfies StylesConfig<
|
|
79
|
+
SelectDataProps<string>,
|
|
80
|
+
false,
|
|
81
|
+
GroupBase<SelectDataProps<string>>
|
|
82
|
+
>;
|
|
66
83
|
|
|
67
84
|
const ControlGrid = styled.div`
|
|
68
85
|
display: flex;
|
|
@@ -92,13 +109,10 @@ const OptionGrid = styled.div`
|
|
|
92
109
|
|
|
93
110
|
const PhoneWrapper = styled.div`
|
|
94
111
|
width: 100%;
|
|
95
|
-
padding-bottom: 0.5rem;
|
|
96
112
|
input {
|
|
97
113
|
width: 100%;
|
|
98
114
|
padding: 1rem;
|
|
99
115
|
gap: 0.5rem;
|
|
100
|
-
background: ${colors.lightGrey};
|
|
101
|
-
border: 1px solid ${colors.border};
|
|
102
116
|
border-radius: 0;
|
|
103
117
|
outline: none;
|
|
104
118
|
font-family: "Plus Jakarta Sans";
|
|
@@ -106,18 +120,34 @@ const PhoneWrapper = styled.div`
|
|
|
106
120
|
}
|
|
107
121
|
`;
|
|
108
122
|
|
|
109
|
-
type
|
|
123
|
+
export type CountrySelectProps = InputProps & {
|
|
110
124
|
countries?: CountryCode[];
|
|
125
|
+
theme?: Partial<{
|
|
126
|
+
controlHeight: CSSProperties["height"];
|
|
127
|
+
borderRadius: CSSProperties["borderRadius"];
|
|
128
|
+
controlHoverBorderColor: CSSProperties["borderColor"];
|
|
129
|
+
controlBackground: CSSProperties["background"];
|
|
130
|
+
controlFocusBorderColor: CSSProperties["borderColor"];
|
|
131
|
+
controlUnfocusedBorderColor: CSSProperties["borderColor"];
|
|
132
|
+
selectedOptionBackground: CSSProperties["background"];
|
|
133
|
+
unselectedOptionBackground: CSSProperties["background"];
|
|
134
|
+
selectedOptionColor: CSSProperties["color"];
|
|
135
|
+
unselectedOptionColor: CSSProperties["color"];
|
|
136
|
+
}>;
|
|
111
137
|
};
|
|
112
138
|
|
|
113
|
-
export function CountrySelect({
|
|
139
|
+
export function CountrySelect({
|
|
140
|
+
name,
|
|
141
|
+
countries,
|
|
142
|
+
theme: selectTheme,
|
|
143
|
+
...rest
|
|
144
|
+
}: CountrySelectProps) {
|
|
114
145
|
const { status } = useFormikContext();
|
|
115
146
|
const [initialized, setInitialized] = useState<boolean>(false);
|
|
116
147
|
const [field, meta, helpers] = useField(name);
|
|
117
148
|
const errorText = meta.error || status?.[name];
|
|
118
149
|
const errorMessage = errorText && meta.touched ? errorText : "";
|
|
119
|
-
const displayError =
|
|
120
|
-
typeof errorMessage === typeof "string" && errorMessage !== "";
|
|
150
|
+
const displayError = typeof errorMessage === "string" && errorMessage !== "";
|
|
121
151
|
const [phone, setPhone] = useState<string | undefined>(undefined);
|
|
122
152
|
const [countryCode, setCountryCode] = useState<CountryCode | undefined>();
|
|
123
153
|
|
|
@@ -131,10 +161,6 @@ export function CountrySelect({ name, countries, ...props }: Props) {
|
|
|
131
161
|
return (
|
|
132
162
|
<>
|
|
133
163
|
<PhoneWrapper>
|
|
134
|
-
{
|
|
135
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, prettier/prettier
|
|
136
|
-
/* @ts-ignore */
|
|
137
|
-
}
|
|
138
164
|
<PhoneInput
|
|
139
165
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
140
166
|
inputComponent={forwardRef((props, ref) => (
|
|
@@ -149,7 +175,37 @@ export function CountrySelect({ name, countries, ...props }: Props) {
|
|
|
149
175
|
<>
|
|
150
176
|
<div>
|
|
151
177
|
<Select
|
|
178
|
+
{...rest}
|
|
152
179
|
{...props}
|
|
180
|
+
isDisabled={rest.disabled}
|
|
181
|
+
theme={(theme) => ({
|
|
182
|
+
...theme,
|
|
183
|
+
controlHeight: selectTheme?.controlHeight,
|
|
184
|
+
borderRadius: selectTheme?.borderRadius || 0,
|
|
185
|
+
colors: {
|
|
186
|
+
...theme.colors,
|
|
187
|
+
controlHoverBorderColor:
|
|
188
|
+
selectTheme?.controlHoverBorderColor ||
|
|
189
|
+
colors.secondary,
|
|
190
|
+
controlBackground:
|
|
191
|
+
selectTheme?.controlBackground || colors.lightGrey,
|
|
192
|
+
controlFocusBorderColor:
|
|
193
|
+
selectTheme?.controlFocusBorderColor ||
|
|
194
|
+
colors.secondary,
|
|
195
|
+
controlUnfocusedBorderColor:
|
|
196
|
+
selectTheme?.controlUnfocusedBorderColor ||
|
|
197
|
+
colors.border,
|
|
198
|
+
selectedOptionBackground:
|
|
199
|
+
selectTheme?.selectedOptionBackground ||
|
|
200
|
+
colors.lightGrey,
|
|
201
|
+
unselectedOptionBackground:
|
|
202
|
+
selectTheme?.unselectedOptionBackground || colors.white,
|
|
203
|
+
selectedOptionColor:
|
|
204
|
+
selectTheme?.selectedOptionColor || colors.secondary,
|
|
205
|
+
unselectedOptionColor:
|
|
206
|
+
selectTheme?.unselectedOptionColor || colors.black
|
|
207
|
+
}
|
|
208
|
+
})}
|
|
153
209
|
styles={customStyles}
|
|
154
210
|
name="countrySelect"
|
|
155
211
|
value={(props?.options || []).find(
|
|
@@ -201,10 +257,7 @@ export function CountrySelect({ name, countries, ...props }: Props) {
|
|
|
201
257
|
)}
|
|
202
258
|
/>
|
|
203
259
|
</PhoneWrapper>
|
|
204
|
-
<Error
|
|
205
|
-
display={!props.hideError && displayError}
|
|
206
|
-
message={errorMessage}
|
|
207
|
-
/>
|
|
260
|
+
<Error display={!rest.hideError && displayError} message={errorMessage} />
|
|
208
261
|
</>
|
|
209
262
|
);
|
|
210
263
|
}
|
|
@@ -15,8 +15,7 @@ export default function DatepickerComponent({
|
|
|
15
15
|
const [field, meta, helpers] = useField(name);
|
|
16
16
|
|
|
17
17
|
const errorMessage = meta.error && meta.touched ? meta.error : "";
|
|
18
|
-
const displayError =
|
|
19
|
-
typeof errorMessage === typeof "string" && errorMessage !== "";
|
|
18
|
+
const displayError = typeof errorMessage === "string" && errorMessage !== "";
|
|
20
19
|
|
|
21
20
|
const handleChange = (date: Dayjs | Array<Dayjs | null>) => {
|
|
22
21
|
if (!meta.touched) {
|
|
@@ -39,8 +39,7 @@ const ColorPicker = styled(Input).attrs({
|
|
|
39
39
|
export default function InputColor({ name, ...props }: InputColorProps) {
|
|
40
40
|
const [field, meta] = useField<string>(name);
|
|
41
41
|
const errorMessage = meta.error && meta.touched ? meta.error : "";
|
|
42
|
-
const displayError =
|
|
43
|
-
typeof errorMessage === typeof "string" && errorMessage !== "";
|
|
42
|
+
const displayError = typeof errorMessage === "string" && errorMessage !== "";
|
|
44
43
|
|
|
45
44
|
return (
|
|
46
45
|
<>
|
|
@@ -138,8 +138,7 @@ export default function Phone({ name, ...props }: InputProps) {
|
|
|
138
138
|
const [field, meta, helpers] = useField(name);
|
|
139
139
|
const errorText = meta.error || status?.[name];
|
|
140
140
|
const errorMessage = errorText && meta.touched ? errorText : "";
|
|
141
|
-
const displayError =
|
|
142
|
-
typeof errorMessage === typeof "string" && errorMessage !== "";
|
|
141
|
+
const displayError = typeof errorMessage === "string" && errorMessage !== "";
|
|
143
142
|
|
|
144
143
|
const handlePhoneChange = useCallback(
|
|
145
144
|
(value: string) => {
|
|
@@ -91,8 +91,7 @@ export default function SelectComponent({
|
|
|
91
91
|
: "";
|
|
92
92
|
|
|
93
93
|
const displayError =
|
|
94
|
-
typeof displayErrorMessage ===
|
|
95
|
-
displayErrorMessage !== "";
|
|
94
|
+
typeof displayErrorMessage === "string" && displayErrorMessage !== "";
|
|
96
95
|
|
|
97
96
|
const handleChange = (option: SelectDataProps<string>) => {
|
|
98
97
|
if (!meta.touched) {
|
|
@@ -6,6 +6,7 @@ export * from "./BaseInput";
|
|
|
6
6
|
export { default as Input, InputProps } from "./Input";
|
|
7
7
|
export { default as Phone } from "./Phone";
|
|
8
8
|
export { default as Select } from "./Select";
|
|
9
|
+
export * from "./CountrySelect";
|
|
9
10
|
export * from "./BaseTagsInput";
|
|
10
11
|
export * from "./BaseTextArea";
|
|
11
12
|
export { default as Upload } from "./Upload/Upload";
|
package/src/index.tsx
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { fn } from "@storybook/test";
|
|
2
|
+
import {
|
|
3
|
+
CountryCode,
|
|
4
|
+
CountrySelect,
|
|
5
|
+
CountrySelectProps,
|
|
6
|
+
theme
|
|
7
|
+
} from "../../index";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { Meta } from "@storybook/react";
|
|
10
|
+
import { Formik } from "formik";
|
|
11
|
+
|
|
12
|
+
const inputWithErrors = "With error";
|
|
13
|
+
const inputName = "test";
|
|
14
|
+
const countries: CountryCode[] = [
|
|
15
|
+
"AR",
|
|
16
|
+
"AU",
|
|
17
|
+
"AT",
|
|
18
|
+
"BE",
|
|
19
|
+
"BR",
|
|
20
|
+
"GR",
|
|
21
|
+
"HK",
|
|
22
|
+
"IS",
|
|
23
|
+
"IN",
|
|
24
|
+
"IE",
|
|
25
|
+
"IL",
|
|
26
|
+
"IT",
|
|
27
|
+
"JP",
|
|
28
|
+
"KR",
|
|
29
|
+
"LU"
|
|
30
|
+
];
|
|
31
|
+
const colors = theme.colors.light;
|
|
32
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
33
|
+
export default {
|
|
34
|
+
title: "Visual Components/Selects/CountrySelect",
|
|
35
|
+
component: CountrySelect,
|
|
36
|
+
parameters: {
|
|
37
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
38
|
+
layout: "centered"
|
|
39
|
+
},
|
|
40
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
41
|
+
tags: ["autodocs"],
|
|
42
|
+
args: { onClick: fn() },
|
|
43
|
+
argTypes: {
|
|
44
|
+
name: {
|
|
45
|
+
table: {
|
|
46
|
+
disable: true // remove name input in controls
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
countries: {
|
|
50
|
+
table: {
|
|
51
|
+
disable: true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
theme: {
|
|
55
|
+
table: {
|
|
56
|
+
disable: true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
disabled: { control: "boolean" },
|
|
60
|
+
placeholder: { control: "text" }
|
|
61
|
+
},
|
|
62
|
+
decorators: [
|
|
63
|
+
(Story, { args, name }) => {
|
|
64
|
+
return (
|
|
65
|
+
<Formik<{ [inputName]: unknown }>
|
|
66
|
+
onSubmit={() => {
|
|
67
|
+
//
|
|
68
|
+
}}
|
|
69
|
+
initialErrors={
|
|
70
|
+
name === inputWithErrors
|
|
71
|
+
? { [inputName]: "There has been an error!" }
|
|
72
|
+
: {}
|
|
73
|
+
}
|
|
74
|
+
initialValues={{ [inputName]: "" }}
|
|
75
|
+
initialTouched={{ [inputName]: true }}
|
|
76
|
+
>
|
|
77
|
+
<Story args={{ ...args, name: inputName }} />
|
|
78
|
+
</Formik>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
} satisfies Meta<typeof CountrySelect>;
|
|
83
|
+
|
|
84
|
+
const BASE_ARGS = {
|
|
85
|
+
name: inputName,
|
|
86
|
+
countries
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
90
|
+
export const Base = {
|
|
91
|
+
args: { ...BASE_ARGS } satisfies CountrySelectProps
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const CustomTheme = {
|
|
95
|
+
args: {
|
|
96
|
+
...BASE_ARGS,
|
|
97
|
+
theme: {
|
|
98
|
+
controlHeight: "45px",
|
|
99
|
+
borderRadius: "30px",
|
|
100
|
+
controlBackground: colors.lightGrey,
|
|
101
|
+
controlFocusBorderColor: colors.blue,
|
|
102
|
+
controlHoverBorderColor: colors.red,
|
|
103
|
+
controlUnfocusedBorderColor: colors.border,
|
|
104
|
+
selectedOptionBackground: colors.lightGrey,
|
|
105
|
+
selectedOptionColor: colors.orange,
|
|
106
|
+
unselectedOptionBackground: colors.white,
|
|
107
|
+
unselectedOptionColor: colors.black
|
|
108
|
+
}
|
|
109
|
+
} satisfies CountrySelectProps
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const WithError = {
|
|
113
|
+
name: inputWithErrors,
|
|
114
|
+
args: {
|
|
115
|
+
...BASE_ARGS,
|
|
116
|
+
placeholder: "this is a placeholder"
|
|
117
|
+
} satisfies CountrySelectProps
|
|
118
|
+
};
|