@updog/data-editor-wc 0.1.32 → 0.1.33
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.d.ts +6 -0
- package/index.js +112 -104
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ declare var export_default = {
|
|
|
130
130
|
},
|
|
131
131
|
footer: {
|
|
132
132
|
submit: "Submit",
|
|
133
|
+
submitBlockedByErrors: "Fix errors before submitting",
|
|
133
134
|
import: "Import",
|
|
134
135
|
next: "Next",
|
|
135
136
|
cancel: "Cancel",
|
|
@@ -1217,6 +1218,11 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
|
|
|
1217
1218
|
* @default true
|
|
1218
1219
|
*/
|
|
1219
1220
|
enableAddSource?: boolean;
|
|
1221
|
+
/**
|
|
1222
|
+
* Disable submit while any row has a validation error.
|
|
1223
|
+
* @default false
|
|
1224
|
+
*/
|
|
1225
|
+
blockSubmitOnError?: boolean;
|
|
1220
1226
|
/**
|
|
1221
1227
|
* Which file formats the user can import. `undefined` allows all formats,
|
|
1222
1228
|
* `false` disables import entirely.
|
package/index.js
CHANGED
|
@@ -8112,6 +8112,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
8112
8112
|
},
|
|
8113
8113
|
footer: {
|
|
8114
8114
|
submit: "Submit",
|
|
8115
|
+
submitBlockedByErrors: "Fix errors before submitting",
|
|
8115
8116
|
import: "Import",
|
|
8116
8117
|
next: "Next",
|
|
8117
8118
|
cancel: "Cancel",
|
|
@@ -22058,71 +22059,72 @@ function Xd(e, t, n, r) {
|
|
|
22058
22059
|
}
|
|
22059
22060
|
//#endregion
|
|
22060
22061
|
//#region src/context/useViewModel.tsx
|
|
22061
|
-
function Zd({ columns: e, primaryKey: t, loadData: n, scaleClient: r, onComplete: i, variant: a, showUploader: o, setShowUploader: s, storeRef: c, enableDeleteRow: l, enableAddRow: u, enableAddSource: d,
|
|
22062
|
-
let { t:
|
|
22063
|
-
|
|
22064
|
-
let { addDynamicColumns:
|
|
22065
|
-
|
|
22066
|
-
}, [
|
|
22067
|
-
Wd(
|
|
22068
|
-
let { onVisibleRangeChange:
|
|
22069
|
-
return (0, _.useEffect)(() => (c && (c.current =
|
|
22062
|
+
function Zd({ columns: e, primaryKey: t, loadData: n, scaleClient: r, onComplete: i, variant: a, showUploader: o, setShowUploader: s, storeRef: c, enableDeleteRow: l, enableAddRow: u, enableAddSource: d, blockSubmitOnError: f, importFormats: p, exportFormats: m, rowHeight: h, headerHeight: g, readonly: v, enableCreateColumn: y, onColumnMatch: b, onValueMatch: x, synonyms: S, sampleData: C, chat: w, remoteSources: T, onError: E, errorHandler: D }) {
|
|
22063
|
+
let { t: O } = k(), A = r ? "server" : "client", j = Vd(A, r, O("dataEditor.dataSources.existingData"), D ?? new dl(E));
|
|
22064
|
+
j.setSchemaColumns(e);
|
|
22065
|
+
let { addDynamicColumns: M, removeDynamicColumn: N, updateColumn: P } = Gd(j), F = (0, _.useCallback)((e) => {
|
|
22066
|
+
j.setDynamicColumns(e);
|
|
22067
|
+
}, [j]), I = (0, _.useSyncExternalStore)(j.subscribe, j.getEffectiveColumns), { navigateToCell: L, navigateByIndex: R, navigateToCellRef: z, resetScrollRef: B, scrollToGridTop: V } = Kd(j), { validator: H, validatorRef: U, findReplace: ee } = Xd(j, I, r?.findAndReplace, R), { search: te, setSearch: ne, matchCase: re, setMatchCase: ie, matchEntireCell: ae, setMatchEntireCell: oe, searchMode: se, setSearchMode: ce, filterColumns: le, setFilterColumns: ue, filtersResetKey: de, resetFilters: fe } = Jd(j, ee, L, V);
|
|
22068
|
+
Wd(j, U, n, A);
|
|
22069
|
+
let { onVisibleRangeChange: pe } = Yd(j, A), { portalRef: me } = qd(), [he, ge] = (0, _.useState)(null);
|
|
22070
|
+
return (0, _.useEffect)(() => (c && (c.current = j), () => {
|
|
22070
22071
|
c && (c.current = null);
|
|
22071
|
-
}), [
|
|
22072
|
-
t &&
|
|
22073
|
-
}, [
|
|
22074
|
-
mode:
|
|
22072
|
+
}), [j, c]), (0, _.useEffect)(() => {
|
|
22073
|
+
t && j.setPrimaryKey(t);
|
|
22074
|
+
}, [j, t]), {
|
|
22075
|
+
mode: A,
|
|
22075
22076
|
scaleClient: r,
|
|
22076
|
-
columns:
|
|
22077
|
+
columns: I,
|
|
22077
22078
|
primaryKey: t,
|
|
22078
22079
|
enableDeleteRow: l ?? !1,
|
|
22079
22080
|
enableAddRow: u ?? !0,
|
|
22080
22081
|
enableAddSource: d ?? !0,
|
|
22081
|
-
|
|
22082
|
-
|
|
22083
|
-
|
|
22084
|
-
|
|
22085
|
-
|
|
22086
|
-
|
|
22087
|
-
|
|
22082
|
+
blockSubmitOnError: f ?? !1,
|
|
22083
|
+
importFormats: p ?? pl,
|
|
22084
|
+
exportFormats: m ?? pl,
|
|
22085
|
+
rowHeight: h ?? 34,
|
|
22086
|
+
headerHeight: g ?? 36,
|
|
22087
|
+
store: j,
|
|
22088
|
+
validator: H,
|
|
22089
|
+
findReplace: ee,
|
|
22088
22090
|
onComplete: i,
|
|
22089
22091
|
showUploader: o,
|
|
22090
22092
|
setShowUploader: s,
|
|
22091
22093
|
variant: a ?? "editor",
|
|
22092
|
-
search:
|
|
22093
|
-
setSearch:
|
|
22094
|
-
matchCase:
|
|
22095
|
-
setMatchCase:
|
|
22096
|
-
matchEntireCell:
|
|
22097
|
-
setMatchEntireCell:
|
|
22098
|
-
searchMode:
|
|
22099
|
-
setSearchMode:
|
|
22100
|
-
filterColumns:
|
|
22101
|
-
setFilterColumns:
|
|
22102
|
-
navigateToCell:
|
|
22103
|
-
navigateToCellRef:
|
|
22104
|
-
resetScrollRef:
|
|
22105
|
-
scrollToGridTop:
|
|
22106
|
-
portalRef:
|
|
22107
|
-
readonly:
|
|
22108
|
-
filtersResetKey:
|
|
22109
|
-
resetFilters:
|
|
22094
|
+
search: te,
|
|
22095
|
+
setSearch: ne,
|
|
22096
|
+
matchCase: re,
|
|
22097
|
+
setMatchCase: ie,
|
|
22098
|
+
matchEntireCell: ae,
|
|
22099
|
+
setMatchEntireCell: oe,
|
|
22100
|
+
searchMode: se,
|
|
22101
|
+
setSearchMode: ce,
|
|
22102
|
+
filterColumns: le,
|
|
22103
|
+
setFilterColumns: ue,
|
|
22104
|
+
navigateToCell: L,
|
|
22105
|
+
navigateToCellRef: z,
|
|
22106
|
+
resetScrollRef: B,
|
|
22107
|
+
scrollToGridTop: V,
|
|
22108
|
+
portalRef: me,
|
|
22109
|
+
readonly: v ?? !1,
|
|
22110
|
+
filtersResetKey: de,
|
|
22111
|
+
resetFilters: fe,
|
|
22110
22112
|
originalColumns: e,
|
|
22111
|
-
dynamicColumns:
|
|
22112
|
-
setDynamicColumns:
|
|
22113
|
-
addDynamicColumns:
|
|
22114
|
-
removeDynamicColumn:
|
|
22115
|
-
updateColumn:
|
|
22116
|
-
gridClipboard:
|
|
22117
|
-
setGridClipboard:
|
|
22118
|
-
enableCreateColumn:
|
|
22119
|
-
onColumnMatch:
|
|
22120
|
-
onValueMatch:
|
|
22121
|
-
synonyms:
|
|
22122
|
-
sampleData:
|
|
22123
|
-
onVisibleRangeChange:
|
|
22124
|
-
chat:
|
|
22125
|
-
remoteSources:
|
|
22113
|
+
dynamicColumns: j.getDynamicColumns(),
|
|
22114
|
+
setDynamicColumns: F,
|
|
22115
|
+
addDynamicColumns: M,
|
|
22116
|
+
removeDynamicColumn: N,
|
|
22117
|
+
updateColumn: P,
|
|
22118
|
+
gridClipboard: he,
|
|
22119
|
+
setGridClipboard: ge,
|
|
22120
|
+
enableCreateColumn: y ?? !0,
|
|
22121
|
+
onColumnMatch: b,
|
|
22122
|
+
onValueMatch: x,
|
|
22123
|
+
synonyms: S,
|
|
22124
|
+
sampleData: C,
|
|
22125
|
+
onVisibleRangeChange: pe,
|
|
22126
|
+
chat: w,
|
|
22127
|
+
remoteSources: T ?? []
|
|
22126
22128
|
};
|
|
22127
22129
|
}
|
|
22128
22130
|
//#endregion
|
|
@@ -25615,74 +25617,74 @@ var qv = ({ open: e, onClose: t, onConfirm: n, loading: r = !1 }) => {
|
|
|
25615
25617
|
})
|
|
25616
25618
|
});
|
|
25617
25619
|
}, Yv = () => {
|
|
25618
|
-
let { store: e, columns: t, onComplete: n, exportFormats: r, readonly: i, navigateToCell: a } = ef(), { t:
|
|
25620
|
+
let { store: e, columns: t, onComplete: n, exportFormats: r, readonly: i, navigateToCell: a, blockSubmitOnError: o } = ef(), { t: s, rtl: c } = k(), { canUndo: l, canRedo: u, undo: d, redo: f } = xl(e, a), { dirtyRowCount: p, deletedRowCount: m, errorCount: h, isLoading: g, sources: v, phase: y } = fl(e), b = p > 0 || m > 0, x = g || v.some((e) => e.isLoading), S = y === "processing", C = o && h > 0, [w, T] = (0, _.useState)(!1), { value: D, setTrue: O, setFalse: A } = ul(!1), [j, M] = (0, _.useState)(!1), N = (0, _.useCallback)(async () => {
|
|
25619
25621
|
if (!n) return;
|
|
25620
25622
|
let t = e.getResultBySource();
|
|
25621
|
-
|
|
25623
|
+
M(!0);
|
|
25622
25624
|
try {
|
|
25623
|
-
await n(t), e.clear(),
|
|
25625
|
+
await n(t), e.clear(), A();
|
|
25624
25626
|
} catch {} finally {
|
|
25625
|
-
|
|
25627
|
+
M(!1);
|
|
25626
25628
|
}
|
|
25627
25629
|
}, [
|
|
25628
25630
|
e,
|
|
25629
25631
|
n,
|
|
25630
|
-
|
|
25631
|
-
]),
|
|
25632
|
+
A
|
|
25633
|
+
]), P = s("dataEditor.footer.export"), F = s("dataEditor.footer.exportAll"), I = s("dataEditor.footer.exportFiltered"), L = s("dataEditor.footer.csvFormat"), R = s("dataEditor.footer.excelFormat"), z = s("dataEditor.footer.jsonFormat"), B = s("dataEditor.footer.tsvFormat"), V = s("dataEditor.footer.xmlFormat"), H = (0, _.useMemo)(() => [
|
|
25632
25634
|
{
|
|
25633
25635
|
menuId: "csv",
|
|
25634
25636
|
format: "csv",
|
|
25635
|
-
text:
|
|
25637
|
+
text: L
|
|
25636
25638
|
},
|
|
25637
25639
|
{
|
|
25638
25640
|
menuId: "tsv",
|
|
25639
25641
|
format: "tsv",
|
|
25640
|
-
text:
|
|
25642
|
+
text: B
|
|
25641
25643
|
},
|
|
25642
25644
|
{
|
|
25643
25645
|
menuId: "excel",
|
|
25644
25646
|
format: "xlsx",
|
|
25645
|
-
text:
|
|
25647
|
+
text: R
|
|
25646
25648
|
},
|
|
25647
25649
|
{
|
|
25648
25650
|
menuId: "json",
|
|
25649
25651
|
format: "json",
|
|
25650
|
-
text:
|
|
25652
|
+
text: z
|
|
25651
25653
|
},
|
|
25652
25654
|
{
|
|
25653
25655
|
menuId: "xml",
|
|
25654
25656
|
format: "xml",
|
|
25655
|
-
text:
|
|
25657
|
+
text: V
|
|
25656
25658
|
}
|
|
25657
25659
|
], [
|
|
25658
|
-
P,
|
|
25659
25660
|
L,
|
|
25660
|
-
|
|
25661
|
-
|
|
25662
|
-
|
|
25663
|
-
|
|
25664
|
-
|
|
25661
|
+
B,
|
|
25662
|
+
R,
|
|
25663
|
+
z,
|
|
25664
|
+
V
|
|
25665
|
+
]), U = r !== !1 && (!e.isServer() || e.hasServerExport), ee = (0, _.useMemo)(() => {
|
|
25666
|
+
let e = r === !1 ? [] : H.filter((e) => r.includes(e.format));
|
|
25665
25667
|
return [{
|
|
25666
25668
|
id: "export-all",
|
|
25667
|
-
text:
|
|
25669
|
+
text: F,
|
|
25668
25670
|
options: e.map((e) => ({
|
|
25669
25671
|
id: `all-${e.menuId}`,
|
|
25670
25672
|
text: e.text
|
|
25671
25673
|
}))
|
|
25672
25674
|
}, {
|
|
25673
25675
|
id: "export-filtered",
|
|
25674
|
-
text:
|
|
25676
|
+
text: I,
|
|
25675
25677
|
options: e.map((e) => ({
|
|
25676
25678
|
id: `filtered-${e.menuId}`,
|
|
25677
25679
|
text: e.text
|
|
25678
25680
|
}))
|
|
25679
25681
|
}];
|
|
25680
25682
|
}, [
|
|
25681
|
-
|
|
25682
|
-
|
|
25683
|
-
|
|
25683
|
+
F,
|
|
25684
|
+
I,
|
|
25685
|
+
H,
|
|
25684
25686
|
r
|
|
25685
|
-
]),
|
|
25687
|
+
]), te = (0, _.useCallback)((n) => {
|
|
25686
25688
|
let [r, i] = n.split("-"), a = {
|
|
25687
25689
|
csv: "csv",
|
|
25688
25690
|
tsv: "tsv",
|
|
@@ -25690,70 +25692,75 @@ var qv = ({ open: e, onClose: t, onConfirm: n, loading: r = !1 }) => {
|
|
|
25690
25692
|
json: "json",
|
|
25691
25693
|
xml: "xml"
|
|
25692
25694
|
};
|
|
25693
|
-
|
|
25695
|
+
T(!0), (e.isServer() ? e.serverExport(a[i], r === "all", c) : Kv({
|
|
25694
25696
|
store: e,
|
|
25695
25697
|
columns: t,
|
|
25696
25698
|
format: a[i],
|
|
25697
25699
|
scope: r,
|
|
25698
|
-
rtl:
|
|
25699
|
-
})).finally(() =>
|
|
25700
|
+
rtl: c
|
|
25701
|
+
})).finally(() => T(!1));
|
|
25700
25702
|
}, [
|
|
25701
25703
|
e,
|
|
25702
25704
|
t,
|
|
25703
|
-
|
|
25704
|
-
]),
|
|
25705
|
+
c
|
|
25706
|
+
]), ne = s("dataEditor.footer.submit"), re = !b || S || j || C;
|
|
25705
25707
|
return /* @__PURE__ */ (0, E.jsxs)(E.Fragment, { children: [/* @__PURE__ */ (0, E.jsxs)("footer", {
|
|
25706
25708
|
className: "updog__data-editor-footer",
|
|
25707
25709
|
children: [/* @__PURE__ */ (0, E.jsx)(Jv, {}), /* @__PURE__ */ (0, E.jsxs)("div", {
|
|
25708
25710
|
className: "updog__data-editor-footer__actions",
|
|
25709
25711
|
children: [
|
|
25710
25712
|
!i && /* @__PURE__ */ (0, E.jsxs)(E.Fragment, { children: [/* @__PURE__ */ (0, E.jsx)(Rs, {
|
|
25711
|
-
content:
|
|
25713
|
+
content: s("dataEditor.undoRedo.undo"),
|
|
25712
25714
|
children: /* @__PURE__ */ (0, E.jsx)(at, {
|
|
25713
25715
|
variant: "ghost",
|
|
25714
25716
|
color: "neutral",
|
|
25715
|
-
disabled: !
|
|
25716
|
-
onClick:
|
|
25717
|
-
"aria-label":
|
|
25717
|
+
disabled: !l || S,
|
|
25718
|
+
onClick: d,
|
|
25719
|
+
"aria-label": s("dataEditor.undoRedo.undo"),
|
|
25718
25720
|
children: /* @__PURE__ */ (0, E.jsx)(Be, { className: "rtl-mirror" })
|
|
25719
25721
|
})
|
|
25720
25722
|
}), /* @__PURE__ */ (0, E.jsx)(Rs, {
|
|
25721
|
-
content:
|
|
25723
|
+
content: s("dataEditor.undoRedo.redo"),
|
|
25722
25724
|
children: /* @__PURE__ */ (0, E.jsx)(at, {
|
|
25723
25725
|
variant: "ghost",
|
|
25724
25726
|
color: "neutral",
|
|
25725
|
-
disabled: !
|
|
25726
|
-
onClick:
|
|
25727
|
-
"aria-label":
|
|
25727
|
+
disabled: !u || S,
|
|
25728
|
+
onClick: f,
|
|
25729
|
+
"aria-label": s("dataEditor.undoRedo.redo"),
|
|
25728
25730
|
children: /* @__PURE__ */ (0, E.jsx)(ke, { className: "rtl-mirror" })
|
|
25729
25731
|
})
|
|
25730
25732
|
})] }),
|
|
25731
|
-
|
|
25732
|
-
options:
|
|
25733
|
-
onSelect:
|
|
25733
|
+
U && /* @__PURE__ */ (0, E.jsx)(cc, {
|
|
25734
|
+
options: ee,
|
|
25735
|
+
onSelect: te,
|
|
25734
25736
|
placement: "top-end",
|
|
25735
25737
|
children: /* @__PURE__ */ (0, E.jsx)(rt, {
|
|
25736
25738
|
variant: "outlined",
|
|
25737
25739
|
color: "neutral",
|
|
25738
|
-
loading:
|
|
25739
|
-
disabled:
|
|
25740
|
+
loading: w,
|
|
25741
|
+
disabled: x || S,
|
|
25740
25742
|
spinnerPosition: "end",
|
|
25741
25743
|
endIcon: /* @__PURE__ */ (0, E.jsx)(ie, {}),
|
|
25742
|
-
children:
|
|
25744
|
+
children: P
|
|
25743
25745
|
})
|
|
25744
25746
|
}),
|
|
25745
|
-
!i && /* @__PURE__ */ (0, E.jsx)(
|
|
25746
|
-
disabled: !
|
|
25747
|
-
|
|
25748
|
-
|
|
25747
|
+
!i && /* @__PURE__ */ (0, E.jsx)(Rs, {
|
|
25748
|
+
disabled: !C,
|
|
25749
|
+
content: s("dataEditor.footer.submitBlockedByErrors"),
|
|
25750
|
+
placement: "top-end",
|
|
25751
|
+
children: /* @__PURE__ */ (0, E.jsx)(rt, {
|
|
25752
|
+
disabled: re,
|
|
25753
|
+
onClick: O,
|
|
25754
|
+
children: ne
|
|
25755
|
+
})
|
|
25749
25756
|
})
|
|
25750
25757
|
]
|
|
25751
25758
|
})]
|
|
25752
25759
|
}), /* @__PURE__ */ (0, E.jsx)(qv, {
|
|
25753
|
-
open:
|
|
25754
|
-
onClose:
|
|
25755
|
-
onConfirm:
|
|
25756
|
-
loading:
|
|
25760
|
+
open: D,
|
|
25761
|
+
onClose: A,
|
|
25762
|
+
onConfirm: N,
|
|
25763
|
+
loading: j
|
|
25757
25764
|
})] });
|
|
25758
25765
|
}, Xv = ({ initialValues: e, existingNames: t, onClose: n, onSubmit: r }) => {
|
|
25759
25766
|
let { t: i } = k(), a = e.id !== void 0, o = (0, _.useMemo)(() => {
|
|
@@ -52064,6 +52071,7 @@ function oV(e) {
|
|
|
52064
52071
|
enableDeleteRow: e.enableDeleteRow,
|
|
52065
52072
|
enableAddRow: e.enableAddRow,
|
|
52066
52073
|
enableAddSource: e.enableAddSource,
|
|
52074
|
+
blockSubmitOnError: e.blockSubmitOnError,
|
|
52067
52075
|
importFormats: e.importFormats,
|
|
52068
52076
|
exportFormats: e.exportFormats,
|
|
52069
52077
|
readonly: e.readonly,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@updog/data-editor-wc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"description": "Client-side CSV importer and spreadsheet editor SDK as a Web Component. Drop into Vue, Angular, Svelte, or vanilla JS. Import CSV, Excel, JSON; edit 1M+ rows entirely in the browser.",
|
|
5
5
|
"author": "Mikhail Kutateladze <admin@updog.tech>",
|
|
6
6
|
"homepage": "https://updog.tech",
|