Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98169882
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, Jan 10, 15:57
Size
992 B
Mime Type
text/x-java
Expires
Sun, Jan 12, 15:57 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
23515170
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
propsToClassKey.js
View Options
import
_objectWithoutPropertiesLoose
from
"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"
;
const
_excluded
=
[
"variant"
];
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
)
{
const
{
variant
}
=
props
,
other
=
_objectWithoutPropertiesLoose
(
props
,
_excluded
);
let
classKey
=
variant
||
''
;
Object
.
keys
(
other
).
sort
().
forEach
(
key
=>
{
if
(
key
===
'color'
)
{
classKey
+=
isEmpty
(
classKey
)
?
props
[
key
]
:
capitalize
(
props
[
key
]);
}
else
{
classKey
+=
`
$
{
isEmpty
(
classKey
)
?
key
:
capitalize
(
key
)}
$
{
capitalize
(
props
[
key
].
toString
())}
`
;
}
});
return
classKey
;
}
Event Timeline
Log In to Comment