ballerina-core 1.0.146 → 1.0.147

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.146",
5
+ "version": "1.0.147",
6
6
  "main": "main.ts",
7
7
  "scripts": {
8
8
  "prettier": "prettier --write ."
@@ -152,9 +152,7 @@ export type OneAbstractRendererView = View<
152
152
  | {
153
153
  kind: "initialized";
154
154
  DetailsRenderer: Template<any, any, any, any>;
155
- PreviewRenderer: (
156
- value: ValueRecord,
157
- ) => Template<any, any, any, any> | undefined;
155
+ PreviewRenderer?: (value: ValueRecord) => Template<any, any, any, any>;
158
156
  }
159
157
  | {
160
158
  kind: "uninitialized";
@@ -161,90 +161,94 @@ export const OneAbstractRenderer = (
161
161
  },
162
162
  }));
163
163
 
164
- const embeddedPreviewRenderer = (value: ValueRecord) =>
165
- PreviewRenderer?.mapContext<
166
- OneAbstractRendererReadonlyContext & OneAbstractRendererState
167
- >((_) => {
168
- const state = RecordAbstractRendererState.Default.zero();
169
- return {
170
- ..._,
171
- ...state,
172
- value,
173
- disabled: _.disabled,
174
- bindings: _.bindings,
175
- extraContext: _.extraContext,
176
- identifiers: {
177
- withLauncher: _.identifiers.withLauncher.concat(`[preview]`),
178
- withoutLauncher: _.identifiers.withoutLauncher.concat(`[preview]`),
179
- },
180
- type: _.type.args,
181
- };
182
- })
183
- .mapState(
184
- OneAbstractRendererState.Updaters.Core.customFormState.children
185
- .detailsState,
186
- )
187
- .mapForeignMutationsFromProps<{
188
- onChange: DispatchOnChange<PredicateValue>;
189
- }>((props) => ({
190
- onChange: (
191
- _: BasicUpdater<ValueRecord>,
192
- nestedDelta: DispatchDelta,
193
- ) => {
194
- props.setState(
195
- OneAbstractRendererState.Updaters.Core.commonFormState.children
196
- .modifiedByUser(replaceWith(true))
197
- .then(
198
- OneAbstractRendererState.Updaters.Core.customFormState.children.detailsState(
199
- RecordAbstractRendererState.Updaters.Core.commonFormState(
200
- DispatchCommonFormState.Updaters.modifiedByUser(
201
- replaceWith(true),
164
+ const embeddedPreviewRenderer = PreviewRenderer
165
+ ? (value: ValueRecord) =>
166
+ PreviewRenderer.mapContext<
167
+ OneAbstractRendererReadonlyContext & OneAbstractRendererState
168
+ >((_) => {
169
+ const state = RecordAbstractRendererState.Default.zero();
170
+ return {
171
+ ..._,
172
+ ...state,
173
+ value,
174
+ disabled: _.disabled,
175
+ bindings: _.bindings,
176
+ extraContext: _.extraContext,
177
+ identifiers: {
178
+ withLauncher: _.identifiers.withLauncher.concat(`[preview]`),
179
+ withoutLauncher:
180
+ _.identifiers.withoutLauncher.concat(`[preview]`),
181
+ },
182
+ type: _.type.args,
183
+ };
184
+ })
185
+ .mapState(
186
+ OneAbstractRendererState.Updaters.Core.customFormState.children
187
+ .detailsState,
188
+ )
189
+ .mapForeignMutationsFromProps<{
190
+ onChange: DispatchOnChange<PredicateValue>;
191
+ }>((props) => ({
192
+ onChange: (
193
+ _: BasicUpdater<ValueRecord>,
194
+ nestedDelta: DispatchDelta,
195
+ ) => {
196
+ props.setState(
197
+ OneAbstractRendererState.Updaters.Core.commonFormState.children
198
+ .modifiedByUser(replaceWith(true))
199
+ .then(
200
+ OneAbstractRendererState.Updaters.Core.customFormState.children.detailsState(
201
+ RecordAbstractRendererState.Updaters.Core.commonFormState(
202
+ DispatchCommonFormState.Updaters.modifiedByUser(
203
+ replaceWith(true),
204
+ ),
205
+ ),
202
206
  ),
203
- ),
204
- ),
205
- )
206
- .then((__) => {
207
- if (
208
- __.customFormState.selectedValue.sync.kind != "loaded" ||
209
- __.customFormState.selectedValue.sync.value.kind ==
210
- "errors" ||
211
- !PredicateValue.Operations.IsRecord(
212
- __.customFormState.selectedValue.sync.value.value,
213
207
  )
214
- ) {
215
- return __;
216
- }
217
- return {
218
- ...__,
219
- customFormState: {
220
- ...__.customFormState,
221
- selectedValue: {
222
- ...__.customFormState.selectedValue,
223
- sync: {
224
- ...__.customFormState.selectedValue.sync,
225
- value: {
226
- ...__.customFormState.selectedValue.sync.value,
227
- value: _(
228
- __.customFormState.selectedValue.sync.value.value,
229
- ),
208
+ .then((__) => {
209
+ if (
210
+ __.customFormState.selectedValue.sync.kind != "loaded" ||
211
+ __.customFormState.selectedValue.sync.value.kind ==
212
+ "errors" ||
213
+ !PredicateValue.Operations.IsRecord(
214
+ __.customFormState.selectedValue.sync.value.value,
215
+ )
216
+ ) {
217
+ return __;
218
+ }
219
+ return {
220
+ ...__,
221
+ customFormState: {
222
+ ...__.customFormState,
223
+ selectedValue: {
224
+ ...__.customFormState.selectedValue,
225
+ sync: {
226
+ ...__.customFormState.selectedValue.sync,
227
+ value: {
228
+ ...__.customFormState.selectedValue.sync.value,
229
+ value: _(
230
+ __.customFormState.selectedValue.sync.value
231
+ .value,
232
+ ),
233
+ },
234
+ },
230
235
  },
231
236
  },
232
- },
233
- },
234
- };
235
- }),
236
- );
237
+ };
238
+ }),
239
+ );
237
240
 
238
- // TODO, must return the ID in the delta,
239
- const delta: DispatchDelta = {
240
- kind: "OptionValue",
241
- value: nestedDelta,
242
- isWholeEntityMutation: true,
243
- };
241
+ // TODO, must return the ID in the delta,
242
+ const delta: DispatchDelta = {
243
+ kind: "OptionValue",
244
+ value: nestedDelta,
245
+ isWholeEntityMutation: true,
246
+ };
244
247
 
245
- props.foreignMutations.onChange(id, delta);
246
- },
247
- }));
248
+ props.foreignMutations.onChange(id, delta);
249
+ },
250
+ }))
251
+ : undefined;
248
252
 
249
253
  return Template.Default<
250
254
  OneAbstractRendererReadonlyContext,