ballerina-core 1.0.64 → 1.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/forms/domains/collection/domains/reference/state.ts +6 -6
- package/src/forms/domains/collection/domains/selection/state.ts +2 -2
- package/src/forms/domains/parser/domains/built-ins/state.ts +46 -20
- package/src/forms/domains/parser/domains/renderer/state.ts +7 -7
- package/src/forms/domains/parser/domains/validator/state.ts +0 -8
- package/src/forms/domains/parser/state.tsx +2 -3
- package/src/forms/domains/primitives/domains/enum/state.ts +5 -5
- package/src/forms/domains/primitives/domains/enum/template.tsx +1 -1
- package/src/forms/domains/primitives/domains/enum-multiselect/state.ts +1 -1
- package/src/forms/domains/primitives/domains/enum-multiselect/template.tsx +3 -3
- package/src/forms/domains/primitives/domains/searchable-infinite-stream-multiselect/template.tsx +3 -3
- package/src/infinite-data-stream/coroutines/builder.ts +1 -1
- package/src/infinite-data-stream/coroutines/infiniteLoader.ts +1 -1
- package/src/infinite-data-stream/coroutines/runner.ts +1 -1
- package/src/infinite-data-stream/state.ts +4 -4
- package/src/infinite-data-stream/template.tsx +1 -1
package/package.json
CHANGED
|
@@ -2,18 +2,18 @@ import { simpleUpdater } from "../../../../../../main";
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
export type CollectionReference = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Id: string;
|
|
6
|
+
DisplayValue: string;
|
|
7
7
|
source?:"enum"|"stream"
|
|
8
8
|
};
|
|
9
9
|
export const CollectionReference = {
|
|
10
|
-
Default: Object.assign((
|
|
11
|
-
|
|
10
|
+
Default: Object.assign((Id: string, DisplayValue: string, source?:"enum"|"stream"): CollectionReference => ({
|
|
11
|
+
Id, DisplayValue, source
|
|
12
12
|
}), {
|
|
13
13
|
empty: (): CollectionReference => CollectionReference.Default("", "")
|
|
14
14
|
}),
|
|
15
15
|
Updaters: {
|
|
16
|
-
...simpleUpdater<CollectionReference>()("
|
|
17
|
-
...simpleUpdater<CollectionReference>()("
|
|
16
|
+
...simpleUpdater<CollectionReference>()("Id"),
|
|
17
|
+
...simpleUpdater<CollectionReference>()("DisplayValue"),
|
|
18
18
|
}
|
|
19
19
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Sum, Value } from "../../../../../../main";
|
|
2
2
|
import { CollectionReference } from "../reference/state"
|
|
3
3
|
|
|
4
|
-
export type CollectionSelection<Element extends CollectionReference | Value
|
|
5
|
-
export const CollectionSelection = <Element extends CollectionReference | Value
|
|
4
|
+
export type CollectionSelection<Element extends CollectionReference | { Value: CollectionReference }> = Sum<Element, "no selection">;
|
|
5
|
+
export const CollectionSelection = <Element extends CollectionReference | { Value: CollectionReference }>() => Sum<Element, "no selection">();
|
|
@@ -5,6 +5,20 @@ import { BasicFun } from "../../../../../fun/state";
|
|
|
5
5
|
import { InjectedPrimitives, Maybe, ParsedType, TypeName } from "../../../../../../main";
|
|
6
6
|
import { ValueOrErrors } from "../../../../../collections/domains/valueOrErrors/state";
|
|
7
7
|
|
|
8
|
+
const sortObjectKeys = (obj: Record<string, any>) =>
|
|
9
|
+
Object.keys(obj)
|
|
10
|
+
.sort()
|
|
11
|
+
.reduce((sortedObj, key) => {
|
|
12
|
+
sortedObj[key] = obj[key]!;
|
|
13
|
+
return sortedObj;
|
|
14
|
+
}, {} as any);
|
|
15
|
+
|
|
16
|
+
const simpleMapKeyToIdentifer = (key: any): string => {
|
|
17
|
+
if(typeof key == "object")
|
|
18
|
+
return JSON.stringify(sortObjectKeys(key));
|
|
19
|
+
return JSON.stringify(key);
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
export const PrimitiveTypes =
|
|
9
23
|
[
|
|
10
24
|
"guid", //resolves to string
|
|
@@ -31,17 +45,18 @@ export type ApiConverter<T> = { fromAPIRawValue: BasicFun<any, T>, toAPIRawValu
|
|
|
31
45
|
export type ApiConverters<T extends {[key in keyof T]: {type: any, state: any}}> = {[key in keyof T]: ApiConverter<T[key]["type"]> } & BuiltInApiConverters
|
|
32
46
|
|
|
33
47
|
export type BuiltInApiConverters = {
|
|
34
|
-
"string": ApiConverter<string
|
|
35
|
-
"number": ApiConverter<number
|
|
36
|
-
"boolean": ApiConverter<boolean
|
|
37
|
-
"maybeBoolean": ApiConverter<boolean | undefined
|
|
38
|
-
"base64File": ApiConverter<string
|
|
39
|
-
"secret": ApiConverter<string
|
|
40
|
-
"Date": ApiConverter<Maybe<Date
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
48
|
+
"string": ApiConverter<string>;
|
|
49
|
+
"number": ApiConverter<number>;
|
|
50
|
+
"boolean": ApiConverter<boolean>;
|
|
51
|
+
"maybeBoolean": ApiConverter<boolean | undefined>;
|
|
52
|
+
"base64File": ApiConverter<string>;
|
|
53
|
+
"secret": ApiConverter<string>;
|
|
54
|
+
"Date": ApiConverter<Maybe<Date>>;
|
|
55
|
+
"unionCase": ApiConverter<CollectionReference>;
|
|
56
|
+
"SingleSelection": ApiConverter<CollectionSelection<CollectionReference | { Value: CollectionReference }>>;
|
|
57
|
+
"MultiSelection": ApiConverter<OrderedMap<string, CollectionReference>>;
|
|
58
|
+
"List": ApiConverter<List<any>>;
|
|
59
|
+
"Map": ApiConverter<List<[any, any]>>;
|
|
45
60
|
}
|
|
46
61
|
|
|
47
62
|
export type PrimitiveBuiltIn = { renderers: Set<keyof BuiltIns["renderers"]>, defaultValue: any }
|
|
@@ -141,7 +156,8 @@ export const defaultValue = <T>(types: Map<TypeName, ParsedType<T>>, builtIns: B
|
|
|
141
156
|
throw Error(`cannot find type ${JSON.stringify(t)} when resolving defaultValue`)
|
|
142
157
|
}
|
|
143
158
|
|
|
144
|
-
export const fromAPIRawValue = <T extends { [key in keyof T]: { type: any; state: any; } }>(t: ParsedType<T>, types: Map<TypeName, ParsedType<T>>, builtIns: BuiltIns, converters: ApiConverters<T>, injectedPrimitives?: InjectedPrimitives<T>) => (raw: any): any => {
|
|
159
|
+
export const fromAPIRawValue = <T extends { [key in keyof T]: { type: any; state: any; } }>(t: ParsedType<T>, types: Map<TypeName, ParsedType<T>>, builtIns: BuiltIns, converters: ApiConverters<T>, injectedPrimitives?: InjectedPrimitives<T>) => (raw: any): any => {
|
|
160
|
+
|
|
145
161
|
if (raw == undefined) {
|
|
146
162
|
return defaultValue(types, builtIns, injectedPrimitives)(t)
|
|
147
163
|
}
|
|
@@ -150,12 +166,15 @@ export const fromAPIRawValue = <T extends { [key in keyof T]: { type: any; state
|
|
|
150
166
|
return converters[t.value].fromAPIRawValue(raw)
|
|
151
167
|
}
|
|
152
168
|
if(t.kind == "union") {
|
|
153
|
-
return
|
|
169
|
+
return fromAPIRawValue({kind: "unionCase", name: "", fields: {} as ParsedType<T>}, types, builtIns, converters, injectedPrimitives)(raw)
|
|
170
|
+
}
|
|
171
|
+
if(t.kind == "unionCase") {
|
|
172
|
+
return converters[t.kind].fromAPIRawValue(raw)
|
|
154
173
|
}
|
|
155
174
|
if (t.kind == "application") {
|
|
156
175
|
if (t.value == "SingleSelection") {
|
|
157
|
-
return CollectionSelection().Updaters.left(
|
|
158
|
-
|
|
176
|
+
return CollectionSelection().Updaters.left(fromAPIRawValue(t.args[0], types, builtIns, converters, injectedPrimitives))
|
|
177
|
+
(converters[t.value].fromAPIRawValue(raw))
|
|
159
178
|
}
|
|
160
179
|
if (t.value == "MultiSelection") {
|
|
161
180
|
return converters["MultiSelection"].fromAPIRawValue(raw).map(fromAPIRawValue(t.args[0], types, builtIns, converters, injectedPrimitives))
|
|
@@ -196,8 +215,13 @@ export const fromAPIRawValue = <T extends { [key in keyof T]: { type: any; state
|
|
|
196
215
|
export const toAPIRawValue = <T extends { [key in keyof T]: { type: any; state: any; }}>(t: ParsedType<T>, types: Map<TypeName, ParsedType<T>>, builtIns: BuiltIns, converters: ApiConverters<T>, injectedPrimitives?: InjectedPrimitives<T>) => (raw: any, formState: any) : ValueOrErrors<any, string> => {
|
|
197
216
|
if (t.kind == "primitive")
|
|
198
217
|
return ValueOrErrors.Operations.Return(converters[t.value as string | keyof T].toAPIRawValue([raw, formState.modifiedByUser]))
|
|
218
|
+
|
|
199
219
|
if(t.kind == "union"){
|
|
200
|
-
return
|
|
220
|
+
return toAPIRawValue({kind: "unionCase", name: "", fields: {} as ParsedType<T>}, types, builtIns, converters, injectedPrimitives)(raw, formState)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if(t.kind == "unionCase") {
|
|
224
|
+
return ValueOrErrors.Operations.Return(converters[t.kind].toAPIRawValue([raw, formState.modifiedByUser]))
|
|
201
225
|
}
|
|
202
226
|
if (t.kind == "application") {
|
|
203
227
|
if (t.value == "SingleSelection") {
|
|
@@ -221,7 +245,7 @@ export const toAPIRawValue = <T extends { [key in keyof T]: { type: any; state:
|
|
|
221
245
|
))))
|
|
222
246
|
}
|
|
223
247
|
if (t.value == "Map") {
|
|
224
|
-
const
|
|
248
|
+
const converterResult = List(converters[t.value].toAPIRawValue([raw, formState.modifiedByUser]))
|
|
225
249
|
const parsedMap: List<ValueOrErrors<{key: ValueOrErrors<any, any>, value: ValueOrErrors<any, any>}, any>> = converterResult.map((keyValue: any, index: number) => {
|
|
226
250
|
return toAPIRawValue(
|
|
227
251
|
t.args[0],
|
|
@@ -243,12 +267,14 @@ export const toAPIRawValue = <T extends { [key in keyof T]: { type: any; state:
|
|
|
243
267
|
)
|
|
244
268
|
|
|
245
269
|
const nonUniqueKeyErrors = parsedMap.filter(_ => _.kind == "value").reduce((acc, _) => {
|
|
246
|
-
const
|
|
247
|
-
acc.ids.contains(id) ? acc.errors = acc.errors.push(ValueOrErrors.Default.throw(List([`Keys in the map are not unique
|
|
270
|
+
const id = simpleMapKeyToIdentifer(_.value.key)
|
|
271
|
+
acc.ids.contains(id) ? acc.errors = acc.errors.push(ValueOrErrors.Default.throw(List([`Keys in the map are not unique`]))) : acc.ids = acc.ids.push(id)
|
|
248
272
|
return acc
|
|
249
273
|
}, {ids: List<string>(), errors: List<ValueOrErrors<any, string>>()}).errors
|
|
250
274
|
|
|
251
|
-
return ValueOrErrors.Operations.All(parsedMap.concat(nonUniqueKeyErrors))
|
|
275
|
+
return ValueOrErrors.Operations.All(parsedMap.concat(nonUniqueKeyErrors)).Then(parsedMap =>
|
|
276
|
+
ValueOrErrors.Default.return(parsedMap.toArray())
|
|
277
|
+
)
|
|
252
278
|
}
|
|
253
279
|
}
|
|
254
280
|
|
|
@@ -212,7 +212,7 @@ export const ParsedRenderer = {
|
|
|
212
212
|
if (viewKind == "boolean")
|
|
213
213
|
return BooleanForm<any & FormLabel, Unit>()
|
|
214
214
|
.withView(formViews[viewKind][viewName]())
|
|
215
|
-
.mapContext<any & CommonFormState & Value<boolean>>(_ => ({ ..._, label, tooltip, details }))
|
|
215
|
+
.mapContext<any & CommonFormState & Value<boolean>>(_ => ({ ..._, label, tooltip, details }))
|
|
216
216
|
if (viewKind == "date")
|
|
217
217
|
return DateForm<any & FormLabel, Unit>()
|
|
218
218
|
.withView(formViews[viewKind][viewName]())
|
|
@@ -226,18 +226,18 @@ export const ParsedRenderer = {
|
|
|
226
226
|
.withView(formViews[viewKind][viewName]())
|
|
227
227
|
.mapContext<any & CommonFormState & Value<string>>(_ => ({ ..._, label, tooltip, details }))
|
|
228
228
|
if (viewKind == "enumSingleSelection" && rendererConfig.kind == "enum")
|
|
229
|
-
return EnumForm<any & FormLabel & BaseEnumContext<Value
|
|
229
|
+
return EnumForm<any & FormLabel & BaseEnumContext<{ Value: CollectionReference }>, Unit, { Value: CollectionReference }>()
|
|
230
230
|
.withView(formViews[viewKind][viewName]())
|
|
231
|
-
.mapContext<any & EnumFormState<any & BaseEnumContext<Value
|
|
231
|
+
.mapContext<any & EnumFormState<any & BaseEnumContext<{ Value: CollectionReference }>, { Value: CollectionReference }> & Value<CollectionSelection<{ Value: CollectionReference }>>>(_ => ({
|
|
232
232
|
..._, label, tooltip, details, getOptions: () => {
|
|
233
|
-
return ((enumOptionsSources as any)(rendererConfig.options)() as Promise<any>).then(options => Map(options.map((o:
|
|
233
|
+
return ((enumOptionsSources as any)(rendererConfig.options)() as Promise<any>).then(options => Map(options.map((o: CollectionReference) => [o.Id, {Value: o}])))
|
|
234
234
|
}
|
|
235
235
|
}))
|
|
236
236
|
if (viewKind == "enumMultiSelection" && rendererConfig.kind == "enum")
|
|
237
|
-
return EnumMultiselectForm<any & FormLabel & BaseEnumContext<Value
|
|
237
|
+
return EnumMultiselectForm<any & FormLabel & BaseEnumContext<{ Value: CollectionReference }>, Unit, { Value: CollectionReference }>()
|
|
238
238
|
.withView(formViews[viewKind][viewName]() )
|
|
239
|
-
.mapContext<any & EnumFormState<any & BaseEnumContext<Value
|
|
240
|
-
..._, label, details, tooltip, getOptions: () => ((enumOptionsSources as any)(rendererConfig.options)() as Promise<any>).then(options => OrderedMap(options.map((o:
|
|
239
|
+
.mapContext<any & EnumFormState<any & BaseEnumContext<{ Value: CollectionReference }>, { Value: CollectionReference }> & Value<OrderedMap<Guid, CollectionReference>>>(_ => ({
|
|
240
|
+
..._, label, details, tooltip, getOptions: () => ((enumOptionsSources as any)(rendererConfig.options)() as Promise<any>).then(options => OrderedMap(options.map((o: CollectionReference) => [o.Id, {Value: o}])))
|
|
241
241
|
}))
|
|
242
242
|
if (viewKind == "streamSingleSelection")
|
|
243
243
|
return SearchableInfiniteStreamForm<CollectionReference, any & FormLabel, Unit>()
|
|
@@ -181,10 +181,6 @@ export const FormsConfig = {
|
|
|
181
181
|
Object.entries(form.fields).forEach(([fieldName, field]: [fieldName: string, field: any]) =>
|
|
182
182
|
{
|
|
183
183
|
const fieldType = formType.fields.get(fieldName)!
|
|
184
|
-
if(fieldType.kind == "application" && fieldType.value == "List" ){
|
|
185
|
-
console.debug("parsing field", fieldName, field)
|
|
186
|
-
console.debug('fieldType', formType.fields.get(fieldName)!);
|
|
187
|
-
}
|
|
188
184
|
|
|
189
185
|
const bwcompatiblefield = fieldType.kind == "application" && fieldType.value == "List" && typeof field.elementRenderer == "string" ? {
|
|
190
186
|
renderer: field.renderer,
|
|
@@ -200,10 +196,6 @@ export const FormsConfig = {
|
|
|
200
196
|
}
|
|
201
197
|
}: field
|
|
202
198
|
|
|
203
|
-
if(fieldType.kind == "application" && fieldType.value == "List" ){
|
|
204
|
-
console.debug('bwcompatiblefield', bwcompatiblefield);
|
|
205
|
-
|
|
206
|
-
}
|
|
207
199
|
return parsedForm.fields = parsedForm.fields.set(fieldName, ParsedRenderer.Operations.ParseRenderer(fieldType, bwcompatiblefield, parsedTypes))
|
|
208
200
|
}
|
|
209
201
|
)
|
|
@@ -121,7 +121,7 @@ export type EntityApis = {
|
|
|
121
121
|
export type EnumName = string
|
|
122
122
|
|
|
123
123
|
|
|
124
|
-
export type EnumOptionsSources = BasicFun<EnumName, BasicFun<Unit, Promise<Array<
|
|
124
|
+
export type EnumOptionsSources = BasicFun<EnumName, BasicFun<Unit, Promise<Array<CollectionReference>>>>
|
|
125
125
|
export const parseForms =
|
|
126
126
|
<LeafPredicates, T extends { [key in keyof T]: { type: any; state: any; }; },>(
|
|
127
127
|
builtIns: BuiltIns,
|
|
@@ -243,8 +243,7 @@ export const parseForms =
|
|
|
243
243
|
const initialState = parsedForm.initialFormState
|
|
244
244
|
const api = {
|
|
245
245
|
get: (id: string) => entityApis.get(launcher.api)(id).then((raw: any) => {
|
|
246
|
-
|
|
247
|
-
return x
|
|
246
|
+
return fromAPIRawValue(parsedForm.formDef.type , formsConfig.types, builtIns, apiConverters, injectedPrimitives)(raw)
|
|
248
247
|
}),
|
|
249
248
|
update: (id: any, parsed: any) => {
|
|
250
249
|
return parsed.kind =="errors" ? Promise.reject(parsed.errors) : entityApis.update(launcher.api)(id, parsed.value)
|
|
@@ -8,17 +8,17 @@ import { FormLabel } from "../../../singleton/domains/form-label/state";
|
|
|
8
8
|
import { OnChange, CommonFormState } from "../../../singleton/state";
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
export type BaseEnumContext<Element extends Value
|
|
12
|
-
export type EnumFormState<Context, Element extends Value
|
|
11
|
+
export type BaseEnumContext<Element extends { Value: CollectionReference }> = { getOptions:() => Promise<OrderedMap<Guid, Element>> }
|
|
12
|
+
export type EnumFormState<Context, Element extends { Value: CollectionReference }> =
|
|
13
13
|
{ commonFormState: CommonFormState,
|
|
14
14
|
customFormState: { options: Synchronized<Unit, OrderedMap<Guid, Element>>; }; };
|
|
15
|
-
export const EnumFormState = <Context extends BaseEnumContext<Value
|
|
16
|
-
Default: (): EnumFormState<Context, Value
|
|
15
|
+
export const EnumFormState = <Context extends BaseEnumContext<{ Value: Element }>, Element extends CollectionReference>() => ({
|
|
16
|
+
Default: (): EnumFormState<Context, { Value: Element }> => ({
|
|
17
17
|
commonFormState: CommonFormState.Default(),
|
|
18
18
|
customFormState: { options: Synchronized.Default(unit) }
|
|
19
19
|
}),
|
|
20
20
|
});
|
|
21
|
-
export type EnumView<Context extends FormLabel & BaseEnumContext<Element>, Element extends Value
|
|
21
|
+
export type EnumView<Context extends FormLabel & BaseEnumContext<Element>, Element extends { Value: CollectionReference }, ForeignMutationsExpected> = View<
|
|
22
22
|
Context & Value<CollectionSelection<Element>> & EnumFormState<Context, Element> &
|
|
23
23
|
{ activeOptions: "loading" | Array<Element>; } & { disabled:boolean }, EnumFormState<Context, Element>,
|
|
24
24
|
ForeignMutationsExpected & {
|
|
@@ -9,7 +9,7 @@ import { FieldValidation, FieldValidationWithPath, FormValidatorSynchronized, On
|
|
|
9
9
|
import { BaseEnumContext, EnumFormState, EnumView } from "./state";
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
export const EnumForm = <Context extends FormLabel & BaseEnumContext<Element>, ForeignMutationsExpected, Element extends Value
|
|
12
|
+
export const EnumForm = <Context extends FormLabel & BaseEnumContext<Element>, ForeignMutationsExpected, Element extends { Value: CollectionReference }>(
|
|
13
13
|
validation?: BasicFun<CollectionSelection<Element>, Promise<FieldValidation>>
|
|
14
14
|
) => {
|
|
15
15
|
const Co = CoTypedFactory<Context & Value<CollectionSelection<Element>> & { disabled:boolean }, EnumFormState<Context, Element>>()
|
|
@@ -8,7 +8,7 @@ import { OnChange } from "../../../singleton/state";
|
|
|
8
8
|
import { BaseEnumContext, EnumFormState } from "../enum/state";
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
export type EnumMultiselectView<Context extends FormLabel & BaseEnumContext<Element>, Element extends Value
|
|
11
|
+
export type EnumMultiselectView<Context extends FormLabel & BaseEnumContext<Element>, Element extends { Value: CollectionReference }, ForeignMutationsExpected> = View<
|
|
12
12
|
Context & Value<OrderedMap<Guid, Element>> & EnumFormState<Context, Element> & {
|
|
13
13
|
selectedIds: Array<Guid>;
|
|
14
14
|
activeOptions: "loading" | Array<Element>;
|
|
@@ -9,7 +9,7 @@ import { BaseEnumContext, EnumFormState } from "../enum/state";
|
|
|
9
9
|
import { EnumMultiselectView } from "./state";
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
export const EnumMultiselectForm = <Context extends FormLabel & BaseEnumContext<Element>, ForeignMutationsExpected, Element extends Value
|
|
12
|
+
export const EnumMultiselectForm = <Context extends FormLabel & BaseEnumContext<Element>, ForeignMutationsExpected, Element extends { Value: CollectionReference }>(
|
|
13
13
|
validation?: BasicFun<OrderedMap<Guid, Element>, Promise<FieldValidation>>
|
|
14
14
|
) => {
|
|
15
15
|
const Co = CoTypedFactory<Context & Value<OrderedMap<Guid, Element>> & EnumFormState<Context, Element> & { disabled:boolean }, EnumFormState<Context, Element>>()
|
|
@@ -17,7 +17,7 @@ export const EnumMultiselectForm = <Context extends FormLabel & BaseEnumContext<
|
|
|
17
17
|
<props.view {...props}
|
|
18
18
|
context={{
|
|
19
19
|
...props.context,
|
|
20
|
-
selectedIds: props.context.value.map(_ => _.
|
|
20
|
+
selectedIds: props.context.value.map(_ => _.Value.Id).valueSeq().toArray(),
|
|
21
21
|
activeOptions: !AsyncState.Operations.hasValue(props.context.customFormState.options.sync) ? "loading"
|
|
22
22
|
: props.context.customFormState.options.sync.value.valueSeq().toArray()
|
|
23
23
|
}}
|
|
@@ -30,7 +30,7 @@ export const EnumMultiselectForm = <Context extends FormLabel & BaseEnumContext<
|
|
|
30
30
|
.flatMap(_ => {
|
|
31
31
|
const selectedItem = options.get(_);
|
|
32
32
|
if (selectedItem != undefined) {
|
|
33
|
-
const item: [string, Element] = [selectedItem.
|
|
33
|
+
const item: [string, Element] = [selectedItem.Value.Id, selectedItem];
|
|
34
34
|
return [item];
|
|
35
35
|
}
|
|
36
36
|
return [];
|
package/src/forms/domains/primitives/domains/searchable-infinite-stream-multiselect/template.tsx
CHANGED
|
@@ -93,9 +93,9 @@ export const InfiniteMultiselectDropdownForm = <Element extends CollectionRefere
|
|
|
93
93
|
),
|
|
94
94
|
toggleSelection: element =>
|
|
95
95
|
props.foreignMutations.onChange(
|
|
96
|
-
props.context.value.has(element.
|
|
97
|
-
OrderedMapRepo.Updaters.remove(element.
|
|
98
|
-
OrderedMapRepo.Updaters.set(element.
|
|
96
|
+
props.context.value.has(element.Id) ?
|
|
97
|
+
OrderedMapRepo.Updaters.remove(element.Id) :
|
|
98
|
+
OrderedMapRepo.Updaters.set(element.Id, element),
|
|
99
99
|
List()),
|
|
100
100
|
}}
|
|
101
101
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CoTypedFactory } from "../../coroutines/builder";
|
|
2
2
|
import { InfiniteStreamReadonlyState, InfiniteStreamWritableState } from "../state";
|
|
3
3
|
|
|
4
|
-
export const StreamCo = <Element extends {
|
|
4
|
+
export const StreamCo = <Element extends { Id: string }>() =>
|
|
5
5
|
CoTypedFactory<
|
|
6
6
|
InfiniteStreamReadonlyState,
|
|
7
7
|
InfiniteStreamWritableState<Element>
|
|
@@ -3,7 +3,7 @@ import { replaceWith } from "../../fun/domains/updater/domains/replaceWith/state
|
|
|
3
3
|
import { InfiniteStreamState, StreamPosition } from "../state";
|
|
4
4
|
import { StreamCo } from "./builder";
|
|
5
5
|
|
|
6
|
-
export const InfiniteStreamLoader = <Element extends {
|
|
6
|
+
export const InfiniteStreamLoader = <Element extends { Id: string }>() => {
|
|
7
7
|
const Co = StreamCo<Element>();
|
|
8
8
|
const updaters = InfiniteStreamState<Element>().Updaters;
|
|
9
9
|
// const operations = InfiniteStreamState<Element>().Operations;
|
|
@@ -3,7 +3,7 @@ import { StreamCo } from "./builder";
|
|
|
3
3
|
import { Loader } from "./infiniteLoader";
|
|
4
4
|
|
|
5
5
|
export const StreamDataLoader =
|
|
6
|
-
<Element extends {
|
|
6
|
+
<Element extends { Id: string }, foreignMutations>() => {
|
|
7
7
|
const operations = InfiniteStreamState<Element>().Operations;
|
|
8
8
|
const LoaderTemplate = StreamCo<Element>().Template<foreignMutations>(Loader<Element>(), {
|
|
9
9
|
runFilter:props => operations.shouldCoroutineRun(props.context)
|
|
@@ -8,7 +8,7 @@ import { BasicFun } from "../fun/state";
|
|
|
8
8
|
|
|
9
9
|
export type StreamingStatus = "reload" | "loadMore" | false;
|
|
10
10
|
|
|
11
|
-
type Identifiable = {
|
|
11
|
+
type Identifiable = { Id: string };
|
|
12
12
|
|
|
13
13
|
export type StreamPosition = {
|
|
14
14
|
chunkSize: number;
|
|
@@ -68,12 +68,12 @@ export const StreamPosition = {
|
|
|
68
68
|
|
|
69
69
|
export type Chunk<Element extends Identifiable> = {
|
|
70
70
|
hasMoreValues: boolean;
|
|
71
|
-
data: OrderedMap<Element["
|
|
71
|
+
data: OrderedMap<Element["Id"], Element>;
|
|
72
72
|
};
|
|
73
73
|
export const Chunk = <Element extends Identifiable>() => ({
|
|
74
74
|
Default:(
|
|
75
75
|
hasMoreValues: boolean,
|
|
76
|
-
data: OrderedMap<Element["
|
|
76
|
+
data: OrderedMap<Element["Id"], Element>,
|
|
77
77
|
) : Chunk<Element> => ({
|
|
78
78
|
hasMoreValues, data
|
|
79
79
|
})
|
|
@@ -171,5 +171,5 @@ export const InfiniteStreamState = <Element extends Identifiable>() => ({
|
|
|
171
171
|
});
|
|
172
172
|
|
|
173
173
|
export type InfiniteStreamReadonlyState = Unit;
|
|
174
|
-
export type InfiniteStreamWritableState<Element extends {
|
|
174
|
+
export type InfiniteStreamWritableState<Element extends { Id: string }> =
|
|
175
175
|
InfiniteStreamState<Element>;
|
|
@@ -4,7 +4,7 @@ import { StreamDataLoader } from "./coroutines/runner";
|
|
|
4
4
|
import { InfiniteStreamReadonlyState, InfiniteStreamWritableState } from "./state";
|
|
5
5
|
|
|
6
6
|
export const InfiniteStreamTemplate =
|
|
7
|
-
<Element extends {
|
|
7
|
+
<Element extends { Id: string }>() => Template.Default<
|
|
8
8
|
InfiniteStreamReadonlyState,
|
|
9
9
|
InfiniteStreamWritableState<Element>,
|
|
10
10
|
Unit
|