Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
react-vanilla
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
react-vanilla
Commits
8ef62f12
Commit
8ef62f12
authored
Oct 11, 2025
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add TextArea component, add Store persistent storage
parent
c9ee2023
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
2 deletions
+63
-2
Cmp.js
Cmp.js
+31
-0
Store.js
Store.js
+32
-2
No files found.
Cmp.js
View file @
8ef62f12
...
@@ -151,6 +151,36 @@
...
@@ -151,6 +151,36 @@
D
.
h
(
'span'
,
{
cls
:
"cmp-color--title"
},
cfg
.
label
)
D
.
h
(
'span'
,
{
cls
:
"cmp-color--title"
},
cfg
.
label
)
:
null
)
:
null
)
);
);
});
D
.
Field
.
TextArea
=
D
.
declare
(
'Field.TextArea'
,
(
cfg
)
=>
{
let
changeHandler
=
cfg
.
onchange
||
cfg
.
onclick
;
var
input
=
D
.
h
(
'textarea'
,
{
cls
:
"text--input"
,
type
:
"text"
,
"aria-label"
:
"Change value"
});
if
(
cfg
.
bind
){
cfg
.
bind
.
hook
(
val
=>
{
input
.
value
=
val
||
''
;
changeHandler
&&
changeHandler
(
val
||
''
);
});
});
};
var
change
=
Store
.
debounce
(
function
(
e
){
var
val
=
input
.
value
;
cfg
.
bind
.
set
(
val
)
},
5
);
'input,change,click,mouseup'
.
split
(
','
)
.
map
(
a
=>
a
.
trim
())
.
forEach
(
evt
=>
input
.
addEventListener
(
evt
,
change
));
return
D
.
h
(
'label'
,
{
cls
:
clsBuilder
(
"cmp-textarea"
,
cfg
),
title
:
cfg
.
alt
||
"Change text"
,
renderTo
:
cfg
.
renderTo
},
(
cfg
.
label
?
D
.
h
(
'span'
,
{
cls
:
"cmp-text--title"
},
cfg
.
label
)
:
null
),
input
);
});
})();
})();
\ No newline at end of file
Store.js
View file @
8ef62f12
...
@@ -574,8 +574,11 @@ Store.SaveInterface.LocalStorage.prototype = {
...
@@ -574,8 +574,11 @@ Store.SaveInterface.LocalStorage.prototype = {
var
data
;
var
data
;
try
{
try
{
data
=
JSON
.
parse
(
localStorage
.
getItem
(
this
.
key
)
);
data
=
JSON
.
parse
(
localStorage
.
getItem
(
this
.
key
)
);
}
catch
(
e
){}
cb
&&
cb
(
false
,
data
||
{});
cb
&&
cb
(
false
,
data
||
{});
}
catch
(
e
){
cb
&&
cb
(
true
,
{});
}
return
data
;
return
data
;
},
},
// Should support full save if arguments.length === 0
// Should support full save if arguments.length === 0
...
@@ -584,7 +587,34 @@ Store.SaveInterface.LocalStorage.prototype = {
...
@@ -584,7 +587,34 @@ Store.SaveInterface.LocalStorage.prototype = {
}
}
};
};
const
StoreBinding
=
function
(
store
,
key
){
let
_saveID
=
1
;
Store
.
Persistent
=
function
(
data
,
key
,
storeInterface
){
storeInterface
=
storeInterface
||
Store
.
SaveInterface
.
LocalStorage
;
key
=
key
||
'persistent_'
+
_saveID
++
;
var
fakeStore
=
{
_props
:
{}};
var
ifaceInstance
=
new
storeInterface
(
key
,
fakeStore
);
ifaceInstance
.
load
(
function
(
err
,
loadedData
){
var
shouldSave
=
false
;
if
(
err
){
if
(
typeof
data
!==
'object'
){
throw
new
Error
(
'Persistent data is not an object'
);
}
shouldSave
=
true
;
}
else
{
for
(
var
k
in
loadedData
){
data
[
k
].
set
(
loadedData
[
k
]);
}
}
Store
.
sub
(
data
,
function
(
data
){
for
(
var
k
in
data
){
fakeStore
.
_props
[
k
]
=
data
[
k
];
}
ifaceInstance
.
save
();
},
!
shouldSave
);
});
}
var
StoreBinding
=
function
(
store
,
key
){
this
.
store
=
store
;
this
.
store
=
store
;
this
.
key
=
key
;
this
.
key
=
key
;
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment