formik-mui-fields 0.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/LICENSE +21 -0
- package/README.md +192 -0
- package/dist/index.cjs +646 -0
- package/dist/index.d.cts +103 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.js +660 -0
- package/package.json +120 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wadii Basmi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @repo/formik-fields
|
|
2
|
+
|
|
3
|
+
Formik-connected [MUI](https://mui.com/) form field components. Each component wraps an MUI input, wires it to Formik via `useField`, and automatically handles value binding, change/blur events, and validation error display.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This is a private internal package. Install peer dependencies in your consuming app:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mui/material formik react react-dom
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Components
|
|
14
|
+
|
|
15
|
+
### FormikTextField
|
|
16
|
+
|
|
17
|
+
Text input bound to Formik. Passes through all MUI `TextFieldProps`.
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
<FormikTextField name="email" label="Email" type="email" />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### FormikSelect
|
|
24
|
+
|
|
25
|
+
Dropdown select with an `options` array. Passes through MUI `SelectProps`.
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
<FormikSelect
|
|
29
|
+
name="country"
|
|
30
|
+
label="Country"
|
|
31
|
+
options={[
|
|
32
|
+
{ value: "us", label: "United States" },
|
|
33
|
+
{ value: "fr", label: "France" },
|
|
34
|
+
]}
|
|
35
|
+
/>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### FormikAutocomplete
|
|
39
|
+
|
|
40
|
+
Generic autocomplete. Accepts a type parameter for option shape.
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
<FormikAutocomplete
|
|
44
|
+
name="user"
|
|
45
|
+
label="User"
|
|
46
|
+
options={users}
|
|
47
|
+
getOptionLabel={(u) => u.name}
|
|
48
|
+
isOptionEqualToValue={(a, b) => a.id === b.id}
|
|
49
|
+
/>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### FormikRadioGroup
|
|
53
|
+
|
|
54
|
+
Radio button group with an `options` array.
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<FormikRadioGroup
|
|
58
|
+
name="plan"
|
|
59
|
+
label="Plan"
|
|
60
|
+
options={[
|
|
61
|
+
{ value: "free", label: "Free" },
|
|
62
|
+
{ value: "pro", label: "Pro" },
|
|
63
|
+
]}
|
|
64
|
+
row
|
|
65
|
+
/>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### FormikCheckbox
|
|
69
|
+
|
|
70
|
+
Checkbox bound to a boolean Formik field. Passes through MUI `CheckboxProps`.
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
<FormikCheckbox name="agree" label="I agree to the terms" />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### FormikSwitch
|
|
77
|
+
|
|
78
|
+
Toggle switch bound to a boolean Formik field. Passes through MUI `SwitchProps`.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<FormikSwitch name="notifications" label="Enable notifications" />
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### FormikSlider
|
|
85
|
+
|
|
86
|
+
Range slider. Passes through MUI `SliderProps`.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
<FormikSlider name="volume" label="Volume" min={0} max={100} />
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### FormikRating
|
|
93
|
+
|
|
94
|
+
Star rating input. Passes through MUI `RatingProps`.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
<FormikRating name="score" label="Rating" max={5} />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### FormikToggleButtonGroup
|
|
101
|
+
|
|
102
|
+
Exclusive toggle button group with an `options` array. Passes through MUI `ToggleButtonGroupProps`.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<FormikToggleButtonGroup
|
|
106
|
+
name="alignment"
|
|
107
|
+
label="Text Alignment"
|
|
108
|
+
options={[
|
|
109
|
+
{ value: "left", label: "Left" },
|
|
110
|
+
{ value: "center", label: "Center" },
|
|
111
|
+
{ value: "right", label: "Right" },
|
|
112
|
+
]}
|
|
113
|
+
exclusive
|
|
114
|
+
/>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### FormikColorPicker
|
|
118
|
+
|
|
119
|
+
Color picker using a circular swatch that opens a Chrome-style color picker (via `react-color`).
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
<FormikColorPicker name="brandColor" label="Brand Color" />
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### FormikFontPicker
|
|
126
|
+
|
|
127
|
+
Google Fonts autocomplete. Fetches font list from `/api/google/fonts` and injects a preview stylesheet for the selected font.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<FormikFontPicker name="fontFamily" label="Font" />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### FormikImageUpload
|
|
134
|
+
|
|
135
|
+
Drag-and-drop style image upload with optional cropping dialog. Supports configurable aspect ratios (`1.91:1`, `1:1`, `3:1`).
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
<FormikImageUpload name="avatar" label="Profile Picture" height={150} />;
|
|
139
|
+
|
|
140
|
+
{
|
|
141
|
+
/* With cropping enabled */
|
|
142
|
+
}
|
|
143
|
+
<FormikImageUpload
|
|
144
|
+
name="banner"
|
|
145
|
+
label="Banner"
|
|
146
|
+
cropEnabled
|
|
147
|
+
cropOptions={["1.91:1", "1:1"]}
|
|
148
|
+
/>;
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Usage
|
|
152
|
+
|
|
153
|
+
All components are designed to be used inside a Formik `<Form>` or `<Formik>` context:
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import { Formik, Form } from "formik";
|
|
157
|
+
import {
|
|
158
|
+
FormikTextField,
|
|
159
|
+
FormikSelect,
|
|
160
|
+
FormikCheckbox,
|
|
161
|
+
} from "@repo/formik-fields";
|
|
162
|
+
|
|
163
|
+
const MyForm = () => (
|
|
164
|
+
<Formik
|
|
165
|
+
initialValues={{ name: "", role: "", agree: false }}
|
|
166
|
+
onSubmit={(values) => console.log(values)}
|
|
167
|
+
>
|
|
168
|
+
<Form>
|
|
169
|
+
<FormikTextField name="name" label="Name" />
|
|
170
|
+
<FormikSelect
|
|
171
|
+
name="role"
|
|
172
|
+
label="Role"
|
|
173
|
+
options={[
|
|
174
|
+
{ value: "admin", label: "Admin" },
|
|
175
|
+
{ value: "user", label: "User" },
|
|
176
|
+
]}
|
|
177
|
+
/>
|
|
178
|
+
<FormikCheckbox name="agree" label="I agree" />
|
|
179
|
+
<button type="submit">Submit</button>
|
|
180
|
+
</Form>
|
|
181
|
+
</Formik>
|
|
182
|
+
);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Peer Dependencies
|
|
186
|
+
|
|
187
|
+
| Package | Version |
|
|
188
|
+
| --------------- | ------- |
|
|
189
|
+
| `@mui/material` | >= 7 |
|
|
190
|
+
| `formik` | >= 2 |
|
|
191
|
+
| `react` | >= 18 |
|
|
192
|
+
| `react-dom` | >= 18 |
|