UNPKG

@shopify/react-form

Version:

Manage react forms tersely and safely-typed with no magic using React hooks.

30 lines (29 loc) 947 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function isField(input) { return (input.hasOwnProperty('value') && input.hasOwnProperty('onChange') && input.hasOwnProperty('onBlur') && input.hasOwnProperty('defaultValue')); } exports.isField = isField; function mapObject(input, mapper) { return Object.keys(input).reduce(function (accumulator, key) { var value = input[key]; accumulator[key] = mapper(value, key); return accumulator; }, {}); } exports.mapObject = mapObject; function normalizeValidation(input) { return Array.isArray(input) ? input : [input]; } exports.normalizeValidation = normalizeValidation; function isChangeEvent(value) { return (typeof value === 'object' && Reflect.has(value, 'target') && Reflect.has(value.target, 'value')); } exports.isChangeEvent = isChangeEvent; function noop() { } exports.noop = noop;