Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22394619
hybrid.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
1 KB
Referenced Files
None
Subscribers
None
hybrid.ts
View Options
import
{
FlatTemplatable
,
tempstream
}
from
"tempstream"
;
import
{
FormControlContext
}
from
"./form-control.js"
;
import
{
FormFieldControl
}
from
"./form-field-control.js"
;
import
{
FormField
}
from
"../fields/field.js"
;
import
{
FormDataValue
}
from
"../form-types.js"
;
import
{
autoWrapInput
}
from
"../../utils/input-wrapper.js"
;
export
class
Hybrid
extends
FormFieldControl
{
constructor
(
public
main_field
:
FormField
,
public
subfields
:
Record
<
string
,
FormField
>
)
{
super
(
Object
.
values
(
subfields
));
for
(
const
[
field_name
,
field
]
of
Object
.
entries
(
subfields
))
{
field
.
setName
(
`
${
main_field
.
name
}
[
${
field_name
}
]`
);
}
}
async
render
(
fctx
:
FormControlContext
)
:
Promise
<
FlatTemplatable
>
{
const
raw_values
=
(
fctx
.
data
.
raw_values
[
this
.
main_field
.
name
]
||
{})
as
Record
<
string
,
FormDataValue
>
;
const
new_fctx
=
new
FormControlContext
(
fctx
.
ctx
,
{
raw_values
,
messages
:
[],
field_messages
:
{},
},
[],
fctx
.
field_name_prefix
,
fctx
.
form_id
,
fctx
.
validate
);
return
tempstream
`<fieldset><legend>
${
this
.
main_field
.
label
||
this
.
main_field
.
name
}
</legend>
${
Object
.
values
(
this
.
subfields
).
map
(
async
(
subfield
)
=>
tempstream
`
${
autoWrapInput
(
subfield
,
await
subfield
.
getControl
().
render
(
new_fctx
)
)
}
`
)
}
</fieldset>`
;
}
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 16:19 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1200174
Default Alt Text
hybrid.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline