namirasoft-site-react 1.4.492 → 1.4.494
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Component, ReactNode } from 'react';
|
|
2
|
-
import { INSBox } from './INSBox';
|
|
3
2
|
import { IBaseComponentProps } from '../props/IBaseComponentProps';
|
|
3
|
+
import { INSBox } from './INSBox';
|
|
4
4
|
import { INSBoxBaseLayoutProps, NSBoxBaseLayout } from './NSBoxBaseLayout';
|
|
5
5
|
export interface NSRepeaterProps<ItemType, ValueType> extends IBaseComponentProps, INSBoxBaseLayoutProps<ItemType, ValueType> {
|
|
6
6
|
createItem: (gIndex: number, lIndex: number, ref: React.RefObject<ItemType>, onChange: () => void, onDelete: undefined | ((lIndex: number) => void)) => ReactNode;
|
|
7
|
-
getValue: (item: ItemType, checkError: boolean) => ValueType | null
|
|
7
|
+
getValue: (item: ItemType, checkError: boolean) => ValueType | null | Promise<ValueType | null>;
|
|
8
8
|
setValue: (item: ItemType, index: number, value: ValueType | null, callback?: () => void) => void;
|
|
9
9
|
isEmpty: (item: ItemType, value: ValueType | null) => boolean;
|
|
10
10
|
onItemChanged?: (repeater: NSRepeater<ItemType, ValueType>) => void;
|
|
@@ -32,6 +32,7 @@ export declare class NSRepeater<ItemType, ValueType> extends Component<NSRepeate
|
|
|
32
32
|
private checkForNew;
|
|
33
33
|
isEmpty(): boolean;
|
|
34
34
|
getError(): string | null;
|
|
35
|
+
getValueAsync(checkError?: boolean): Promise<ValueType[]>;
|
|
35
36
|
getValue(checkError?: boolean): ValueType[];
|
|
36
37
|
setValue(value: ValueType[], callback?: () => void): void;
|
|
37
38
|
componentDidMount(): void;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
11
|
import { Component, createRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { NSLine } from './NSLine';
|
|
12
|
+
import { Validator } from '../Validator';
|
|
5
13
|
import { NSBoxBaseLayout } from './NSBoxBaseLayout';
|
|
14
|
+
import { NSLine } from './NSLine';
|
|
6
15
|
import { safeMenuMenuItem } from './NSMenuButton';
|
|
7
|
-
import {
|
|
16
|
+
import { NSSpace, NSSpaceSizeType } from './NSSpace';
|
|
8
17
|
export class NSRepeater extends Component {
|
|
9
18
|
constructor(props) {
|
|
10
19
|
super(props);
|
|
@@ -94,19 +103,23 @@ export class NSRepeater extends Component {
|
|
|
94
103
|
this.checkForNew();
|
|
95
104
|
}
|
|
96
105
|
checkForNew() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
last
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
this.
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
let length = this.state.items.filter(x => x).length;
|
|
108
|
+
if (length === 0)
|
|
109
|
+
this.addItem();
|
|
110
|
+
else {
|
|
111
|
+
let last = this.Item_Refs.length - 1;
|
|
112
|
+
while (!this.state.items[last])
|
|
113
|
+
last--;
|
|
114
|
+
let item = this.Item_Refs[last].current;
|
|
115
|
+
if (item) {
|
|
116
|
+
let value = yield this.props.getValue(item, false);
|
|
117
|
+
if (!this.props.isEmpty(item, value)) {
|
|
118
|
+
this.addItem();
|
|
119
|
+
}
|
|
108
120
|
}
|
|
109
|
-
|
|
121
|
+
}
|
|
122
|
+
});
|
|
110
123
|
}
|
|
111
124
|
isEmpty() {
|
|
112
125
|
return true;
|
|
@@ -114,16 +127,48 @@ export class NSRepeater extends Component {
|
|
|
114
127
|
getError() {
|
|
115
128
|
return (Validator.getErrorArray(this.props.title, this.last_value, this.props.required, this.props.min, this.props.max));
|
|
116
129
|
}
|
|
130
|
+
getValueAsync() {
|
|
131
|
+
return __awaiter(this, arguments, void 0, function* (checkError = true) {
|
|
132
|
+
var _a;
|
|
133
|
+
this.last_value = [];
|
|
134
|
+
for (let index = 0; index < this.state.items.length; index++) {
|
|
135
|
+
const exists = this.state.items[index];
|
|
136
|
+
if (exists) {
|
|
137
|
+
let item = this.Item_Refs[index].current;
|
|
138
|
+
if (item) {
|
|
139
|
+
try {
|
|
140
|
+
let empty_value = yield this.props.getValue(item, false);
|
|
141
|
+
if (!this.props.isEmpty(item, empty_value)) {
|
|
142
|
+
let value = yield this.props.getValue(item, checkError);
|
|
143
|
+
if (value != null)
|
|
144
|
+
this.last_value.push(value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (this.props.ignoreItemsHavingError !== true)
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return (_a = NSBoxBaseLayout.checkGetValue(this, checkError, () => this.last_value)) !== null && _a !== void 0 ? _a : [];
|
|
155
|
+
});
|
|
156
|
+
}
|
|
117
157
|
getValue(checkError = true) {
|
|
118
158
|
var _a;
|
|
119
|
-
this.last_value =
|
|
159
|
+
this.last_value = [];
|
|
160
|
+
for (let index = 0; index < this.state.items.length; index++) {
|
|
161
|
+
const exists = this.state.items[index];
|
|
120
162
|
if (exists) {
|
|
121
163
|
let item = this.Item_Refs[index].current;
|
|
122
164
|
if (item) {
|
|
123
165
|
try {
|
|
124
166
|
let empty_value = this.props.getValue(item, false);
|
|
125
|
-
if (!this.props.isEmpty(item, empty_value))
|
|
126
|
-
|
|
167
|
+
if (!this.props.isEmpty(item, empty_value)) {
|
|
168
|
+
let value = this.props.getValue(item, checkError);
|
|
169
|
+
if (value != null)
|
|
170
|
+
this.last_value.push(value);
|
|
171
|
+
}
|
|
127
172
|
}
|
|
128
173
|
catch (error) {
|
|
129
174
|
if (this.props.ignoreItemsHavingError !== true)
|
|
@@ -131,8 +176,7 @@ export class NSRepeater extends Component {
|
|
|
131
176
|
}
|
|
132
177
|
}
|
|
133
178
|
}
|
|
134
|
-
|
|
135
|
-
}).filter(x => x !== null);
|
|
179
|
+
}
|
|
136
180
|
return (_a = NSBoxBaseLayout.checkGetValue(this, checkError, () => this.last_value)) !== null && _a !== void 0 ? _a : [];
|
|
137
181
|
}
|
|
138
182
|
setValue(value, callback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSRepeater.js","sourceRoot":"","sources":["../../src/components/NSRepeater.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NSRepeater.js","sourceRoot":"","sources":["../../src/components/NSRepeater.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAyB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAqBrD,MAAM,OAAO,UAAgC,SAAQ,SAAgE;IAKpH,YAAY,KAA2C;QAEtD,KAAK,CAAC,KAAK,CAAC,CAAC;QALd,yBAAoB,GAAG,SAAS,EAAm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HANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.4.
|
|
11
|
+
"version": "1.4.494",
|
|
12
12
|
"author": "Amir Abolhasani",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/main.js",
|
|
@@ -23,23 +23,23 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@ant-design/charts": "^2.6.5",
|
|
25
25
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
26
|
-
"@types/node": "^24.
|
|
26
|
+
"@types/node": "^24.8.1",
|
|
27
27
|
"@types/react": "^18.3.12",
|
|
28
28
|
"@types/react-bootstrap": "^1.1.0",
|
|
29
29
|
"@types/react-dom": "^18.3.1",
|
|
30
30
|
"@types/react-gtm-module": "^2.0.4",
|
|
31
|
-
"antd": "^5.27.
|
|
31
|
+
"antd": "^5.27.5",
|
|
32
32
|
"async-mutex": "^0.5.0",
|
|
33
33
|
"bootstrap": "^5.3.8",
|
|
34
34
|
"chart.js": "^4.5.1",
|
|
35
35
|
"copyfiles": "^2.4.1",
|
|
36
36
|
"link-react": "^3.0.0",
|
|
37
37
|
"namirasoft-api-link": "^1.4.20",
|
|
38
|
-
"namirasoft-api-product": "^1.4.
|
|
39
|
-
"namirasoft-core": "^1.4.
|
|
38
|
+
"namirasoft-api-product": "^1.4.41",
|
|
39
|
+
"namirasoft-core": "^1.4.100",
|
|
40
40
|
"namirasoft-schema": "^1.4.25",
|
|
41
41
|
"namirasoft-site": "^1.4.41",
|
|
42
|
-
"namirasoft-site-map": "^1.4.
|
|
42
|
+
"namirasoft-site-map": "^1.4.38",
|
|
43
43
|
"os-browserify": "^0.3.0",
|
|
44
44
|
"path-browserify": "^1.0.1",
|
|
45
45
|
"react": "^18.3.1",
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Component, createRef, ReactNode } from 'react';
|
|
2
|
-
import { INSBox } from './INSBox';
|
|
3
2
|
import { IBaseComponentProps } from '../props/IBaseComponentProps';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { Validator } from '../Validator';
|
|
4
|
+
import { INSBox } from './INSBox';
|
|
6
5
|
import { INSBoxBaseLayoutProps, NSBoxBaseLayout } from './NSBoxBaseLayout';
|
|
6
|
+
import { NSLine } from './NSLine';
|
|
7
7
|
import { safeMenuMenuItem } from './NSMenuButton';
|
|
8
|
-
import {
|
|
8
|
+
import { NSSpace, NSSpaceSizeType } from './NSSpace';
|
|
9
9
|
|
|
10
10
|
export interface NSRepeaterProps<ItemType, ValueType> extends IBaseComponentProps, INSBoxBaseLayoutProps<ItemType, ValueType>
|
|
11
11
|
{
|
|
12
12
|
createItem: (gIndex: number, lIndex: number, ref: React.RefObject<ItemType>, onChange: () => void, onDelete: undefined | ((lIndex: number) => void)) => ReactNode;
|
|
13
|
-
getValue: (item: ItemType, checkError: boolean) => ValueType | null
|
|
13
|
+
getValue: (item: ItemType, checkError: boolean) => ValueType | null | Promise<ValueType | null>;
|
|
14
14
|
setValue: (item: ItemType, index: number, value: ValueType | null, callback?: () => void) => void;
|
|
15
15
|
isEmpty: (item: ItemType, value: ValueType | null) => boolean;
|
|
16
16
|
onItemChanged?: (repeater: NSRepeater<ItemType, ValueType>) => void;
|
|
@@ -128,7 +128,7 @@ export class NSRepeater<ItemType, ValueType> extends Component<NSRepeaterProps<I
|
|
|
128
128
|
this.props.onValuesChanged?.(this);
|
|
129
129
|
this.checkForNew();
|
|
130
130
|
}
|
|
131
|
-
private checkForNew()
|
|
131
|
+
private async checkForNew()
|
|
132
132
|
{
|
|
133
133
|
let length = this.state.items.filter(x => x).length;
|
|
134
134
|
if (length === 0)
|
|
@@ -140,10 +140,13 @@ export class NSRepeater<ItemType, ValueType> extends Component<NSRepeaterProps<I
|
|
|
140
140
|
last--;
|
|
141
141
|
let item = this.Item_Refs[last].current;
|
|
142
142
|
if (item)
|
|
143
|
-
|
|
143
|
+
{
|
|
144
|
+
let value = await this.props.getValue(item, false)
|
|
145
|
+
if (!this.props.isEmpty(item, value))
|
|
144
146
|
{
|
|
145
147
|
this.addItem();
|
|
146
148
|
}
|
|
149
|
+
}
|
|
147
150
|
}
|
|
148
151
|
}
|
|
149
152
|
isEmpty(): boolean
|
|
@@ -156,10 +159,43 @@ export class NSRepeater<ItemType, ValueType> extends Component<NSRepeaterProps<I
|
|
|
156
159
|
Validator.getErrorArray(this.props.title, this.last_value, this.props.required, this.props.min, this.props.max)
|
|
157
160
|
);
|
|
158
161
|
}
|
|
162
|
+
// todo getValueAsync and getValue are using same logic. Repeatitive code must be removed.
|
|
163
|
+
async getValueAsync(checkError: boolean = true): Promise<ValueType[]>
|
|
164
|
+
{
|
|
165
|
+
this.last_value = [];
|
|
166
|
+
for (let index = 0; index < this.state.items.length; index++)
|
|
167
|
+
{
|
|
168
|
+
const exists = this.state.items[index];
|
|
169
|
+
if (exists)
|
|
170
|
+
{
|
|
171
|
+
let item = this.Item_Refs[index].current;
|
|
172
|
+
if (item)
|
|
173
|
+
{
|
|
174
|
+
try
|
|
175
|
+
{
|
|
176
|
+
let empty_value = await this.props.getValue(item, false);
|
|
177
|
+
if (!this.props.isEmpty(item, empty_value))
|
|
178
|
+
{
|
|
179
|
+
let value = await this.props.getValue(item, checkError);
|
|
180
|
+
if (value != null)
|
|
181
|
+
this.last_value.push(value);
|
|
182
|
+
}
|
|
183
|
+
} catch (error)
|
|
184
|
+
{
|
|
185
|
+
if (this.props.ignoreItemsHavingError !== true)
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return NSBoxBaseLayout.checkGetValue(this, checkError, () => this.last_value) ?? [];
|
|
192
|
+
}
|
|
159
193
|
getValue(checkError: boolean = true): ValueType[]
|
|
160
194
|
{
|
|
161
|
-
this.last_value =
|
|
195
|
+
this.last_value = [];
|
|
196
|
+
for (let index = 0; index < this.state.items.length; index++)
|
|
162
197
|
{
|
|
198
|
+
const exists = this.state.items[index];
|
|
163
199
|
if (exists)
|
|
164
200
|
{
|
|
165
201
|
let item = this.Item_Refs[index].current;
|
|
@@ -167,9 +203,13 @@ export class NSRepeater<ItemType, ValueType> extends Component<NSRepeaterProps<I
|
|
|
167
203
|
{
|
|
168
204
|
try
|
|
169
205
|
{
|
|
170
|
-
let empty_value = this.props.getValue(item, false);
|
|
206
|
+
let empty_value = this.props.getValue(item, false) as ValueType | null;
|
|
171
207
|
if (!this.props.isEmpty(item, empty_value))
|
|
172
|
-
|
|
208
|
+
{
|
|
209
|
+
let value = this.props.getValue(item, checkError) as ValueType | null;
|
|
210
|
+
if (value != null)
|
|
211
|
+
this.last_value.push(value);
|
|
212
|
+
}
|
|
173
213
|
} catch (error)
|
|
174
214
|
{
|
|
175
215
|
if (this.props.ignoreItemsHavingError !== true)
|
|
@@ -177,8 +217,7 @@ export class NSRepeater<ItemType, ValueType> extends Component<NSRepeaterProps<I
|
|
|
177
217
|
}
|
|
178
218
|
}
|
|
179
219
|
}
|
|
180
|
-
|
|
181
|
-
}).filter(x => x !== null) as ValueType[];
|
|
220
|
+
}
|
|
182
221
|
return NSBoxBaseLayout.checkGetValue(this, checkError, () => this.last_value) ?? [];
|
|
183
222
|
}
|
|
184
223
|
setValue(value: ValueType[], callback?: () => void): void
|
|
@@ -244,19 +283,19 @@ export class NSRepeater<ItemType, ValueType> extends Component<NSRepeaterProps<I
|
|
|
244
283
|
|
|
245
284
|
if (visible && LIndex !== 0)
|
|
246
285
|
return (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
286
|
+
<div key={GIndex} style={{ width: "100%", ...props.style }}>
|
|
287
|
+
<NSSpace size={NSSpaceSizeType.MICRO} />
|
|
288
|
+
<NSLine />
|
|
289
|
+
<NSSpace size={NSSpaceSizeType.MICRO} />
|
|
290
|
+
{item}
|
|
291
|
+
</div>
|
|
292
|
+
)
|
|
254
293
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
294
|
+
return (
|
|
295
|
+
<div key={GIndex} style={{ width: "100%", ...props.style }}>
|
|
296
|
+
{item}
|
|
297
|
+
</div>
|
|
298
|
+
)
|
|
260
299
|
})
|
|
261
300
|
}
|
|
262
301
|
</NSBoxBaseLayout>
|