Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22399095
autocomplete.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
902 B
Referenced Files
None
Subscribers
None
autocomplete.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
PickFromListField
}
from
"../fields/pick-from-list.js"
;
import
{
FormDataValue
}
from
"../form-types.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
/* HTML */
`<datalist id="
${
this
.
getListID
()
}
">
${
(
await
this
.
field
.
generateOptions
(
ctx
)).
map
(
({
value
}
) => /* HTML */ `
<
option
>
$
{
value
}
<
/option>`
)}
<
/datalist>`;
}
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 17:29 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1200953
Default Alt Text
autocomplete.ts (902 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline