@amirjalili1374/ui-kit 1.4.34 → 1.4.39

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
@@ -13549,6 +13549,14 @@ const formatPrice = (value2, currency = "", decimals = 0) => {
13549
13549
  const formattedNumber = formatNumberWithCommas(value2, decimals);
13550
13550
  return currency ? `${currency}${formattedNumber}` : formattedNumber;
13551
13551
  };
13552
+ function defaultFilterAdapter(raw) {
13553
+ const out = {};
13554
+ for (const [key2, value2] of Object.entries(raw)) {
13555
+ if (value2 === "" || value2 === null || value2 === void 0) continue;
13556
+ out[key2] = value2;
13557
+ }
13558
+ return out;
13559
+ }
13552
13560
  const VAlertTitle = createSimpleFunctional("v-alert-title");
13553
13561
  const makeIconSizeProps = propsFactory({
13554
13562
  iconSize: [Number, String],
@@ -17121,7 +17129,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17121
17129
  bulkMode: { type: Boolean, default: false },
17122
17130
  axiosInstance: {},
17123
17131
  enableTextTruncation: { type: Boolean, default: false },
17124
- maxTextLength: { default: 50 }
17132
+ maxTextLength: { default: 50 },
17133
+ filterAdapter: {}
17125
17134
  },
17126
17135
  emits: ["update:selectedItems", "selection-change"],
17127
17136
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -17158,6 +17167,12 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17158
17167
  groupBy: props.groupBy,
17159
17168
  defaultExpanded: props.defaultExpanded
17160
17169
  });
17170
+ function resolveFilter(raw) {
17171
+ if (props.filterAdapter) {
17172
+ return props.filterAdapter(raw);
17173
+ }
17174
+ return defaultFilterAdapter(raw);
17175
+ }
17161
17176
  const originalToggleSelection = selection.toggleSelection;
17162
17177
  selection.toggleSelection = (item) => {
17163
17178
  if (props.bulkMode) {
@@ -17537,14 +17552,19 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17537
17552
  var _a, _b, _c;
17538
17553
  loading.value = true;
17539
17554
  error.value = null;
17540
- let params = {
17541
- ...buildFilterParams(),
17542
- ...props.queryParams
17543
- };
17544
- if (queryParams) {
17545
- params = { ...params, ...queryParams };
17546
- }
17547
17555
  try {
17556
+ const rawFilter = buildFilterParams();
17557
+ const finalFilter = resolveFilter(rawFilter);
17558
+ let params = {
17559
+ ...finalFilter,
17560
+ ...props.queryParams
17561
+ };
17562
+ if (queryParams) {
17563
+ params = {
17564
+ ...params,
17565
+ ...queryParams
17566
+ };
17567
+ }
17548
17568
  const shouldPaginate = props.showPagination !== false;
17549
17569
  const requestParams = shouldPaginate ? {
17550
17570
  ...params,
@@ -17558,12 +17578,10 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17558
17578
  } else {
17559
17579
  if (Array.isArray(response.data)) {
17560
17580
  serverRawData = response.data;
17561
- } else if (((_b = response.data) == null ? void 0 : _b.content) && Array.isArray(response.data.content)) {
17581
+ } else if (Array.isArray((_b = response.data) == null ? void 0 : _b.content)) {
17562
17582
  serverRawData = response.data.content;
17563
- } else if (response.data && typeof response.data === "object" && !Array.isArray(response.data)) {
17583
+ } else if (response.data && typeof response.data === "object") {
17564
17584
  serverRawData = [response.data];
17565
- } else {
17566
- serverRawData = [];
17567
17585
  }
17568
17586
  }
17569
17587
  const serverData = Array.isArray(serverRawData) ? serverRawData : [];
@@ -17574,8 +17592,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17574
17592
  if (isDateHeader(header) && newItem[header.key]) {
17575
17593
  try {
17576
17594
  newItem[header.key] = DateConverter.toShamsi(newItem[header.key]);
17577
- } catch (error2) {
17578
- console.error(`Error converting date for field ${header.key}:`, error2);
17595
+ } catch (e) {
17596
+ console.error(`Date convert error: ${header.key}`, e);
17579
17597
  }
17580
17598
  }
17581
17599
  });
@@ -17590,7 +17608,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17590
17608
  totalPages.value = 1;
17591
17609
  hasMore.value = false;
17592
17610
  }
17593
- if (props.defaultSelected && items.value.length > 0 && props.defaultSelected in items.value[0]) {
17611
+ if (props.defaultSelected && items.value.length && props.defaultSelected in items.value[0]) {
17594
17612
  const defaultSelectedItems = items.value.filter((item) => item[props.defaultSelected] === true);
17595
17613
  selectedItems.value = [...defaultSelectedItems];
17596
17614
  emit("update:selectedItems", selectedItems.value);
@@ -17598,7 +17616,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17598
17616
  }
17599
17617
  } catch (err) {
17600
17618
  if (err.response) {
17601
- error.value = `خطای سرور: ${err.response.status} - ${err.response.data.message || "خطای ناشناخته"}`;
17619
+ error.value = `خطای سرور: ${err.response.status}`;
17602
17620
  } else if (err.request) {
17603
17621
  error.value = "خطای شبکه. لطفا دوباره تلاش کنید.";
17604
17622
  } else {
@@ -17819,9 +17837,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17819
17837
  if (propertyValues.length === 0) {
17820
17838
  return null;
17821
17839
  }
17822
- const allPropertiesEmpty = propertyValues.every(
17823
- (val2) => val2 === null || val2 === void 0 || val2 === ""
17824
- );
17840
+ const allPropertiesEmpty = propertyValues.every((val2) => val2 === null || val2 === void 0 || val2 === "");
17825
17841
  if (allPropertiesEmpty) {
17826
17842
  return null;
17827
17843
  }
@@ -17852,12 +17868,18 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
17852
17868
  if (hasAutocomplete(header) && dataToSave[header.key]) {
17853
17869
  const enhancedHeader = header;
17854
17870
  if (enhancedHeader.autocompleteMultiple && Array.isArray(dataToSave[header.key])) {
17855
- console.log(`[CustomDataTable] Autocomplete field "${header.key}" (${dataToSave[header.key].length} items) before save:`, dataToSave[header.key]);
17871
+ console.log(
17872
+ `[CustomDataTable] Autocomplete field "${header.key}" (${dataToSave[header.key].length} items) before save:`,
17873
+ dataToSave[header.key]
17874
+ );
17856
17875
  const itemsWithNulls = dataToSave[header.key].filter(
17857
17876
  (item) => item && typeof item === "object" && Object.values(item).some((val2) => val2 === null)
17858
17877
  );
17859
17878
  if (itemsWithNulls.length > 0) {
17860
- console.warn(`[CustomDataTable] Warning: Found ${itemsWithNulls.length} items with null properties in "${header.key}":`, itemsWithNulls);
17879
+ console.warn(
17880
+ `[CustomDataTable] Warning: Found ${itemsWithNulls.length} items with null properties in "${header.key}":`,
17881
+ itemsWithNulls
17882
+ );
17861
17883
  }
17862
17884
  } else {
17863
17885
  console.log(`[CustomDataTable] Autocomplete field "${header.key}" before save:`, dataToSave[header.key]);
@@ -38144,6 +38166,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent$1({
38144
38166
  miniSidebar: {
38145
38167
  type: Boolean,
38146
38168
  required: true
38169
+ },
38170
+ version: {
38171
+ type: String,
38172
+ required: false
38147
38173
  }
38148
38174
  },
38149
38175
  emits: ["update:sidebarDrawer"],
@@ -38209,9 +38235,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent$1({
38209
38235
  color: "inputBorder",
38210
38236
  size: "small"
38211
38237
  }, {
38212
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
38213
- createTextVNode("نمایشی", -1)
38214
- ])]),
38238
+ default: withCtx(() => [
38239
+ createTextVNode(toDisplayString(props.version ? props.version : "نمایشی"), 1)
38240
+ ]),
38215
38241
  _: 1
38216
38242
  })
38217
38243
  ])) : createCommentVNode("", true)
@@ -38224,7 +38250,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent$1({
38224
38250
  };
38225
38251
  }
38226
38252
  });
38227
- const AppSidebar = /* @__PURE__ */ _export_sfc$1(_sfc_main$2, [["__scopeId", "data-v-19e7c400"]]);
38253
+ const AppSidebar = /* @__PURE__ */ _export_sfc$1(_sfc_main$2, [["__scopeId", "data-v-b59df261"]]);
38228
38254
  const makeVToolbarTitleProps = propsFactory({
38229
38255
  text: String,
38230
38256
  ...makeComponentProps(),
@@ -38970,7 +38996,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent$1({
38970
38996
  sidebarDrawer: __props.sidebar.sidebarDrawer,
38971
38997
  miniSidebar: __props.sidebar.miniSidebar,
38972
38998
  "onUpdate:sidebarDrawer": __props.sidebar["onUpdate:sidebarDrawer"],
38973
- class: "app-sidebar"
38999
+ class: "app-sidebar",
39000
+ version: "1.0.0"
38974
39001
  }, null, 8, ["sidebarItems", "getFilteredSidebarItems", "logoComponent", "sidebarDrawer", "miniSidebar", "onUpdate:sidebarDrawer"]),
38975
39002
  createVNode(VMain, null, {
38976
39003
  default: withCtx(() => [
@@ -38986,7 +39013,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent$1({
38986
39013
  };
38987
39014
  }
38988
39015
  });
38989
- const AppLayout = /* @__PURE__ */ _export_sfc$1(_sfc_main, [["__scopeId", "data-v-82bccb54"]]);
39016
+ const AppLayout = /* @__PURE__ */ _export_sfc$1(_sfc_main, [["__scopeId", "data-v-8eddbad4"]]);
38990
39017
  function useDataTable(options) {
38991
39018
  const items = ref([]);
38992
39019
  const loading = ref(false);