@easyvision/easyvision-ui 1.9.0 → 1.9.2

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';
@@ -19,7 +19,6 @@ import { es } from 'date-fns/locale';
19
19
  import { DayPicker } from 'react-day-picker';
20
20
  import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table';
21
21
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
22
- import ExcelJS from 'exceljs';
23
22
 
24
23
  // index.ts
25
24
  function cn(...inputs) {
@@ -991,6 +990,20 @@ function MultifilterField({
991
990
  return null;
992
991
  }
993
992
  }
993
+
994
+ // lib/escapeRegex.ts
995
+ function escapeRegex(value) {
996
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
997
+ }
998
+
999
+ // multifilter/hooks/useMultifilterQuery.ts
1000
+ function textCondition(def, value) {
1001
+ const str = String(value).trim();
1002
+ if (!str) return void 0;
1003
+ const like = { $regex: `.*${escapeRegex(str)}.*`, $options: "i" };
1004
+ if (def.fields?.length) return { $or: def.fields.map((f) => ({ [f]: like })) };
1005
+ return def.field ? { [def.field]: like } : void 0;
1006
+ }
994
1007
  function buildCondition(def, value) {
995
1008
  if (value === void 0 || value === null || value === "") return void 0;
996
1009
  const mapper = def.toCondition ?? def.transform;
@@ -1003,13 +1016,9 @@ function buildCondition(def, value) {
1003
1016
  if (def.field) return { [def.field]: mapped };
1004
1017
  return void 0;
1005
1018
  }
1019
+ if (def.type === "text") return textCondition(def, value);
1006
1020
  if (!def.field) return void 0;
1007
1021
  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
1022
  case "selector": {
1014
1023
  return { [def.field]: value };
1015
1024
  }
@@ -1349,6 +1358,7 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
1349
1358
  },
1350
1359
  [activeFields, values, patch]
1351
1360
  );
1361
+ const [clearTick, setClearTick] = useState(0);
1352
1362
  const clearAll = useCallback(() => {
1353
1363
  const seed = {};
1354
1364
  if (config.searchField?.defaultValue !== void 0) {
@@ -1362,7 +1372,13 @@ var EasyVisionMultifilter = forwardRef(function EasyVisionMultifilter2(props, re
1362
1372
  }).concat(config.searchField ? [config.searchField.id] : []),
1363
1373
  lastConfirmedSnapshotJSON: null
1364
1374
  });
1365
- }, [config, patch, initialActive]);
1375
+ if (lastConfirmedSnapshotJSON !== null && resolvedPerformMode !== "live") {
1376
+ setClearTick((n) => n + 1);
1377
+ }
1378
+ }, [config, patch, initialActive, lastConfirmedSnapshotJSON, resolvedPerformMode]);
1379
+ useEffect(() => {
1380
+ if (clearTick > 0) performAction();
1381
+ }, [clearTick]);
1366
1382
  const visibleConfigFields = useMemo(
1367
1383
  () => config.fields.filter((f) => isFieldVisible(f, composedValues)),
1368
1384
  [config.fields, composedValues]
@@ -1558,13 +1574,12 @@ function buildChildQueryDirect(field, values) {
1558
1574
  if (def.type === "multifilter") continue;
1559
1575
  const v = values[def.id];
1560
1576
  if (v === void 0 || v === null || v === "") continue;
1577
+ if (def.type === "text") {
1578
+ Object.assign(where, textCondition(def, v));
1579
+ continue;
1580
+ }
1561
1581
  if (!def.field) continue;
1562
1582
  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
1583
  case "selector":
1569
1584
  where[def.field] = v;
1570
1585
  break;
@@ -1597,9 +1612,7 @@ function buildChildQueryDirect(field, values) {
1597
1612
  }
1598
1613
  if (field.config.searchField) {
1599
1614
  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
- }
1615
+ if (typeof sv === "string") Object.assign(where, textCondition(field.config.searchField, sv));
1603
1616
  }
1604
1617
  return Object.keys(where).length > 0 ? { where } : {};
1605
1618
  }
@@ -3106,6 +3119,8 @@ function EasyVisionTable(props) {
3106
3119
  ] })
3107
3120
  ] }) });
3108
3121
  }
3122
+
3123
+ // export/buildWorkbook.ts
3109
3124
  var HEADER_FILL_ARGB = "FFCCCCCC";
3110
3125
  var MIN_COLUMN_WIDTH = 10;
3111
3126
  var COLUMN_WIDTH_PADDING = 2;
@@ -3154,7 +3169,8 @@ async function buildWorkbook(sheets) {
3154
3169
  (sheet) => sheet.rows.length > 0 && sheet.columns.length > 0
3155
3170
  );
3156
3171
  if (usable.length === 0) return null;
3157
- const workbook = new ExcelJS.Workbook();
3172
+ const { default: Excel } = await import('exceljs');
3173
+ const workbook = new Excel.Workbook();
3158
3174
  const takenNames = /* @__PURE__ */ new Set();
3159
3175
  for (const sheet of usable) {
3160
3176
  const worksheet = workbook.addWorksheet(uniqueSheetName(sheet.name, takenNames));