@mmstack/form-core 21.0.1 → 21.0.2
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.
|
@@ -108,21 +108,21 @@ function generateID() {
|
|
|
108
108
|
*/
|
|
109
109
|
function formControl(initial, opt) {
|
|
110
110
|
const value = isSignal(initial) ? initial : signal(initial, opt);
|
|
111
|
-
const initialValue = signal(untracked(value), ...(ngDevMode ? [{ debugName: "initialValue" }] : []));
|
|
111
|
+
const initialValue = signal(untracked(value), ...(ngDevMode ? [{ debugName: "initialValue" }] : /* istanbul ignore next */ []));
|
|
112
112
|
const eq = opt?.equal ?? Object.is;
|
|
113
113
|
const dirtyEq = opt?.dirtyEquality ?? eq;
|
|
114
|
-
const disabled = computed(() => opt?.disable?.() ?? false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
|
|
115
|
-
const readonly = computed(() => opt?.readonly?.() ?? false, ...(ngDevMode ? [{ debugName: "readonly" }] : []));
|
|
116
|
-
const dirty = computed(() => !dirtyEq(value(), initialValue()), ...(ngDevMode ? [{ debugName: "dirty" }] : []));
|
|
117
|
-
const touched = signal(false, ...(ngDevMode ? [{ debugName: "touched" }] : []));
|
|
118
|
-
const validator = computed(() => opt?.validator?.() ?? (() => ''), ...(ngDevMode ? [{ debugName: "validator" }] : []));
|
|
114
|
+
const disabled = computed(() => opt?.disable?.() ?? false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
115
|
+
const readonly = computed(() => opt?.readonly?.() ?? false, ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
116
|
+
const dirty = computed(() => !dirtyEq(value(), initialValue()), ...(ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []));
|
|
117
|
+
const touched = signal(false, ...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
118
|
+
const validator = computed(() => opt?.validator?.() ?? (() => ''), ...(ngDevMode ? [{ debugName: "validator" }] : /* istanbul ignore next */ []));
|
|
119
119
|
const error = computed(() => {
|
|
120
120
|
if (opt?.overrideValidation)
|
|
121
121
|
return opt.overrideValidation();
|
|
122
122
|
if (disabled() || readonly())
|
|
123
123
|
return '';
|
|
124
124
|
return validator()(value());
|
|
125
|
-
}, ...(ngDevMode ? [{ debugName: "error" }] : []));
|
|
125
|
+
}, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
126
126
|
const markAsTouched = () => {
|
|
127
127
|
touched.set(true);
|
|
128
128
|
opt?.onTouched?.();
|
|
@@ -130,8 +130,8 @@ function formControl(initial, opt) {
|
|
|
130
130
|
const markAllAsTouched = markAsTouched;
|
|
131
131
|
const markAsPristine = () => touched.set(false);
|
|
132
132
|
const markAllAsPristine = markAsPristine;
|
|
133
|
-
const label = computed(() => opt?.label?.() ?? '', ...(ngDevMode ? [{ debugName: "label" }] : []));
|
|
134
|
-
const partialValue = computed(() => (dirty() ? value() : undefined), ...(ngDevMode ? [{ debugName: "partialValue" }] : []));
|
|
133
|
+
const label = computed(() => opt?.label?.() ?? '', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
134
|
+
const partialValue = computed(() => (dirty() ? value() : undefined), ...(ngDevMode ? [{ debugName: "partialValue" }] : /* istanbul ignore next */ []));
|
|
135
135
|
const internalReconcile = (newValue, force = false) => {
|
|
136
136
|
const isDirty = untracked(dirty);
|
|
137
137
|
if (!isDirty || force) {
|
|
@@ -143,7 +143,7 @@ function formControl(initial, opt) {
|
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
|
-
const pending = computed(() => opt?.pending?.() ?? false, ...(ngDevMode ? [{ debugName: "pending" }] : []));
|
|
146
|
+
const pending = computed(() => opt?.pending?.() ?? false, ...(ngDevMode ? [{ debugName: "pending" }] : /* istanbul ignore next */ []));
|
|
147
147
|
return {
|
|
148
148
|
id: opt?.id?.() ?? generateID(),
|
|
149
149
|
value,
|
|
@@ -211,8 +211,8 @@ function formArray(initial, factory, opt) {
|
|
|
211
211
|
return true;
|
|
212
212
|
return a.every((v, i) => eq(v, b[i]));
|
|
213
213
|
};
|
|
214
|
-
const min = computed(() => opt?.min?.() ?? 0, ...(ngDevMode ? [{ debugName: "min" }] : []));
|
|
215
|
-
const max = computed(() => opt?.max?.() ?? Number.MAX_SAFE_INTEGER, ...(ngDevMode ? [{ debugName: "max" }] : []));
|
|
214
|
+
const min = computed(() => opt?.min?.() ?? 0, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
215
|
+
const max = computed(() => opt?.max?.() ?? Number.MAX_SAFE_INTEGER, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
216
216
|
const arrayOptions = {
|
|
217
217
|
...opt,
|
|
218
218
|
equal: arrayEqual,
|
|
@@ -220,12 +220,12 @@ function formArray(initial, factory, opt) {
|
|
|
220
220
|
controlType: 'array',
|
|
221
221
|
};
|
|
222
222
|
const ctrl = formControl(initial, arrayOptions);
|
|
223
|
-
const length = computed(() => ctrl.value().length, ...(ngDevMode ? [{ debugName: "length" }] : []));
|
|
223
|
+
const length = computed(() => ctrl.value().length, ...(ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []));
|
|
224
224
|
const reconcileChildren = createReconcileChildren(factory, { equal: eq });
|
|
225
225
|
// linkedSignal used to re-use previous value so that only length changes are affected and existing controls are kept, but updated
|
|
226
|
-
const children = linkedSignal({ ...(ngDevMode ? { debugName: "children" } : {}), source: () => length(),
|
|
226
|
+
const children = linkedSignal({ ...(ngDevMode ? { debugName: "children" } : /* istanbul ignore next */ {}), source: () => length(),
|
|
227
227
|
computation: (len, prev) => reconcileChildren(len, ctrl.value, prev?.value) });
|
|
228
|
-
const ownError = computed(() => ctrl.error(), ...(ngDevMode ? [{ debugName: "ownError" }] : []));
|
|
228
|
+
const ownError = computed(() => ctrl.error(), ...(ngDevMode ? [{ debugName: "ownError" }] : /* istanbul ignore next */ []));
|
|
229
229
|
const error = computed(() => {
|
|
230
230
|
const own = ownError();
|
|
231
231
|
if (own)
|
|
@@ -236,14 +236,14 @@ function formArray(initial, factory, opt) {
|
|
|
236
236
|
.map((c, idx) => (c.error() ? `${idx}: ${c.error()}` : ''))
|
|
237
237
|
.filter(Boolean)
|
|
238
238
|
.join('\n');
|
|
239
|
-
}, ...(ngDevMode ? [{ debugName: "error" }] : []));
|
|
239
|
+
}, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
240
240
|
const dirty = computed(() => {
|
|
241
241
|
if (ctrl.dirty())
|
|
242
242
|
return true;
|
|
243
243
|
if (!children().length)
|
|
244
244
|
return false;
|
|
245
245
|
return children().some((c) => c.dirty());
|
|
246
|
-
}, ...(ngDevMode ? [{ debugName: "dirty" }] : []));
|
|
246
|
+
}, ...(ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []));
|
|
247
247
|
const markAllAsTouched = () => {
|
|
248
248
|
ctrl.markAllAsTouched();
|
|
249
249
|
for (const c of untracked(children)) {
|
|
@@ -269,9 +269,9 @@ function formArray(initial, factory, opt) {
|
|
|
269
269
|
// return full value for child objects/arrays as this cannot be partially patched without idx
|
|
270
270
|
return toPartialValue(c.value());
|
|
271
271
|
});
|
|
272
|
-
}, ...(ngDevMode ? [{ debugName: "partialValue" }] : []));
|
|
272
|
+
}, ...(ngDevMode ? [{ debugName: "partialValue" }] : /* istanbul ignore next */ []));
|
|
273
273
|
const touched = computed(() => ctrl.touched() ||
|
|
274
|
-
!!(children().length && children().some((c) => c.touched())), ...(ngDevMode ? [{ debugName: "touched" }] : []));
|
|
274
|
+
!!(children().length && children().some((c) => c.touched())), ...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
275
275
|
const reconcile = (newValue) => {
|
|
276
276
|
const ctrls = untracked(children);
|
|
277
277
|
for (let i = 0; i < newValue.length; i++) {
|
|
@@ -290,8 +290,8 @@ function formArray(initial, factory, opt) {
|
|
|
290
290
|
if (!children().length)
|
|
291
291
|
return true;
|
|
292
292
|
return children().every((d) => d.valid());
|
|
293
|
-
}, ...(ngDevMode ? [{ debugName: "childrenValid" }] : []));
|
|
294
|
-
const childrenPending = computed(() => !!children().length && children().some((d) => d.pending()), ...(ngDevMode ? [{ debugName: "childrenPending" }] : []));
|
|
293
|
+
}, ...(ngDevMode ? [{ debugName: "childrenValid" }] : /* istanbul ignore next */ []));
|
|
294
|
+
const childrenPending = computed(() => !!children().length && children().some((d) => d.pending()), ...(ngDevMode ? [{ debugName: "childrenPending" }] : /* istanbul ignore next */ []));
|
|
295
295
|
return {
|
|
296
296
|
...ctrl,
|
|
297
297
|
ownError,
|
|
@@ -389,8 +389,8 @@ function formGroup(initial, providedChildren, opt) {
|
|
|
389
389
|
? computed(() => providedChildren())
|
|
390
390
|
: computed(() => providedChildren);
|
|
391
391
|
// array allows for easier handling
|
|
392
|
-
const derivationsArray = computed(() => Object.values(children()), ...(ngDevMode ? [{ debugName: "derivationsArray" }] : []));
|
|
393
|
-
const childrenDirty = computed(() => !!derivationsArray().length && derivationsArray().some((d) => d.dirty()), ...(ngDevMode ? [{ debugName: "childrenDirty" }] : []));
|
|
392
|
+
const derivationsArray = computed(() => Object.values(children()), ...(ngDevMode ? [{ debugName: "derivationsArray" }] : /* istanbul ignore next */ []));
|
|
393
|
+
const childrenDirty = computed(() => !!derivationsArray().length && derivationsArray().some((d) => d.dirty()), ...(ngDevMode ? [{ debugName: "childrenDirty" }] : /* istanbul ignore next */ []));
|
|
394
394
|
// by default dont compare object references, just use childrenDirtySignal
|
|
395
395
|
const baseDirtyEq = opt?.dirtyEquality ?? opt?.equal ?? (() => true);
|
|
396
396
|
// function which calls a signal becomes a signal
|
|
@@ -417,8 +417,8 @@ function formGroup(initial, providedChildren, opt) {
|
|
|
417
417
|
},
|
|
418
418
|
});
|
|
419
419
|
const childrenTouched = computed(() => !!derivationsArray().length &&
|
|
420
|
-
derivationsArray().some((d) => d.touched()), ...(ngDevMode ? [{ debugName: "childrenTouched" }] : []));
|
|
421
|
-
const touched = computed(() => ctrl.touched() || childrenTouched(), ...(ngDevMode ? [{ debugName: "touched" }] : []));
|
|
420
|
+
derivationsArray().some((d) => d.touched()), ...(ngDevMode ? [{ debugName: "childrenTouched" }] : /* istanbul ignore next */ []));
|
|
421
|
+
const touched = computed(() => ctrl.touched() || childrenTouched(), ...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
422
422
|
const childError = computed(() => {
|
|
423
423
|
if (!derivationsArray().length)
|
|
424
424
|
return '';
|
|
@@ -426,13 +426,13 @@ function formGroup(initial, providedChildren, opt) {
|
|
|
426
426
|
.map((d) => (d.error() ? `${d.label()}: ${d.error()}` : ''))
|
|
427
427
|
.filter(Boolean)
|
|
428
428
|
.join('\n');
|
|
429
|
-
}, ...(ngDevMode ? [{ debugName: "childError" }] : []));
|
|
429
|
+
}, ...(ngDevMode ? [{ debugName: "childError" }] : /* istanbul ignore next */ []));
|
|
430
430
|
const error = computed(() => {
|
|
431
431
|
const ownError = ctrl.error();
|
|
432
432
|
if (ownError)
|
|
433
433
|
return ownError;
|
|
434
434
|
return childError() ? 'INVALID' : '';
|
|
435
|
-
}, ...(ngDevMode ? [{ debugName: "error" }] : []));
|
|
435
|
+
}, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
436
436
|
const markAllAsTouched = () => {
|
|
437
437
|
ctrl.markAllAsTouched();
|
|
438
438
|
for (const ctrl of untracked(derivationsArray)) {
|
|
@@ -481,14 +481,14 @@ function formGroup(initial, providedChildren, opt) {
|
|
|
481
481
|
obj[key] = pv;
|
|
482
482
|
}
|
|
483
483
|
return obj;
|
|
484
|
-
}, ...(ngDevMode ? [{ debugName: "partialValue" }] : []));
|
|
484
|
+
}, ...(ngDevMode ? [{ debugName: "partialValue" }] : /* istanbul ignore next */ []));
|
|
485
485
|
const childrenValid = computed(() => {
|
|
486
486
|
if (!derivationsArray().length)
|
|
487
487
|
return true;
|
|
488
488
|
return derivationsArray().every((d) => d.valid());
|
|
489
|
-
}, ...(ngDevMode ? [{ debugName: "childrenValid" }] : []));
|
|
489
|
+
}, ...(ngDevMode ? [{ debugName: "childrenValid" }] : /* istanbul ignore next */ []));
|
|
490
490
|
const childrenPending = computed(() => !!derivationsArray().length &&
|
|
491
|
-
derivationsArray().some((d) => d.pending()), ...(ngDevMode ? [{ debugName: "childrenPending" }] : []));
|
|
491
|
+
derivationsArray().some((d) => d.pending()), ...(ngDevMode ? [{ debugName: "childrenPending" }] : /* istanbul ignore next */ []));
|
|
492
492
|
return {
|
|
493
493
|
...ctrl,
|
|
494
494
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mmstack-form-core.mjs","sources":["../../../../../packages/form/core/src/lib/util.ts","../../../../../packages/form/core/src/lib/form-control.ts","../../../../../packages/form/core/src/lib/form-array.ts","../../../../../packages/form/core/src/lib/form-group.ts","../../../../../packages/form/core/src/mmstack-form-core.ts"],"sourcesContent":["/**\n * Merges two arrays element by element using the `mergeIfObject` logic.\n *\n * The resulting array will have the same length as the `next` array.\n * For each index `i`, the element in the resulting array is determined by:\n * `mergeIfObject(prev[i], next[i])`.\n * If `prev` is shorter than `next`, `prev[i]` will be `undefined` for the out-of-bounds indices.\n *\n * @template {any[]} T The array type being merged.\n * @param {T} prev The previous array.\n * @param {T} next The next array.\n * @returns {T} A new array containing the merged elements.\n * @example\n * const prev = [1, { id: 1, name: \"A\" }, [10], \"extraPrev\"];\n * const next = [2, { id: 1, status: \"B\" }, [20, 21], missing , { id: 2 }];\n *\n * mergeArray(prev, next);\n * // Result approx:\n * // [\n * // 2, // Primitive replaced\n * // { id: 1, name: \"A\", status: \"B\" }, // Objects shallow-merged\n * // [20, 21], // Arrays replaced (via mergeIfObject -> mergeArray)\n * // undefined, // Primitive replaced by missing item in sparse 'next' array\n * // { id: 2 } // Added from 'next' (prev[4] was undefined)\n * // ]\n */\nexport function mergeArray<T extends any[]>(prev: T, next: T): T {\n return next.map((item, index): T[number] =>\n mergeIfObject<T[number]>(prev[index], item),\n ) as T;\n}\n\n/**\n * Merges two values (`prev`, `next`), prioritizing `next` in most cases.\n *\n * Behavior:\n * - If both `prev` and `next` are non-null, non-array objects, it performs a **shallow merge**\n * (`{ ...prev, ...next }`), where properties from `next` overwrite those in `prev`.\n * - If both `prev` and `next` are arrays, it delegates to `mergeArray` for element-wise merging.\n * - In all other scenarios (type mismatch, primitives, null involved, array mixed with object),\n * it simply returns the `next` value.\n *\n * @template T The type of the values being merged.\n * @param {T | undefined} prev The previous value (can be undefined if accessed out of array bounds).\n * @param {T} next The next value.\n * @returns {T} The merged result based on the rules above.\n */\nexport function mergeIfObject<T>(prev: T, next: T): T {\n if (typeof prev !== typeof next) return next;\n if (typeof prev !== 'object' || typeof next !== 'object') return next;\n if (prev === null || next === null) return next;\n if (Array.isArray(prev) && Array.isArray(next)) return mergeArray(prev, next);\n if (Array.isArray(prev) || Array.isArray(next)) return next;\n\n return { ...prev, ...next };\n}\n\n/**\n * Generates a unique ID using crypto.randomUUID if available,\n * otherwise falls back to a non-secure random string.\n * @returns {string}\n */\nexport function generateID() {\n if (globalThis.crypto?.randomUUID) {\n return globalThis.crypto.randomUUID();\n }\n return Math.random().toString(36).substring(2);\n}\n","import {\n computed,\n isSignal,\n signal,\n untracked,\n type CreateSignalOptions,\n type Signal,\n type ValueEqualityFn,\n type WritableSignal,\n} from '@angular/core';\nimport { type DerivedSignal } from '@mmstack/primitives';\nimport { generateID } from './util';\n\n/**\n * Represents the type of a form control.\n * - `control`: A single form control (e.g., an input field).\n * - `array`: An array of form controls (like Angular's `FormArray`).\n * - `group`: A group of form controls (like Angular's `FormGroup`).\n */\nexport type ControlType = 'control' | 'array' | 'group';\n\n/**\n * Represents a reactive form control. It holds the value, validation status, and other\n * metadata for a form field. This is the core building block for creating reactive forms\n * with signals.\n *\n * @typeParam T - The type of the form control's value.\n * @typeParam TParent - The type of the parent form control's value (if this control is part of a group or array). Defaults to `undefined`.\n * @typeParam TControlType - The type of the control ('control', 'array', or 'group'). Defaults to 'control'.\n * @typeParam TPartialValue - The type of the partial value, used for patching.\n */\nexport type FormControlSignal<\n T,\n TParent = undefined,\n TControlType extends ControlType = 'control',\n TPartialValue = T | undefined,\n> = {\n /** A unique identifier for the control. Used for tracking in `@for` loops. */\n id: string;\n /** The main value signal for the control. */\n value: WritableSignal<T>;\n /** A signal indicating whether the control's value has been changed. */\n dirty: Signal<boolean>;\n /** A signal indicating whether the control has been interacted with (e.g., blurred). */\n touched: Signal<boolean>;\n /** A signal containing the current validation error message (empty string if valid). */\n error: Signal<string>;\n /** A signal indicating whether the control is pending */\n pending: Signal<boolean>;\n /** A signal indicating whether the control is disabled. */\n /** A signal indicating whether the control is in a valid state (without errors & not pending) */\n valid: Signal<boolean>;\n disabled: Signal<boolean>;\n /** A signal indicating whether the control is read-only. */\n readonly: Signal<boolean>;\n /** A signal indicating whether the control is required. */\n required: Signal<boolean>;\n /** A signal containing the label for the control. */\n label: Signal<string>;\n /** A signal containing the hint text for the control. */\n hint: Signal<string>;\n /** Marks the control as touched. */\n markAsTouched: () => void;\n /** Marks the control and all its child controls (if any) as touched. */\n markAllAsTouched: () => void;\n /** Marks the control as pristine (not touched). */\n markAsPristine: () => void;\n /** Marks the control and all its child controls (if any) as pristine. */\n markAllAsPristine: () => void;\n /**\n * Resets the control to a new value and sets a new initial value. This is intended for\n * scenarios where the underlying data is updated externally (e.g., data coming from\n * the server). If the control is not dirty, the value is updated. If the control *is*\n * dirty, the value is *not* updated (preserving user changes).\n */\n reconcile: (newValue: T) => void;\n /**\n * Similar to `reconcile`, but forces the update even if the control is dirty.\n */\n forceReconcile: (newValue: T) => void;\n /** Resets the control's value to its initial value. */\n reset: () => void;\n /** Resets the control's value and initial value. */\n resetWithInitial: (initial: T) => void;\n /**\n * The derivation function used to create this control if it's part of a `formGroup` or `formArray`.\n * @internal\n */\n from?: DerivedSignal<TParent, T>['from'];\n /** The equality function used to compare values. Defaults to `Object.is`. */\n equal: (a: T, b: T) => boolean;\n /** The type of the control ('control', 'array', or 'group'). */\n controlType: TControlType;\n /**\n * A signal representing the partial value of the control, suitable for patching data on a server.\n * It contains the changed value if `dirty` is `true`.\n */\n partialValue: Signal<TPartialValue>;\n};\n\nexport type CreateFormControlOptions<\n T,\n TControlType extends ControlType = ControlType,\n> = CreateSignalOptions<T> & {\n validator?: () => (value: T) => string;\n onTouched?: () => void;\n disable?: () => boolean;\n readonly?: () => boolean;\n required?: () => boolean;\n label?: () => string;\n id?: () => string;\n hint?: () => string;\n dirtyEquality?: ValueEqualityFn<T>;\n onReset?: () => void;\n controlType?: TControlType;\n overrideValidation?: () => string;\n pending?: () => boolean;\n};\n\n/**\n * Creates a `FormControlSignal`, a reactive form control that holds a value and tracks its\n * validity, dirty state, touched state, and other metadata.\n *\n * @typeParam T - The type of the form control's value.\n * @typeParam TParent - The type of the parent form control's value (if this control is part of a group or array).\n * @typeParam TControlType - The type of the control. Defaults to `'control'`.\n * @typeParam TPartialValue - The type of value when patching\n * @param initial - The initial value of the control, or a `DerivedSignal` if this control is part of a `formGroup` or `formArray`.\n * @param options - Optional configuration options for the control.\n * @returns A `FormControlSignal` instance.\n *\n * @example\n * // Create a simple form control:\n * const name = formControl('Initial Name');\n *\n * // Create a form control with validation:\n * const age = formControl(0, {\n * validator: () => (value) => value >= 18 ? '' : 'Must be at least 18',\n * });\n *\n * // Create a derived form control (equivalent to the above, but more explicit):\n * const user = signal({ name: 'John Doe', age: 30 });\n * const name = formControl(derived(user, {\n * from: (u) => u.name,\n * onChange: (newName) => user.update(u => ({...u, name: newName}))\n * }));\n *\n * // Create a form group with nested controls:\n * const user = signal({ name: 'John Doe', age: 30 });\n * const form = formGroup(user, {\n * name: formControl(derived(user, 'name')),\n * age: formControl(derived(user, 'age')),\n * })\n */\nexport function formControl<\n T,\n TParent = undefined,\n TControlType extends ControlType = 'control',\n TPartialValue = T | undefined,\n>(\n initial: DerivedSignal<TParent, T> | T,\n opt?: CreateFormControlOptions<T, TControlType>,\n): FormControlSignal<T, TParent, TControlType, TPartialValue> {\n const value = isSignal(initial) ? initial : signal(initial, opt);\n const initialValue = signal(untracked(value));\n const eq = opt?.equal ?? Object.is;\n\n const dirtyEq = opt?.dirtyEquality ?? eq;\n\n const disabled = computed(() => opt?.disable?.() ?? false);\n const readonly = computed(() => opt?.readonly?.() ?? false);\n\n const dirty = computed(() => !dirtyEq(value(), initialValue()));\n\n const touched = signal(false);\n\n const validator = computed(() => opt?.validator?.() ?? (() => ''));\n\n const error = computed(() => {\n if (opt?.overrideValidation) return opt.overrideValidation();\n if (disabled() || readonly()) return '';\n return validator()(value());\n });\n\n const markAsTouched = () => {\n touched.set(true);\n opt?.onTouched?.();\n };\n const markAllAsTouched = markAsTouched;\n\n const markAsPristine = () => touched.set(false);\n const markAllAsPristine = markAsPristine;\n\n const label = computed(() => opt?.label?.() ?? '');\n\n const partialValue = computed(() => (dirty() ? value() : undefined));\n\n const internalReconcile = (newValue: T, force = false) => {\n const isDirty = untracked(dirty);\n\n if (!isDirty || force) {\n // very dangerous use of untracked here, don't do this everywhere :)\n // thanks to u/synalx for the idea to use untracked here\n\n untracked(() => {\n initialValue.set(newValue);\n value.set(newValue);\n });\n }\n };\n\n const pending = computed(() => opt?.pending?.() ?? false);\n\n return {\n id: opt?.id?.() ?? generateID(),\n value,\n dirty,\n touched,\n error,\n label,\n required: computed(() => opt?.required?.() ?? false),\n disabled,\n readonly,\n pending,\n valid: computed(() => !pending() && !error()),\n hint: computed(() => opt?.hint?.() ?? ''),\n markAsTouched,\n markAllAsTouched,\n markAsPristine,\n markAllAsPristine,\n from: (isSignal(initial) ? initial.from : undefined) as FormControlSignal<\n T,\n TParent,\n TControlType\n >['from'],\n reconcile: (newValue: T) => internalReconcile(newValue),\n forceReconcile: (newValue: T) => internalReconcile(newValue, true),\n reset: () => {\n opt?.onReset?.();\n value.set(untracked(initialValue));\n },\n resetWithInitial: (initial: T) => {\n opt?.onReset?.();\n initialValue.set(initial);\n value.set(initial);\n },\n equal: eq,\n controlType: (opt?.controlType ?? 'control') as TControlType,\n partialValue: partialValue as Signal<TPartialValue>,\n };\n}\n","import {\n computed,\n linkedSignal,\n untracked,\n type Signal,\n type WritableSignal,\n} from '@angular/core';\nimport { derived, type DerivedSignal } from '@mmstack/primitives';\nimport {\n formControl,\n type CreateFormControlOptions,\n type FormControlSignal,\n} from './form-control';\nimport { type SignalValue } from './signal-value.type';\nimport { mergeArray } from './util';\n\nexport type FormArraySignal<\n T,\n TIndividualState extends FormControlSignal<\n T,\n any,\n any,\n any\n > = FormControlSignal<T, any, any, any>,\n TParent = undefined,\n> = FormControlSignal<\n T[],\n TParent,\n 'array',\n | Exclude<SignalValue<TIndividualState['partialValue']>, null | undefined>[]\n | undefined\n> & {\n ownError: Signal<string>;\n children: Signal<TIndividualState[]>;\n push: (value: T) => void; // add new control with value\n remove: (index: number) => void; // remove at index\n min: Signal<number>; // for display purposes\n max: Signal<number>; // for display purposes\n canAdd: Signal<boolean>; // disable add button if false\n canRemove: Signal<boolean>; // disable remove buttons if false\n};\n\nexport type CreateFormArraySignalOptions<\n T,\n TIndividualState extends FormControlSignal<T, any, any, any>,\n> = Omit<CreateFormControlOptions<T[]>, 'equal'> & {\n min?: () => number;\n max?: () => number;\n equal?: (a: T, b: T) => boolean;\n toPartialValue?: (\n v: T,\n ) => Exclude<SignalValue<TIndividualState['partialValue']>, null | undefined>;\n};\n\nfunction createReconcileChildren<\n T,\n TIndividualState extends FormControlSignal<T, any, any, any>,\n>(\n factory: (val: DerivedSignal<T[], T>, idx: number) => TIndividualState,\n opt: { equal: (a: T, b: T) => boolean },\n) {\n return (\n length: number,\n source: WritableSignal<T[]>,\n prev?: TIndividualState[],\n ): TIndividualState[] => {\n if (!prev) {\n const nextControls = [];\n\n for (let i = 0; i < length; i++) {\n nextControls.push(\n factory(derived(source, i, { equal: opt?.equal }), i),\n );\n }\n\n return nextControls;\n }\n\n if (length === prev.length) return prev;\n\n const next = [...prev];\n\n if (length < prev.length) {\n next.splice(length);\n } else if (length > prev.length) {\n for (let i = prev.length; i < length; i++) {\n next.push(factory(derived(source, i, { equal: opt?.equal }), i));\n }\n }\n\n return next;\n };\n}\n\nexport function formArray<\n T,\n TIndividualState extends FormControlSignal<\n T,\n any,\n any,\n any\n > = FormControlSignal<T, any, any, any>,\n TParent = undefined,\n>(\n initial: T[] | DerivedSignal<TParent, T[]>,\n factory: (val: DerivedSignal<T[], T>, idx: number) => TIndividualState,\n opt?: CreateFormArraySignalOptions<T, TIndividualState>,\n): FormArraySignal<T, TIndividualState, TParent> {\n const eq = opt?.equal ?? Object.is;\n\n const arrayEqual = (a: T[], b: T[]) => {\n if (a.length !== b.length) return false;\n if (!a.length) return true;\n\n return a.every((v, i) => eq(v, b[i]));\n };\n\n const min = computed(() => opt?.min?.() ?? 0);\n const max = computed(() => opt?.max?.() ?? Number.MAX_SAFE_INTEGER);\n\n const arrayOptions: CreateFormControlOptions<T[], 'array'> = {\n ...opt,\n equal: arrayEqual,\n dirtyEquality: (a, b) => a.length === b.length,\n controlType: 'array',\n };\n\n const ctrl = formControl<T[], TParent, 'array'>(\n initial,\n arrayOptions,\n ) satisfies FormControlSignal<T[], TParent, 'array'>;\n\n const length = computed(() => ctrl.value().length);\n\n const reconcileChildren = createReconcileChildren<T, TIndividualState>(\n factory,\n { equal: eq },\n );\n\n // linkedSignal used to re-use previous value so that only length changes are affected and existing controls are kept, but updated\n const children = linkedSignal<number, TIndividualState[]>({\n source: () => length(),\n computation: (len, prev) => reconcileChildren(len, ctrl.value, prev?.value),\n });\n\n const ownError = computed(() => ctrl.error());\n\n const error = computed((): string => {\n const own = ownError();\n if (own) return own;\n if (!children().length) return '';\n return children()\n .map((c, idx) => (c.error() ? `${idx}: ${c.error()}` : ''))\n .filter(Boolean)\n .join('\\n');\n });\n\n const dirty = computed(() => {\n if (ctrl.dirty()) return true;\n if (!children().length) return false;\n return children().some((c) => c.dirty());\n });\n\n const markAllAsTouched = () => {\n ctrl.markAllAsTouched();\n for (const c of untracked(children)) {\n c.markAllAsTouched();\n }\n };\n const markAllAsPristine = () => {\n ctrl.markAllAsPristine();\n for (const c of untracked(children)) {\n c.markAllAsPristine();\n }\n };\n\n const toPartialValue = opt?.toPartialValue ?? ((v: T) => v);\n const partialValue = computed(() => {\n if (!dirty()) return undefined;\n return children().map((c) => {\n const pv = c.partialValue();\n if (pv) return pv;\n if (c.controlType === 'control') return undefined;\n\n // return full value for child objects/arrays as this cannot be partially patched without idx\n return toPartialValue(c.value());\n });\n });\n\n const touched = computed(\n () =>\n ctrl.touched() ||\n !!(children().length && children().some((c) => c.touched())),\n );\n\n const reconcile = (newValue: T[]) => {\n const ctrls = untracked(children);\n\n for (let i = 0; i < newValue.length; i++) {\n ctrls.at(i)?.reconcile(newValue[i]); // reconcile existing controls that are relevant addition/removal will be handled after ctrl.reconcile through linkedSignal\n }\n\n ctrl.reconcile(mergeArray(newValue, untracked(ctrl.value)));\n };\n\n const forceReconcile = (newValue: T[]) => {\n const ctrls = untracked(children);\n\n for (let i = 0; i < newValue.length; i++) {\n ctrls.at(i)?.forceReconcile(newValue[i]);\n }\n\n ctrl.forceReconcile(newValue);\n };\n\n const childrenValid = computed(() => {\n if (!children().length) return true;\n return children().every((d) => d.valid());\n });\n\n const childrenPending = computed(\n () => !!children().length && children().some((d) => d.pending()),\n );\n\n return {\n ...ctrl,\n ownError,\n error,\n valid: computed(() => ctrl.valid() && childrenValid()),\n pending: computed(() => ctrl.pending() || childrenPending()),\n touched,\n children,\n dirty,\n markAllAsTouched,\n markAllAsPristine,\n min,\n max,\n partialValue,\n canAdd: computed(\n () => !ctrl.disabled() && !ctrl.readonly() && length() < max(),\n ),\n canRemove: computed(\n () => !ctrl.disabled() && !ctrl.readonly() && length() > min(),\n ),\n reconcile,\n forceReconcile,\n reset: () => {\n for (const c of untracked(children)) {\n c.reset();\n }\n ctrl.reset();\n },\n resetWithInitial: (initial: T[]) => {\n const ctrls = untracked(children);\n for (let i = 0; i < initial.length; i++) {\n ctrls.at(i)?.resetWithInitial(initial[i]);\n }\n ctrl.resetWithInitial(initial);\n },\n push: (next) => ctrl.value.update((cur) => [...cur, next]),\n remove: (idx) =>\n ctrl.value.update((cur) => cur.filter((_, i) => i !== idx)),\n };\n}\n","import {\n computed,\n isSignal,\n signal,\n untracked,\n type Signal,\n type WritableSignal,\n} from '@angular/core';\nimport {\n isDerivation,\n toFakeSignalDerivation,\n type DerivedSignal,\n} from '@mmstack/primitives';\nimport {\n formControl,\n type CreateFormControlOptions,\n type FormControlSignal,\n} from './form-control';\nimport { type SignalValue } from './signal-value.type';\nimport { mergeIfObject } from './util';\n\ntype AnyObject = Record<PropertyKey, any>;\n\n/**\n * Extracts the partial value types from a record of `FormControlSignal` instances.\n * This is used to construct the `partialValue` type for `FormGroupSignal`.\n * @internal\n */\ntype DerivationPartialValues<\n TDerivations extends Record<string, FormControlSignal<any, any, any, any>>,\n> = {\n [K in keyof TDerivations]: Exclude<\n SignalValue<TDerivations[K]['partialValue']>,\n undefined\n >;\n};\n\n/**\n * Represents a group of form controls, similar to Angular's `FormGroup`. It aggregates\n * the values and states of its child controls into a single object.\n *\n * @typeParam T - The type of the form group's value (an object).\n * @typeParam TDerivations - A record where keys are the names of the child controls and values are the `FormControlSignal` instances.\n * @typeParam TParent - The type of the parent form control's value (if this group is nested).\n */\nexport type FormGroupSignal<\n T,\n TDerivations extends Record<string, FormControlSignal<any, T, any, any>>,\n TParent = undefined,\n> = FormControlSignal<\n T,\n TParent,\n 'group',\n Partial<DerivationPartialValues<TDerivations>>\n> & {\n /**\n * A signal that holds a record of the child form controls. The keys are the names\n * of the controls, and the values are the `FormControlSignal` instances.\n */\n children: Signal<TDerivations>;\n /**\n * A signal that holds the validation error message of the group itself (excluding child errors).\n */\n ownError: Signal<string>;\n};\n\n/**\n * Options for creating a `FormGroupSignal`. Extends `CreateFormControlOptions`.\n */\nexport type CreateFormGroupOptions<\n T,\n TDerivations extends Record<string, FormControlSignal<any, T, any, any>>,\n> = CreateFormControlOptions<T, 'group'> & {\n /**\n * An optional function to create a base object for the `partialValue` signal.\n * This can be used to pre-populate the partial value with default values or\n * to perform custom logic before merging in the partial values from child controls.\n */\n createBasePartialValue?: (\n value: T,\n ) => Partial<DerivationPartialValues<TDerivations>>;\n};\n\n/**\n * Creates a `FormGroupSignal`, which aggregates a set of child form controls into a single object.\n *\n * @typeParam T - The type of the form group's value (an object).\n * @typeParam TDerivations - A record where keys are the names of the child controls and values are the `FormControlSignal` instances.\n * @typeParam TParent - The type of the parent form control's value (if this group is nested within another group or array).\n * @param initial - The initial value of the form group (or a `WritableSignal` or `DerivedSignal` if the group is nested).\n * @param providedChildren - An object containing the child `FormControlSignal` instances, or a function that returns such an object.\n * Using a function allows for dynamic creation of child controls (e.g., in response to changes in other signals).\n * @param options - Optional configuration options for the form group.\n * @returns A `FormGroupSignal` instance.\n *\n * @example\n * // Create a simple form group:\n * const user = signal({ name: 'John Doe', age: 30 });\n * const form = formGroup(user, {\n * name: formControl(derived(user, 'name')),\n * age: formControl(derived(user, 'age')),\n * })\n *\n * // Create a nested form group:\n * const user = signal({ name: 'John', age: 30, address: {street: \"Some street\"} });\n *\n * const address = derived(user, 'address');\n * const userForm = formGroup(user, {\n * name: formControl(derived(user, 'name')),\n * age: formControl(derived(user, 'age')),\n * address: formGroup(address, {\n * street: formControl(derived(address, (address) => address.street), {\n * validator: () => (value) => value ? \"\" : \"required!\"\n * }) // you can create deeply nested structures.\n * })\n * });\n *\n * // Create a form group with dynamically created children replaced rare FormRecord requirements.\n * const showAddress = signal(false);\n * type Characteristic = {\n * valueType: 'string';\n * value: string;\n * } | {\n * valueType: 'number';\n * value: number;\n * }\n * const char = signal<Characteristic>({ valueType: 'string', value: '' });\n * const charForm = formGroup(char, () => {\n * if (char().valueType === 'string) return createStringControl(char);\n * return createNumberControl(char);\n * });\n *\n */\nexport function formGroup<\n T,\n TDerivations extends Record<string, FormControlSignal<any, T, any, any>>,\n TParent = undefined,\n>(\n initial: DerivedSignal<TParent, T> | T | WritableSignal<T>,\n providedChildren: (() => TDerivations) | TDerivations,\n opt?: CreateFormGroupOptions<T, TDerivations>,\n): FormGroupSignal<T, TDerivations, TParent> {\n const valueSignal = isSignal(initial) ? initial : signal(initial);\n // we fake a derivation if not present, so that .from is present on the signal\n const value = isDerivation<TParent, T>(valueSignal)\n ? valueSignal\n : toFakeSignalDerivation<TParent, T>(valueSignal);\n\n // we allow for a function/signal to be passed, this case should only be used if the child controls change dependent upon something, say if a formControl is flipped into a formGroup.\n const children =\n typeof providedChildren === 'function'\n ? computed(() => providedChildren())\n : computed(() => providedChildren);\n\n // array allows for easier handling\n const derivationsArray = computed(() => Object.values(children()));\n\n const childrenDirty = computed(\n () =>\n !!derivationsArray().length && derivationsArray().some((d) => d.dirty()),\n );\n\n // by default dont compare object references, just use childrenDirtySignal\n const baseDirtyEq = opt?.dirtyEquality ?? opt?.equal ?? (() => true);\n\n // function which calls a signal becomes a signal\n const dirtyEquality = (a: T, b: T) => {\n return baseDirtyEq(a, b) && !childrenDirty();\n };\n\n // group control\n const ctrl = formControl<T, TParent, 'group'>(value, {\n ...opt,\n dirtyEquality,\n controlType: 'group',\n readonly: () => {\n // readonly if is readonly or all children are readonly\n if (opt?.readonly?.()) return true;\n return (\n !!derivationsArray().length &&\n derivationsArray().every((d) => d.readonly())\n );\n },\n disable: () => {\n if (opt?.disable?.()) return true;\n return (\n !!derivationsArray().length &&\n derivationsArray().every((d) => d.disabled())\n );\n },\n }) satisfies FormControlSignal<T, TParent, 'group'>;\n\n const childrenTouched = computed(\n () =>\n !!derivationsArray().length &&\n derivationsArray().some((d) => d.touched()),\n );\n\n const touched = computed(() => ctrl.touched() || childrenTouched());\n\n const childError = computed(() => {\n if (!derivationsArray().length) return '';\n return derivationsArray()\n .map((d) => (d.error() ? `${d.label()}: ${d.error()}` : ''))\n .filter(Boolean)\n .join('\\n');\n });\n\n const error = computed(() => {\n const ownError = ctrl.error();\n if (ownError) return ownError;\n return childError() ? 'INVALID' : '';\n });\n\n const markAllAsTouched = () => {\n ctrl.markAllAsTouched();\n for (const ctrl of untracked(derivationsArray)) {\n ctrl.markAllAsTouched();\n }\n };\n\n const markAllAsPristine = () => {\n ctrl.markAllAsPristine();\n for (const ctrl of untracked(derivationsArray)) {\n ctrl.markAllAsPristine();\n }\n };\n\n const reconcile = (newValue: T) => {\n // set the children values based on the derivation of the new value\n for (const ctrl of untracked(derivationsArray)) {\n const from = ctrl.from;\n if (!from) continue;\n ctrl.reconcile(from(newValue));\n }\n ctrl.reconcile(mergeIfObject(newValue, untracked(value)));\n };\n\n const forceReconcile = (newValue: T) => {\n for (const ctrl of untracked(derivationsArray)) {\n const from = ctrl.from;\n if (!from) continue;\n ctrl.forceReconcile(from(newValue));\n }\n ctrl.forceReconcile(newValue);\n };\n\n const createBaseValueFn = opt?.createBasePartialValue;\n\n const basePartialValue: Signal<\n Partial<DerivationPartialValues<TDerivations>>\n > = createBaseValueFn\n ? computed(() => createBaseValueFn(ctrl.value()))\n : computed(() => ({}));\n\n const partialValue = computed(() => {\n const obj: Partial<DerivationPartialValues<TDerivations>> = {\n ...basePartialValue(),\n };\n\n if (!ctrl.dirty()) return obj;\n\n for (const [key, ctrl] of Object.entries(children())) {\n const pv = ctrl.partialValue();\n\n if (pv === undefined) continue;\n (obj as AnyObject)[key] = pv;\n }\n\n return obj;\n });\n\n const childrenValid = computed(() => {\n if (!derivationsArray().length) return true;\n return derivationsArray().every((d) => d.valid());\n });\n\n const childrenPending = computed(\n () =>\n !!derivationsArray().length &&\n derivationsArray().some((d) => d.pending()),\n );\n\n return {\n ...ctrl,\n children,\n partialValue,\n reconcile,\n forceReconcile,\n ownError: ctrl.error,\n touched,\n error,\n valid: computed(() => ctrl.valid() && childrenValid()),\n pending: computed(() => ctrl.pending() || childrenPending()),\n markAllAsPristine,\n markAllAsTouched,\n reset: () => {\n for (const ctrl of untracked(derivationsArray)) {\n ctrl.reset();\n }\n ctrl.reset();\n },\n resetWithInitial: (initial: T) => {\n for (const ctrl of untracked(derivationsArray)) {\n const from = ctrl.from;\n if (from) ctrl.resetWithInitial(from(initial));\n else ctrl.reset();\n }\n ctrl.resetWithInitial(initial);\n },\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACG,SAAU,UAAU,CAAkB,IAAO,EAAE,IAAO,EAAA;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,KAC1B,aAAa,CAAY,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CACvC;AACR;AAEA;;;;;;;;;;;;;;AAcG;AACG,SAAU,aAAa,CAAI,IAAO,EAAE,IAAO,EAAA;AAC/C,IAAA,IAAI,OAAO,IAAI,KAAK,OAAO,IAAI;AAAE,QAAA,OAAO,IAAI;IAC5C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;AACrE,IAAA,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI;AAAE,QAAA,OAAO,IAAI;AAC/C,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC;AAC7E,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;AAE3D,IAAA,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE;AAC7B;AAEA;;;;AAIG;SACa,UAAU,GAAA;AACxB,IAAA,IAAI,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE;AACjC,QAAA,OAAO,UAAU,CAAC,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AO,EAAE,IAAI,eAAe,EAAE,CAAC;QAC5D,iBAAiB;QACjB,gBAAgB;QAChB,KAAK,EAAE,MAAK;YACV,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,gBAAgB,CAAC,EAAE;gBAC9C,IAAI,CAAC,KAAK,EAAE;YACd;YACA,IAAI,CAAC,KAAK,EAAE;QACd,CAAC;AACD,QAAA,gBAAgB,EAAE,CAAC,OAAU,KAAI;YAC/B,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,gBAAgB,CAAC,EAAE;AAC9C,gBAAA,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI;AACtB,gBAAA,IAAI,IAAI;oBAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;;oBACzC,IAAI,CAAC,KAAK,EAAE;YACnB;AACA,YAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;QAChC,CAAC;KACF;AACH;;ACvTA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"mmstack-form-core.mjs","sources":["../../../../../packages/form/core/src/lib/util.ts","../../../../../packages/form/core/src/lib/form-control.ts","../../../../../packages/form/core/src/lib/form-array.ts","../../../../../packages/form/core/src/lib/form-group.ts","../../../../../packages/form/core/src/mmstack-form-core.ts"],"sourcesContent":["/**\n * Merges two arrays element by element using the `mergeIfObject` logic.\n *\n * The resulting array will have the same length as the `next` array.\n * For each index `i`, the element in the resulting array is determined by:\n * `mergeIfObject(prev[i], next[i])`.\n * If `prev` is shorter than `next`, `prev[i]` will be `undefined` for the out-of-bounds indices.\n *\n * @template {any[]} T The array type being merged.\n * @param {T} prev The previous array.\n * @param {T} next The next array.\n * @returns {T} A new array containing the merged elements.\n * @example\n * const prev = [1, { id: 1, name: \"A\" }, [10], \"extraPrev\"];\n * const next = [2, { id: 1, status: \"B\" }, [20, 21], missing , { id: 2 }];\n *\n * mergeArray(prev, next);\n * // Result approx:\n * // [\n * // 2, // Primitive replaced\n * // { id: 1, name: \"A\", status: \"B\" }, // Objects shallow-merged\n * // [20, 21], // Arrays replaced (via mergeIfObject -> mergeArray)\n * // undefined, // Primitive replaced by missing item in sparse 'next' array\n * // { id: 2 } // Added from 'next' (prev[4] was undefined)\n * // ]\n */\nexport function mergeArray<T extends any[]>(prev: T, next: T): T {\n return next.map((item, index): T[number] =>\n mergeIfObject<T[number]>(prev[index], item),\n ) as T;\n}\n\n/**\n * Merges two values (`prev`, `next`), prioritizing `next` in most cases.\n *\n * Behavior:\n * - If both `prev` and `next` are non-null, non-array objects, it performs a **shallow merge**\n * (`{ ...prev, ...next }`), where properties from `next` overwrite those in `prev`.\n * - If both `prev` and `next` are arrays, it delegates to `mergeArray` for element-wise merging.\n * - In all other scenarios (type mismatch, primitives, null involved, array mixed with object),\n * it simply returns the `next` value.\n *\n * @template T The type of the values being merged.\n * @param {T | undefined} prev The previous value (can be undefined if accessed out of array bounds).\n * @param {T} next The next value.\n * @returns {T} The merged result based on the rules above.\n */\nexport function mergeIfObject<T>(prev: T, next: T): T {\n if (typeof prev !== typeof next) return next;\n if (typeof prev !== 'object' || typeof next !== 'object') return next;\n if (prev === null || next === null) return next;\n if (Array.isArray(prev) && Array.isArray(next)) return mergeArray(prev, next);\n if (Array.isArray(prev) || Array.isArray(next)) return next;\n\n return { ...prev, ...next };\n}\n\n/**\n * Generates a unique ID using crypto.randomUUID if available,\n * otherwise falls back to a non-secure random string.\n * @returns {string}\n */\nexport function generateID() {\n if (globalThis.crypto?.randomUUID) {\n return globalThis.crypto.randomUUID();\n }\n return Math.random().toString(36).substring(2);\n}\n","import {\n computed,\n isSignal,\n signal,\n untracked,\n type CreateSignalOptions,\n type Signal,\n type ValueEqualityFn,\n type WritableSignal,\n} from '@angular/core';\nimport { type DerivedSignal } from '@mmstack/primitives';\nimport { generateID } from './util';\n\n/**\n * Represents the type of a form control.\n * - `control`: A single form control (e.g., an input field).\n * - `array`: An array of form controls (like Angular's `FormArray`).\n * - `group`: A group of form controls (like Angular's `FormGroup`).\n */\nexport type ControlType = 'control' | 'array' | 'group';\n\n/**\n * Represents a reactive form control. It holds the value, validation status, and other\n * metadata for a form field. This is the core building block for creating reactive forms\n * with signals.\n *\n * @typeParam T - The type of the form control's value.\n * @typeParam TParent - The type of the parent form control's value (if this control is part of a group or array). Defaults to `undefined`.\n * @typeParam TControlType - The type of the control ('control', 'array', or 'group'). Defaults to 'control'.\n * @typeParam TPartialValue - The type of the partial value, used for patching.\n */\nexport type FormControlSignal<\n T,\n TParent = undefined,\n TControlType extends ControlType = 'control',\n TPartialValue = T | undefined,\n> = {\n /** A unique identifier for the control. Used for tracking in `@for` loops. */\n id: string;\n /** The main value signal for the control. */\n value: WritableSignal<T>;\n /** A signal indicating whether the control's value has been changed. */\n dirty: Signal<boolean>;\n /** A signal indicating whether the control has been interacted with (e.g., blurred). */\n touched: Signal<boolean>;\n /** A signal containing the current validation error message (empty string if valid). */\n error: Signal<string>;\n /** A signal indicating whether the control is pending */\n pending: Signal<boolean>;\n /** A signal indicating whether the control is disabled. */\n /** A signal indicating whether the control is in a valid state (without errors & not pending) */\n valid: Signal<boolean>;\n disabled: Signal<boolean>;\n /** A signal indicating whether the control is read-only. */\n readonly: Signal<boolean>;\n /** A signal indicating whether the control is required. */\n required: Signal<boolean>;\n /** A signal containing the label for the control. */\n label: Signal<string>;\n /** A signal containing the hint text for the control. */\n hint: Signal<string>;\n /** Marks the control as touched. */\n markAsTouched: () => void;\n /** Marks the control and all its child controls (if any) as touched. */\n markAllAsTouched: () => void;\n /** Marks the control as pristine (not touched). */\n markAsPristine: () => void;\n /** Marks the control and all its child controls (if any) as pristine. */\n markAllAsPristine: () => void;\n /**\n * Resets the control to a new value and sets a new initial value. This is intended for\n * scenarios where the underlying data is updated externally (e.g., data coming from\n * the server). If the control is not dirty, the value is updated. If the control *is*\n * dirty, the value is *not* updated (preserving user changes).\n */\n reconcile: (newValue: T) => void;\n /**\n * Similar to `reconcile`, but forces the update even if the control is dirty.\n */\n forceReconcile: (newValue: T) => void;\n /** Resets the control's value to its initial value. */\n reset: () => void;\n /** Resets the control's value and initial value. */\n resetWithInitial: (initial: T) => void;\n /**\n * The derivation function used to create this control if it's part of a `formGroup` or `formArray`.\n * @internal\n */\n from?: DerivedSignal<TParent, T>['from'];\n /** The equality function used to compare values. Defaults to `Object.is`. */\n equal: (a: T, b: T) => boolean;\n /** The type of the control ('control', 'array', or 'group'). */\n controlType: TControlType;\n /**\n * A signal representing the partial value of the control, suitable for patching data on a server.\n * It contains the changed value if `dirty` is `true`.\n */\n partialValue: Signal<TPartialValue>;\n};\n\nexport type CreateFormControlOptions<\n T,\n TControlType extends ControlType = ControlType,\n> = CreateSignalOptions<T> & {\n validator?: () => (value: T) => string;\n onTouched?: () => void;\n disable?: () => boolean;\n readonly?: () => boolean;\n required?: () => boolean;\n label?: () => string;\n id?: () => string;\n hint?: () => string;\n dirtyEquality?: ValueEqualityFn<T>;\n onReset?: () => void;\n controlType?: TControlType;\n overrideValidation?: () => string;\n pending?: () => boolean;\n};\n\n/**\n * Creates a `FormControlSignal`, a reactive form control that holds a value and tracks its\n * validity, dirty state, touched state, and other metadata.\n *\n * @typeParam T - The type of the form control's value.\n * @typeParam TParent - The type of the parent form control's value (if this control is part of a group or array).\n * @typeParam TControlType - The type of the control. Defaults to `'control'`.\n * @typeParam TPartialValue - The type of value when patching\n * @param initial - The initial value of the control, or a `DerivedSignal` if this control is part of a `formGroup` or `formArray`.\n * @param options - Optional configuration options for the control.\n * @returns A `FormControlSignal` instance.\n *\n * @example\n * // Create a simple form control:\n * const name = formControl('Initial Name');\n *\n * // Create a form control with validation:\n * const age = formControl(0, {\n * validator: () => (value) => value >= 18 ? '' : 'Must be at least 18',\n * });\n *\n * // Create a derived form control (equivalent to the above, but more explicit):\n * const user = signal({ name: 'John Doe', age: 30 });\n * const name = formControl(derived(user, {\n * from: (u) => u.name,\n * onChange: (newName) => user.update(u => ({...u, name: newName}))\n * }));\n *\n * // Create a form group with nested controls:\n * const user = signal({ name: 'John Doe', age: 30 });\n * const form = formGroup(user, {\n * name: formControl(derived(user, 'name')),\n * age: formControl(derived(user, 'age')),\n * })\n */\nexport function formControl<\n T,\n TParent = undefined,\n TControlType extends ControlType = 'control',\n TPartialValue = T | undefined,\n>(\n initial: DerivedSignal<TParent, T> | T,\n opt?: CreateFormControlOptions<T, TControlType>,\n): FormControlSignal<T, TParent, TControlType, TPartialValue> {\n const value = isSignal(initial) ? initial : signal(initial, opt);\n const initialValue = signal(untracked(value));\n const eq = opt?.equal ?? Object.is;\n\n const dirtyEq = opt?.dirtyEquality ?? eq;\n\n const disabled = computed(() => opt?.disable?.() ?? false);\n const readonly = computed(() => opt?.readonly?.() ?? false);\n\n const dirty = computed(() => !dirtyEq(value(), initialValue()));\n\n const touched = signal(false);\n\n const validator = computed(() => opt?.validator?.() ?? (() => ''));\n\n const error = computed(() => {\n if (opt?.overrideValidation) return opt.overrideValidation();\n if (disabled() || readonly()) return '';\n return validator()(value());\n });\n\n const markAsTouched = () => {\n touched.set(true);\n opt?.onTouched?.();\n };\n const markAllAsTouched = markAsTouched;\n\n const markAsPristine = () => touched.set(false);\n const markAllAsPristine = markAsPristine;\n\n const label = computed(() => opt?.label?.() ?? '');\n\n const partialValue = computed(() => (dirty() ? value() : undefined));\n\n const internalReconcile = (newValue: T, force = false) => {\n const isDirty = untracked(dirty);\n\n if (!isDirty || force) {\n // very dangerous use of untracked here, don't do this everywhere :)\n // thanks to u/synalx for the idea to use untracked here\n\n untracked(() => {\n initialValue.set(newValue);\n value.set(newValue);\n });\n }\n };\n\n const pending = computed(() => opt?.pending?.() ?? false);\n\n return {\n id: opt?.id?.() ?? generateID(),\n value,\n dirty,\n touched,\n error,\n label,\n required: computed(() => opt?.required?.() ?? false),\n disabled,\n readonly,\n pending,\n valid: computed(() => !pending() && !error()),\n hint: computed(() => opt?.hint?.() ?? ''),\n markAsTouched,\n markAllAsTouched,\n markAsPristine,\n markAllAsPristine,\n from: (isSignal(initial) ? initial.from : undefined) as FormControlSignal<\n T,\n TParent,\n TControlType\n >['from'],\n reconcile: (newValue: T) => internalReconcile(newValue),\n forceReconcile: (newValue: T) => internalReconcile(newValue, true),\n reset: () => {\n opt?.onReset?.();\n value.set(untracked(initialValue));\n },\n resetWithInitial: (initial: T) => {\n opt?.onReset?.();\n initialValue.set(initial);\n value.set(initial);\n },\n equal: eq,\n controlType: (opt?.controlType ?? 'control') as TControlType,\n partialValue: partialValue as Signal<TPartialValue>,\n };\n}\n","import {\n computed,\n linkedSignal,\n untracked,\n type Signal,\n type WritableSignal,\n} from '@angular/core';\nimport { derived, type DerivedSignal } from '@mmstack/primitives';\nimport {\n formControl,\n type CreateFormControlOptions,\n type FormControlSignal,\n} from './form-control';\nimport { type SignalValue } from './signal-value.type';\nimport { mergeArray } from './util';\n\nexport type FormArraySignal<\n T,\n TIndividualState extends FormControlSignal<\n T,\n any,\n any,\n any\n > = FormControlSignal<T, any, any, any>,\n TParent = undefined,\n> = FormControlSignal<\n T[],\n TParent,\n 'array',\n | Exclude<SignalValue<TIndividualState['partialValue']>, null | undefined>[]\n | undefined\n> & {\n ownError: Signal<string>;\n children: Signal<TIndividualState[]>;\n push: (value: T) => void; // add new control with value\n remove: (index: number) => void; // remove at index\n min: Signal<number>; // for display purposes\n max: Signal<number>; // for display purposes\n canAdd: Signal<boolean>; // disable add button if false\n canRemove: Signal<boolean>; // disable remove buttons if false\n};\n\nexport type CreateFormArraySignalOptions<\n T,\n TIndividualState extends FormControlSignal<T, any, any, any>,\n> = Omit<CreateFormControlOptions<T[]>, 'equal'> & {\n min?: () => number;\n max?: () => number;\n equal?: (a: T, b: T) => boolean;\n toPartialValue?: (\n v: T,\n ) => Exclude<SignalValue<TIndividualState['partialValue']>, null | undefined>;\n};\n\nfunction createReconcileChildren<\n T,\n TIndividualState extends FormControlSignal<T, any, any, any>,\n>(\n factory: (val: DerivedSignal<T[], T>, idx: number) => TIndividualState,\n opt: { equal: (a: T, b: T) => boolean },\n) {\n return (\n length: number,\n source: WritableSignal<T[]>,\n prev?: TIndividualState[],\n ): TIndividualState[] => {\n if (!prev) {\n const nextControls = [];\n\n for (let i = 0; i < length; i++) {\n nextControls.push(\n factory(derived(source, i, { equal: opt?.equal }), i),\n );\n }\n\n return nextControls;\n }\n\n if (length === prev.length) return prev;\n\n const next = [...prev];\n\n if (length < prev.length) {\n next.splice(length);\n } else if (length > prev.length) {\n for (let i = prev.length; i < length; i++) {\n next.push(factory(derived(source, i, { equal: opt?.equal }), i));\n }\n }\n\n return next;\n };\n}\n\nexport function formArray<\n T,\n TIndividualState extends FormControlSignal<\n T,\n any,\n any,\n any\n > = FormControlSignal<T, any, any, any>,\n TParent = undefined,\n>(\n initial: T[] | DerivedSignal<TParent, T[]>,\n factory: (val: DerivedSignal<T[], T>, idx: number) => TIndividualState,\n opt?: CreateFormArraySignalOptions<T, TIndividualState>,\n): FormArraySignal<T, TIndividualState, TParent> {\n const eq = opt?.equal ?? Object.is;\n\n const arrayEqual = (a: T[], b: T[]) => {\n if (a.length !== b.length) return false;\n if (!a.length) return true;\n\n return a.every((v, i) => eq(v, b[i]));\n };\n\n const min = computed(() => opt?.min?.() ?? 0);\n const max = computed(() => opt?.max?.() ?? Number.MAX_SAFE_INTEGER);\n\n const arrayOptions: CreateFormControlOptions<T[], 'array'> = {\n ...opt,\n equal: arrayEqual,\n dirtyEquality: (a, b) => a.length === b.length,\n controlType: 'array',\n };\n\n const ctrl = formControl<T[], TParent, 'array'>(\n initial,\n arrayOptions,\n ) satisfies FormControlSignal<T[], TParent, 'array'>;\n\n const length = computed(() => ctrl.value().length);\n\n const reconcileChildren = createReconcileChildren<T, TIndividualState>(\n factory,\n { equal: eq },\n );\n\n // linkedSignal used to re-use previous value so that only length changes are affected and existing controls are kept, but updated\n const children = linkedSignal<number, TIndividualState[]>({\n source: () => length(),\n computation: (len, prev) => reconcileChildren(len, ctrl.value, prev?.value),\n });\n\n const ownError = computed(() => ctrl.error());\n\n const error = computed((): string => {\n const own = ownError();\n if (own) return own;\n if (!children().length) return '';\n return children()\n .map((c, idx) => (c.error() ? `${idx}: ${c.error()}` : ''))\n .filter(Boolean)\n .join('\\n');\n });\n\n const dirty = computed(() => {\n if (ctrl.dirty()) return true;\n if (!children().length) return false;\n return children().some((c) => c.dirty());\n });\n\n const markAllAsTouched = () => {\n ctrl.markAllAsTouched();\n for (const c of untracked(children)) {\n c.markAllAsTouched();\n }\n };\n const markAllAsPristine = () => {\n ctrl.markAllAsPristine();\n for (const c of untracked(children)) {\n c.markAllAsPristine();\n }\n };\n\n const toPartialValue = opt?.toPartialValue ?? ((v: T) => v);\n const partialValue = computed(() => {\n if (!dirty()) return undefined;\n return children().map((c) => {\n const pv = c.partialValue();\n if (pv) return pv;\n if (c.controlType === 'control') return undefined;\n\n // return full value for child objects/arrays as this cannot be partially patched without idx\n return toPartialValue(c.value());\n });\n });\n\n const touched = computed(\n () =>\n ctrl.touched() ||\n !!(children().length && children().some((c) => c.touched())),\n );\n\n const reconcile = (newValue: T[]) => {\n const ctrls = untracked(children);\n\n for (let i = 0; i < newValue.length; i++) {\n ctrls.at(i)?.reconcile(newValue[i]); // reconcile existing controls that are relevant addition/removal will be handled after ctrl.reconcile through linkedSignal\n }\n\n ctrl.reconcile(mergeArray(newValue, untracked(ctrl.value)));\n };\n\n const forceReconcile = (newValue: T[]) => {\n const ctrls = untracked(children);\n\n for (let i = 0; i < newValue.length; i++) {\n ctrls.at(i)?.forceReconcile(newValue[i]);\n }\n\n ctrl.forceReconcile(newValue);\n };\n\n const childrenValid = computed(() => {\n if (!children().length) return true;\n return children().every((d) => d.valid());\n });\n\n const childrenPending = computed(\n () => !!children().length && children().some((d) => d.pending()),\n );\n\n return {\n ...ctrl,\n ownError,\n error,\n valid: computed(() => ctrl.valid() && childrenValid()),\n pending: computed(() => ctrl.pending() || childrenPending()),\n touched,\n children,\n dirty,\n markAllAsTouched,\n markAllAsPristine,\n min,\n max,\n partialValue,\n canAdd: computed(\n () => !ctrl.disabled() && !ctrl.readonly() && length() < max(),\n ),\n canRemove: computed(\n () => !ctrl.disabled() && !ctrl.readonly() && length() > min(),\n ),\n reconcile,\n forceReconcile,\n reset: () => {\n for (const c of untracked(children)) {\n c.reset();\n }\n ctrl.reset();\n },\n resetWithInitial: (initial: T[]) => {\n const ctrls = untracked(children);\n for (let i = 0; i < initial.length; i++) {\n ctrls.at(i)?.resetWithInitial(initial[i]);\n }\n ctrl.resetWithInitial(initial);\n },\n push: (next) => ctrl.value.update((cur) => [...cur, next]),\n remove: (idx) =>\n ctrl.value.update((cur) => cur.filter((_, i) => i !== idx)),\n };\n}\n","import {\n computed,\n isSignal,\n signal,\n untracked,\n type Signal,\n type WritableSignal,\n} from '@angular/core';\nimport {\n isDerivation,\n toFakeSignalDerivation,\n type DerivedSignal,\n} from '@mmstack/primitives';\nimport {\n formControl,\n type CreateFormControlOptions,\n type FormControlSignal,\n} from './form-control';\nimport { type SignalValue } from './signal-value.type';\nimport { mergeIfObject } from './util';\n\n/**\n * Extracts the partial value types from a record of `FormControlSignal` instances.\n * This is used to construct the `partialValue` type for `FormGroupSignal`.\n * @internal\n */\ntype DerivationPartialValues<\n TDerivations extends Record<string, FormControlSignal<any, any, any, any>>,\n> = {\n [K in keyof TDerivations]: Exclude<\n SignalValue<TDerivations[K]['partialValue']>,\n undefined\n >;\n};\n\n/**\n * Represents a group of form controls, similar to Angular's `FormGroup`. It aggregates\n * the values and states of its child controls into a single object.\n *\n * @typeParam T - The type of the form group's value (an object).\n * @typeParam TDerivations - A record where keys are the names of the child controls and values are the `FormControlSignal` instances.\n * @typeParam TParent - The type of the parent form control's value (if this group is nested).\n */\nexport type FormGroupSignal<\n T,\n TDerivations extends Record<string, FormControlSignal<any, T, any, any>>,\n TParent = undefined,\n> = FormControlSignal<\n T,\n TParent,\n 'group',\n Partial<DerivationPartialValues<TDerivations>>\n> & {\n /**\n * A signal that holds a record of the child form controls. The keys are the names\n * of the controls, and the values are the `FormControlSignal` instances.\n */\n children: Signal<TDerivations>;\n /**\n * A signal that holds the validation error message of the group itself (excluding child errors).\n */\n ownError: Signal<string>;\n};\n\n/**\n * Options for creating a `FormGroupSignal`. Extends `CreateFormControlOptions`.\n */\nexport type CreateFormGroupOptions<\n T,\n TDerivations extends Record<string, FormControlSignal<any, T, any, any>>,\n> = CreateFormControlOptions<T, 'group'> & {\n /**\n * An optional function to create a base object for the `partialValue` signal.\n * This can be used to pre-populate the partial value with default values or\n * to perform custom logic before merging in the partial values from child controls.\n */\n createBasePartialValue?: (\n value: T,\n ) => Partial<DerivationPartialValues<TDerivations>>;\n};\n\n/**\n * Creates a `FormGroupSignal`, which aggregates a set of child form controls into a single object.\n *\n * @typeParam T - The type of the form group's value (an object).\n * @typeParam TDerivations - A record where keys are the names of the child controls and values are the `FormControlSignal` instances.\n * @typeParam TParent - The type of the parent form control's value (if this group is nested within another group or array).\n * @param initial - The initial value of the form group (or a `WritableSignal` or `DerivedSignal` if the group is nested).\n * @param providedChildren - An object containing the child `FormControlSignal` instances, or a function that returns such an object.\n * Using a function allows for dynamic creation of child controls (e.g., in response to changes in other signals).\n * @param options - Optional configuration options for the form group.\n * @returns A `FormGroupSignal` instance.\n *\n * @example\n * // Create a simple form group:\n * const user = signal({ name: 'John Doe', age: 30 });\n * const form = formGroup(user, {\n * name: formControl(derived(user, 'name')),\n * age: formControl(derived(user, 'age')),\n * })\n *\n * // Create a nested form group:\n * const user = signal({ name: 'John', age: 30, address: {street: \"Some street\"} });\n *\n * const address = derived(user, 'address');\n * const userForm = formGroup(user, {\n * name: formControl(derived(user, 'name')),\n * age: formControl(derived(user, 'age')),\n * address: formGroup(address, {\n * street: formControl(derived(address, (address) => address.street), {\n * validator: () => (value) => value ? \"\" : \"required!\"\n * }) // you can create deeply nested structures.\n * })\n * });\n *\n * // Create a form group with dynamically created children replaced rare FormRecord requirements.\n * const showAddress = signal(false);\n * type Characteristic = {\n * valueType: 'string';\n * value: string;\n * } | {\n * valueType: 'number';\n * value: number;\n * }\n * const char = signal<Characteristic>({ valueType: 'string', value: '' });\n * const charForm = formGroup(char, () => {\n * if (char().valueType === 'string) return createStringControl(char);\n * return createNumberControl(char);\n * });\n *\n */\nexport function formGroup<\n T,\n TDerivations extends Record<string, FormControlSignal<any, T, any, any>>,\n TParent = undefined,\n>(\n initial: DerivedSignal<TParent, T> | T | WritableSignal<T>,\n providedChildren: (() => TDerivations) | TDerivations,\n opt?: CreateFormGroupOptions<T, TDerivations>,\n): FormGroupSignal<T, TDerivations, TParent> {\n const valueSignal = isSignal(initial) ? initial : signal(initial);\n // we fake a derivation if not present, so that .from is present on the signal\n const value = isDerivation<TParent, T>(valueSignal)\n ? valueSignal\n : toFakeSignalDerivation<TParent, T>(valueSignal);\n\n // we allow for a function/signal to be passed, this case should only be used if the child controls change dependent upon something, say if a formControl is flipped into a formGroup.\n const children =\n typeof providedChildren === 'function'\n ? computed(() => providedChildren())\n : computed(() => providedChildren);\n\n // array allows for easier handling\n const derivationsArray = computed(() => Object.values(children()));\n\n const childrenDirty = computed(\n () =>\n !!derivationsArray().length && derivationsArray().some((d) => d.dirty()),\n );\n\n // by default dont compare object references, just use childrenDirtySignal\n const baseDirtyEq = opt?.dirtyEquality ?? opt?.equal ?? (() => true);\n\n // function which calls a signal becomes a signal\n const dirtyEquality = (a: T, b: T) => {\n return baseDirtyEq(a, b) && !childrenDirty();\n };\n\n // group control\n const ctrl = formControl<T, TParent, 'group'>(value, {\n ...opt,\n dirtyEquality,\n controlType: 'group',\n readonly: () => {\n // readonly if is readonly or all children are readonly\n if (opt?.readonly?.()) return true;\n return (\n !!derivationsArray().length &&\n derivationsArray().every((d) => d.readonly())\n );\n },\n disable: () => {\n if (opt?.disable?.()) return true;\n return (\n !!derivationsArray().length &&\n derivationsArray().every((d) => d.disabled())\n );\n },\n }) satisfies FormControlSignal<T, TParent, 'group'>;\n\n const childrenTouched = computed(\n () =>\n !!derivationsArray().length &&\n derivationsArray().some((d) => d.touched()),\n );\n\n const touched = computed(() => ctrl.touched() || childrenTouched());\n\n const childError = computed(() => {\n if (!derivationsArray().length) return '';\n return derivationsArray()\n .map((d) => (d.error() ? `${d.label()}: ${d.error()}` : ''))\n .filter(Boolean)\n .join('\\n');\n });\n\n const error = computed(() => {\n const ownError = ctrl.error();\n if (ownError) return ownError;\n return childError() ? 'INVALID' : '';\n });\n\n const markAllAsTouched = () => {\n ctrl.markAllAsTouched();\n for (const ctrl of untracked(derivationsArray)) {\n ctrl.markAllAsTouched();\n }\n };\n\n const markAllAsPristine = () => {\n ctrl.markAllAsPristine();\n for (const ctrl of untracked(derivationsArray)) {\n ctrl.markAllAsPristine();\n }\n };\n\n const reconcile = (newValue: T) => {\n // set the children values based on the derivation of the new value\n for (const ctrl of untracked(derivationsArray)) {\n const from = ctrl.from;\n if (!from) continue;\n ctrl.reconcile(from(newValue));\n }\n ctrl.reconcile(mergeIfObject(newValue, untracked(value)));\n };\n\n const forceReconcile = (newValue: T) => {\n for (const ctrl of untracked(derivationsArray)) {\n const from = ctrl.from;\n if (!from) continue;\n ctrl.forceReconcile(from(newValue));\n }\n ctrl.forceReconcile(newValue);\n };\n\n const createBaseValueFn = opt?.createBasePartialValue;\n\n const basePartialValue: Signal<\n Partial<DerivationPartialValues<TDerivations>>\n > = createBaseValueFn\n ? computed(() => createBaseValueFn(ctrl.value()))\n : computed(() => ({}));\n\n const partialValue = computed(() => {\n const obj: Partial<DerivationPartialValues<TDerivations>> = {\n ...basePartialValue(),\n };\n\n if (!ctrl.dirty()) return obj;\n\n for (const [key, ctrl] of Object.entries(children())) {\n const pv = ctrl.partialValue();\n\n if (pv === undefined) continue;\n (obj as Record<PropertyKey, any>)[key] = pv;\n }\n\n return obj;\n });\n\n const childrenValid = computed(() => {\n if (!derivationsArray().length) return true;\n return derivationsArray().every((d) => d.valid());\n });\n\n const childrenPending = computed(\n () =>\n !!derivationsArray().length &&\n derivationsArray().some((d) => d.pending()),\n );\n\n return {\n ...ctrl,\n children,\n partialValue,\n reconcile,\n forceReconcile,\n ownError: ctrl.error,\n touched,\n error,\n valid: computed(() => ctrl.valid() && childrenValid()),\n pending: computed(() => ctrl.pending() || childrenPending()),\n markAllAsPristine,\n markAllAsTouched,\n reset: () => {\n for (const ctrl of untracked(derivationsArray)) {\n ctrl.reset();\n }\n ctrl.reset();\n },\n resetWithInitial: (initial: T) => {\n for (const ctrl of untracked(derivationsArray)) {\n const from = ctrl.from;\n if (from) ctrl.resetWithInitial(from(initial));\n else ctrl.reset();\n }\n ctrl.resetWithInitial(initial);\n },\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACG,SAAU,UAAU,CAAkB,IAAO,EAAE,IAAO,EAAA;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,KAC1B,aAAa,CAAY,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CACvC;AACR;AAEA;;;;;;;;;;;;;;AAcG;AACG,SAAU,aAAa,CAAI,IAAO,EAAE,IAAO,EAAA;AAC/C,IAAA,IAAI,OAAO,IAAI,KAAK,OAAO,IAAI;AAAE,QAAA,OAAO,IAAI;IAC5C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;AACrE,IAAA,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI;AAAE,QAAA,OAAO,IAAI;AAC/C,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC;AAC7E,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;AAE3D,IAAA,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,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AAA,KAAK,EAAE,QAAQ,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,IAAI,aAAa,EAAE,CAAC;AACtD,QAAA,OAAO,EAAE,QAAQ,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,eAAe,EAAE,CAAC;QAC5D,iBAAiB;QACjB,gBAAgB;QAChB,KAAK,EAAE,MAAK;YACV,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,gBAAgB,CAAC,EAAE;gBAC9C,IAAI,CAAC,KAAK,EAAE;YACd;YACA,IAAI,CAAC,KAAK,EAAE;QACd,CAAC;AACD,QAAA,gBAAgB,EAAE,CAAC,OAAU,KAAI;YAC/B,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,gBAAgB,CAAC,EAAE;AAC9C,gBAAA,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI;AACtB,gBAAA,IAAI,IAAI;oBAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;;oBACzC,IAAI,CAAC,KAAK,EAAE;YACnB;AACA,YAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;QAChC,CAAC;KACF;AACH;;ACrTA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mmstack/form-core",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"angular",
|
|
6
6
|
"signals",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/mihajm/mmstack"
|
|
18
|
+
"url": "git+https://github.com/mihajm/mmstack.git",
|
|
19
|
+
"directory": "packages/form/core"
|
|
19
20
|
},
|
|
20
21
|
"homepage": "https://github.com/mihajm/mmstack/blob/master/packages/form/core",
|
|
21
22
|
"dependencies": {
|
|
@@ -36,5 +37,6 @@
|
|
|
36
37
|
"types": "./types/mmstack-form-core.d.ts",
|
|
37
38
|
"default": "./fesm2022/mmstack-form-core.mjs"
|
|
38
39
|
}
|
|
39
|
-
}
|
|
40
|
+
},
|
|
41
|
+
"type": "module"
|
|
40
42
|
}
|