@shival99/z-ui 1.6.2 → 1.6.3
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.
|
@@ -255,7 +255,7 @@ class ZTableEditCellComponent {
|
|
|
255
255
|
zChange = output();
|
|
256
256
|
_currentValue = signal(undefined, ...(ngDevMode ? [{ debugName: "_currentValue" }] : []));
|
|
257
257
|
_valueChange$ = new Subject();
|
|
258
|
-
|
|
258
|
+
_lastExternalValue = undefined;
|
|
259
259
|
_pendingBlurValue = undefined;
|
|
260
260
|
_hasPendingBlur = false;
|
|
261
261
|
_inputControl = null;
|
|
@@ -302,28 +302,22 @@ class ZTableEditCellComponent {
|
|
|
302
302
|
if (!optionsConfig) {
|
|
303
303
|
return [];
|
|
304
304
|
}
|
|
305
|
-
|
|
306
|
-
if (typeof optionsConfig === 'function') {
|
|
307
|
-
rawOptions = optionsConfig(this.zRow());
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
rawOptions = optionsConfig;
|
|
311
|
-
}
|
|
305
|
+
const rawOptions = typeof optionsConfig === 'function' ? optionsConfig(this.zRow()) : optionsConfig;
|
|
312
306
|
const labelKey = config?.optionLabelKey;
|
|
313
307
|
const valueKey = config?.optionValueKey;
|
|
314
|
-
if (labelKey
|
|
315
|
-
return rawOptions
|
|
316
|
-
if (typeof opt !== 'object' || opt === null) {
|
|
317
|
-
return { label: String(opt), value: opt };
|
|
318
|
-
}
|
|
319
|
-
const obj = opt;
|
|
320
|
-
return {
|
|
321
|
-
label: String(obj[labelKey ?? 'label'] ?? ''),
|
|
322
|
-
value: obj[valueKey ?? 'value'],
|
|
323
|
-
};
|
|
324
|
-
});
|
|
308
|
+
if (!labelKey && !valueKey) {
|
|
309
|
+
return rawOptions;
|
|
325
310
|
}
|
|
326
|
-
return rawOptions
|
|
311
|
+
return rawOptions.map((opt) => {
|
|
312
|
+
if (typeof opt !== 'object' || opt === null) {
|
|
313
|
+
return { label: String(opt), value: opt };
|
|
314
|
+
}
|
|
315
|
+
const obj = opt;
|
|
316
|
+
return {
|
|
317
|
+
label: String(obj[labelKey ?? 'label'] ?? ''),
|
|
318
|
+
value: obj[valueKey ?? 'value'],
|
|
319
|
+
};
|
|
320
|
+
});
|
|
327
321
|
}, ...(ngDevMode ? [{ debugName: "selectOptions" }] : []));
|
|
328
322
|
isDisabled = computed(() => {
|
|
329
323
|
const config = this.editConfig();
|
|
@@ -346,10 +340,13 @@ class ZTableEditCellComponent {
|
|
|
346
340
|
return config.readonly;
|
|
347
341
|
}, ...(ngDevMode ? [{ debugName: "isReadonly" }] : []));
|
|
348
342
|
value = computed(() => {
|
|
349
|
-
|
|
350
|
-
|
|
343
|
+
const externalValue = this.zValue();
|
|
344
|
+
if (externalValue !== this._lastExternalValue) {
|
|
345
|
+
this._lastExternalValue = externalValue;
|
|
346
|
+
this._currentValue.set(externalValue);
|
|
347
|
+
return externalValue;
|
|
351
348
|
}
|
|
352
|
-
return this.
|
|
349
|
+
return this._currentValue();
|
|
353
350
|
}, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
354
351
|
stringValue = computed(() => {
|
|
355
352
|
const val = this.value();
|
|
@@ -384,7 +381,6 @@ class ZTableEditCellComponent {
|
|
|
384
381
|
onValueChange(newValue) {
|
|
385
382
|
const oldValue = this.zValue();
|
|
386
383
|
this._currentValue.set(newValue);
|
|
387
|
-
this._initialized = true;
|
|
388
384
|
const config = this.editConfig();
|
|
389
385
|
if (config?.blurEdit) {
|
|
390
386
|
this._pendingBlurValue = newValue;
|
|
@@ -406,32 +402,27 @@ class ZTableEditCellComponent {
|
|
|
406
402
|
this._emitChange(oldValue, this._pendingBlurValue);
|
|
407
403
|
}
|
|
408
404
|
onToggleChange(checked) {
|
|
409
|
-
|
|
410
|
-
this._currentValue.set(checked);
|
|
411
|
-
this._initialized = true;
|
|
412
|
-
this._emitChange(oldValue, checked);
|
|
405
|
+
this._handleImmediateChange(checked);
|
|
413
406
|
}
|
|
414
407
|
onSelectChange(newValue) {
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
finalValue = newValue.value;
|
|
419
|
-
}
|
|
420
|
-
this._currentValue.set(finalValue);
|
|
421
|
-
this._initialized = true;
|
|
422
|
-
this._emitChange(oldValue, finalValue);
|
|
408
|
+
const isWrappedObject = typeof newValue === 'object' && newValue !== null && 'value' in newValue;
|
|
409
|
+
const finalValue = isWrappedObject ? newValue.value : newValue;
|
|
410
|
+
this._handleImmediateChange(finalValue);
|
|
423
411
|
}
|
|
424
412
|
onDateChange(newValue) {
|
|
425
|
-
|
|
426
|
-
this._currentValue.set(newValue);
|
|
427
|
-
this._initialized = true;
|
|
428
|
-
this._emitChange(oldValue, newValue);
|
|
413
|
+
this._handleImmediateChange(newValue);
|
|
429
414
|
}
|
|
430
415
|
onCheckboxChange(checked) {
|
|
416
|
+
this._handleImmediateChange(checked);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Handles immediate value changes (non-debounced).
|
|
420
|
+
* Used by checkbox, toggle, select, and date controls.
|
|
421
|
+
*/
|
|
422
|
+
_handleImmediateChange(newValue) {
|
|
431
423
|
const oldValue = this.zValue();
|
|
432
|
-
this._currentValue.set(
|
|
433
|
-
this.
|
|
434
|
-
this._emitChange(oldValue, checked);
|
|
424
|
+
this._currentValue.set(newValue);
|
|
425
|
+
this._emitChange(oldValue, newValue);
|
|
435
426
|
}
|
|
436
427
|
_emitChange(oldValue, newValue) {
|
|
437
428
|
this.zChange.emit({
|