Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
morrys committed Nov 7, 2023
1 parent 42d779e commit 339b750
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 31 deletions.
4 changes: 2 additions & 2 deletions examples/form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"react-relay-forms": "^1.1.1",
"react-relay-forms": "^2.0.0",
"relay-forms": "2.0.0",
"relay-forms-nodeps": "^1.1.1",
"relay-forms-nodeps": "^2.0.0",
"react-relay": "14.1.0",
"relay-hooks": "8.0.0",
"relay-runtime": "^14.1.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/form/src/AppNoDeps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ const App = () => {
);
};

export { useFormSetValue, useFormSubmit, useFormState, useFormValue } from 'relay-forms-nodeps';
export { useFormField, useForm, useFormState, useFormValue } from 'relay-forms-nodeps';

export default App;
2 changes: 1 addition & 1 deletion examples/form/src/AppReactRelayForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const App = () => {
);
};

export { useFormSetValue, useFormSubmit, useFormState, useFormValue } from 'react-relay-forms';
export { useFormField, useForm, useFormState, useFormValue } from 'react-relay-forms';

export default App;
7 changes: 1 addition & 6 deletions examples/form/src/AppRelayForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ const App = () => {
);
};

export {
useFormField as useFormSetValue,
useForm as useFormSubmit,
useFormState,
useFormValue,
} from 'relay-forms';
export { useFormField, useForm, useFormState, useFormValue } from 'relay-forms';

export default App;
4 changes: 2 additions & 2 deletions examples/form/src/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, BoxProps, Paper } from '@mui/material';
import * as React from 'react';
import { InputField, required, validateMinFive } from './InputField';
import { DELAY, useFormSubmit } from './index';
import { DELAY, useForm } from './index';
import { InputDateField } from './InputDateField';
import { InputFiles } from './InputFiles';
import { SelectField } from './SelectField';
Expand Down Expand Up @@ -54,7 +54,7 @@ export const FormBox: React.FunctionComponent<FormBoxProps> = (props) => (
);

export const FormInternal: React.FC<any> = ({ onSubmit }) => {
const data = useFormSubmit<FormSubmit>({
const data = useForm<FormSubmit>({
onSubmit: async (values) => {
console.log('SUBMIT :)', values);

Expand Down
4 changes: 2 additions & 2 deletions examples/form/src/InputDateField.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { useFormSetValue } from './index';
import { useFormField } from './index';
import { TextField as TextFieldMUI } from '@mui/material';

export type InputDateFieldType = Date | undefined;

const initialValue = new Date();

export const InputDateField: React.FC<any> = ({ fieldKey, placeholder }) => {
const [{ value, error }, setValue] = useFormSetValue<InputDateFieldType>({
const [{ value, error }, setValue] = useFormField<InputDateFieldType>({
key: fieldKey,
initialValue,
label: placeholder,
Expand Down
4 changes: 2 additions & 2 deletions examples/form/src/InputField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { TextField as TextFieldMUI } from '@mui/material';
import { DELAY, useFormSetValue } from './index';
import { DELAY, useFormField } from './index';
import { useCallback } from 'react';
import { sleep } from './Form';

Expand Down Expand Up @@ -32,7 +32,7 @@ export const InputField: React.FC<TextFieldProps> = ({
initialValue,
validate,
}) => {
const [{ error, value }, setValue] = useFormSetValue({
const [{ error, value }, setValue] = useFormField({
key: fieldKey,
validate,
initialValue: initialValue ? initialValue : '',
Expand Down
4 changes: 2 additions & 2 deletions examples/form/src/InputFiles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { useFormSetValue } from './index';
import { useFormField } from './index';
import Chip from '@mui/material/Chip';
import CloudUploadIcon from '@mui/icons-material/CloudUpload';
import PublishIcon from '@mui/icons-material/Publish';
Expand All @@ -10,7 +10,7 @@ import Button from '@mui/material/Button';
import { styled } from '@mui/styles';

export const InputFiles: React.FC<any> = ({ fieldKey, initialValue }) => {
const [{ value }, setValue] = useFormSetValue({
const [{ value }, setValue] = useFormField({
key: fieldKey,
initialValue,
});
Expand Down
4 changes: 2 additions & 2 deletions examples/form/src/SelectField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { useFormSetValue } from './index';
import { useFormField } from './index';
import { useCallback } from 'react';
import TextField from '@mui/material/TextField';

Expand All @@ -20,7 +20,7 @@ export const SelectField: React.FC<TextFieldProps> = ({
width = 330,
initialValue = 'None',
}) => {
const [{ error, value }, setValue] = useFormSetValue({
const [{ error, value }, setValue] = useFormField({
key: fieldKey,
validate,
initialValue,
Expand Down
6 changes: 3 additions & 3 deletions examples/form/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import ReactDOM from 'react-dom';
import './index.css';

//import App from './AppNoDeps';
//export { useFormSetValue, useFormSubmit, useFormState, useFormValue } from './AppNoDeps';
//export { useFormField, useForm, useFormState, useFormValue } from './AppNoDeps';
//import App from './AppReactRelayForms';
//export { useFormSetValue, useFormSubmit, useFormState, useFormValue } from './AppReactRelayForms';
//export { useFormField, useForm, useFormState, useFormValue } from './AppReactRelayForms';
import App from './AppRelayForms';
export { useFormSetValue, useFormSubmit, useFormState, useFormValue } from './AppRelayForms';
export { useFormField, useForm, useFormState, useFormValue } from './AppRelayForms';
// eslint-disable-next-line import/first
import * as serviceWorker from './serviceWorker';

Expand Down
16 changes: 8 additions & 8 deletions examples/form/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7758,10 +7758,10 @@ react-refresh@^0.11.0:
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046"
integrity sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==

react-relay-forms@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/react-relay-forms/-/react-relay-forms-1.1.1.tgz#a1f54c87fd8dcc0336840daf46b17042b4981eab"
integrity sha512-dCCDL+7By6Bms9C3b2DJAhyl/y2H6lfF3KjMIk1mt6sb8kTYHPNXvNJVqKVpnAQBtZBACN7WyKwc88Do+TLHHg==
react-relay-forms@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/react-relay-forms/-/react-relay-forms-2.0.0.tgz#7e573b686e2d4c6628dcaea7958f8bca9a2dc6f5"
integrity sha512-xzVKBahGE0oF52Yrs66IztQI1e7XftvRdDTrDGw1AdvEm0gwi4OYbEba4lXv07rilRBPmlCHyeu3m662bW68Cw==

react-relay@14.1.0:
version "14.1.0"
Expand Down Expand Up @@ -7962,10 +7962,10 @@ relateurl@^0.2.7:
resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9"
integrity sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==

relay-forms-nodeps@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/relay-forms-nodeps/-/relay-forms-nodeps-1.1.1.tgz#39072c0ed077746c73a7c03d129125b45df93142"
integrity sha512-5SOME+8Yfor+RwjNNEKAY2cAcYtYKx12aw4gE1HoYkdBqDKJ8dm8Bcl7XNQiQ4V5Vg6MQQqIquaxfau09/ODDg==
relay-forms-nodeps@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/relay-forms-nodeps/-/relay-forms-nodeps-2.0.0.tgz#ca531e568e20ecf40a6b5ab1f2f1d87e919f3d6f"
integrity sha512-eXgCQTee0amV08sTjmQ1eJtzP6dAC68ujz7Zn1LKFxZZu8C7X0E54rvwJOcU8BVSNP5x9NC2pPmykySvBs5vCw==

relay-forms@2.0.0:
version "2.0.0"
Expand Down

0 comments on commit 339b750

Please sign in to comment.