@snmt-react-ui/user-select 2.4.1 → 2.5.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/dist/UserSelect.d.ts +2 -0
- package/dist/user-select.js +314 -304
- package/package.json +4 -4
package/dist/UserSelect.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export type UserSelectProps = (Omit<SingleSelectProps, 'options'> | Omit<MultiSe
|
|
|
34
34
|
status: number;
|
|
35
35
|
message?: string;
|
|
36
36
|
}) => void;
|
|
37
|
+
/** Should contain None option */
|
|
38
|
+
allowEmpty?: boolean;
|
|
37
39
|
};
|
|
38
40
|
/**
|
|
39
41
|
* This is UserSelect. It is a customizable and asynchronous select component designed
|
package/dist/user-select.js
CHANGED
|
@@ -3,7 +3,7 @@ var le = (i, e, t) => e in i ? oe(i, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var M1 = (i, e, t) => le(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import "./index.css";
|
|
5
5
|
import { jsx as r, Fragment as X, jsxs as u } from "react/jsx-runtime";
|
|
6
|
-
import { createContext as n1, forwardRef as r1, useState as
|
|
6
|
+
import { createContext as n1, forwardRef as r1, useState as B, useRef as f1, useEffect as T, useCallback as j, useImperativeHandle as ae, useContext as o1 } from "react";
|
|
7
7
|
import { Select as he, Flex as ce, Avatar as de, Checkbox as ge, Typography as K1, Tag as P1, Popover as ue } from "antd";
|
|
8
8
|
import { SNMTUiContext as Ce } from "@snmt-react-ui/core";
|
|
9
9
|
const c1 = ({
|
|
@@ -56,7 +56,7 @@ const fe = ({
|
|
|
56
56
|
disabled: n = !1,
|
|
57
57
|
disableUncheck: l = !1
|
|
58
58
|
}) => {
|
|
59
|
-
const [c, o] =
|
|
59
|
+
const [c, o] = B(i), [d, g] = B(e);
|
|
60
60
|
T(() => {
|
|
61
61
|
o(i), g(e);
|
|
62
62
|
}, [i, e]);
|
|
@@ -3077,7 +3077,7 @@ const we = ({
|
|
|
3077
3077
|
disabled: l = !1,
|
|
3078
3078
|
onClick: c
|
|
3079
3079
|
}) => {
|
|
3080
|
-
const [o, d] =
|
|
3080
|
+
const [o, d] = B(n), { theme: g } = o1(F1), a = l ? g && g === "dark" ? k.GREY_LIGHT_4 : k.GREY_DARK_1 : s, h = l ? void 0 : c;
|
|
3081
3081
|
return T(() => {
|
|
3082
3082
|
if (n) {
|
|
3083
3083
|
h && !l && d(`${n} clickable`);
|
|
@@ -6369,7 +6369,7 @@ const Jt = ({
|
|
|
6369
6369
|
disabled: l = !1,
|
|
6370
6370
|
onClick: c
|
|
6371
6371
|
}) => {
|
|
6372
|
-
const [o, d] =
|
|
6372
|
+
const [o, d] = B(n), { theme: g } = o1(Y1), a = l ? g && g === "dark" ? L.GREY_LIGHT_4 : L.GREY_DARK_1 : s, h = l ? void 0 : c;
|
|
6373
6373
|
return T(() => {
|
|
6374
6374
|
if (n) {
|
|
6375
6375
|
h && !l && d(`${n} clickable`);
|
|
@@ -6695,7 +6695,7 @@ const z1 = ({ children: i, width: e, size: t = "small", onClose: s, closable: n
|
|
|
6695
6695
|
placement: n = "topRight",
|
|
6696
6696
|
noPadding: l = !1
|
|
6697
6697
|
}) => {
|
|
6698
|
-
const [c, o] =
|
|
6698
|
+
const [c, o] = B(!1);
|
|
6699
6699
|
return /* @__PURE__ */ r(
|
|
6700
6700
|
ue,
|
|
6701
6701
|
{
|
|
@@ -6719,7 +6719,7 @@ const z1 = ({ children: i, width: e, size: t = "small", onClose: s, closable: n
|
|
|
6719
6719
|
options: n,
|
|
6720
6720
|
extraOptions: l
|
|
6721
6721
|
}) => {
|
|
6722
|
-
const [c, o] =
|
|
6722
|
+
const [c, o] = B(!1);
|
|
6723
6723
|
T(() => {
|
|
6724
6724
|
i.length || o(!1);
|
|
6725
6725
|
}, [i]);
|
|
@@ -6780,96 +6780,96 @@ const z1 = ({ children: i, width: e, size: t = "small", onClose: s, closable: n
|
|
|
6780
6780
|
onDropdownVisibleChange: h,
|
|
6781
6781
|
onScrollToEnd: C,
|
|
6782
6782
|
onPopupScroll: p,
|
|
6783
|
-
id:
|
|
6784
|
-
extraOptions:
|
|
6785
|
-
dropdownRender:
|
|
6786
|
-
optionRender:
|
|
6783
|
+
id: x,
|
|
6784
|
+
extraOptions: R,
|
|
6785
|
+
dropdownRender: v,
|
|
6786
|
+
optionRender: _,
|
|
6787
6787
|
isLoading: y,
|
|
6788
|
-
readOnly:
|
|
6789
|
-
},
|
|
6790
|
-
const [m,
|
|
6788
|
+
readOnly: V
|
|
6789
|
+
}, w) => {
|
|
6790
|
+
const [m, N] = B(!1), [M, I] = B(!1), [A, S] = B(!0), [b, P] = B(i), Z = f1(null);
|
|
6791
6791
|
T(() => {
|
|
6792
|
-
|
|
6792
|
+
P(i);
|
|
6793
6793
|
}, [i]);
|
|
6794
|
-
const
|
|
6795
|
-
|
|
6796
|
-
}, $ = (
|
|
6794
|
+
const H = (f) => {
|
|
6795
|
+
N(f), h && h(f);
|
|
6796
|
+
}, $ = (f, O) => {
|
|
6797
6797
|
var D;
|
|
6798
|
-
return !!((D =
|
|
6798
|
+
return !!((D = O == null ? void 0 : O.label) != null && D.toString().toLowerCase().includes(f.toLowerCase()));
|
|
6799
6799
|
}, Y = () => {
|
|
6800
|
-
|
|
6800
|
+
I(!0);
|
|
6801
6801
|
}, U = () => {
|
|
6802
|
-
|
|
6803
|
-
},
|
|
6804
|
-
(
|
|
6805
|
-
if (
|
|
6806
|
-
const D =
|
|
6802
|
+
I(!1);
|
|
6803
|
+
}, E = j(
|
|
6804
|
+
(f) => {
|
|
6805
|
+
if (P(f), s) {
|
|
6806
|
+
const D = f;
|
|
6807
6807
|
e == null || e(D);
|
|
6808
6808
|
return;
|
|
6809
6809
|
}
|
|
6810
|
-
const
|
|
6811
|
-
e == null || e(
|
|
6810
|
+
const O = f;
|
|
6811
|
+
e == null || e(O);
|
|
6812
6812
|
},
|
|
6813
6813
|
[s, e]
|
|
6814
6814
|
), F = j(() => {
|
|
6815
|
-
if (!
|
|
6815
|
+
if (!V) {
|
|
6816
6816
|
if (s) {
|
|
6817
|
-
|
|
6817
|
+
E([]);
|
|
6818
6818
|
return;
|
|
6819
6819
|
}
|
|
6820
|
-
|
|
6820
|
+
E("");
|
|
6821
6821
|
}
|
|
6822
|
-
}, [
|
|
6823
|
-
(
|
|
6824
|
-
const
|
|
6825
|
-
|
|
6822
|
+
}, [E, s, V]), G = j(
|
|
6823
|
+
(f) => {
|
|
6824
|
+
const O = b.filter((D) => D !== f);
|
|
6825
|
+
E(O), P(O);
|
|
6826
6826
|
},
|
|
6827
|
-
[
|
|
6827
|
+
[E, b]
|
|
6828
6828
|
), e1 = j(
|
|
6829
|
-
(
|
|
6829
|
+
(f) => (b == null ? void 0 : b.indexOf(f)) === 0 ? (
|
|
6830
6830
|
// if the search input is empty
|
|
6831
6831
|
// then display the placeholder, else do not display it
|
|
6832
|
-
/* @__PURE__ */ r("span", { className: "custom-placeholder", children:
|
|
6832
|
+
/* @__PURE__ */ r("span", { className: "custom-placeholder", children: A ? t : "" })
|
|
6833
6833
|
) : /* @__PURE__ */ r(X, {}),
|
|
6834
|
-
[
|
|
6835
|
-
), ie = (
|
|
6836
|
-
|
|
6837
|
-
}, se = async (
|
|
6838
|
-
const { target:
|
|
6839
|
-
|
|
6834
|
+
[A, b, t]
|
|
6835
|
+
), ie = (f) => {
|
|
6836
|
+
f.preventDefault(), f.stopPropagation();
|
|
6837
|
+
}, se = async (f) => {
|
|
6838
|
+
const { target: O } = f;
|
|
6839
|
+
O.scrollTop + O.offsetHeight >= O.scrollHeight - g && (C == null || C(!0)), p && await p(f);
|
|
6840
6840
|
}, m1 = j(
|
|
6841
|
-
(
|
|
6842
|
-
var
|
|
6843
|
-
return ((
|
|
6844
|
-
(k1) => k1.value ===
|
|
6845
|
-
)) == null ? void 0 : D.label) ||
|
|
6841
|
+
(f) => {
|
|
6842
|
+
var O, D;
|
|
6843
|
+
return ((O = l.find((k1) => k1.value === f)) == null ? void 0 : O.label) || ((D = R == null ? void 0 : R.find(
|
|
6844
|
+
(k1) => k1.value === f
|
|
6845
|
+
)) == null ? void 0 : D.label) || f;
|
|
6846
6846
|
},
|
|
6847
|
-
[
|
|
6847
|
+
[R, l]
|
|
6848
6848
|
), ne = j(
|
|
6849
|
-
(
|
|
6850
|
-
var
|
|
6849
|
+
(f) => {
|
|
6850
|
+
var O;
|
|
6851
6851
|
return /* @__PURE__ */ r(
|
|
6852
6852
|
_i,
|
|
6853
6853
|
{
|
|
6854
|
-
values:
|
|
6855
|
-
onTagClose:
|
|
6856
|
-
maxWidth: ((
|
|
6857
|
-
disabled: o ||
|
|
6854
|
+
values: f,
|
|
6855
|
+
onTagClose: G,
|
|
6856
|
+
maxWidth: ((O = Z.current) == null ? void 0 : O.clientWidth) || 0,
|
|
6857
|
+
disabled: o || V,
|
|
6858
6858
|
options: l,
|
|
6859
|
-
extraOptions:
|
|
6859
|
+
extraOptions: R
|
|
6860
6860
|
}
|
|
6861
6861
|
);
|
|
6862
6862
|
},
|
|
6863
|
-
[o,
|
|
6863
|
+
[o, R, G, l, V]
|
|
6864
6864
|
), re = j(
|
|
6865
|
-
({ label:
|
|
6866
|
-
[o, m1,
|
|
6865
|
+
({ label: f, value: O, mode: D }) => D === "filter" ? e1(O) : /* @__PURE__ */ r("div", { onMouseDown: ie, className: "tag-wrapper", children: /* @__PURE__ */ r(z1, { onClose: () => G(O), closable: !o, children: /* @__PURE__ */ r(J1, { variant: "body4", children: typeof f == "object" ? f : m1(O) }) }) }),
|
|
6866
|
+
[o, m1, G, e1]
|
|
6867
6867
|
);
|
|
6868
6868
|
return /* @__PURE__ */ u(
|
|
6869
6869
|
"div",
|
|
6870
6870
|
{
|
|
6871
|
-
className: `snmt-select ${
|
|
6872
|
-
${s ? "" : "snmt-select-single"} ${
|
|
6871
|
+
className: `snmt-select ${M ? "snmt-select-focused" : ""}
|
|
6872
|
+
${s ? "" : "snmt-select-single"} ${V ? "snmt-select-read-only" : ""}`,
|
|
6873
6873
|
ref: Z,
|
|
6874
6874
|
style: { width: c },
|
|
6875
6875
|
children: [
|
|
@@ -6877,58 +6877,58 @@ const z1 = ({ children: i, width: e, size: t = "small", onClose: s, closable: n
|
|
|
6877
6877
|
he,
|
|
6878
6878
|
{
|
|
6879
6879
|
className: "snmt-select-blank",
|
|
6880
|
-
popupClassName:
|
|
6881
|
-
id:
|
|
6882
|
-
ref:
|
|
6880
|
+
popupClassName: V ? "dropdown-read-only" : "",
|
|
6881
|
+
id: x,
|
|
6882
|
+
ref: w,
|
|
6883
6883
|
showSearch: !!n,
|
|
6884
6884
|
filterOption: n && $,
|
|
6885
|
-
onDropdownVisibleChange:
|
|
6885
|
+
onDropdownVisibleChange: H,
|
|
6886
6886
|
placeholder: t ? d ? `${t}*` : t : void 0,
|
|
6887
6887
|
disabled: o,
|
|
6888
|
-
value:
|
|
6889
|
-
labelRender: (
|
|
6888
|
+
value: b || void 0,
|
|
6889
|
+
labelRender: (f) => m1(f.value),
|
|
6890
6890
|
mode: s === "filter" ? "multiple" : s,
|
|
6891
|
-
onChange:
|
|
6891
|
+
onChange: E,
|
|
6892
6892
|
onFocus: Y,
|
|
6893
6893
|
onBlur: U,
|
|
6894
|
-
onSearch: (
|
|
6895
|
-
|
|
6894
|
+
onSearch: (f) => {
|
|
6895
|
+
S(!f), a && a(f);
|
|
6896
6896
|
},
|
|
6897
|
-
onSelect: () =>
|
|
6898
|
-
onDeselect: () =>
|
|
6899
|
-
tagRender: (
|
|
6897
|
+
onSelect: () => S(!0),
|
|
6898
|
+
onDeselect: () => S(!0),
|
|
6899
|
+
tagRender: (f) => re({ ...f, mode: s }),
|
|
6900
6900
|
maxTagCount: "responsive",
|
|
6901
6901
|
maxTagPlaceholder: ne,
|
|
6902
6902
|
onPopupScroll: se,
|
|
6903
|
-
prefix:
|
|
6903
|
+
prefix: V && !i && /* @__PURE__ */ r(y1, { size: 15 }),
|
|
6904
6904
|
suffixIcon: /* @__PURE__ */ r("div", { className: "wrapper-suffix-icon", children: s !== "filter" && /* @__PURE__ */ u(X, { children: [
|
|
6905
|
-
s &&
|
|
6905
|
+
s && b && !!b.length && /* @__PURE__ */ r("div", { onClick: F, children: /* @__PURE__ */ r(l1, { name: "cancel" }) }),
|
|
6906
6906
|
/* @__PURE__ */ r(
|
|
6907
6907
|
l1,
|
|
6908
6908
|
{
|
|
6909
6909
|
name: "selectArrowIcon",
|
|
6910
6910
|
color: o ? q.GREY_DARK_1 : q.GREY_DARK_5,
|
|
6911
6911
|
className: m ? "select-arrow-rotated" : "select-arrow",
|
|
6912
|
-
onClick: () =>
|
|
6912
|
+
onClick: () => N(!m)
|
|
6913
6913
|
}
|
|
6914
6914
|
)
|
|
6915
6915
|
] }) }),
|
|
6916
6916
|
removeIcon: /* @__PURE__ */ r(l1, { name: "errorSmall", color: q.GREY_DARK_2 }),
|
|
6917
6917
|
options: l,
|
|
6918
|
-
optionRender: (
|
|
6918
|
+
optionRender: (f) => _ ? _(f.data) : /* @__PURE__ */ u(c1, { justifyContent: "space-between", alignItems: "center", flex: "1", children: [
|
|
6919
6919
|
/* @__PURE__ */ u(c1, { alignItems: "center", gap: 12, children: [
|
|
6920
6920
|
s && /* @__PURE__ */ r(
|
|
6921
6921
|
fe,
|
|
6922
6922
|
{
|
|
6923
|
-
checked: !!(
|
|
6923
|
+
checked: !!(b != null && b.includes(f.value))
|
|
6924
6924
|
}
|
|
6925
6925
|
),
|
|
6926
6926
|
/* @__PURE__ */ u(c1, { alignItems: "center", gap: 8, children: [
|
|
6927
|
-
|
|
6928
|
-
/* @__PURE__ */ r("span", { children:
|
|
6927
|
+
f.data.image && /* @__PURE__ */ r(pe, { src: f.data.image, size: 20 }),
|
|
6928
|
+
/* @__PURE__ */ r("span", { children: f.label })
|
|
6929
6929
|
] })
|
|
6930
6930
|
] }),
|
|
6931
|
-
!s &&
|
|
6931
|
+
!s && b === f.value && /* @__PURE__ */ r(
|
|
6932
6932
|
l1,
|
|
6933
6933
|
{
|
|
6934
6934
|
name: "ok",
|
|
@@ -6948,13 +6948,13 @@ const z1 = ({ children: i, width: e, size: t = "small", onClose: s, closable: n
|
|
|
6948
6948
|
},
|
|
6949
6949
|
children: /* @__PURE__ */ r(y1, { size: 28 })
|
|
6950
6950
|
}
|
|
6951
|
-
) : (
|
|
6951
|
+
) : (f) => v ? v(f) : f
|
|
6952
6952
|
}
|
|
6953
6953
|
),
|
|
6954
6954
|
/* @__PURE__ */ r(
|
|
6955
6955
|
"fieldset",
|
|
6956
6956
|
{
|
|
6957
|
-
className: `${
|
|
6957
|
+
className: `${M ? "fieldset-focused" : ""}
|
|
6958
6958
|
${o ? "fieldset-disabled" : ""}
|
|
6959
6959
|
${typeof i == "string" && i ? "fieldset-filled" : ""}
|
|
6960
6960
|
${typeof i == "object" && i != null && i.length ? "fieldset-filled" : ""}`,
|
|
@@ -6996,67 +6996,67 @@ const a1 = {
|
|
|
6996
6996
|
onDropdownVisibleChange: h,
|
|
6997
6997
|
optionRender: C,
|
|
6998
6998
|
dropdownRender: p,
|
|
6999
|
-
readOnly:
|
|
7000
|
-
},
|
|
7001
|
-
const [
|
|
7002
|
-
async (
|
|
7003
|
-
if (!
|
|
6999
|
+
readOnly: x
|
|
7000
|
+
}, R) => {
|
|
7001
|
+
const [v, _] = B([]), [y, V] = B(a1), [w, m] = B(!1), [N, M] = B(null), I = j(
|
|
7002
|
+
async (H = !1, $) => {
|
|
7003
|
+
if (!w) {
|
|
7004
7004
|
m(!0);
|
|
7005
7005
|
try {
|
|
7006
|
-
const Y =
|
|
7007
|
-
|
|
7008
|
-
(
|
|
7009
|
-
),
|
|
7010
|
-
...
|
|
7011
|
-
offset:
|
|
7006
|
+
const Y = H ? { ...a1, search: $ } : y, U = await i(Y);
|
|
7007
|
+
_(
|
|
7008
|
+
(E) => H ? U.options : [...E, ...U.options]
|
|
7009
|
+
), M(U.count), V((E) => ({
|
|
7010
|
+
...E,
|
|
7011
|
+
offset: E.offset + E.limit
|
|
7012
7012
|
}));
|
|
7013
7013
|
} finally {
|
|
7014
7014
|
m(!1);
|
|
7015
7015
|
}
|
|
7016
7016
|
}
|
|
7017
7017
|
},
|
|
7018
|
-
[y, i,
|
|
7019
|
-
),
|
|
7020
|
-
(
|
|
7021
|
-
|
|
7018
|
+
[y, i, w]
|
|
7019
|
+
), A = Ii(I), S = j(
|
|
7020
|
+
(H) => {
|
|
7021
|
+
H === "" || H === void 0 || H === null ? (V(a1), A(!0)) : A(!0, H);
|
|
7022
7022
|
},
|
|
7023
|
-
[
|
|
7024
|
-
),
|
|
7025
|
-
|
|
7026
|
-
},
|
|
7027
|
-
(
|
|
7028
|
-
|
|
7023
|
+
[A]
|
|
7024
|
+
), b = async (H) => {
|
|
7025
|
+
H && N !== null && N > v.length && await I(!1);
|
|
7026
|
+
}, P = j(
|
|
7027
|
+
(H) => {
|
|
7028
|
+
H && !g && I(!1), h && h(H);
|
|
7029
7029
|
},
|
|
7030
7030
|
// eslint-disable-next-line
|
|
7031
7031
|
[g]
|
|
7032
7032
|
);
|
|
7033
7033
|
T(() => {
|
|
7034
|
-
g &&
|
|
7034
|
+
g && I(!1);
|
|
7035
7035
|
}, []);
|
|
7036
7036
|
const Z = {
|
|
7037
7037
|
id: n,
|
|
7038
7038
|
width: e,
|
|
7039
|
-
options:
|
|
7039
|
+
options: v,
|
|
7040
7040
|
onChange: t,
|
|
7041
|
-
ref:
|
|
7041
|
+
ref: R,
|
|
7042
7042
|
placeholder: o,
|
|
7043
7043
|
search: !0,
|
|
7044
7044
|
value: s,
|
|
7045
|
-
onSearchChange:
|
|
7046
|
-
onDropdownVisibleChange:
|
|
7045
|
+
onSearchChange: S,
|
|
7046
|
+
onDropdownVisibleChange: P,
|
|
7047
7047
|
scrollThresholdValue: c,
|
|
7048
|
-
onScrollToEnd:
|
|
7048
|
+
onScrollToEnd: b,
|
|
7049
7049
|
loadOnClosedState: g,
|
|
7050
7050
|
disabled: l,
|
|
7051
7051
|
extraOptions: a,
|
|
7052
|
-
isLoading:
|
|
7052
|
+
isLoading: w,
|
|
7053
7053
|
optionRender: C,
|
|
7054
7054
|
dropdownRender: p,
|
|
7055
|
-
readOnly:
|
|
7055
|
+
readOnly: x
|
|
7056
7056
|
};
|
|
7057
|
-
return ae(
|
|
7057
|
+
return ae(R, () => ({
|
|
7058
7058
|
refetchOptions: async () => {
|
|
7059
|
-
|
|
7059
|
+
V(a1), await I(!0);
|
|
7060
7060
|
}
|
|
7061
7061
|
})), d ? /* @__PURE__ */ r(b1, { ...Z, onChange: t, value: s, mode: d }) : /* @__PURE__ */ r("div", { className: "snmt-async-select", children: /* @__PURE__ */ r(b1, { ...Z, onChange: t, value: s }) });
|
|
7062
7062
|
}
|
|
@@ -7192,8 +7192,8 @@ const zi = (i, e) => {
|
|
|
7192
7192
|
} = o1(Yi) || {}, l = t || s || $i();
|
|
7193
7193
|
if (l && !l.reportNamespaces && (l.reportNamespaces = new Ui()), !l) {
|
|
7194
7194
|
N1("You will need to pass in an i18next instance by using initReactI18next");
|
|
7195
|
-
const
|
|
7196
|
-
return m.t =
|
|
7195
|
+
const w = (N, M) => z(M) ? M : Wi(M) && z(M.defaultValue) ? M.defaultValue : Array.isArray(N) ? N[N.length - 1] : N, m = [w, {}, !1];
|
|
7196
|
+
return m.t = w, m.i18n = {}, m.ready = !1, m;
|
|
7197
7197
|
}
|
|
7198
7198
|
l.options.react && l.options.react.wait !== void 0 && N1("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
|
|
7199
7199
|
const c = {
|
|
@@ -7206,33 +7206,33 @@ const zi = (i, e) => {
|
|
|
7206
7206
|
} = c;
|
|
7207
7207
|
let g = i;
|
|
7208
7208
|
g = z(g) ? [g] : g || ["translation"], l.reportNamespaces.addUsedNamespaces && l.reportNamespaces.addUsedNamespaces(g);
|
|
7209
|
-
const a = (l.isInitialized || l.initializedStoreOnce) && g.every((
|
|
7210
|
-
let
|
|
7211
|
-
e.lng && (
|
|
7212
|
-
const
|
|
7209
|
+
const a = (l.isInitialized || l.initializedStoreOnce) && g.every((w) => Bi(w, l, c)), h = Ji(l, e.lng || null, c.nsMode === "fallback" ? g : g[0], d), C = () => h, p = () => X1(l, e.lng || null, c.nsMode === "fallback" ? g : g[0], d), [x, R] = B(C);
|
|
7210
|
+
let v = g.join();
|
|
7211
|
+
e.lng && (v = `${e.lng}${v}`);
|
|
7212
|
+
const _ = zi(v), y = f1(!0);
|
|
7213
7213
|
T(() => {
|
|
7214
7214
|
const {
|
|
7215
|
-
bindI18n:
|
|
7215
|
+
bindI18n: w,
|
|
7216
7216
|
bindI18nStore: m
|
|
7217
7217
|
} = c;
|
|
7218
7218
|
y.current = !0, !a && !o && (e.lng ? _1(l, e.lng, g, () => {
|
|
7219
|
-
y.current &&
|
|
7219
|
+
y.current && R(p);
|
|
7220
7220
|
}) : H1(l, g, () => {
|
|
7221
|
-
y.current &&
|
|
7222
|
-
})), a &&
|
|
7223
|
-
const
|
|
7224
|
-
y.current &&
|
|
7221
|
+
y.current && R(p);
|
|
7222
|
+
})), a && _ && _ !== v && y.current && R(p);
|
|
7223
|
+
const N = () => {
|
|
7224
|
+
y.current && R(p);
|
|
7225
7225
|
};
|
|
7226
|
-
return
|
|
7227
|
-
y.current = !1,
|
|
7226
|
+
return w && l && l.on(w, N), m && l && l.store.on(m, N), () => {
|
|
7227
|
+
y.current = !1, w && l && w.split(" ").forEach((M) => l.off(M, N)), m && l && m.split(" ").forEach((M) => l.store.off(M, N));
|
|
7228
7228
|
};
|
|
7229
|
-
}, [l,
|
|
7230
|
-
y.current && a &&
|
|
7229
|
+
}, [l, v]), T(() => {
|
|
7230
|
+
y.current && a && R(C);
|
|
7231
7231
|
}, [l, d, a]);
|
|
7232
|
-
const
|
|
7233
|
-
if (
|
|
7234
|
-
throw new Promise((
|
|
7235
|
-
e.lng ? _1(l, e.lng, g, () =>
|
|
7232
|
+
const V = [x, l, a];
|
|
7233
|
+
if (V.t = x, V.i18n = l, V.ready = a, a || !a && !o) return V;
|
|
7234
|
+
throw new Promise((w) => {
|
|
7235
|
+
e.lng ? _1(l, e.lng, g, () => w()) : H1(l, g, () => w());
|
|
7236
7236
|
});
|
|
7237
7237
|
}, qi = {
|
|
7238
7238
|
type: "logger",
|
|
@@ -7291,7 +7291,7 @@ class g1 {
|
|
|
7291
7291
|
return e = e || this.options, e.prefix = e.prefix || this.prefix, new g1(this.logger, e);
|
|
7292
7292
|
}
|
|
7293
7293
|
}
|
|
7294
|
-
var
|
|
7294
|
+
var K = new g1();
|
|
7295
7295
|
class w1 {
|
|
7296
7296
|
constructor() {
|
|
7297
7297
|
this.observers = {};
|
|
@@ -7525,7 +7525,7 @@ const W1 = {};
|
|
|
7525
7525
|
class p1 extends w1 {
|
|
7526
7526
|
constructor(e) {
|
|
7527
7527
|
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
7528
|
-
super(), Xi(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger =
|
|
7528
|
+
super(), Xi(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = K.create("translator");
|
|
7529
7529
|
}
|
|
7530
7530
|
changeLanguage(e) {
|
|
7531
7531
|
e && (this.language = e);
|
|
@@ -7571,15 +7571,15 @@ class p1 extends w1 {
|
|
|
7571
7571
|
} = this.extractFromKey(e[e.length - 1], t), d = o[o.length - 1], g = t.lng || this.language, a = t.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
7572
7572
|
if (g && g.toLowerCase() === "cimode") {
|
|
7573
7573
|
if (a) {
|
|
7574
|
-
const
|
|
7574
|
+
const w = t.nsSeparator || this.options.nsSeparator;
|
|
7575
7575
|
return n ? {
|
|
7576
|
-
res: `${d}${
|
|
7576
|
+
res: `${d}${w}${c}`,
|
|
7577
7577
|
usedKey: c,
|
|
7578
7578
|
exactUsedKey: c,
|
|
7579
7579
|
usedLng: g,
|
|
7580
7580
|
usedNS: d,
|
|
7581
7581
|
usedParams: this.getUsedParamsDetails(t)
|
|
7582
|
-
} : `${d}${
|
|
7582
|
+
} : `${d}${w}${c}`;
|
|
7583
7583
|
}
|
|
7584
7584
|
return n ? {
|
|
7585
7585
|
res: c,
|
|
@@ -7592,64 +7592,64 @@ class p1 extends w1 {
|
|
|
7592
7592
|
}
|
|
7593
7593
|
const h = this.resolve(e, t);
|
|
7594
7594
|
let C = h && h.res;
|
|
7595
|
-
const p = h && h.usedKey || c,
|
|
7596
|
-
if (y && C && (typeof C != "string" && typeof C != "boolean" && typeof C != "number") &&
|
|
7595
|
+
const p = h && h.usedKey || c, x = h && h.exactUsedKey || c, R = Object.prototype.toString.apply(C), v = ["[object Number]", "[object Function]", "[object RegExp]"], _ = t.joinArrays !== void 0 ? t.joinArrays : this.options.joinArrays, y = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
7596
|
+
if (y && C && (typeof C != "string" && typeof C != "boolean" && typeof C != "number") && v.indexOf(R) < 0 && !(typeof _ == "string" && Array.isArray(C))) {
|
|
7597
7597
|
if (!t.returnObjects && !this.options.returnObjects) {
|
|
7598
7598
|
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
7599
|
-
const
|
|
7599
|
+
const w = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(p, C, {
|
|
7600
7600
|
...t,
|
|
7601
7601
|
ns: o
|
|
7602
7602
|
}) : `key '${c} (${this.language})' returned an object instead of string.`;
|
|
7603
|
-
return n ? (h.res =
|
|
7603
|
+
return n ? (h.res = w, h.usedParams = this.getUsedParamsDetails(t), h) : w;
|
|
7604
7604
|
}
|
|
7605
7605
|
if (l) {
|
|
7606
|
-
const
|
|
7607
|
-
for (const
|
|
7608
|
-
if (Object.prototype.hasOwnProperty.call(C,
|
|
7609
|
-
const
|
|
7610
|
-
m[
|
|
7606
|
+
const w = Array.isArray(C), m = w ? [] : {}, N = w ? x : p;
|
|
7607
|
+
for (const M in C)
|
|
7608
|
+
if (Object.prototype.hasOwnProperty.call(C, M)) {
|
|
7609
|
+
const I = `${N}${l}${M}`;
|
|
7610
|
+
m[M] = this.translate(I, {
|
|
7611
7611
|
...t,
|
|
7612
7612
|
joinArrays: !1,
|
|
7613
7613
|
ns: o
|
|
7614
|
-
}), m[
|
|
7614
|
+
}), m[M] === I && (m[M] = C[M]);
|
|
7615
7615
|
}
|
|
7616
7616
|
C = m;
|
|
7617
7617
|
}
|
|
7618
|
-
} else if (y && typeof
|
|
7619
|
-
C = C.join(
|
|
7618
|
+
} else if (y && typeof _ == "string" && Array.isArray(C))
|
|
7619
|
+
C = C.join(_), C && (C = this.extendTranslation(C, e, t, s));
|
|
7620
7620
|
else {
|
|
7621
|
-
let
|
|
7622
|
-
const
|
|
7621
|
+
let w = !1, m = !1;
|
|
7622
|
+
const N = t.count !== void 0 && typeof t.count != "string", M = p1.hasDefaultValue(t), I = N ? this.pluralResolver.getSuffix(g, t.count, t) : "", A = t.ordinal && N ? this.pluralResolver.getSuffix(g, t.count, {
|
|
7623
7623
|
ordinal: !1
|
|
7624
|
-
}) : "",
|
|
7625
|
-
!this.isValidLookup(C) &&
|
|
7626
|
-
const Z = (t.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && m ? void 0 : C,
|
|
7627
|
-
if (m ||
|
|
7628
|
-
if (this.logger.log(
|
|
7629
|
-
const
|
|
7624
|
+
}) : "", S = N && !t.ordinal && t.count === 0 && this.pluralResolver.shouldUseIntlApi(), b = S && t[`defaultValue${this.options.pluralSeparator}zero`] || t[`defaultValue${I}`] || t[`defaultValue${A}`] || t.defaultValue;
|
|
7625
|
+
!this.isValidLookup(C) && M && (w = !0, C = b), this.isValidLookup(C) || (m = !0, C = c);
|
|
7626
|
+
const Z = (t.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && m ? void 0 : C, H = M && b !== C && this.options.updateMissing;
|
|
7627
|
+
if (m || w || H) {
|
|
7628
|
+
if (this.logger.log(H ? "updateKey" : "missingKey", g, d, c, H ? b : C), l) {
|
|
7629
|
+
const E = this.resolve(c, {
|
|
7630
7630
|
...t,
|
|
7631
7631
|
keySeparator: !1
|
|
7632
7632
|
});
|
|
7633
|
-
|
|
7633
|
+
E && E.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
|
|
7634
7634
|
}
|
|
7635
7635
|
let $ = [];
|
|
7636
7636
|
const Y = this.languageUtils.getFallbackCodes(this.options.fallbackLng, t.lng || this.language);
|
|
7637
7637
|
if (this.options.saveMissingTo === "fallback" && Y && Y[0])
|
|
7638
|
-
for (let
|
|
7639
|
-
$.push(Y[
|
|
7638
|
+
for (let E = 0; E < Y.length; E++)
|
|
7639
|
+
$.push(Y[E]);
|
|
7640
7640
|
else this.options.saveMissingTo === "all" ? $ = this.languageUtils.toResolveHierarchy(t.lng || this.language) : $.push(t.lng || this.language);
|
|
7641
|
-
const U = (
|
|
7642
|
-
const e1 =
|
|
7643
|
-
this.options.missingKeyHandler ? this.options.missingKeyHandler(
|
|
7641
|
+
const U = (E, F, G) => {
|
|
7642
|
+
const e1 = M && G !== C ? G : Z;
|
|
7643
|
+
this.options.missingKeyHandler ? this.options.missingKeyHandler(E, d, F, e1, H, t) : this.backendConnector && this.backendConnector.saveMissing && this.backendConnector.saveMissing(E, d, F, e1, H, t), this.emit("missingKey", E, d, F, C);
|
|
7644
7644
|
};
|
|
7645
|
-
this.options.saveMissing && (this.options.saveMissingPlurals &&
|
|
7646
|
-
const F = this.pluralResolver.getSuffixes(
|
|
7647
|
-
|
|
7648
|
-
U([
|
|
7645
|
+
this.options.saveMissing && (this.options.saveMissingPlurals && N ? $.forEach((E) => {
|
|
7646
|
+
const F = this.pluralResolver.getSuffixes(E, t);
|
|
7647
|
+
S && t[`defaultValue${this.options.pluralSeparator}zero`] && F.indexOf(`${this.options.pluralSeparator}zero`) < 0 && F.push(`${this.options.pluralSeparator}zero`), F.forEach((G) => {
|
|
7648
|
+
U([E], c + G, t[`defaultValue${G}`] || b);
|
|
7649
7649
|
});
|
|
7650
|
-
}) : U($, c,
|
|
7650
|
+
}) : U($, c, b));
|
|
7651
7651
|
}
|
|
7652
|
-
C = this.extendTranslation(C, e, t, h, s), m && C === c && this.options.appendNamespaceToMissingKey && (C = `${d}:${c}`), (m ||
|
|
7652
|
+
C = this.extendTranslation(C, e, t, h, s), m && C === c && this.options.appendNamespaceToMissingKey && (C = `${d}:${c}`), (m || w) && this.options.parseMissingKeyHandler && (this.options.compatibilityAPI !== "v1" ? C = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${d}:${c}` : c, w ? C : void 0) : C = this.options.parseMissingKeyHandler(C));
|
|
7653
7653
|
}
|
|
7654
7654
|
return n ? (h.res = C, h.usedParams = this.getUsedParamsDetails(t), h) : C;
|
|
7655
7655
|
}
|
|
@@ -7685,8 +7685,8 @@ class p1 extends w1 {
|
|
|
7685
7685
|
a < p && (s.nest = !1);
|
|
7686
7686
|
}
|
|
7687
7687
|
!s.lng && this.options.compatibilityAPI !== "v1" && n && n.res && (s.lng = this.language || n.usedLng), s.nest !== !1 && (e = this.interpolator.nest(e, function() {
|
|
7688
|
-
for (var C = arguments.length, p = new Array(C),
|
|
7689
|
-
p[
|
|
7688
|
+
for (var C = arguments.length, p = new Array(C), x = 0; x < C; x++)
|
|
7689
|
+
p[x] = arguments[x];
|
|
7690
7690
|
return l && l[0] === p[0] && !s.context ? (c.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${t[0]}`), null) : c.translate(...p, t);
|
|
7691
7691
|
}, s)), s.interpolation && this.interpolator.reset();
|
|
7692
7692
|
}
|
|
@@ -7707,26 +7707,26 @@ class p1 extends w1 {
|
|
|
7707
7707
|
n = a;
|
|
7708
7708
|
let h = g.namespaces;
|
|
7709
7709
|
this.options.fallbackNS && (h = h.concat(this.options.fallbackNS));
|
|
7710
|
-
const C = t.count !== void 0 && typeof t.count != "string", p = C && !t.ordinal && t.count === 0 && this.pluralResolver.shouldUseIntlApi(),
|
|
7711
|
-
h.forEach((
|
|
7712
|
-
this.isValidLookup(s) || (o =
|
|
7710
|
+
const C = t.count !== void 0 && typeof t.count != "string", p = C && !t.ordinal && t.count === 0 && this.pluralResolver.shouldUseIntlApi(), x = t.context !== void 0 && (typeof t.context == "string" || typeof t.context == "number") && t.context !== "", R = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
|
|
7711
|
+
h.forEach((v) => {
|
|
7712
|
+
this.isValidLookup(s) || (o = v, !W1[`${R[0]}-${v}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(o) && (W1[`${R[0]}-${v}`] = !0, this.logger.warn(`key "${n}" for languages "${R.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), R.forEach((_) => {
|
|
7713
7713
|
if (this.isValidLookup(s)) return;
|
|
7714
|
-
c =
|
|
7714
|
+
c = _;
|
|
7715
7715
|
const y = [a];
|
|
7716
7716
|
if (this.i18nFormat && this.i18nFormat.addLookupKeys)
|
|
7717
|
-
this.i18nFormat.addLookupKeys(y, a,
|
|
7717
|
+
this.i18nFormat.addLookupKeys(y, a, _, v, t);
|
|
7718
7718
|
else {
|
|
7719
|
-
let
|
|
7720
|
-
C && (
|
|
7721
|
-
const m = `${this.options.pluralSeparator}zero`,
|
|
7722
|
-
if (C && (y.push(a +
|
|
7723
|
-
const
|
|
7724
|
-
y.push(
|
|
7719
|
+
let w;
|
|
7720
|
+
C && (w = this.pluralResolver.getSuffix(_, t.count, t));
|
|
7721
|
+
const m = `${this.options.pluralSeparator}zero`, N = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
7722
|
+
if (C && (y.push(a + w), t.ordinal && w.indexOf(N) === 0 && y.push(a + w.replace(N, this.options.pluralSeparator)), p && y.push(a + m)), x) {
|
|
7723
|
+
const M = `${a}${this.options.contextSeparator}${t.context}`;
|
|
7724
|
+
y.push(M), C && (y.push(M + w), t.ordinal && w.indexOf(N) === 0 && y.push(M + w.replace(N, this.options.pluralSeparator)), p && y.push(M + m));
|
|
7725
7725
|
}
|
|
7726
7726
|
}
|
|
7727
|
-
let
|
|
7728
|
-
for (;
|
|
7729
|
-
this.isValidLookup(s) || (l =
|
|
7727
|
+
let V;
|
|
7728
|
+
for (; V = y.pop(); )
|
|
7729
|
+
this.isValidLookup(s) || (l = V, s = this.getResource(_, v, V, t));
|
|
7730
7730
|
}));
|
|
7731
7731
|
});
|
|
7732
7732
|
}), {
|
|
@@ -7771,7 +7771,7 @@ class p1 extends w1 {
|
|
|
7771
7771
|
const L1 = (i) => i.charAt(0).toUpperCase() + i.slice(1);
|
|
7772
7772
|
class j1 {
|
|
7773
7773
|
constructor(e) {
|
|
7774
|
-
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger =
|
|
7774
|
+
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = K.create("languageUtils");
|
|
7775
7775
|
}
|
|
7776
7776
|
getScriptPartFromCode(e) {
|
|
7777
7777
|
if (e = C1(e), !e || e.indexOf("-") < 0) return null;
|
|
@@ -7965,7 +7965,7 @@ const d5 = ["v1", "v2", "v3"], g5 = ["v4"], Z1 = {
|
|
|
7965
7965
|
class C5 {
|
|
7966
7966
|
constructor(e) {
|
|
7967
7967
|
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
7968
|
-
this.languageUtils = e, this.options = t, this.logger =
|
|
7968
|
+
this.languageUtils = e, this.options = t, this.logger = K.create("pluralResolver"), (!this.options.compatibilityJSON || g5.includes(this.options.compatibilityJSON)) && (typeof Intl > "u" || !Intl.PluralRules) && (this.options.compatibilityJSON = "v3", this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")), this.rules = u5(), this.pluralRulesCache = {};
|
|
7969
7969
|
}
|
|
7970
7970
|
addRule(e, t) {
|
|
7971
7971
|
this.rules[e] = t;
|
|
@@ -8029,7 +8029,7 @@ const D1 = function(i, e, t) {
|
|
|
8029
8029
|
class p5 {
|
|
8030
8030
|
constructor() {
|
|
8031
8031
|
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
8032
|
-
this.logger =
|
|
8032
|
+
this.logger = K.create("interpolator"), this.options = e, this.format = e.interpolation && e.interpolation.format || ((t) => t), this.init(e);
|
|
8033
8033
|
}
|
|
8034
8034
|
init() {
|
|
8035
8035
|
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
@@ -8049,13 +8049,13 @@ class p5 {
|
|
|
8049
8049
|
unescapePrefix: h,
|
|
8050
8050
|
nestingPrefix: C,
|
|
8051
8051
|
nestingPrefixEscaped: p,
|
|
8052
|
-
nestingSuffix:
|
|
8053
|
-
nestingSuffixEscaped:
|
|
8054
|
-
nestingOptionsSeparator:
|
|
8055
|
-
maxReplaces:
|
|
8052
|
+
nestingSuffix: x,
|
|
8053
|
+
nestingSuffixEscaped: R,
|
|
8054
|
+
nestingOptionsSeparator: v,
|
|
8055
|
+
maxReplaces: _,
|
|
8056
8056
|
alwaysFormat: y
|
|
8057
8057
|
} = e.interpolation;
|
|
8058
|
-
this.escape = t !== void 0 ? t : n5, this.escapeValue = s !== void 0 ? s : !0, this.useRawValueToEscape = n !== void 0 ? n : !1, this.prefix = l ? J(l) : c || "{{", this.suffix = o ? J(o) : d || "}}", this.formatSeparator = g || ",", this.unescapePrefix = a ? "" : h || "-", this.unescapeSuffix = this.unescapePrefix ? "" : a || "", this.nestingPrefix = C ? J(C) : p || J("$t("), this.nestingSuffix =
|
|
8058
|
+
this.escape = t !== void 0 ? t : n5, this.escapeValue = s !== void 0 ? s : !0, this.useRawValueToEscape = n !== void 0 ? n : !1, this.prefix = l ? J(l) : c || "{{", this.suffix = o ? J(o) : d || "}}", this.formatSeparator = g || ",", this.unescapePrefix = a ? "" : h || "-", this.unescapeSuffix = this.unescapePrefix ? "" : a || "", this.nestingPrefix = C ? J(C) : p || J("$t("), this.nestingSuffix = x ? J(x) : R || J(")"), this.nestingOptionsSeparator = v || ",", this.maxReplaces = _ || 1e3, this.alwaysFormat = y !== void 0 ? y : !1, this.resetRegExp();
|
|
8059
8059
|
}
|
|
8060
8060
|
reset() {
|
|
8061
8061
|
this.options && this.init(this.options);
|
|
@@ -8068,18 +8068,18 @@ class p5 {
|
|
|
8068
8068
|
let l, c, o;
|
|
8069
8069
|
const d = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, g = (p) => {
|
|
8070
8070
|
if (p.indexOf(this.formatSeparator) < 0) {
|
|
8071
|
-
const
|
|
8072
|
-
return this.alwaysFormat ? this.format(
|
|
8071
|
+
const _ = D1(t, d, p, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
8072
|
+
return this.alwaysFormat ? this.format(_, void 0, s, {
|
|
8073
8073
|
...n,
|
|
8074
8074
|
...t,
|
|
8075
8075
|
interpolationkey: p
|
|
8076
|
-
}) :
|
|
8076
|
+
}) : _;
|
|
8077
8077
|
}
|
|
8078
|
-
const
|
|
8079
|
-
return this.format(D1(t, d,
|
|
8078
|
+
const x = p.split(this.formatSeparator), R = x.shift().trim(), v = x.join(this.formatSeparator).trim();
|
|
8079
|
+
return this.format(D1(t, d, R, this.options.keySeparator, this.options.ignoreJSONStructure), v, s, {
|
|
8080
8080
|
...n,
|
|
8081
8081
|
...t,
|
|
8082
|
-
interpolationkey:
|
|
8082
|
+
interpolationkey: R
|
|
8083
8083
|
});
|
|
8084
8084
|
};
|
|
8085
8085
|
this.resetRegExp();
|
|
@@ -8092,21 +8092,21 @@ class p5 {
|
|
|
8092
8092
|
safeValue: (p) => this.escapeValue ? v1(this.escape(p)) : v1(p)
|
|
8093
8093
|
}].forEach((p) => {
|
|
8094
8094
|
for (o = 0; l = p.regex.exec(e); ) {
|
|
8095
|
-
const
|
|
8096
|
-
if (c = g(
|
|
8095
|
+
const x = l[1].trim();
|
|
8096
|
+
if (c = g(x), c === void 0)
|
|
8097
8097
|
if (typeof a == "function") {
|
|
8098
|
-
const
|
|
8099
|
-
c = typeof
|
|
8100
|
-
} else if (n && Object.prototype.hasOwnProperty.call(n,
|
|
8098
|
+
const v = a(e, l, n);
|
|
8099
|
+
c = typeof v == "string" ? v : "";
|
|
8100
|
+
} else if (n && Object.prototype.hasOwnProperty.call(n, x))
|
|
8101
8101
|
c = "";
|
|
8102
8102
|
else if (h) {
|
|
8103
8103
|
c = l[0];
|
|
8104
8104
|
continue;
|
|
8105
8105
|
} else
|
|
8106
|
-
this.logger.warn(`missed to pass in variable ${
|
|
8106
|
+
this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`), c = "";
|
|
8107
8107
|
else typeof c != "string" && !this.useRawValueToEscape && (c = I1(c));
|
|
8108
|
-
const
|
|
8109
|
-
if (e = e.replace(l[0],
|
|
8108
|
+
const R = p.safeValue(c);
|
|
8109
|
+
if (e = e.replace(l[0], R), h ? (p.regex.lastIndex += c.length, p.regex.lastIndex -= l[0].length) : p.regex.lastIndex = 0, o++, o >= this.maxReplaces)
|
|
8110
8110
|
break;
|
|
8111
8111
|
}
|
|
8112
8112
|
}), e;
|
|
@@ -8119,15 +8119,15 @@ class p5 {
|
|
|
8119
8119
|
const h = d.split(new RegExp(`${a}[ ]*{`));
|
|
8120
8120
|
let C = `{${h[1]}`;
|
|
8121
8121
|
d = h[0], C = this.interpolate(C, c);
|
|
8122
|
-
const p = C.match(/'/g),
|
|
8123
|
-
(p && p.length % 2 === 0 && !
|
|
8122
|
+
const p = C.match(/'/g), x = C.match(/"/g);
|
|
8123
|
+
(p && p.length % 2 === 0 && !x || x.length % 2 !== 0) && (C = C.replace(/'/g, '"'));
|
|
8124
8124
|
try {
|
|
8125
8125
|
c = JSON.parse(C), g && (c = {
|
|
8126
8126
|
...g,
|
|
8127
8127
|
...c
|
|
8128
8128
|
});
|
|
8129
|
-
} catch (
|
|
8130
|
-
return this.logger.warn(`failed parsing options string in nesting for key ${d}`,
|
|
8129
|
+
} catch (R) {
|
|
8130
|
+
return this.logger.warn(`failed parsing options string in nesting for key ${d}`, R), `${d}${a}${C}`;
|
|
8131
8131
|
}
|
|
8132
8132
|
return c.defaultValue && c.defaultValue.indexOf(this.prefix) > -1 && delete c.defaultValue, d;
|
|
8133
8133
|
};
|
|
@@ -8184,7 +8184,7 @@ const f5 = (i) => {
|
|
|
8184
8184
|
class w5 {
|
|
8185
8185
|
constructor() {
|
|
8186
8186
|
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
8187
|
-
this.logger =
|
|
8187
|
+
this.logger = K.create("formatter"), this.options = e, this.formats = {
|
|
8188
8188
|
number: Q((t, s) => {
|
|
8189
8189
|
const n = new Intl.NumberFormat(t, {
|
|
8190
8190
|
...s
|
|
@@ -8267,7 +8267,7 @@ const m5 = (i, e) => {
|
|
|
8267
8267
|
class k5 extends w1 {
|
|
8268
8268
|
constructor(e, t, s) {
|
|
8269
8269
|
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
8270
|
-
super(), this.backend = e, this.store = t, this.services = s, this.languageUtils = s.languageUtils, this.options = n, this.logger =
|
|
8270
|
+
super(), this.backend = e, this.store = t, this.services = s, this.languageUtils = s.languageUtils, this.options = n, this.logger = K.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = n.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = n.maxRetries >= 0 ? n.maxRetries : 5, this.retryTimeout = n.retryTimeout >= 1 ? n.retryTimeout : 350, this.state = {}, this.queue = [], this.backend && this.backend.init && this.backend.init(s, n.backend, n);
|
|
8271
8271
|
}
|
|
8272
8272
|
queueLoad(e, t, s, n) {
|
|
8273
8273
|
const l = {}, c = {}, o = {}, d = {};
|
|
@@ -8464,7 +8464,7 @@ const T1 = () => ({
|
|
|
8464
8464
|
class s1 extends w1 {
|
|
8465
8465
|
constructor() {
|
|
8466
8466
|
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
|
|
8467
|
-
if (super(), this.options = G1(e), this.services = {}, this.logger =
|
|
8467
|
+
if (super(), this.options = G1(e), this.services = {}, this.logger = K, this.modules = {
|
|
8468
8468
|
external: []
|
|
8469
8469
|
}, L5(this), t && !this.isInitialized && !e.isClone) {
|
|
8470
8470
|
if (!this.options.initImmediate)
|
|
@@ -8489,26 +8489,26 @@ class s1 extends w1 {
|
|
|
8489
8489
|
}), t.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = t.keySeparator), t.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = t.nsSeparator);
|
|
8490
8490
|
const l = (a) => a ? typeof a == "function" ? new a() : a : null;
|
|
8491
8491
|
if (!this.options.isClone) {
|
|
8492
|
-
this.modules.logger ?
|
|
8492
|
+
this.modules.logger ? K.init(l(this.modules.logger), this.options) : K.init(null, this.options);
|
|
8493
8493
|
let a;
|
|
8494
8494
|
this.modules.formatter ? a = this.modules.formatter : typeof Intl < "u" && (a = w5);
|
|
8495
8495
|
const h = new j1(this.options);
|
|
8496
8496
|
this.store = new B1(this.options.resources, this.options);
|
|
8497
8497
|
const C = this.services;
|
|
8498
|
-
C.logger =
|
|
8498
|
+
C.logger = K, C.resourceStore = this.store, C.languageUtils = h, C.pluralResolver = new C5(h, {
|
|
8499
8499
|
prepend: this.options.pluralSeparator,
|
|
8500
8500
|
compatibilityJSON: this.options.compatibilityJSON,
|
|
8501
8501
|
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
8502
8502
|
}), a && (!this.options.interpolation.format || this.options.interpolation.format === n.interpolation.format) && (C.formatter = l(a), C.formatter.init(C, this.options), this.options.interpolation.format = C.formatter.format.bind(C.formatter)), C.interpolator = new p5(this.options), C.utils = {
|
|
8503
8503
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
8504
8504
|
}, C.backendConnector = new k5(l(this.modules.backend), C.resourceStore, C, this.options), C.backendConnector.on("*", function(p) {
|
|
8505
|
-
for (var
|
|
8506
|
-
|
|
8507
|
-
e.emit(p, ...
|
|
8505
|
+
for (var x = arguments.length, R = new Array(x > 1 ? x - 1 : 0), v = 1; v < x; v++)
|
|
8506
|
+
R[v - 1] = arguments[v];
|
|
8507
|
+
e.emit(p, ...R);
|
|
8508
8508
|
}), this.modules.languageDetector && (C.languageDetector = l(this.modules.languageDetector), C.languageDetector.init && C.languageDetector.init(C, this.options.detection, this.options)), this.modules.i18nFormat && (C.i18nFormat = l(this.modules.i18nFormat), C.i18nFormat.init && C.i18nFormat.init(this)), this.translator = new p1(this.services, this.options), this.translator.on("*", function(p) {
|
|
8509
|
-
for (var
|
|
8510
|
-
|
|
8511
|
-
e.emit(p, ...
|
|
8509
|
+
for (var x = arguments.length, R = new Array(x > 1 ? x - 1 : 0), v = 1; v < x; v++)
|
|
8510
|
+
R[v - 1] = arguments[v];
|
|
8511
|
+
e.emit(p, ...R);
|
|
8512
8512
|
}), this.modules.external.forEach((p) => {
|
|
8513
8513
|
p.init && p.init(this);
|
|
8514
8514
|
});
|
|
@@ -8610,7 +8610,7 @@ class s1 extends w1 {
|
|
|
8610
8610
|
d.lng = d.lng || l.lng, d.lngs = d.lngs || l.lngs, d.ns = d.ns || l.ns, d.keyPrefix !== "" && (d.keyPrefix = d.keyPrefix || s || l.keyPrefix);
|
|
8611
8611
|
const C = n.options.keySeparator || ".";
|
|
8612
8612
|
let p;
|
|
8613
|
-
return d.keyPrefix && Array.isArray(c) ? p = c.map((
|
|
8613
|
+
return d.keyPrefix && Array.isArray(c) ? p = c.map((x) => `${d.keyPrefix}${C}${x}`) : p = d.keyPrefix ? `${d.keyPrefix}${C}${c}` : c, n.t(p, d);
|
|
8614
8614
|
};
|
|
8615
8615
|
return typeof e == "string" ? l.lng = e : l.lngs = e, l.ns = t, l.keyPrefix = s, l;
|
|
8616
8616
|
}
|
|
@@ -8699,22 +8699,22 @@ class s1 extends w1 {
|
|
|
8699
8699
|
};
|
|
8700
8700
|
}
|
|
8701
8701
|
}
|
|
8702
|
-
const
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8702
|
+
const W = s1.createInstance();
|
|
8703
|
+
W.createInstance = s1.createInstance;
|
|
8704
|
+
W.createInstance;
|
|
8705
|
+
W.dir;
|
|
8706
|
+
W.init;
|
|
8707
|
+
W.loadResources;
|
|
8708
|
+
W.reloadResources;
|
|
8709
|
+
W.use;
|
|
8710
|
+
W.changeLanguage;
|
|
8711
|
+
W.getFixedT;
|
|
8712
|
+
W.t;
|
|
8713
|
+
W.exists;
|
|
8714
|
+
W.setDefaultNamespace;
|
|
8715
|
+
W.hasLoadedNamespace;
|
|
8716
|
+
W.loadNamespaces;
|
|
8717
|
+
W.loadLanguages;
|
|
8718
8718
|
const v5 = "Archived", N5 = "Deleted", x5 = {
|
|
8719
8719
|
archived: v5,
|
|
8720
8720
|
deleted: N5
|
|
@@ -8722,7 +8722,7 @@ const v5 = "Archived", N5 = "Deleted", x5 = {
|
|
|
8722
8722
|
archived: R5,
|
|
8723
8723
|
deleted: M5
|
|
8724
8724
|
};
|
|
8725
|
-
|
|
8725
|
+
W.use(Fi).init({
|
|
8726
8726
|
defaultNS: "common",
|
|
8727
8727
|
lng: "en",
|
|
8728
8728
|
resources: {
|
|
@@ -8735,141 +8735,151 @@ B.use(Fi).init({
|
|
|
8735
8735
|
}
|
|
8736
8736
|
});
|
|
8737
8737
|
const O5 = r1(
|
|
8738
|
-
({
|
|
8739
|
-
|
|
8740
|
-
|
|
8738
|
+
({
|
|
8739
|
+
fetchParams: i,
|
|
8740
|
+
mode: e = void 0,
|
|
8741
|
+
placeholder: t,
|
|
8742
|
+
disabled: s,
|
|
8743
|
+
value: n,
|
|
8744
|
+
onChange: l,
|
|
8745
|
+
onError: c,
|
|
8746
|
+
allowEmpty: o = !1
|
|
8747
|
+
}, d) => {
|
|
8748
|
+
const { axiosPeople: g, locale: a } = o1(Ce), { t: h } = Qi("common", { lng: a }), [C, p] = B([]), [x, R] = B(!0);
|
|
8749
|
+
if (!g)
|
|
8741
8750
|
throw new Error(
|
|
8742
8751
|
`UserSelect requires "axiosPeople" to fetch users.
|
|
8743
8752
|
Please provide it via SNMTUiContext.`
|
|
8744
8753
|
);
|
|
8745
|
-
const
|
|
8746
|
-
(
|
|
8747
|
-
let
|
|
8748
|
-
return
|
|
8754
|
+
const v = j(
|
|
8755
|
+
(m) => {
|
|
8756
|
+
let N = "";
|
|
8757
|
+
return m.deletedAt && (N += `[${h("deleted")}] `), m.status === d1.ARCHIVED && (N += `[${h("archived")}] `), `${N}${m.firstName} ${m.lastName}`;
|
|
8749
8758
|
},
|
|
8750
|
-
[
|
|
8751
|
-
),
|
|
8759
|
+
[h]
|
|
8760
|
+
), _ = j(
|
|
8752
8761
|
async ({
|
|
8753
|
-
offset:
|
|
8754
|
-
limit:
|
|
8762
|
+
offset: m,
|
|
8763
|
+
limit: N,
|
|
8755
8764
|
search: M
|
|
8756
8765
|
}) => {
|
|
8757
|
-
var
|
|
8766
|
+
var I, A, S;
|
|
8758
8767
|
try {
|
|
8759
|
-
const
|
|
8760
|
-
offset:
|
|
8761
|
-
limit:
|
|
8768
|
+
const b = await g.post("v1/users/search", {
|
|
8769
|
+
offset: m,
|
|
8770
|
+
limit: N,
|
|
8762
8771
|
search: M,
|
|
8763
8772
|
...i,
|
|
8764
8773
|
includeCount: !0
|
|
8765
|
-
}), { data:
|
|
8774
|
+
}), { data: P, metadata: Z } = b.data;
|
|
8766
8775
|
return {
|
|
8767
|
-
options:
|
|
8768
|
-
value:
|
|
8769
|
-
label:
|
|
8776
|
+
options: P.map((H) => ({
|
|
8777
|
+
value: H.id,
|
|
8778
|
+
label: v(H)
|
|
8770
8779
|
})),
|
|
8771
|
-
count:
|
|
8780
|
+
count: Z.count
|
|
8772
8781
|
};
|
|
8773
|
-
} catch (
|
|
8782
|
+
} catch (b) {
|
|
8774
8783
|
return c && c({
|
|
8775
|
-
status: ((
|
|
8776
|
-
message: ((
|
|
8784
|
+
status: ((I = b.response) == null ? void 0 : I.status) ?? 500,
|
|
8785
|
+
message: ((S = (A = b.response) == null ? void 0 : A.data) == null ? void 0 : S.message) ?? "Error while fetching options"
|
|
8777
8786
|
}), {
|
|
8778
8787
|
options: [],
|
|
8779
8788
|
count: 0
|
|
8780
8789
|
};
|
|
8781
8790
|
}
|
|
8782
8791
|
},
|
|
8783
|
-
[
|
|
8784
|
-
),
|
|
8785
|
-
async (
|
|
8786
|
-
var
|
|
8792
|
+
[g, i, c, v]
|
|
8793
|
+
), y = j(
|
|
8794
|
+
async (m) => {
|
|
8795
|
+
var N, M, I;
|
|
8787
8796
|
try {
|
|
8788
8797
|
return await Promise.all(
|
|
8789
|
-
|
|
8790
|
-
const
|
|
8791
|
-
if (
|
|
8792
|
-
return
|
|
8793
|
-
const
|
|
8798
|
+
m.map(async (S) => {
|
|
8799
|
+
const b = C.find((H) => H.value === S);
|
|
8800
|
+
if (b)
|
|
8801
|
+
return b;
|
|
8802
|
+
const Z = (await g.post("v1/users/search", {
|
|
8794
8803
|
filters: {
|
|
8795
|
-
id: [
|
|
8804
|
+
id: [S],
|
|
8796
8805
|
status: [d1.ACTIVE, d1.ARCHIVED]
|
|
8797
8806
|
}
|
|
8798
8807
|
})).data.data[0];
|
|
8799
8808
|
return {
|
|
8800
|
-
value:
|
|
8801
|
-
label:
|
|
8809
|
+
value: S,
|
|
8810
|
+
label: v(Z)
|
|
8802
8811
|
};
|
|
8803
8812
|
})
|
|
8804
8813
|
);
|
|
8805
|
-
} catch (
|
|
8814
|
+
} catch (A) {
|
|
8806
8815
|
return c && c({
|
|
8807
|
-
status: ((
|
|
8808
|
-
message: ((
|
|
8816
|
+
status: ((N = A.response) == null ? void 0 : N.status) ?? 500,
|
|
8817
|
+
message: ((I = (M = A.response) == null ? void 0 : M.data) == null ? void 0 : I.message) ?? "Error while fetching selected items"
|
|
8809
8818
|
}), [];
|
|
8810
8819
|
}
|
|
8811
8820
|
},
|
|
8812
8821
|
// Use eslint disable to exclude selectedOptions to prevent infinity rerender
|
|
8813
8822
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8814
|
-
[
|
|
8823
|
+
[g, v, c]
|
|
8815
8824
|
);
|
|
8816
8825
|
T(() => {
|
|
8817
8826
|
if (!n) {
|
|
8818
|
-
|
|
8827
|
+
R(!1);
|
|
8819
8828
|
return;
|
|
8820
8829
|
}
|
|
8821
8830
|
(async () => {
|
|
8822
|
-
const
|
|
8823
|
-
|
|
8831
|
+
const N = Array.isArray(n) ? n : [n], M = await y(N);
|
|
8832
|
+
p(M), R(!1);
|
|
8824
8833
|
})();
|
|
8825
|
-
}, [
|
|
8826
|
-
const
|
|
8834
|
+
}, [y, n]);
|
|
8835
|
+
const V = j(
|
|
8827
8836
|
async ({
|
|
8828
|
-
limit:
|
|
8829
|
-
offset:
|
|
8837
|
+
limit: m,
|
|
8838
|
+
offset: N,
|
|
8830
8839
|
search: M
|
|
8831
8840
|
}) => {
|
|
8832
|
-
const {
|
|
8833
|
-
offset:
|
|
8834
|
-
limit:
|
|
8841
|
+
const { count: I, ...A } = await _({
|
|
8842
|
+
offset: N,
|
|
8843
|
+
limit: m,
|
|
8835
8844
|
search: M
|
|
8836
8845
|
});
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8846
|
+
let S = A.options;
|
|
8847
|
+
return o && N === 0 && (S = [{ value: null, label: "None" }, ...S]), {
|
|
8848
|
+
options: S,
|
|
8849
|
+
count: I,
|
|
8850
|
+
limit: m
|
|
8841
8851
|
};
|
|
8842
8852
|
},
|
|
8843
|
-
[
|
|
8853
|
+
[o, _]
|
|
8844
8854
|
);
|
|
8845
|
-
if (
|
|
8855
|
+
if (x)
|
|
8846
8856
|
return /* @__PURE__ */ r(Oi, {});
|
|
8847
|
-
const
|
|
8848
|
-
ref:
|
|
8857
|
+
const w = {
|
|
8858
|
+
ref: d,
|
|
8849
8859
|
placeholder: t,
|
|
8850
8860
|
disabled: s
|
|
8851
8861
|
};
|
|
8852
8862
|
return e ? /* @__PURE__ */ r(
|
|
8853
8863
|
E1,
|
|
8854
8864
|
{
|
|
8855
|
-
...
|
|
8865
|
+
...w,
|
|
8856
8866
|
mode: e,
|
|
8857
8867
|
value: n,
|
|
8858
8868
|
onChange: l,
|
|
8859
|
-
loadOptions:
|
|
8869
|
+
loadOptions: V,
|
|
8860
8870
|
loadOnClosedState: !0,
|
|
8861
|
-
extraOptions:
|
|
8871
|
+
extraOptions: C
|
|
8862
8872
|
}
|
|
8863
8873
|
) : /* @__PURE__ */ r(
|
|
8864
8874
|
E1,
|
|
8865
8875
|
{
|
|
8866
|
-
...
|
|
8876
|
+
...w,
|
|
8867
8877
|
value: n,
|
|
8868
8878
|
mode: void 0,
|
|
8869
8879
|
onChange: l,
|
|
8870
|
-
loadOptions:
|
|
8880
|
+
loadOptions: V,
|
|
8871
8881
|
loadOnClosedState: !0,
|
|
8872
|
-
extraOptions:
|
|
8882
|
+
extraOptions: C
|
|
8873
8883
|
}
|
|
8874
8884
|
);
|
|
8875
8885
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snmt-react-ui/user-select",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/user-select.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"build": "tsc && vite build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@snmt-react-ui/async-select": "^1.5.
|
|
21
|
+
"@snmt-react-ui/async-select": "^1.5.1",
|
|
22
22
|
"@snmt-react-ui/core": "^2.1.0",
|
|
23
23
|
"@snmt-react-ui/loader": "^1.4.0",
|
|
24
|
-
"@snmt-react-ui/select": "^1.
|
|
24
|
+
"@snmt-react-ui/select": "^1.13.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"antd": "^5.22.3",
|
|
28
28
|
"i18next": "^23.11.1",
|
|
29
29
|
"react-i18next": "^14.1.0"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "4fb4e1391cb8b2eadb496aac3eae00c2b13ba0b2"
|
|
32
32
|
}
|