@ng-forge/dynamic-forms 1.0.0 → 1.1.0-next.1
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/fesm2022/ng-forge-dynamic-forms-integration.mjs +36 -17
- package/fesm2022/ng-forge-dynamic-forms-integration.mjs.map +1 -1
- package/fesm2022/ng-forge-dynamic-forms-internal.mjs +37 -11
- package/fesm2022/ng-forge-dynamic-forms-internal.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ng-forge-dynamic-forms-integration.d.ts +28 -2
- package/types/ng-forge-dynamic-forms-internal.d.ts +35 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { inject, computed, signal, Injector, isDevMode, afterRenderEffect, input, Directive, untracked, InjectionToken, ElementRef, EnvironmentInjector, runInInjectionContext } from '@angular/core';
|
|
3
|
-
import { injectFieldSignalContext, omit, buildBaseInputs, DEFAULT_PROPS, resolveNonFieldHidden, resolveNonFieldDisabled, RootFormRegistryService, ARRAY_CONTEXT, FORM_OPTIONS, resolveSubmitButtonDisabled, resolveNextButtonDisabled, dynamicTextToObservable, interpolateParams, isEqual, applyMetaToElement, DEFAULT_VALIDATION_MESSAGES, EventBus, resolveTokens, resolveDynamicValue, ADDON_ACTION_REGISTRY, writeToFieldValue } from '@ng-forge/dynamic-forms/internal';
|
|
3
|
+
import { injectFieldSignalContext, omit, buildBaseInputs, DEFAULT_PROPS, resolveNonFieldHidden, resolveNonFieldDisabled, RootFormRegistryService, injectNonFieldEvaluationContext, ARRAY_CONTEXT, FORM_OPTIONS, resolveSubmitButtonDisabled, resolveNextButtonDisabled, dynamicTextToObservable, interpolateParams, isEqual, applyMetaToElement, DEFAULT_VALIDATION_MESSAGES, EventBus, resolveTokens, resolveDynamicValue, ADDON_ACTION_REGISTRY, writeToFieldValue } from '@ng-forge/dynamic-forms/internal';
|
|
4
4
|
export { ADDON_ACTION_REGISTRY, ADDON_TYPE_COMPONENT_CACHE, ADDON_TYPE_DEFINITIONS, ADDON_TYPE_REGISTRY, ARRAY_CONTEXT, DEFAULT_PROPS, DEFAULT_VALIDATION_MESSAGES, DEFAULT_WRAPPERS, DfAddonSlot, DynamicTextPipe, EventBus, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FORM_OPTIONS, GROUP_CONTEXT, INITIALIZATION_TIMEOUT_MS, RootFormRegistryService, applyMetaToElement, applyValidator, applyValidators, arrayFieldMapper, baseFieldMapper, buildBaseInputs, containerFieldMapper, dynamicTextToObservable, getArrayLength, groupFieldMapper, injectAddonTypeRegistry, injectFieldSignalContext, injectFieldsSupportingAddons, interpolateParams, isCheckedField, isEqual, isValueField, pageFieldMapper, resolveDynamicValue, resolveNonFieldDisabled, resolveNonFieldHidden, resolveTokens, rowFieldMapper, runPresetAction, textFieldMapper, toReadonlyFieldTree, withPreviousValue, writeToFieldValue } from '@ng-forge/dynamic-forms/internal';
|
|
5
5
|
import { DynamicFormLogger, AppendArrayItemEvent, PrependArrayItemEvent, InsertArrayItemEvent, RemoveAtIndexEvent, PopArrayItemEvent, ShiftArrayItemEvent, NextPageEvent, PreviousPageEvent } from '@ng-forge/dynamic-forms';
|
|
6
6
|
export { BUILT_IN_FIELDS, createWrappers, isWrappersBundle, wrapperProps } from '@ng-forge/dynamic-forms';
|
|
@@ -125,7 +125,7 @@ function sliderFieldMapper(fieldDef) {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
function applyNonFieldLogic(rootFormRegistry, fieldDef) {
|
|
128
|
+
function applyNonFieldLogic(rootFormRegistry, fieldDef, evaluationContext) {
|
|
129
129
|
const result = {};
|
|
130
130
|
const rootForm = rootFormRegistry.rootForm();
|
|
131
131
|
if (rootForm) {
|
|
@@ -134,6 +134,7 @@ function applyNonFieldLogic(rootFormRegistry, fieldDef) {
|
|
|
134
134
|
form: rootForm,
|
|
135
135
|
fieldLogic: fieldDef.logic,
|
|
136
136
|
explicitValue: fieldDef.hidden,
|
|
137
|
+
evaluationContext,
|
|
137
138
|
});
|
|
138
139
|
result.hidden = hiddenSignal();
|
|
139
140
|
}
|
|
@@ -142,6 +143,7 @@ function applyNonFieldLogic(rootFormRegistry, fieldDef) {
|
|
|
142
143
|
form: rootForm,
|
|
143
144
|
fieldLogic: fieldDef.logic,
|
|
144
145
|
explicitValue: fieldDef.disabled,
|
|
146
|
+
evaluationContext,
|
|
145
147
|
});
|
|
146
148
|
result.disabled = disabledSignal();
|
|
147
149
|
}
|
|
@@ -156,7 +158,7 @@ function applyNonFieldLogic(rootFormRegistry, fieldDef) {
|
|
|
156
158
|
}
|
|
157
159
|
return result;
|
|
158
160
|
}
|
|
159
|
-
function resolveHiddenValue(rootForm, fieldDef) {
|
|
161
|
+
function resolveHiddenValue(rootForm, fieldDef, evaluationContext) {
|
|
160
162
|
if (!rootForm) {
|
|
161
163
|
return fieldDef.hidden;
|
|
162
164
|
}
|
|
@@ -165,23 +167,29 @@ function resolveHiddenValue(rootForm, fieldDef) {
|
|
|
165
167
|
form: rootForm,
|
|
166
168
|
fieldLogic: fieldDef.logic,
|
|
167
169
|
explicitValue: fieldDef.hidden,
|
|
170
|
+
evaluationContext,
|
|
168
171
|
})();
|
|
169
172
|
}
|
|
170
173
|
return undefined;
|
|
171
174
|
}
|
|
175
|
+
function injectNonFieldLogicResolver(fieldDef) {
|
|
176
|
+
const rootFormRegistry = inject(RootFormRegistryService);
|
|
177
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
178
|
+
return () => applyNonFieldLogic(rootFormRegistry, fieldDef, evaluationContext);
|
|
179
|
+
}
|
|
172
180
|
|
|
173
181
|
function buttonFieldMapper(fieldDef) {
|
|
174
182
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
175
|
-
const
|
|
183
|
+
const resolveLogic = injectNonFieldLogicResolver(fieldDef);
|
|
176
184
|
return computed(() => {
|
|
177
185
|
const inputs = buildBaseInputs(fieldDef, defaultProps());
|
|
178
|
-
|
|
186
|
+
inputs['event'] = fieldDef.event;
|
|
179
187
|
if (fieldDef.eventArgs !== undefined) {
|
|
180
188
|
inputs['eventArgs'] = fieldDef.eventArgs;
|
|
181
189
|
}
|
|
182
|
-
|
|
190
|
+
return {
|
|
183
191
|
...inputs,
|
|
184
|
-
...
|
|
192
|
+
...resolveLogic(),
|
|
185
193
|
};
|
|
186
194
|
});
|
|
187
195
|
}
|
|
@@ -225,6 +233,7 @@ function resolveArrayButtonEventArgs(fieldEventArgs, defaultEventArgs = ['$array
|
|
|
225
233
|
function addArrayItemButtonMapper(fieldDef) {
|
|
226
234
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
227
235
|
const rootFormRegistry = inject(RootFormRegistryService);
|
|
236
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
228
237
|
const ctx = resolveArrayButtonContext(fieldDef.key, 'addArrayItem', fieldDef.arrayKey);
|
|
229
238
|
return computed(() => {
|
|
230
239
|
const baseInputs = buildBaseInputs(fieldDef, defaultProps?.());
|
|
@@ -233,13 +242,14 @@ function addArrayItemButtonMapper(fieldDef) {
|
|
|
233
242
|
event: AppendArrayItemEvent,
|
|
234
243
|
eventArgs: resolveArrayButtonEventArgs(fieldDef.eventArgs, ['$arrayKey', '$template']),
|
|
235
244
|
eventContext: buildArrayButtonEventContext(fieldDef.key, ctx, fieldDef.template),
|
|
236
|
-
...applyNonFieldLogic(rootFormRegistry, fieldDef),
|
|
245
|
+
...applyNonFieldLogic(rootFormRegistry, fieldDef, evaluationContext),
|
|
237
246
|
};
|
|
238
247
|
});
|
|
239
248
|
}
|
|
240
249
|
function prependArrayItemButtonMapper(fieldDef) {
|
|
241
250
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
242
251
|
const rootFormRegistry = inject(RootFormRegistryService);
|
|
252
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
243
253
|
const ctx = resolveArrayButtonContext(fieldDef.key, 'prependArrayItem', fieldDef.arrayKey);
|
|
244
254
|
return computed(() => {
|
|
245
255
|
const baseInputs = buildBaseInputs(fieldDef, defaultProps?.());
|
|
@@ -248,13 +258,14 @@ function prependArrayItemButtonMapper(fieldDef) {
|
|
|
248
258
|
event: PrependArrayItemEvent,
|
|
249
259
|
eventArgs: resolveArrayButtonEventArgs(fieldDef.eventArgs, ['$arrayKey', '$template']),
|
|
250
260
|
eventContext: buildArrayButtonEventContext(fieldDef.key, ctx, fieldDef.template),
|
|
251
|
-
...applyNonFieldLogic(rootFormRegistry, fieldDef),
|
|
261
|
+
...applyNonFieldLogic(rootFormRegistry, fieldDef, evaluationContext),
|
|
252
262
|
};
|
|
253
263
|
});
|
|
254
264
|
}
|
|
255
265
|
function insertArrayItemButtonMapper(fieldDef) {
|
|
256
266
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
257
267
|
const rootFormRegistry = inject(RootFormRegistryService);
|
|
268
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
258
269
|
const ctx = resolveArrayButtonContext(fieldDef.key, 'insertArrayItem', fieldDef.arrayKey);
|
|
259
270
|
return computed(() => {
|
|
260
271
|
const baseInputs = buildBaseInputs(fieldDef, defaultProps?.());
|
|
@@ -263,13 +274,14 @@ function insertArrayItemButtonMapper(fieldDef) {
|
|
|
263
274
|
event: InsertArrayItemEvent,
|
|
264
275
|
eventArgs: resolveArrayButtonEventArgs(fieldDef.eventArgs, ['$arrayKey', fieldDef.index, '$template']),
|
|
265
276
|
eventContext: buildArrayButtonEventContext(fieldDef.key, ctx, fieldDef.template),
|
|
266
|
-
...applyNonFieldLogic(rootFormRegistry, fieldDef),
|
|
277
|
+
...applyNonFieldLogic(rootFormRegistry, fieldDef, evaluationContext),
|
|
267
278
|
};
|
|
268
279
|
});
|
|
269
280
|
}
|
|
270
281
|
function removeArrayItemButtonMapper(fieldDef) {
|
|
271
282
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
272
283
|
const rootFormRegistry = inject(RootFormRegistryService);
|
|
284
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
273
285
|
const ctx = resolveArrayButtonContext(fieldDef.key, 'removeArrayItem', fieldDef.arrayKey);
|
|
274
286
|
const eventType = ctx.isInsideArray ? RemoveAtIndexEvent : PopArrayItemEvent;
|
|
275
287
|
const defaultEventArgs = ctx.isInsideArray ? ['$arrayKey', '$index'] : ['$arrayKey'];
|
|
@@ -280,13 +292,14 @@ function removeArrayItemButtonMapper(fieldDef) {
|
|
|
280
292
|
event: eventType,
|
|
281
293
|
eventArgs: resolveArrayButtonEventArgs(fieldDef.eventArgs, defaultEventArgs),
|
|
282
294
|
eventContext: buildArrayButtonEventContext(fieldDef.key, ctx),
|
|
283
|
-
...applyNonFieldLogic(rootFormRegistry, fieldDef),
|
|
295
|
+
...applyNonFieldLogic(rootFormRegistry, fieldDef, evaluationContext),
|
|
284
296
|
};
|
|
285
297
|
});
|
|
286
298
|
}
|
|
287
299
|
function popArrayItemButtonMapper(fieldDef) {
|
|
288
300
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
289
301
|
const rootFormRegistry = inject(RootFormRegistryService);
|
|
302
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
290
303
|
const ctx = resolveArrayButtonContext(fieldDef.key, 'popArrayItem', fieldDef.arrayKey);
|
|
291
304
|
return computed(() => {
|
|
292
305
|
const baseInputs = buildBaseInputs(fieldDef, defaultProps?.());
|
|
@@ -295,13 +308,14 @@ function popArrayItemButtonMapper(fieldDef) {
|
|
|
295
308
|
event: PopArrayItemEvent,
|
|
296
309
|
eventArgs: resolveArrayButtonEventArgs(fieldDef.eventArgs, ['$arrayKey']),
|
|
297
310
|
eventContext: buildArrayButtonEventContext(fieldDef.key, ctx),
|
|
298
|
-
...applyNonFieldLogic(rootFormRegistry, fieldDef),
|
|
311
|
+
...applyNonFieldLogic(rootFormRegistry, fieldDef, evaluationContext),
|
|
299
312
|
};
|
|
300
313
|
});
|
|
301
314
|
}
|
|
302
315
|
function shiftArrayItemButtonMapper(fieldDef) {
|
|
303
316
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
304
317
|
const rootFormRegistry = inject(RootFormRegistryService);
|
|
318
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
305
319
|
const ctx = resolveArrayButtonContext(fieldDef.key, 'shiftArrayItem', fieldDef.arrayKey);
|
|
306
320
|
return computed(() => {
|
|
307
321
|
const baseInputs = buildBaseInputs(fieldDef, defaultProps?.());
|
|
@@ -310,7 +324,7 @@ function shiftArrayItemButtonMapper(fieldDef) {
|
|
|
310
324
|
event: ShiftArrayItemEvent,
|
|
311
325
|
eventArgs: resolveArrayButtonEventArgs(fieldDef.eventArgs, ['$arrayKey']),
|
|
312
326
|
eventContext: buildArrayButtonEventContext(fieldDef.key, ctx),
|
|
313
|
-
...applyNonFieldLogic(rootFormRegistry, fieldDef),
|
|
327
|
+
...applyNonFieldLogic(rootFormRegistry, fieldDef, evaluationContext),
|
|
314
328
|
};
|
|
315
329
|
});
|
|
316
330
|
}
|
|
@@ -319,6 +333,7 @@ function submitButtonFieldMapper(fieldDef) {
|
|
|
319
333
|
const rootFormRegistry = inject(RootFormRegistryService);
|
|
320
334
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
321
335
|
const formOptions = inject(FORM_OPTIONS);
|
|
336
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
322
337
|
const fieldWithLogic = fieldDef;
|
|
323
338
|
return computed(() => {
|
|
324
339
|
const baseInputs = buildBaseInputs(fieldDef, defaultProps());
|
|
@@ -329,6 +344,7 @@ function submitButtonFieldMapper(fieldDef) {
|
|
|
329
344
|
formOptions: formOptions(),
|
|
330
345
|
fieldLogic: fieldWithLogic.logic,
|
|
331
346
|
explicitlyDisabled: fieldDef.disabled,
|
|
347
|
+
evaluationContext,
|
|
332
348
|
})()
|
|
333
349
|
: (fieldDef.disabled ?? false);
|
|
334
350
|
const inputs = {
|
|
@@ -336,7 +352,7 @@ function submitButtonFieldMapper(fieldDef) {
|
|
|
336
352
|
props: { ...fieldDef.props, type: 'submit' },
|
|
337
353
|
disabled,
|
|
338
354
|
};
|
|
339
|
-
const hidden = resolveHiddenValue(rootForm, fieldWithLogic);
|
|
355
|
+
const hidden = resolveHiddenValue(rootForm, fieldWithLogic, evaluationContext);
|
|
340
356
|
if (hidden !== undefined) {
|
|
341
357
|
inputs['hidden'] = hidden;
|
|
342
358
|
}
|
|
@@ -348,6 +364,7 @@ function nextButtonFieldMapper(fieldDef) {
|
|
|
348
364
|
const rootFormRegistry = inject(RootFormRegistryService);
|
|
349
365
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
350
366
|
const formOptions = inject(FORM_OPTIONS);
|
|
367
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
351
368
|
const fieldWithLogic = fieldDef;
|
|
352
369
|
return computed(() => {
|
|
353
370
|
const baseInputs = buildBaseInputs(fieldDef, defaultProps());
|
|
@@ -357,13 +374,14 @@ function nextButtonFieldMapper(fieldDef) {
|
|
|
357
374
|
formOptions: formOptions(),
|
|
358
375
|
fieldLogic: fieldWithLogic.logic,
|
|
359
376
|
currentPageValid: fieldSignalContext.currentPageValid,
|
|
377
|
+
evaluationContext,
|
|
360
378
|
})();
|
|
361
379
|
const inputs = {
|
|
362
380
|
...baseInputs,
|
|
363
381
|
event: NextPageEvent,
|
|
364
382
|
disabled,
|
|
365
383
|
};
|
|
366
|
-
const hidden = resolveHiddenValue(rootForm, fieldWithLogic);
|
|
384
|
+
const hidden = resolveHiddenValue(rootForm, fieldWithLogic, evaluationContext);
|
|
367
385
|
if (hidden !== undefined) {
|
|
368
386
|
inputs['hidden'] = hidden;
|
|
369
387
|
}
|
|
@@ -373,6 +391,7 @@ function nextButtonFieldMapper(fieldDef) {
|
|
|
373
391
|
function previousButtonFieldMapper(fieldDef) {
|
|
374
392
|
const defaultProps = inject(DEFAULT_PROPS);
|
|
375
393
|
const rootFormRegistry = inject(RootFormRegistryService);
|
|
394
|
+
const evaluationContext = injectNonFieldEvaluationContext(fieldDef);
|
|
376
395
|
const fieldWithLogic = fieldDef;
|
|
377
396
|
return computed(() => {
|
|
378
397
|
const baseInputs = buildBaseInputs(fieldDef, defaultProps());
|
|
@@ -384,7 +403,7 @@ function previousButtonFieldMapper(fieldDef) {
|
|
|
384
403
|
if (fieldDef.disabled !== undefined) {
|
|
385
404
|
inputs['disabled'] = fieldDef.disabled;
|
|
386
405
|
}
|
|
387
|
-
const hidden = resolveHiddenValue(rootForm, fieldWithLogic);
|
|
406
|
+
const hidden = resolveHiddenValue(rootForm, fieldWithLogic, evaluationContext);
|
|
388
407
|
if (hidden !== undefined) {
|
|
389
408
|
inputs['hidden'] = hidden;
|
|
390
409
|
}
|
|
@@ -979,5 +998,5 @@ function provideTestValidationMessages(messages) {
|
|
|
979
998
|
|
|
980
999
|
|
|
981
1000
|
|
|
982
|
-
export { ADDON_PRESET_HANDLER, NG_FORGE_ACTION_INPUTS, NG_FORGE_ADDONS_INPUTS, NG_FORGE_ADDON_ACTION_INPUTS, NG_FORGE_FIELD_SHELL_INPUTS, NG_FORGE_VALUE_FIELD_INPUTS, NgForgeAction, NgForgeActionHost, NgForgeAddonAction, NgForgeAddonActionBase, NgForgeAddons, NgForgeAddonsBase, NgForgeControl, NgForgeField, NgForgeFieldHost, NgForgeFieldShell, NgForgeHostControl, addArrayItemButtonMapper, buildArrayButtonEventContext, buildValueFieldInputs, buttonFieldMapper, checkboxFieldMapper, createAriaDescribedBySignal, createNgForgeActionFixture, createNgForgeFieldFixture, createResolvedErrorsSignal, datepickerFieldMapper, injectNgForgeAction, injectNgForgeAddonAction, injectNgForgeAddons, injectNgForgeField, insertArrayItemButtonMapper, nextButtonFieldMapper, optionsFieldMapper, popArrayItemButtonMapper, prependArrayItemButtonMapper, previousButtonFieldMapper, provideTestValidationMessages, removeArrayItemButtonMapper, resolveArrayButtonContext, resolveArrayButtonEventArgs, resolveValueFieldContext, setupMetaTracking, shiftArrayItemButtonMapper, shouldShowErrors, submitButtonFieldMapper, valueFieldMapper };
|
|
1001
|
+
export { ADDON_PRESET_HANDLER, NG_FORGE_ACTION_INPUTS, NG_FORGE_ADDONS_INPUTS, NG_FORGE_ADDON_ACTION_INPUTS, NG_FORGE_FIELD_SHELL_INPUTS, NG_FORGE_VALUE_FIELD_INPUTS, NgForgeAction, NgForgeActionHost, NgForgeAddonAction, NgForgeAddonActionBase, NgForgeAddons, NgForgeAddonsBase, NgForgeControl, NgForgeField, NgForgeFieldHost, NgForgeFieldShell, NgForgeHostControl, addArrayItemButtonMapper, buildArrayButtonEventContext, buildValueFieldInputs, buttonFieldMapper, checkboxFieldMapper, createAriaDescribedBySignal, createNgForgeActionFixture, createNgForgeFieldFixture, createResolvedErrorsSignal, datepickerFieldMapper, injectNgForgeAction, injectNgForgeAddonAction, injectNgForgeAddons, injectNgForgeField, injectNonFieldLogicResolver, insertArrayItemButtonMapper, nextButtonFieldMapper, optionsFieldMapper, popArrayItemButtonMapper, prependArrayItemButtonMapper, previousButtonFieldMapper, provideTestValidationMessages, removeArrayItemButtonMapper, resolveArrayButtonContext, resolveArrayButtonEventArgs, resolveValueFieldContext, setupMetaTracking, shiftArrayItemButtonMapper, shouldShowErrors, submitButtonFieldMapper, valueFieldMapper };
|
|
983
1002
|
//# sourceMappingURL=ng-forge-dynamic-forms-integration.mjs.map
|