namirasoft-site-react 1.3.113 → 1.3.115
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/App.js +4 -3
- package/dist/App.js.map +1 -1
- package/dist/components/{NSInputDate.d.ts → NSBoxDate.d.ts} +4 -4
- package/dist/components/{NSInputDate.js → NSBoxDate.js} +5 -5
- package/dist/components/NSBoxDate.js.map +1 -0
- package/dist/components/NSBoxDateTime.d.ts +21 -0
- package/dist/components/NSBoxDateTime.js +41 -0
- package/dist/components/NSBoxDateTime.js.map +1 -0
- package/dist/components/{NSInputInteger.d.ts → NSBoxDouble.d.ts} +5 -5
- package/dist/components/{NSInputPrice.js → NSBoxDouble.js} +8 -8
- package/dist/components/NSBoxDouble.js.map +1 -0
- package/dist/components/{NSInputDuration.d.ts → NSBoxDuration.d.ts} +4 -4
- package/dist/components/{NSInputDuration.js → NSBoxDuration.js} +5 -5
- package/dist/components/NSBoxDuration.js.map +1 -0
- package/dist/components/{NSInputTime.d.ts → NSBoxEmail.d.ts} +5 -5
- package/dist/components/{NSInputEmail.js → NSBoxEmail.js} +5 -5
- package/dist/components/NSBoxEmail.js.map +1 -0
- package/dist/components/NSBoxEntity.d.ts +12 -0
- package/dist/components/NSBoxEntity.js +10 -0
- package/dist/components/NSBoxEntity.js.map +1 -0
- package/dist/components/NSBoxEnum.d.ts +7 -0
- package/dist/components/NSBoxEnum.js +38 -0
- package/dist/components/NSBoxEnum.js.map +1 -0
- package/dist/components/NSBoxErrorNotifier.d.ts +5 -0
- package/dist/components/{NSInputErrorNotifier.js → NSBoxErrorNotifier.js} +3 -3
- package/dist/components/NSBoxErrorNotifier.js.map +1 -0
- package/dist/components/{NSInputIP.d.ts → NSBoxIPV4.d.ts} +4 -4
- package/dist/components/{NSInputIP.js → NSBoxIPV4.js} +6 -5
- package/dist/components/NSBoxIPV4.js.map +1 -0
- package/dist/components/{NSInputEmail.d.ts → NSBoxIPV6.d.ts} +5 -5
- package/dist/components/NSBoxIPV6.js +44 -0
- package/dist/components/NSBoxIPV6.js.map +1 -0
- package/dist/components/{NSInputFloat.d.ts → NSBoxInteger.d.ts} +5 -5
- package/dist/components/{NSInputInteger.js → NSBoxInteger.js} +5 -5
- package/dist/components/NSBoxInteger.js.map +1 -0
- package/dist/components/{NSInputString.d.ts → NSBoxPassword.d.ts} +4 -4
- package/dist/components/{NSInputPassword.js → NSBoxPassword.js} +5 -5
- package/dist/components/NSBoxPassword.js.map +1 -0
- package/dist/components/{NSInputPhone.d.ts → NSBoxPhone.d.ts} +4 -4
- package/dist/components/{NSInputPhone.js → NSBoxPhone.js} +5 -5
- package/dist/components/NSBoxPhone.js.map +1 -0
- package/dist/components/{NSInputPrice.d.ts → NSBoxPrice.d.ts} +5 -5
- package/dist/components/{NSInputFloat.js → NSBoxPrice.js} +5 -5
- package/dist/components/NSBoxPrice.js.map +1 -0
- package/dist/components/{NSInputSearch.d.ts → NSBoxSearch.d.ts} +4 -4
- package/dist/components/{NSInputSearch.js → NSBoxSearch.js} +5 -5
- package/dist/components/NSBoxSearch.js.map +1 -0
- package/dist/components/{NSInputText.d.ts → NSBoxString.d.ts} +4 -4
- package/dist/components/{NSInputString.js → NSBoxString.js} +5 -5
- package/dist/components/NSBoxString.js.map +1 -0
- package/dist/components/NSBoxText.d.ts +22 -0
- package/dist/components/{NSInputText.js → NSBoxText.js} +5 -5
- package/dist/components/NSBoxText.js.map +1 -0
- package/dist/components/NSBoxTime.d.ts +22 -0
- package/dist/components/{NSInputTime.js → NSBoxTime.js} +5 -5
- package/dist/components/NSBoxTime.js.map +1 -0
- package/dist/components/NSSelectBox.d.ts +1 -0
- package/dist/components/NSSelectBox.js +3 -2
- package/dist/components/NSSelectBox.js.map +1 -1
- package/dist/components/NSTable.js +2 -2
- package/dist/components/NSTable.js.map +1 -1
- package/dist/main.d.ts +15 -14
- package/dist/main.js +15 -14
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
- package/src/App.tsx +12 -1
- package/src/components/NSBoxDate.tsx +81 -0
- package/src/components/NSBoxDateTime.tsx +81 -0
- package/src/components/NSBoxDouble.tsx +92 -0
- package/src/components/NSBoxDuration.tsx +91 -0
- package/src/components/NSBoxEmail.tsx +90 -0
- package/src/components/NSBoxEntity.tsx +29 -0
- package/src/components/NSBoxEnum.tsx +54 -0
- package/src/components/NSBoxErrorNotifier.tsx +28 -0
- package/src/components/NSBoxIPV4.tsx +96 -0
- package/src/components/NSBoxIPV6.tsx +93 -0
- package/src/components/NSBoxInteger.tsx +89 -0
- package/src/components/NSBoxPassword.tsx +89 -0
- package/src/components/NSBoxPhone.tsx +83 -0
- package/src/components/NSBoxPrice.tsx +91 -0
- package/src/components/{NSInputSearch.tsx → NSBoxSearch.tsx} +9 -9
- package/src/components/NSBoxString.tsx +89 -0
- package/src/components/NSBoxText.tsx +89 -0
- package/src/components/NSBoxTime.tsx +91 -0
- package/src/components/NSSelectBox.tsx +94 -93
- package/src/components/NSTable.tsx +130 -130
- package/src/main.ts +15 -14
- package/dist/components/NSInputDate.js.map +0 -1
- package/dist/components/NSInputDuration.js.map +0 -1
- package/dist/components/NSInputEmail.js.map +0 -1
- package/dist/components/NSInputErrorNotifier.d.ts +0 -5
- package/dist/components/NSInputErrorNotifier.js.map +0 -1
- package/dist/components/NSInputFloat.js.map +0 -1
- package/dist/components/NSInputIP.js.map +0 -1
- package/dist/components/NSInputInteger.js.map +0 -1
- package/dist/components/NSInputPassword.d.ts +0 -22
- package/dist/components/NSInputPassword.js.map +0 -1
- package/dist/components/NSInputPhone.js.map +0 -1
- package/dist/components/NSInputPrice.js.map +0 -1
- package/dist/components/NSInputSearch.js.map +0 -1
- package/dist/components/NSInputString.js.map +0 -1
- package/dist/components/NSInputText.js.map +0 -1
- package/dist/components/NSInputTime.js.map +0 -1
- package/src/components/NSInputDate.tsx +0 -81
- package/src/components/NSInputDuration.tsx +0 -91
- package/src/components/NSInputEmail.tsx +0 -90
- package/src/components/NSInputErrorNotifier.tsx +0 -28
- package/src/components/NSInputFloat.tsx +0 -89
- package/src/components/NSInputIP.tsx +0 -90
- package/src/components/NSInputInteger.tsx +0 -89
- package/src/components/NSInputPassword.tsx +0 -89
- package/src/components/NSInputPhone.tsx +0 -83
- package/src/components/NSInputPrice.tsx +0 -90
- package/src/components/NSInputString.tsx +0 -89
- package/src/components/NSInputText.tsx +0 -89
- package/src/components/NSInputTime.tsx +0 -91
- /package/dist/components/{NSInput.module.css → NSBox.module.css} +0 -0
- /package/dist/components/{NSInputDate.module.css → NSBoxDate.module.css} +0 -0
- /package/dist/components/{NSInputErrorNotifier.module.css → NSBoxErrorNotifier.module.css} +0 -0
- /package/src/components/{NSInput.module.css → NSBox.module.css} +0 -0
- /package/src/components/{NSInputDate.module.css → NSBoxDate.module.css} +0 -0
- /package/src/components/{NSInputErrorNotifier.module.css → NSBoxErrorNotifier.module.css} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import Styles from "./NSBox.module.css";
|
|
5
|
+
import IconInputText from '../assets/images/icon-input-text.svg';
|
|
6
|
+
import { IBaseComponentProps } from "../props/IBaseComponentProps";
|
|
7
|
+
import { IValidationProps } from "../props/IValidationProps";
|
|
8
|
+
import { IValidationStringProps } from "../props/IValidationStringProps";
|
|
9
|
+
import { Validator } from "../Validator";
|
|
10
|
+
import { NSBoxErrorNotifier } from "./NSBoxErrorNotifier";
|
|
11
|
+
|
|
12
|
+
export interface INSBoxTextProps extends IBaseComponentProps, IValidationProps, IValidationStringProps
|
|
13
|
+
{
|
|
14
|
+
title: string;
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
onChanged?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface INSBoxTextState
|
|
21
|
+
{
|
|
22
|
+
value: string;
|
|
23
|
+
error?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class NSBoxText extends React.Component<INSBoxTextProps, INSBoxTextState>
|
|
27
|
+
{
|
|
28
|
+
constructor(props: INSBoxTextProps)
|
|
29
|
+
{
|
|
30
|
+
super(props);
|
|
31
|
+
this.state = { value: props.defaultValue ?? "" };
|
|
32
|
+
this.getValue = this.getValue.bind(this);
|
|
33
|
+
this.setValue = this.setValue.bind(this);
|
|
34
|
+
this.onChanged = this.onChanged.bind(this);
|
|
35
|
+
}
|
|
36
|
+
getError(): string | null
|
|
37
|
+
{
|
|
38
|
+
return (
|
|
39
|
+
Validator.getError(this.props.title, this.state.value, this.props) &&
|
|
40
|
+
Validator.getErrorString(this.props.title, this.state.value, this.props)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
getValue(): string
|
|
44
|
+
{
|
|
45
|
+
let error = this.getError();
|
|
46
|
+
if (error)
|
|
47
|
+
{
|
|
48
|
+
this.setState({ error });
|
|
49
|
+
throw new Error(error);
|
|
50
|
+
}
|
|
51
|
+
return this.state.value;
|
|
52
|
+
}
|
|
53
|
+
setValue(value: string): void
|
|
54
|
+
{
|
|
55
|
+
this.setState({ value });
|
|
56
|
+
}
|
|
57
|
+
private onChanged(e: React.ChangeEvent<HTMLInputElement>): void
|
|
58
|
+
{
|
|
59
|
+
this.setValue(e.target.value);
|
|
60
|
+
if (this.props.onChanged)
|
|
61
|
+
this.props.onChanged(e);
|
|
62
|
+
}
|
|
63
|
+
override render()
|
|
64
|
+
{
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<div className={`${Styles.ns_input_parent} ${this.props.classList?.join(" ")}`} style={this.props.style}>
|
|
68
|
+
<span className={Styles.ns_input_title}> {this.props.required && <span style={{ color: "red" }} >*</span>} {this.props.title} </span>
|
|
69
|
+
<img
|
|
70
|
+
className={Styles.ns_input_icon}
|
|
71
|
+
src={IconInputText}
|
|
72
|
+
alt="Text Icon"
|
|
73
|
+
width={24}
|
|
74
|
+
height={24}
|
|
75
|
+
/>
|
|
76
|
+
<input
|
|
77
|
+
id={this.props.id}
|
|
78
|
+
value={this.state.value}
|
|
79
|
+
onChange={this.onChanged}
|
|
80
|
+
type="text"
|
|
81
|
+
className={Styles.ns_input}
|
|
82
|
+
placeholder={this.props.placeholder}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
<NSBoxErrorNotifier error={this.state.error} />
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import Styles from "./NSBox.module.css";
|
|
5
|
+
import IconInputTime from '../assets/images/icon-input-time.svg';
|
|
6
|
+
import { IBaseComponentProps } from "../props/IBaseComponentProps";
|
|
7
|
+
import { IValidationProps } from "../props/IValidationProps";
|
|
8
|
+
import { IValidationStringProps } from "../props/IValidationStringProps";
|
|
9
|
+
import { Validator } from "../Validator";
|
|
10
|
+
import { NSBoxErrorNotifier } from "./NSBoxErrorNotifier";
|
|
11
|
+
|
|
12
|
+
export interface INSBoxTimeProps extends IBaseComponentProps, IValidationProps, IValidationStringProps
|
|
13
|
+
{
|
|
14
|
+
title: string;
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
onChanged?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface INSBoxTimeState
|
|
21
|
+
{
|
|
22
|
+
value: string;
|
|
23
|
+
error?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class NSBoxTime extends React.Component<INSBoxTimeProps, INSBoxTimeState>
|
|
27
|
+
{
|
|
28
|
+
constructor(props: INSBoxTimeProps)
|
|
29
|
+
{
|
|
30
|
+
super(props);
|
|
31
|
+
this.state = { value: props.defaultValue ?? "" };
|
|
32
|
+
this.getValue = this.getValue.bind(this);
|
|
33
|
+
this.setValue = this.setValue.bind(this);
|
|
34
|
+
this.onChanged = this.onChanged.bind(this);
|
|
35
|
+
}
|
|
36
|
+
getError(): string | null
|
|
37
|
+
{
|
|
38
|
+
return (
|
|
39
|
+
Validator.getError(this.props.title, this.state.value, this.props) &&
|
|
40
|
+
Validator.getErrorString(this.props.title, this.state.value, this.props) &&
|
|
41
|
+
Validator.getErrorTime(this.props.title, this.state.value)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
getValue(): string
|
|
45
|
+
{
|
|
46
|
+
let error = this.getError();
|
|
47
|
+
if (error)
|
|
48
|
+
{
|
|
49
|
+
this.setState({ error });
|
|
50
|
+
throw new Error(error);
|
|
51
|
+
}
|
|
52
|
+
return this.state.value;
|
|
53
|
+
}
|
|
54
|
+
setValue(value: string): void
|
|
55
|
+
{
|
|
56
|
+
this.setState({ value });
|
|
57
|
+
}
|
|
58
|
+
private onChanged(e: React.ChangeEvent<HTMLInputElement>): void
|
|
59
|
+
{
|
|
60
|
+
this.setValue(e.target.value);
|
|
61
|
+
if (this.props.onChanged)
|
|
62
|
+
this.props.onChanged(e);
|
|
63
|
+
}
|
|
64
|
+
override render()
|
|
65
|
+
{
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<div className={`${Styles.ns_input_parent} p-2 ${this.props.classList?.join(" ")}`} style={this.props.style}>
|
|
69
|
+
<span className={Styles.ns_input_title}> {this.props.required && <span style={{ color: "red" }} >*</span>} {this.props.title} </span>
|
|
70
|
+
<img
|
|
71
|
+
className={Styles.ns_input_icon}
|
|
72
|
+
src={IconInputTime}
|
|
73
|
+
alt="Time Icon"
|
|
74
|
+
width={24}
|
|
75
|
+
height={24}
|
|
76
|
+
/>
|
|
77
|
+
<input
|
|
78
|
+
id={this.props.id}
|
|
79
|
+
value={this.state.value}
|
|
80
|
+
onChange={this.onChanged}
|
|
81
|
+
type="time"
|
|
82
|
+
className={Styles.ns_input}
|
|
83
|
+
placeholder={this.props.placeholder}
|
|
84
|
+
step="2"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
<NSBoxErrorNotifier error={this.state.error} />
|
|
88
|
+
</>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -7,108 +7,109 @@ import IconSelectBox from '../assets/images/icon-select-box.svg';
|
|
|
7
7
|
import { IBaseComponentProps } from "../props/IBaseComponentProps";
|
|
8
8
|
import { IValidationProps } from "../props/IValidationProps";
|
|
9
9
|
import { Validator } from "../Validator";
|
|
10
|
-
import {
|
|
10
|
+
import { NSBoxErrorNotifier } from "./NSBoxErrorNotifier";
|
|
11
11
|
|
|
12
12
|
export interface INSSelectBoxProps extends IBaseComponentProps, IValidationProps
|
|
13
13
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
title: string;
|
|
15
|
+
options: SelectProps['options'];
|
|
16
|
+
multiple: boolean;
|
|
17
|
+
placeHolder?: string;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export interface NSSelectBoxState
|
|
20
21
|
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
value: string | null;
|
|
23
|
+
values: string[];
|
|
24
|
+
error?: string;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export class NSSelectBox extends React.Component<INSSelectBoxProps, NSSelectBoxState>
|
|
27
28
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
29
|
+
constructor(props: INSSelectBoxProps)
|
|
30
|
+
{
|
|
31
|
+
super(props);
|
|
32
|
+
this.state = {
|
|
33
|
+
value: null,
|
|
34
|
+
values: [],
|
|
35
|
+
};
|
|
36
|
+
this.getValues = this.getValues.bind(this);
|
|
37
|
+
this.setValues = this.setValues.bind(this);
|
|
38
|
+
this.setValue = this.setValue.bind(this);
|
|
39
|
+
this.getValue = this.getValue.bind(this);
|
|
40
|
+
this.handleChange = this.handleChange.bind(this);
|
|
41
|
+
}
|
|
42
|
+
getError(value: string): string | null
|
|
43
|
+
{
|
|
44
|
+
return (
|
|
45
|
+
Validator.getError(this.props.title, value, this.props)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
getValue(): string | null
|
|
49
|
+
{
|
|
50
|
+
let error = this.getError(this.state.value || "");
|
|
51
|
+
if (error)
|
|
52
|
+
{
|
|
53
|
+
this.setState({ error });
|
|
54
|
+
throw new Error(error);
|
|
55
|
+
}
|
|
56
|
+
return this.state.value;
|
|
57
|
+
}
|
|
58
|
+
getValues(): string[]
|
|
59
|
+
{
|
|
60
|
+
this.state.values.forEach(value =>
|
|
61
|
+
{
|
|
62
|
+
let error = this.getError(value || "");
|
|
63
|
+
if (error)
|
|
64
|
+
{
|
|
65
|
+
this.setState({ error });
|
|
66
|
+
throw new Error(error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return this.state.values;
|
|
70
|
+
}
|
|
71
|
+
setValue(value: string | null): void
|
|
72
|
+
{
|
|
73
|
+
this.setState({ value });
|
|
74
|
+
}
|
|
75
|
+
setValues(values: string[]): void
|
|
76
|
+
{
|
|
77
|
+
this.setState({ values });
|
|
78
|
+
}
|
|
79
|
+
handleChange(value: string | null | string[]): void
|
|
80
|
+
{
|
|
81
|
+
if (this.props.multiple)
|
|
82
|
+
{
|
|
83
|
+
this.setValues(value as string[]);
|
|
84
|
+
} else
|
|
85
|
+
{
|
|
86
|
+
this.setValue(value as string | null);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
override render()
|
|
90
|
+
{
|
|
91
|
+
return (
|
|
92
|
+
<>
|
|
93
|
+
<div className={`${Styles.ns_input_parent}`}>
|
|
94
|
+
<span className={Styles.ns_input_title}> {this.props.required && <span style={{ color: "red" }} >*</span>} {this.props.title} </span>
|
|
95
|
+
<Select
|
|
96
|
+
mode={this.props.multiple ? "multiple" : undefined}
|
|
97
|
+
style={{ width: '100%' }}
|
|
98
|
+
className={Styles.ns_input_select}
|
|
99
|
+
placeholder={this.props.placeHolder ?? "Combo Box"}
|
|
100
|
+
onChange={this.handleChange}
|
|
101
|
+
optionLabelProp="label"
|
|
102
|
+
options={this.props.options}
|
|
103
|
+
optionRender={(option) => (
|
|
104
|
+
<Space className={Styles.ns_input_select_option}>
|
|
105
|
+
{option.data.desc}
|
|
106
|
+
</Space>
|
|
107
|
+
)}
|
|
108
|
+
suffixIcon={<img src={IconSelectBox} alt="SelectBox Icon" />}
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
<NSBoxErrorNotifier error={this.state.error} />
|
|
112
|
+
</>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
114
115
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import NSButton from './NSButton';
|
|
4
|
-
import {
|
|
4
|
+
import { NSBoxSearch } from './NSBoxSearch';
|
|
5
5
|
import { NSPagination } from './NSPagination';
|
|
6
6
|
import { NSSpace, NSSpaceSizeType } from './NSSpace';
|
|
7
7
|
import Styles from './NSTable.module.css';
|
|
@@ -12,142 +12,142 @@ import { NSModal } from './NSModal';
|
|
|
12
12
|
|
|
13
13
|
export interface INSTableProps<RowType> extends IBaseComponentProps
|
|
14
14
|
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
columns: { [key: string]: string };
|
|
16
|
+
rows: RowType[];
|
|
17
|
+
getRowKey: (row: RowType, rowIndex: number) => string;
|
|
18
|
+
getColumnAttributes?: (column: string, columnIndex: number) => { [key: string]: string };
|
|
19
|
+
getCell?: (row: RowType, column: string, rowIndex: number, columnIndex: number) => any;
|
|
20
|
+
onRowClick?: (e: React.MouseEvent<HTMLTableRowElement, MouseEvent>, row: RowType, rowIndex: number) => void;
|
|
21
|
+
onCellClick?: (e: React.MouseEvent<HTMLTableDataCellElement, MouseEvent>, row: RowType, column: string, rowIndex: number, columnIndex: number) => boolean | undefined;
|
|
22
|
+
onChanged?: () => void
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface NSTableState<RowType>
|
|
26
26
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
columns: { [key: string]: string };
|
|
28
|
+
rows: RowType[];
|
|
29
|
+
title?: string
|
|
30
|
+
model: {
|
|
31
|
+
show: boolean;
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export class NSTable<RowType> extends Component<INSTableProps<RowType>, NSTableState<RowType>>
|
|
37
37
|
{
|
|
38
|
-
|
|
38
|
+
private search?: React.RefObject<NSBoxSearch>;
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
40
|
+
constructor(props: INSTableProps<RowType>)
|
|
41
|
+
{
|
|
42
|
+
super(props);
|
|
43
|
+
this.state = { columns: props.columns, rows: props.rows, model: { show: false } };
|
|
44
|
+
this.search = React.createRef<NSBoxSearch>();
|
|
45
|
+
}
|
|
46
|
+
setColumns(columns: { [key: string]: string })
|
|
47
|
+
{
|
|
48
|
+
this.setState({ columns });
|
|
49
|
+
}
|
|
50
|
+
setRows(rows: RowType[])
|
|
51
|
+
{
|
|
52
|
+
this.setState({ rows });
|
|
53
|
+
}
|
|
54
|
+
getSearchValue(): string
|
|
55
|
+
{
|
|
56
|
+
return this.search?.current?.getValue() ?? "";
|
|
57
|
+
}
|
|
58
|
+
showModal(description: string)
|
|
59
|
+
{
|
|
60
|
+
this.setState({ model: { show: true, description } });
|
|
61
|
+
}
|
|
62
|
+
hideModal()
|
|
63
|
+
{
|
|
64
|
+
this.setState({ model: { show: false } });
|
|
65
|
+
}
|
|
66
|
+
override render()
|
|
67
|
+
{
|
|
68
|
+
let modalTitle = (e: any) =>
|
|
69
|
+
{
|
|
70
|
+
this.setState({ title: e.currentTarget.innerText });
|
|
71
|
+
}
|
|
72
|
+
let column_keys = Object.keys(this.state.columns);
|
|
73
|
+
let getColumnAttributes = (column: string, columnIndex: number) =>
|
|
74
|
+
{
|
|
75
|
+
if (this.props.getColumnAttributes)
|
|
76
|
+
return this.props.getColumnAttributes(column, columnIndex);
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
let getCell = (row: RowType, column: string, rowIndex: number, columnIndex: number) =>
|
|
80
|
+
{
|
|
81
|
+
if (this.props.getCell)
|
|
82
|
+
return this.props.getCell(row, column, rowIndex, columnIndex);
|
|
83
|
+
return (row as any)[column];
|
|
84
|
+
}
|
|
85
|
+
let onRowClick = (e: React.MouseEvent<HTMLTableRowElement, MouseEvent>, row: RowType, rowIndex: number) =>
|
|
86
|
+
{
|
|
87
|
+
if (this.props.onRowClick)
|
|
88
|
+
this.props.onRowClick(e, row, rowIndex);
|
|
89
|
+
};
|
|
90
|
+
let onCellClick = (e: React.MouseEvent<HTMLTableDataCellElement, MouseEvent>, row: RowType, column: string, rowIndex: number, columnIndex: number) =>
|
|
91
|
+
{
|
|
92
|
+
let overided = false;
|
|
93
|
+
if (this.props.onCellClick)
|
|
94
|
+
{
|
|
95
|
+
let res = this.props.onCellClick(e, row, column, rowIndex, rowIndex);
|
|
96
|
+
if (res === undefined)
|
|
97
|
+
overided = true;
|
|
98
|
+
else
|
|
99
|
+
overided = res;
|
|
100
|
+
}
|
|
101
|
+
if (!overided)
|
|
102
|
+
this.showModal(getCell(row, column, rowIndex, columnIndex));
|
|
103
|
+
};
|
|
104
|
+
return (
|
|
105
|
+
<div id={this.props.id}
|
|
106
|
+
className={`${Styles.ns_project_list_container} ${this.props.classList?.join(" ")}`}
|
|
107
|
+
style={this.props.style}>
|
|
108
|
+
<NSBoxSearch title="Search" required={false} onChanged={this.props.onChanged} ref={this.search} />
|
|
109
|
+
<NSSpace size={NSSpaceSizeType.SMALL} />
|
|
110
|
+
<table className={Styles.ns_table} >
|
|
111
|
+
<thead className={Styles.ns_thead}>
|
|
112
|
+
<tr>
|
|
113
|
+
{column_keys.map(column_key => <th key={column_key} scope="col"
|
|
114
|
+
onClick={(e) => modalTitle(e)}>
|
|
115
|
+
{this.state.columns[column_key]}
|
|
116
|
+
</th>)}
|
|
117
|
+
</tr>
|
|
118
|
+
</thead>
|
|
119
|
+
<tbody className={Styles.ns_tbody}>
|
|
120
|
+
{
|
|
121
|
+
this.state.rows.map((row, rowIndex) =>
|
|
122
|
+
<tr key={this.props.getRowKey(row, rowIndex)} onClick={(e) => { onRowClick(e, row, rowIndex); }}>
|
|
123
|
+
{
|
|
124
|
+
column_keys.map((column, columnIndex) => (
|
|
125
|
+
<td {...getColumnAttributes(column, columnIndex)} data-label={`${this.state.columns[column]} : `} onClick={(e) => { onCellClick(e, row, column, rowIndex, columnIndex); }}>
|
|
126
|
+
{getCell(row, column, rowIndex, columnIndex)}
|
|
127
|
+
</td>
|
|
128
|
+
))
|
|
129
|
+
}
|
|
130
|
+
</tr>)
|
|
131
|
+
}
|
|
132
|
+
</tbody >
|
|
133
|
+
</table>
|
|
134
|
+
<NSSpace size={NSSpaceSizeType.MICRO} />
|
|
135
|
+
<section className={Styles.ns_pagination_button}>
|
|
136
|
+
<NSPagination size={50} page={5} />
|
|
137
|
+
<NSSpace size={NSSpaceSizeType.SMALL} />
|
|
138
|
+
<div className={Styles.ns_button}>
|
|
139
|
+
<NSButton title='Export' icon={{ src: "/assets/images/export-vector.png" }} onClick={() => { }} style={{ border: '1px solid rgba(255, 148, 50, 1)', width: "128px" }} />
|
|
140
|
+
<NSButton title='Refresh' icon={{ src: "/assets/images/refresh-vector.png" }} onClick={() => { }} style={{ border: '1px solid rgba(3, 119, 255, 1)', width: "128px" }} />
|
|
141
|
+
</div>
|
|
142
|
+
</section>
|
|
143
|
+
<NSSpace size={NSSpaceSizeType.SMALL} />
|
|
144
|
+
<NSModal
|
|
145
|
+
show={this.state.model.show}
|
|
146
|
+
description={this.state.model.description}
|
|
147
|
+
onClose={() => { this.hideModal(); }}
|
|
148
|
+
title={this.state.title}
|
|
149
|
+
/>
|
|
150
|
+
</div >
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
153
|
}
|