@@ -6,6 +6,7 @@ import { z } from 'zod';
66import { FormError , TextField } from '@lambdacurry/forms' ;
77import { Button } from '@lambdacurry/forms/ui/button' ;
88import { FormMessage } from '@lambdacurry/forms/remix-hook-form/form' ;
9+ import { withReactRouterStubDecorator } from '../lib/storybook/react-router-stub' ;
910
1011// Form schema for testing
1112const formSchema = z . object ( {
@@ -15,6 +16,7 @@ const formSchema = z.object({
1516
1617type FormData = z . infer < typeof formSchema > ;
1718
19+
1820// Basic Form Error Story
1921const BasicFormErrorExample = ( ) => {
2022 const fetcher = useFetcher < {
@@ -407,7 +409,17 @@ export default meta;
407409type Story = StoryObj < typeof FormError > ;
408410
409411export const BasicFormError : Story = {
410- render : ( ) => < BasicFormErrorExample /> ,
412+ decorators : [
413+ withReactRouterStubDecorator ( {
414+ routes : [
415+ {
416+ path : '/' ,
417+ Component : BasicFormErrorExample ,
418+ action : async ( { request } : ActionFunctionArgs ) => handleBasicFormError ( request ) ,
419+ } ,
420+ ] ,
421+ } ) ,
422+ ] ,
411423 parameters : {
412424 docs : {
413425 description : {
@@ -433,7 +445,17 @@ The FormError component automatically displays when \`errors._form\` exists in t
433445} ;
434446
435447export const MixedErrors : Story = {
436- render : ( ) => < MixedErrorsExample /> ,
448+ decorators : [
449+ withReactRouterStubDecorator ( {
450+ routes : [
451+ {
452+ path : '/' ,
453+ Component : MixedErrorsExample ,
454+ action : async ( { request } : ActionFunctionArgs ) => handleMixedErrors ( request ) ,
455+ } ,
456+ ] ,
457+ } ) ,
458+ ] ,
437459 parameters : {
438460 docs : {
439461 description : {
@@ -453,7 +475,17 @@ This pattern is useful when you want to show form-level context alongside specif
453475} ;
454476
455477export const CustomStyling : Story = {
456- render : ( ) => < CustomStyledFormErrorExample /> ,
478+ decorators : [
479+ withReactRouterStubDecorator ( {
480+ routes : [
481+ {
482+ path : '/' ,
483+ Component : CustomStyledFormErrorExample ,
484+ action : async ( { request } : ActionFunctionArgs ) => handleCustomStyledError ( request ) ,
485+ } ,
486+ ] ,
487+ } ) ,
488+ ] ,
457489 parameters : {
458490 docs : {
459491 description : {
@@ -478,7 +510,17 @@ This example shows an alert-style error message with an icon and custom styling.
478510} ;
479511
480512export const PlacementVariations : Story = {
481- render : ( ) => < PlacementVariationsExample /> ,
513+ decorators : [
514+ withReactRouterStubDecorator ( {
515+ routes : [
516+ {
517+ path : '/' ,
518+ Component : PlacementVariationsExample ,
519+ action : async ( { request } : ActionFunctionArgs ) => handlePlacementTest ( request ) ,
520+ } ,
521+ ] ,
522+ } ) ,
523+ ] ,
482524 parameters : {
483525 docs : {
484526 description : {
@@ -498,8 +540,8 @@ Each FormError instance shows the same error but can be styled differently using
498540 } ,
499541} ;
500542
501- // Export action handlers for Storybook
502- export const actionHandlers = {
543+ // Action handlers for Storybook (not exported to avoid being treated as a story)
544+ const actionHandlers = {
503545 '/login' : handleBasicFormError ,
504546 '/register' : handleMixedErrors ,
505547 '/custom-login' : handleCustomStyledError ,
0 commit comments