namirasoft-site-react 1.3.395 → 1.3.397
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 +5 -7
- package/dist/App.js.map +1 -1
- package/dist/components/NSBoxBoolean.d.ts +1 -1
- package/dist/components/NSBoxBoolean.js +9 -7
- package/dist/components/NSBoxBoolean.js.map +1 -1
- package/dist/components/NSBoxCombo.d.ts +1 -1
- package/dist/components/NSBoxCombo.js +7 -5
- package/dist/components/NSBoxCombo.js.map +1 -1
- package/dist/components/NSBoxDate.d.ts +1 -1
- package/dist/components/NSBoxDate.js +7 -5
- package/dist/components/NSBoxDate.js.map +1 -1
- package/dist/components/NSBoxDateTime.d.ts +1 -1
- package/dist/components/NSBoxDateTime.js +7 -5
- package/dist/components/NSBoxDateTime.js.map +1 -1
- package/dist/components/NSBoxDouble.d.ts +1 -1
- package/dist/components/NSBoxDouble.js +7 -5
- package/dist/components/NSBoxDouble.js.map +1 -1
- package/dist/components/NSBoxDuration.d.ts +1 -1
- package/dist/components/NSBoxDuration.js +7 -5
- package/dist/components/NSBoxDuration.js.map +1 -1
- package/dist/components/NSBoxEmail.d.ts +1 -1
- package/dist/components/NSBoxEmail.js +7 -5
- package/dist/components/NSBoxEmail.js.map +1 -1
- package/dist/components/NSBoxEntity.d.ts +1 -1
- package/dist/components/NSBoxEntity.js +7 -5
- package/dist/components/NSBoxEntity.js.map +1 -1
- package/dist/components/NSBoxIPV4.d.ts +1 -1
- package/dist/components/NSBoxIPV4.js +7 -5
- package/dist/components/NSBoxIPV4.js.map +1 -1
- package/dist/components/NSBoxIPV6.d.ts +1 -1
- package/dist/components/NSBoxIPV6.js +7 -5
- package/dist/components/NSBoxIPV6.js.map +1 -1
- package/dist/components/NSBoxInteger.d.ts +1 -1
- package/dist/components/NSBoxInteger.js +7 -5
- package/dist/components/NSBoxInteger.js.map +1 -1
- package/dist/components/NSBoxPassword.d.ts +1 -1
- package/dist/components/NSBoxPassword.js +7 -5
- package/dist/components/NSBoxPassword.js.map +1 -1
- package/dist/components/NSBoxPhone.d.ts +1 -1
- package/dist/components/NSBoxPhone.js +7 -5
- package/dist/components/NSBoxPhone.js.map +1 -1
- package/dist/components/NSBoxPrice.d.ts +1 -1
- package/dist/components/NSBoxPrice.js +7 -5
- package/dist/components/NSBoxPrice.js.map +1 -1
- package/dist/components/NSBoxSearch.d.ts +1 -1
- package/dist/components/NSBoxSearch.js +7 -5
- package/dist/components/NSBoxSearch.js.map +1 -1
- package/dist/components/NSBoxString.d.ts +1 -1
- package/dist/components/NSBoxString.js +7 -5
- package/dist/components/NSBoxString.js.map +1 -1
- package/dist/components/NSBoxTextArea.d.ts +1 -1
- package/dist/components/NSBoxTextArea.js +7 -5
- package/dist/components/NSBoxTextArea.js.map +1 -1
- package/dist/components/NSBoxTime.d.ts +1 -1
- package/dist/components/NSBoxTime.js +7 -5
- package/dist/components/NSBoxTime.js.map +1 -1
- package/dist/components/NSRadioButton.d.ts +1 -1
- package/dist/components/NSRadioButton.js +7 -5
- package/dist/components/NSRadioButton.js.map +1 -1
- package/dist/components/NSRepeater.d.ts +2 -2
- package/dist/components/NSRepeater.js +4 -4
- package/dist/components/NSRepeater.js.map +1 -1
- package/dist/components/NSTag.d.ts +19 -1
- package/dist/components/NSTag.js +41 -7
- package/dist/components/NSTag.js.map +1 -1
- package/package.json +1 -1
- package/src/App.tsx +11 -9
- package/src/components/NSBoxBoolean.tsx +10 -7
- package/src/components/NSBoxCombo.tsx +8 -5
- package/src/components/NSBoxDate.tsx +8 -5
- package/src/components/NSBoxDateTime.tsx +8 -5
- package/src/components/NSBoxDouble.tsx +8 -5
- package/src/components/NSBoxDuration.tsx +8 -5
- package/src/components/NSBoxEmail.tsx +8 -5
- package/src/components/NSBoxEntity.tsx +8 -5
- package/src/components/NSBoxIPV4.tsx +8 -5
- package/src/components/NSBoxIPV6.tsx +8 -5
- package/src/components/NSBoxInteger.tsx +8 -5
- package/src/components/NSBoxPassword.tsx +8 -5
- package/src/components/NSBoxPhone.tsx +8 -5
- package/src/components/NSBoxPrice.tsx +8 -5
- package/src/components/NSBoxSearch.tsx +8 -5
- package/src/components/NSBoxString.tsx +8 -5
- package/src/components/NSBoxTextArea.tsx +8 -5
- package/src/components/NSBoxTime.tsx +8 -5
- package/src/components/NSRadioButton.tsx +8 -5
- package/src/components/NSRepeater.tsx +5 -5
- package/src/components/NSTag.tsx +67 -42
|
@@ -56,13 +56,16 @@ export class NSBoxCombo extends React.Component<INSBoxComboProps, INSBoxComboSta
|
|
|
56
56
|
Validator.getError(this.props.title, value, this.props)
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
|
-
getValue(): string | null
|
|
59
|
+
getValue(checkError: boolean = true): string | null
|
|
60
60
|
{
|
|
61
|
-
|
|
62
|
-
if (error)
|
|
61
|
+
if (checkError)
|
|
63
62
|
{
|
|
64
|
-
this.
|
|
65
|
-
|
|
63
|
+
let error = this.getError(this.state.value || "");
|
|
64
|
+
if (error)
|
|
65
|
+
{
|
|
66
|
+
this.setState({ error });
|
|
67
|
+
throw new Error(error);
|
|
68
|
+
}
|
|
66
69
|
}
|
|
67
70
|
return this.state.value;
|
|
68
71
|
}
|
|
@@ -39,13 +39,16 @@ export class NSBoxDate extends React.Component<INSBoxDateProps, INSBoxDateState>
|
|
|
39
39
|
Validator.getErrorDate(this.props.title, this.state.value)
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
|
-
getValue(): string
|
|
42
|
+
getValue(checkError: boolean = true): string
|
|
43
43
|
{
|
|
44
|
-
|
|
45
|
-
if (error)
|
|
44
|
+
if (checkError)
|
|
46
45
|
{
|
|
47
|
-
this.
|
|
48
|
-
|
|
46
|
+
let error = this.getError();
|
|
47
|
+
if (error)
|
|
48
|
+
{
|
|
49
|
+
this.setState({ error });
|
|
50
|
+
throw new Error(error);
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
return this.state.value;
|
|
51
54
|
}
|
|
@@ -39,13 +39,16 @@ export class NSBoxDateTime extends React.Component<INSBoxDateTimeProps, INSBoxDa
|
|
|
39
39
|
Validator.getErrorDate(this.props.title, this.state.value)
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
|
-
getValue(): string
|
|
42
|
+
getValue(checkError: boolean = true): string
|
|
43
43
|
{
|
|
44
|
-
|
|
45
|
-
if (error)
|
|
44
|
+
if (checkError)
|
|
46
45
|
{
|
|
47
|
-
this.
|
|
48
|
-
|
|
46
|
+
let error = this.getError();
|
|
47
|
+
if (error)
|
|
48
|
+
{
|
|
49
|
+
this.setState({ error });
|
|
50
|
+
throw new Error(error);
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
return this.state.value;
|
|
51
54
|
}
|
|
@@ -41,13 +41,16 @@ export class NSBoxDouble extends React.Component<INSBoxDoubleProps, INSBoxDouble
|
|
|
41
41
|
Validator.getErrorNumber(this.props.title, this.state.value, this.props)
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
|
-
getValue(): number | undefined
|
|
44
|
+
getValue(checkError: boolean = true): number | undefined
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
if (error)
|
|
46
|
+
if (checkError)
|
|
48
47
|
{
|
|
49
|
-
this.
|
|
50
|
-
|
|
48
|
+
let error = this.getError();
|
|
49
|
+
if (error)
|
|
50
|
+
{
|
|
51
|
+
this.setState({ error });
|
|
52
|
+
throw new Error(error);
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
return this.state.value;
|
|
53
56
|
}
|
|
@@ -42,13 +42,16 @@ export class NSBoxDuration extends React.Component<INSBoxDurationProps, INSBoxDu
|
|
|
42
42
|
Validator.getErrorDuration(this.props.title, this.state.value)
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
|
-
getValue(): string
|
|
45
|
+
getValue(checkError: boolean = true): string
|
|
46
46
|
{
|
|
47
|
-
|
|
48
|
-
if (error)
|
|
47
|
+
if (checkError)
|
|
49
48
|
{
|
|
50
|
-
this.
|
|
51
|
-
|
|
49
|
+
let error = this.getError();
|
|
50
|
+
if (error)
|
|
51
|
+
{
|
|
52
|
+
this.setState({ error });
|
|
53
|
+
throw new Error(error);
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
56
|
return this.state.value;
|
|
54
57
|
}
|
|
@@ -46,13 +46,16 @@ export class NSBoxEmail extends React.Component<INSBoxEmailProps, INSBoxEmailSta
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
getValue(): string
|
|
49
|
+
getValue(checkError: boolean = true): string
|
|
50
50
|
{
|
|
51
|
-
|
|
52
|
-
if (error)
|
|
51
|
+
if (checkError)
|
|
53
52
|
{
|
|
54
|
-
this.
|
|
55
|
-
|
|
53
|
+
let error = this.getError();
|
|
54
|
+
if (error)
|
|
55
|
+
{
|
|
56
|
+
this.setState({ error });
|
|
57
|
+
throw new Error(error);
|
|
58
|
+
}
|
|
56
59
|
}
|
|
57
60
|
return this.state.value;
|
|
58
61
|
}
|
|
@@ -65,13 +65,16 @@ export class NSBoxEntity<Data> extends React.Component<INSBoxEntityProps<Data>,
|
|
|
65
65
|
Validator.getError(this.props.title, value_string, this.props)
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
|
-
getValue(): Data | null
|
|
68
|
+
getValue(checkError: boolean = true): Data | null
|
|
69
69
|
{
|
|
70
|
-
|
|
71
|
-
if (error)
|
|
70
|
+
if (checkError)
|
|
72
71
|
{
|
|
73
|
-
this.
|
|
74
|
-
|
|
72
|
+
let error = this.getError(this.state.value);
|
|
73
|
+
if (error)
|
|
74
|
+
{
|
|
75
|
+
this.setState({ error });
|
|
76
|
+
throw new Error(error);
|
|
77
|
+
}
|
|
75
78
|
}
|
|
76
79
|
return this.state.value;
|
|
77
80
|
}
|
|
@@ -44,13 +44,16 @@ export class NSBoxIPV4 extends React.Component<INSBoxIPV4Props, INSBoxIPV4State>
|
|
|
44
44
|
Validator.getErrorIP(this.props.title, this.state.value)
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
|
-
getValue(): string
|
|
47
|
+
getValue(checkError: boolean = true): string
|
|
48
48
|
{
|
|
49
|
-
|
|
50
|
-
if (error)
|
|
49
|
+
if (checkError)
|
|
51
50
|
{
|
|
52
|
-
this.
|
|
53
|
-
|
|
51
|
+
let error = this.getError();
|
|
52
|
+
if (error)
|
|
53
|
+
{
|
|
54
|
+
this.setState({ error });
|
|
55
|
+
throw new Error(error);
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
return this.state.value;
|
|
56
59
|
}
|
|
@@ -44,13 +44,16 @@ export class NSBoxIPV6 extends React.Component<INSBoxIPV6Props, INSBoxIPV6State>
|
|
|
44
44
|
Validator.getErrorIP(this.props.title, this.state.value)
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
|
-
getValue(): string
|
|
47
|
+
getValue(checkError: boolean = true): string
|
|
48
48
|
{
|
|
49
|
-
|
|
50
|
-
if (error)
|
|
49
|
+
if (checkError)
|
|
51
50
|
{
|
|
52
|
-
this.
|
|
53
|
-
|
|
51
|
+
let error = this.getError();
|
|
52
|
+
if (error)
|
|
53
|
+
{
|
|
54
|
+
this.setState({ error });
|
|
55
|
+
throw new Error(error);
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
return this.state.value;
|
|
56
59
|
}
|
|
@@ -41,13 +41,16 @@ export class NSBoxInteger extends React.Component<INSBoxIntegerProps, INSBoxInte
|
|
|
41
41
|
Validator.getErrorNumber(this.props.title, this.state.value, this.props)
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
|
-
getValue(): number | undefined
|
|
44
|
+
getValue(checkError: boolean = true): number | undefined
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
if (error)
|
|
46
|
+
if (checkError)
|
|
48
47
|
{
|
|
49
|
-
this.
|
|
50
|
-
|
|
48
|
+
let error = this.getError();
|
|
49
|
+
if (error)
|
|
50
|
+
{
|
|
51
|
+
this.setState({ error });
|
|
52
|
+
throw new Error(error);
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
return this.state.value;
|
|
53
56
|
}
|
|
@@ -41,13 +41,16 @@ export class NSBoxPassword extends React.Component<INSBoxPasswordProps, INSBoxPa
|
|
|
41
41
|
Validator.getErrorString(this.props.title, this.state.value, this.props)
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
|
-
getValue(): string
|
|
44
|
+
getValue(checkError: boolean = true): string
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
if (error)
|
|
46
|
+
if (checkError)
|
|
48
47
|
{
|
|
49
|
-
this.
|
|
50
|
-
|
|
48
|
+
let error = this.getError();
|
|
49
|
+
if (error)
|
|
50
|
+
{
|
|
51
|
+
this.setState({ error });
|
|
52
|
+
throw new Error(error);
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
return this.state.value;
|
|
53
56
|
}
|
|
@@ -44,13 +44,16 @@ export class NSBoxPhone extends React.Component<INSBoxPhoneProps, INSBoxPhoneSta
|
|
|
44
44
|
Validator.getErrorString(this.props.title, this.state.value, this.props)
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
|
-
getValue(): string
|
|
47
|
+
getValue(checkError: boolean = true): string
|
|
48
48
|
{
|
|
49
|
-
|
|
50
|
-
if (error)
|
|
49
|
+
if (checkError)
|
|
51
50
|
{
|
|
52
|
-
this.
|
|
53
|
-
|
|
51
|
+
let error = this.getError();
|
|
52
|
+
if (error)
|
|
53
|
+
{
|
|
54
|
+
this.setState({ error });
|
|
55
|
+
throw new Error(error);
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
return this.state.value;
|
|
56
59
|
}
|
|
@@ -41,13 +41,16 @@ export class NSBoxPrice extends React.Component<INSBoxPriceProps, INSBoxPriceSta
|
|
|
41
41
|
Validator.getErrorNumber(this.props.title, this.state.value, this.props)
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
|
-
getValue(): number | undefined
|
|
44
|
+
getValue(checkError: boolean = true): number | undefined
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
if (error)
|
|
46
|
+
if (checkError)
|
|
48
47
|
{
|
|
49
|
-
this.
|
|
50
|
-
|
|
48
|
+
let error = this.getError();
|
|
49
|
+
if (error)
|
|
50
|
+
{
|
|
51
|
+
this.setState({ error });
|
|
52
|
+
throw new Error(error);
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
return this.state.value;
|
|
53
56
|
}
|
|
@@ -43,13 +43,16 @@ export class NSBoxSearch extends React.Component<INSBoxSearchProps, INSBoxSearch
|
|
|
43
43
|
Validator.getErrorString(this.props.title, this.state.value, this.props)
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
|
-
getValue(): string
|
|
46
|
+
getValue(checkError: boolean = true): string
|
|
47
47
|
{
|
|
48
|
-
|
|
49
|
-
if (error)
|
|
48
|
+
if (checkError)
|
|
50
49
|
{
|
|
51
|
-
this.
|
|
52
|
-
|
|
50
|
+
let error = this.getError();
|
|
51
|
+
if (error)
|
|
52
|
+
{
|
|
53
|
+
this.setState({ error });
|
|
54
|
+
throw new Error(error);
|
|
55
|
+
}
|
|
53
56
|
}
|
|
54
57
|
return this.state.value;
|
|
55
58
|
}
|
|
@@ -49,13 +49,16 @@ export class NSBoxString extends React.Component<INSBoxStringProps, INSBoxString
|
|
|
49
49
|
custom
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
|
-
getValue(): string
|
|
52
|
+
getValue(checkError: boolean = true): string
|
|
53
53
|
{
|
|
54
|
-
|
|
55
|
-
if (error)
|
|
54
|
+
if (checkError)
|
|
56
55
|
{
|
|
57
|
-
this.
|
|
58
|
-
|
|
56
|
+
let error = this.getError();
|
|
57
|
+
if (error)
|
|
58
|
+
{
|
|
59
|
+
this.setState({ error });
|
|
60
|
+
throw new Error(error);
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
return this.state.value;
|
|
61
64
|
}
|
|
@@ -45,13 +45,16 @@ export class NSBoxTextArea extends React.Component<INSBoxTextAreaProps, INSBoxTe
|
|
|
45
45
|
Validator.getErrorString(this.props.title, this.state.value, this.props)
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
-
getValue(): string
|
|
48
|
+
getValue(checkError: boolean = true): string
|
|
49
49
|
{
|
|
50
|
-
|
|
51
|
-
if (error)
|
|
50
|
+
if (checkError)
|
|
52
51
|
{
|
|
53
|
-
this.
|
|
54
|
-
|
|
52
|
+
let error = this.getError();
|
|
53
|
+
if (error)
|
|
54
|
+
{
|
|
55
|
+
this.setState({ error });
|
|
56
|
+
throw new Error(error);
|
|
57
|
+
}
|
|
55
58
|
}
|
|
56
59
|
return this.state.value;
|
|
57
60
|
}
|
|
@@ -42,13 +42,16 @@ export class NSBoxTime extends React.Component<INSBoxTimeProps, INSBoxTimeState>
|
|
|
42
42
|
Validator.getErrorTime(this.props.title, this.state.value)
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
|
-
getValue(): string
|
|
45
|
+
getValue(checkError: boolean = true): string
|
|
46
46
|
{
|
|
47
|
-
|
|
48
|
-
if (error)
|
|
47
|
+
if (checkError)
|
|
49
48
|
{
|
|
50
|
-
this.
|
|
51
|
-
|
|
49
|
+
let error = this.getError();
|
|
50
|
+
if (error)
|
|
51
|
+
{
|
|
52
|
+
this.setState({ error });
|
|
53
|
+
throw new Error(error);
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
56
|
return this.state.value;
|
|
54
57
|
}
|
|
@@ -37,13 +37,16 @@ export class NSRadioButton extends React.Component<INSRadioButtonProps, INSBoxBo
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
getValue(): boolean
|
|
40
|
+
getValue(checkError: boolean = true): boolean
|
|
41
41
|
{
|
|
42
|
-
|
|
43
|
-
if (error)
|
|
42
|
+
if (checkError)
|
|
44
43
|
{
|
|
45
|
-
this.
|
|
46
|
-
|
|
44
|
+
let error = this.getError();
|
|
45
|
+
if (error)
|
|
46
|
+
{
|
|
47
|
+
this.setState({ error });
|
|
48
|
+
throw new Error(error);
|
|
49
|
+
}
|
|
47
50
|
}
|
|
48
51
|
return this.state.value;
|
|
49
52
|
}
|
|
@@ -4,7 +4,7 @@ export interface NSRepeaterProps<ItemType, ValueType>
|
|
|
4
4
|
{
|
|
5
5
|
createItem: (index: number, ref: React.RefObject<ItemType>, onChange: (index: number) => void, onDelete: (index: number) => void) => ReactNode;
|
|
6
6
|
updateItem: (item: ItemType, index: number, value: ValueType | null) => void;
|
|
7
|
-
getValue: (item: ItemType) => ValueType;
|
|
7
|
+
getValue: (item: ItemType, checkError: boolean) => ValueType;
|
|
8
8
|
isEmpty: (value: ValueType) => boolean;
|
|
9
9
|
onItemChanged?: () => void;
|
|
10
10
|
onValuesChanged?: (values: ValueType[]) => void;
|
|
@@ -91,7 +91,7 @@ export class NSRepeater<ItemType, ValueType> extends Component<NSRepeaterProps<I
|
|
|
91
91
|
private onChange()
|
|
92
92
|
{
|
|
93
93
|
if (this.props.onValuesChanged)
|
|
94
|
-
this.props.onValuesChanged(this.getValues());
|
|
94
|
+
this.props.onValuesChanged(this.getValues(false));
|
|
95
95
|
this.checkForNew();
|
|
96
96
|
}
|
|
97
97
|
private onDelete(index: number)
|
|
@@ -113,18 +113,18 @@ export class NSRepeater<ItemType, ValueType> extends Component<NSRepeaterProps<I
|
|
|
113
113
|
last--;
|
|
114
114
|
let item = this.Item_Refs[last].current;
|
|
115
115
|
if (item)
|
|
116
|
-
if (!this.props.isEmpty(this.props.getValue(item)))
|
|
116
|
+
if (!this.props.isEmpty(this.props.getValue(item, false)))
|
|
117
117
|
this.addItem();
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
getValues(): ValueType[]
|
|
120
|
+
getValues(checkError: boolean = true): ValueType[]
|
|
121
121
|
{
|
|
122
122
|
return this.state.items.map((_, index) =>
|
|
123
123
|
{
|
|
124
124
|
let item = this.Item_Refs[index].current;
|
|
125
125
|
if (item)
|
|
126
126
|
{
|
|
127
|
-
let value = this.props.getValue(item);
|
|
127
|
+
let value = this.props.getValue(item, checkError);
|
|
128
128
|
if (!this.props.isEmpty(value))
|
|
129
129
|
return value;
|
|
130
130
|
}
|
package/src/components/NSTag.tsx
CHANGED
|
@@ -1,50 +1,75 @@
|
|
|
1
|
+
import { Component, createRef } from 'react';
|
|
1
2
|
import { NSBoxString } from './NSBoxString';
|
|
2
3
|
import NSButton from './NSButton';
|
|
3
4
|
import Styles from './NSTag.module.css';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
export interface NSTagProps
|
|
6
7
|
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<div className={Styles.ns_tag_input_group}>
|
|
10
|
-
<NSBoxString title='Key' required />
|
|
11
|
-
<NSBoxString title='Value' required />
|
|
12
|
-
<NSBoxString title='Option' required />
|
|
13
|
-
<NSButton
|
|
14
|
-
title='Remove'
|
|
15
|
-
onClick={() => { }}
|
|
16
|
-
style={{
|
|
17
|
-
backgroundColor: "transparent",
|
|
18
|
-
border: "1px solid rgba(3, 119, 255, 1)",
|
|
19
|
-
width: "145px",
|
|
20
|
-
marginTop: "28px"
|
|
21
|
-
}}
|
|
22
|
-
/>
|
|
23
|
-
</div>
|
|
24
|
-
</section>
|
|
25
|
-
)
|
|
8
|
+
onChanged?: () => void;
|
|
9
|
+
onDeleted?: () => void;
|
|
26
10
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// </div>
|
|
47
|
-
// );
|
|
48
|
-
// }
|
|
11
|
+
export interface NSTagValue
|
|
12
|
+
{
|
|
13
|
+
name: string;
|
|
14
|
+
value: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class NSTag extends Component<NSTagProps>
|
|
19
|
+
{
|
|
20
|
+
static isEmpty(value: NSTagValue)
|
|
21
|
+
{
|
|
22
|
+
if (value.name || value.value || value.description)
|
|
23
|
+
return false
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private NSBoxString_Key = createRef<NSBoxString>();
|
|
28
|
+
private NSBoxString_Value = createRef<NSBoxString>();
|
|
29
|
+
private NSBoxString_Description = createRef<NSBoxString>();
|
|
49
30
|
|
|
31
|
+
getValue(checkError: boolean = true): NSTagValue
|
|
32
|
+
{
|
|
33
|
+
let name = this.NSBoxString_Key.current?.getValue(checkError) ?? "";
|
|
34
|
+
let value = this.NSBoxString_Value.current?.getValue(checkError) ?? "";
|
|
35
|
+
let description = this.NSBoxString_Description.current?.getValue(checkError) ?? "";
|
|
36
|
+
return {
|
|
37
|
+
name,
|
|
38
|
+
value,
|
|
39
|
+
description
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
setValue(value: NSTagValue)
|
|
43
|
+
{
|
|
44
|
+
this.NSBoxString_Key.current?.setValue(value.name);
|
|
45
|
+
this.NSBoxString_Value.current?.setValue(value.value);
|
|
46
|
+
this.NSBoxString_Description.current?.setValue(value.description ?? "");
|
|
47
|
+
}
|
|
48
|
+
override render()
|
|
49
|
+
{
|
|
50
|
+
return (
|
|
51
|
+
<section className={Styles.ns_tag_input_container} >
|
|
52
|
+
<div className={Styles.ns_tag_input_group}>
|
|
53
|
+
<NSBoxString ref={this.NSBoxString_Key} title='Name' required onChanged={this.props.onChanged} />
|
|
54
|
+
<NSBoxString ref={this.NSBoxString_Value} title='Value' required onChanged={this.props.onChanged} />
|
|
55
|
+
<NSBoxString ref={this.NSBoxString_Description} title='Description' required={false} onChanged={this.props.onChanged} />
|
|
56
|
+
<NSButton
|
|
57
|
+
title='Remove'
|
|
58
|
+
onClick={() =>
|
|
59
|
+
{
|
|
60
|
+
if (this.props.onDeleted)
|
|
61
|
+
this.props.onDeleted();
|
|
62
|
+
}}
|
|
63
|
+
style={{
|
|
64
|
+
backgroundColor: "transparent",
|
|
65
|
+
border: "1px solid rgba(3, 119, 255, 1)",
|
|
66
|
+
width: "145px",
|
|
67
|
+
marginTop: "28px"
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</section>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
50
75
|
export default NSTag;
|