@easyvision/easyvision-ui 1.9.3 → 1.11.0
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 +45 -1
- package/dist/EasyVisionTable.css +27 -27
- package/dist/easyvision.css +137 -129
- package/dist/index.cjs +107 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -1
- package/dist/index.d.ts +74 -1
- package/dist/index.js +106 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2352,6 +2352,97 @@ function matchLeaf(value, condition) {
|
|
|
2352
2352
|
return true;
|
|
2353
2353
|
}
|
|
2354
2354
|
|
|
2355
|
+
// adapters/ingot.ts
|
|
2356
|
+
var OPERATORS = {
|
|
2357
|
+
$eq: "eq",
|
|
2358
|
+
$ne: "neq",
|
|
2359
|
+
$neq: "neq",
|
|
2360
|
+
$in: "inq",
|
|
2361
|
+
$nin: "nin",
|
|
2362
|
+
$gt: "gt",
|
|
2363
|
+
$gte: "gte",
|
|
2364
|
+
$lt: "lt",
|
|
2365
|
+
$lte: "lte",
|
|
2366
|
+
$exists: "exists"
|
|
2367
|
+
};
|
|
2368
|
+
var LOGICAL = { $and: "and", $or: "or" };
|
|
2369
|
+
var isPlainObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Date);
|
|
2370
|
+
function regexToLiteral(pattern) {
|
|
2371
|
+
const body = pattern.replace(/^\.\*/, "");
|
|
2372
|
+
let literal = "";
|
|
2373
|
+
for (let i = 0; i < body.length; i++) {
|
|
2374
|
+
const ch = body[i];
|
|
2375
|
+
if (ch === "\\") {
|
|
2376
|
+
if (i + 1 >= body.length) return void 0;
|
|
2377
|
+
literal += body[++i];
|
|
2378
|
+
} else if (ch === "." && body[i + 1] === "*" && i + 2 === body.length) {
|
|
2379
|
+
break;
|
|
2380
|
+
} else if (".*+?^${}()|[]".includes(ch)) {
|
|
2381
|
+
return void 0;
|
|
2382
|
+
} else {
|
|
2383
|
+
literal += ch;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
return literal;
|
|
2387
|
+
}
|
|
2388
|
+
function translateOperators(field, ops) {
|
|
2389
|
+
const out = {};
|
|
2390
|
+
for (const [op, value] of Object.entries(ops)) {
|
|
2391
|
+
if (!op.startsWith("$")) {
|
|
2392
|
+
out[op] = value;
|
|
2393
|
+
} else if (op === "$regex") {
|
|
2394
|
+
const flags = ops.$options ?? "";
|
|
2395
|
+
if (flags !== "" && flags !== "i") {
|
|
2396
|
+
throw new Error(`ingot: unsupported $options "${String(flags)}" on "${field}" (only "i")`);
|
|
2397
|
+
}
|
|
2398
|
+
const literal = typeof value === "string" ? regexToLiteral(value) : void 0;
|
|
2399
|
+
if (literal === void 0) {
|
|
2400
|
+
throw new Error(`ingot: "${field}" uses a regex pattern; ingot only supports literal substring search`);
|
|
2401
|
+
}
|
|
2402
|
+
out[flags === "i" ? "ilike" : "like"] = literal;
|
|
2403
|
+
} else if (op === "$options") {
|
|
2404
|
+
if (!("$regex" in ops)) throw new Error(`ingot: $options without $regex on "${field}"`);
|
|
2405
|
+
} else if (op in OPERATORS) {
|
|
2406
|
+
out[OPERATORS[op]] = value;
|
|
2407
|
+
} else {
|
|
2408
|
+
throw new Error(`ingot: unsupported operator ${op} on "${field}"`);
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
return out;
|
|
2412
|
+
}
|
|
2413
|
+
function toIngotWhere(where) {
|
|
2414
|
+
const out = {};
|
|
2415
|
+
for (const [key, value] of Object.entries(where)) {
|
|
2416
|
+
if (key in LOGICAL) {
|
|
2417
|
+
if (!Array.isArray(value)) throw new Error(`ingot: ${key} expects an array`);
|
|
2418
|
+
out[LOGICAL[key]] = value.map((sub) => toIngotWhere(sub));
|
|
2419
|
+
} else if (key.startsWith("$")) {
|
|
2420
|
+
throw new Error(`ingot: unsupported operator ${key}`);
|
|
2421
|
+
} else if (isPlainObject(value) && Object.keys(value).some((k) => k.startsWith("$"))) {
|
|
2422
|
+
out[key] = translateOperators(key, value);
|
|
2423
|
+
} else {
|
|
2424
|
+
out[key] = value;
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
return out;
|
|
2428
|
+
}
|
|
2429
|
+
function createIngotTableFetcher(opts) {
|
|
2430
|
+
const { fetchPage, include, fields, defaultOrder, idFields } = opts;
|
|
2431
|
+
return async ({ page, itemsPerPage, sort, filter, idsOnly }) => {
|
|
2432
|
+
const order = sort ? [`${sort.column} ${sort.descending ? "DESC" : "ASC"}`] : defaultOrder ?? [];
|
|
2433
|
+
const effectiveFields = idsOnly ? idFields ?? ["id"] : fields;
|
|
2434
|
+
const effectiveInclude = idsOnly ? void 0 : include;
|
|
2435
|
+
return fetchPage({
|
|
2436
|
+
where: toIngotWhere(filter?.where ?? {}),
|
|
2437
|
+
skip: (page - 1) * itemsPerPage,
|
|
2438
|
+
limit: itemsPerPage,
|
|
2439
|
+
order,
|
|
2440
|
+
...effectiveInclude ? { include: effectiveInclude } : {},
|
|
2441
|
+
...effectiveFields ? { fields: effectiveFields } : {}
|
|
2442
|
+
});
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2355
2446
|
// export/sources.ts
|
|
2356
2447
|
var sources = /* @__PURE__ */ new Map();
|
|
2357
2448
|
var registerExportSource = (fullId, source) => {
|
|
@@ -2417,6 +2508,7 @@ function EasyVisionTable(props) {
|
|
|
2417
2508
|
data,
|
|
2418
2509
|
fetchData: fetchDataProp,
|
|
2419
2510
|
loopback,
|
|
2511
|
+
ingot,
|
|
2420
2512
|
onDataLoaded,
|
|
2421
2513
|
multifilter,
|
|
2422
2514
|
multifilterRef,
|
|
@@ -2455,9 +2547,19 @@ function EasyVisionTable(props) {
|
|
|
2455
2547
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2456
2548
|
[lbFetchPage, lbFetchCount, lbIncludeKey, lbFieldsKey, lbOrderKey]
|
|
2457
2549
|
);
|
|
2458
|
-
const
|
|
2459
|
-
const
|
|
2460
|
-
const
|
|
2550
|
+
const igFetchPage = ingot?.fetchPage;
|
|
2551
|
+
const igIncludeKey = JSON.stringify(ingot?.include ?? null);
|
|
2552
|
+
const igFieldsKey = JSON.stringify(ingot?.fields ?? null);
|
|
2553
|
+
const igOrderKey = JSON.stringify(ingot?.defaultOrder ?? null);
|
|
2554
|
+
const ingotFetcher = React9.useMemo(
|
|
2555
|
+
() => ingot ? createIngotTableFetcher(ingot) : void 0,
|
|
2556
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2557
|
+
[igFetchPage, igIncludeKey, igFieldsKey, igOrderKey]
|
|
2558
|
+
);
|
|
2559
|
+
const fetchData = fetchDataProp ?? loopbackFetcher ?? ingotFetcher;
|
|
2560
|
+
const apiShortcut = Boolean(loopback || ingot);
|
|
2561
|
+
const paginationMode = apiShortcut ? "api" : paginationModeProp;
|
|
2562
|
+
const orderingMode = apiShortcut ? "api" : orderingModeProp;
|
|
2461
2563
|
const getRowId = React9.useMemo(
|
|
2462
2564
|
() => getRowIdProp ?? ((row) => String(row?.id ?? "")),
|
|
2463
2565
|
[getRowIdProp]
|
|
@@ -3321,6 +3423,7 @@ exports.EasyVisionMultifilter = EasyVisionMultifilter;
|
|
|
3321
3423
|
exports.EasyVisionSelector = EasyVisionSelector;
|
|
3322
3424
|
exports.EasyVisionTable = EasyVisionTable;
|
|
3323
3425
|
exports.buildWorkbook = buildWorkbook;
|
|
3426
|
+
exports.createIngotTableFetcher = createIngotTableFetcher;
|
|
3324
3427
|
exports.createLoopbackTableFetcher = createLoopbackTableFetcher;
|
|
3325
3428
|
exports.defaultCell = defaultCell;
|
|
3326
3429
|
exports.downloadBlob = downloadBlob;
|
|
@@ -3330,5 +3433,6 @@ exports.getSlice = getSlice;
|
|
|
3330
3433
|
exports.matchLoopbackWhere = matchLoopbackWhere;
|
|
3331
3434
|
exports.sanitizeSheetName = sanitizeSheetName;
|
|
3332
3435
|
exports.toExportColumns = toExportColumns;
|
|
3436
|
+
exports.toIngotWhere = toIngotWhere;
|
|
3333
3437
|
//# sourceMappingURL=index.cjs.map
|
|
3334
3438
|
//# sourceMappingURL=index.cjs.map
|