Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7859814
component-input-single-reference.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
component-input-single-reference.ts
View Options
import
type
{
Context
}
from
"koa"
;
import
type
{
JDDContext
,
SingleReference
}
from
"@sealcode/jdd"
;
import
{
printArgPath
}
from
"./print-arg-path.js"
;
export
async
function
ComponentInputSingleReference
<
State
,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T
extends
SingleReference
<
any
>
>
({
ctx
,
arg_path
,
arg
,
value
,
onchange
,
makeJDDContext
,
}
:
{
ctx
:
Context
;
state
:
State
;
arg_path
:
string
[];
arg
:
T
;
value
:
string
;
onchange
?:
string
;
makeJDDContext
:
(
ctx
:
Context
)
=>
JDDContext
;
})
:
Promise
<
string
>
{
const
values
=
await
arg
.
getValues
(
makeJDDContext
(
ctx
));
const
ret
=
`<div>
<label>
${
arg_path
.
at
(
-
1
)
||
""
}
<select name="
${
`$
${
printArgPath
(
arg_path
)
}
`
}
" onchange="
${
onchange
||
""
}
">
${
values
.
sort
((
v1
,
v2
)
=>
(
v1
.
label
>
v2
.
label
?
1
:
-
1
))
.
map
(
(
v
)
=>
/* HTML */
`<option
value="
${
v
.
value
}
"
${
value
==
v
.
value
?
"selected"
:
""
}
>
${
v
.
label
}
</option>`
)
.
join
(
""
)
}
</select>
</label>
</div>`
;
return
ret
;
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, Aug 13, 17:06 (21 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
872190
Default Alt Text
component-input-single-reference.ts (1 KB)
Attached To
Mode
rJDDE jdd-editor
Attached
Detach File
Event Timeline
Log In to Comment