@adcops/autocore-react 3.0.18 → 3.0.20
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/components/FileList.d.ts +1 -0
- package/dist/components/FileList.js +1 -1
- package/dist/components/FileSelect.d.ts +10 -0
- package/dist/components/FileSelect.js +1 -0
- package/dist/components/ProgressBarWithValue.css +27 -0
- package/dist/components/ProgressBarWithValue.d.ts +9 -0
- package/dist/components/ProgressBarWithValue.js +1 -0
- package/dist/components/TextInput.d.ts +1 -0
- package/dist/components/TextInput.js +1 -1
- package/dist/components/ToggleGroup.d.ts +1 -0
- package/dist/components/ToggleGroup.js +1 -1
- package/dist/components/ValueInput.d.ts +66 -77
- package/dist/components/ValueInput.js +1 -1
- package/dist/hooks/adsHooks.d.ts +96 -0
- package/dist/hooks/adsHooks.js +1 -0
- package/package.json +2 -2
- package/src/components/FileList.tsx +11 -5
- package/src/components/FileSelect.tsx +115 -0
- package/src/components/ProgressBarWithValue.css +27 -0
- package/src/components/ProgressBarWithValue.tsx +49 -0
- package/src/components/TextInput.tsx +11 -1
- package/src/components/ToggleGroup.tsx +38 -1
- package/src/components/ValueInput.tsx +213 -213
- package/src/hooks/adsHooks.tsx +208 -0
- package/dist/hooks/useAdsRegisterSymbol.d.ts +0 -32
- package/dist/hooks/useAdsRegisterSymbol.js +0 -1
- package/src/hooks/useAdsRegisterSymbol.ts +0 -97
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
|
|
3
|
+
* Created Date: 2024-04-28 16:06:59
|
|
4
|
+
* -----
|
|
5
|
+
* Last Modified: 2024-04-28 20:05:41
|
|
6
|
+
* -----
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import React, { useState, useContext, useEffect } from 'react';
|
|
12
|
+
import { DataTable } from 'primereact/datatable';
|
|
13
|
+
import { Column } from 'primereact/column';
|
|
14
|
+
import { Button } from 'primereact/button';
|
|
15
|
+
|
|
16
|
+
import { EventEmitterContext } from "../core/EventEmitterContext";
|
|
17
|
+
|
|
18
|
+
type FileSelectProps = {
|
|
19
|
+
domain?: string,
|
|
20
|
+
subdir?: string,
|
|
21
|
+
onFileSelected?: (fileName: string) => void,
|
|
22
|
+
onAccept?: (fileName: string) => void,
|
|
23
|
+
onCancel?: () => void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type FileItem = {
|
|
27
|
+
id: number;
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const FileSelect: React.FC<FileSelectProps> = ({
|
|
32
|
+
domain = "DATASTORE",
|
|
33
|
+
subdir,
|
|
34
|
+
onFileSelected,
|
|
35
|
+
onAccept,
|
|
36
|
+
onCancel
|
|
37
|
+
}) => {
|
|
38
|
+
const { invoke } = useContext(EventEmitterContext);
|
|
39
|
+
const [files, setFiles] = useState<FileItem[]>([]);
|
|
40
|
+
const [selectedFile, setSelectedFile] = useState<FileItem | null>(null);
|
|
41
|
+
|
|
42
|
+
const listFiles = async () => {
|
|
43
|
+
try {
|
|
44
|
+
const args = subdir ? { "subdir": subdir } : {};
|
|
45
|
+
const res = await invoke(domain, "list_files", args);
|
|
46
|
+
const items = res.data.map((item: string, index: number) => ({
|
|
47
|
+
id: index + 1,
|
|
48
|
+
name: item
|
|
49
|
+
}));
|
|
50
|
+
setFiles(items);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error("Failed to list files:", error);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const handleSelect = (file: FileItem) => {
|
|
57
|
+
setSelectedFile(file);
|
|
58
|
+
if (onFileSelected) onFileSelected(file.name);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const makeReturnFileName = () => {
|
|
62
|
+
if (selectedFile !== null) {
|
|
63
|
+
if (subdir !== undefined) {
|
|
64
|
+
return `${subdir}/${selectedFile.name}`;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return selectedFile.name;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
listFiles();
|
|
77
|
+
}, [domain, subdir]);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div>
|
|
81
|
+
<DataTable
|
|
82
|
+
value={files}
|
|
83
|
+
selectionMode="single"
|
|
84
|
+
selection={selectedFile}
|
|
85
|
+
onSelectionChange={e => handleSelect(e.value as FileItem)}
|
|
86
|
+
>
|
|
87
|
+
<Column field="name" header="File Name" />
|
|
88
|
+
<Column body={(rowData: FileItem) => (
|
|
89
|
+
<Button
|
|
90
|
+
label={selectedFile?.name === rowData.name ? "Selected" : "Select"}
|
|
91
|
+
icon={selectedFile?.name === rowData.name ? "pi pi-check-circle" : "pi pi-circle-off"}
|
|
92
|
+
onClick={() => handleSelect(rowData)}
|
|
93
|
+
className={`p-button-rounded ${selectedFile?.name === rowData.name ? "p-button-success" : "p-button-outlined"}`}
|
|
94
|
+
aria-label="Select"
|
|
95
|
+
size="small"
|
|
96
|
+
/>
|
|
97
|
+
)} header="Select" />
|
|
98
|
+
</DataTable>
|
|
99
|
+
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '10px' }}>
|
|
100
|
+
<Button label="Cancel" icon="pi pi-times" className="p-button-text" onClick={onCancel} />
|
|
101
|
+
<Button
|
|
102
|
+
label="Accept"
|
|
103
|
+
icon="pi pi-check"
|
|
104
|
+
className="p-button"
|
|
105
|
+
onClick={() => { if (onAccept !== undefined && selectedFile !== null) onAccept(makeReturnFileName()) }}
|
|
106
|
+
disabled={!selectedFile}
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export default FileSelect;
|
|
114
|
+
|
|
115
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
|
|
3
|
+
* Created Date: 2024-04-27 12:46:35
|
|
4
|
+
* -----
|
|
5
|
+
* Last Modified: 2024-04-27 13:10:43
|
|
6
|
+
* -----
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
.custom-progress-bar {
|
|
13
|
+
position: relative;
|
|
14
|
+
width: 100%; /* Ensure the progress bar fills the container */
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.centered-value {
|
|
18
|
+
position: absolute;
|
|
19
|
+
width: 100%;
|
|
20
|
+
text-align: center;
|
|
21
|
+
font-weight: 600;
|
|
22
|
+
z-index: 10;
|
|
23
|
+
top: 50%;
|
|
24
|
+
left: 50%;
|
|
25
|
+
transform: translate(-50%, -50%); /* Centering magic */
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
|
|
3
|
+
* Created Date: 2024-04-27 12:46:15
|
|
4
|
+
* -----
|
|
5
|
+
* Last Modified: 2024-04-27 13:25:56
|
|
6
|
+
* -----
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { ProgressBar } from 'primereact/progressbar';
|
|
13
|
+
import './ProgressBarWithValue.css'; // Import your custom CSS
|
|
14
|
+
|
|
15
|
+
interface ProgressBarWithValueProps {
|
|
16
|
+
value: number;
|
|
17
|
+
max?: number;
|
|
18
|
+
label? : string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const ProgressBarWithValue: React.FC<ProgressBarWithValueProps> = ({ value, max, label }) => {
|
|
22
|
+
let progressValue = value;
|
|
23
|
+
let indeterminate = false;
|
|
24
|
+
|
|
25
|
+
if (max !== undefined) {
|
|
26
|
+
if (max > 0) {
|
|
27
|
+
progressValue = (value / max) * 100; // Calculate percentage
|
|
28
|
+
}
|
|
29
|
+
else { // max === 0
|
|
30
|
+
progressValue = 0;
|
|
31
|
+
indeterminate = true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="custom-progress-bar">
|
|
37
|
+
<ProgressBar
|
|
38
|
+
showValue={false}
|
|
39
|
+
value={progressValue}
|
|
40
|
+
mode={indeterminate ? 'indeterminate' : 'determinate'}
|
|
41
|
+
/>
|
|
42
|
+
<div className="centered-value">
|
|
43
|
+
{label ? `${label} ` : ''} {value} {max ? `of ${max}` : ''}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default ProgressBarWithValue;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
|
|
3
3
|
* Created Date: 2024-03-20 13:05:42
|
|
4
4
|
* -----
|
|
5
|
-
* Last Modified: 2024-
|
|
5
|
+
* Last Modified: 2024-04-27 17:33:46
|
|
6
6
|
* -----
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
@@ -143,6 +143,16 @@ export class TextInput extends React.Component<TextInputProps, TextInputState> {
|
|
|
143
143
|
componentDidMount() {
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
|
|
147
|
+
componentDidUpdate(prevProps: TextInputProps) {
|
|
148
|
+
// Check if the value prop has changed
|
|
149
|
+
if (prevProps.value !== this.props.value) {
|
|
150
|
+
this.setState({
|
|
151
|
+
entryValue: this.props.value,
|
|
152
|
+
editing: false
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
146
156
|
|
|
147
157
|
|
|
148
158
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
|
|
3
3
|
* Created Date: 2024-03-12 10:14:48
|
|
4
4
|
* -----
|
|
5
|
-
* Last Modified: 2024-04-
|
|
5
|
+
* Last Modified: 2024-04-29 10:43:49
|
|
6
6
|
* -----
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
@@ -33,6 +33,7 @@ export interface ToggleGroupProps extends SelectButtonProps {
|
|
|
33
33
|
invisibleTopic?: string;
|
|
34
34
|
actionMode?: ActionMode;
|
|
35
35
|
invert?: boolean;
|
|
36
|
+
onValueChanged? : (value: boolean | number) => void;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export const ToggleGroup: React.FC<ToggleGroupProps> = ({
|
|
@@ -47,6 +48,7 @@ export const ToggleGroup: React.FC<ToggleGroupProps> = ({
|
|
|
47
48
|
invisibleTopic,
|
|
48
49
|
actionMode,
|
|
49
50
|
invert,
|
|
51
|
+
onValueChanged: onValueChange,
|
|
50
52
|
...restProps
|
|
51
53
|
}) => {
|
|
52
54
|
|
|
@@ -239,6 +241,40 @@ export const ToggleGroup: React.FC<ToggleGroupProps> = ({
|
|
|
239
241
|
|
|
240
242
|
const toggleGroupName = `${uniqueId}-togglegroup-selectbutton-container`;
|
|
241
243
|
|
|
244
|
+
|
|
245
|
+
const handleValueChange = (label : string) => {
|
|
246
|
+
|
|
247
|
+
if (onValueChange !== undefined && onValueChange !== null) {
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
if (restProps.options === undefined || restProps.options === null || restProps.options.length === 0) {
|
|
251
|
+
if (isMultiple)
|
|
252
|
+
onValueChange(0);
|
|
253
|
+
else
|
|
254
|
+
onValueChange(false);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
let index = 0;
|
|
258
|
+
for (let i=0;i<restProps.options.length;++i) {
|
|
259
|
+
if (label === restProps.options[i] ) {
|
|
260
|
+
index = i;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (isMultiple)
|
|
266
|
+
onValueChange(index);
|
|
267
|
+
else
|
|
268
|
+
onValueChange(index > 0);
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
}
|
|
277
|
+
|
|
242
278
|
return (
|
|
243
279
|
<div className="flex">
|
|
244
280
|
{
|
|
@@ -275,6 +311,7 @@ export const ToggleGroup: React.FC<ToggleGroupProps> = ({
|
|
|
275
311
|
onTouchStart={handleOnPressed}
|
|
276
312
|
onMouseUp={handleOnReleased}
|
|
277
313
|
onTouchEnd={handleOnReleased}
|
|
314
|
+
onChange={(e) => handleValueChange(e.value)}
|
|
278
315
|
/>
|
|
279
316
|
</div>
|
|
280
317
|
</div>
|