Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102553416
propsToClassKey.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Feb 21, 22:49
Size
960 B
Mime Type
text/x-java
Expires
Sun, Feb 23, 22:49 (2 d)
Engine
blob
Format
Raw Data
Handle
24359131
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
propsToClassKey.js
View Options
import
_objectWithoutProperties
from
"@babel/runtime/helpers/esm/objectWithoutProperties"
;
import
{
unstable_capitalize
as
capitalize
}
from
'@mui/utils'
;
function
isEmpty
(
string
)
{
return
string
.
length
===
0
;
}
/**
* Generates string classKey based on the properties provided. It starts with the
* variant if defined, and then it appends all other properties in alphabetical order.
* @param {object} props - the properties for which the classKey should be created.
*/
export
default
function
propsToClassKey
(
props
)
{
var
variant
=
props
.
variant
,
other
=
_objectWithoutProperties
(
props
,
[
"variant"
]);
var
classKey
=
variant
||
''
;
Object
.
keys
(
other
).
sort
().
forEach
(
function
(
key
)
{
if
(
key
===
'color'
)
{
classKey
+=
isEmpty
(
classKey
)
?
props
[
key
]
:
capitalize
(
props
[
key
]);
}
else
{
classKey
+=
""
.
concat
(
isEmpty
(
classKey
)
?
key
:
capitalize
(
key
)).
concat
(
capitalize
(
props
[
key
].
toString
()));
}
});
return
classKey
;
}
Event Timeline
Log In to Comment