@easyvision/easyvision-ui 1.9.0 → 1.9.1

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/index.d.cts CHANGED
@@ -108,6 +108,13 @@ interface TextFieldDef extends MultifilterFieldBase {
108
108
  * Multiple prominent fields are supported and wrap onto extra rows as needed.
109
109
  */
110
110
  prominent?: boolean;
111
+ /**
112
+ * Search every one of these paths (a case-insensitive substring match on
113
+ * any of them, as one `$or`) instead of `field`. The text is escaped, so it
114
+ * matches literally. Use this instead of a hand-written `toCondition` for
115
+ * multi-path search bars, e.g. `fields: ['name', 'documentId']`.
116
+ */
117
+ fields?: string[];
111
118
  }
112
119
  interface SelectorFieldDef<V extends string | number = string | number> extends MultifilterFieldBase {
113
120
  type: 'selector';
package/dist/index.d.ts CHANGED
@@ -108,6 +108,13 @@ interface TextFieldDef extends MultifilterFieldBase {
108
108
  * Multiple prominent fields are supported and wrap onto extra rows as needed.
109
109
  */
110
110
  prominent?: boolean;
111
+ /**
112
+ * Search every one of these paths (a case-insensitive substring match on
113
+ * any of them, as one `$or`) instead of `field`. The text is escaped, so it
114
+ * matches literally. Use this instead of a hand-written `toCondition` for
115
+ * multi-path search bars, e.g. `fields: ['name', 'documentId']`.
116
+ */
117
+ fields?: string[];
111
118
  }
112
119
  interface SelectorFieldDef<V extends string | number = string | number> extends MultifilterFieldBase {
113
120
  type: 'selector';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import './easyvision.css';
2
2
  import './EasyVisionTable.css';
3
3
  import * as React9 from 'react';
4
- import { createContext, forwardRef, useMemo, useSyncExternalStore, useRef, useEffect, useCallback, useImperativeHandle, useContext, useState, createElement } from 'react';
4
+ import { createContext, forwardRef, useMemo, useSyncExternalStore, useRef, useEffect, useCallback, useImperativeHandle, useState, useContext, createElement } from 'react';
5
5
  import { ChevronDown, ChevronUp, Check, Search, X, Plus, ChevronRight, Circle, Calendar as Calendar$1, ChevronLeft, ChevronsUpDown, Loader2, ArrowUp, ArrowDown, ArrowUpDown, Download, Settings2 } from 'lucide-react';
6
6
  import { clsx } from 'clsx';
7
7
  import { twMerge } from 'tailwind-merge';
@@ -991,6 +991,20 @@ function MultifilterField({
991
991
  return null;
992
992
  }
993
993
  }
994
+
995
+ // lib/escapeRegex.ts
996
+ function escapeRegex(value) {
997
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
998
+ }
999
+
1000
+ // multifilter/hooks/useMultifilterQuery.ts
1001
+ function textCondition(def, value) {
1002
+ const str = String(value).trim();
1003
+ if (!str) return void 0;
1004
+ const like = { $regex: `.*${escapeRegex(str)}.*`, $options: "i" };
1005
+ if (def.fields?.length) return { $or: def.fields.map((f) => ({ [f]: like })) };
1006
+ return def.field ? { [def.field]: like } : void 0;
1007
+ }
994
1008
  function buildCondition(def, value) {
995
1009
  if (value === void 0 || value === null || value === "") return void 0;
996
1010
  const mapper = def.toCondition ?? def.transform;
@@ -1003,13 +1017,9 @@ function buildCondition(def, value) {
1003
1017
  if (def.field) return { [def.field]: mapped };
1004
1018
  return void 0;
1005
1019
  }
1020
+ if (def.type === "text") return textCondition(def, value);
1006
1021
  if (!def.field) return void 0;
1007
1022
  switch (def.type) {
1008
- case "text": {
1009
- const str = String(value).trim();
1010
- if (!str) return void 0;
1011
- return { [def.field]: { $regex: `.*${str}.*`, $options: "i" } };
1012
- }
1013
1023
  case "selector": {
1014
1024
  return { [def.field]: value };
1015
1025
  }
@@ -1349,6 +1359,7 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
1349
1359
  },
1350
1360
  [activeFields, values, patch]
1351
1361
  );
1362
+ const [clearTick, setClearTick] = useState(0);
1352
1363
  const clearAll = useCallback(() => {
1353
1364
  const seed = {};
1354
1365
  if (config.searchField?.defaultValue !== void 0) {
@@ -1362,7 +1373,13 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
1362
1373
  }).concat(config.searchField ? [config.searchField.id] : []),
1363
1374
  lastConfirmedSnapshotJSON: null
1364
1375
  });
1365
- }, [config, patch, initialActive]);
1376
+ if (lastConfirmedSnapshotJSON !== null && resolvedPerformMode !== "live") {
1377
+ setClearTick((n) => n + 1);
1378
+ }
1379
+ }, [config, patch, initialActive, lastConfirmedSnapshotJSON, resolvedPerformMode]);
1380
+ useEffect(() => {
1381
+ if (clearTick > 0) performAction();
1382
+ }, [clearTick]);
1366
1383
  const visibleConfigFields = useMemo(
1367
1384
  () => config.fields.filter((f) => isFieldVisible(f, composedValues)),
1368
1385
  [config.fields, composedValues]
@@ -1558,13 +1575,12 @@ function buildChildQueryDirect(field, values) {
1558
1575
  if (def.type === "multifilter") continue;
1559
1576
  const v = values[def.id];
1560
1577
  if (v === void 0 || v === null || v === "") continue;
1578
+ if (def.type === "text") {
1579
+ Object.assign(where, textCondition(def, v));
1580
+ continue;
1581
+ }
1561
1582
  if (!def.field) continue;
1562
1583
  switch (def.type) {
1563
- case "text": {
1564
- const str = String(v).trim();
1565
- if (str) where[def.field] = { $regex: `.*${str}.*`, $options: "i" };
1566
- break;
1567
- }
1568
1584
  case "selector":
1569
1585
  where[def.field] = v;
1570
1586
  break;
@@ -1597,9 +1613,7 @@ function buildChildQueryDirect(field, values) {
1597
1613
  }
1598
1614
  if (field.config.searchField) {
1599
1615
  const sv = values[field.config.searchField.id];
1600
- if (typeof sv === "string" && sv.trim() && field.config.searchField.field) {
1601
- where[field.config.searchField.field] = { $regex: `.*${sv.trim()}.*`, $options: "i" };
1602
- }
1616
+ if (typeof sv === "string") Object.assign(where, textCondition(field.config.searchField, sv));
1603
1617
  }
1604
1618
  return Object.keys(where).length > 0 ? { where } : {};
1605
1619
  }