Socket
Socket
Sign inDemoInstall

@altiore/form

Package Overview
Dependencies
Maintainers
1
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@altiore/form - npm Package Compare versions

Comparing version 0.3.2 to 0.3.4

dist/@common/array-field-context.d.ts

19

dist/form/form.d.ts

@@ -1,5 +0,20 @@

import React from 'react';
import { ReactNode } from 'react';
export interface FormProps {
children: ReactNode;
defaultValues?: Record<string, any>;
onSubmit: (values: unknown) => void;
}
export declare const Form: React.FC<FormProps>;
/**
* Компонент Form принимает children, defaultValues, onSubmit
*
* @component
*
* @typedef Form
* @prop {React.ReactNode} [children] Childrens формы
* @prop {React.ReactNode} [defaultValues] Дефолтные значения
* @prop {func} [onSubmit] ...
*
* @example
* return (any)
*/
export declare const Form: ({ children, defaultValues, onSubmit, }: FormProps) => JSX.Element;

@@ -1,5 +0,49 @@

import React, { useCallback, useRef } from 'react';
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import React, { useCallback, useRef, useState, } from 'react';
import set from 'lodash/set';
import { FormContext } from '../@common/form-context';
import { List } from '../create-field-array/list';
/**
* Компонент Form принимает children, defaultValues, onSubmit
*
* @component
*
* @typedef Form
* @prop {React.ReactNode} [children] Childrens формы
* @prop {React.ReactNode} [defaultValues] Дефолтные значения
* @prop {func} [onSubmit] ...
*
* @example
* return (any)
*/
export var Form = function (_a) {
var children = _a.children, onSubmit = _a.onSubmit;
var children = _a.children, defaultValues = _a.defaultValues, onSubmit = _a.onSubmit;
var formRef = useRef(null);
var _b = useState({
defaultValues: defaultValues,
errors: {},
fields: {},
}), formState = _b[0], setFormState = _b[1];
var registerField = useCallback(function (fieldName, isArray, prevList) {
setFormState(function (s) {
var _a;
var _b;
return (__assign(__assign({}, s), { fields: __assign(__assign({}, s.fields), (_a = {}, _a[fieldName] = {
list: isArray
? new List(registerField, (_b = s.defaultValues) === null || _b === void 0 ? void 0 : _b[fieldName], fieldName, prevList)
: undefined,
registered: true,
}, _a)) }));
});
}, [setFormState]);
var handleSubmit = useCallback(function (evt) {

@@ -10,6 +54,10 @@ var _a;

var values = {};
formData.forEach(function (value, key) { return (values[key] = value); });
formData.forEach(function (value, key) {
var keyArr = key.split('.');
set(values, keyArr, value);
});
onSubmit(values);
}, [onSubmit]);
return (React.createElement("form", { ref: formRef, onSubmit: handleSubmit }, children));
return (React.createElement("form", { onSubmit: handleSubmit, ref: formRef },
React.createElement(FormContext.Provider, { value: __assign(__assign({}, formState), { registerField: registerField }) }, children)));
};

3

dist/index.d.ts

@@ -1,2 +0,3 @@

export * from './field';
export * from './create-field';
export * from './form';
export * from './validators';

@@ -1,2 +0,3 @@

export * from './field';
export * from './create-field';
export * from './form';
export * from './validators';
{
"name": "@altiore/form",
"version": "0.3.2",
"version": "0.3.4",
"description": "Form helper for building powerful forms",

@@ -11,4 +11,5 @@ "main": "dist/index.js",

"scripts": {
"start": "npm run storybook",
"build": "rm -rf dist && tsc",
"start": "npm run story",
"test:jest": "jest",
"build": "rm -rf dist && tsc && tscpaths -p tsconfig.json -s ./src -o ./dist",
"npm:patch": "npm version patch && npm publish --access=public && git push && git push --tags",

@@ -20,7 +21,8 @@ "npm:minor": "npm version minor && npm publish --access=public && git push && git push --tags",

"lint:ci": "tsc --noEmit && prettier --check \"**/*.{js,jsx,ts,tsx,json,md,yml}\" && eslint . --ext .js,.jsx,.ts,.tsx --max-warnings=0",
"jsdoc": "jsdoc -c jsdoc.json",
"prepublish": "npm run build",
"prepare": "husky install",
"storybook": "start-storybook -p 8888",
"build-storybook": "build-storybook",
"deploy-storybook": "storybook-to-ghpages"
"story": "start-storybook -p 8888",
"story-build": "rm -rf ./storybook-static && build-storybook",
"story-deploy": "gh-pages -d storybook-static"
},

@@ -32,7 +34,15 @@ "repository": {

"keywords": [
"test",
"regex",
"within",
"probject",
"forbidden"
"form",
"forms",
"react",
"react-dom",
"altiore",
"validate",
"validation",
"form-decorator",
"form-hook",
"form-HOC",
"form-helper",
"form helper",
"validation helper"
],

@@ -44,2 +54,9 @@ "author": {

},
"contributors": [
{
"name": "Alexander Chernykh",
"email": "dev@whitered932.ru",
"url": "https://github.com/whitered932"
}
],
"license": "MIT",

@@ -61,2 +78,3 @@ "bugs": {

"@storybook/storybook-deployer": "^2.8.10",
"@types/jest": "^27.0.2",
"@types/lodash": "^4.14.173",

@@ -67,2 +85,3 @@ "@types/node": "16.4.9",

"babel-loader": "^8.2.2",
"better-docs": "^2.3.2",
"eslint": "7.32.0",

@@ -72,3 +91,5 @@ "eslint-config-prettier": "8.3.0",

"eslint-plugin-prettier": "^3.4.0",
"gh-pages": "3.2.3",
"husky": "^7.0.1",
"jest": "^27.3.1",
"lint-staged": "^11.1.1",

@@ -78,4 +99,23 @@ "prettier": "2.3.2",

"react-dom": "^16.14.0",
"ts-jest": "^27.0.7",
"tscpaths": "0.0.9",
"typescript": "4.4.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"ts",
"json"
],
"rootDir": "./",
"moduleNameMapper": {
"@root-dir/(.*)": "<rootDir>/$1",
"~/(.*)": "<rootDir>/src/$1"
},
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"testEnvironment": "node"
},
"peerDependencies": {

@@ -82,0 +122,0 @@ "react": "^16.14.0 || ^17.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc