Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { useEffect, useState } from 'react'
import { formSubscriptionItems } from 'final-form'
export const all = formSubscriptionItems.reduce((result, key) => {
result[key] = true
return result
}, {})
/**
* Converts { active: true, data: false, ... } to `[true, false, false, ...]`.
*/
const subscriptionToInputs = subscription =>
formSubscriptionItems.map(key => Boolean(subscription[key]))
const useFormState = (form, subscription = all) => {
const [state, setState] = useState(() => form.getState())
const deps = subscriptionToInputs(subscription)
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(() => form.subscribe(setState, subscription), [form, ...deps])
import { FormApi, FormState, FormSubscription, formSubscriptionItems, Unsubscribe } from 'final-form';
import { JSONSchema7 } from 'json-schema';
import { each, isEqual, memoize, set, values } from 'lodash';
import { Component, ComponentType } from 'react';
import * as React from 'react'; // tslint:disable-line no-duplicate-imports
import { getFormFromSchema, visitSchema } from '../core/core';
import { FrontierDataProps, schemaFromDataProps } from '../data';
import { saveData } from '../data/graphql';
import { UIKitAPI, UIKITFieldProps } from '../ui-kit';
export const allFormSubscriptionItems: FormSubscription = formSubscriptionItems.reduce(
(result, key) => {
result[key] = true;
return result;
},
{}
);
export interface Modifiers {
change: (value: any) => void; // tslint:disable-line no-any
focus: () => void;
blur: () => void;
}
// export type RenderPropsModifiersFieldObject = { [k: string]: RenderPropsModifiersFieldObject | Modifiers; }
// tslint:disable-next-line max-line-length
// export type RenderPropsUIKitFieldObject = { [k: string]: RenderPropsUIKitFieldObject | ComponentType; }
import {provider} from '@corpuscule/context';
import {assertRequiredProperty} from '@corpuscule/utils/lib/asserts';
import defineExtendable from '@corpuscule/utils/lib/defineExtendable';
import reflectClassMethods from '@corpuscule/utils/lib/reflectClassMethods';
import {createForm, formSubscriptionItems} from 'final-form';
import {formOptionResponsibilityKeys, tokenRegistry} from './utils';
export const all = formSubscriptionItems.reduce((result, key) => {
result[key] = true;
return result;
}, {});
const form = (token, {decorators = [], subscription = all} = {}) => klass => {
let $formApi;
let $state;
let $onSubmit;
let sharedProperties;
const {prototype} = klass;
const sharedPropertiesRegistry = tokenRegistry.get(token);
const $$reset = Symbol();
const $$submit = Symbol();
import shallowEqual from './shallowEqual'
import isSyntheticEvent from './isSyntheticEvent'
import type { FormRenderProps } from './types.js.flow'
import ReactFinalFormContext from './context'
import useLatest from './useLatest'
import { version } from '../package.json'
import { addLazyFormState } from './getters'
export { version }
const versions = {
'final-form': ffVersion,
'react-final-form': version
}
export const all: FormSubscription = formSubscriptionItems.reduce(
(result, key) => {
result[key] = true
return result
},
{}
)
function ReactFinalForm({
debug,
decorators,
destroyOnUnregister,
form: alternateFormApi,
initialValues,
initialValuesEqual,
keepDirtyOnReinitialize,
mutators,
import { createForm, formSubscriptionItems } from 'final-form'
import assign from 'nano-assign'
import { getChildren, composeFormValidators } from './utils'
const defaultSubscription = formSubscriptionItems.reduce(
(result, key) => {
result[key] = true
return result
},
{}
)
export default {
name: 'final-form',
props: {
initialValues: Object,
submit: {
type: Function,
default: () => {}
},