Skip to content

Commit 4a054aa

Browse files
committed
chore: update dependencies and improve medusa-forms structure
- Updated remix-hook-form to version 7.0.1 across multiple package.json files. - Added new dependencies: @hookform/error-message and @hookform/resolvers in apps/docs. - Enhanced tsconfig paths for medusa-forms to include src and lib directories. - Refactored ControlledInput component to use ComponentProps for better type safety. - Removed unused index.ts file from controlled directory in medusa-forms. - Improved error handling in Error component for better readability and performance. - Updated main.css for consistent Tailwind CSS imports and added Medusa UI tokens.
1 parent f218347 commit 4a054aa

11 files changed

Lines changed: 992 additions & 60 deletions

File tree

.cursor/rules/monorepo-organization.mdc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
2-
type: Always
32
description: Monorepo structure and import conventions for the lambda-curry/forms repository
3+
globs:
4+
alwaysApply: false
45
---
56

67
You are an expert in monorepo architecture, package management, and TypeScript module organization.
@@ -169,7 +170,7 @@ src/
169170
{
170171
"peerDependencies": {
171172
"react": "^19.0.0",
172-
"remix-hook-form": "7.0.0"
173+
"remix-hook-form": "7.0.1"
173174
},
174175
"dependencies": {
175176
"@radix-ui/react-slot": "^1.1.2",

apps/docs/package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"test:local": "test-storybook"
1212
},
1313
"dependencies": {
14+
"@hookform/error-message": "^2.0.0",
15+
"@hookform/resolvers": "^3.9.1",
1416
"@lambdacurry/forms": "*",
1517
"@lambdacurry/medusa-forms": "*",
1618
"@storybook/addon-essentials": "^8.6.7",
@@ -20,22 +22,25 @@
2022
"@storybook/react": "^8.6.7",
2123
"@storybook/react-vite": "^8.6.7",
2224
"@storybook/test": "^8.6.7",
25+
"react": "^19.0.0",
2326
"react-hook-form": "^7.51.0",
27+
"react-router": "^7.0.0",
28+
"react-router-dom": "^7.0.0",
29+
"remix-hook-form": "^7.0.1",
2430
"storybook": "^8.6.7"
2531
},
2632
"devDependencies": {
33+
"@medusajs/ui-preset": "^2.8.3",
2734
"@react-router/dev": "^7.0.0",
2835
"@storybook/test-runner": "^0.22.0",
2936
"@storybook/testing-library": "^0.2.2",
37+
"@tailwindcss/postcss": "^4.1.8",
3038
"@tailwindcss/vite": "^4.0.0",
3139
"@types/react": "^19.0.0",
3240
"@typescript-eslint/eslint-plugin": "^6.21.0",
3341
"@typescript-eslint/parser": "^6.21.0",
3442
"autoprefixer": "^10.4.20",
3543
"http-server": "^14.1.1",
36-
"react": "^19.0.0",
37-
"react-router": "^7.0.0",
38-
"react-router-dom": "^7.0.0",
3944
"start-server-and-test": "^2.0.11",
4045
"tailwindcss": "^4.0.0",
4146
"typescript": "^5.7.2",

apps/docs/src/main.css

Lines changed: 636 additions & 25 deletions
Large diffs are not rendered by default.

apps/docs/src/medusa-forms/ControlledInput.stories.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ControlledInput } from '@lambdacurry/medusa-forms/controlled';
1+
import { ControlledInput } from '@lambdacurry/medusa-forms/controlled/ControlledInput';
22
import type { Meta, StoryObj } from '@storybook/react';
33
import { FormProvider, useForm } from 'react-hook-form';
44

@@ -24,17 +24,17 @@ const ControlledInputWithHookForm = () => {
2424
return (
2525
<FormProvider {...form}>
2626
<div className="w-[400px]">
27-
<ControlledInput
28-
name="username"
29-
label="Username"
30-
placeholder="Enter your username"
31-
description="This is your unique identifier"
32-
/>
27+
<ControlledInput name="username" label="Username" placeholder="Enter your username" />
3328
</div>
3429
</FormProvider>
3530
);
3631
};
3732

3833
export const WithReactHookForm: Story = {
34+
args: {
35+
name: 'username',
36+
label: 'Username',
37+
placeholder: 'Enter your username',
38+
},
3939
render: () => <ControlledInputWithHookForm />,
4040
};

apps/docs/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"moduleResolution": "bundler",
66
"paths": {
77
"@lambdacurry/forms/*": ["../../packages/components/src/*"],
8-
"@lambdacurry/forms/lib/*": ["../../packages/components/lib/*"]
8+
"@lambdacurry/forms/lib/*": ["../../packages/components/lib/*"],
9+
"@lambdacurry/medusa-forms/*": ["../../packages/medusa-forms/src/*"],
10+
"@lambdacurry/medusa-forms/lib/*": ["../../packages/medusa-forms/lib/*"]
911
}
1012
},
1113
"include": ["lib", "src"],

apps/docs/vite.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export default defineConfig({
1212
'@/lib/utils': path.resolve(__dirname, '../../packages/components/lib/utils'),
1313
'@lambdacurry/forms': path.resolve(__dirname, '../../packages/components/src'),
1414
'@lambdacurry/forms/lib': path.resolve(__dirname, '../../packages/components/lib'),
15+
'@lambdacurry/medusa-forms': path.resolve(__dirname, '../../packages/medusa-forms/src'),
16+
'@lambdacurry/medusa-forms/lib': path.resolve(__dirname, '../../packages/medusa-forms/lib'),
1517
},
1618
},
1719
build: {

packages/components/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"peerDependencies": {
3838
"react": "^19.0.0",
39-
"remix-hook-form": "7.0.0"
39+
"remix-hook-form": "7.0.1"
4040
},
4141
"dependencies": {
4242
"@hookform/resolvers": "^3.9.1",
@@ -66,7 +66,7 @@
6666
"react-hook-form": "^7.53.1",
6767
"react-router": "^7.0.0",
6868
"react-router-dom": "^7.0.0",
69-
"remix-hook-form": "7.0.0",
69+
"remix-hook-form": "7.0.1",
7070
"sonner": "^1.7.1",
7171
"tailwind-merge": "^2.5.5",
7272
"tailwindcss-animate": "^1.0.7",

packages/medusa-forms/src/controlled/ControlledInput.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ComponentProps } from 'react';
12
import {
23
Controller,
34
type ControllerProps,
@@ -12,7 +13,7 @@ type Props<T extends FieldValues> = InputProps &
1213
Omit<ControllerProps, 'render'> & {
1314
name: Path<T>;
1415
rules?: Omit<RegisterOptions<T, Path<T>>, 'disabled' | 'valueAsNumber' | 'valueAsDate' | 'setValueAs'>;
15-
} & React.ComponentProps<typeof Input> &
16+
} & ComponentProps<typeof Input> &
1617
Omit<ControllerProps<T>, 'render'>;
1718

1819
export const ControlledInput = <T extends FieldValues>({ name, rules, onChange, ...props }: Props<T>) => {

packages/medusa-forms/src/controlled/index.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/medusa-forms/src/ui/Error.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ const MultipleMessages = ({ messages }: { messages: MultipleFieldErrors }) => {
2525
<div className="inter-small-regular text-rose-50">
2626
{remainderErrors.map((e, i) => {
2727
return (
28+
// biome-ignore lint/suspicious/noArrayIndexKey: index is the best option here
2829
<p key={i}>
29-
{Array.from(Array(i + 1)).map((_) => '*')}
30+
{Array.from(new Array(remainderErrors.length)).map((_) => '*')}
3031
{e}
3132
</p>
3233
);
@@ -44,9 +45,7 @@ const MultipleMessages = ({ messages }: { messages: MultipleFieldErrors }) => {
4445
};
4546

4647
export const FieldError = ({ errors, name, className }: Props) => {
47-
if (!errors || !name) {
48-
return null;
49-
}
48+
if (!(errors && name)) return null;
5049

5150
return (
5251
<ErrorMessage

0 commit comments

Comments
 (0)