Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22393410
json.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
json.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
FormControlContext
}
from
"../controls/form-control.js"
;
import
{
Textarea
}
from
"../controls/textarea.js"
;
import
{
FormDataValue
}
from
"../form-types.js"
;
import
{
FieldParseResult
}
from
"./field.js"
;
import
{
SimpleFormField
}
from
"./simple-form-field.js"
;
export
class
JSONField
<
Required
extends
boolean
>
extends
SimpleFormField
<
Required
,
Textarea
,
Record
<
string
,
unknown
>
>
{
constructor
(
required
:
Required
)
{
super
(
required
,
"text"
);
}
getControl
()
:
Textarea
{
return
new
Textarea
(
this
);
}
public
getEmptyValue
()
:
Record
<
string
,
unknown
>
{
return
{};
}
async
parse
(
ctx
:
Context
,
raw_value
:
FormDataValue
)
:
Promise
<
FieldParseResult
<
Record
<
string
,
unknown
>>>
{
return
{
parsable
:
true
,
error
:
null
,
parsed_value
:
JSON
.
parse
(
raw_value
as
string
)
as
Record
<
string
,
unknown
>
,
};
}
async
getSealiousCreateValue
(
fctx
:
FormControlContext
)
:
Promise
<
Record
<
string
,
unknown
>
|
null
>
{
const
{
parsed
}
=
await
this
.
getParsedValue
(
fctx
.
ctx
,
fctx
.
data
.
raw_values
);
return
parsed
;
}
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 16:04 (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1200143
Default Alt Text
json.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline