@3kles/kles-material-dynamicforms 19.4.12 → 19.4.13

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.
@@ -4419,6 +4419,9 @@ class ArrayUiState extends AbstractUiState {
4419
4419
  }
4420
4420
  push(control) {
4421
4421
  const items = Array.isArray(control) ? control : [control];
4422
+ if (items.length === 0) {
4423
+ return;
4424
+ }
4422
4425
  for (const item of items) {
4423
4426
  const index = this.states.length;
4424
4427
  this.states.push(item);
@@ -4427,6 +4430,22 @@ class ArrayUiState extends AbstractUiState {
4427
4430
  this._value.set(this.states.map((s) => s.value()));
4428
4431
  this.notifyParent();
4429
4432
  }
4433
+ insert(index, state) {
4434
+ const items = Array.isArray(state) ? state : [state];
4435
+ if (items.length === 0) {
4436
+ return;
4437
+ }
4438
+ const safeIndex = Math.max(0, Math.min(index, this.states.length));
4439
+ this.states.splice(safeIndex, 0, ...items);
4440
+ for (let i = safeIndex; i < this.states.length; i++) {
4441
+ this.states[i]?.setParent(this, i);
4442
+ }
4443
+ const curr = this._value();
4444
+ const next = [...curr];
4445
+ next.splice(safeIndex, 0, ...items.map((item) => item.value()));
4446
+ this._value.set(next);
4447
+ this.notifyParent();
4448
+ }
4430
4449
  removeAt(index) {
4431
4450
  if (index < 0 || index >= this.states.length)
4432
4451
  return;