@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/README.md +5 -12
- package/dist/index.cjs +32 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +33 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -652,13 +652,13 @@ interface MultifilterSnapshot {
|
|
|
652
652
|
```
|
|
653
653
|
|
|
654
654
|
The default `query.where` builder uses these conventions per type:
|
|
655
|
-
- `text` → `{ [field]: { $regex: `.*${value}.*`, $options: 'i' } }`
|
|
655
|
+
- `text` → `{ [field]: { $regex: `.*${value}.*`, $options: 'i' } }` (regex metacharacters in `value` are escaped, so the text matches literally)
|
|
656
656
|
- `selector` → `{ [field]: value }`
|
|
657
657
|
- `multiselect` → `{ [field]: { $in: value } }`
|
|
658
658
|
- `dateRange` → `{ [field]: { $gte, $lte } }` (ISO strings)
|
|
659
659
|
- `numberRange` → `{ [field]: { $gte, $lte } }`
|
|
660
660
|
|
|
661
|
-
|
|
661
|
+
To search several paths with one input, give a `text` field `fields` instead of `field`. It builds one `$or` with the same escaped, case-insensitive match on each path:
|
|
662
662
|
|
|
663
663
|
```ts
|
|
664
664
|
// Search bar that matches client.name OR title OR topics:
|
|
@@ -667,19 +667,12 @@ Override per field with `toCondition: (value) => unknown` (return either a primi
|
|
|
667
667
|
type: 'text',
|
|
668
668
|
prominent: true,
|
|
669
669
|
pinned: true,
|
|
670
|
-
|
|
671
|
-
const s = String(v ?? '').trim();
|
|
672
|
-
if (!s) return undefined;
|
|
673
|
-
const like = { $regex: `.*${s}.*`, $options: 'i' };
|
|
674
|
-
return { $or: [
|
|
675
|
-
{ 'client.name': like },
|
|
676
|
-
{ title: like },
|
|
677
|
-
{ relatedTopicsText: like },
|
|
678
|
-
]};
|
|
679
|
-
},
|
|
670
|
+
fields: ['client.name', 'title', 'relatedTopicsText'],
|
|
680
671
|
}
|
|
681
672
|
```
|
|
682
673
|
|
|
674
|
+
Override per field with `toCondition: (value) => unknown` (return either a primitive — wrapped in `{ [field]: ... }` — or a full clause containing `$or`/`$and`, which is merged at the top level of `where`). Useful for translating UI values into a backend-specific shape. A `toCondition` replaces the default builder entirely, so if it builds a `$regex` from user text it must escape that text itself.
|
|
675
|
+
|
|
683
676
|
> `transform` is the deprecated old name for `toCondition` and is still accepted as an alias.
|
|
684
677
|
|
|
685
678
|
### Multifilter props
|
package/dist/index.cjs
CHANGED
|
@@ -20,9 +20,6 @@ var locale = require('date-fns/locale');
|
|
|
20
20
|
var reactDayPicker = require('react-day-picker');
|
|
21
21
|
var reactTable = require('@tanstack/react-table');
|
|
22
22
|
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
23
|
-
var ExcelJS = require('exceljs');
|
|
24
|
-
|
|
25
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
23
|
|
|
27
24
|
function _interopNamespace(e) {
|
|
28
25
|
if (e && e.__esModule) return e;
|
|
@@ -47,7 +44,6 @@ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive)
|
|
|
47
44
|
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
48
45
|
var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
|
|
49
46
|
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
|
|
50
|
-
var ExcelJS__default = /*#__PURE__*/_interopDefault(ExcelJS);
|
|
51
47
|
|
|
52
48
|
// index.ts
|
|
53
49
|
function cn(...inputs) {
|
|
@@ -1019,6 +1015,20 @@ function MultifilterField({
|
|
|
1019
1015
|
return null;
|
|
1020
1016
|
}
|
|
1021
1017
|
}
|
|
1018
|
+
|
|
1019
|
+
// lib/escapeRegex.ts
|
|
1020
|
+
function escapeRegex(value) {
|
|
1021
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
// multifilter/hooks/useMultifilterQuery.ts
|
|
1025
|
+
function textCondition(def, value) {
|
|
1026
|
+
const str = String(value).trim();
|
|
1027
|
+
if (!str) return void 0;
|
|
1028
|
+
const like = { $regex: `.*${escapeRegex(str)}.*`, $options: "i" };
|
|
1029
|
+
if (def.fields?.length) return { $or: def.fields.map((f) => ({ [f]: like })) };
|
|
1030
|
+
return def.field ? { [def.field]: like } : void 0;
|
|
1031
|
+
}
|
|
1022
1032
|
function buildCondition(def, value) {
|
|
1023
1033
|
if (value === void 0 || value === null || value === "") return void 0;
|
|
1024
1034
|
const mapper = def.toCondition ?? def.transform;
|
|
@@ -1031,13 +1041,9 @@ function buildCondition(def, value) {
|
|
|
1031
1041
|
if (def.field) return { [def.field]: mapped };
|
|
1032
1042
|
return void 0;
|
|
1033
1043
|
}
|
|
1044
|
+
if (def.type === "text") return textCondition(def, value);
|
|
1034
1045
|
if (!def.field) return void 0;
|
|
1035
1046
|
switch (def.type) {
|
|
1036
|
-
case "text": {
|
|
1037
|
-
const str = String(value).trim();
|
|
1038
|
-
if (!str) return void 0;
|
|
1039
|
-
return { [def.field]: { $regex: `.*${str}.*`, $options: "i" } };
|
|
1040
|
-
}
|
|
1041
1047
|
case "selector": {
|
|
1042
1048
|
return { [def.field]: value };
|
|
1043
1049
|
}
|
|
@@ -1377,6 +1383,7 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1377
1383
|
},
|
|
1378
1384
|
[activeFields, values, patch]
|
|
1379
1385
|
);
|
|
1386
|
+
const [clearTick, setClearTick] = React9.useState(0);
|
|
1380
1387
|
const clearAll = React9.useCallback(() => {
|
|
1381
1388
|
const seed = {};
|
|
1382
1389
|
if (config.searchField?.defaultValue !== void 0) {
|
|
@@ -1390,7 +1397,13 @@ var EasyVisionMultifilter = React9.forwardRef(function EasyVisionMultifilter2(pr
|
|
|
1390
1397
|
}).concat(config.searchField ? [config.searchField.id] : []),
|
|
1391
1398
|
lastConfirmedSnapshotJSON: null
|
|
1392
1399
|
});
|
|
1393
|
-
|
|
1400
|
+
if (lastConfirmedSnapshotJSON !== null && resolvedPerformMode !== "live") {
|
|
1401
|
+
setClearTick((n) => n + 1);
|
|
1402
|
+
}
|
|
1403
|
+
}, [config, patch, initialActive, lastConfirmedSnapshotJSON, resolvedPerformMode]);
|
|
1404
|
+
React9.useEffect(() => {
|
|
1405
|
+
if (clearTick > 0) performAction();
|
|
1406
|
+
}, [clearTick]);
|
|
1394
1407
|
const visibleConfigFields = React9.useMemo(
|
|
1395
1408
|
() => config.fields.filter((f) => isFieldVisible(f, composedValues)),
|
|
1396
1409
|
[config.fields, composedValues]
|
|
@@ -1586,13 +1599,12 @@ function buildChildQueryDirect(field, values) {
|
|
|
1586
1599
|
if (def.type === "multifilter") continue;
|
|
1587
1600
|
const v = values[def.id];
|
|
1588
1601
|
if (v === void 0 || v === null || v === "") continue;
|
|
1602
|
+
if (def.type === "text") {
|
|
1603
|
+
Object.assign(where, textCondition(def, v));
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1589
1606
|
if (!def.field) continue;
|
|
1590
1607
|
switch (def.type) {
|
|
1591
|
-
case "text": {
|
|
1592
|
-
const str = String(v).trim();
|
|
1593
|
-
if (str) where[def.field] = { $regex: `.*${str}.*`, $options: "i" };
|
|
1594
|
-
break;
|
|
1595
|
-
}
|
|
1596
1608
|
case "selector":
|
|
1597
1609
|
where[def.field] = v;
|
|
1598
1610
|
break;
|
|
@@ -1625,9 +1637,7 @@ function buildChildQueryDirect(field, values) {
|
|
|
1625
1637
|
}
|
|
1626
1638
|
if (field.config.searchField) {
|
|
1627
1639
|
const sv = values[field.config.searchField.id];
|
|
1628
|
-
if (typeof sv === "string"
|
|
1629
|
-
where[field.config.searchField.field] = { $regex: `.*${sv.trim()}.*`, $options: "i" };
|
|
1630
|
-
}
|
|
1640
|
+
if (typeof sv === "string") Object.assign(where, textCondition(field.config.searchField, sv));
|
|
1631
1641
|
}
|
|
1632
1642
|
return Object.keys(where).length > 0 ? { where } : {};
|
|
1633
1643
|
}
|
|
@@ -3134,6 +3144,8 @@ function EasyVisionTable(props) {
|
|
|
3134
3144
|
] })
|
|
3135
3145
|
] }) });
|
|
3136
3146
|
}
|
|
3147
|
+
|
|
3148
|
+
// export/buildWorkbook.ts
|
|
3137
3149
|
var HEADER_FILL_ARGB = "FFCCCCCC";
|
|
3138
3150
|
var MIN_COLUMN_WIDTH = 10;
|
|
3139
3151
|
var COLUMN_WIDTH_PADDING = 2;
|
|
@@ -3182,7 +3194,8 @@ async function buildWorkbook(sheets) {
|
|
|
3182
3194
|
(sheet) => sheet.rows.length > 0 && sheet.columns.length > 0
|
|
3183
3195
|
);
|
|
3184
3196
|
if (usable.length === 0) return null;
|
|
3185
|
-
const
|
|
3197
|
+
const { default: Excel } = await import('exceljs');
|
|
3198
|
+
const workbook = new Excel.Workbook();
|
|
3186
3199
|
const takenNames = /* @__PURE__ */ new Set();
|
|
3187
3200
|
for (const sheet of usable) {
|
|
3188
3201
|
const worksheet = workbook.addWorksheet(uniqueSheetName(sheet.name, takenNames));
|