Skip to content

Commit 72f347e

Browse files
author
Ömer Gülçiçek
committed
Update version to 1.1.4. Fix mask functionality and simplify API. Remove unnecessary shadcn parameter and update documentation.
1 parent 7008e20 commit 72f347e

File tree

4 files changed

+31
-38
lines changed

4 files changed

+31
-38
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## [v1.1.4] - 2025-06-06
4+
5+
### Fixed
6+
- Mask functionality now works correctly in all scenarios
7+
8+
### Removed
9+
- `shadcn` parameter from useFormFields hook (no longer needed)
10+
- `getShadcnMaskProps` internal helper function
11+
12+
### Changed
13+
- Simplified API - useFormFields now works consistently across all UI libraries
14+
15+
### Documentation
16+
- Updated README to remove shadcn: true usage examples
17+
- Simplified shadcn/ui integration examples
18+
319
## [v1.1.3] - 2025-06-06
420

521
### Added

README.md

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,10 @@ export default function MyForm() {
124124

125125
This package is designed to be fully compatible with [shadcn/ui](https://ui.shadcn.com/docs/components/input?ref=omergulcicek/forms) input component.
126126

127-
```tsx
128-
import { Input } from "@/components/ui/input"
129-
130-
const { alpha } = useFormFields<FormData>({
131-
fields: [{ name: "alpha", type: "alpha" }],
132-
registerWithMask,
133-
register: form.register
134-
})
135-
136-
<Input {...alpha} />
137-
```
138-
139-
140127
```tsx
141128
import {
142129
Form,
143130
FormControl,
144-
FormDescription,
145131
FormField,
146132
FormItem,
147133
FormLabel,
@@ -152,10 +138,13 @@ import { Input } from "@/components/ui/input"
152138
const { alpha } = useFormFields<FormData>({
153139
fields: [{ name: "alpha", type: "alpha" }],
154140
registerWithMask,
155-
register: form.register,
156-
shadcn: true // Enable shadcn/ui compatibility (default=false)
141+
register: form.register
157142
})
158143

144+
<Input {...alpha} />
145+
146+
// or
147+
159148
<FormField
160149
control={form.control}
161150
name="alpha"
@@ -172,8 +161,4 @@ const { alpha } = useFormFields<FormData>({
172161
</FormItem>
173162
)}
174163
/>
175-
```
176-
177-
## License
178-
179-
MIT
164+
```

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@omergulcicek/forms",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "Advanced input fields with mask and regex support for React Hook Form",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -43,5 +43,8 @@
4343
"type": "git",
4444
"url": "https://github.com/omergulcicek/forms.git"
4545
},
46-
"homepage": "https://github.com/omergulcicek/forms#readme"
46+
"homepage": "https://github.com/omergulcicek/forms#readme",
47+
"publishConfig": {
48+
"access": "public"
49+
}
4750
}

src/index.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ interface UseFormFieldsParams<T extends Record<string, any>> {
8282
options?: Record<string, unknown>
8383
) => Record<string, unknown>;
8484
register: (name: keyof T) => Record<string, unknown>;
85-
shadcn?: boolean;
8685
}
8786

8887
const handleAlphaKeyDown = (e: { key: string; preventDefault: () => void }) => {
@@ -114,46 +113,36 @@ const getNumericFieldProps = (type: keyof typeof NUMERIC_FIELD_CONFIGS) => ({
114113
onKeyDown: handleNumericKeyDown,
115114
});
116115

117-
const getShadcnMaskProps = (maskProps: Record<string, unknown>) => {
118-
const { onChange, onBlur, name, ref, ...rest } = maskProps;
119-
return rest;
120-
};
121-
122116
/**
123117
* Creates form field props with mask and validation
124118
* @param fields - Array of field configurations
125119
* @param registerWithMask - React Hook Form mask register function
126120
* @param register - React Hook Form register function
127-
* @param shadcn - Enable shadcn/ui compatibility mode
128121
* @returns Object with field names as keys and props as values
129122
*/
130123
export function useFormFields<T extends Record<string, any>>({
131124
fields,
132125
registerWithMask,
133126
register,
134-
shadcn = false,
135127
}: UseFormFieldsParams<T>) {
136128
const memoizedRegister = useCallback(register, [register]);
137-
const memoizedRegisterWithMask = useCallback(registerWithMask, []);
129+
const memoizedRegisterWithMask = useCallback(registerWithMask, [register]);
138130

139131
const result = useMemo(() => {
140132
const result: Record<string, Record<string, unknown>> = {};
141133

142134
fields.forEach(({ name, type }) => {
143-
const baseRegisterProps = shadcn ? {} : memoizedRegister(name as keyof T);
135+
const baseRegisterProps = memoizedRegister(name as keyof T);
144136

145137
if (isNumericField(type)) {
146138
const maskProps = memoizedRegisterWithMask(
147139
name as keyof T,
148140
MASKS[type],
149141
MASK_OPTIONS
150142
);
151-
const baseMaskProps = shadcn
152-
? getShadcnMaskProps(maskProps)
153-
: maskProps;
154143

155144
result[String(name)] = {
156-
...baseMaskProps,
145+
...maskProps,
157146
...getNumericFieldProps(type),
158147
};
159148
} else if (type === "alpha") {
@@ -177,7 +166,7 @@ export function useFormFields<T extends Record<string, any>>({
177166
});
178167

179168
return result;
180-
}, [fields, memoizedRegister, memoizedRegisterWithMask, shadcn]);
169+
}, [fields, memoizedRegister, memoizedRegisterWithMask]);
181170

182171
return result;
183172
}

0 commit comments

Comments
 (0)