@matchain/matchid-sdk-react 0.1.53-alpha.25 → 0.1.53-alpha.26

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.
@@ -1,4 +1,4 @@
1
- export { B as BTCModal, l as ContactCard, C as ContactList, d as EVMModal, E as EmailModal, L as LoginBox, a as LoginButton, c as LoginModal, b as LoginPanel, M as MessageList, e as TONModal, T as TRONModal, g as TokenDetail, h as TokenSend, j as TokenSendList, k as TransactionList, U as UsernameModal, f as WalletAsset, W as WalletModal } from '../index-DromP9ET.mjs';
1
+ export { B as BTCModal, l as ContactCard, C as ContactList, d as EVMModal, E as EmailModal, L as LoginBox, a as LoginButton, c as LoginModal, b as LoginPanel, e as TONModal, T as TRONModal, g as TokenDetail, h as TokenSend, j as TokenSendList, k as TransactionList, U as UsernameModal, f as WalletAsset, W as WalletModal } from '../index-CPwcm70o.mjs';
2
2
  export { B as Button, F as Field, I as Input, M as Modal, a as ModalWithHeader, O as Overlay, P as Popover } from '../index-CkHDxE7B.mjs';
3
3
  import 'react/jsx-runtime';
4
4
  import '../types-Bi9iq57H.mjs';
@@ -1,4 +1,4 @@
1
- export { B as BTCModal, l as ContactCard, C as ContactList, d as EVMModal, E as EmailModal, L as LoginBox, a as LoginButton, c as LoginModal, b as LoginPanel, M as MessageList, e as TONModal, T as TRONModal, g as TokenDetail, h as TokenSend, j as TokenSendList, k as TransactionList, U as UsernameModal, f as WalletAsset, W as WalletModal } from '../index-D3BHrg4-.js';
1
+ export { B as BTCModal, l as ContactCard, C as ContactList, d as EVMModal, E as EmailModal, L as LoginBox, a as LoginButton, c as LoginModal, b as LoginPanel, e as TONModal, T as TRONModal, g as TokenDetail, h as TokenSend, j as TokenSendList, k as TransactionList, U as UsernameModal, f as WalletAsset, W as WalletModal } from '../index-Dj1K-UdZ.js';
2
2
  export { B as Button, F as Field, I as Input, M as Modal, a as ModalWithHeader, O as Overlay, P as Popover } from '../index-SRHVQn5G.js';
3
3
  import 'react/jsx-runtime';
4
4
  import '../types-Bi9iq57H.js';
@@ -42,7 +42,6 @@ __export(components_exports, {
42
42
  LoginButton: () => LoginButton,
43
43
  LoginModal: () => LoginModal,
44
44
  LoginPanel: () => LoginPanel,
45
- MessageList: () => MessageList,
46
45
  Modal: () => Modal,
47
46
  ModalWithHeader: () => ModalWithHeader,
48
47
  Overlay: () => Overlay,
@@ -1324,44 +1323,6 @@ function ModalWithHeader({
1324
1323
  children
1325
1324
  ] });
1326
1325
  }
1327
- function ConfirmModal({
1328
- title,
1329
- children,
1330
- onClose,
1331
- onConfirm,
1332
- isOpen,
1333
- confirmText,
1334
- zIndex = 100
1335
- }) {
1336
- const intl = (0, import_react_intl.useIntl)();
1337
- const [loading, setLoading] = (0, import_react3.useState)(false);
1338
- const [error, setError] = (0, import_react3.useState)("");
1339
- (0, import_react3.useEffect)(() => {
1340
- if (isOpen) {
1341
- setError("");
1342
- setLoading(false);
1343
- }
1344
- }, [isOpen]);
1345
- const onSubmit = async () => {
1346
- setError("");
1347
- setLoading(true);
1348
- try {
1349
- await onConfirm();
1350
- } catch (e) {
1351
- setError(e.message);
1352
- console.error(e);
1353
- } finally {
1354
- setLoading(false);
1355
- }
1356
- };
1357
- return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ModalWithHeader, { isOpen, onClose, title, zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "matchid-confirm-modal", children: [
1358
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "matchid-w-full", children }),
1359
- error && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: `matchid-error`, children: error }),
1360
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Button, { size: "lg", onClick: onSubmit, loading, block: true, highlight: true, children: confirmText ?? intl.formatMessage({
1361
- id: "Confirm"
1362
- }) })
1363
- ] }) });
1364
- }
1365
1326
 
1366
1327
  // src/components/EmailModal/StepEmail.tsx
1367
1328
  var import_react5 = require("react");
@@ -1951,20 +1912,6 @@ var userInviteApi = (data) => {
1951
1912
  data
1952
1913
  });
1953
1914
  };
1954
- var getUserMessageListApi = (data) => {
1955
- return request_default({
1956
- url: `/api/v1/user/message/list`,
1957
- method: "POST",
1958
- data
1959
- });
1960
- };
1961
- var handleMessageApi = (data) => {
1962
- return request_default({
1963
- url: `/api/v1/user/message`,
1964
- method: "POST",
1965
- data
1966
- });
1967
- };
1968
1915
 
1969
1916
  // src/store/useLocalStore.ts
1970
1917
  var persistedState = (0, import_middleware.persist)(
@@ -6766,190 +6713,6 @@ function ContactList({
6766
6713
  }
6767
6714
  );
6768
6715
  }
6769
-
6770
- // src/hooks/api/message.ts
6771
- var import_react_query14 = require("@tanstack/react-query");
6772
- var import_last2 = __toESM(require("lodash/last"));
6773
- var import_react45 = require("react");
6774
- function useMessageListQuery(page_size = 20) {
6775
- const { token } = useLocalStore_default();
6776
- const [hasMore, setHasMore] = (0, import_react45.useState)(true);
6777
- const messageListQuery = (0, import_react_query14.useInfiniteQuery)({
6778
- queryKey: ["matchid-message-list", token],
6779
- initialPageParam: 0,
6780
- queryFn: async (args) => {
6781
- const res = (await getUserMessageListApi({
6782
- limit: page_size,
6783
- limit_id: args.pageParam
6784
- })).data;
6785
- console.log("hasMore", !(!res || res.length == 0 || res.length < page_size));
6786
- setHasMore(!(!res || res.length == 0 || res.length < page_size));
6787
- return res || [];
6788
- },
6789
- getNextPageParam: (lastPage, allPages) => {
6790
- if (!lastPage || lastPage.length == 0 || lastPage.length < page_size) return void 0;
6791
- return (0, import_last2.default)(lastPage)?.limit_id;
6792
- }
6793
- });
6794
- (0, import_react45.useEffect)(() => {
6795
- console.log("messageListQuery.data", messageListQuery.data);
6796
- }, [messageListQuery.data]);
6797
- const data = (0, import_react45.useMemo)(() => {
6798
- return (messageListQuery.data?.pages ?? []).reduce(
6799
- (a, b) => {
6800
- return a.concat(b || []);
6801
- },
6802
- []
6803
- );
6804
- }, [messageListQuery.data]);
6805
- return {
6806
- data,
6807
- totalCount: hasMore ? data.length + 1 : data.length,
6808
- loading: messageListQuery.isLoading,
6809
- loadingNextPage: messageListQuery.isFetchingNextPage,
6810
- hasNextPage: messageListQuery.hasNextPage,
6811
- onLoadMore: messageListQuery.fetchNextPage,
6812
- queryKey: ["matchid-message-list", token]
6813
- };
6814
- }
6815
-
6816
- // src/components/MessageList/index.tsx
6817
- var import_react46 = require("react");
6818
- var import_react_virtuoso2 = require("react-virtuoso");
6819
- var import_react_intl25 = require("react-intl");
6820
- var import_react47 = __toESM(require("react"));
6821
- var import_react_query15 = require("@tanstack/react-query");
6822
- var import_jsx_runtime100 = require("react/jsx-runtime");
6823
- function MessageList({
6824
- empty,
6825
- height = 600,
6826
- pageSize = 20
6827
- }) {
6828
- const { loading, totalCount, data, onLoadMore, queryKey, ...query } = useMessageListQuery(pageSize);
6829
- (0, import_react46.useEffect)(() => {
6830
- console.log("query", query);
6831
- }, [query]);
6832
- const modal = useModal();
6833
- const toast = useToast();
6834
- const isDownMd = useDownMd();
6835
- const queryClient2 = (0, import_react_query15.useQueryClient)();
6836
- const intl = (0, import_react_intl25.useIntl)();
6837
- const updateList = (limit_id, newData) => {
6838
- queryClient2.setQueryData(queryKey, (oldData) => {
6839
- if (!oldData) return oldData;
6840
- return {
6841
- ...oldData,
6842
- pages: oldData.pages.map((page) => page.map(
6843
- (item) => item.limit_id === limit_id ? { ...item, ...newData } : item
6844
- ))
6845
- };
6846
- });
6847
- };
6848
- const handleShortPress = async (data2, index) => {
6849
- if (data2.status == 0) {
6850
- updateList(data2.limit_id, { status: 1 });
6851
- const res = await handleMessageApi({
6852
- limit_id: data2.limit_id,
6853
- status: 1
6854
- });
6855
- if (!isSuccess(res)) {
6856
- updateList(data2.limit_id, { status: 0 });
6857
- }
6858
- }
6859
- };
6860
- const handleDelete = (data2, index) => {
6861
- modal.show(({ close, zIndex }) => {
6862
- return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
6863
- ConfirmModal,
6864
- {
6865
- title: intl.formatMessage({
6866
- id: "Delete Message Confirm"
6867
- }),
6868
- onClose: close,
6869
- onConfirm: async () => {
6870
- const res = await handleMessageApi({
6871
- limit_id: data2.limit_id,
6872
- status: 2
6873
- });
6874
- close();
6875
- if (isSuccess(res)) {
6876
- toast.success(intl.formatMessage({
6877
- id: "Message has been cleared"
6878
- }));
6879
- updateList(data2.limit_id, { hidden: true });
6880
- return;
6881
- }
6882
- toast.error(res.message);
6883
- },
6884
- isOpen: true,
6885
- zIndex,
6886
- children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_react_intl25.FormattedMessage, { id: "Are you sure to delete this message?" })
6887
- }
6888
- );
6889
- });
6890
- };
6891
- const handleLongPress = (data2, index) => {
6892
- handleDelete(data2, index);
6893
- };
6894
- return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
6895
- import_react_virtuoso2.Virtuoso,
6896
- {
6897
- style: {
6898
- height
6899
- },
6900
- totalCount: loading ? 0 : totalCount,
6901
- itemContent: (index) => {
6902
- const item = data[index];
6903
- if (!item) return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_jsx_runtime100.Fragment, {});
6904
- if (item.hidden) {
6905
- return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_jsx_runtime100.Fragment, {});
6906
- }
6907
- return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_react47.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(
6908
- "div",
6909
- {
6910
- className: "matchid-message-item",
6911
- onClick: () => handleShortPress(item, index),
6912
- onContextMenu: (e) => {
6913
- if (isDownMd) {
6914
- e.preventDefault();
6915
- handleLongPress(item, index);
6916
- }
6917
- },
6918
- children: [
6919
- /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("div", { className: "matchid-message-item-content", children: [
6920
- /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { className: "matchid-message-item-content-message", children: item.message }),
6921
- /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { className: "matchid-message-item-content-status", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
6922
- "div",
6923
- {
6924
- className: `matchid-message-item-content-status-indicator ${item.status == 0 ? "highlight" : "default"}`
6925
- }
6926
- ) })
6927
- ] }),
6928
- /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("div", { className: "matchid-message-item-footer", children: [
6929
- /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { children: !isDownMd && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
6930
- "div",
6931
- {
6932
- className: "matchid-message-item-footer-delete",
6933
- onClick: () => handleDelete(item, index),
6934
- children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_react_intl25.FormattedMessage, { id: "Delete" })
6935
- }
6936
- ) }),
6937
- /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { children: formatDate(item.dispatch_time, "YYYY.MM.DD HH:mm") })
6938
- ] })
6939
- ]
6940
- }
6941
- ) });
6942
- },
6943
- endReached: () => {
6944
- onLoadMore();
6945
- },
6946
- components: {
6947
- EmptyPlaceholder: () => empty || /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { className: "matchid-nomore", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_react_intl25.FormattedMessage, { id: "There is no Data here!" }) }),
6948
- Footer: data.length > 0 ? () => /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { className: "matchid-nomore", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_react_intl25.FormattedMessage, { id: "There is no Message here!" }) }) : () => /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { className: "matchid-nomore", children: "Loading..." })
6949
- }
6950
- }
6951
- );
6952
- }
6953
6716
  // Annotate the CommonJS export names for ESM import in node:
6954
6717
  0 && (module.exports = {
6955
6718
  BTCModal,
@@ -6964,7 +6727,6 @@ function MessageList({
6964
6727
  LoginButton,
6965
6728
  LoginModal,
6966
6729
  LoginPanel,
6967
- MessageList,
6968
6730
  Modal,
6969
6731
  ModalWithHeader,
6970
6732
  Overlay,