@algolia/satellite 1.0.0 → 1.1.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/AutoComplete/AutoComplete.d.ts +1 -1
- package/dist/cjs/AutoComplete/AutoComplete.js +49 -26
- package/dist/cjs/AutoComplete/AutoComplete.tailwind.js +9 -1
- package/dist/cjs/AutoComplete/types.d.ts +1 -0
- package/dist/cjs/Checkbox/Checkbox.d.ts +1 -1
- package/dist/cjs/Checkbox/Checkbox.js +21 -13
- package/dist/cjs/Checkbox/Checkbox.tailwind.js +8 -2
- package/dist/cjs/DatePicker/DatePicker/DatePicker.d.ts +4 -2
- package/dist/cjs/DatePicker/DatePicker/DatePicker.js +18 -7
- package/dist/cjs/DatePicker/components/Display.d.ts +3 -3
- package/dist/cjs/DatePicker/components/Display.js +16 -5
- package/dist/cjs/Dropzone/Dropzone.d.ts +4 -2
- package/dist/cjs/Dropzone/Dropzone.js +23 -12
- package/dist/cjs/Field/Field.d.ts +1 -0
- package/dist/cjs/Field/Field.js +63 -11
- package/dist/cjs/Field/FieldContext.d.ts +3 -0
- package/dist/cjs/Field/useField.d.ts +4 -1
- package/dist/cjs/Field/useField.js +17 -1
- package/dist/cjs/Form/Form.d.ts +16 -0
- package/dist/cjs/Form/Form.js +140 -0
- package/dist/cjs/Form/FormContext.d.ts +13 -0
- package/dist/cjs/Form/FormContext.js +8 -0
- package/dist/cjs/Form/index.d.ts +3 -0
- package/dist/cjs/Form/index.js +27 -0
- package/dist/cjs/Form/stories/AsynchronousValidation.js +396 -0
- package/dist/cjs/Form/stories/Complex.js +928 -0
- package/dist/cjs/Form/stories/DependentFieldsValidation.js +249 -0
- package/dist/cjs/Form/stories/DirtyFields.js +339 -0
- package/dist/cjs/Form/stories/DynamicFieldsValidation.js +425 -0
- package/dist/cjs/Form/stories/FieldArrays.js +549 -0
- package/dist/cjs/Form/stories/ValidationStrategies.js +455 -0
- package/dist/cjs/Form/stories/utils/useFormikAutoFocusOnError.js +22 -0
- package/dist/cjs/Form/useForm.d.ts +1 -0
- package/dist/cjs/Form/useForm.js +11 -0
- package/dist/cjs/Input/Input.js +22 -9
- package/dist/cjs/Input/Input.tailwind.js +7 -2
- package/dist/cjs/Pagination/DotPagination/DotPagination.d.ts +1 -1
- package/dist/cjs/RadioGroup/RadioButton.d.ts +1 -1
- package/dist/cjs/RadioGroup/RadioButton.js +16 -3
- package/dist/cjs/RadioGroup/RadioButton.tailwind.js +23 -0
- package/dist/cjs/RadioGroup/RadioGroup.d.ts +7 -5
- package/dist/cjs/RadioGroup/RadioGroup.js +78 -16
- package/dist/cjs/RadioGroup/{RadiogroupContext.d.ts → RadioGroupContext.d.ts} +8 -1
- package/dist/cjs/RangeSlider/RangeSlider.d.ts +2 -3
- package/dist/cjs/RangeSlider/RangeSlider.js +27 -10
- package/dist/cjs/Satellite/locale.d.ts +2 -0
- package/dist/cjs/Select/Select.js +39 -6
- package/dist/cjs/Select/Select.tailwind.js +19 -0
- package/dist/cjs/Stepper/Step.js +2 -2
- package/dist/cjs/Switch/Switch.js +2 -2
- package/dist/cjs/Switch/SwitchOption.js +3 -3
- package/dist/cjs/Tables/DataTable/DataTable.d.ts +1 -1
- package/dist/cjs/Tag/Tag.d.ts +1 -1
- package/dist/cjs/TextArea/TextArea.d.ts +1 -0
- package/dist/cjs/TextArea/TextArea.js +47 -8
- package/dist/cjs/TextArea/TextArea.tailwind.js +41 -4
- package/dist/cjs/Toggle/Toggle.d.ts +1 -1
- package/dist/cjs/Toggle/Toggle.js +23 -6
- package/dist/cjs/Toggle/Toggle.tailwind.js +9 -0
- package/dist/cjs/Tooltip/Tooltip.d.ts +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/utils/isCssPropertySupported.d.ts +1 -1
- package/dist/cjs/utils/mergeRefs.d.ts +2 -0
- package/dist/cjs/utils/mergeRefs.js +17 -0
- package/dist/esm/AutoComplete/AutoComplete.d.ts +1 -1
- package/dist/esm/AutoComplete/AutoComplete.js +52 -27
- package/dist/esm/AutoComplete/AutoComplete.tailwind.js +9 -1
- package/dist/esm/AutoComplete/types.d.ts +1 -0
- package/dist/esm/Checkbox/Checkbox.d.ts +1 -1
- package/dist/esm/Checkbox/Checkbox.js +21 -13
- package/dist/esm/Checkbox/Checkbox.tailwind.js +8 -2
- package/dist/esm/DatePicker/DatePicker/DatePicker.d.ts +4 -2
- package/dist/esm/DatePicker/DatePicker/DatePicker.js +19 -8
- package/dist/esm/DatePicker/components/Display.d.ts +3 -3
- package/dist/esm/DatePicker/components/Display.js +15 -5
- package/dist/esm/Dropzone/Dropzone.d.ts +4 -2
- package/dist/esm/Dropzone/Dropzone.js +24 -13
- package/dist/esm/Field/Field.d.ts +1 -0
- package/dist/esm/Field/Field.js +64 -12
- package/dist/esm/Field/FieldContext.d.ts +3 -0
- package/dist/esm/Field/useField.d.ts +4 -1
- package/dist/esm/Field/useField.js +17 -2
- package/dist/esm/Form/Form.d.ts +16 -0
- package/dist/esm/Form/Form.js +135 -0
- package/dist/esm/Form/FormContext.d.ts +13 -0
- package/dist/esm/Form/FormContext.js +2 -0
- package/dist/esm/Form/index.d.ts +3 -0
- package/dist/esm/Form/index.js +3 -0
- package/dist/esm/Form/stories/AsynchronousValidation.js +387 -0
- package/dist/esm/Form/stories/Complex.js +919 -0
- package/dist/esm/Form/stories/DependentFieldsValidation.js +240 -0
- package/dist/esm/Form/stories/DirtyFields.js +330 -0
- package/dist/esm/Form/stories/DynamicFieldsValidation.js +416 -0
- package/dist/esm/Form/stories/FieldArrays.js +544 -0
- package/dist/esm/Form/stories/ValidationStrategies.js +446 -0
- package/dist/esm/Form/stories/utils/useFormikAutoFocusOnError.js +16 -0
- package/dist/esm/Form/useForm.d.ts +1 -0
- package/dist/esm/Form/useForm.js +5 -0
- package/dist/esm/Input/Input.js +22 -9
- package/dist/esm/Input/Input.tailwind.js +7 -2
- package/dist/esm/Pagination/DotPagination/DotPagination.d.ts +1 -1
- package/dist/esm/RadioGroup/RadioButton.d.ts +1 -1
- package/dist/esm/RadioGroup/RadioButton.js +16 -3
- package/dist/esm/RadioGroup/RadioButton.tailwind.js +23 -0
- package/dist/esm/RadioGroup/RadioGroup.d.ts +7 -5
- package/dist/esm/RadioGroup/RadioGroup.js +77 -15
- package/dist/esm/RadioGroup/{RadiogroupContext.d.ts → RadioGroupContext.d.ts} +8 -1
- package/dist/esm/RangeSlider/RangeSlider.d.ts +2 -3
- package/dist/esm/RangeSlider/RangeSlider.js +27 -10
- package/dist/esm/Satellite/locale.d.ts +2 -0
- package/dist/esm/Select/Select.js +41 -7
- package/dist/esm/Select/Select.tailwind.js +19 -0
- package/dist/esm/Stepper/Step.js +2 -2
- package/dist/esm/Switch/Switch.js +1 -1
- package/dist/esm/Switch/SwitchOption.js +2 -2
- package/dist/esm/Tables/DataTable/DataTable.d.ts +1 -1
- package/dist/esm/Tag/Tag.d.ts +1 -1
- package/dist/esm/TextArea/TextArea.d.ts +1 -0
- package/dist/esm/TextArea/TextArea.js +49 -9
- package/dist/esm/TextArea/TextArea.tailwind.js +41 -4
- package/dist/esm/Toggle/Toggle.d.ts +1 -1
- package/dist/esm/Toggle/Toggle.js +23 -6
- package/dist/esm/Toggle/Toggle.tailwind.js +9 -0
- package/dist/esm/Tooltip/Tooltip.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/isCssPropertySupported.d.ts +1 -1
- package/dist/esm/utils/mergeRefs.d.ts +2 -0
- package/dist/esm/utils/mergeRefs.js +11 -0
- package/dist/satellite.min.css +1 -1
- package/package.json +13 -7
- /package/dist/cjs/RadioGroup/{RadiogroupContext.js → RadioGroupContext.js} +0 -0
- /package/dist/esm/RadioGroup/{RadiogroupContext.js → RadioGroupContext.js} +0 -0
@@ -0,0 +1,919 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37, _templateObject38, _templateObject39, _templateObject40, _templateObject41, _templateObject42, _templateObject43, _templateObject44, _templateObject45, _templateObject46, _templateObject47, _templateObject48;
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
7
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
8
|
+
import { useFormik } from "formik";
|
9
|
+
import capitalize from "lodash/capitalize";
|
10
|
+
import { useState } from "react";
|
11
|
+
import { Controller, useForm } from "react-hook-form";
|
12
|
+
import * as yup from "yup";
|
13
|
+
import { z } from "zod";
|
14
|
+
import { AutoComplete } from "../../AutoComplete";
|
15
|
+
import { Checkbox } from "../../Checkbox";
|
16
|
+
import { DatePicker } from "../../DatePicker";
|
17
|
+
import { Dropzone } from "../../Dropzone";
|
18
|
+
import { Field } from "../../Field";
|
19
|
+
import { Input } from "../../Input";
|
20
|
+
import { RadioButton, RadioGroup } from "../../RadioGroup";
|
21
|
+
import { RangeSlider } from "../../RangeSlider";
|
22
|
+
import { Select } from "../../Select";
|
23
|
+
import stl from "../../styles/helpers/satellitePrefixer";
|
24
|
+
import { TextArea } from "../../TextArea";
|
25
|
+
import { Toggle } from "../../Toggle";
|
26
|
+
import { ExperimentalForm, ExperimentalFormErrorMessage, ExperimentalFormReset, ExperimentalFormSubmit } from "../Form";
|
27
|
+
import { useFormikAutoFocusOnError } from "./utils/useFormikAutoFocusOnError";
|
28
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
29
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
30
|
+
var initialFormData = {
|
31
|
+
firstName: "",
|
32
|
+
lastName: "",
|
33
|
+
password: "",
|
34
|
+
civility: "",
|
35
|
+
gender: "",
|
36
|
+
jobPositions: [],
|
37
|
+
employmentStatus: "",
|
38
|
+
birthday: null,
|
39
|
+
age: "",
|
40
|
+
interest: 0,
|
41
|
+
idealLocation: [0, 50],
|
42
|
+
profilePicture: null,
|
43
|
+
bio: "",
|
44
|
+
acceptTerms: false,
|
45
|
+
newsletter: false
|
46
|
+
};
|
47
|
+
var civilities = ["Mr", "Mrs", "Ms"];
|
48
|
+
var jobPositions = ["Frontend Developer", "Backend Developer", "Fullstack Developer"].map(function (jobPosition) {
|
49
|
+
return {
|
50
|
+
label: jobPosition,
|
51
|
+
value: jobPosition
|
52
|
+
};
|
53
|
+
});
|
54
|
+
var now = new Date();
|
55
|
+
var genders = ["please select", "woman", "man", "transgender man", "transgender woman", "non-binary", "agender", "prefer not to state"];
|
56
|
+
var employmentStatuses = ["employed", "unemployed", "student"];
|
57
|
+
var zodSchema = z.object({
|
58
|
+
firstName: z.string().min(1, {
|
59
|
+
message: "You must specify a first name"
|
60
|
+
}).min(3, {
|
61
|
+
message: "First name must be at least 3 characters long"
|
62
|
+
}).refine(function (val) {
|
63
|
+
return val.toLowerCase() !== "john";
|
64
|
+
}, {
|
65
|
+
message: "John is not allowed"
|
66
|
+
}),
|
67
|
+
lastName: z.string().min(1, {
|
68
|
+
message: "You must specify a last name"
|
69
|
+
}).min(3, {
|
70
|
+
message: "Last name must be at least 3 characters long"
|
71
|
+
}),
|
72
|
+
password: z.string().min(1, {
|
73
|
+
message: "You must specify a password"
|
74
|
+
}).min(5, "Password must be at least 5 characters long"),
|
75
|
+
civility: z["enum"](civilities, {
|
76
|
+
errorMap: function errorMap() {
|
77
|
+
return {
|
78
|
+
message: "You must specify a civility"
|
79
|
+
};
|
80
|
+
}
|
81
|
+
}),
|
82
|
+
gender: z["enum"](genders, {
|
83
|
+
errorMap: function errorMap() {
|
84
|
+
return {
|
85
|
+
message: "You must specify a gender"
|
86
|
+
};
|
87
|
+
}
|
88
|
+
}).refine(function (val) {
|
89
|
+
return val !== "please select";
|
90
|
+
}, {
|
91
|
+
message: "You must specify a gender"
|
92
|
+
}),
|
93
|
+
jobPositions: z.array(z.object({
|
94
|
+
label: z.string(),
|
95
|
+
value: z.string()
|
96
|
+
})).min(1, {
|
97
|
+
message: "You must specify at least one job position"
|
98
|
+
}),
|
99
|
+
birthday: z.date({
|
100
|
+
errorMap: function errorMap() {
|
101
|
+
return {
|
102
|
+
message: "You must specify a birthday"
|
103
|
+
};
|
104
|
+
}
|
105
|
+
}),
|
106
|
+
age: z.coerce.number().min(1, {
|
107
|
+
message: "You must specify an age"
|
108
|
+
}).gte(18, {
|
109
|
+
message: "You must be at least 18 years old"
|
110
|
+
}).lte(100, {
|
111
|
+
message: "You must be at most 100 years old"
|
112
|
+
}),
|
113
|
+
interest: z.number().min(5, {
|
114
|
+
message: "Your level of interest must be at least 5"
|
115
|
+
}),
|
116
|
+
idealLocation: z.array(z.number().gte(10, {
|
117
|
+
message: "Your minimum ideal location must be 10 km"
|
118
|
+
}).lte(40, {
|
119
|
+
message: "Your maximum ideal location must be 40 km"
|
120
|
+
})),
|
121
|
+
employmentStatus: z["enum"](employmentStatuses, {
|
122
|
+
errorMap: function errorMap() {
|
123
|
+
return {
|
124
|
+
message: "You must specify an employment status"
|
125
|
+
};
|
126
|
+
}
|
127
|
+
}),
|
128
|
+
profilePicture: z.object({
|
129
|
+
file: z["instanceof"](File).optional(),
|
130
|
+
path: z.string().optional(),
|
131
|
+
errors: z.array(z.object({
|
132
|
+
code: z.string(),
|
133
|
+
message: z.string()
|
134
|
+
})).optional()
|
135
|
+
}).nullable().refine(function (val) {
|
136
|
+
return val !== null && !val.errors;
|
137
|
+
}, function (val) {
|
138
|
+
var _val$errors;
|
139
|
+
return {
|
140
|
+
message: val === null ? "You must upload a profile picture" : (_val$errors = val.errors) === null || _val$errors === void 0 ? void 0 : _val$errors.map(function (error) {
|
141
|
+
return error.message;
|
142
|
+
}).join(", ")
|
143
|
+
};
|
144
|
+
}),
|
145
|
+
bio: z.string().min(1, {
|
146
|
+
message: "You must specify a bio"
|
147
|
+
}).min(10, {
|
148
|
+
message: "Your bio must be at least 10 characters long"
|
149
|
+
}),
|
150
|
+
acceptTerms: z["boolean"]().refine(function (val) {
|
151
|
+
return val;
|
152
|
+
}, {
|
153
|
+
message: "You must accept the terms"
|
154
|
+
}),
|
155
|
+
newsletter: z["boolean"]().refine(function (val) {
|
156
|
+
return val;
|
157
|
+
}, {
|
158
|
+
message: "You must accept to receive the newsletter"
|
159
|
+
})
|
160
|
+
});
|
161
|
+
export var RHFComplexComponent = function RHFComplexComponent() {
|
162
|
+
var _useForm = useForm({
|
163
|
+
resolver: zodResolver(zodSchema),
|
164
|
+
defaultValues: initialFormData,
|
165
|
+
reValidateMode: "onChange"
|
166
|
+
}),
|
167
|
+
control = _useForm.control,
|
168
|
+
handleSubmit = _useForm.handleSubmit,
|
169
|
+
getFieldStateFromReactHookForm = _useForm.getFieldState,
|
170
|
+
formState = _useForm.formState,
|
171
|
+
reset = _useForm.reset,
|
172
|
+
getValues = _useForm.getValues;
|
173
|
+
var _useState = useState(initialFormData),
|
174
|
+
_useState2 = _slicedToArray(_useState, 2),
|
175
|
+
formData = _useState2[0],
|
176
|
+
setFormData = _useState2[1];
|
177
|
+
var getFieldState = function getFieldState(fieldName) {
|
178
|
+
var fieldState = getFieldStateFromReactHookForm(fieldName, formState);
|
179
|
+
var fieldErrors = fieldState.error ? Array.isArray(fieldState.error) ? fieldState.error : [fieldState.error] : [];
|
180
|
+
if (fieldErrors.length > 0) {
|
181
|
+
return {
|
182
|
+
status: "invalid",
|
183
|
+
errors: fieldErrors.map(function (error) {
|
184
|
+
return error.message;
|
185
|
+
})
|
186
|
+
};
|
187
|
+
} else if (!fieldState.invalid && formState.isSubmitted) {
|
188
|
+
return {
|
189
|
+
status: "validated"
|
190
|
+
};
|
191
|
+
} else {
|
192
|
+
return {
|
193
|
+
status: "default"
|
194
|
+
};
|
195
|
+
}
|
196
|
+
};
|
197
|
+
return /*#__PURE__*/_jsxs("div", {
|
198
|
+
className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["flex flex-col gap-8 w-3/5"]))),
|
199
|
+
children: [/*#__PURE__*/_jsxs(ExperimentalForm, {
|
200
|
+
onSubmit: handleSubmit(function (data) {
|
201
|
+
return setFormData(data);
|
202
|
+
}),
|
203
|
+
onReset: function onReset() {
|
204
|
+
return setFormData(initialFormData);
|
205
|
+
},
|
206
|
+
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["flex flex-col items-start gap-4 min-w-72"]))),
|
207
|
+
children: [/*#__PURE__*/_jsx(ExperimentalFormErrorMessage, {}), /*#__PURE__*/_jsx(Controller, {
|
208
|
+
name: "firstName",
|
209
|
+
control: control,
|
210
|
+
render: function render(_ref) {
|
211
|
+
var field = _ref.field;
|
212
|
+
return /*#__PURE__*/_jsx(Field, {
|
213
|
+
label: "First Name",
|
214
|
+
labelFor: "firstName",
|
215
|
+
description: "Please enter your first name",
|
216
|
+
state: getFieldState("firstName"),
|
217
|
+
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["w-full"]))),
|
218
|
+
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
219
|
+
id: "firstName",
|
220
|
+
placeholder: "John",
|
221
|
+
required: true
|
222
|
+
}, field))
|
223
|
+
});
|
224
|
+
}
|
225
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
226
|
+
name: "lastName",
|
227
|
+
control: control,
|
228
|
+
render: function render(_ref2) {
|
229
|
+
var field = _ref2.field;
|
230
|
+
return /*#__PURE__*/_jsx(Field, {
|
231
|
+
label: "Last Name",
|
232
|
+
labelFor: "lastName",
|
233
|
+
description: "Please enter your last name",
|
234
|
+
state: getFieldState("lastName"),
|
235
|
+
className: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["w-full"]))),
|
236
|
+
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
237
|
+
id: "lastName",
|
238
|
+
placeholder: "Doe",
|
239
|
+
required: true
|
240
|
+
}, field))
|
241
|
+
});
|
242
|
+
}
|
243
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
244
|
+
name: "password",
|
245
|
+
control: control,
|
246
|
+
render: function render(_ref3) {
|
247
|
+
var field = _ref3.field;
|
248
|
+
return /*#__PURE__*/_jsx(Field, {
|
249
|
+
label: "Password",
|
250
|
+
labelFor: "password",
|
251
|
+
description: "Please enter your password",
|
252
|
+
state: getFieldState("password"),
|
253
|
+
className: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["w-full"]))),
|
254
|
+
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
255
|
+
id: "password",
|
256
|
+
placeholder: "Password",
|
257
|
+
type: "password",
|
258
|
+
required: true
|
259
|
+
}, field))
|
260
|
+
});
|
261
|
+
}
|
262
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
263
|
+
name: "civility",
|
264
|
+
control: control,
|
265
|
+
render: function render(_ref4) {
|
266
|
+
var field = _ref4.field;
|
267
|
+
return /*#__PURE__*/_jsx(Field, {
|
268
|
+
label: "Civility",
|
269
|
+
labelFor: civilities[0],
|
270
|
+
description: "Please enter your civility",
|
271
|
+
state: getFieldState("civility"),
|
272
|
+
className: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["w-full"]))),
|
273
|
+
children: /*#__PURE__*/_jsx("div", {
|
274
|
+
className: stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["flex gap-4 display-body"]))),
|
275
|
+
children: civilities.map(function (civility) {
|
276
|
+
return /*#__PURE__*/_jsxs("label", {
|
277
|
+
htmlFor: civility,
|
278
|
+
className: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["flex items-center gap-1"]))),
|
279
|
+
children: [/*#__PURE__*/_jsx(RadioButton, _objectSpread(_objectSpread({
|
280
|
+
id: civility,
|
281
|
+
"aria-labelledby": civility,
|
282
|
+
required: true,
|
283
|
+
checked: civility === field.value
|
284
|
+
}, field), {}, {
|
285
|
+
value: civility
|
286
|
+
})), capitalize(civility)]
|
287
|
+
}, civility);
|
288
|
+
})
|
289
|
+
})
|
290
|
+
});
|
291
|
+
}
|
292
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
293
|
+
name: "gender",
|
294
|
+
control: control,
|
295
|
+
render: function render(_ref5) {
|
296
|
+
var field = _ref5.field;
|
297
|
+
return /*#__PURE__*/_jsx(Field, {
|
298
|
+
label: "Gender",
|
299
|
+
labelFor: "gender",
|
300
|
+
description: "Please specify your gender",
|
301
|
+
state: getFieldState("gender"),
|
302
|
+
className: stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["w-full"]))),
|
303
|
+
children: /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({
|
304
|
+
id: "gender",
|
305
|
+
required: true
|
306
|
+
}, field), {}, {
|
307
|
+
children: genders.map(function (gender) {
|
308
|
+
return /*#__PURE__*/_jsx("option", {
|
309
|
+
value: gender,
|
310
|
+
children: capitalize(gender)
|
311
|
+
}, gender);
|
312
|
+
})
|
313
|
+
}))
|
314
|
+
});
|
315
|
+
}
|
316
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
317
|
+
name: "jobPositions",
|
318
|
+
control: control,
|
319
|
+
render: function render(_ref6) {
|
320
|
+
var field = _ref6.field;
|
321
|
+
return /*#__PURE__*/_jsx(Field, {
|
322
|
+
label: "Job Positions",
|
323
|
+
labelFor: "jobPositions",
|
324
|
+
description: "Please specify the job positions you are interested in",
|
325
|
+
state: getFieldState("jobPositions"),
|
326
|
+
className: stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["w-full"]))),
|
327
|
+
children: /*#__PURE__*/_jsx(AutoComplete, _objectSpread({
|
328
|
+
id: "jobPositions",
|
329
|
+
options: jobPositions,
|
330
|
+
placeholder: jobPositions[0].label,
|
331
|
+
multiple: true,
|
332
|
+
required: true,
|
333
|
+
clearable: true
|
334
|
+
}, field))
|
335
|
+
});
|
336
|
+
}
|
337
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
338
|
+
name: "employmentStatus",
|
339
|
+
control: control,
|
340
|
+
render: function render(_ref7) {
|
341
|
+
var field = _ref7.field;
|
342
|
+
return /*#__PURE__*/_jsx(Field, {
|
343
|
+
label: "Employment Status",
|
344
|
+
labelFor: "employmentStatus",
|
345
|
+
description: "Please specify your employment status",
|
346
|
+
state: getFieldState("employmentStatus"),
|
347
|
+
className: stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["w-full"]))),
|
348
|
+
children: /*#__PURE__*/_jsx(RadioGroup, _objectSpread(_objectSpread({
|
349
|
+
id: "employmentStatus",
|
350
|
+
required: true
|
351
|
+
}, field), {}, {
|
352
|
+
children: employmentStatuses.map(function (employmentStatus) {
|
353
|
+
return /*#__PURE__*/_jsx(RadioGroup.Item, {
|
354
|
+
value: employmentStatus,
|
355
|
+
children: capitalize(employmentStatus)
|
356
|
+
}, employmentStatus);
|
357
|
+
})
|
358
|
+
}))
|
359
|
+
});
|
360
|
+
}
|
361
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
362
|
+
name: "birthday",
|
363
|
+
control: control,
|
364
|
+
render: function render(_ref8) {
|
365
|
+
var field = _ref8.field;
|
366
|
+
return /*#__PURE__*/_jsx(Field, {
|
367
|
+
label: "Birthday",
|
368
|
+
labelFor: "birthday",
|
369
|
+
description: "Please specify your birthday",
|
370
|
+
state: getFieldState("birthday"),
|
371
|
+
className: stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["w-full"]))),
|
372
|
+
children: /*#__PURE__*/_jsx(DatePicker, _objectSpread({
|
373
|
+
id: "birthday",
|
374
|
+
calendarProps: {
|
375
|
+
disabled: {
|
376
|
+
after: now
|
377
|
+
}
|
378
|
+
},
|
379
|
+
required: true
|
380
|
+
}, field))
|
381
|
+
});
|
382
|
+
}
|
383
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
384
|
+
name: "age",
|
385
|
+
control: control,
|
386
|
+
render: function render(_ref9) {
|
387
|
+
var field = _ref9.field;
|
388
|
+
return /*#__PURE__*/_jsx(Field, {
|
389
|
+
label: "Age",
|
390
|
+
labelFor: "age",
|
391
|
+
description: "Please specify your age",
|
392
|
+
state: getFieldState("age"),
|
393
|
+
className: stl(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["w-full"]))),
|
394
|
+
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
395
|
+
id: "age",
|
396
|
+
type: "number",
|
397
|
+
placeholder: "18",
|
398
|
+
step: 1,
|
399
|
+
required: true
|
400
|
+
}, field))
|
401
|
+
});
|
402
|
+
}
|
403
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
404
|
+
name: "interest",
|
405
|
+
control: control,
|
406
|
+
render: function render(_ref10) {
|
407
|
+
var field = _ref10.field;
|
408
|
+
return /*#__PURE__*/_jsxs(Field, {
|
409
|
+
label: "Interest",
|
410
|
+
labelFor: "interest",
|
411
|
+
description: "Please specify your interest",
|
412
|
+
state: getFieldState("interest"),
|
413
|
+
className: stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["w-full"]))),
|
414
|
+
children: [/*#__PURE__*/_jsxs("p", {
|
415
|
+
className: stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["display-caption flex justify-between mb-2"]))),
|
416
|
+
children: [/*#__PURE__*/_jsx("span", {
|
417
|
+
children: "0"
|
418
|
+
}), /*#__PURE__*/_jsx("span", {
|
419
|
+
children: "5"
|
420
|
+
}), /*#__PURE__*/_jsx("span", {
|
421
|
+
children: "10"
|
422
|
+
})]
|
423
|
+
}), /*#__PURE__*/_jsx(RangeSlider, _objectSpread({
|
424
|
+
id: "interest",
|
425
|
+
min: 0,
|
426
|
+
max: 10,
|
427
|
+
required: true
|
428
|
+
}, field))]
|
429
|
+
});
|
430
|
+
}
|
431
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
432
|
+
name: "idealLocation",
|
433
|
+
control: control,
|
434
|
+
render: function render(_ref11) {
|
435
|
+
var field = _ref11.field;
|
436
|
+
return /*#__PURE__*/_jsxs(Field, {
|
437
|
+
label: "Ideal Location",
|
438
|
+
labelFor: "idealLocation",
|
439
|
+
description: "Please specify your ideal location",
|
440
|
+
state: getFieldState("idealLocation"),
|
441
|
+
className: stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["w-full"]))),
|
442
|
+
children: [/*#__PURE__*/_jsxs("p", {
|
443
|
+
className: stl(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["display-caption flex justify-between mb-2"]))),
|
444
|
+
children: [/*#__PURE__*/_jsx("span", {
|
445
|
+
children: "0 km"
|
446
|
+
}), /*#__PURE__*/_jsx("span", {
|
447
|
+
children: "10 km"
|
448
|
+
}), /*#__PURE__*/_jsx("span", {
|
449
|
+
children: "20 km"
|
450
|
+
}), /*#__PURE__*/_jsx("span", {
|
451
|
+
children: "30 km"
|
452
|
+
}), /*#__PURE__*/_jsx("span", {
|
453
|
+
children: "40 km"
|
454
|
+
}), /*#__PURE__*/_jsx("span", {
|
455
|
+
children: "50 km"
|
456
|
+
})]
|
457
|
+
}), /*#__PURE__*/_jsx(RangeSlider, _objectSpread({
|
458
|
+
id: "idealLocation",
|
459
|
+
min: 0,
|
460
|
+
max: 50,
|
461
|
+
step: 10,
|
462
|
+
required: true
|
463
|
+
}, field))]
|
464
|
+
});
|
465
|
+
}
|
466
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
467
|
+
name: "profilePicture",
|
468
|
+
control: control,
|
469
|
+
render: function render(_ref12) {
|
470
|
+
var field = _ref12.field;
|
471
|
+
return /*#__PURE__*/_jsx(Field, {
|
472
|
+
label: "Profile Picture",
|
473
|
+
labelFor: "profilePicture",
|
474
|
+
description: "Please upload your profile picture, 1 MB minimum",
|
475
|
+
state: getFieldState("profilePicture"),
|
476
|
+
className: stl(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["w-full"]))),
|
477
|
+
children: /*#__PURE__*/_jsx(Dropzone, _objectSpread(_objectSpread({
|
478
|
+
id: "profilePicture",
|
479
|
+
minSize: 1024 * 1024 * 1,
|
480
|
+
accept: [".png", ".jpg"],
|
481
|
+
required: true
|
482
|
+
}, field), {}, {
|
483
|
+
onChange: function onChange(acceptedFiles, rejectedFiles) {
|
484
|
+
return field.onChange(rejectedFiles.length > 0 ? rejectedFiles[0] : acceptedFiles[0]);
|
485
|
+
}
|
486
|
+
}))
|
487
|
+
});
|
488
|
+
}
|
489
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
490
|
+
name: "bio",
|
491
|
+
control: control,
|
492
|
+
render: function render(_ref13) {
|
493
|
+
var field = _ref13.field;
|
494
|
+
return /*#__PURE__*/_jsx(Field, {
|
495
|
+
label: "Bio",
|
496
|
+
labelFor: "bio",
|
497
|
+
description: "Please write a short bio",
|
498
|
+
state: getFieldState("bio"),
|
499
|
+
className: stl(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["w-full"]))),
|
500
|
+
children: /*#__PURE__*/_jsx(TextArea, _objectSpread({
|
501
|
+
id: "bio",
|
502
|
+
required: true
|
503
|
+
}, field))
|
504
|
+
});
|
505
|
+
}
|
506
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
507
|
+
name: "acceptTerms",
|
508
|
+
control: control,
|
509
|
+
render: function render(_ref14) {
|
510
|
+
var field = _ref14.field;
|
511
|
+
return /*#__PURE__*/_jsx(Field, {
|
512
|
+
label: "Accept Terms",
|
513
|
+
labelFor: "acceptTerms",
|
514
|
+
description: "Please accept the terms",
|
515
|
+
state: getFieldState("acceptTerms"),
|
516
|
+
className: stl(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["w-full"]))),
|
517
|
+
inline: true,
|
518
|
+
children: /*#__PURE__*/_jsx(Checkbox, _objectSpread({
|
519
|
+
id: "acceptTerms",
|
520
|
+
required: true,
|
521
|
+
checked: getValues("acceptTerms")
|
522
|
+
}, field))
|
523
|
+
});
|
524
|
+
}
|
525
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
526
|
+
name: "newsletter",
|
527
|
+
control: control,
|
528
|
+
render: function render(_ref15) {
|
529
|
+
var field = _ref15.field;
|
530
|
+
return /*#__PURE__*/_jsx(Field, {
|
531
|
+
label: "Receive Newsletter",
|
532
|
+
labelFor: "newsletter",
|
533
|
+
description: "Do you want to receive our newsletter?",
|
534
|
+
state: getFieldState("newsletter"),
|
535
|
+
className: stl(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["w-full"]))),
|
536
|
+
inline: true,
|
537
|
+
children: /*#__PURE__*/_jsx(Toggle, _objectSpread({
|
538
|
+
id: "newsletter",
|
539
|
+
required: true,
|
540
|
+
checked: getValues("newsletter")
|
541
|
+
}, field))
|
542
|
+
});
|
543
|
+
}
|
544
|
+
}), /*#__PURE__*/_jsxs("div", {
|
545
|
+
className: stl(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["flex gap-2"]))),
|
546
|
+
children: [/*#__PURE__*/_jsx(ExperimentalFormSubmit, {
|
547
|
+
variant: "primary",
|
548
|
+
"aria-label": "Save the form",
|
549
|
+
children: "Save"
|
550
|
+
}), /*#__PURE__*/_jsx(ExperimentalFormReset, {
|
551
|
+
"aria-label": "Reset the form",
|
552
|
+
onClick: function onClick() {
|
553
|
+
return reset();
|
554
|
+
},
|
555
|
+
children: "Reset"
|
556
|
+
})]
|
557
|
+
})]
|
558
|
+
}), /*#__PURE__*/_jsx("hr", {
|
559
|
+
className: stl(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["text-grey-500"])))
|
560
|
+
}), /*#__PURE__*/_jsx("code", {
|
561
|
+
className: stl(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["whitespace-pre"]))),
|
562
|
+
children: JSON.stringify(formData, null, 2)
|
563
|
+
})]
|
564
|
+
});
|
565
|
+
};
|
566
|
+
var yupSchema = yup.object({
|
567
|
+
firstName: yup.string().min(3, "First name must be at least 3 characters long").matches(/^(?!john$).*/i, "John is not allowed").required("You must specify a first name"),
|
568
|
+
lastName: yup.string().min(3, "Last name must be at least 3 characters long").required("You must specify a last name"),
|
569
|
+
password: yup.string().min(5, "Password must be at least 5 characters long").required("You must specify a password"),
|
570
|
+
civility: yup.string().oneOf(civilities).required("You must specify a civility"),
|
571
|
+
gender: yup.string().oneOf(genders.slice(1), "You must specify a gender").required("You must specify a gender"),
|
572
|
+
jobPositions: yup.array(yup.object({
|
573
|
+
label: yup.string(),
|
574
|
+
value: yup.string()
|
575
|
+
})).min(1, "You must specify at least one job position"),
|
576
|
+
employmentStatus: yup.string().oneOf(employmentStatuses).required("You must specify an employment status"),
|
577
|
+
birthday: yup.date().required("You must specify a birthday"),
|
578
|
+
age: yup.number().min(18, "You must be at least 18 years old").max(100, "You must be at most 100 years old").required("You must specify an age"),
|
579
|
+
interest: yup.number().min(5, "Your level of interest must be at least 5").required(),
|
580
|
+
idealLocation: yup.array(yup.number().min(10, "Your minimum ideal location must be 10 km").max(40, "Your maximum ideal location must be 40 km").required()).required(),
|
581
|
+
profilePicture: yup.mixed().nullable().test("profilePicture", function (_ref16) {
|
582
|
+
var value = _ref16.value;
|
583
|
+
return value.errors.map(function (error) {
|
584
|
+
return error.message;
|
585
|
+
}).join(", ");
|
586
|
+
}, function (value) {
|
587
|
+
return typeof value.errors === "undefined";
|
588
|
+
}).required("You must upload a profile picture"),
|
589
|
+
bio: yup.string().min(10, "Your bio must be at least 10 characters long").required("You must specify a bio"),
|
590
|
+
acceptTerms: yup["boolean"]().oneOf([true], "You must accept the terms").required(),
|
591
|
+
newsletter: yup["boolean"]().oneOf([true], "You must accept to receive the newsletter").required()
|
592
|
+
});
|
593
|
+
export var FormikComplexComponent = function FormikComplexComponent() {
|
594
|
+
var _useState3 = useState(initialFormData),
|
595
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
596
|
+
formData = _useState4[0],
|
597
|
+
setFormData = _useState4[1];
|
598
|
+
var _useState5 = useState(false),
|
599
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
600
|
+
revalidationEnabled = _useState6[0],
|
601
|
+
setRevalidationEnabled = _useState6[1];
|
602
|
+
var formik = useFormik({
|
603
|
+
initialValues: initialFormData,
|
604
|
+
validateOnChange: revalidationEnabled,
|
605
|
+
validateOnBlur: revalidationEnabled,
|
606
|
+
validationSchema: yupSchema,
|
607
|
+
onSubmit: function onSubmit(values) {
|
608
|
+
return setFormData(values);
|
609
|
+
},
|
610
|
+
onReset: function onReset() {
|
611
|
+
return setFormData(initialFormData);
|
612
|
+
}
|
613
|
+
});
|
614
|
+
var getFieldState = function getFieldState(fieldName) {
|
615
|
+
var fieldMeta = formik.getFieldMeta(fieldName);
|
616
|
+
var fieldErrors = fieldMeta.error ? Array.isArray(fieldMeta.error) ? fieldMeta.error : [fieldMeta.error] : [];
|
617
|
+
if (fieldErrors.length > 0) {
|
618
|
+
return {
|
619
|
+
status: "invalid",
|
620
|
+
errors: fieldErrors
|
621
|
+
};
|
622
|
+
} else if (formik.isSubmitting && fieldMeta.touched) {
|
623
|
+
return {
|
624
|
+
status: "validated"
|
625
|
+
};
|
626
|
+
} else {
|
627
|
+
return {
|
628
|
+
status: "default"
|
629
|
+
};
|
630
|
+
}
|
631
|
+
};
|
632
|
+
useFormikAutoFocusOnError(formik);
|
633
|
+
return /*#__PURE__*/_jsxs("div", {
|
634
|
+
className: stl(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["flex flex-col gap-8 w-3/5"]))),
|
635
|
+
children: [/*#__PURE__*/_jsxs(ExperimentalForm, {
|
636
|
+
onSubmit: function onSubmit(e) {
|
637
|
+
setRevalidationEnabled(true);
|
638
|
+
formik.handleSubmit(e);
|
639
|
+
},
|
640
|
+
onReset: function onReset(e) {
|
641
|
+
setRevalidationEnabled(false);
|
642
|
+
formik.handleReset(e);
|
643
|
+
},
|
644
|
+
className: stl(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["flex flex-col items-start gap-4 min-w-72"]))),
|
645
|
+
children: [/*#__PURE__*/_jsx(ExperimentalFormErrorMessage, {}), /*#__PURE__*/_jsx(Field, {
|
646
|
+
label: "First Name",
|
647
|
+
labelFor: "firstName",
|
648
|
+
description: "Please enter your first name",
|
649
|
+
state: getFieldState("firstName"),
|
650
|
+
className: stl(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["w-full"]))),
|
651
|
+
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
652
|
+
id: "firstName",
|
653
|
+
placeholder: "John",
|
654
|
+
required: true
|
655
|
+
}, formik.getFieldProps("firstName")))
|
656
|
+
}), /*#__PURE__*/_jsx(Field, {
|
657
|
+
label: "Last Name",
|
658
|
+
labelFor: "lastName",
|
659
|
+
description: "Please enter your last name",
|
660
|
+
state: getFieldState("lastName"),
|
661
|
+
className: stl(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["w-full"]))),
|
662
|
+
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
663
|
+
id: "lastName",
|
664
|
+
placeholder: "Doe",
|
665
|
+
required: true
|
666
|
+
}, formik.getFieldProps("lastName")))
|
667
|
+
}), /*#__PURE__*/_jsx(Field, {
|
668
|
+
label: "Password",
|
669
|
+
labelFor: "password",
|
670
|
+
description: "Please enter your password",
|
671
|
+
state: getFieldState("password"),
|
672
|
+
className: stl(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["w-full"]))),
|
673
|
+
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
674
|
+
id: "password",
|
675
|
+
placeholder: "Password",
|
676
|
+
type: "password",
|
677
|
+
required: true
|
678
|
+
}, formik.getFieldProps("password")))
|
679
|
+
}), /*#__PURE__*/_jsx(Field, {
|
680
|
+
label: "Civility",
|
681
|
+
labelFor: civilities[0],
|
682
|
+
description: "Please enter your civility",
|
683
|
+
state: getFieldState("civility"),
|
684
|
+
className: stl(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["w-full"]))),
|
685
|
+
children: /*#__PURE__*/_jsx("div", {
|
686
|
+
className: stl(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["flex gap-4 display-body"]))),
|
687
|
+
children: civilities.map(function (civility, index) {
|
688
|
+
return /*#__PURE__*/_jsxs("label", {
|
689
|
+
id: index === 0 ? "civility" : undefined,
|
690
|
+
htmlFor: civility,
|
691
|
+
className: stl(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["flex items-center gap-1"]))),
|
692
|
+
children: [/*#__PURE__*/_jsx(RadioButton, _objectSpread({
|
693
|
+
id: civility,
|
694
|
+
"aria-labelledby": civility,
|
695
|
+
required: true
|
696
|
+
}, formik.getFieldProps({
|
697
|
+
name: "civility",
|
698
|
+
value: civility,
|
699
|
+
type: "radio"
|
700
|
+
}))), capitalize(civility)]
|
701
|
+
}, civility);
|
702
|
+
})
|
703
|
+
})
|
704
|
+
}), /*#__PURE__*/_jsx(Field, {
|
705
|
+
label: "Gender",
|
706
|
+
labelFor: "gender",
|
707
|
+
description: "Please specify your gender",
|
708
|
+
state: getFieldState("gender"),
|
709
|
+
className: stl(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["w-full"]))),
|
710
|
+
children: /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({
|
711
|
+
id: "gender",
|
712
|
+
required: true
|
713
|
+
}, formik.getFieldProps("gender")), {}, {
|
714
|
+
children: genders.map(function (gender) {
|
715
|
+
return /*#__PURE__*/_jsx("option", {
|
716
|
+
value: gender,
|
717
|
+
children: capitalize(gender)
|
718
|
+
}, gender);
|
719
|
+
})
|
720
|
+
}))
|
721
|
+
}), /*#__PURE__*/_jsx(Field, {
|
722
|
+
label: "Job Positions",
|
723
|
+
labelFor: "jobPositions",
|
724
|
+
description: "Please specify the job positions you are interested in",
|
725
|
+
state: getFieldState("jobPositions"),
|
726
|
+
className: stl(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["w-full"]))),
|
727
|
+
children: /*#__PURE__*/_jsx(AutoComplete, {
|
728
|
+
id: "jobPositions",
|
729
|
+
options: jobPositions,
|
730
|
+
placeholder: jobPositions[0].label,
|
731
|
+
multiple: true,
|
732
|
+
required: true,
|
733
|
+
clearable: true,
|
734
|
+
onChange: function onChange(value) {
|
735
|
+
return formik.setFieldValue("jobPositions", value);
|
736
|
+
},
|
737
|
+
onBlur: formik.handleBlur,
|
738
|
+
value: formik.values.jobPositions
|
739
|
+
})
|
740
|
+
}), /*#__PURE__*/_jsx(Field, {
|
741
|
+
label: "Employment Status",
|
742
|
+
labelFor: "employmentStatus",
|
743
|
+
description: "Please specify your employment status",
|
744
|
+
state: getFieldState("employmentStatus"),
|
745
|
+
className: stl(_templateObject35 || (_templateObject35 = _taggedTemplateLiteral(["w-full"]))),
|
746
|
+
children: /*#__PURE__*/_jsx(RadioGroup, {
|
747
|
+
id: "employmentStatus",
|
748
|
+
required: true,
|
749
|
+
onChange: function onChange(value) {
|
750
|
+
return formik.setFieldValue("employmentStatus", value);
|
751
|
+
},
|
752
|
+
value: formik.values.employmentStatus,
|
753
|
+
children: employmentStatuses.map(function (employmentStatus) {
|
754
|
+
return /*#__PURE__*/_jsx(RadioGroup.Item, {
|
755
|
+
value: employmentStatus,
|
756
|
+
children: capitalize(employmentStatus)
|
757
|
+
}, employmentStatus);
|
758
|
+
})
|
759
|
+
})
|
760
|
+
}), /*#__PURE__*/_jsx(Field, {
|
761
|
+
label: "Birthday",
|
762
|
+
labelFor: "birthday",
|
763
|
+
description: "Please specify your birthday",
|
764
|
+
state: getFieldState("birthday"),
|
765
|
+
className: stl(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["w-full"]))),
|
766
|
+
children: /*#__PURE__*/_jsx(DatePicker, {
|
767
|
+
id: "birthday",
|
768
|
+
calendarProps: {
|
769
|
+
disabled: {
|
770
|
+
after: now
|
771
|
+
}
|
772
|
+
},
|
773
|
+
required: true,
|
774
|
+
onChange: function onChange(value) {
|
775
|
+
return formik.setFieldValue("birthday", value);
|
776
|
+
},
|
777
|
+
value: formik.values.birthday
|
778
|
+
})
|
779
|
+
}), /*#__PURE__*/_jsx(Field, {
|
780
|
+
label: "Age",
|
781
|
+
labelFor: "age",
|
782
|
+
description: "Please specify your age",
|
783
|
+
state: getFieldState("age"),
|
784
|
+
className: stl(_templateObject37 || (_templateObject37 = _taggedTemplateLiteral(["w-full"]))),
|
785
|
+
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
786
|
+
id: "age",
|
787
|
+
type: "number",
|
788
|
+
placeholder: "18",
|
789
|
+
step: 1,
|
790
|
+
required: true
|
791
|
+
}, formik.getFieldProps("age")))
|
792
|
+
}), /*#__PURE__*/_jsxs(Field, {
|
793
|
+
label: "Interest",
|
794
|
+
labelFor: "interest",
|
795
|
+
description: "Please specify your interest",
|
796
|
+
state: getFieldState("interest"),
|
797
|
+
className: stl(_templateObject38 || (_templateObject38 = _taggedTemplateLiteral(["w-full"]))),
|
798
|
+
children: [/*#__PURE__*/_jsxs("p", {
|
799
|
+
className: stl(_templateObject39 || (_templateObject39 = _taggedTemplateLiteral(["display-caption flex justify-between mb-2"]))),
|
800
|
+
children: [/*#__PURE__*/_jsx("span", {
|
801
|
+
children: "0"
|
802
|
+
}), /*#__PURE__*/_jsx("span", {
|
803
|
+
children: "5"
|
804
|
+
}), /*#__PURE__*/_jsx("span", {
|
805
|
+
children: "10"
|
806
|
+
})]
|
807
|
+
}), /*#__PURE__*/_jsx(RangeSlider, {
|
808
|
+
id: "interest",
|
809
|
+
min: 0,
|
810
|
+
max: 10,
|
811
|
+
required: true,
|
812
|
+
onChange: function onChange(value) {
|
813
|
+
return formik.setFieldValue("interest", value);
|
814
|
+
},
|
815
|
+
value: formik.values.interest
|
816
|
+
})]
|
817
|
+
}), /*#__PURE__*/_jsxs(Field, {
|
818
|
+
label: "Ideal Location",
|
819
|
+
labelFor: "idealLocation",
|
820
|
+
description: "Please specify your ideal location",
|
821
|
+
state: getFieldState("idealLocation"),
|
822
|
+
className: stl(_templateObject40 || (_templateObject40 = _taggedTemplateLiteral(["w-full"]))),
|
823
|
+
children: [/*#__PURE__*/_jsxs("p", {
|
824
|
+
className: stl(_templateObject41 || (_templateObject41 = _taggedTemplateLiteral(["display-caption flex justify-between mb-2"]))),
|
825
|
+
children: [/*#__PURE__*/_jsx("span", {
|
826
|
+
children: "0 km"
|
827
|
+
}), /*#__PURE__*/_jsx("span", {
|
828
|
+
children: "10 km"
|
829
|
+
}), /*#__PURE__*/_jsx("span", {
|
830
|
+
children: "20 km"
|
831
|
+
}), /*#__PURE__*/_jsx("span", {
|
832
|
+
children: "30 km"
|
833
|
+
}), /*#__PURE__*/_jsx("span", {
|
834
|
+
children: "40 km"
|
835
|
+
}), /*#__PURE__*/_jsx("span", {
|
836
|
+
children: "50 km"
|
837
|
+
})]
|
838
|
+
}), /*#__PURE__*/_jsx(RangeSlider, {
|
839
|
+
id: "idealLocation",
|
840
|
+
min: 0,
|
841
|
+
max: 50,
|
842
|
+
step: 10,
|
843
|
+
required: true,
|
844
|
+
onChange: function onChange(value) {
|
845
|
+
return formik.setFieldValue("idealLocation", value);
|
846
|
+
},
|
847
|
+
value: formik.values.idealLocation
|
848
|
+
})]
|
849
|
+
}), /*#__PURE__*/_jsx(Field, {
|
850
|
+
label: "Profile Picture",
|
851
|
+
labelFor: "profilePicture",
|
852
|
+
description: "Please upload your profile picture, 1 MB minimum",
|
853
|
+
state: getFieldState("profilePicture"),
|
854
|
+
className: stl(_templateObject42 || (_templateObject42 = _taggedTemplateLiteral(["w-full"]))),
|
855
|
+
children: /*#__PURE__*/_jsx(Dropzone, {
|
856
|
+
id: "profilePicture",
|
857
|
+
minSize: 1024 * 1024 * 1,
|
858
|
+
accept: [".png", ".jpg"],
|
859
|
+
required: true,
|
860
|
+
onChange: function onChange(acceptedFiles, rejectedFiles) {
|
861
|
+
return formik.setFieldValue("profilePicture", rejectedFiles.length > 0 ? rejectedFiles[0] : acceptedFiles[0]);
|
862
|
+
}
|
863
|
+
})
|
864
|
+
}), /*#__PURE__*/_jsx(Field, {
|
865
|
+
label: "Bio",
|
866
|
+
labelFor: "bio",
|
867
|
+
description: "Please write a short bio",
|
868
|
+
state: getFieldState("bio"),
|
869
|
+
className: stl(_templateObject43 || (_templateObject43 = _taggedTemplateLiteral(["w-full"]))),
|
870
|
+
children: /*#__PURE__*/_jsx(TextArea, _objectSpread({
|
871
|
+
id: "bio",
|
872
|
+
required: true
|
873
|
+
}, formik.getFieldProps("bio")))
|
874
|
+
}), /*#__PURE__*/_jsx(Field, {
|
875
|
+
label: "Accept Terms",
|
876
|
+
labelFor: "acceptTerms",
|
877
|
+
description: "Please accept the terms",
|
878
|
+
state: getFieldState("acceptTerms"),
|
879
|
+
className: stl(_templateObject44 || (_templateObject44 = _taggedTemplateLiteral(["w-full"]))),
|
880
|
+
inline: true,
|
881
|
+
children: /*#__PURE__*/_jsx(Checkbox, _objectSpread({
|
882
|
+
id: "acceptTerms",
|
883
|
+
required: true,
|
884
|
+
checked: formik.values.acceptTerms
|
885
|
+
}, formik.getFieldProps("acceptTerms")))
|
886
|
+
}), /*#__PURE__*/_jsx(Field, {
|
887
|
+
label: "Receive Newsletter",
|
888
|
+
labelFor: "newsletter",
|
889
|
+
description: "Do you want to receive our newsletter?",
|
890
|
+
state: getFieldState("newsletter"),
|
891
|
+
className: stl(_templateObject45 || (_templateObject45 = _taggedTemplateLiteral(["w-full"]))),
|
892
|
+
inline: true,
|
893
|
+
children: /*#__PURE__*/_jsx(Toggle, _objectSpread({
|
894
|
+
id: "newsletter",
|
895
|
+
required: true,
|
896
|
+
checked: formik.values.newsletter
|
897
|
+
}, formik.getFieldProps("newsletter")))
|
898
|
+
}), /*#__PURE__*/_jsxs("div", {
|
899
|
+
className: stl(_templateObject46 || (_templateObject46 = _taggedTemplateLiteral(["flex gap-2"]))),
|
900
|
+
children: [/*#__PURE__*/_jsx(ExperimentalFormSubmit, {
|
901
|
+
variant: "primary",
|
902
|
+
"aria-label": "Save the form",
|
903
|
+
children: "Save"
|
904
|
+
}), /*#__PURE__*/_jsx(ExperimentalFormReset, {
|
905
|
+
"aria-label": "Reset the form",
|
906
|
+
onClick: function onClick() {
|
907
|
+
return formik.resetForm();
|
908
|
+
},
|
909
|
+
children: "Reset"
|
910
|
+
})]
|
911
|
+
})]
|
912
|
+
}), /*#__PURE__*/_jsx("hr", {
|
913
|
+
className: stl(_templateObject47 || (_templateObject47 = _taggedTemplateLiteral(["text-grey-500"])))
|
914
|
+
}), /*#__PURE__*/_jsx("code", {
|
915
|
+
className: stl(_templateObject48 || (_templateObject48 = _taggedTemplateLiteral(["whitespace-pre"]))),
|
916
|
+
children: JSON.stringify(formData, null, 2)
|
917
|
+
})]
|
918
|
+
});
|
919
|
+
};
|