File tree Expand file tree Collapse file tree 6 files changed +19
-16
lines changed
src/components/form/components
stories/components/form/tanstack Expand file tree Collapse file tree 6 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import styled from '@emotion/styled';
33import type { ChangeEvent } from 'react' ;
44
55import { useFieldContext } from '../../context/use_ts_form.js' ;
6- import type { Layout } from '../input_groups/form .js' ;
6+ import type { Layout } from '../input_groups/form_context .js' ;
77import { FormGroup } from '../input_groups/form_group.js' ;
88
99interface SwitchProps {
Original file line number Diff line number Diff line change 11import type { FormHTMLAttributes , ReactNode } from 'react' ;
2- import { createContext , useContext , useMemo } from 'react' ;
2+ import { useMemo } from 'react' ;
33
4- export type Layout = 'inline' | 'stacked' ;
4+ import type { Layout } from './form_context.js' ;
5+ import { formContext } from './form_context.js' ;
56
67export interface FormProps extends FormHTMLAttributes < HTMLFormElement > {
78 children : ReactNode ;
89 layout ?: Layout ;
910}
1011
11- const formContext = createContext < { layout : Layout } > ( {
12- layout : 'stacked' ,
13- } ) ;
14-
15- // eslint-disable-next-line react-refresh/only-export-components
16- export function useFormContext ( ) {
17- return useContext ( formContext ) ;
18- }
19-
2012export function Form ( props : FormProps ) {
2113 const { children, layout = 'stacked' , ...otherProps } = props ;
2214
Original file line number Diff line number Diff line change 1+ import { createContext , useContext } from 'react' ;
2+
3+ export type Layout = 'inline' | 'stacked' ;
4+
5+ export const formContext = createContext < { layout : Layout } > ( {
6+ layout : 'stacked' ,
7+ } ) ;
8+
9+ export function useFormContext ( ) {
10+ return useContext ( formContext ) ;
11+ }
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ import { Classes } from '@blueprintjs/core';
33import styled from '@emotion/styled' ;
44import type { ReactNode } from 'react' ;
55
6- import type { Layout } from './form .js' ;
7- import { useFormContext } from './form .js' ;
6+ import type { Layout } from './form_context .js' ;
7+ import { useFormContext } from './form_context .js' ;
88
99const INPUT_HEIGHT = 30 ;
1010
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import type { FormEvent } from 'react';
44import { action } from 'storybook/actions' ;
55import { z } from 'zod' ;
66
7- import type { Layout } from '../../../../src/components/form/components/input_groups/form .js' ;
7+ import type { Layout } from '../../../../src/components/form/components/input_groups/form_context .js' ;
88import { Section } from '../../../../src/components/form/components/layout/Section.js' ;
99import { useForm } from '../../../../src/components/index.js' ;
1010
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ import { revalidateLogic } from '@tanstack/react-form';
44import { action } from 'storybook/actions' ;
55import { z } from 'zod' ;
66
7- import type { Layout } from '../../../../src/components/form/components/input_groups/form.js' ;
87import { Form } from '../../../../src/components/form/components/input_groups/form.js' ;
8+ import type { Layout } from '../../../../src/components/form/components/input_groups/form_context.js' ;
99import { useForm } from '../../../../src/components/index.js' ;
1010
1111export default {
You can’t perform that action at this time.
0 commit comments