@updog/data-editor 0.1.44 → 0.1.45

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.
Files changed (3) hide show
  1. package/index.d.ts +8 -2
  2. package/index.js +152 -81
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -3031,14 +3031,20 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
3031
3031
  */
3032
3032
  onValueMatch?: (valuesToMatch: Record<string, ValueMatchInput>) => ValueMatchOutput | Promise<ValueMatchOutput>;
3033
3033
  /**
3034
- * Extra synonyms for column auto-matching. Keys are column IDs, values are
3035
- * alternative names the matching engine should recognize.
3034
+ * Extra synonyms layered on top of the built-ins for both column matching
3035
+ * (header vs column) and value matching (imported value vs select option).
3036
+ * Each key is the canonical target (a column ID/title, or a select option
3037
+ * value); the array lists aliases the matching engine should treat as
3038
+ * equivalent. Merged with the built-ins as a union per key.
3036
3039
  *
3037
3040
  * @example
3038
3041
  * ```ts
3039
3042
  * synonyms={{
3043
+ * // column aliases
3040
3044
  * productSku: ["sku", "article_no", "item_code"],
3041
3045
  * firstName: ["first", "given_name", "fname"],
3046
+ * // value aliases (e.g. for a "status" select)
3047
+ * Active: ["live", "enabled"],
3042
3048
  * }}
3043
3049
  * ```
3044
3050
  */
package/index.js CHANGED
@@ -20720,77 +20720,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
20720
20720
  ]
20721
20721
  })]
20722
20722
  });
20723
- }, fv = 60, pv = (e) => e.toLowerCase().replace(/[\s_\-.]+/g, "").trim(), mv = (e) => e.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[\s_\-.]+/g, " ").toLowerCase().split(" ").filter(Boolean), hv = (e, t) => {
20724
- let n = new Set(mv(e)), r = new Set(mv(t));
20725
- if (n.size === 0 || r.size === 0) return 0;
20726
- let i = 0;
20727
- for (let e of n) r.has(e) && i++;
20728
- return i / Math.max(n.size, r.size);
20729
- }, gv = (e, t) => {
20730
- if (e.length === 0) return t.length;
20731
- if (t.length === 0) return e.length;
20732
- e.length > t.length && ([e, t] = [t, e]);
20733
- let n = e.length, r = t.length, i = Array(n + 1);
20734
- for (let e = 0; e <= n; e++) i[e] = e;
20735
- for (let a = 1; a <= r; a++) {
20736
- let r = i[0];
20737
- i[0] = a;
20738
- for (let o = 1; o <= n; o++) {
20739
- let n = e[o - 1] === t[a - 1] ? 0 : 1, s = i[o];
20740
- i[o] = Math.min(i[o] + 1, i[o - 1] + 1, r + n), r = s;
20741
- }
20742
- }
20743
- return i[n];
20744
- }, _v = (e) => e <= 4 ? 1 : e <= 8 ? 2 : e <= 15 ? 3 : 4, vv = (e, t) => {
20745
- let n = Math.max(e.length, t.length);
20746
- if (n === 0) return !0;
20747
- let r = _v(n);
20748
- return gv(e, t) <= r;
20749
- }, yv = (e, t) => {
20750
- let n = pv(e), r = pv(t);
20751
- return (n.length <= r.length ? n : r).length < 4 ? !1 : n.includes(r) || r.includes(n);
20752
- }, bv = (e, t, n) => {
20753
- let r = pv(e), i = pv(t);
20754
- for (let [e, t] of Object.entries(n)) {
20755
- let n = [e, ...t], a = n.includes(r), o = n.includes(i);
20756
- if (a && o) return !0;
20757
- }
20758
- return !1;
20759
- }, xv = (e, t, n) => {
20760
- let r = pv(e), i = pv(t);
20761
- if (r === i) return 100;
20762
- if (n && bv(e, t, n)) return 90;
20763
- if (yv(e, t)) return 80;
20764
- let a = hv(e, t);
20765
- return a >= .5 ? 70 : vv(r, i) ? 65 : a > 0 ? Math.round(a * 60) : 0;
20766
- }, Sv = (e, t, n, r) => {
20767
- let i = xv(e, t, r), a = xv(e, n, r);
20768
- return Math.max(i, a);
20769
- }, Cv = (e, t, n = fv) => {
20770
- let r, i = 0;
20771
- for (let n of t) {
20772
- let t = xv(e, n);
20773
- t > i && (i = t, r = n);
20774
- }
20775
- return i >= n ? r : void 0;
20776
- }, wv = (e) => {
20777
- let t = {};
20778
- for (let [n, { importedValues: r, options: i }] of Object.entries(e)) {
20779
- let e = {};
20780
- for (let t of r) e[t] = Cv(t, i);
20781
- t[n] = e;
20782
- }
20783
- return t;
20784
- }, Tv = async (e, t) => {
20785
- if (!t) return wv(e);
20786
- let n = await t(e), r = {};
20787
- for (let [t, { importedValues: i, options: a }] of Object.entries(e)) {
20788
- let e = n[t], o = {};
20789
- for (let t of i) e && t in e ? o[t] = e[t] ?? void 0 : o[t] = Cv(t, a);
20790
- r[t] = o;
20791
- }
20792
- return r;
20793
- }, Ev = "action:create", Dv = {
20723
+ }, fv = {
20794
20724
  prefix: ["salutation", "honorific"],
20795
20725
  firstname: [
20796
20726
  "fname",
@@ -20986,7 +20916,9 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
20986
20916
  "supervisor",
20987
20917
  "linemanager",
20988
20918
  "reportingmanager",
20989
- "managername"
20919
+ "managername",
20920
+ "mgr",
20921
+ "mngr"
20990
20922
  ],
20991
20923
  managerid: [
20992
20924
  "supervisorid",
@@ -21317,8 +21249,76 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21317
21249
  "languagespoken",
21318
21250
  "nativelanguage",
21319
21251
  "languageproficiency"
21320
- ]
21321
- }, Ov = (e, t) => {
21252
+ ],
21253
+ male: [
21254
+ "m",
21255
+ "man",
21256
+ "boy"
21257
+ ],
21258
+ female: [
21259
+ "f",
21260
+ "woman",
21261
+ "girl"
21262
+ ],
21263
+ other: [
21264
+ "nonbinary",
21265
+ "nb",
21266
+ "diverse",
21267
+ "prefernottosay"
21268
+ ],
21269
+ junior: [
21270
+ "jr",
21271
+ "jun",
21272
+ "entry",
21273
+ "entrylevel",
21274
+ "grad",
21275
+ "graduate"
21276
+ ],
21277
+ midlevel: [
21278
+ "mid",
21279
+ "intermediate",
21280
+ "middle"
21281
+ ],
21282
+ senior: ["sr", "sen"],
21283
+ associate: ["assoc", "asc"],
21284
+ principal: ["princ", "principle"],
21285
+ lead: [
21286
+ "teamlead",
21287
+ "techlead",
21288
+ "tl"
21289
+ ],
21290
+ director: ["dir"],
21291
+ executive: ["exec"],
21292
+ intern: ["internship", "trainee"],
21293
+ fulltime: ["ft", "full"],
21294
+ parttime: ["pt", "part"],
21295
+ contract: [
21296
+ "contractor",
21297
+ "contractual",
21298
+ "freelance",
21299
+ "freelancer"
21300
+ ],
21301
+ temporary: ["temp"],
21302
+ permanent: ["perm"],
21303
+ active: ["enabled", "current"],
21304
+ inactive: [
21305
+ "disabled",
21306
+ "terminated",
21307
+ "former"
21308
+ ],
21309
+ onleave: ["leave"],
21310
+ pending: ["awaiting"],
21311
+ single: ["unmarried"],
21312
+ married: ["wed"],
21313
+ divorced: ["div"],
21314
+ widowed: ["widow", "widower"],
21315
+ low: ["lo"],
21316
+ medium: ["med"],
21317
+ high: ["hi"],
21318
+ critical: ["crit", "urgent"],
21319
+ yes: ["y", "true"],
21320
+ no: ["n", "false"]
21321
+ }, pv = (e, t) => {
21322
21322
  if (!t) return e;
21323
21323
  let n = { ...e };
21324
21324
  for (let [e, r] of Object.entries(t)) if (e in n) {
@@ -21327,7 +21327,77 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21327
21327
  n[e] = [...t];
21328
21328
  } else n[e] = r;
21329
21329
  return n;
21330
- }, kv = (e, t, n) => Sv(e, t.id, t.title, n), Av = (e, t, n, r, i = 60) => {
21330
+ }, mv = 60, hv = (e) => e.toLowerCase().replace(/[\s_\-.]+/g, "").trim(), gv = (e) => e.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[\s_\-.]+/g, " ").toLowerCase().split(" ").filter(Boolean), _v = (e, t) => {
21331
+ let n = new Set(gv(e)), r = new Set(gv(t));
21332
+ if (n.size === 0 || r.size === 0) return 0;
21333
+ let i = 0;
21334
+ for (let e of n) r.has(e) && i++;
21335
+ return i / Math.max(n.size, r.size);
21336
+ }, vv = (e, t) => {
21337
+ if (e.length === 0) return t.length;
21338
+ if (t.length === 0) return e.length;
21339
+ e.length > t.length && ([e, t] = [t, e]);
21340
+ let n = e.length, r = t.length, i = Array(n + 1);
21341
+ for (let e = 0; e <= n; e++) i[e] = e;
21342
+ for (let a = 1; a <= r; a++) {
21343
+ let r = i[0];
21344
+ i[0] = a;
21345
+ for (let o = 1; o <= n; o++) {
21346
+ let n = e[o - 1] === t[a - 1] ? 0 : 1, s = i[o];
21347
+ i[o] = Math.min(i[o] + 1, i[o - 1] + 1, r + n), r = s;
21348
+ }
21349
+ }
21350
+ return i[n];
21351
+ }, yv = (e) => e <= 4 ? 1 : e <= 8 ? 2 : e <= 15 ? 3 : 4, bv = (e, t) => {
21352
+ let n = Math.max(e.length, t.length);
21353
+ if (n === 0) return !0;
21354
+ let r = yv(n);
21355
+ return vv(e, t) <= r;
21356
+ }, xv = (e, t) => {
21357
+ let n = hv(e), r = hv(t);
21358
+ return (n.length <= r.length ? n : r).length < 4 ? !1 : n.includes(r) || r.includes(n);
21359
+ }, Sv = (e, t, n) => {
21360
+ let r = hv(e), i = hv(t);
21361
+ for (let [e, t] of Object.entries(n)) {
21362
+ let n = [e, ...t], a = n.includes(r), o = n.includes(i);
21363
+ if (a && o) return !0;
21364
+ }
21365
+ return !1;
21366
+ }, Cv = (e, t, n) => {
21367
+ let r = hv(e), i = hv(t);
21368
+ if (r === i) return 100;
21369
+ if (n && Sv(e, t, n)) return 90;
21370
+ if (xv(e, t)) return 80;
21371
+ let a = _v(e, t);
21372
+ return a >= .5 ? 70 : bv(r, i) ? 65 : a > 0 ? Math.round(a * 60) : 0;
21373
+ }, wv = (e, t, n, r) => {
21374
+ let i = Cv(e, t, r), a = Cv(e, n, r);
21375
+ return Math.max(i, a);
21376
+ }, Tv = (e, t, n = fv, r = mv) => {
21377
+ let i, a = 0;
21378
+ for (let r of t) {
21379
+ let t = Cv(e, r, n);
21380
+ t > a && (a = t, i = r);
21381
+ }
21382
+ return a >= r ? i : void 0;
21383
+ }, Ev = (e, t) => {
21384
+ let n = pv(fv, t), r = {};
21385
+ for (let [t, { importedValues: i, options: a }] of Object.entries(e)) {
21386
+ let e = {};
21387
+ for (let t of i) e[t] = Tv(t, a, n);
21388
+ r[t] = e;
21389
+ }
21390
+ return r;
21391
+ }, Dv = async (e, t, n) => {
21392
+ if (!t) return Ev(e, n);
21393
+ let r = pv(fv, n), i = await t(e), a = {};
21394
+ for (let [t, { importedValues: n, options: o }] of Object.entries(e)) {
21395
+ let e = i[t], s = {};
21396
+ for (let t of n) e && t in e ? s[t] = e[t] ?? void 0 : s[t] = Tv(t, o, r);
21397
+ a[t] = s;
21398
+ }
21399
+ return a;
21400
+ }, Ov = "action:create", kv = (e, t, n) => wv(e, t.id, t.title, n), Av = (e, t, n, r, i = 60) => {
21331
21401
  let a = null, o = 0;
21332
21402
  for (let i of t) {
21333
21403
  if (n.has(i.id)) continue;
@@ -21347,13 +21417,13 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21347
21417
  ...s
21348
21418
  };
21349
21419
  }, Mv = (e, t, n) => {
21350
- let r = Ov(Dv, n), i = {}, a = /* @__PURE__ */ new Set();
21420
+ let r = pv(fv, n), i = {}, a = /* @__PURE__ */ new Set();
21351
21421
  for (let n of e) {
21352
- let e = pv(n);
21422
+ let e = hv(n);
21353
21423
  for (let r of t) {
21354
21424
  let t = r.id;
21355
21425
  if (a.has(t)) continue;
21356
- let o = pv(t), s = pv(r.title);
21426
+ let o = hv(t), s = hv(r.title);
21357
21427
  if (e === o || e === s) {
21358
21428
  i[n] = t, a.add(t);
21359
21429
  break;
@@ -21478,7 +21548,7 @@ var Z_ = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21478
21548
  id: `${r}_d`,
21479
21549
  type: "divider"
21480
21550
  }, {
21481
- id: Ev,
21551
+ id: Ov,
21482
21552
  text: a,
21483
21553
  icon: /* @__PURE__ */ C(Ce, { size: "1rem" })
21484
21554
  }), [r, c];
@@ -22568,14 +22638,15 @@ function wy() {
22568
22638
  return;
22569
22639
  }
22570
22640
  let t = ++Le.current;
22571
- Tv(e, c).then((e) => {
22641
+ Dv(e, c, l).then((e) => {
22572
22642
  Le.current === t && Ie(e);
22573
22643
  });
22574
22644
  }, [
22575
22645
  S,
22576
22646
  T,
22577
22647
  n,
22578
- c
22648
+ c,
22649
+ l
22579
22650
  ]);
22580
22651
  let Re = v(() => {
22581
22652
  let e = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@updog/data-editor",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "Client-side CSV importer and spreadsheet editor for React. Import CSV, Excel, JSON, TSV, and XML, match columns, validate, and edit 1M+ rows entirely in the browser.",
5
5
  "author": "Mikhail Kutateladze <admin@updog.tech>",
6
6
  "homepage": "https://updog.tech",