Skip to content

Commit e6f0a03

Browse files
committedJan 13, 2024
standalone callback added
1 parent 3b3b317 commit e6f0a03

File tree

7 files changed

+81
-25
lines changed

7 files changed

+81
-25
lines changed
 

‎.idea/workspace.xml

+24-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ npm i project-react-mvc
1212
[Form](https://github.com/kriit24/project-react-mvc/tree/master/docs/form)
1313
[Popup](https://github.com/kriit24/project-react-mvc/tree/master/docs/popup)
1414
[Promise](https://github.com/kriit24/project-react-mvc/tree/master/docs/promise)
15+
[Callback](https://github.com/kriit24/project-react-mvc/tree/master/docs/callback)

‎docs/callback/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# CALLBACK
2+
3+
## Usage
4+
5+
```
6+
import {Project} from 'project-react-mvc';
7+
8+
//this callback does not allow overwrite object params and function arguments
9+
Project.Callback(function (row, etc) {
10+
11+
setTimeout(() => {
12+
13+
console.log('APP-ARGS');
14+
console.log(pre(row));
15+
//console.log(pre(row2));
16+
console.log(this.seda);
17+
//console.log(this.init());
18+
console.log('END');
19+
20+
}, 5000);
21+
22+
}, this/null, {'see': 1}, {'etc...'});
23+
```

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "project-react-mvc",
3-
"version": "1.3.6",
3+
"version": "1.3.7",
44
"description": "Project React MVC Package where is implemented Form and Popup packages",
55
"main": "src/index.js",
66
"react-native": "src/index.js",

‎src/component/form/input.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ function FormInput(props) {
2626
props.value !== undefined && props.value ? props.value : '';
2727

2828
let selectionLength =
29-
globalValue[props.name] !== null ? globalValue[props.name].length : 0;
29+
globalValue[props.name] !== null ? globalValue[props.name].length : props.value.length;
3030

3131
setTimeout(() => {
3232
if (globalInputRef && !globalInputRef.isFocused()) {
3333
globalInputRef.focus();
34-
globalInputRef.setNativeProps({
35-
selection: {start: selectionLength, end: selectionLength},
36-
});
3734
}
3835
}, 150);
3936

@@ -48,6 +45,7 @@ function FormInput(props) {
4845
}}
4946
value={null}
5047
defaultValue={globalValue[props.name]}
48+
selection={{start: selectionLength, end: selectionLength}}
5149
innerRef={(ref) => {
5250
if (ref) {
5351
globalInputRef = Object.assign(ref, {props: props});
@@ -63,9 +61,10 @@ let editableTimeout = null;
6361

6462
function DblClickInput(props) {
6563

64+
let startSelection = (props.selection !== undefined ? props.selection : {'start': 0, 'end': 0});
6665
const [editable, setEditable] = useState(false);
6766
const [editableText, setEditableText] = useState(props.defaultValue !== null ? props.defaultValue : "");
68-
const [selection, setSelection] = useState({'start': 0, 'end': 0});
67+
const [selection, setSelection] = useState(startSelection);
6968

7069
return <TextInput
7170
{...props}
@@ -74,7 +73,7 @@ function DblClickInput(props) {
7473
ref={props.innerRef !== undefined ? props.innerRef : null}
7574
onChangeText={(text) => {
7675

77-
setSelection({'start': 0, 'end': 0});
76+
setSelection(startSelection);
7877
setEditableText(text);
7978
if( props.onChangeText ) props.onChangeText(text);
8079
}}
@@ -88,7 +87,7 @@ function DblClickInput(props) {
8887
setEditable(false);
8988
} else {
9089

91-
setSelection({'start': 0, 'end': 0});
90+
setSelection(startSelection);
9291
setEditable(true);
9392
editableTimeout = setTimeout(() => {
9493

‎src/component/project.callback.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default function ProjectCallback(){
2+
3+
let callback = arguments[0];
4+
let object = arguments[1];
5+
let args = [];
6+
7+
for (var i = 2; i < arguments.length; i++) {
8+
9+
args.push(arguments[i]);
10+
}
11+
12+
let priv = function(){
13+
14+
let callback = arguments[0];
15+
let args = arguments[1];
16+
callback.apply(this, [].concat(args));
17+
};
18+
19+
if( object )
20+
priv = priv.bind(Object.assign(Object.create(Object.getPrototypeOf(object)), object), callback, args);
21+
else
22+
priv = priv.bind(this, callback, args);
23+
priv();
24+
}

‎src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import ProjectValidate from './component/project.validate';
44
import Popup from './helper/popup';
55
import Loader from './helper/loader';
66
import ProjectPromise from "./component/project.promise";
7+
import ProjectCallback from "./component/project.callback";
78

89
const Project = {
910
React: ProjectReact,
1011
Form: ProjectForm,
1112
Validate: ProjectValidate,
1213
Popup: Popup,
1314
Promise: ProjectPromise,
15+
Callback: ProjectCallback,
1416
};
1517

1618
const App = ProjectApp;

0 commit comments

Comments
 (0)
Please sign in to comment.