@oliasoft-open-source/react-ui-library 5.11.7-beta-6 → 5.11.7-beta-7
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/dist/index.js +39 -36
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3916,17 +3916,20 @@ const TableScrollWrapper = ({ table: e, children: t }) => {
|
|
|
3916
3916
|
isValid: s
|
|
3917
3917
|
};
|
|
3918
3918
|
}, Table$1 = ({ validationRules: e, parsedResult: t, updateState: n, testId: r }) => {
|
|
3919
|
-
let i = useMemo(() => t.fields.map((e) => ({ value: e })), [t.fields]), [a, s] = useState(20), [l, u] = useState(1), f = useRef([]), h = (l - 1) * a, g = a === 0 ? t.rows.length : h + a, [_, v] = useState([]), y =
|
|
3920
|
-
|
|
3921
|
-
|
|
3919
|
+
let i = useMemo(() => t.fields.map((e) => ({ value: e })), [t.fields]), [a, s] = useState(20), [l, u] = useState(1), f = useRef([]), h = (l - 1) * a, g = a === 0 ? t.rows.length : h + a, [_, v] = useState([]), y = useMemo(() => {
|
|
3920
|
+
let n = e.filter((e) => !e.optionalColumn);
|
|
3921
|
+
return t.fields.length === n.length ? n : e;
|
|
3922
|
+
}, [e, t.fields.length]), b = useCallback((e, r) => (!f.current.length && t.rows.length && (f.current = t.rows[0].map((e) => isNumericLike(e) ? "NumberInput" : "Input")), {
|
|
3923
|
+
cells: e.map((e, a) => {
|
|
3924
|
+
let { columnMessage: o = {}, validator: s = () => null } = y?.[a] ?? {}, c = i?.[a]?.value, l = `${`Row ${r + 1}`} → ${c}:`, u = s(e), d = t?.errors?.find((e) => e.startsWith(l)) ?? null, p = u || d || null;
|
|
3922
3925
|
return {
|
|
3923
|
-
name:
|
|
3924
|
-
value:
|
|
3925
|
-
type: f.current[
|
|
3926
|
+
name: c,
|
|
3927
|
+
value: e,
|
|
3928
|
+
type: f.current[a] ?? "Input",
|
|
3926
3929
|
disableValidationOnFocus: !0,
|
|
3927
|
-
error:
|
|
3928
|
-
validationCallback: (e,
|
|
3929
|
-
let
|
|
3930
|
+
error: p,
|
|
3931
|
+
validationCallback: (e, i) => {
|
|
3932
|
+
let a = `Row ${r + 1}`, { updatedErrors: o, isValid: s } = getUpdatedErrors(t.errors, a, e, i);
|
|
3930
3933
|
n({ parsedResult: {
|
|
3931
3934
|
...t,
|
|
3932
3935
|
errors: o,
|
|
@@ -3934,7 +3937,7 @@ const TableScrollWrapper = ({ table: e, children: t }) => {
|
|
|
3934
3937
|
} });
|
|
3935
3938
|
},
|
|
3936
3939
|
onChange: (e) => {
|
|
3937
|
-
let { value:
|
|
3940
|
+
let { value: i } = e?.target ?? {}, o = `Row ${r + 1}`, l = s(i), { updatedErrors: u, isValid: d } = getUpdatedErrors(t.errors, o, c, l), f = t.rows.map((e, t) => t === r ? e.map((e, t) => t === a ? i : e) : e);
|
|
3938
3941
|
n({ parsedResult: {
|
|
3939
3942
|
...t,
|
|
3940
3943
|
rows: f,
|
|
@@ -3942,17 +3945,17 @@ const TableScrollWrapper = ({ table: e, children: t }) => {
|
|
|
3942
3945
|
isValid: d
|
|
3943
3946
|
} }), v((e) => {
|
|
3944
3947
|
let t = [...e];
|
|
3945
|
-
return t[
|
|
3948
|
+
return t[r] = b(f[r], r), t;
|
|
3946
3949
|
});
|
|
3947
3950
|
},
|
|
3948
|
-
...
|
|
3951
|
+
...o
|
|
3949
3952
|
};
|
|
3950
3953
|
}),
|
|
3951
3954
|
actions: [{
|
|
3952
3955
|
label: "Delete",
|
|
3953
3956
|
icon: "minus",
|
|
3954
3957
|
onClick: () => {
|
|
3955
|
-
let e = t.rows.filter((e, t) => t !==
|
|
3958
|
+
let e = t.rows.filter((e, t) => t !== r);
|
|
3956
3959
|
n({ parsedResult: {
|
|
3957
3960
|
...t,
|
|
3958
3961
|
rows: e
|
|
@@ -3966,7 +3969,7 @@ const TableScrollWrapper = ({ table: e, children: t }) => {
|
|
|
3966
3969
|
n
|
|
3967
3970
|
]);
|
|
3968
3971
|
useEffect(() => {
|
|
3969
|
-
v(t.rows.map((e, t) =>
|
|
3972
|
+
v(t.rows.map((e, t) => b(e, t)));
|
|
3970
3973
|
}, [
|
|
3971
3974
|
t.rows.length,
|
|
3972
3975
|
i,
|
|
@@ -3974,24 +3977,24 @@ const TableScrollWrapper = ({ table: e, children: t }) => {
|
|
|
3974
3977
|
t.errors,
|
|
3975
3978
|
t.isValid
|
|
3976
3979
|
]);
|
|
3977
|
-
let
|
|
3978
|
-
let
|
|
3979
|
-
if (!
|
|
3980
|
-
let
|
|
3980
|
+
let x = useMemo(() => t.fields.map((e, r) => {
|
|
3981
|
+
let a = y?.[r], o = Array.isArray(a?.validUnits) ? a.validUnits : [], s = o?.some((e) => toLower(e) === placeholder$1);
|
|
3982
|
+
if (!o.length || s) return {};
|
|
3983
|
+
let c = t?.units?.[r], l = toLower(c), u = o?.some((e) => toLower(e) === l) ? c : a?.defaultUnit ?? "";
|
|
3981
3984
|
return {
|
|
3982
|
-
key: i?.[
|
|
3983
|
-
value:
|
|
3985
|
+
key: i?.[r]?.value,
|
|
3986
|
+
value: u,
|
|
3984
3987
|
type: "Select",
|
|
3985
|
-
disabled: !
|
|
3986
|
-
options:
|
|
3988
|
+
disabled: !o.length || !u,
|
|
3989
|
+
options: o.map((e) => ({
|
|
3987
3990
|
label: e,
|
|
3988
3991
|
value: e
|
|
3989
3992
|
})),
|
|
3990
3993
|
onChange: (e) => {
|
|
3991
|
-
let { value:
|
|
3994
|
+
let { value: i } = e?.target ?? {}, a = t.units.map((e, t) => t === r ? i : e);
|
|
3992
3995
|
n({ parsedResult: {
|
|
3993
3996
|
...t,
|
|
3994
|
-
units:
|
|
3997
|
+
units: a
|
|
3995
3998
|
} });
|
|
3996
3999
|
}
|
|
3997
4000
|
};
|
|
@@ -4000,30 +4003,30 @@ const TableScrollWrapper = ({ table: e, children: t }) => {
|
|
|
4000
4003
|
e,
|
|
4001
4004
|
i,
|
|
4002
4005
|
n
|
|
4003
|
-
]),
|
|
4006
|
+
]), S = useMemo(() => x.some((e) => !isEmpty(e)), [x]), C = useMemo(() => [{
|
|
4004
4007
|
cells: i,
|
|
4005
4008
|
actions: [{}]
|
|
4006
|
-
}, ...
|
|
4009
|
+
}, ...S ? [{ cells: x }] : []], [
|
|
4007
4010
|
i,
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
]),
|
|
4011
|
+
S,
|
|
4012
|
+
x
|
|
4013
|
+
]), w = useMemo(() => _.slice(h, g), [
|
|
4011
4014
|
_,
|
|
4012
4015
|
h,
|
|
4013
4016
|
g
|
|
4014
|
-
]),
|
|
4017
|
+
]), T = useCallback(({ rowIndex: e }) => {
|
|
4015
4018
|
let n = h + e, r = t.rows[n];
|
|
4016
|
-
return r ?
|
|
4019
|
+
return r ? b(r, n) : {
|
|
4017
4020
|
cells: [],
|
|
4018
4021
|
actions: []
|
|
4019
4022
|
};
|
|
4020
4023
|
}, [
|
|
4021
4024
|
t.rows,
|
|
4022
|
-
|
|
4025
|
+
b,
|
|
4023
4026
|
h
|
|
4024
4027
|
]);
|
|
4025
4028
|
return /* @__PURE__ */ jsx(Table, {
|
|
4026
|
-
beforeRenderRow:
|
|
4029
|
+
beforeRenderRow: T,
|
|
4027
4030
|
onListReorder: ({ from: e, to: r }) => {
|
|
4028
4031
|
let i = [...t.rows], [a] = i.splice(e, 1);
|
|
4029
4032
|
i.splice(r, 0, a), n({ parsedResult: {
|
|
@@ -4037,12 +4040,12 @@ const TableScrollWrapper = ({ table: e, children: t }) => {
|
|
|
4037
4040
|
table: {
|
|
4038
4041
|
testId: `${r}-paste-with-review-modal-table`,
|
|
4039
4042
|
draggable: !0,
|
|
4040
|
-
headers:
|
|
4041
|
-
rows: Array.from({ length:
|
|
4043
|
+
headers: C,
|
|
4044
|
+
rows: Array.from({ length: w?.length || 0 }, () => ({
|
|
4042
4045
|
cells: [],
|
|
4043
4046
|
actions: []
|
|
4044
4047
|
})),
|
|
4045
|
-
rowCount:
|
|
4048
|
+
rowCount: w?.length,
|
|
4046
4049
|
infiniteScroll: !0,
|
|
4047
4050
|
footer: { pagination: {
|
|
4048
4051
|
rowCount: t.rows.length,
|
package/package.json
CHANGED