88 lines
1.8 KiB
TypeScript
88 lines
1.8 KiB
TypeScript
namespace formgen.ioc
|
|
{
|
|
|
|
/**
|
|
*/
|
|
export class class_ioc_map<type_value>
|
|
extends class_ioc_wrapper<Array<{first : string; second: type_value;}>, Record<string, type_value>>
|
|
implements interface_ioc<Record<string, type_value>>
|
|
{
|
|
|
|
/**
|
|
*/
|
|
public constructor(
|
|
element_input_factory : (() => interface_ioc<type_value>),
|
|
{
|
|
"label": label = null,
|
|
"handlers": handlers = [],
|
|
}
|
|
:
|
|
{
|
|
label ?: (null | string);
|
|
handlers ?: Array<type_handler<Record<string, type_value>>>;
|
|
}
|
|
=
|
|
{
|
|
}
|
|
)
|
|
{
|
|
super(
|
|
new class_ioc_list<{first : string; second : type_value;}>(
|
|
() => new class_ioc_wrapper<
|
|
Record<string, any>,
|
|
{first : string; second : type_value;}
|
|
>(
|
|
new class_ioc_group(
|
|
[
|
|
{
|
|
"name": "key",
|
|
"ioc": new class_ioc_text(
|
|
{
|
|
/**
|
|
* @todo parametrize
|
|
*/
|
|
"label": "Schlüssel",
|
|
}
|
|
),
|
|
"marked": true,
|
|
},
|
|
{
|
|
"name": "value",
|
|
"ioc": element_input_factory(),
|
|
"marked": true,
|
|
},
|
|
]
|
|
),
|
|
(value_inner) => ({"first": value_inner["key"], "second": value_inner["value"]}),
|
|
(value_outer) => ({"key": value_outer.first, "value": value_outer.second}),
|
|
),
|
|
{
|
|
"label": label,
|
|
/**
|
|
* @todo
|
|
*/
|
|
"handlers": [],
|
|
}
|
|
),
|
|
(value_inner) => Object.fromEntries(
|
|
value_inner.map(
|
|
entry => ([entry.first, entry.second])
|
|
)
|
|
),
|
|
(value_outer) => (
|
|
Object.entries(value_outer).map(
|
|
([key, value]) => ({"first": key, "second": (value as type_value)})
|
|
)
|
|
)
|
|
);
|
|
/*
|
|
this.element_input_factory = element_input_factory;
|
|
this.label = label;
|
|
this.notification = new trait_notification(handlers);
|
|
*/
|
|
}
|
|
|
|
}
|
|
|
|
}
|