@teselagen/ui 0.3.63 → 0.3.64
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/index.cjs.js +16 -2
- package/index.es.js +16 -2
- package/package.json +2 -2
- package/src/FormComponents/tryToMatchSchemas.js +18 -3
package/index.cjs.js
CHANGED
|
@@ -60452,15 +60452,29 @@ function matchSchemas(_0) {
|
|
|
60452
60452
|
};
|
|
60453
60453
|
let csvValidationIssue = false;
|
|
60454
60454
|
const fuse = new Fuse(userSchema.fields, options);
|
|
60455
|
+
const matchedAltPaths = [];
|
|
60455
60456
|
officialSchema.fields.forEach((h2) => {
|
|
60456
60457
|
let hasMatch = false;
|
|
60457
60458
|
let result = fuse.search(h2.path) || [];
|
|
60459
|
+
const hadNormalPathMatch = userSchema.fields.some((uh) => norm(uh.path) === norm(h2.path));
|
|
60458
60460
|
userSchema.fields.forEach((uh, i) => {
|
|
60459
60461
|
const pathMatch = norm(uh.path) === norm(h2.path);
|
|
60460
60462
|
const displayNameMatch = h2.displayName && norm(uh.path) === norm(getTextFromEl(h2.displayName));
|
|
60461
|
-
const hasAlternatePathMatch = h2.alternatePathMatch && (lodashExports.isArray(h2.alternatePathMatch) ? h2.alternatePathMatch : [h2.alternatePathMatch]).
|
|
60462
|
-
|
|
60463
|
+
const hasAlternatePathMatch = !hadNormalPathMatch && h2.alternatePathMatch && (lodashExports.isArray(h2.alternatePathMatch) ? h2.alternatePathMatch : [h2.alternatePathMatch]).find((alternatePathMatch) => {
|
|
60464
|
+
let altPath = alternatePathMatch;
|
|
60465
|
+
if (lodashExports.isPlainObject(alternatePathMatch)) {
|
|
60466
|
+
altPath = alternatePathMatch.path;
|
|
60467
|
+
}
|
|
60468
|
+
return norm(uh.path) === norm(altPath);
|
|
60463
60469
|
});
|
|
60470
|
+
if (hasAlternatePathMatch) {
|
|
60471
|
+
matchedAltPaths.push(
|
|
60472
|
+
hasAlternatePathMatch.path || hasAlternatePathMatch
|
|
60473
|
+
);
|
|
60474
|
+
if (hasAlternatePathMatch.format) {
|
|
60475
|
+
h2.format = hasAlternatePathMatch.format;
|
|
60476
|
+
}
|
|
60477
|
+
}
|
|
60464
60478
|
if (pathMatch || displayNameMatch || hasAlternatePathMatch) {
|
|
60465
60479
|
result = result.filter(({ path: path2 }) => path2 === uh.path);
|
|
60466
60480
|
result.unshift({
|
package/index.es.js
CHANGED
|
@@ -60434,15 +60434,29 @@ function matchSchemas(_0) {
|
|
|
60434
60434
|
};
|
|
60435
60435
|
let csvValidationIssue = false;
|
|
60436
60436
|
const fuse = new Fuse(userSchema.fields, options);
|
|
60437
|
+
const matchedAltPaths = [];
|
|
60437
60438
|
officialSchema.fields.forEach((h2) => {
|
|
60438
60439
|
let hasMatch = false;
|
|
60439
60440
|
let result = fuse.search(h2.path) || [];
|
|
60441
|
+
const hadNormalPathMatch = userSchema.fields.some((uh) => norm(uh.path) === norm(h2.path));
|
|
60440
60442
|
userSchema.fields.forEach((uh, i) => {
|
|
60441
60443
|
const pathMatch = norm(uh.path) === norm(h2.path);
|
|
60442
60444
|
const displayNameMatch = h2.displayName && norm(uh.path) === norm(getTextFromEl(h2.displayName));
|
|
60443
|
-
const hasAlternatePathMatch = h2.alternatePathMatch && (lodashExports.isArray(h2.alternatePathMatch) ? h2.alternatePathMatch : [h2.alternatePathMatch]).
|
|
60444
|
-
|
|
60445
|
+
const hasAlternatePathMatch = !hadNormalPathMatch && h2.alternatePathMatch && (lodashExports.isArray(h2.alternatePathMatch) ? h2.alternatePathMatch : [h2.alternatePathMatch]).find((alternatePathMatch) => {
|
|
60446
|
+
let altPath = alternatePathMatch;
|
|
60447
|
+
if (lodashExports.isPlainObject(alternatePathMatch)) {
|
|
60448
|
+
altPath = alternatePathMatch.path;
|
|
60449
|
+
}
|
|
60450
|
+
return norm(uh.path) === norm(altPath);
|
|
60445
60451
|
});
|
|
60452
|
+
if (hasAlternatePathMatch) {
|
|
60453
|
+
matchedAltPaths.push(
|
|
60454
|
+
hasAlternatePathMatch.path || hasAlternatePathMatch
|
|
60455
|
+
);
|
|
60456
|
+
if (hasAlternatePathMatch.format) {
|
|
60457
|
+
h2.format = hasAlternatePathMatch.format;
|
|
60458
|
+
}
|
|
60459
|
+
}
|
|
60446
60460
|
if (pathMatch || displayNameMatch || hasAlternatePathMatch) {
|
|
60447
60461
|
result = result.filter(({ path: path2 }) => path2 === uh.path);
|
|
60448
60462
|
result.unshift({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teselagen/ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.64",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"./style.css": "./style.css"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@teselagen/file-utils": "0.3.
|
|
13
|
+
"@teselagen/file-utils": "0.3.15",
|
|
14
14
|
"@teselagen/bounce-loader": "0.3.11",
|
|
15
15
|
"@blueprintjs/core": "3.52.0",
|
|
16
16
|
"@blueprintjs/datetime": "3.23.19",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forEach, isArray, map, snakeCase } from "lodash";
|
|
1
|
+
import { forEach, isArray, isPlainObject, map, snakeCase } from "lodash";
|
|
2
2
|
import { nanoid } from "nanoid";
|
|
3
3
|
import Fuse from "fuse.js";
|
|
4
4
|
import { editCellHelper } from "../DataTable/editCellHelper";
|
|
@@ -82,25 +82,40 @@ async function matchSchemas({ userSchema, officialSchema }) {
|
|
|
82
82
|
let csvValidationIssue = false;
|
|
83
83
|
const fuse = new Fuse(userSchema.fields, options);
|
|
84
84
|
|
|
85
|
+
const matchedAltPaths = [];
|
|
85
86
|
officialSchema.fields.forEach(h => {
|
|
86
87
|
let hasMatch = false;
|
|
87
88
|
//run fuse search for results
|
|
88
89
|
let result = fuse.search(h.path) || [];
|
|
89
90
|
|
|
91
|
+
const hadNormalPathMatch = userSchema.fields.some(uh => norm(uh.path) === norm(h.path))
|
|
90
92
|
//if there are any exact matches, push them onto the results array
|
|
91
93
|
userSchema.fields.forEach((uh, i) => {
|
|
92
94
|
const pathMatch = norm(uh.path) === norm(h.path);
|
|
93
95
|
const displayNameMatch =
|
|
94
96
|
h.displayName && norm(uh.path) === norm(getTextFromEl(h.displayName));
|
|
95
97
|
const hasAlternatePathMatch =
|
|
98
|
+
!hadNormalPathMatch &&
|
|
96
99
|
h.alternatePathMatch &&
|
|
97
100
|
(isArray(h.alternatePathMatch)
|
|
98
101
|
? h.alternatePathMatch
|
|
99
102
|
: [h.alternatePathMatch]
|
|
100
|
-
).
|
|
101
|
-
|
|
103
|
+
).find(alternatePathMatch => {
|
|
104
|
+
let altPath = alternatePathMatch;
|
|
105
|
+
if (isPlainObject(alternatePathMatch)) {
|
|
106
|
+
altPath = alternatePathMatch.path;
|
|
107
|
+
}
|
|
108
|
+
return norm(uh.path) === norm(altPath);
|
|
102
109
|
});
|
|
103
110
|
|
|
111
|
+
if (hasAlternatePathMatch) {
|
|
112
|
+
matchedAltPaths.push(
|
|
113
|
+
hasAlternatePathMatch.path || hasAlternatePathMatch
|
|
114
|
+
);
|
|
115
|
+
if (hasAlternatePathMatch.format) {
|
|
116
|
+
h.format = hasAlternatePathMatch.format;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
104
119
|
if (pathMatch || displayNameMatch || hasAlternatePathMatch) {
|
|
105
120
|
result = result.filter(({ path }) => path === uh.path);
|
|
106
121
|
//add a fake perfect match result to make sure we get the match
|