@altiore/form
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,37 +0,13 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Field = void 0; | ||
const react_1 = __importStar(require("react")); | ||
const debounce_1 = __importDefault(require("lodash/debounce")); | ||
const Field = ({ name, component: Input, validate, }) => { | ||
const [meta, setMeta] = (0, react_1.useState)({ | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
import _debounce from 'lodash/debounce'; | ||
export var Field = function (_a) { | ||
var name = _a.name, Input = _a.component, validate = _a.validate; | ||
var _b = useState({ | ||
valid: true, | ||
}); | ||
const handleDebounceFn = (0, react_1.useCallback)((e) => { | ||
}), meta = _b[0], setMeta = _b[1]; | ||
var handleDebounceFn = useCallback(function (e) { | ||
e.preventDefault(); | ||
if (e.target) { | ||
const { value } = e.target; | ||
const validationError = typeof validate === 'function' ? validate(value) : undefined; | ||
var value = e.target.value; | ||
var validationError = typeof validate === 'function' ? validate(value) : undefined; | ||
setMeta({ | ||
@@ -43,8 +19,8 @@ error: validationError, | ||
}, []); | ||
const debounceHandle = (0, react_1.useCallback)((0, debounce_1.default)(handleDebounceFn, 1500), []); | ||
const handleKeyUp = (0, react_1.useCallback)((e) => { | ||
var debounceHandle = useCallback(_debounce(handleDebounceFn, 1500), []); | ||
var handleKeyUp = useCallback(function (e) { | ||
debounceHandle(e); | ||
}, [debounceHandle]); | ||
(0, react_1.useEffect)(() => { | ||
const input = document.querySelector(`input[name=${name}]`); | ||
useEffect(function () { | ||
var input = document.querySelector("input[name=" + name + "]"); | ||
if (input) { | ||
@@ -54,5 +30,5 @@ input.addEventListener('keyup', handleKeyUp); | ||
else { | ||
throw new Error(`Input c name=${name} не был найден`); | ||
throw new Error("Input c name=" + name + " \u043D\u0435 \u0431\u044B\u043B \u043D\u0430\u0439\u0434\u0435\u043D"); | ||
} | ||
return () => { | ||
return function () { | ||
if (input) { | ||
@@ -63,4 +39,3 @@ input.removeEventListener('keyup', handleKeyUp); | ||
}, []); | ||
return (react_1.default.createElement(react_1.default.Fragment, null, Input ? react_1.default.createElement(Input, { name: name, meta: meta }) : react_1.default.createElement("input", { name: name }))); | ||
return (React.createElement(React.Fragment, null, Input ? React.createElement(Input, { name: name, meta: meta }) : React.createElement("input", { name: name }))); | ||
}; | ||
exports.Field = Field; |
@@ -1,13 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./field"), exports); | ||
export * from './field'; |
@@ -1,35 +0,14 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Form = void 0; | ||
const react_1 = __importStar(require("react")); | ||
const Form = ({ children, onSubmit }) => { | ||
const formRef = (0, react_1.useRef)(null); | ||
const handleSubmit = (0, react_1.useCallback)((evt) => { | ||
import React, { useCallback, useRef } from 'react'; | ||
export var Form = function (_a) { | ||
var children = _a.children, onSubmit = _a.onSubmit; | ||
var formRef = useRef(null); | ||
var handleSubmit = useCallback(function (evt) { | ||
var _a; | ||
evt.preventDefault(); | ||
const formData = new FormData(formRef.current ?? undefined); | ||
const values = {}; | ||
formData.forEach((value, key) => (values[key] = value)); | ||
var formData = new FormData((_a = formRef.current) !== null && _a !== void 0 ? _a : undefined); | ||
var values = {}; | ||
formData.forEach(function (value, key) { return (values[key] = value); }); | ||
onSubmit(values); | ||
}, [onSubmit]); | ||
return (react_1.default.createElement("form", { ref: formRef, onSubmit: handleSubmit }, children)); | ||
return (React.createElement("form", { ref: formRef, onSubmit: handleSubmit }, children)); | ||
}; | ||
exports.Form = Form; |
@@ -1,13 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./form"), exports); | ||
export * from './form'; |
@@ -1,14 +0,2 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./field"), exports); | ||
__exportStar(require("./form"), exports); | ||
export * from './field'; | ||
export * from './form'; |
{ | ||
"name": "@altiore/form", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Form helper for building powerful forms", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
5891
80