@dolusoft/vue3-datatable 1.8.50 → 1.8.52

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 = {
@@ -5472,15 +5541,36 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
5472
5541
  clearTimeout(existingTimer);
5473
5542
  debounceTimers.set(col.field, null);
5474
5543
  }
5544
+ if (!isEmpty && (column.type === "string" || column.type === "String") && typeof newValue === "string") {
5545
+ const parsed = parseFilterInput(newValue);
5546
+ if (parsed.isOperatorDetected && parsed.rules.length > 0) {
5547
+ column.condition = parsed.rules[0].condition;
5548
+ columnConditions.value[col.field] = parsed.rules[0].condition;
5549
+ }
5550
+ }
5475
5551
  const processChange = () => {
5476
5552
  debounceTimers.set(col.field, null);
5477
- if (column.type === "string" || column.type === "String") {
5478
- column.value = isEmpty ? "" : typeof newValue === "string" ? newValue.trim() : newValue;
5553
+ if (isEmpty) {
5554
+ column.value = "";
5555
+ column.parsedFilterRules = void 0;
5556
+ emit("filterChange");
5557
+ return;
5558
+ }
5559
+ if ((column.type === "string" || column.type === "String") && typeof newValue === "string") {
5560
+ const parsed = parseFilterInput(newValue);
5561
+ if (parsed.isOperatorDetected && parsed.rules.length > 0) {
5562
+ column.value = newValue.trim();
5563
+ column.parsedFilterRules = parsed.rules;
5564
+ emit("filterChange");
5565
+ return;
5566
+ }
5567
+ column.value = newValue.trim();
5568
+ column.parsedFilterRules = void 0;
5479
5569
  } else {
5480
- column.value = isEmpty ? "" : newValue;
5570
+ column.value = newValue;
5571
+ column.parsedFilterRules = void 0;
5481
5572
  }
5482
- if (isEmpty) ;
5483
- else if (!columnConditions.value[col.field]) {
5573
+ if (!columnConditions.value[col.field]) {
5484
5574
  column.condition = "Equal";
5485
5575
  columnConditions.value[col.field] = "Equal";
5486
5576
  } else {
@@ -5539,6 +5629,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
5539
5629
  if (col.filter) {
5540
5630
  col.value = "";
5541
5631
  col.condition = "";
5632
+ col.parsedFilterRules = void 0;
5542
5633
  }
5543
5634
  });
5544
5635
  }
@@ -5637,13 +5728,20 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
5637
5728
  const type = ((_a = col.type) == null ? void 0 : _a.toLowerCase()) || "string";
5638
5729
  const conditions = FILTER_CONDITIONS[type] || FILTER_CONDITIONS.string;
5639
5730
  const found = conditions.find((c2) => c2.value === condition);
5731
+ let label = "";
5640
5732
  if (found) {
5641
5733
  if (props.columnFilterLang && props.columnFilterLang[condition]) {
5642
- return props.columnFilterLang[condition];
5734
+ label = props.columnFilterLang[condition];
5735
+ } else {
5736
+ label = found.label;
5643
5737
  }
5644
- return found.label;
5738
+ } else {
5739
+ label = condition;
5740
+ }
5741
+ if (col.parsedFilterRules && col.parsedFilterRules.length > 1) {
5742
+ label += ` (${col.parsedFilterRules.length})`;
5645
5743
  }
5646
- return condition;
5744
+ return label;
5647
5745
  };
5648
5746
  const handleConditionChange = (field, condition) => {
5649
5747
  const column = columnsMap.value.get(field);
@@ -5657,6 +5755,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
5657
5755
  filterInputs.value[col.field] = "";
5658
5756
  col.value = "";
5659
5757
  col.condition = "";
5758
+ col.parsedFilterRules = void 0;
5660
5759
  columnConditions.value[col.field] = "";
5661
5760
  if (props.currentSortColumn === col.field) {
5662
5761
  emit("sortChange", props.all.sortColumn || col.field, "asc");
@@ -6661,6 +6760,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
6661
6760
  if (column) {
6662
6761
  column.value = value;
6663
6762
  column.condition = condition || "Equal";
6763
+ column.parsedFilterRules = void 0;
6664
6764
  filterUpdateTrigger.value++;
6665
6765
  updateHasAnyActiveFilter();
6666
6766
  if (triggerFilter) {
@@ -6951,6 +7051,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
6951
7051
  selectAll(false);
6952
7052
  for (let i2 = 0; i2 < props.columns.length; i2++) {
6953
7053
  props.columns[i2].value = "";
7054
+ props.columns[i2].parsedFilterRules = void 0;
6954
7055
  }
6955
7056
  currentSearch.value = "";
6956
7057
  currentPageSize.value = oldPageSize;
@@ -7011,6 +7112,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
7011
7112
  if (col.filter) {
7012
7113
  col.value = "";
7013
7114
  col.condition = "";
7115
+ col.parsedFilterRules = void 0;
7014
7116
  }
7015
7117
  }
7016
7118
  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 = {
@@ -5471,15 +5540,36 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5471
5540
  clearTimeout(existingTimer);
5472
5541
  debounceTimers.set(col.field, null);
5473
5542
  }
5543
+ if (!isEmpty && (column.type === "string" || column.type === "String") && typeof newValue === "string") {
5544
+ const parsed = parseFilterInput(newValue);
5545
+ if (parsed.isOperatorDetected && parsed.rules.length > 0) {
5546
+ column.condition = parsed.rules[0].condition;
5547
+ columnConditions.value[col.field] = parsed.rules[0].condition;
5548
+ }
5549
+ }
5474
5550
  const processChange = () => {
5475
5551
  debounceTimers.set(col.field, null);
5476
- if (column.type === "string" || column.type === "String") {
5477
- column.value = isEmpty ? "" : typeof newValue === "string" ? newValue.trim() : newValue;
5552
+ if (isEmpty) {
5553
+ column.value = "";
5554
+ column.parsedFilterRules = void 0;
5555
+ emit("filterChange");
5556
+ return;
5557
+ }
5558
+ if ((column.type === "string" || column.type === "String") && typeof newValue === "string") {
5559
+ const parsed = parseFilterInput(newValue);
5560
+ if (parsed.isOperatorDetected && parsed.rules.length > 0) {
5561
+ column.value = newValue.trim();
5562
+ column.parsedFilterRules = parsed.rules;
5563
+ emit("filterChange");
5564
+ return;
5565
+ }
5566
+ column.value = newValue.trim();
5567
+ column.parsedFilterRules = void 0;
5478
5568
  } else {
5479
- column.value = isEmpty ? "" : newValue;
5569
+ column.value = newValue;
5570
+ column.parsedFilterRules = void 0;
5480
5571
  }
5481
- if (isEmpty) ;
5482
- else if (!columnConditions.value[col.field]) {
5572
+ if (!columnConditions.value[col.field]) {
5483
5573
  column.condition = "Equal";
5484
5574
  columnConditions.value[col.field] = "Equal";
5485
5575
  } else {
@@ -5538,6 +5628,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5538
5628
  if (col.filter) {
5539
5629
  col.value = "";
5540
5630
  col.condition = "";
5631
+ col.parsedFilterRules = void 0;
5541
5632
  }
5542
5633
  });
5543
5634
  }
@@ -5636,13 +5727,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5636
5727
  const type = ((_a = col.type) == null ? void 0 : _a.toLowerCase()) || "string";
5637
5728
  const conditions = FILTER_CONDITIONS[type] || FILTER_CONDITIONS.string;
5638
5729
  const found = conditions.find((c2) => c2.value === condition);
5730
+ let label = "";
5639
5731
  if (found) {
5640
5732
  if (props.columnFilterLang && props.columnFilterLang[condition]) {
5641
- return props.columnFilterLang[condition];
5733
+ label = props.columnFilterLang[condition];
5734
+ } else {
5735
+ label = found.label;
5642
5736
  }
5643
- return found.label;
5737
+ } else {
5738
+ label = condition;
5739
+ }
5740
+ if (col.parsedFilterRules && col.parsedFilterRules.length > 1) {
5741
+ label += ` (${col.parsedFilterRules.length})`;
5644
5742
  }
5645
- return condition;
5743
+ return label;
5646
5744
  };
5647
5745
  const handleConditionChange = (field, condition) => {
5648
5746
  const column = columnsMap.value.get(field);
@@ -5656,6 +5754,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5656
5754
  filterInputs.value[col.field] = "";
5657
5755
  col.value = "";
5658
5756
  col.condition = "";
5757
+ col.parsedFilterRules = void 0;
5659
5758
  columnConditions.value[col.field] = "";
5660
5759
  if (props.currentSortColumn === col.field) {
5661
5760
  emit("sortChange", props.all.sortColumn || col.field, "asc");
@@ -6660,6 +6759,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6660
6759
  if (column) {
6661
6760
  column.value = value;
6662
6761
  column.condition = condition || "Equal";
6762
+ column.parsedFilterRules = void 0;
6663
6763
  filterUpdateTrigger.value++;
6664
6764
  updateHasAnyActiveFilter();
6665
6765
  if (triggerFilter) {
@@ -6950,6 +7050,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6950
7050
  selectAll(false);
6951
7051
  for (let i2 = 0; i2 < props.columns.length; i2++) {
6952
7052
  props.columns[i2].value = "";
7053
+ props.columns[i2].parsedFilterRules = void 0;
6953
7054
  }
6954
7055
  currentSearch.value = "";
6955
7056
  currentPageSize.value = oldPageSize;
@@ -7010,6 +7111,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
7010
7111
  if (col.filter) {
7011
7112
  col.value = "";
7012
7113
  col.condition = "";
7114
+ col.parsedFilterRules = void 0;
7013
7115
  }
7014
7116
  }
7015
7117
  updateHasAnyActiveFilter();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolusoft/vue3-datatable",
3
- "version": "1.8.50",
3
+ "version": "1.8.52",
4
4
  "description": "Vue3 Datatable - fully customizable & easy to use datatable library",
5
5
  "private": false,
6
6
  "type": "module",