Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010954
autocomplete.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
903 B
Referenced Files
None
Subscribers
None
autocomplete.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
tempstream
}
from
"tempstream"
;
import
{
PickFromListField
}
from
"../fields/pick-from-list.js"
;
import
{
FormControlContext
}
from
"./form-control.js"
;
import
{
SimpleInput
}
from
"./simple-input.js"
;
export
class
Autocomplete
extends
SimpleInput
<
string
|
null
>
{
constructor
(
public
field
:
PickFromListField
<
boolean
>
,
public
options
:
{
id
?:
string
;
label
?:
string
;
placeholder
?:
string
}
)
{
super
(
field
);
}
getListID
()
:
string
{
return
this
.
getID
()
+
"_list"
;
}
async
getInputAttributes
(
fctx
:
FormControlContext
)
{
return
{
...(
await
super
.
getInputAttributes
(
fctx
)),
list
:
this
.
getListID
(),
};
}
async
postInput
(
ctx
:
Context
)
{
return
tempstream
/* HTML */
`<datalist id="
${
this
.
getListID
()
}
">
${
(
await
this
.
field
.
generateOptions
(
ctx
)).
map
(
({
value
}
) => /* HTML */ `
<
option
>
$
{
value
}
<
/option>`
)}
<
/datalist>`;
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, May 7, 19:50 (23 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
625749
Default Alt Text
autocomplete.ts (903 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment