@dolusoft/vue3-datatable 1.8.48 → 1.8.51

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.
@@ -5259,6 +5259,75 @@ function _sfc_render(_ctx, _cache) {
5259
5259
  return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$3, _hoisted_3$2);
5260
5260
  }
5261
5261
  const iconFilter = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render]]);
5262
+ function parseSingleSegment(input) {
5263
+ let value = input.trim();
5264
+ if (value === "") return null;
5265
+ const negated = value.startsWith("!");
5266
+ if (negated) {
5267
+ value = value.substring(1);
5268
+ }
5269
+ if (value === "" || value === "*" || /^\*+$/.test(value)) {
5270
+ return null;
5271
+ }
5272
+ const startsWithStar = value.startsWith("*");
5273
+ const endsWithStar = value.endsWith("*");
5274
+ let condition;
5275
+ let operatorDetected = negated;
5276
+ if (startsWithStar && endsWithStar && value.length > 1) {
5277
+ value = value.substring(1, value.length - 1);
5278
+ condition = negated ? "NotContains" : "Contains";
5279
+ operatorDetected = true;
5280
+ } else if (endsWithStar) {
5281
+ value = value.substring(0, value.length - 1);
5282
+ condition = negated ? "NotContains" : "StartsWith";
5283
+ operatorDetected = true;
5284
+ } else if (startsWithStar) {
5285
+ value = value.substring(1);
5286
+ condition = negated ? "NotContains" : "EndsWith";
5287
+ operatorDetected = true;
5288
+ } else if (negated) {
5289
+ condition = "NotEqual";
5290
+ } else {
5291
+ condition = "Equal";
5292
+ }
5293
+ if (value.trim() === "") {
5294
+ return null;
5295
+ }
5296
+ return {
5297
+ rule: { value: value.trim(), condition },
5298
+ operatorDetected
5299
+ };
5300
+ }
5301
+ function parseFilterInput(rawInput) {
5302
+ const empty = { rules: [], displayCondition: "", isOperatorDetected: false };
5303
+ if (!rawInput || typeof rawInput !== "string") {
5304
+ return empty;
5305
+ }
5306
+ const trimmed = rawInput.trim();
5307
+ if (trimmed === "") {
5308
+ return empty;
5309
+ }
5310
+ const segments = trimmed.split(",");
5311
+ const rules = [];
5312
+ let anyOperatorDetected = false;
5313
+ for (const segment of segments) {
5314
+ const result = parseSingleSegment(segment);
5315
+ if (result) {
5316
+ rules.push(result.rule);
5317
+ if (result.operatorDetected) {
5318
+ anyOperatorDetected = true;
5319
+ }
5320
+ }
5321
+ }
5322
+ if (rules.length === 0) {
5323
+ return empty;
5324
+ }
5325
+ return {
5326
+ rules,
5327
+ displayCondition: rules[0].condition,
5328
+ isOperatorDetected: anyOperatorDetected
5329
+ };
5330
+ }
5262
5331
  const _hoisted_1$2 = { key: "hdrrow" };
5263
5332
  const _hoisted_2$2 = { class: "bh-checkbox" };
5264
5333
  const _hoisted_3$1 = {
@@ -5474,15 +5543,29 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
5474
5543
  }
5475
5544
  const processChange = () => {
5476
5545
  debounceTimers.set(col.field, null);
5477
- if (column.type === "string" || column.type === "String") {
5478
- column.value = isEmpty ? "" : typeof newValue === "string" ? newValue.trim() : newValue;
5546
+ if (isEmpty) {
5547
+ column.value = "";
5548
+ column.parsedFilterRules = void 0;
5549
+ emit("filterChange");
5550
+ return;
5551
+ }
5552
+ if ((column.type === "string" || column.type === "String") && typeof newValue === "string") {
5553
+ const parsed = parseFilterInput(newValue);
5554
+ if (parsed.isOperatorDetected && parsed.rules.length > 0) {
5555
+ column.value = parsed.rules[0].value;
5556
+ column.condition = parsed.rules[0].condition;
5557
+ columnConditions.value[col.field] = parsed.rules[0].condition;
5558
+ column.parsedFilterRules = parsed.rules.length > 1 ? parsed.rules : void 0;
5559
+ emit("filterChange");
5560
+ return;
5561
+ }
5562
+ column.value = newValue.trim();
5563
+ column.parsedFilterRules = void 0;
5479
5564
  } else {
5480
- column.value = isEmpty ? "" : newValue;
5565
+ column.value = newValue;
5566
+ column.parsedFilterRules = void 0;
5481
5567
  }
5482
- if (isEmpty) {
5483
- column.condition = "";
5484
- columnConditions.value[col.field] = "";
5485
- } else if (!columnConditions.value[col.field]) {
5568
+ if (!columnConditions.value[col.field]) {
5486
5569
  column.condition = "Equal";
5487
5570
  columnConditions.value[col.field] = "Equal";
5488
5571
  } else {
@@ -5541,6 +5624,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
5541
5624
  if (col.filter) {
5542
5625
  col.value = "";
5543
5626
  col.condition = "";
5627
+ col.parsedFilterRules = void 0;
5544
5628
  }
5545
5629
  });
5546
5630
  }
@@ -5587,8 +5671,6 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
5587
5671
  if (currentCondition !== colState.condition) {
5588
5672
  columnConditions.value[colState.field] = colState.condition;
5589
5673
  }
5590
- } else if (!hasValue) {
5591
- columnConditions.value[colState.field] = "";
5592
5674
  }
5593
5675
  }
5594
5676
  });
@@ -5641,13 +5723,20 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
5641
5723
  const type = ((_a = col.type) == null ? void 0 : _a.toLowerCase()) || "string";
5642
5724
  const conditions = FILTER_CONDITIONS[type] || FILTER_CONDITIONS.string;
5643
5725
  const found = conditions.find((c2) => c2.value === condition);
5726
+ let label = "";
5644
5727
  if (found) {
5645
5728
  if (props.columnFilterLang && props.columnFilterLang[condition]) {
5646
- return props.columnFilterLang[condition];
5729
+ label = props.columnFilterLang[condition];
5730
+ } else {
5731
+ label = found.label;
5647
5732
  }
5648
- return found.label;
5733
+ } else {
5734
+ label = condition;
5735
+ }
5736
+ if (col.parsedFilterRules && col.parsedFilterRules.length > 1) {
5737
+ label += ` (${col.parsedFilterRules.length})`;
5649
5738
  }
5650
- return condition;
5739
+ return label;
5651
5740
  };
5652
5741
  const handleConditionChange = (field, condition) => {
5653
5742
  const column = columnsMap.value.get(field);
@@ -5661,6 +5750,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
5661
5750
  filterInputs.value[col.field] = "";
5662
5751
  col.value = "";
5663
5752
  col.condition = "";
5753
+ col.parsedFilterRules = void 0;
5664
5754
  columnConditions.value[col.field] = "";
5665
5755
  if (props.currentSortColumn === col.field) {
5666
5756
  emit("sortChange", props.all.sortColumn || col.field, "asc");
@@ -6665,6 +6755,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
6665
6755
  if (column) {
6666
6756
  column.value = value;
6667
6757
  column.condition = condition || "Equal";
6758
+ column.parsedFilterRules = void 0;
6668
6759
  filterUpdateTrigger.value++;
6669
6760
  updateHasAnyActiveFilter();
6670
6761
  if (triggerFilter) {
@@ -6955,6 +7046,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
6955
7046
  selectAll(false);
6956
7047
  for (let i2 = 0; i2 < props.columns.length; i2++) {
6957
7048
  props.columns[i2].value = "";
7049
+ props.columns[i2].parsedFilterRules = void 0;
6958
7050
  }
6959
7051
  currentSearch.value = "";
6960
7052
  currentPageSize.value = oldPageSize;
@@ -7015,6 +7107,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
7015
7107
  if (col.filter) {
7016
7108
  col.value = "";
7017
7109
  col.condition = "";
7110
+ col.parsedFilterRules = void 0;
7018
7111
  }
7019
7112
  }
7020
7113
  updateHasAnyActiveFilter();
@@ -5258,6 +5258,75 @@ function _sfc_render(_ctx, _cache) {
5258
5258
  return openBlock(), createElementBlock("svg", _hoisted_1$3, _hoisted_3$2);
5259
5259
  }
5260
5260
  const iconFilter = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render]]);
5261
+ function parseSingleSegment(input) {
5262
+ let value = input.trim();
5263
+ if (value === "") return null;
5264
+ const negated = value.startsWith("!");
5265
+ if (negated) {
5266
+ value = value.substring(1);
5267
+ }
5268
+ if (value === "" || value === "*" || /^\*+$/.test(value)) {
5269
+ return null;
5270
+ }
5271
+ const startsWithStar = value.startsWith("*");
5272
+ const endsWithStar = value.endsWith("*");
5273
+ let condition;
5274
+ let operatorDetected = negated;
5275
+ if (startsWithStar && endsWithStar && value.length > 1) {
5276
+ value = value.substring(1, value.length - 1);
5277
+ condition = negated ? "NotContains" : "Contains";
5278
+ operatorDetected = true;
5279
+ } else if (endsWithStar) {
5280
+ value = value.substring(0, value.length - 1);
5281
+ condition = negated ? "NotContains" : "StartsWith";
5282
+ operatorDetected = true;
5283
+ } else if (startsWithStar) {
5284
+ value = value.substring(1);
5285
+ condition = negated ? "NotContains" : "EndsWith";
5286
+ operatorDetected = true;
5287
+ } else if (negated) {
5288
+ condition = "NotEqual";
5289
+ } else {
5290
+ condition = "Equal";
5291
+ }
5292
+ if (value.trim() === "") {
5293
+ return null;
5294
+ }
5295
+ return {
5296
+ rule: { value: value.trim(), condition },
5297
+ operatorDetected
5298
+ };
5299
+ }
5300
+ function parseFilterInput(rawInput) {
5301
+ const empty = { rules: [], displayCondition: "", isOperatorDetected: false };
5302
+ if (!rawInput || typeof rawInput !== "string") {
5303
+ return empty;
5304
+ }
5305
+ const trimmed = rawInput.trim();
5306
+ if (trimmed === "") {
5307
+ return empty;
5308
+ }
5309
+ const segments = trimmed.split(",");
5310
+ const rules = [];
5311
+ let anyOperatorDetected = false;
5312
+ for (const segment of segments) {
5313
+ const result = parseSingleSegment(segment);
5314
+ if (result) {
5315
+ rules.push(result.rule);
5316
+ if (result.operatorDetected) {
5317
+ anyOperatorDetected = true;
5318
+ }
5319
+ }
5320
+ }
5321
+ if (rules.length === 0) {
5322
+ return empty;
5323
+ }
5324
+ return {
5325
+ rules,
5326
+ displayCondition: rules[0].condition,
5327
+ isOperatorDetected: anyOperatorDetected
5328
+ };
5329
+ }
5261
5330
  const _hoisted_1$2 = { key: "hdrrow" };
5262
5331
  const _hoisted_2$2 = { class: "bh-checkbox" };
5263
5332
  const _hoisted_3$1 = {
@@ -5473,15 +5542,29 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5473
5542
  }
5474
5543
  const processChange = () => {
5475
5544
  debounceTimers.set(col.field, null);
5476
- if (column.type === "string" || column.type === "String") {
5477
- column.value = isEmpty ? "" : typeof newValue === "string" ? newValue.trim() : newValue;
5545
+ if (isEmpty) {
5546
+ column.value = "";
5547
+ column.parsedFilterRules = void 0;
5548
+ emit("filterChange");
5549
+ return;
5550
+ }
5551
+ if ((column.type === "string" || column.type === "String") && typeof newValue === "string") {
5552
+ const parsed = parseFilterInput(newValue);
5553
+ if (parsed.isOperatorDetected && parsed.rules.length > 0) {
5554
+ column.value = parsed.rules[0].value;
5555
+ column.condition = parsed.rules[0].condition;
5556
+ columnConditions.value[col.field] = parsed.rules[0].condition;
5557
+ column.parsedFilterRules = parsed.rules.length > 1 ? parsed.rules : void 0;
5558
+ emit("filterChange");
5559
+ return;
5560
+ }
5561
+ column.value = newValue.trim();
5562
+ column.parsedFilterRules = void 0;
5478
5563
  } else {
5479
- column.value = isEmpty ? "" : newValue;
5564
+ column.value = newValue;
5565
+ column.parsedFilterRules = void 0;
5480
5566
  }
5481
- if (isEmpty) {
5482
- column.condition = "";
5483
- columnConditions.value[col.field] = "";
5484
- } else if (!columnConditions.value[col.field]) {
5567
+ if (!columnConditions.value[col.field]) {
5485
5568
  column.condition = "Equal";
5486
5569
  columnConditions.value[col.field] = "Equal";
5487
5570
  } else {
@@ -5540,6 +5623,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5540
5623
  if (col.filter) {
5541
5624
  col.value = "";
5542
5625
  col.condition = "";
5626
+ col.parsedFilterRules = void 0;
5543
5627
  }
5544
5628
  });
5545
5629
  }
@@ -5586,8 +5670,6 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5586
5670
  if (currentCondition !== colState.condition) {
5587
5671
  columnConditions.value[colState.field] = colState.condition;
5588
5672
  }
5589
- } else if (!hasValue) {
5590
- columnConditions.value[colState.field] = "";
5591
5673
  }
5592
5674
  }
5593
5675
  });
@@ -5640,13 +5722,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5640
5722
  const type = ((_a = col.type) == null ? void 0 : _a.toLowerCase()) || "string";
5641
5723
  const conditions = FILTER_CONDITIONS[type] || FILTER_CONDITIONS.string;
5642
5724
  const found = conditions.find((c2) => c2.value === condition);
5725
+ let label = "";
5643
5726
  if (found) {
5644
5727
  if (props.columnFilterLang && props.columnFilterLang[condition]) {
5645
- return props.columnFilterLang[condition];
5728
+ label = props.columnFilterLang[condition];
5729
+ } else {
5730
+ label = found.label;
5646
5731
  }
5647
- return found.label;
5732
+ } else {
5733
+ label = condition;
5734
+ }
5735
+ if (col.parsedFilterRules && col.parsedFilterRules.length > 1) {
5736
+ label += ` (${col.parsedFilterRules.length})`;
5648
5737
  }
5649
- return condition;
5738
+ return label;
5650
5739
  };
5651
5740
  const handleConditionChange = (field, condition) => {
5652
5741
  const column = columnsMap.value.get(field);
@@ -5660,6 +5749,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5660
5749
  filterInputs.value[col.field] = "";
5661
5750
  col.value = "";
5662
5751
  col.condition = "";
5752
+ col.parsedFilterRules = void 0;
5663
5753
  columnConditions.value[col.field] = "";
5664
5754
  if (props.currentSortColumn === col.field) {
5665
5755
  emit("sortChange", props.all.sortColumn || col.field, "asc");
@@ -6664,6 +6754,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6664
6754
  if (column) {
6665
6755
  column.value = value;
6666
6756
  column.condition = condition || "Equal";
6757
+ column.parsedFilterRules = void 0;
6667
6758
  filterUpdateTrigger.value++;
6668
6759
  updateHasAnyActiveFilter();
6669
6760
  if (triggerFilter) {
@@ -6954,6 +7045,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6954
7045
  selectAll(false);
6955
7046
  for (let i2 = 0; i2 < props.columns.length; i2++) {
6956
7047
  props.columns[i2].value = "";
7048
+ props.columns[i2].parsedFilterRules = void 0;
6957
7049
  }
6958
7050
  currentSearch.value = "";
6959
7051
  currentPageSize.value = oldPageSize;
@@ -7014,6 +7106,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
7014
7106
  if (col.filter) {
7015
7107
  col.value = "";
7016
7108
  col.condition = "";
7109
+ col.parsedFilterRules = void 0;
7017
7110
  }
7018
7111
  }
7019
7112
  updateHasAnyActiveFilter();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolusoft/vue3-datatable",
3
- "version": "1.8.48",
3
+ "version": "1.8.51",
4
4
  "description": "Vue3 Datatable - fully customizable & easy to use datatable library",
5
5
  "private": false,
6
6
  "type": "module",