Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22394857
input-wrapper.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
953 B
Referenced Files
None
Subscribers
None
input-wrapper.ts
View Options
import
{
FlatTemplatable
,
tempstream
}
from
"tempstream"
;
import
{
FormField
}
from
"../index.js"
;
import
{
toKebabCase
}
from
"js-convert-case"
;
export
function
getRequiredClass
(
isRequired
:
boolean
)
:
string
{
return
isRequired
?
"required"
:
""
;
}
function
getModifierClasses
(
modifiers
:
string
[])
{
return
modifiers
.
map
((
m
)
=>
"form-input__wrapper--"
+
m
).
join
(
" "
);
}
export
async
function
inputWrapper
(
type
:
string
,
modifiers
:
string
[],
input
:
FlatTemplatable
)
:
Promise
<
string
>
{
return
tempstream
/* HTML */
`<div
class="form-input form-input--type-
${
type
}
form-input__wrapper
${
getModifierClasses
(
modifiers
)
}
"
>
${
input
}
</div>`
;
}
export
async
function
autoWrapInput
(
field
:
FormField
,
input
:
FlatTemplatable
)
{
return
inputWrapper
(
toKebabCase
(
field
.
constructor
.
name
),
[
`type--`
+
toKebabCase
(
field
.
constructor
.
name
),
`name--`
+
toKebabCase
(
field
.
name
),
getRequiredClass
(
field
.
required
),
],
input
);
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 16:21 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1199901
Default Alt Text
input-wrapper.ts (953 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline