UNPKG

@undermuz/use-form

Version:
60 lines (58 loc) 1.86 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/useForm/getInitialState.ts var getInitialState_exports = {}; __export(getInitialState_exports, { getInitialState: () => getInitialState }); module.exports = __toCommonJS(getInitialState_exports); var import_validate = require("./middlewares/validate.cjs"); var import_reducer = require("./reducer.cjs"); var DEF_INITIAL_STATE_OPTIONS = { initialValues: {}, valueTests: [], fields: {}, validate: import_validate.getFormErrors }; var getInitialState = (props = DEF_INITIAL_STATE_OPTIONS) => { const { initialValues = {}, valueTests = [], fields = {}, validate: _validate = import_validate.getFormErrors } = props; return { status: import_reducer.EnumFormStatus.Initial, values: initialValues, isSending: false, isCanceling: false, isSuccess: false, sendError: null, tests: valueTests, validate: _validate, touched: [], fields, errors: {}, customErrors: {} }; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { getInitialState });