ballerina-core 1.0.41 → 1.0.44

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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ballerina-core",
3
3
  "author": "Dr. Giuseppe Maggiore",
4
4
  "private": false,
5
- "version": "1.0.41",
5
+ "version": "1.0.44",
6
6
  "main": "main.ts",
7
7
  "dependencies": {
8
8
  "immutable": "^5.0.0-beta.5",
@@ -69,8 +69,8 @@ export const builtInsFromFieldViews = (fieldViews: any): BuiltIns => {
69
69
  ["number", { renderers: Set(["number"]), defaultValue: 0 }] as [string, PrimitiveBuiltIn],
70
70
  ["boolean", { renderers: Set(["boolean"]), defaultValue: false }],
71
71
  ["maybeBoolean", { renderers: Set(["maybeBoolean"]), defaultValue: undefined }] as [string, PrimitiveBuiltIn],
72
- ["date", { renderers: Set(["date"]), defaultValue: new Date(Date.now()) }] as [string, PrimitiveBuiltIn],
73
- ["Date", { renderers: Set(["date"]), defaultValue: new Date(Date.now()) }] as [string, PrimitiveBuiltIn],
72
+ ["date", { renderers: Set(["date"]), defaultValue: undefined }] as [string, PrimitiveBuiltIn],
73
+ ["Date", { renderers: Set(["date"]), defaultValue: undefined }] as [string, PrimitiveBuiltIn],
74
74
  ["CollectionReference", { renderers: Set(["enumSingleSelection", "enumMultiSelection", "streamSingleSelection", "streamMultiSelection"]), defaultValue: CollectionReference.Default("", "") }] as [string, PrimitiveBuiltIn],
75
75
  ["base64File", { renderers: Set(["base64File"]), defaultValue: "" }] as [string, PrimitiveBuiltIn],
76
76
  ["secret", { renderers: Set(["secret"]), defaultValue: "" }] as [string, PrimitiveBuiltIn],
@@ -1,5 +1,5 @@
1
1
  import { List, Map, OrderedMap, OrderedSet, Set } from "immutable";
2
- import { BoolExpr, Unit, PromiseRepo, Guid, LeafPredicatesEvaluators, Predicate, FormsConfig, BuiltIns, FormDef, Sum, BasicFun, Template, unit, EditFormState, EditFormTemplate, ApiErrors, CreateFormTemplate, EntityFormTemplate, SharedFormState, CreateFormState, Entity, EditFormContext, CreateFormContext, MappedEntityFormTemplate, Mapping, FormValidationResult, Synchronized, simpleUpdater, PrimitiveType, GenericType, ApiConverter, TypeName, ListFieldState, ListForm, TypeDefinition, BuiltInApiConverters, defaultValue, fromAPIRawValue, toAPIRawValue, EditFormForeignMutationsExpected, MapFieldState, MapForm, Type, FieldConfig, Base64FileForm, SecretForm, InjectedPrimitives, Injectables, ApiConverters } from "../../../../main";
2
+ import { BoolExpr, Unit, Guid, LeafPredicatesEvaluators, Predicate, FormsConfig, BuiltIns, FormDef, Sum, BasicFun, Template, unit, EditFormState, EditFormTemplate, ApiErrors, CreateFormTemplate, EntityFormTemplate, SharedFormState, CreateFormState, Entity, EditFormContext, CreateFormContext, MappedEntityFormTemplate, Mapping, Synchronized, simpleUpdater, TypeName, ListFieldState, ListForm, TypeDefinition, BuiltInApiConverters, defaultValue, fromAPIRawValue, toAPIRawValue, EditFormForeignMutationsExpected, MapFieldState, MapForm, Type, FieldConfig, Base64FileForm, SecretForm, InjectedPrimitives, Injectables, ApiConverters, Maybe } from "../../../../main";
3
3
  import { Value } from "../../../value/state";
4
4
  import { CollectionReference } from "../collection/domains/reference/state";
5
5
  import { CollectionSelection } from "../collection/domains/selection/state";
@@ -37,7 +37,7 @@ export const FieldView = //<Context, FieldViews extends DefaultFieldViews, EnumF
37
37
  if (viewType == "date")
38
38
  return DateForm<any & FormLabel, Unit>()
39
39
  .withView(((fieldViews as any)[viewType] as any)[viewName]() as any)
40
- .mapContext<any & DateFormState & Value<Date>>(_ => ({ ..._, label: label, tooltip })) as any
40
+ .mapContext<any & DateFormState & Value<Maybe<Date>>>(_ => ({ ..._, label: label, tooltip })) as any
41
41
  if (viewType == "number")
42
42
  return NumberForm<any & FormLabel, Unit>()
43
43
  .withView(((fieldViews as any)[viewType] as any)[viewName]() as any)
@@ -96,10 +96,9 @@ export const FieldFormState = //<Context, FieldViews extends DefaultFieldViews,
96
96
  ...injectedPrimitiveDefaultState,
97
97
  ...SharedFormState.Default()
98
98
  }) : SharedFormState.Default();
99
- return SharedFormState.Default()
100
99
  }
101
100
  if (viewType == "date")
102
- return DateFormState.Default("");
101
+ return DateFormState.Default();
103
102
  if (viewType == "enumSingleSelection" || viewType == "enumMultiSelection")
104
103
  return ({ ...EnumFormState<any, any>().Default(), ...SharedFormState.Default() });
105
104
  if (viewType == "streamSingleSelection" || viewType == "streamMultiSelection") {
@@ -600,6 +599,9 @@ export const revertKeyword = (fieldName: string): string => {
600
599
 
601
600
  export const replaceKeywords = (obj: any, kind: "from api" | "to api"): any => {
602
601
  const replacementFn = kind == "from api" ? replaceKeyword : revertKeyword;
602
+ if(obj instanceof Date && !isNaN(obj.valueOf())) {
603
+ return obj;
604
+ }
603
605
  if (Array.isArray(obj) || List.isList(obj)) {
604
606
  return obj.map((item) =>
605
607
  typeof item == "string"
@@ -1,15 +1,15 @@
1
- import { SimpleCallback, simpleUpdater } from "../../../../../../main";
1
+ import { Maybe, SimpleCallback, simpleUpdater } from "../../../../../../main";
2
2
  import { View } from "../../../../../template/state";
3
3
  import { Value } from "../../../../../value/state";
4
4
  import { FormLabel } from "../../../singleton/domains/form-label/state";
5
5
  import { OnChange, SharedFormState } from "../../../singleton/state";
6
6
 
7
7
  export type DateFormState = SharedFormState &
8
- { possiblyInvalidInput: string; };
8
+ { possiblyInvalidInput: Maybe<string>; };
9
9
  export const DateFormState = {
10
- Default: (possiblyInvalidInput: string): DateFormState => ({
10
+ Default: (): DateFormState => ({
11
11
  ...SharedFormState.Default(),
12
- possiblyInvalidInput
12
+ possiblyInvalidInput: Maybe.Default(undefined)
13
13
  }),
14
14
  Updaters: {
15
15
  ...simpleUpdater<DateFormState>()("possiblyInvalidInput")
@@ -17,7 +17,7 @@ export const DateFormState = {
17
17
  };
18
18
  export type DateView<Context extends FormLabel, ForeignMutationsExpected> =
19
19
  View<
20
- Context & Value<Date> & DateFormState & { disabled:boolean },
20
+ Context & Value<Maybe<Date>> & DateFormState & { disabled:boolean },
21
21
  DateFormState,
22
- ForeignMutationsExpected & { onChange: OnChange<Date>; setNewValue: SimpleCallback<string> }
22
+ ForeignMutationsExpected & { onChange: OnChange<Maybe<Date>>; setNewValue: SimpleCallback<Maybe<string>> }
23
23
  >;
@@ -1,30 +1,29 @@
1
1
  import { List } from "immutable";
2
- import { BasicFun, CoTypedFactory, Debounce, Debounced, replaceWith, Synchronize, Unit, ValidateRunner } from "../../../../../../main";
2
+ import { BasicFun, Maybe, replaceWith, ValidateRunner } from "../../../../../../main";
3
3
  import { Template } from "../../../../../template/state";
4
4
  import { Value } from "../../../../../value/state";
5
5
  import { FormLabel } from "../../../singleton/domains/form-label/state";
6
- import { FieldValidation, FieldValidationWithPath, FormValidatorSynchronized, OnChange, SharedFormState, ValidationError } from "../../../singleton/state";
6
+ import { FieldValidation, FieldValidationWithPath, OnChange } from "../../../singleton/state";
7
7
  import { DateFormState, DateView } from "./state";
8
8
 
9
9
  export const DateForm = <Context extends FormLabel, ForeignMutationsExpected>(
10
- validation?: BasicFun<Date, Promise<FieldValidation>>
10
+ validation?: BasicFun<Maybe<Date>, Promise<FieldValidation>>
11
11
  ) => {
12
- return Template.Default<Context & Value<Date> & { disabled:boolean }, DateFormState, ForeignMutationsExpected & { onChange: OnChange<Date>; }, DateView<Context, ForeignMutationsExpected>>(props => <>
12
+ return Template.Default<Context & Value<Maybe<Date>> & { disabled:boolean }, DateFormState, ForeignMutationsExpected & { onChange: OnChange<Maybe<Date>>; }, DateView<Context, ForeignMutationsExpected>>(props => <>
13
13
  <props.view {...props}
14
14
  foreignMutations={{
15
15
  ...props.foreignMutations,
16
16
  setNewValue: (_) => {
17
- props.setState(DateFormState.Updaters.possiblyInvalidInput(replaceWith(_)))
18
- const newDate = new Date(_)
17
+ props.setState(DateFormState.Updaters.possiblyInvalidInput(Maybe.Updaters.value(replaceWith(_))))
18
+ const newValue = _ == undefined ? _ : new Date(_)
19
19
  setTimeout(() => {
20
- props.foreignMutations.onChange(replaceWith(newDate), List())
20
+ props.foreignMutations.onChange(Maybe.Updaters.value(replaceWith(newValue)), List())
21
21
  }, 0)
22
-
23
- }
22
+ }
24
23
  }} />
25
24
  </>
26
25
  ).any([
27
- ValidateRunner<Context & { disabled:boolean }, DateFormState, ForeignMutationsExpected, Date>(
26
+ ValidateRunner<Context & { disabled:boolean }, DateFormState, ForeignMutationsExpected, Maybe<Date>>(
28
27
  validation ? _ => validation(_).then(FieldValidationWithPath.Default.fromFieldValidation) : undefined
29
28
  ),
30
29
  ]);