Skip to content

Commit 1d80509

Browse files
committed
Rename TypeScript types and export more of them
1 parent e5fe910 commit 1d80509

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+290
-192
lines changed

packages/solid/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to the library will be documented in this file.
44

5+
## vX.X.X (Month DD, YYYY)
6+
7+
- Rename TypeScript types and export more of them
8+
59
## v0.5.0 (November 06, 2022)
610

711
- Reset form response at `handleSubmit` and `reset` method

packages/solid/src/index.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
import type {
2-
FormState as ModularForm,
3-
FieldState as ModularField,
4-
FieldValue as ModularValue,
5-
FieldValues as ModularValues,
6-
FieldArrayState as ModularFieldArray,
7-
} from './types';
8-
export type {
9-
ModularForm,
10-
ModularField,
11-
ModularValue,
12-
ModularValues,
13-
ModularFieldArray,
14-
};
151
export * from './components';
162
export * from './methods';
173
export * from './primitives';
4+
export * from './types';
185
export * from './validation';

packages/website/src/components/Debugger.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {
22
getValues,
3-
ModularValue,
4-
ModularValues,
5-
ModularForm,
3+
FieldValue,
4+
FieldValues,
5+
FormState,
66
} from '@modular-forms/solid';
77
import clsx from 'clsx';
88
import { createMemo, For, Show } from 'solid-js';
99

1010
type DebuggerProps = {
11-
of: ModularForm<any> | undefined;
11+
of: FormState<any> | undefined;
1212
};
1313

1414
/**
@@ -82,7 +82,7 @@ export function Debugger(props: DebuggerProps) {
8282
when={Object.keys(values() || {}).length}
8383
fallback={<p>Wait for input...</p>}
8484
>
85-
<FieldValues values={values()} />
85+
<FieldValueList values={values()} />
8686
</Show>
8787
</div>
8888
</div>
@@ -91,13 +91,13 @@ export function Debugger(props: DebuggerProps) {
9191

9292
type FieldValuesProps = {
9393
class?: string;
94-
values: ModularValue[] | ModularValues | ModularValues[];
94+
values: FieldValue[] | FieldValues | FieldValues[];
9595
};
9696

9797
/**
9898
* Recusive component that displays individual form values.
9999
*/
100-
function FieldValues(props: FieldValuesProps) {
100+
function FieldValueList(props: FieldValuesProps) {
101101
return (
102102
<ul class={clsx('space-y-5', props.class)}>
103103
<For each={Object.entries(props.values)}>
@@ -136,7 +136,7 @@ function FieldValues(props: FieldValuesProps) {
136136
: String(value)}
137137
</span>
138138
) : (
139-
<FieldValues class="ml-2 mt-3" values={value} />
139+
<FieldValueList class="ml-2 mt-3" values={value} />
140140
)}
141141
</li>
142142
)}

packages/website/src/components/FormFooter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { ModularForm, reset } from '@modular-forms/solid';
1+
import { FormState, reset } from '@modular-forms/solid';
22
import { ActionButton } from './ActionButton';
33

44
type FormFooterProps = {
5-
of: ModularForm<any>;
5+
of: FormState<any>;
66
};
77

88
/**

packages/website/src/components/FormHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { ModularForm, reset } from '@modular-forms/solid';
1+
import { FormState, reset } from '@modular-forms/solid';
22
import { ActionButton } from './ActionButton';
33

44
type FormHeaderProps = {
5-
of: ModularForm<any>;
5+
of: FormState<any>;
66
heading: string;
77
};
88

packages/website/src/contexts/form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ModularForm } from '@modular-forms/solid';
1+
import { FormState } from '@modular-forms/solid';
22
import {
33
Accessor,
44
createContext,
@@ -8,7 +8,7 @@ import {
88
useContext,
99
} from 'solid-js';
1010

11-
type Form = ModularForm<any> | undefined;
11+
type Form = FormState<any> | undefined;
1212

1313
// Create form context
1414
const FormContext = createContext<{ get: Accessor<Form>; set: Setter<Form> }>();

packages/website/src/routes/api.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ export default function ApiLayout() {
6464
{
6565
heading: 'Types',
6666
items: [
67-
'ModularField',
68-
'ModularFieldArray',
69-
'ModularForm',
70-
'ModularValue',
71-
'ModularValues',
67+
'FieldArrayState',
68+
'FieldElement',
69+
'FieldState',
70+
'FieldValue',
71+
'FieldValues',
72+
'FormState',
73+
'Response',
74+
'ValidateField',
75+
'ValidateFieldArray',
7276
],
7377
},
7478
]}

packages/website/src/routes/api/Field.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ export const properties = {
4848
of: {
4949
type: {
5050
type: 'custom',
51-
name: 'ModularForm',
52-
href: '/api/ModularForm',
51+
name: 'FormState',
52+
href: '/api/FormState',
5353
},
5454
},
5555
initialValue: {
5656
type: [
5757
{
5858
type: 'custom',
59-
name: 'ModularValue',
60-
href: '/api/ModularValue',
59+
name: 'FieldValue',
60+
href: '/api/FieldValue',
6161
},
6262
'undefined',
6363
],
@@ -71,8 +71,8 @@ export const properties = {
7171
name: 'value',
7272
type: {
7373
type: 'custom',
74-
name: 'ModularValue',
75-
href: '/api/ModularValue',
74+
name: 'FieldValue',
75+
href: '/api/FieldValue',
7676
},
7777
},
7878
],
@@ -94,8 +94,8 @@ export const properties = {
9494
name: 'value',
9595
type: {
9696
type: 'custom',
97-
name: 'ModularValue',
98-
href: '/api/ModularValue',
97+
name: 'FieldValue',
98+
href: '/api/FieldValue',
9999
},
100100
},
101101
],
@@ -128,8 +128,8 @@ export const properties = {
128128
name: 'field',
129129
type: {
130130
type: 'custom',
131-
name: 'ModularField',
132-
href: '/api/ModularField',
131+
name: 'FieldState',
132+
href: '/api/FieldState',
133133
},
134134
},
135135
],

packages/website/src/routes/api/FieldArray.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export const properties = {
3737
of: {
3838
type: {
3939
type: 'custom',
40-
name: 'ModularForm',
41-
href: '/api/ModularForm',
40+
name: 'FormState',
41+
href: '/api/FormState',
4242
},
4343
},
4444
validate: {
@@ -105,8 +105,8 @@ export const properties = {
105105
name: 'fieldArray',
106106
type: {
107107
type: 'custom',
108-
name: 'ModularFieldArray',
109-
href: '/api/ModularFieldArray',
108+
name: 'FieldArrayState',
109+
href: '/api/FieldArrayState',
110110
},
111111
},
112112
],

packages/website/src/routes/api/ModularFieldArray.mdx renamed to packages/website/src/routes/api/FieldArrayState.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Description, Property, Title } from '~/components';
22

3-
<Title>ModularFieldArray</Title>
3+
<Title>FieldArrayState</Title>
44
<Description>Type that defines the state of a form field array.</Description>
55

6-
# ModularFieldArray
6+
# FieldArrayState
77

88
Type that defines the state of a form field array.
99

1010
## Definition
1111

12-
- `ModularFieldArray` <Property type="object" />
12+
- `FieldArrayState` <Property type="object" />
1313
- `name` <Property type="string" />
1414
- `items` <Property type={{ type: 'array', item: 'number' }} />
1515
- `length` <Property type="number" />
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Description, Property, Title } from '~/components';
2+
3+
<Title>FieldElement</Title>
4+
<Description>Type that defines the HTML element of a field.</Description>
5+
6+
# FieldElement
7+
8+
Type that defines the HTML element of a field.
9+
10+
## Definition
11+
12+
- `FieldElement` <Property {...properties.FieldElement} />
13+
14+
export const properties = {
15+
FieldElement: {
16+
type: [
17+
{
18+
type: 'custom',
19+
name: 'HTMLInputElement',
20+
},
21+
{
22+
type: 'custom',
23+
name: 'HTMLSelectElement',
24+
},
25+
{
26+
type: 'custom',
27+
name: 'HTMLTextAreaElement',
28+
},
29+
],
30+
},
31+
};

packages/website/src/routes/api/ModularField.mdx renamed to packages/website/src/routes/api/FieldState.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Description, Property, Title } from '~/components';
22

3-
<Title>ModularField</Title>
3+
<Title>FieldState</Title>
44
<Description>Type that defines the state of a form field.</Description>
55

6-
# ModularField
6+
# FieldState
77

88
Type that defines the state of a form field.
99

1010
## Definition
1111

12-
- `ModularField` <Property type="object" />
12+
- `FieldState` <Property type="object" />
1313
- `props` <Property type="object" />
1414
- `name` <Property type="string" />
1515
- `ref` <Property {...properties.ref} />
@@ -40,11 +40,11 @@ export const properties = {
4040
params: [
4141
{
4242
name: 'element',
43-
type: [
44-
{ type: 'custom', name: 'HTMLInputElement' },
45-
{ type: 'custom', name: 'HTMLSelectElement' },
46-
{ type: 'custom', name: 'HTMLTextAreaElement' },
47-
],
43+
type: {
44+
type: 'custom',
45+
name: 'FieldElement',
46+
href: '/api/FieldElement',
47+
},
4848
},
4949
],
5050
return: 'void',
@@ -98,8 +98,8 @@ export const properties = {
9898
value: {
9999
type: {
100100
type: 'custom',
101-
name: 'ModularValue',
102-
href: '/api/ModularValue',
101+
name: 'FieldValue',
102+
href: '/api/FieldValue',
103103
},
104104
},
105105
};

packages/website/src/routes/api/ModularValue.mdx renamed to packages/website/src/routes/api/FieldValue.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { A } from 'solid-start';
22
import { Description, Property, Title } from '~/components';
33

4-
<Title>ModularValue</Title>
4+
<Title>FieldValue</Title>
55
<Description>Type that defines the value of a field.</Description>
66

7-
# ModularValue
7+
# FieldValue
88

99
Type that defines the value of a field.
1010

1111
## Definition
1212

13-
- `ModularValue` <Property {...properties.ModularValue} />
13+
- `FieldValue` <Property {...properties.FieldValue} />
1414

1515
> Make sure to use the correct input fields with the correct setting for the respective values. You can find instructions <A href="/guides/special-inputs">here</A>.
1616
1717
export const properties = {
18-
ModularValue: {
18+
FieldValue: {
1919
type: [
2020
'string',
2121
'number',

packages/website/src/routes/api/ModularValues.mdx renamed to packages/website/src/routes/api/FieldValues.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
import { A } from 'solid-start';
22
import { Description, Property, Title } from '~/components';
33

4-
<Title>ModularValues</Title>
4+
<Title>FieldValues</Title>
55
<Description>Type that defines the field values of a form.</Description>
66

7-
# ModularValues
7+
# FieldValues
88

99
Type that defines the field values of a form.
1010

1111
## Definition
1212

13-
- `ModularValues` <Property {...properties.ModularValues} />
13+
- `FieldValues` <Property {...properties.FieldValues} />
1414

1515
> When defining your field values, make sure that the individual values are compatible with the respective input element. You can learn more about this <A href="/guides/special-inputs">here</A>.
1616
1717
export const properties = {
18-
ModularValues: {
18+
FieldValues: {
1919
type: {
2020
type: 'object',
2121
entries: [
2222
{
2323
key: { name: 'name', type: 'string' },
2424
value: [
25-
{ type: 'custom', name: 'ModularValue', href: '/api/ModularValue' },
25+
{ type: 'custom', name: 'FieldValue', href: '/api/FieldValue' },
2626
{
2727
type: 'array',
2828
item: {
2929
type: 'custom',
30-
name: 'ModularValue',
31-
href: '/api/ModularValue',
30+
name: 'FieldValue',
31+
href: '/api/FieldValue',
3232
},
3333
},
34-
{ type: 'custom', name: 'ModularValues' },
34+
{ type: 'custom', name: 'FieldValues' },
3535
{
3636
type: 'array',
37-
item: { type: 'custom', name: 'ModularValues' },
37+
item: { type: 'custom', name: 'FieldValues' },
3838
},
3939
],
4040
},

0 commit comments

Comments
 (0)