@amirjalili1374/ui-kit 1.4.32 → 1.4.33

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/dist/ui-kit.es.js CHANGED
@@ -17790,6 +17790,78 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17790
17790
  console.error(`Error converting date for field ${header.key}:`, error2);
17791
17791
  }
17792
17792
  }
17793
+ if (hasAutocomplete(header)) {
17794
+ const enhancedHeader = header;
17795
+ const currentValue = dataToSave[header.key];
17796
+ const valueKey = resolveAutocompleteItemValue(header);
17797
+ if (enhancedHeader.autocompleteMultiple && Array.isArray(currentValue)) {
17798
+ const autocompleteItems = resolveAutocompleteItems(header, dataToSave);
17799
+ const processedArray = currentValue.map((item) => {
17800
+ if (item === null || item === void 0) {
17801
+ return null;
17802
+ }
17803
+ if (enhancedHeader.autocompleteReturnObject !== false) {
17804
+ if (typeof item !== "object") {
17805
+ return null;
17806
+ }
17807
+ const itemValue = valueKey && item[valueKey];
17808
+ if (itemValue !== null && itemValue !== void 0) {
17809
+ const fullItem = autocompleteItems.find((autocompleteItem) => {
17810
+ const autocompleteValue = autocompleteItem[valueKey];
17811
+ return autocompleteValue !== null && autocompleteValue !== void 0 && String(autocompleteValue) === String(itemValue);
17812
+ });
17813
+ if (fullItem && typeof fullItem === "object") {
17814
+ return fullItem;
17815
+ }
17816
+ }
17817
+ const propertyValues = Object.values(item);
17818
+ if (propertyValues.length === 0) {
17819
+ return null;
17820
+ }
17821
+ const allPropertiesEmpty = propertyValues.every(
17822
+ (val2) => val2 === null || val2 === void 0 || val2 === ""
17823
+ );
17824
+ if (allPropertiesEmpty) {
17825
+ return null;
17826
+ }
17827
+ return item;
17828
+ }
17829
+ return item !== null && item !== void 0 && item !== "" ? item : null;
17830
+ }).filter((item) => item !== null && item !== void 0);
17831
+ dataToSave[header.key] = processedArray;
17832
+ } else if (currentValue === null || currentValue === void 0 || currentValue === "") {
17833
+ dataToSave[header.key] = null;
17834
+ } else if (enhancedHeader.autocompleteReturnObject !== false && typeof currentValue === "object") {
17835
+ const autocompleteItems = resolveAutocompleteItems(header, dataToSave);
17836
+ const valueKey2 = resolveAutocompleteItemValue(header);
17837
+ const itemValue = valueKey2 && currentValue[valueKey2];
17838
+ if (itemValue !== null && itemValue !== void 0) {
17839
+ const fullItem = autocompleteItems.find((autocompleteItem) => {
17840
+ const autocompleteValue = autocompleteItem[valueKey2];
17841
+ return autocompleteValue !== null && autocompleteValue !== void 0 && String(autocompleteValue) === String(itemValue);
17842
+ });
17843
+ if (fullItem && typeof fullItem === "object") {
17844
+ dataToSave[header.key] = fullItem;
17845
+ }
17846
+ }
17847
+ }
17848
+ }
17849
+ });
17850
+ props.headers.forEach((header) => {
17851
+ if (hasAutocomplete(header) && dataToSave[header.key]) {
17852
+ const enhancedHeader = header;
17853
+ if (enhancedHeader.autocompleteMultiple && Array.isArray(dataToSave[header.key])) {
17854
+ console.log(`[CustomDataTable] Autocomplete field "${header.key}" (${dataToSave[header.key].length} items) before save:`, dataToSave[header.key]);
17855
+ const itemsWithNulls = dataToSave[header.key].filter(
17856
+ (item) => item && typeof item === "object" && Object.values(item).some((val2) => val2 === null)
17857
+ );
17858
+ if (itemsWithNulls.length > 0) {
17859
+ console.warn(`[CustomDataTable] Warning: Found ${itemsWithNulls.length} items with null properties in "${header.key}":`, itemsWithNulls);
17860
+ }
17861
+ } else {
17862
+ console.log(`[CustomDataTable] Autocomplete field "${header.key}" before save:`, dataToSave[header.key]);
17863
+ }
17864
+ }
17793
17865
  });
17794
17866
  if (isEditing.value && dataToSave.id) {
17795
17867
  await api.update(dataToSave);