namirasoft-site-react 1.3.47 → 1.3.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Validator.d.ts +9 -0
- package/dist/Validator.js +52 -0
- package/dist/Validator.js.map +1 -0
- package/dist/components/NSInputEmail.d.ts +6 -2
- package/dist/components/NSInputEmail.js +12 -13
- package/dist/components/NSInputEmail.js.map +1 -1
- package/dist/components/NSInputFloat.d.ts +6 -1
- package/dist/components/NSInputFloat.js +11 -1
- package/dist/components/NSInputFloat.js.map +1 -1
- package/dist/components/NSSpace.d.ts +1 -10
- package/dist/components/NSSpace.js +2 -18
- package/dist/components/NSSpace.js.map +1 -1
- package/dist/props/BaseComponentProps.d.ts +5 -0
- package/dist/props/BaseComponentProps.js +2 -0
- package/dist/props/BaseComponentProps.js.map +1 -0
- package/dist/props/ValidationNumberProps.d.ts +5 -0
- package/dist/props/ValidationNumberProps.js +2 -0
- package/dist/props/ValidationNumberProps.js.map +1 -0
- package/dist/props/ValidationProps.d.ts +5 -0
- package/dist/props/ValidationProps.js +2 -0
- package/dist/props/ValidationProps.js.map +1 -0
- package/dist/props/ValidationRegexProps.d.ts +4 -0
- package/dist/props/ValidationRegexProps.js +2 -0
- package/dist/props/ValidationRegexProps.js.map +1 -0
- package/dist/props/ValidationStringProps.d.ts +5 -0
- package/dist/props/ValidationStringProps.js +2 -0
- package/dist/props/ValidationStringProps.js.map +1 -0
- package/package.json +2 -2
- package/src/App.tsx +1 -1
- package/src/Validator.ts +62 -0
- package/src/components/NSInputEmail.tsx +34 -30
- package/src/components/NSInputFloat.tsx +29 -9
- package/src/components/NSSpace.tsx +4 -31
- package/src/props/BaseComponentProps.ts +7 -0
- package/src/props/ValidationNumberProps.ts +7 -0
- package/src/props/ValidationProps.ts +7 -0
- package/src/props/ValidationRegexProps.ts +5 -0
- package/src/props/ValidationStringProps.ts +7 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ValidationNumberProps } from "./props/ValidationNumberProps";
|
|
2
|
+
import { ValidationProps } from "./props/ValidationProps";
|
|
3
|
+
import { ValidationStringProps } from "./props/ValidationStringProps";
|
|
4
|
+
export declare class Validator {
|
|
5
|
+
static getError(name: string, value: string | null | undefined, validator: ValidationProps): string | null;
|
|
6
|
+
static getErrorString(name: string, value: string | null | undefined, validator: ValidationStringProps): string | null;
|
|
7
|
+
static getErrorNumber(name: string, value: string | null | undefined, validator: ValidationNumberProps): string | null;
|
|
8
|
+
static getErrorEmail(name: string, value: string | null | undefined): string | null;
|
|
9
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export class Validator {
|
|
2
|
+
static getError(name, value, validator) {
|
|
3
|
+
if (validator.required)
|
|
4
|
+
if (!value)
|
|
5
|
+
return `${name} is required.`;
|
|
6
|
+
if (value)
|
|
7
|
+
if (validator.regex)
|
|
8
|
+
if (!validator.regex.regex.test(value))
|
|
9
|
+
return `${name} is not a valid ${validator.regex.name}.`;
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
static getErrorString(name, value, validator) {
|
|
13
|
+
let error = this.getError(name, value, validator);
|
|
14
|
+
if (error)
|
|
15
|
+
return error;
|
|
16
|
+
if (value) {
|
|
17
|
+
if (validator.max_length != null)
|
|
18
|
+
if (validator.max_length < value.length)
|
|
19
|
+
return `Max length of ${name} should be ${validator.max_length} characters.`;
|
|
20
|
+
if (validator.min_length != null)
|
|
21
|
+
if (validator.min_length > value.length)
|
|
22
|
+
return `Minlength of ${name} should be ${validator.min_length} characters.`;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
static getErrorNumber(name, value, validator) {
|
|
27
|
+
let error = this.getError(name, value, validator);
|
|
28
|
+
if (error)
|
|
29
|
+
return error;
|
|
30
|
+
if (value) {
|
|
31
|
+
let numValue = parseFloat(value);
|
|
32
|
+
if (isNaN(numValue))
|
|
33
|
+
return `${name} is not a number.`;
|
|
34
|
+
if (validator.max != null)
|
|
35
|
+
if (validator.max < numValue)
|
|
36
|
+
return `Max value of ${name} should be ${validator.max} characters.`;
|
|
37
|
+
if (validator.min != null)
|
|
38
|
+
if (validator.min > numValue)
|
|
39
|
+
return `Min value of ${name} should be ${validator.min} characters.`;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
static getErrorEmail(name, value) {
|
|
44
|
+
return Validator.getError(name, value, {
|
|
45
|
+
required: true, regex: {
|
|
46
|
+
name: "Email",
|
|
47
|
+
regex: /^[\w]+@([\w]+\.)+\w{2,}$/gm
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=Validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Validator.js","sourceRoot":"","sources":["../src/Validator.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,SAAS;IAElB,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,KAAgC,EAAE,SAA0B;QAEtF,IAAI,SAAS,CAAC,QAAQ;YAClB,IAAI,CAAC,KAAK;gBACN,OAAO,GAAG,IAAI,eAAe,CAAC;QACtC,IAAI,KAAK;YACL,IAAI,SAAS,CAAC,KAAK;gBACf,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;oBAClC,OAAO,GAAG,IAAI,mBAAmB,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC;QACrE,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,CAAC,cAAc,CAAC,IAAY,EAAE,KAAgC,EAAE,SAAgC;QAElG,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAClD,IAAI,KAAK;YACL,OAAO,KAAK,CAAC;QACjB,IAAI,KAAK,EACT,CAAC;YACG,IAAI,SAAS,CAAC,UAAU,IAAI,IAAI;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A4B;aACtC;SACJ,CAAC,CAAA;IACN,CAAC;CACJ"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
import { ValidationProps } from "../props/ValidationProps";
|
|
3
|
+
import { ValidationStringProps } from "../props/ValidationStringProps";
|
|
4
|
+
export interface NSInputEmailProps extends ValidationProps, ValidationStringProps {
|
|
3
5
|
title: string;
|
|
4
6
|
defaultValue?: string;
|
|
7
|
+
placeholder?: string;
|
|
5
8
|
onChanged?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
6
9
|
}
|
|
7
10
|
export interface NSInputEmailState {
|
|
8
11
|
value: string;
|
|
9
|
-
error
|
|
12
|
+
error?: string;
|
|
10
13
|
}
|
|
11
14
|
export declare class NSInputEmail extends React.Component<NSInputEmailProps, NSInputEmailState> {
|
|
12
15
|
constructor(props: NSInputEmailProps);
|
|
16
|
+
getError(): string | null;
|
|
13
17
|
getValue(): string;
|
|
14
18
|
setValue(value: string): void;
|
|
15
19
|
private onChanged;
|
|
@@ -4,30 +4,29 @@ import React from "react";
|
|
|
4
4
|
import Styles from "./NSInputEmail.module.css";
|
|
5
5
|
import IconInputEmail from '../assets/images/icon-input-email.svg';
|
|
6
6
|
import Danger from '../assets/images/danger.svg';
|
|
7
|
+
import { Validator } from "../Validator";
|
|
7
8
|
export class NSInputEmail extends React.Component {
|
|
8
9
|
constructor(props) {
|
|
9
10
|
var _a;
|
|
10
11
|
super(props);
|
|
11
|
-
this.state = {
|
|
12
|
-
value: (_a = props.defaultValue) !== null && _a !== void 0 ? _a : "",
|
|
13
|
-
error: false,
|
|
14
|
-
};
|
|
12
|
+
this.state = { value: (_a = props.defaultValue) !== null && _a !== void 0 ? _a : "" };
|
|
15
13
|
this.setValue = this.setValue.bind(this);
|
|
16
14
|
this.getValue = this.getValue.bind(this);
|
|
17
15
|
this.onChanged = this.onChanged.bind(this);
|
|
18
16
|
}
|
|
17
|
+
getError() {
|
|
18
|
+
return Validator.getErrorString(this.props.title, this.state.value, this.props) && Validator.getErrorEmail(this.props.title, this.state.value);
|
|
19
|
+
}
|
|
19
20
|
getValue() {
|
|
21
|
+
let error = this.getError();
|
|
22
|
+
if (error) {
|
|
23
|
+
this.setState({ error });
|
|
24
|
+
throw new Error(error);
|
|
25
|
+
}
|
|
20
26
|
return this.state.value;
|
|
21
27
|
}
|
|
22
28
|
setValue(value) {
|
|
23
|
-
|
|
24
|
-
debugger;
|
|
25
|
-
if (!email.test(value)) {
|
|
26
|
-
this.setState({ error: true, value });
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
this.setState({ error: false, value });
|
|
30
|
-
}
|
|
29
|
+
this.setState({ value });
|
|
31
30
|
}
|
|
32
31
|
onChanged(e) {
|
|
33
32
|
this.setValue(e.target.value);
|
|
@@ -35,7 +34,7 @@ export class NSInputEmail extends React.Component {
|
|
|
35
34
|
this.props.onChanged(e);
|
|
36
35
|
}
|
|
37
36
|
render() {
|
|
38
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: `${Styles.ns_input_parent} p-2`, children: [_jsx("span", { className: Styles.ns_input_title, children: this.props.title }), _jsx("img", { className: Styles.ns_input_icon, src: IconInputEmail, alt: "
|
|
37
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: `${Styles.ns_input_parent} p-2`, children: [_jsx("span", { className: Styles.ns_input_title, children: this.props.title }), _jsx("img", { className: Styles.ns_input_icon, src: IconInputEmail, alt: "Email Icon", width: 24, height: 24 }), _jsx("input", { value: this.state.value, onChange: this.onChanged, type: "email", className: `${this.state.error ? Styles.ns_input_red : ""} ${Styles.ns_input}`, placeholder: this.props.placeholder })] }), this.state.error && (_jsx(_Fragment, { children: _jsxs("div", { className: "d-flex justify-content-start align-items-center gap-2 ms-2", children: [_jsx("img", { className: "", src: Danger, alt: "Error Icon", width: 13, height: 13 }), _jsx("span", { className: Styles.ns_input_error, children: this.state.error })] }) }))] }));
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
//# sourceMappingURL=NSInputEmail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSInputEmail.js","sourceRoot":"","sources":["../../src/components/NSInputEmail.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,cAAc,MAAM,uCAAuC,CAAC;AACnE,OAAO,MAAM,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"NSInputEmail.js","sourceRoot":"","sources":["../../src/components/NSInputEmail.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,cAAc,MAAM,uCAAuC,CAAC;AACnE,OAAO,MAAM,MAAM,6BAA6B,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAkBzC,MAAM,OAAO,YAAa,SAAQ,KAAK,CAAC,SAA+C;IAEnF,YAAY,KAAwB;;QAEhC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,MAAA,KAAK,CAAC,YAAY,mCAAI,EAAE,EAAE,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,QAAQ;QAEJ,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,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CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,QAAQ,EAAE,EAC9E,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,GACrC,IACA,EAGF,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CAChB,4BACI,eAAK,SAAS,EAAC,4DAA4D,aACvE,cACI,SAAS,EAAE,EAAE,EACb,GAAG,EAAE,MAAM,EACX,GAAG,EAAC,YAAY,EAChB,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,GACZ,EACF,eAAM,SAAS,EAAE,MAAM,CAAC,cAAc,YAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAQ,IAC/D,GACP,CAAC,IAEb,CACN,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
import { BaseComponentProps } from "../props/BaseComponentProps";
|
|
3
|
+
import { ValidationProps } from "../props/ValidationProps";
|
|
4
|
+
import { ValidationNumberProps } from "../props/ValidationNumberProps";
|
|
5
|
+
export interface NSInputFloatProps extends BaseComponentProps, ValidationProps, ValidationNumberProps {
|
|
3
6
|
title: string;
|
|
4
7
|
defaultValue?: string;
|
|
5
8
|
onChanged?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
6
9
|
}
|
|
7
10
|
export interface NSInputFloatState {
|
|
8
11
|
value: string;
|
|
12
|
+
error?: string;
|
|
9
13
|
}
|
|
10
14
|
export declare class NSInputFloat extends React.Component<NSInputFloatProps, NSInputFloatState> {
|
|
11
15
|
constructor(props: NSInputFloatProps);
|
|
16
|
+
getError(): string | null;
|
|
12
17
|
getValue(): string;
|
|
13
18
|
setValue(value: string): void;
|
|
14
19
|
private onChanged;
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import Styles from "./NSInputFloat.module.css";
|
|
5
5
|
import IconInputFloat from '../assets/images/icon-input-float.svg';
|
|
6
|
+
import { Validator } from "../Validator";
|
|
6
7
|
export class NSInputFloat extends React.Component {
|
|
7
8
|
constructor(props) {
|
|
8
9
|
var _a;
|
|
@@ -14,7 +15,15 @@ export class NSInputFloat extends React.Component {
|
|
|
14
15
|
this.getValue = this.getValue.bind(this);
|
|
15
16
|
this.onChanged = this.onChanged.bind(this);
|
|
16
17
|
}
|
|
18
|
+
getError() {
|
|
19
|
+
return Validator.getErrorNumber(this.props.title, this.state.value, this.props);
|
|
20
|
+
}
|
|
17
21
|
getValue() {
|
|
22
|
+
let error = this.getError();
|
|
23
|
+
if (error) {
|
|
24
|
+
this.setState({ error });
|
|
25
|
+
throw new Error(error);
|
|
26
|
+
}
|
|
18
27
|
return this.state.value;
|
|
19
28
|
}
|
|
20
29
|
setValue(value) {
|
|
@@ -26,7 +35,8 @@ export class NSInputFloat extends React.Component {
|
|
|
26
35
|
this.props.onChanged(e);
|
|
27
36
|
}
|
|
28
37
|
render() {
|
|
29
|
-
|
|
38
|
+
var _a;
|
|
39
|
+
return (_jsxs("div", { className: `${Styles.ns_input_parent} p-2 ${(_a = this.props.classList) === null || _a === void 0 ? void 0 : _a.join(" ")}`, style: this.props.style, children: [_jsxs("span", { className: Styles.ns_input_title, children: [this.props.required && _jsx("span", { children: "*" }), this.props.title] }), _jsx("img", { className: Styles.ns_input_icon, src: IconInputFloat, alt: "icon", width: 24, height: 24 }), _jsx("input", { value: this.state.value, onChange: this.onChanged, type: "number", className: Styles.ns_input, placeholder: "1.2" })] }));
|
|
30
40
|
}
|
|
31
41
|
}
|
|
32
42
|
//# sourceMappingURL=NSInputFloat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSInputFloat.js","sourceRoot":"","sources":["../../src/components/NSInputFloat.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAA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GE = "128px"
|
|
16
15
|
}
|
|
17
|
-
export
|
|
18
|
-
size: NSSpaceSizeType;
|
|
19
|
-
}
|
|
20
|
-
export declare class NSSpace extends React.Component<NSSpaceProps, NSSpaceState> {
|
|
21
|
-
constructor(props: NSSpaceProps);
|
|
22
|
-
setValue(size: NSSpaceSizeType): void;
|
|
23
|
-
getValue(): NSSpaceSizeType;
|
|
24
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
}
|
|
16
|
+
export declare function NSSpace(props: NSSpaceProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import React from "react";
|
|
4
2
|
export var NSSpaceSizeType;
|
|
5
3
|
(function (NSSpaceSizeType) {
|
|
6
4
|
NSSpaceSizeType["NANO"] = "4px";
|
|
@@ -14,21 +12,7 @@ export var NSSpaceSizeType;
|
|
|
14
12
|
NSSpaceSizeType["XXLARGE"] = "96px";
|
|
15
13
|
NSSpaceSizeType["XXXLARGE"] = "128px";
|
|
16
14
|
})(NSSpaceSizeType || (NSSpaceSizeType = {}));
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
super(props);
|
|
20
|
-
this.state = { size: props.size };
|
|
21
|
-
this.setValue = this.setValue.bind(this);
|
|
22
|
-
this.getValue = this.getValue.bind(this);
|
|
23
|
-
}
|
|
24
|
-
setValue(size) {
|
|
25
|
-
this.setState({ size });
|
|
26
|
-
}
|
|
27
|
-
getValue() {
|
|
28
|
-
return this.state.size;
|
|
29
|
-
}
|
|
30
|
-
render() {
|
|
31
|
-
return (_jsx("hr", { style: { width: "100%", height: this.state.size, margin: "0px", padding: "0px", background: "transparent", color: "transparent", border: 0 } }));
|
|
32
|
-
}
|
|
15
|
+
export function NSSpace(props) {
|
|
16
|
+
return (_jsx("hr", { style: { width: "100%", height: props.size, margin: "0px", padding: "0px", background: "transparent", color: "transparent", border: 0 } }));
|
|
33
17
|
}
|
|
34
18
|
//# sourceMappingURL=NSSpace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSSpace.js","sourceRoot":"","sources":["../../src/components/NSSpace.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NSSpace.js","sourceRoot":"","sources":["../../src/components/NSSpace.tsx"],"names":[],"mappings":";AAKA,MAAM,CAAN,IAAY,eAYX;AAZD,WAAY,eAAe;IAEvB,+BAAY,CAAA;IACZ,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,iCAAc,CAAA;IACd,kCAAe,CAAA;IACf,kCAAe,CAAA;IACf,iCAAc,CAAA;IACd,kCAAe,CAAA;IACf,mCAAgB,CAAA;IAChB,qCAAkB,CAAA;AACtB,CAAC,EAZW,eAAe,KAAf,eAAe,QAY1B;AAED,MAAM,UAAU,OAAO,CAAC,KAAmB;IAEvC,OAAO,CACH,aAAI,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,EAAE,GAAI,CAClJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseComponentProps.js","sourceRoot":"","sources":["../../src/props/BaseComponentProps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationNumberProps.js","sourceRoot":"","sources":["../../src/props/ValidationNumberProps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationProps.js","sourceRoot":"","sources":["../../src/props/ValidationProps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationRegexProps.js","sourceRoot":"","sources":["../../src/props/ValidationRegexProps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationStringProps.js","sourceRoot":"","sources":["../../src/props/ValidationStringProps.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.3.
|
|
11
|
+
"version": "1.3.49",
|
|
12
12
|
"author": "Amir Abolhasani, Alireza Esmaeeli, Hooman Shashaeh",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/main.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@types/node": "^20.12.7",
|
|
25
|
-
"@types/react": "^18.2.
|
|
25
|
+
"@types/react": "^18.2.79",
|
|
26
26
|
"@types/react-dom": "^18.2.25",
|
|
27
27
|
"antd": "^5.16.2",
|
|
28
28
|
"bootstrap": "^5.3.3",
|
package/src/App.tsx
CHANGED
package/src/Validator.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ValidationNumberProps } from "./props/ValidationNumberProps";
|
|
2
|
+
import { ValidationProps } from "./props/ValidationProps";
|
|
3
|
+
import { ValidationStringProps } from "./props/ValidationStringProps";
|
|
4
|
+
|
|
5
|
+
export class Validator
|
|
6
|
+
{
|
|
7
|
+
static getError(name: string, value: string | null | undefined, validator: ValidationProps): string | null
|
|
8
|
+
{
|
|
9
|
+
if (validator.required)
|
|
10
|
+
if (!value)
|
|
11
|
+
return `${name} is required.`;
|
|
12
|
+
if (value)
|
|
13
|
+
if (validator.regex)
|
|
14
|
+
if (!validator.regex.regex.test(value))
|
|
15
|
+
return `${name} is not a valid ${validator.regex.name}.`;
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
static getErrorString(name: string, value: string | null | undefined, validator: ValidationStringProps): string | null
|
|
19
|
+
{
|
|
20
|
+
let error = this.getError(name, value, validator);
|
|
21
|
+
if (error)
|
|
22
|
+
return error;
|
|
23
|
+
if (value)
|
|
24
|
+
{
|
|
25
|
+
if (validator.max_length != null)
|
|
26
|
+
if (validator.max_length < value.length)
|
|
27
|
+
return `Max length of ${name} should be ${validator.max_length} characters.`;
|
|
28
|
+
if (validator.min_length != null)
|
|
29
|
+
if (validator.min_length > value.length)
|
|
30
|
+
return `Minlength of ${name} should be ${validator.min_length} characters.`;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
static getErrorNumber(name: string, value: string | null | undefined, validator: ValidationNumberProps): string | null
|
|
35
|
+
{
|
|
36
|
+
let error = this.getError(name, value, validator);
|
|
37
|
+
if (error)
|
|
38
|
+
return error;
|
|
39
|
+
if (value)
|
|
40
|
+
{
|
|
41
|
+
let numValue = parseFloat(value);
|
|
42
|
+
if (isNaN(numValue))
|
|
43
|
+
return `${name} is not a number.`;
|
|
44
|
+
if (validator.max != null)
|
|
45
|
+
if (validator.max < numValue)
|
|
46
|
+
return `Max value of ${name} should be ${validator.max} characters.`;
|
|
47
|
+
if (validator.min != null)
|
|
48
|
+
if (validator.min > numValue)
|
|
49
|
+
return `Min value of ${name} should be ${validator.min} characters.`;
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
static getErrorEmail(name: string, value: string | null | undefined): string | null
|
|
54
|
+
{
|
|
55
|
+
return Validator.getError(name, value, {
|
|
56
|
+
required: true, regex: {
|
|
57
|
+
name: "Email",
|
|
58
|
+
regex: /^[\w]+@([\w]+\.)+\w{2,}$/gm
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -4,49 +4,52 @@ import React from "react";
|
|
|
4
4
|
import Styles from "./NSInputEmail.module.css";
|
|
5
5
|
import IconInputEmail from '../assets/images/icon-input-email.svg';
|
|
6
6
|
import Danger from '../assets/images/danger.svg';
|
|
7
|
+
import { Validator } from "../Validator";
|
|
8
|
+
import { ValidationProps } from "../props/ValidationProps";
|
|
9
|
+
import { ValidationStringProps } from "../props/ValidationStringProps";
|
|
7
10
|
|
|
8
|
-
export interface NSInputEmailProps
|
|
11
|
+
export interface NSInputEmailProps extends ValidationProps, ValidationStringProps
|
|
9
12
|
{
|
|
10
13
|
title: string;
|
|
11
|
-
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
placeholder?: string;
|
|
12
16
|
onChanged?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export interface NSInputEmailState
|
|
16
20
|
{
|
|
17
21
|
value: string;
|
|
18
|
-
error
|
|
22
|
+
error?: string;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
export class NSInputEmail extends React.Component<NSInputEmailProps, NSInputEmailState>
|
|
25
|
+
export class NSInputEmail extends React.Component<NSInputEmailProps, NSInputEmailState>
|
|
26
|
+
{
|
|
22
27
|
constructor(props: NSInputEmailProps)
|
|
23
28
|
{
|
|
24
29
|
super(props);
|
|
25
|
-
this.state = {
|
|
26
|
-
value: props.defaultValue ?? "",
|
|
27
|
-
error: false,
|
|
28
|
-
};
|
|
30
|
+
this.state = { value: props.defaultValue ?? "" };
|
|
29
31
|
this.setValue = this.setValue.bind(this);
|
|
30
32
|
this.getValue = this.getValue.bind(this);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
this.onChanged = this.onChanged.bind(this);
|
|
34
|
+
}
|
|
35
|
+
getError(): string | null
|
|
36
|
+
{
|
|
37
|
+
return Validator.getErrorString(this.props.title, this.state.value, this.props) && Validator.getErrorEmail(this.props.title, this.state.value);
|
|
38
|
+
}
|
|
33
39
|
getValue(): string
|
|
34
40
|
{
|
|
41
|
+
let error = this.getError();
|
|
42
|
+
if (error)
|
|
43
|
+
{
|
|
44
|
+
this.setState({ error });
|
|
45
|
+
throw new Error(error);
|
|
46
|
+
}
|
|
35
47
|
return this.state.value;
|
|
36
|
-
|
|
48
|
+
}
|
|
37
49
|
setValue(value: string): void
|
|
38
50
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!email.test(value))
|
|
42
|
-
{
|
|
43
|
-
this.setState({ error: true, value });
|
|
44
|
-
}
|
|
45
|
-
else
|
|
46
|
-
{
|
|
47
|
-
this.setState({ error: false, value });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
51
|
+
this.setState({ value });
|
|
52
|
+
}
|
|
50
53
|
private onChanged(e: React.ChangeEvent<HTMLInputElement>): void
|
|
51
54
|
{
|
|
52
55
|
this.setValue(e.target.value);
|
|
@@ -62,7 +65,7 @@ export class NSInputEmail extends React.Component<NSInputEmailProps, NSInputEmai
|
|
|
62
65
|
<img
|
|
63
66
|
className={Styles.ns_input_icon}
|
|
64
67
|
src={IconInputEmail}
|
|
65
|
-
alt="
|
|
68
|
+
alt="Email Icon"
|
|
66
69
|
width={24}
|
|
67
70
|
height={24}
|
|
68
71
|
/>
|
|
@@ -70,24 +73,25 @@ export class NSInputEmail extends React.Component<NSInputEmailProps, NSInputEmai
|
|
|
70
73
|
value={this.state.value}
|
|
71
74
|
onChange={this.onChanged}
|
|
72
75
|
type="email"
|
|
73
|
-
className={`${this.state.error
|
|
74
|
-
placeholder=
|
|
76
|
+
className={`${this.state.error ? Styles.ns_input_red : ""} ${Styles.ns_input}`}
|
|
77
|
+
placeholder={this.props.placeholder}
|
|
75
78
|
/>
|
|
76
79
|
</div>
|
|
77
80
|
{
|
|
78
|
-
|
|
81
|
+
// todo make it a component
|
|
82
|
+
this.state.error && (
|
|
79
83
|
<>
|
|
80
|
-
<div className="d-flex justify-content-start align-items-center gap-2 ms-2
|
|
84
|
+
<div className="d-flex justify-content-start align-items-center gap-2 ms-2">
|
|
81
85
|
<img
|
|
82
86
|
className={""}
|
|
83
87
|
src={Danger}
|
|
84
|
-
alt="
|
|
88
|
+
alt="Error Icon"
|
|
85
89
|
width={13}
|
|
86
90
|
height={13}
|
|
87
91
|
/>
|
|
88
|
-
<span className={Styles.ns_input_error}>
|
|
92
|
+
<span className={Styles.ns_input_error}>{this.state.error}</span>
|
|
89
93
|
</div>
|
|
90
|
-
</>)
|
|
94
|
+
</>)
|
|
91
95
|
}
|
|
92
96
|
</>
|
|
93
97
|
);
|
|
@@ -3,20 +3,26 @@
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import Styles from "./NSInputFloat.module.css";
|
|
5
5
|
import IconInputFloat from '../assets/images/icon-input-float.svg';
|
|
6
|
+
import { BaseComponentProps } from "../props/BaseComponentProps";
|
|
7
|
+
import { ValidationProps } from "../props/ValidationProps";
|
|
8
|
+
import { ValidationNumberProps } from "../props/ValidationNumberProps";
|
|
9
|
+
import { Validator } from "../Validator";
|
|
6
10
|
|
|
7
|
-
export interface NSInputFloatProps
|
|
11
|
+
export interface NSInputFloatProps extends BaseComponentProps, ValidationProps, ValidationNumberProps
|
|
8
12
|
{
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
title: string;
|
|
14
|
+
defaultValue?: string;
|
|
11
15
|
onChanged?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
export interface NSInputFloatState
|
|
15
19
|
{
|
|
16
20
|
value: string;
|
|
21
|
+
error?: string;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
export class NSInputFloat extends React.Component<NSInputFloatProps, NSInputFloatState>
|
|
24
|
+
export class NSInputFloat extends React.Component<NSInputFloatProps, NSInputFloatState>
|
|
25
|
+
{
|
|
20
26
|
constructor(props: NSInputFloatProps)
|
|
21
27
|
{
|
|
22
28
|
super(props);
|
|
@@ -27,15 +33,24 @@ export class NSInputFloat extends React.Component<NSInputFloatProps, NSInputFloa
|
|
|
27
33
|
this.getValue = this.getValue.bind(this);
|
|
28
34
|
this.onChanged = this.onChanged.bind(this);
|
|
29
35
|
}
|
|
36
|
+
getError(): string | null
|
|
37
|
+
{
|
|
38
|
+
return Validator.getErrorNumber(this.props.title, this.state.value, this.props);
|
|
39
|
+
}
|
|
30
40
|
getValue(): string
|
|
31
41
|
{
|
|
42
|
+
let error = this.getError();
|
|
43
|
+
if (error)
|
|
44
|
+
{
|
|
45
|
+
this.setState({ error });
|
|
46
|
+
throw new Error(error);
|
|
47
|
+
}
|
|
32
48
|
return this.state.value;
|
|
33
|
-
|
|
49
|
+
}
|
|
34
50
|
setValue(value: string): void
|
|
35
51
|
{
|
|
36
52
|
this.setState({ value });
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
}
|
|
39
54
|
private onChanged(e: React.ChangeEvent<HTMLInputElement>): void
|
|
40
55
|
{
|
|
41
56
|
this.setValue(e.target.value);
|
|
@@ -45,8 +60,13 @@ export class NSInputFloat extends React.Component<NSInputFloatProps, NSInputFloa
|
|
|
45
60
|
override render()
|
|
46
61
|
{
|
|
47
62
|
return (
|
|
48
|
-
<div className={`${Styles.ns_input_parent} p-2`}>
|
|
49
|
-
<span className={Styles.ns_input_title}>
|
|
63
|
+
<div className={`${Styles.ns_input_parent} p-2 ${this.props.classList?.join(" ")}`} style={this.props.style}>
|
|
64
|
+
<span className={Styles.ns_input_title}>
|
|
65
|
+
{
|
|
66
|
+
this.props.required && <span>*</span>
|
|
67
|
+
}
|
|
68
|
+
{this.props.title}
|
|
69
|
+
</span>
|
|
50
70
|
<img
|
|
51
71
|
className={Styles.ns_input_icon}
|
|
52
72
|
src={IconInputFloat}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
|
|
5
1
|
export interface NSSpaceProps
|
|
6
2
|
{
|
|
7
3
|
size: NSSpaceSizeType;
|
|
@@ -21,32 +17,9 @@ export enum NSSpaceSizeType
|
|
|
21
17
|
XXXLARGE = "128px",
|
|
22
18
|
}
|
|
23
19
|
|
|
24
|
-
export
|
|
25
|
-
{
|
|
26
|
-
size: NSSpaceSizeType;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class NSSpace extends React.Component<NSSpaceProps, NSSpaceState>
|
|
20
|
+
export function NSSpace(props: NSSpaceProps)
|
|
30
21
|
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.state = { size: props.size };
|
|
35
|
-
this.setValue = this.setValue.bind(this);
|
|
36
|
-
this.getValue = this.getValue.bind(this);
|
|
37
|
-
}
|
|
38
|
-
setValue(size: NSSpaceSizeType): void
|
|
39
|
-
{
|
|
40
|
-
this.setState({ size });
|
|
41
|
-
}
|
|
42
|
-
getValue(): NSSpaceSizeType
|
|
43
|
-
{
|
|
44
|
-
return this.state.size;
|
|
45
|
-
}
|
|
46
|
-
override render()
|
|
47
|
-
{
|
|
48
|
-
return (
|
|
49
|
-
<hr style={{ width: "100%", height: this.state.size, margin: "0px", padding: "0px", background: "transparent", color: "transparent", border: 0 }} />
|
|
50
|
-
);
|
|
51
|
-
}
|
|
22
|
+
return (
|
|
23
|
+
<hr style={{ width: "100%", height: props.size, margin: "0px", padding: "0px", background: "transparent", color: "transparent", border: 0 }} />
|
|
24
|
+
);
|
|
52
25
|
}
|