@0xchain/table 1.1.0-beta.18 → 1.1.0-beta.19

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/LICENSE +21 -0
  2. package/dist/index.js +472 -302
  3. package/package.json +38 -22
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present 0xchain
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -1,414 +1,584 @@
1
1
  'use client';
2
- import { jsx as e, jsxs as l } from "react/jsx-runtime";
3
- import { Table as ie, TableHeader as ce, TableRow as E, TableHead as de, TableBody as me, TableCell as K } from "@0xchain/ui/table";
4
- import * as Z from "react";
5
- import he, { useState as w, useEffect as z } from "react";
6
- import { startOfDay as q, endOfDay as X } from "date-fns";
7
- import { twMerge as v } from "tailwind-merge";
8
- import { DatePicker as ue } from "antd";
9
- import M from "dayjs";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from "@0xchain/ui/table";
4
+ import * as React from "react";
5
+ import React__default, { useState, useEffect } from "react";
6
+ import { startOfDay, endOfDay } from "date-fns";
7
+ import { twMerge } from "tailwind-merge";
8
+ import { DatePicker } from "antd";
9
+ import dayjs from "dayjs";
10
10
  import "dayjs/locale/en";
11
11
  import "dayjs/locale/zh-cn";
12
12
  import "dayjs/locale/zh-tw";
13
13
  import "dayjs/locale/ja";
14
14
  import "dayjs/locale/ko";
15
- import fe from "antd/es/date-picker/locale/en_US";
16
- import pe from "antd/es/date-picker/locale/zh_CN";
17
- import Ae from "antd/es/date-picker/locale/zh_TW";
18
- import ge from "antd/es/date-picker/locale/ja_JP";
19
- import be from "antd/es/date-picker/locale/ko_KR";
20
- import D from "@0xchain/image";
21
- import { Popover as O, PopoverTrigger as U, PopoverContent as Q } from "@0xchain/ui/popover";
22
- import { useLocale as xe, useTranslations as J } from "next-intl";
23
- import { X as W, Search as V } from "lucide-react";
24
- import * as Y from "@radix-ui/react-slider";
25
- import $ from "@0xchain/number-like";
26
- import S from "@0xchain/translation";
27
- import _ from "@0xchain/request";
28
- import { useParams as ee } from "next/navigation";
29
- import { Checkbox as te } from "@0xchain/ui/checkbox";
30
- import { useDebounceFn as we } from "ahooks";
31
- import ye from "@0xchain/empty";
32
- import ke from "@0xchain/loading";
33
- const Ne = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAZCAYAAAArK+5dAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADWSURBVHgB7ZPhDcIgEIUP0wEcQTdwAxjBERzBDcSJdAPbDdwANznBQnIih6TQP02/hJDmwb274wqwaBDRuDVVd3TksLKbivSd1zRzn9PvQognzeSA7VG0gqPfe7sGksnF71dIk9IljJ1QPt5YonfV9HZIhQme1ONYHeR5Vep5A/tQ+xo9ZSCRn5hSZM5Awe+oVhEb9PA9RVMIU5Q0GGxfNVTgW6zC9yZz0EQ/jinRYliDVrBjmhvBkvEMzF7B+gZ/mb2CD7aHZ2zPiRps7bphOx4uJiyCNyogpaxjuzr+AAAAAElFTkSuQmCC";
34
- function ve({
35
- className: a,
36
- onChange: i,
37
- ...c
15
+ import enUSPicker from "antd/es/date-picker/locale/en_US";
16
+ import zhCNPicker from "antd/es/date-picker/locale/zh_CN";
17
+ import zhTWPicker from "antd/es/date-picker/locale/zh_TW";
18
+ import jaJPPicker from "antd/es/date-picker/locale/ja_JP";
19
+ import koKRPicker from "antd/es/date-picker/locale/ko_KR";
20
+ import ImageBar from "@0xchain/image";
21
+ import { Popover, PopoverTrigger, PopoverContent } from "@0xchain/ui/popover";
22
+ import { useLocale, useTranslations } from "next-intl";
23
+ import { X, Search } from "lucide-react";
24
+ import * as Slider from "@radix-ui/react-slider";
25
+ import NumberLike from "@0xchain/number-like";
26
+ import Translation from "@0xchain/translation";
27
+ import request from "@0xchain/request";
28
+ import { useParams } from "next/navigation";
29
+ import { Checkbox } from "@0xchain/ui/checkbox";
30
+ import { useDebounceFn } from "ahooks";
31
+ import Empty from "@0xchain/empty";
32
+ import Loading from "@0xchain/loading";
33
+ const CalendarIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAZCAYAAAArK+5dAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADWSURBVHgB7ZPhDcIgEIUP0wEcQTdwAxjBERzBDcSJdAPbDdwANznBQnIih6TQP02/hJDmwb274wqwaBDRuDVVd3TksLKbivSd1zRzn9PvQognzeSA7VG0gqPfe7sGksnF71dIk9IljJ1QPt5YonfV9HZIhQme1ONYHeR5Vep5A/tQ+xo9ZSCRn5hSZM5Awe+oVhEb9PA9RVMIU5Q0GGxfNVTgW6zC9yZz0EQ/jinRYliDVrBjmhvBkvEMzF7B+gZ/mb2CD7aHZ2zPiRps7bphOx4uJiyCNyogpaxjuzr+AAAAAElFTkSuQmCC";
34
+ function DatePickerWithRange({
35
+ className,
36
+ onChange,
37
+ ...props
38
38
  }) {
39
- const m = xe(), [A, y] = Z.useState(!1), k = Z.useRef(null), [b, g] = Z.useState(null), d = {
40
- en: fe,
41
- "zh-hans": pe,
42
- "zh-hant": Ae,
43
- ja: ge,
44
- ko: be
45
- }, f = {
39
+ const locale = useLocale();
40
+ const [open, setOpen] = React.useState(false);
41
+ const containerRef = React.useRef(null);
42
+ const [panelRange, setPanelRange] = React.useState(null);
43
+ const dpLocaleMap = {
44
+ en: enUSPicker,
45
+ "zh-hans": zhCNPicker,
46
+ "zh-hant": zhTWPicker,
47
+ ja: jaJPPicker,
48
+ ko: koKRPicker
49
+ };
50
+ const dayjsLocaleKeyMap = {
46
51
  en: "en",
47
52
  "zh-hans": "zh-cn",
48
53
  "zh-hant": "zh-tw",
49
54
  ja: "ja",
50
55
  ko: "ko"
51
56
  };
52
- Z.useEffect(() => {
53
- M.locale(f[m] ?? "en");
54
- }, [m]);
55
- const C = (o) => {
56
- if (!o) {
57
- i("", ""), N();
57
+ React.useEffect(() => {
58
+ dayjs.locale(dayjsLocaleKeyMap[locale] ?? "en");
59
+ }, [locale]);
60
+ const closePopover = (selectedDate) => {
61
+ if (!selectedDate) {
62
+ onChange("", "");
63
+ cancelPopover();
58
64
  return;
59
65
  }
60
- const [h, p] = o, x = h ? q(h.toDate()) : void 0, T = p ? X(p.toDate()) : void 0;
61
- i(x ? Math.floor(x.getTime() / 1e3) : "", T ? Math.floor(T.getTime() / 1e3) : ""), N();
62
- }, N = () => {
63
- y(!1);
64
- }, R = (o) => {
65
- o ? y(!0) : C(b);
66
- }, B = (o) => {
67
- if (!o) {
68
- g(null);
66
+ const [from, to] = selectedDate;
67
+ const start = from ? startOfDay(from.toDate()) : void 0;
68
+ const end = to ? endOfDay(to.toDate()) : void 0;
69
+ onChange(start ? Math.floor(start.getTime() / 1e3) : "", end ? Math.floor(end.getTime() / 1e3) : "");
70
+ cancelPopover();
71
+ };
72
+ const cancelPopover = () => {
73
+ setOpen(false);
74
+ };
75
+ const togglePopover = (flag) => {
76
+ if (!flag) {
77
+ closePopover(panelRange);
78
+ } else {
79
+ setOpen(true);
80
+ }
81
+ };
82
+ const onAntdCalendarChange = (vals) => {
83
+ if (!vals) {
84
+ setPanelRange(null);
69
85
  return;
70
86
  }
71
- const [h, p] = o;
72
- g([h, p]);
73
- }, n = (o) => {
74
- if (!o || !o[0] || !o[1]) {
75
- g(null), i("", ""), N();
87
+ const [s, e] = vals;
88
+ setPanelRange([s, e]);
89
+ };
90
+ const onAntdChange = (vals) => {
91
+ if (!vals || !vals[0] || !vals[1]) {
92
+ setPanelRange(null);
93
+ onChange("", "");
94
+ cancelPopover();
76
95
  return;
77
96
  }
78
- const h = q(o[0].toDate()), p = X(o[1].toDate());
79
- i(Math.floor(h.getTime() / 1e3), Math.floor(p.getTime() / 1e3)), g([o[0], o[1]]), N();
97
+ const sDate = startOfDay(vals[0].toDate());
98
+ const eDate = endOfDay(vals[1].toDate());
99
+ onChange(Math.floor(sDate.getTime() / 1e3), Math.floor(eDate.getTime() / 1e3));
100
+ setPanelRange([vals[0], vals[1]]);
101
+ cancelPopover();
80
102
  };
81
- return /* @__PURE__ */ e("div", { className: v(a), ...c, children: /* @__PURE__ */ l(O, { open: A, onOpenChange: R, children: [
82
- /* @__PURE__ */ e(U, { asChild: !0, children: /* @__PURE__ */ e("i", { className: "w-4 h-4 p-[2px] cursor-pointer flex items-center justify-center bg-[#000] rounded-sm", children: /* @__PURE__ */ e(D, { src: Ne, width: 12, height: 12 }) }) }),
83
- /* @__PURE__ */ e(Q, { className: "w-auto p-0", align: "center", side: "right", children: /* @__PURE__ */ e("div", { ref: k, className: "relative", children: /* @__PURE__ */ e(
84
- ue.RangePicker,
103
+ return /* @__PURE__ */ jsx("div", { className: twMerge(className), ...props, children: /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: togglePopover, children: [
104
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx("i", { className: "w-4 h-4 p-[2px] cursor-pointer flex items-center justify-center bg-[#000] rounded-sm", children: /* @__PURE__ */ jsx(ImageBar, { src: CalendarIcon, width: 12, height: 12 }) }) }),
105
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "center", side: "right", children: /* @__PURE__ */ jsx("div", { ref: containerRef, className: "relative", children: /* @__PURE__ */ jsx(
106
+ DatePicker.RangePicker,
85
107
  {
86
- open: !0,
108
+ open: true,
87
109
  size: "small",
88
- locale: d[m],
89
- allowClear: !1,
90
- value: b ?? [M(), M()],
91
- onCalendarChange: B,
92
- onChange: n,
93
- getPopupContainer: () => k.current,
110
+ locale: dpLocaleMap[locale],
111
+ allowClear: false,
112
+ value: panelRange ?? [dayjs(), dayjs()],
113
+ onCalendarChange: onAntdCalendarChange,
114
+ onChange: onAntdChange,
115
+ getPopupContainer: () => containerRef.current,
94
116
  style: { position: "absolute", opacity: 0, width: 0, height: 0, pointerEvents: "none" },
95
- disabledDate: (o) => o && o > M().endOf("day")
117
+ disabledDate: (current) => {
118
+ return current && current > dayjs().endOf("day");
119
+ }
96
120
  }
97
121
  ) }) })
98
122
  ] }) });
99
123
  }
100
- const Ce = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADZSURBVHgB7ZTbDcIwDEVvUAfoCN2AjsAI3YBu0jABGYER2KAjABPABrBBcMARFkjNo/krR7IaWfZ1nDoB/gRQfmGt7enToAw3pdThu4BFQajAS7sSvh3ZwOsj2QVprMk6ofULNWHsmytZg0hcLOc4TCh4FEVqhMVrIT6idELqhnySbHk/ETfkHKlPbsnuLDBMiLuYFjm4u2E/bIW/E/4ecyABLXZa8/H5zjRKQEInFtywxU0MsUIcD2QSWyCb5RVInvcqMs7/ZHerzygNz74Wz0f0mM4pZLAInpppFh6wLb8LAAAAAElFTkSuQmCC";
101
- function je({ onChange: a, filterKey: i }) {
102
- const [c, m] = w(!1), A = J("common"), [y, k] = w(""), [b, g] = w(""), [d, f] = w([0.01, 1e10]), C = (p) => {
103
- f(p), k(p[0].toString()), g(p[1].toString());
104
- }, N = (p) => {
105
- const x = p.target.value;
106
- if (x === "" || /^\d*\.?\d{0,8}$/.test(x) && !x.startsWith(".")) {
107
- k(x);
108
- const T = parseFloat(x) || 0;
109
- f([T, d[1]]);
124
+ const AmountIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADZSURBVHgB7ZTbDcIwDEVvUAfoCN2AjsAI3YBu0jABGYER2KAjABPABrBBcMARFkjNo/krR7IaWfZ1nDoB/gRQfmGt7enToAw3pdThu4BFQajAS7sSvh3ZwOsj2QVprMk6ofULNWHsmytZg0hcLOc4TCh4FEVqhMVrIT6idELqhnySbHk/ETfkHKlPbsnuLDBMiLuYFjm4u2E/bIW/E/4ecyABLXZa8/H5zjRKQEInFtywxU0MsUIcD2QSWyCb5RVInvcqMs7/ZHerzygNz74Wz0f0mM4pZLAInpppFh6wLb8LAAAAAElFTkSuQmCC";
125
+ function Amount({ onChange, filterKey }) {
126
+ const [open, setOpen] = useState(false);
127
+ const t = useTranslations("common");
128
+ const [min, setMin] = useState("");
129
+ const [max, setMax] = useState("");
130
+ const [sliderValues, setSliderValues] = useState([0.01, 1e10]);
131
+ const handleSliderChange = (values) => {
132
+ setSliderValues(values);
133
+ setMin(values[0].toString());
134
+ setMax(values[1].toString());
135
+ };
136
+ const handleFromChange = (e) => {
137
+ const value = e.target.value;
138
+ if (value === "" || /^\d*\.?\d{0,8}$/.test(value) && !value.startsWith(".")) {
139
+ setMin(value);
140
+ const numValue = parseFloat(value) || 0;
141
+ setSliderValues([numValue, sliderValues[1]]);
142
+ }
143
+ };
144
+ const handleToChange = (e) => {
145
+ const value = e.target.value;
146
+ if (value === "" || /^\d*\.?\d{0,8}$/.test(value) && !value.startsWith(".")) {
147
+ setMax(value);
148
+ const numValue = parseFloat(value);
149
+ setSliderValues([sliderValues[0], numValue]);
150
+ }
151
+ };
152
+ const handleConfirm = () => {
153
+ onChange(min, max);
154
+ setOpen(false);
155
+ };
156
+ const handleCancel = () => {
157
+ setOpen(false);
158
+ };
159
+ const handleMinBlur = (e) => {
160
+ const value = e.target.value;
161
+ if (value === "0") {
162
+ setMin("0.01");
110
163
  }
111
- }, R = (p) => {
112
- const x = p.target.value;
113
- if (x === "" || /^\d*\.?\d{0,8}$/.test(x) && !x.startsWith(".")) {
114
- g(x);
115
- const T = parseFloat(x);
116
- f([d[0], T]);
164
+ };
165
+ const handleMaxBlur = (e) => {
166
+ const value = e.target.value;
167
+ if (value === "0") {
168
+ setMax("0.01");
117
169
  }
118
- }, B = () => {
119
- a(y, b), m(!1);
120
- }, n = () => {
121
- m(!1);
122
- }, o = (p) => {
123
- p.target.value === "0" && k("0.01");
124
- }, h = (p) => {
125
- p.target.value === "0" && g("0.01");
126
170
  };
127
- return /* @__PURE__ */ l(O, { open: c, onOpenChange: m, children: [
128
- /* @__PURE__ */ e(U, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "w-[16px] h-[16px] flex items-center justify-center bg-[#000] rounded-sm cursor-pointer", children: /* @__PURE__ */ e(D, { src: Ce, width: 12, height: 12, objectFit: "contain" }) }) }),
129
- /* @__PURE__ */ e(Q, { className: "bg-card", children: /* @__PURE__ */ l("div", { className: "w-full h-full", children: [
130
- /* @__PURE__ */ l("div", { className: "flex flex-row items-center justify-between h-9", children: [
131
- /* @__PURE__ */ e("span", { className: "text-sm", children: /* @__PURE__ */ e(S, { value: "label", parentKey: "common.filter.amount" }) }),
132
- /* @__PURE__ */ e("div", { className: "w-4 h-4 text-foreground text-sm cursor-pointer flex items-center justify-center", onClick: () => n(), children: /* @__PURE__ */ e(W, { className: "w-4 h-4" }) })
171
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
172
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "w-[16px] h-[16px] flex items-center justify-center bg-[#000] rounded-sm cursor-pointer", children: /* @__PURE__ */ jsx(ImageBar, { src: AmountIcon, width: 12, height: 12, objectFit: "contain" }) }) }),
173
+ /* @__PURE__ */ jsx(PopoverContent, { className: "bg-card", children: /* @__PURE__ */ jsxs("div", { className: "w-full h-full", children: [
174
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center justify-between h-9", children: [
175
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: /* @__PURE__ */ jsx(Translation, { value: "label", parentKey: "common.filter.amount" }) }),
176
+ /* @__PURE__ */ jsx("div", { className: "w-4 h-4 text-foreground text-sm cursor-pointer flex items-center justify-center", onClick: () => handleCancel(), children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" }) })
133
177
  ] }),
134
- /* @__PURE__ */ l("div", { className: "flex flex-row items-center justify-between gap-2 py-3", children: [
135
- /* @__PURE__ */ l("fieldset", { className: "w-1/2 h-full", children: [
136
- /* @__PURE__ */ e("label", { className: "w-full h-full text-sm", children: /* @__PURE__ */ e(S, { value: "form", parentKey: "common.filter.amount" }) }),
137
- /* @__PURE__ */ e("input", { type: "text", inputMode: "decimal", pattern: "[0-9]*\\.?[0-9]{0,8}", onBlur: o, placeholder: A("filter.amount.min"), className: "w-full h-full bg-card text-sm border-1 border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: y, onChange: N })
178
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center justify-between gap-2 py-3", children: [
179
+ /* @__PURE__ */ jsxs("fieldset", { className: "w-1/2 h-full", children: [
180
+ /* @__PURE__ */ jsx("label", { className: "w-full h-full text-sm", children: /* @__PURE__ */ jsx(Translation, { value: "form", parentKey: "common.filter.amount" }) }),
181
+ /* @__PURE__ */ jsx("input", { type: "text", inputMode: "decimal", pattern: "[0-9]*\\.?[0-9]{0,8}", onBlur: handleMinBlur, placeholder: t("filter.amount.min"), className: "w-full h-full bg-card text-sm border-1 border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: min, onChange: handleFromChange })
138
182
  ] }),
139
- /* @__PURE__ */ l("fieldset", { className: "w-1/2 h-full", children: [
140
- /* @__PURE__ */ e("label", { className: "w-full h-full text-sm", children: /* @__PURE__ */ e(S, { value: "to", parentKey: "common.filter.amount" }) }),
141
- /* @__PURE__ */ e("input", { type: "text", inputMode: "decimal", pattern: "[0-9]*\\.?[0-9]{0,8}", onBlur: h, placeholder: A("filter.amount.max"), className: "w-full h-full bg-card text-sm border-1 border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: b, onChange: R })
183
+ /* @__PURE__ */ jsxs("fieldset", { className: "w-1/2 h-full", children: [
184
+ /* @__PURE__ */ jsx("label", { className: "w-full h-full text-sm", children: /* @__PURE__ */ jsx(Translation, { value: "to", parentKey: "common.filter.amount" }) }),
185
+ /* @__PURE__ */ jsx("input", { type: "text", inputMode: "decimal", pattern: "[0-9]*\\.?[0-9]{0,8}", onBlur: handleMaxBlur, placeholder: t("filter.amount.max"), className: "w-full h-full bg-card text-sm border-1 border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: max, onChange: handleToChange })
142
186
  ] })
143
187
  ] }),
144
- /* @__PURE__ */ l("div", { className: " w-full pb-4", children: [
145
- /* @__PURE__ */ l(
146
- Y.Root,
188
+ /* @__PURE__ */ jsxs("div", { className: " w-full pb-4", children: [
189
+ /* @__PURE__ */ jsxs(
190
+ Slider.Root,
147
191
  {
148
192
  className: "w-full relative flex items-center justify-center h-1 grow bg-background rounded-sm touch-pan-y select-none",
149
- value: d,
150
- onValueChange: C,
193
+ value: sliderValues,
194
+ onValueChange: handleSliderChange,
151
195
  max: 1e10,
152
196
  min: 0.01,
153
197
  step: 1,
154
198
  children: [
155
- /* @__PURE__ */ e(Y.Track, { className: "h-1 rounded-full bg-primary", children: /* @__PURE__ */ e(Y.Range, { className: "h-1 absolute bg-primary rounded-full" }) }),
156
- /* @__PURE__ */ e(Y.Thumb, { className: "block w-3 h-3 bg-primary rounded-full cursor-pointer touch-none", "aria-label": "Min value" }),
157
- /* @__PURE__ */ e(Y.Thumb, { className: "block w-3 h-3 bg-primary rounded-full cursor-pointer touch-none", "aria-label": "Max value" })
199
+ /* @__PURE__ */ jsx(Slider.Track, { className: "h-1 rounded-full bg-primary", children: /* @__PURE__ */ jsx(Slider.Range, { className: "h-1 absolute bg-primary rounded-full" }) }),
200
+ /* @__PURE__ */ jsx(Slider.Thumb, { className: "block w-3 h-3 bg-primary rounded-full cursor-pointer touch-none", "aria-label": "Min value" }),
201
+ /* @__PURE__ */ jsx(Slider.Thumb, { className: "block w-3 h-3 bg-primary rounded-full cursor-pointer touch-none", "aria-label": "Max value" })
158
202
  ]
159
203
  }
160
204
  ),
161
- /* @__PURE__ */ l("div", { className: "flex justify-between text-xs text-gray-500 mt-2", children: [
162
- /* @__PURE__ */ e($, { addonBefore: i === "valueUSD" ? /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: "$" }) : void 0, number: "0.01", minimumFractionDigits: 2, notation: "compact", maximumFractionDigits: 20 }),
163
- /* @__PURE__ */ e($, { addonBefore: i === "valueUSD" ? /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: "$" }) : void 0, number: "10000000000", notation: "compact", maximumFractionDigits: 2 })
205
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-xs text-gray-500 mt-2", children: [
206
+ /* @__PURE__ */ jsx(NumberLike, { addonBefore: filterKey === "valueUSD" ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "$" }) : void 0, number: "0.01", minimumFractionDigits: 2, notation: "compact", maximumFractionDigits: 20 }),
207
+ /* @__PURE__ */ jsx(NumberLike, { addonBefore: filterKey === "valueUSD" ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "$" }) : void 0, number: "10000000000", notation: "compact", maximumFractionDigits: 2 })
164
208
  ] })
165
209
  ] }),
166
- /* @__PURE__ */ l("div", { className: "flex justify-end items-center", children: [
167
- /* @__PURE__ */ e("button", { className: "bg-card text-foreground text-sm px-3 py-1 border border-border rounded-lg ml-3 cursor-pointer", onClick: n, children: A("button.cancel") }),
168
- /* @__PURE__ */ e("button", { className: "bg-primary text-white text-sm px-3 py-1 rounded-lg ml-3 cursor-pointer", onClick: B, children: A("button.confirm") })
210
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end items-center", children: [
211
+ /* @__PURE__ */ jsx("button", { className: "bg-card text-foreground text-sm px-3 py-1 border border-border rounded-lg ml-3 cursor-pointer", onClick: handleCancel, children: t("button.cancel") }),
212
+ /* @__PURE__ */ jsx("button", { className: "bg-primary text-white text-sm px-3 py-1 rounded-lg ml-3 cursor-pointer", onClick: handleConfirm, children: t("button.confirm") })
169
213
  ] })
170
214
  ] }) })
171
215
  ] });
172
216
  }
173
- const H = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAFFSURBVHgB5VVRccMwDFV2A+AxCIOZwQyhDGYGC4OGQcegYzAIgZANgcsgY6DJd9Kquk4Te9ef9t3pkpOf/CTFigHuAojoyPZkAY+YyAYyD/8BbdDyRksIVWIU9MrZStY9mSUzvB7fPdmoxLYlAlYFvsvGF/hdsRAee98rn+PWSXWjbhGvC9ySgJc+Z3w57BWvZ9+wJBKYuMkE/7WOhUOSjFGVujmBlglTbi3jM5h8L04kokv5j/xs+fmVEpqmOWR8P3AOiX1OFx4SkQNcASIimT1BPcySiJT6AvWQNn3PMtTpclABFW8vkeS4jlAusF07J0Zls4P1Anri7ZoAq4Zql5uRhP+m+AOsRZx4FRgr63SGPLhx6gc8R9HfuMXTi2oOEyfhq4RYLPb7A0/vjkD2yZsbxa0XKkxKC3m4Fvibxso3cHP4BWMxfN1YKiXJAAAAAElFTkSuQmCC";
174
- function Re({ onChange: a }) {
175
- const [i, c] = w(!1), m = J("common"), [A, y] = w(""), k = (d) => {
176
- const f = d.target.value;
177
- (f === "" || /^[a-zA-Z0-9]*$/.test(f)) && y(f);
178
- }, b = () => {
179
- a(A), c(!1);
180
- }, g = () => {
181
- c(!1);
217
+ const TokenIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAFFSURBVHgB5VVRccMwDFV2A+AxCIOZwQyhDGYGC4OGQcegYzAIgZANgcsgY6DJd9Kquk4Te9ef9t3pkpOf/CTFigHuAojoyPZkAY+YyAYyD/8BbdDyRksIVWIU9MrZStY9mSUzvB7fPdmoxLYlAlYFvsvGF/hdsRAee98rn+PWSXWjbhGvC9ySgJc+Z3w57BWvZ9+wJBKYuMkE/7WOhUOSjFGVujmBlglTbi3jM5h8L04kokv5j/xs+fmVEpqmOWR8P3AOiX1OFx4SkQNcASIimT1BPcySiJT6AvWQNn3PMtTpclABFW8vkeS4jlAusF07J0Zls4P1Anri7ZoAq4Zql5uRhP+m+AOsRZx4FRgr63SGPLhx6gc8R9HfuMXTi2oOEyfhq4RYLPb7A0/vjkD2yZsbxa0XKkxKC3m4Fvibxso3cHP4BWMxfN1YKiXJAAAAAElFTkSuQmCC";
218
+ function Address({ onChange }) {
219
+ const [open, setOpen] = useState(false);
220
+ const t = useTranslations("common");
221
+ const [address, setAddress] = useState("");
222
+ const handleAddressChange = (e) => {
223
+ const value = e.target.value;
224
+ if (value === "" || /^[a-zA-Z0-9]*$/.test(value)) {
225
+ setAddress(value);
226
+ }
182
227
  };
183
- return /* @__PURE__ */ l(O, { open: i, onOpenChange: c, children: [
184
- /* @__PURE__ */ e(U, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "w-[16px] h-[16px] flex items-center justify-center bg-[#000] rounded-sm cursor-pointer", children: /* @__PURE__ */ e(D, { src: H, width: 12, height: 12, objectFit: "contain" }) }) }),
185
- /* @__PURE__ */ e(Q, { className: "bg-card", children: /* @__PURE__ */ l("div", { className: "w-full h-full", children: [
186
- /* @__PURE__ */ l("fieldset", { className: "w-full h-full", children: [
187
- /* @__PURE__ */ l("label", { className: "w-full h-full text-sm flex items-center justify-between", children: [
188
- m("filter.address.label"),
189
- /* @__PURE__ */ e("div", { className: "w-4 h-4 text-f text-sm cursor-pointer flex items-center justify-center", onClick: () => g(), children: /* @__PURE__ */ e(W, { className: "w-4 h-4" }) })
228
+ const handleConfirm = () => {
229
+ onChange(address);
230
+ setOpen(false);
231
+ };
232
+ const handleCancel = () => {
233
+ setOpen(false);
234
+ };
235
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
236
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "w-[16px] h-[16px] flex items-center justify-center bg-[#000] rounded-sm cursor-pointer", children: /* @__PURE__ */ jsx(ImageBar, { src: TokenIcon, width: 12, height: 12, objectFit: "contain" }) }) }),
237
+ /* @__PURE__ */ jsx(PopoverContent, { className: "bg-card", children: /* @__PURE__ */ jsxs("div", { className: "w-full h-full", children: [
238
+ /* @__PURE__ */ jsxs("fieldset", { className: "w-full h-full", children: [
239
+ /* @__PURE__ */ jsxs("label", { className: "w-full h-full text-sm flex items-center justify-between", children: [
240
+ t("filter.address.label"),
241
+ /* @__PURE__ */ jsx("div", { className: "w-4 h-4 text-f text-sm cursor-pointer flex items-center justify-center", onClick: () => handleCancel(), children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" }) })
190
242
  ] }),
191
- /* @__PURE__ */ l("div", { className: "w-full relative text-sm ", children: [
192
- /* @__PURE__ */ e(V, { className: "w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2" }),
193
- /* @__PURE__ */ e("input", { placeholder: m("filter.amount.label"), type: "text", pattern: "[a-zA-Z0-9]*", className: "pl-6 w-full h-full bg-card text-sm border-1 border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: A, onChange: k })
243
+ /* @__PURE__ */ jsxs("div", { className: "w-full relative text-sm ", children: [
244
+ /* @__PURE__ */ jsx(Search, { className: "w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2" }),
245
+ /* @__PURE__ */ jsx("input", { placeholder: t("filter.amount.label"), type: "text", pattern: "[a-zA-Z0-9]*", className: "pl-6 w-full h-full bg-card text-sm border-1 border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: address, onChange: handleAddressChange })
194
246
  ] })
195
247
  ] }),
196
- /* @__PURE__ */ l("div", { className: "flex justify-end items-center mt-2", children: [
197
- /* @__PURE__ */ e("button", { className: "bg-card text-foreground text-sm px-3 py-1 border rounded ml-3 cursor-pointer", onClick: g, children: m("button.cancel") }),
198
- /* @__PURE__ */ e("button", { className: "bg-primary text-white text-sm px-3 py-1 rounded ml-3 cursor-pointer", onClick: b, children: m("button.confirm") })
248
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end items-center mt-2", children: [
249
+ /* @__PURE__ */ jsx("button", { className: "bg-card text-foreground text-sm px-3 py-1 border rounded ml-3 cursor-pointer", onClick: handleCancel, children: t("button.cancel") }),
250
+ /* @__PURE__ */ jsx("button", { className: "bg-primary text-white text-sm px-3 py-1 rounded ml-3 cursor-pointer", onClick: handleConfirm, children: t("button.confirm") })
199
251
  ] })
200
252
  ] }) })
201
253
  ] });
202
254
  }
203
- const Be = (a) => _.get("/api/v2/tokens/hot-list", { params: { ...a, limit: 100, page: 1 } }), Se = (a) => _.get("/api/token/list/verified", {
204
- params: {
205
- search: a,
206
- page: 1,
207
- size: 100
208
- }
209
- });
210
- function Te({ onChange: a }) {
211
- const { chain: i } = ee(), c = J("common.filter.amount"), [m, A] = w(!1), [y, k] = w(""), [b, g] = w([]), [d, f] = w([]), C = () => {
212
- A(!1);
213
- }, N = () => {
214
- a(d), A(!1);
215
- }, R = (n) => {
216
- d.some((o) => o.tokenAddress === n.tokenAddress) ? f(d.filter((o) => o.tokenAddress !== n.tokenAddress)) : f([...d, n]);
217
- }, B = we(async () => {
218
- const n = await Be({
219
- chain: i,
220
- text: y,
255
+ const getHotTokenList = (params) => {
256
+ return request.get(`/api/v2/tokens/hot-list`, { params: { ...params, limit: 100, page: 1 } });
257
+ };
258
+ const searchToken = (search) => {
259
+ return request.get(`/api/token/list/verified`, {
260
+ params: {
261
+ search,
262
+ page: 1,
263
+ size: 100
264
+ }
265
+ });
266
+ };
267
+ function Token({ onChange }) {
268
+ const { chain } = useParams();
269
+ const t = useTranslations("common.filter.amount");
270
+ const [open, setOpen] = useState(false);
271
+ const [token, setToken] = useState("");
272
+ const [tokenList, setTokenList] = useState([]);
273
+ const [selectedToken, setSelectedToken] = useState([]);
274
+ const handleCancel = () => {
275
+ setOpen(false);
276
+ };
277
+ const handleConfirm = () => {
278
+ onChange(selectedToken);
279
+ setOpen(false);
280
+ };
281
+ const tokenChange = (item) => {
282
+ if (selectedToken.some((token2) => token2.tokenAddress === item.tokenAddress)) {
283
+ setSelectedToken(selectedToken.filter((token2) => token2.tokenAddress !== item.tokenAddress));
284
+ } else {
285
+ setSelectedToken([...selectedToken, item]);
286
+ }
287
+ };
288
+ const loadData = useDebounceFn(async () => {
289
+ const res = await getHotTokenList({
290
+ chain,
291
+ text: token,
221
292
  limit: 100,
222
293
  page: 1
223
294
  });
224
- g((n == null ? void 0 : n.data) || []);
295
+ setTokenList(res?.data || []);
225
296
  }, { wait: 300 });
226
- return z(() => {
227
- B.run();
228
- }, [i, y]), /* @__PURE__ */ l(O, { open: m, onOpenChange: A, children: [
229
- /* @__PURE__ */ e(U, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "w-[16px] h-[16px] flex items-center justify-center bg-[#000] rounded-sm cursor-pointer", children: /* @__PURE__ */ e(D, { src: H, width: 12, height: 12, objectFit: "contain" }) }) }),
230
- /* @__PURE__ */ l(Q, { className: "py-5 bg-card", children: [
231
- /* @__PURE__ */ l("div", { className: "w-full h-full", children: [
232
- /* @__PURE__ */ l("div", { className: "flex flex-row items-center justify-between h-9", children: [
233
- /* @__PURE__ */ e("span", { className: "text-base text-foreground", children: /* @__PURE__ */ e(S, { value: "label", parentKey: "common.filter.token" }) }),
234
- /* @__PURE__ */ e("div", { className: "w-4 h-4 text-foreground text-sm cursor-pointer flex items-center justify-center", onClick: () => C(), children: /* @__PURE__ */ e(W, { className: "w-4 h-4 text-foreground" }) })
297
+ useEffect(() => {
298
+ loadData.run();
299
+ }, [chain, token]);
300
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
301
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "w-[16px] h-[16px] flex items-center justify-center bg-[#000] rounded-sm cursor-pointer", children: /* @__PURE__ */ jsx(ImageBar, { src: TokenIcon, width: 12, height: 12, objectFit: "contain" }) }) }),
302
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "py-5 bg-card", children: [
303
+ /* @__PURE__ */ jsxs("div", { className: "w-full h-full", children: [
304
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center justify-between h-9", children: [
305
+ /* @__PURE__ */ jsx("span", { className: "text-base text-foreground", children: /* @__PURE__ */ jsx(Translation, { value: "label", parentKey: "common.filter.token" }) }),
306
+ /* @__PURE__ */ jsx("div", { className: "w-4 h-4 text-foreground text-sm cursor-pointer flex items-center justify-center", onClick: () => handleCancel(), children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4 text-foreground" }) })
235
307
  ] }),
236
- /* @__PURE__ */ l("div", { className: "w-full relative text-sm py-3", children: [
237
- /* @__PURE__ */ e(V, { className: "w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2" }),
238
- /* @__PURE__ */ e("input", { type: "text", placeholder: c("label"), className: "pl-6 w-full h-full bg-card text-sm border border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: y, onChange: (n) => k(n.target.value) })
308
+ /* @__PURE__ */ jsxs("div", { className: "w-full relative text-sm py-3", children: [
309
+ /* @__PURE__ */ jsx(Search, { className: "w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2" }),
310
+ /* @__PURE__ */ jsx("input", { type: "text", placeholder: t("label"), className: "pl-6 w-full h-full bg-card text-sm border border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: token, onChange: (e) => setToken(e.target.value) })
239
311
  ] })
240
312
  ] }),
241
- /* @__PURE__ */ e("ul", { className: "max-h-30 min-h-30 overflow-y-auto overflow-x-hidden w-full", children: b == null ? void 0 : b.map((n, o) => /* @__PURE__ */ l("li", { className: "flex h-10 flex-row items-center gap-3 hover:bg-background hover:rounded-sm p-2 cursor-pointer overflow-hidden", onClick: () => R(n), children: [
242
- /* @__PURE__ */ e(D, { src: n.iconUrl, objectFit: "contain", alt: n.tokenSymbol, className: "rounded-full w-4 h-4 min-w-4 min-h-4 flex-shrink-0" }),
243
- /* @__PURE__ */ l("div", { className: "text-sm text-foreground text-left truncate min-w-0 flex-1 overflow-hidden", children: [
244
- /* @__PURE__ */ e("span", { className: "text-foreground", children: n.tokenSymbol }),
313
+ /* @__PURE__ */ jsx("ul", { className: "max-h-30 min-h-30 overflow-y-auto overflow-x-hidden w-full", children: tokenList?.map((item, index) => /* @__PURE__ */ jsxs("li", { className: "flex h-10 flex-row items-center gap-3 hover:bg-background hover:rounded-sm p-2 cursor-pointer overflow-hidden", onClick: () => tokenChange(item), children: [
314
+ /* @__PURE__ */ jsx(ImageBar, { src: item.iconUrl, objectFit: "contain", alt: item.tokenSymbol, className: "rounded-full w-4 h-4 min-w-4 min-h-4 flex-shrink-0" }),
315
+ /* @__PURE__ */ jsxs("div", { className: "text-sm text-foreground text-left truncate min-w-0 flex-1 overflow-hidden", children: [
316
+ /* @__PURE__ */ jsx("span", { className: "text-foreground", children: item.tokenSymbol }),
245
317
  " ",
246
- /* @__PURE__ */ e("span", { className: "text-muted-foreground text-xs", children: n.tokenName })
318
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: item.tokenName })
247
319
  ] }),
248
- /* @__PURE__ */ e("div", { className: "shrink-0", children: /* @__PURE__ */ e(te, { className: v("w-4 h-4 cursor-pointer border border-gray-300 rounded-sm", d.some((h) => h.tokenAddress === n.tokenAddress) ? "bg-primary" : "bg-card"), checked: d.some((h) => h.tokenAddress === n.tokenAddress) }) })
249
- ] }, o)) }),
250
- /* @__PURE__ */ l("div", { className: "flex justify-end items-center mt-2", children: [
251
- /* @__PURE__ */ e("button", { className: "bg-card text-foreground text-sm px-3 py-1 border rounded ml-3 cursor-pointer", onClick: C, children: /* @__PURE__ */ e(S, { value: "button.cancel", parentKey: "common" }) }),
252
- /* @__PURE__ */ e("button", { className: "bg-primary text-white text-sm px-3 py-1 rounded ml-3 cursor-pointer", onClick: N, children: /* @__PURE__ */ e(S, { value: "button.confirm", parentKey: "common" }) })
320
+ /* @__PURE__ */ jsx("div", { className: "shrink-0", children: /* @__PURE__ */ jsx(Checkbox, { className: twMerge("w-4 h-4 cursor-pointer border border-gray-300 rounded-sm", selectedToken.some((token2) => token2.tokenAddress === item.tokenAddress) ? "bg-primary" : "bg-card"), checked: selectedToken.some((token2) => token2.tokenAddress === item.tokenAddress) }) })
321
+ ] }, index)) }),
322
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end items-center mt-2", children: [
323
+ /* @__PURE__ */ jsx("button", { className: "bg-card text-foreground text-sm px-3 py-1 border rounded ml-3 cursor-pointer", onClick: handleCancel, children: /* @__PURE__ */ jsx(Translation, { value: "button.cancel", parentKey: "common" }) }),
324
+ /* @__PURE__ */ jsx("button", { className: "bg-primary text-white text-sm px-3 py-1 rounded ml-3 cursor-pointer", onClick: handleConfirm, children: /* @__PURE__ */ jsx(Translation, { value: "button.confirm", parentKey: "common" }) })
253
325
  ] })
254
326
  ] })
255
327
  ] });
256
328
  }
257
- function De({ onChange: a }) {
258
- const { chain: i = "" } = ee(), c = J("common.filter.amount"), [m, A] = w(!1), [y, k] = w(""), [b, g] = w([]), [d, f] = w([]), C = () => {
259
- a([]), k(""), f([]), A(!1);
260
- }, N = () => {
261
- a(d), A(!1);
262
- }, R = (n) => {
263
- d.some((o) => o.tokenAddress === n.tokenAddress) ? f(d.filter((o) => o.tokenAddress !== n.tokenAddress)) : f([...d, n]);
264
- }, B = async () => {
265
- var o;
266
- const n = await Se(y);
267
- g(((o = n == null ? void 0 : n.data) == null ? void 0 : o.content) || []);
329
+ function TokenSearch({ onChange }) {
330
+ const { chain = "" } = useParams();
331
+ const t = useTranslations("common.filter.amount");
332
+ const [open, setOpen] = useState(false);
333
+ const [token, setToken] = useState("");
334
+ const [tokenList, setTokenList] = useState([]);
335
+ const [selectedToken, setSelectedToken] = useState([]);
336
+ const handleCancel = () => {
337
+ onChange([]);
338
+ setToken("");
339
+ setSelectedToken([]);
340
+ setOpen(false);
341
+ };
342
+ const handleConfirm = () => {
343
+ onChange(selectedToken);
344
+ setOpen(false);
345
+ };
346
+ const tokenChange = (item) => {
347
+ if (selectedToken.some((token2) => token2.tokenAddress === item.tokenAddress)) {
348
+ setSelectedToken(selectedToken.filter((token2) => token2.tokenAddress !== item.tokenAddress));
349
+ } else {
350
+ setSelectedToken([...selectedToken, item]);
351
+ }
352
+ };
353
+ const loadData = async () => {
354
+ const res = await searchToken(token);
355
+ setTokenList(res?.data?.content || []);
268
356
  };
269
- return z(() => {
270
- B();
271
- }, [i, y]), /* @__PURE__ */ l(O, { open: m, onOpenChange: A, children: [
272
- /* @__PURE__ */ e(U, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "w-[16px] h-[16px] flex items-center justify-center bg-[#000] rounded-sm cursor-pointer", children: /* @__PURE__ */ e(D, { src: H, width: 12, height: 12, objectFit: "contain" }) }) }),
273
- /* @__PURE__ */ l(Q, { className: "py-5 bg-card", children: [
274
- /* @__PURE__ */ l("div", { className: "w-full h-full bg-card", children: [
275
- /* @__PURE__ */ l("div", { className: "flex flex-row items-center justify-between h-9", children: [
276
- /* @__PURE__ */ e("span", { className: "text-base text-foreground", children: /* @__PURE__ */ e(S, { value: "label", parentKey: "common.filter.token" }) }),
277
- /* @__PURE__ */ e("div", { className: "w-4 h-4 text-foreground text-sm cursor-pointer flex items-center justify-center", onClick: () => C(), children: /* @__PURE__ */ e(W, { className: "w-4 h-4 text-foreground" }) })
357
+ useEffect(() => {
358
+ loadData();
359
+ }, [chain, token]);
360
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
361
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "w-[16px] h-[16px] flex items-center justify-center bg-[#000] rounded-sm cursor-pointer", children: /* @__PURE__ */ jsx(ImageBar, { src: TokenIcon, width: 12, height: 12, objectFit: "contain" }) }) }),
362
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "py-5 bg-card", children: [
363
+ /* @__PURE__ */ jsxs("div", { className: "w-full h-full bg-card", children: [
364
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center justify-between h-9", children: [
365
+ /* @__PURE__ */ jsx("span", { className: "text-base text-foreground", children: /* @__PURE__ */ jsx(Translation, { value: "label", parentKey: "common.filter.token" }) }),
366
+ /* @__PURE__ */ jsx("div", { className: "w-4 h-4 text-foreground text-sm cursor-pointer flex items-center justify-center", onClick: () => handleCancel(), children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4 text-foreground" }) })
278
367
  ] }),
279
- /* @__PURE__ */ l("div", { className: "w-full relative bg-card text-sm py-3", children: [
280
- /* @__PURE__ */ e(V, { className: "w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2" }),
281
- /* @__PURE__ */ e("input", { type: "text", placeholder: c("label"), className: "pl-6 w-full h-full bg-card text-sm border border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: y, onChange: (n) => k(n.target.value) })
368
+ /* @__PURE__ */ jsxs("div", { className: "w-full relative bg-card text-sm py-3", children: [
369
+ /* @__PURE__ */ jsx(Search, { className: "w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2" }),
370
+ /* @__PURE__ */ jsx("input", { type: "text", placeholder: t("label"), className: "pl-6 w-full h-full bg-card text-sm border border-gray-300 rounded p-2 my-2 focus-visible:outline-primary placeholder:text-gray-400", value: token, onChange: (e) => setToken(e.target.value) })
282
371
  ] })
283
372
  ] }),
284
- /* @__PURE__ */ e("ul", { className: "max-h-50 min-h-25 overflow-y-auto overflow-x-hidden w-full", children: b == null ? void 0 : b.map((n, o) => /* @__PURE__ */ l("li", { className: "flex h-10 flex-row items-center gap-3 hover:bg-background hover:rounded-sm p-2 cursor-pointer overflow-hidden", onClick: () => R(n), children: [
285
- /* @__PURE__ */ e(D, { src: n.iconUrl, objectFit: "contain", alt: n.tokenName, className: "rounded-full w-4 h-4 min-w-4 min-h-4 flex-shrink-0" }),
286
- /* @__PURE__ */ e("div", { className: "text-sm text-foreground text-left truncate min-w-0 flex-1 overflow-hidden", children: n.tokenName }),
287
- /* @__PURE__ */ e("div", { className: "shrink-0", children: /* @__PURE__ */ e(te, { className: v("w-4 h-4 cursor-pointer border border-gray-300 rounded-sm", d.some((h) => h.tokenAddress === n.tokenAddress) ? "bg-primary" : "bg-white"), checked: d.some((h) => h.tokenAddress === n.tokenAddress) }) })
288
- ] }, o)) }),
289
- /* @__PURE__ */ l("div", { className: "flex justify-end items-center mt-2", children: [
290
- /* @__PURE__ */ e("button", { className: "bg-card text-foreground text-sm px-3 py-1 border rounded ml-3 cursor-pointer", onClick: C, children: /* @__PURE__ */ e(S, { value: "button.cancel", parentKey: "common" }) }),
291
- /* @__PURE__ */ e("button", { className: "bg-primary text-white text-sm px-3 py-1 rounded ml-3 cursor-pointer", onClick: N, children: /* @__PURE__ */ e(S, { value: "button.confirm", parentKey: "common" }) })
373
+ /* @__PURE__ */ jsx("ul", { className: "max-h-50 min-h-25 overflow-y-auto overflow-x-hidden w-full", children: tokenList?.map((item, index) => /* @__PURE__ */ jsxs("li", { className: "flex h-10 flex-row items-center gap-3 hover:bg-background hover:rounded-sm p-2 cursor-pointer overflow-hidden", onClick: () => tokenChange(item), children: [
374
+ /* @__PURE__ */ jsx(ImageBar, { src: item.iconUrl, objectFit: "contain", alt: item.tokenName, className: "rounded-full w-4 h-4 min-w-4 min-h-4 flex-shrink-0" }),
375
+ /* @__PURE__ */ jsx("div", { className: "text-sm text-foreground text-left truncate min-w-0 flex-1 overflow-hidden", children: item.tokenName }),
376
+ /* @__PURE__ */ jsx("div", { className: "shrink-0", children: /* @__PURE__ */ jsx(Checkbox, { className: twMerge("w-4 h-4 cursor-pointer border border-gray-300 rounded-sm", selectedToken.some((token2) => token2.tokenAddress === item.tokenAddress) ? "bg-primary" : "bg-white"), checked: selectedToken.some((token2) => token2.tokenAddress === item.tokenAddress) }) })
377
+ ] }, index)) }),
378
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end items-center mt-2", children: [
379
+ /* @__PURE__ */ jsx("button", { className: "bg-card text-foreground text-sm px-3 py-1 border rounded ml-3 cursor-pointer", onClick: handleCancel, children: /* @__PURE__ */ jsx(Translation, { value: "button.cancel", parentKey: "common" }) }),
380
+ /* @__PURE__ */ jsx("button", { className: "bg-primary text-white text-sm px-3 py-1 rounded ml-3 cursor-pointer", onClick: handleConfirm, children: /* @__PURE__ */ jsx(Translation, { value: "button.confirm", parentKey: "common" }) })
292
381
  ] })
293
382
  ] })
294
383
  ] });
295
384
  }
296
- const Pe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAhCAYAAABX5MJvAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHtSURBVHgB7ZfBalNBFIb/M7cmaBGuT2BcCNZVHsG+QWNw3Qw00qyMT5DbJ9Buiujipnsl+gZ5A3EjLu8bNIIVzSVzOhNaKGnTe86EQhf5IARyD8M388/cMwHW3CEIK/Bs/6RhTG3kh2n6T/bz6P4BIoiWaPRP0gf/69/9CI2L35ybbf/68HAMJQaRbJb1wWWB+WAmyYMclERJbPVOd5jRv+ZRw69ODiVqibAPCPRuaQFhZ6v3tw8Fagmie9liDFdrMAiyuA2J5/t/OkRmV1CaJiSPRSwxnxmZgbSeCS+ksYgl5jOriGERaSwiiRBDmBn0pMbUR1VFIgmW7YNlNJ92p02sKkHkfiASBopy87S4qWYDAmq1MptOaxPv/BhKqJwdFkePJlgjQNRF83yUug284ZnuiAZKxkHPtgqsKvHp+POQEH1CJon7/cRau3RfyE4Hk3pDXiL9h/TG9i57TzC+IZ6iKg6RRNe233uTMSIoHW1X1Yh7R8nG+i/VeWdw5aYMqO6YH/MvHWNI1qL9yu112pWrEFDdJ17b9tA3kq+C0uJ85USob1YJIwxeVJRlkhiiJaxtTdjNls+Sabi3+/IYCqJu2137agzHh9c8KsIbEkqi/3ckMBmuxqKKYWWJEItz1DoX8RHxW20MaxY5AxD/nDkC92cTAAAAAElFTkSuQmCC", Fe = (a) => a == null ? "" : typeof a == "object" ? JSON.stringify(a) : a, ct = (a) => {
297
- const i = {
385
+ const SortIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAhCAYAAABX5MJvAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHtSURBVHgB7ZfBalNBFIb/M7cmaBGuT2BcCNZVHsG+QWNw3Qw00qyMT5DbJ9Buiujipnsl+gZ5A3EjLu8bNIIVzSVzOhNaKGnTe86EQhf5IARyD8M388/cMwHW3CEIK/Bs/6RhTG3kh2n6T/bz6P4BIoiWaPRP0gf/69/9CI2L35ybbf/68HAMJQaRbJb1wWWB+WAmyYMclERJbPVOd5jRv+ZRw69ODiVqibAPCPRuaQFhZ6v3tw8Fagmie9liDFdrMAiyuA2J5/t/OkRmV1CaJiSPRSwxnxmZgbSeCS+ksYgl5jOriGERaSwiiRBDmBn0pMbUR1VFIgmW7YNlNJ92p02sKkHkfiASBopy87S4qWYDAmq1MptOaxPv/BhKqJwdFkePJlgjQNRF83yUug284ZnuiAZKxkHPtgqsKvHp+POQEH1CJon7/cRau3RfyE4Hk3pDXiL9h/TG9i57TzC+IZ6iKg6RRNe233uTMSIoHW1X1Yh7R8nG+i/VeWdw5aYMqO6YH/MvHWNI1qL9yu112pWrEFDdJ17b9tA3kq+C0uJ85USob1YJIwxeVJRlkhiiJaxtTdjNls+Sabi3+/IYCqJu2137agzHh9c8KsIbEkqi/3ckMBmuxqKKYWWJEItz1DoX8RHxW20MaxY5AxD/nDkC92cTAAAAAElFTkSuQmCC";
386
+ const formatValue = (value) => {
387
+ if (value === null || value === void 0) {
388
+ return "";
389
+ }
390
+ if (typeof value === "object") {
391
+ return JSON.stringify(value);
392
+ }
393
+ return value;
394
+ };
395
+ const formatFilterValue = (filterValues) => {
396
+ const obj = {
298
397
  filters: {}
299
398
  };
300
- return Object.keys(a).forEach((c) => {
301
- c === "timestamp" ? (i.filters.startTime = a.timestamp.start, i.filters.endTime = a.timestamp.end) : c === "fromAddress" ? i.filters.fromAddress = a.fromAddress.address : c === "toAddress" ? i.filters.toAddress = a.toAddress.address : c === "valueUsd" ? (i.filters.minValueUsd = a.valueUsd.min, i.filters.maxValueUsd = a.valueUsd.max) : c === "amount" ? (i.filters.minAmount = a.amount.min, i.filters.maxAmount = a.amount.max) : c === "token" ? i.filters.tokenList = a.token.map((m) => m.tokenAddress) : c === "tokenSearch" ? i.filters.tokenList = a.tokenSearch.map((m) => m.tokenAddress) : c === "inputAmount" ? (i.filters.minInputAmount = a.inputAmount.min, i.filters.maxInputAmount = a.inputAmount.max) : c === "outputAmount" ? (i.filters.minOutputAmount = a.outputAmount.min, i.filters.maxOutputAmount = a.outputAmount.max) : c === "fee" && (i.filters.minFee = a.fee.min, i.filters.maxFee = a.fee.max);
302
- }), i.filters;
399
+ Object.keys(filterValues).forEach((key) => {
400
+ if (key === "timestamp") {
401
+ obj.filters.startTime = filterValues.timestamp.start;
402
+ obj.filters.endTime = filterValues.timestamp.end;
403
+ } else if (key === "fromAddress") {
404
+ obj.filters.fromAddress = filterValues.fromAddress.address;
405
+ } else if (key === "toAddress") {
406
+ obj.filters.toAddress = filterValues.toAddress.address;
407
+ } else if (key === "valueUsd") {
408
+ obj.filters.minValueUsd = filterValues.valueUsd.min;
409
+ obj.filters.maxValueUsd = filterValues.valueUsd.max;
410
+ } else if (key === "amount") {
411
+ obj.filters.minAmount = filterValues.amount.min;
412
+ obj.filters.maxAmount = filterValues.amount.max;
413
+ } else if (key === "token") {
414
+ obj.filters.tokenList = filterValues.token.map((item) => item.tokenAddress);
415
+ } else if (key === "tokenSearch") {
416
+ obj.filters.tokenList = filterValues.tokenSearch.map((item) => item.tokenAddress);
417
+ } else if (key === "inputAmount") {
418
+ obj.filters.minInputAmount = filterValues.inputAmount.min;
419
+ obj.filters.maxInputAmount = filterValues.inputAmount.max;
420
+ } else if (key === "outputAmount") {
421
+ obj.filters.minOutputAmount = filterValues.outputAmount.min;
422
+ obj.filters.maxOutputAmount = filterValues.outputAmount.max;
423
+ } else if (key === "fee") {
424
+ obj.filters.minFee = filterValues.fee.min;
425
+ obj.filters.maxFee = filterValues.fee.max;
426
+ }
427
+ });
428
+ return obj.filters;
303
429
  };
304
- function dt({ data: a, columns: i, headerClassName: c, bodyClassName: m, rowClassName: A, tableClassName: y, showHeader: k = !0, renderChildren: b, onFilterChange: g, loading: d, onSortChange: f, defaultOrder: C, defaultSortKey: N, emptyClassName: R, ...B }) {
305
- const [n, o] = w(null), [h, p] = w({}), [x, T] = w(N || null), [L, re] = w(C || null), I = (t, r) => {
306
- o((s) => ({
307
- ...s,
308
- [t]: r
430
+ function CustomTable({ data, columns, headerClassName, bodyClassName, rowClassName, tableClassName, showHeader = true, renderChildren, onFilterChange, loading, onSortChange, defaultOrder, defaultSortKey, emptyClassName, ...props }) {
431
+ const [filterValues, setFilterValues] = useState(null);
432
+ const [resetKey, setResetKey] = useState({});
433
+ const [sortKey, setSortKey] = useState(defaultSortKey || null);
434
+ const [sortOrder, setSortOrder] = useState(defaultOrder || null);
435
+ const handleFilterChange = (columnKey, value) => {
436
+ setFilterValues((prev) => ({
437
+ ...prev,
438
+ [columnKey]: value
309
439
  }));
310
- }, P = (t) => {
311
- o((r) => {
312
- const s = { ...r };
313
- return delete s[t], s;
314
- }), p((r) => ({
315
- ...r,
316
- [t]: (r[t] || 0) + 1
440
+ };
441
+ const removeFilter = (columnKey) => {
442
+ setFilterValues((prev) => {
443
+ const newValues = { ...prev };
444
+ delete newValues[columnKey];
445
+ return newValues;
446
+ });
447
+ setResetKey((prev) => ({
448
+ ...prev,
449
+ [columnKey]: (prev[columnKey] || 0) + 1
317
450
  }));
318
- }, ne = (t) => {
319
- switch (t.filter) {
451
+ };
452
+ const renderFilter = (column) => {
453
+ switch (column.filter) {
320
454
  case "timeRange":
321
- return /* @__PURE__ */ e(ve, { onChange: (r, s) => {
322
- var u, j;
323
- r && s ? (I(t.key, { start: r, end: s }), (j = (u = t.filterProps) == null ? void 0 : u.onChange) == null || j.call(u, { start: r, end: s })) : P(t.key);
324
- } }, h[t.key]);
455
+ return /* @__PURE__ */ jsx(DatePickerWithRange, { onChange: (start, end) => {
456
+ if (start && end) {
457
+ handleFilterChange(column.key, { start, end });
458
+ column.filterProps?.onChange?.({ start, end });
459
+ } else {
460
+ removeFilter(column.key);
461
+ }
462
+ } }, resetKey[column.key]);
325
463
  case "address":
326
- return /* @__PURE__ */ e(Re, { onChange: (r) => {
327
- var s, u;
328
- r ? (I(t.key, { address: r }), (u = (s = t.filterProps) == null ? void 0 : s.onChange) == null || u.call(s, { address: r })) : P(t.key);
329
- } }, h[t.key]);
464
+ return /* @__PURE__ */ jsx(Address, { onChange: (address) => {
465
+ if (address) {
466
+ handleFilterChange(column.key, { address });
467
+ column.filterProps?.onChange?.({ address });
468
+ } else {
469
+ removeFilter(column.key);
470
+ }
471
+ } }, resetKey[column.key]);
330
472
  case "amount":
331
- return /* @__PURE__ */ e(je, { filterKey: t.key, onChange: (r, s) => {
332
- var j, G;
333
- const u = {};
334
- r && (u.min = r), s && (u.max = s), Object.keys(u).length > 0 ? (I(t.key, u), (G = (j = t.filterProps) == null ? void 0 : j.onChange) == null || G.call(j, u)) : P(t.key);
335
- } }, h[t.key]);
473
+ return /* @__PURE__ */ jsx(Amount, { filterKey: column.key, onChange: (min, max) => {
474
+ const obj = {};
475
+ if (min) {
476
+ obj.min = min;
477
+ }
478
+ if (max) {
479
+ obj.max = max;
480
+ }
481
+ if (Object.keys(obj).length > 0) {
482
+ handleFilterChange(column.key, obj);
483
+ column.filterProps?.onChange?.(obj);
484
+ } else {
485
+ removeFilter(column.key);
486
+ }
487
+ } }, resetKey[column.key]);
336
488
  case "token":
337
- return /* @__PURE__ */ e(Te, { onChange: (r) => {
338
- var s, u;
339
- r ? (I(t.key, r), (u = (s = t.filterProps) == null ? void 0 : s.onChange) == null || u.call(s, r)) : P(t.key);
340
- } }, h[t.key]);
489
+ return /* @__PURE__ */ jsx(Token, { onChange: (token) => {
490
+ if (token) {
491
+ handleFilterChange(column.key, token);
492
+ column.filterProps?.onChange?.(token);
493
+ } else {
494
+ removeFilter(column.key);
495
+ }
496
+ } }, resetKey[column.key]);
341
497
  case "tokenSearch":
342
- return /* @__PURE__ */ e(De, { onChange: (r) => {
343
- var s, u;
344
- r ? (I(t.key, r), (u = (s = t.filterProps) == null ? void 0 : s.onChange) == null || u.call(s, r)) : P(t.key);
345
- } }, h[t.key]);
498
+ return /* @__PURE__ */ jsx(TokenSearch, { onChange: (token) => {
499
+ if (token) {
500
+ handleFilterChange(column.key, token);
501
+ column.filterProps?.onChange?.(token);
502
+ } else {
503
+ removeFilter(column.key);
504
+ }
505
+ } }, resetKey[column.key]);
346
506
  default:
347
507
  return null;
348
508
  }
349
- }, se = (t) => t.min && !t.max ? `≥ ${t.min}` : !t.min && t.max ? `≤ ${t.max}` : `${t.min} - ${t.max}`, ae = (t, r) => {
350
- if (!r) return null;
351
- switch (t.filter) {
509
+ };
510
+ const renderAmount = (value) => {
511
+ if (value.min && !value.max) return `≥ ${value.min}`;
512
+ if (!value.min && value.max) return `≤ ${value.max}`;
513
+ return `${value.min} - ${value.max}`;
514
+ };
515
+ const renderFilterValue = (column, value) => {
516
+ if (!value) return null;
517
+ switch (column.filter) {
352
518
  case "timeRange":
353
- return `${M(r.start * 1e3).format("YYYY-MM-DD") || ""} - ${M(r.end * 1e3).format("YYYY-MM-DD") || ""}`;
519
+ return `${dayjs(value.start * 1e3).format("YYYY-MM-DD") || ""} - ${dayjs(value.end * 1e3).format("YYYY-MM-DD") || ""}`;
354
520
  case "address":
355
- return r.address;
521
+ return value.address;
356
522
  case "amount":
357
- return se(r);
523
+ return renderAmount(value);
358
524
  case "token":
359
- return r.map((s) => s.tokenName).join(", ");
525
+ return value.map((item) => item.tokenName).join(", ");
360
526
  case "tokenSearch":
361
- return r.map((s) => s.tokenName).join(", ");
527
+ return value.map((item) => item.tokenName).join(", ");
362
528
  default:
363
529
  return null;
364
530
  }
365
- }, oe = (t) => {
366
- const r = L === "asc" ? "desc" : "asc";
367
- T(t), re(r), f == null || f(t, r);
368
- }, F = i.filter((t) => !t.hidden), le = F.some((t) => t.filter);
369
- return z(() => {
370
- n !== null && (g == null || g(n));
371
- }, [n]), /* @__PURE__ */ l("div", { className: "overflow-auto min-w-full relative", ...B, children: [
372
- /* @__PURE__ */ e(ke, { loading: d }),
373
- le && n && Object.keys(n).length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-row gap-3 flex-nowrap overflow-x-auto scrollbar-hide pb-3", children: F.map((t) => {
374
- if (!n) return null;
375
- const r = n == null ? void 0 : n[t.key];
376
- return !r || Array.isArray(r) && r.length === 0 ? null : /* @__PURE__ */ l("div", { className: "flex items-center flex-nowrap gap-2 bg-card px-3 py-1 rounded-full border-1 border-border max-w-full min-w-0 overflow-hidden", children: [
377
- /* @__PURE__ */ l("div", { className: "text-sm text-muted-foreground shrink-0", children: [
378
- t.label,
531
+ };
532
+ const handleSort = (key) => {
533
+ const so = sortOrder === "asc" ? "desc" : "asc";
534
+ setSortKey(key);
535
+ setSortOrder(so);
536
+ onSortChange?.(key, so);
537
+ };
538
+ const showColumn = columns.filter((column) => !column.hidden);
539
+ const showFilter = showColumn.some((column) => column.filter);
540
+ useEffect(() => {
541
+ if (filterValues !== null) {
542
+ onFilterChange?.(filterValues);
543
+ }
544
+ }, [filterValues]);
545
+ return /* @__PURE__ */ jsxs("div", { className: "overflow-auto min-w-full relative", ...props, children: [
546
+ /* @__PURE__ */ jsx(Loading, { loading }),
547
+ showFilter && filterValues && Object.keys(filterValues).length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-row gap-3 flex-nowrap overflow-x-auto scrollbar-hide pb-3", children: showColumn.map((column) => {
548
+ if (!filterValues) return null;
549
+ const filterValue = filterValues?.[column.key];
550
+ if (!filterValue) return null;
551
+ if (Array.isArray(filterValue) && filterValue.length === 0) return null;
552
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center flex-nowrap gap-2 bg-card px-3 py-1 rounded-full border-1 border-border max-w-full min-w-0 overflow-hidden", children: [
553
+ /* @__PURE__ */ jsxs("div", { className: "text-sm text-muted-foreground shrink-0", children: [
554
+ column.label,
379
555
  ":"
380
556
  ] }),
381
- /* @__PURE__ */ e("div", { className: "text-sm flex-1 min-w-0", children: /* @__PURE__ */ e("div", { className: "min-w-0 truncate", children: ae(t, r) }) }),
382
- /* @__PURE__ */ e(
557
+ /* @__PURE__ */ jsx("div", { className: "text-sm flex-1 min-w-0", children: /* @__PURE__ */ jsx("div", { className: "min-w-0 truncate", children: renderFilterValue(column, filterValue) }) }),
558
+ /* @__PURE__ */ jsx(
383
559
  "button",
384
560
  {
385
- onClick: () => P(t.key),
561
+ onClick: () => removeFilter(column.key),
386
562
  className: "shrink-0 hover:bg-background rounded-full p-1",
387
- children: /* @__PURE__ */ e(W, { className: "w-3 h-3 cursor-pointer" })
563
+ children: /* @__PURE__ */ jsx(X, { className: "w-3 h-3 cursor-pointer" })
388
564
  }
389
565
  )
390
- ] }, t.key);
566
+ ] }, column.key);
391
567
  }) }),
392
- /* @__PURE__ */ l(ie, { className: v("", y), children: [
393
- k && /* @__PURE__ */ e(ce, { className: v("border-b border-border", c), children: /* @__PURE__ */ e(E, { className: "border-b-0 hover:bg-transparent", children: F.map((t, r) => {
394
- var s;
395
- return /* @__PURE__ */ e(de, { className: v("text-left", "whitespace-nowrap"), style: { width: t.width }, children: /* @__PURE__ */ l("div", { className: v("flex items-center gap-1 min-w-fit w-full whitespace-nowrap", t.align === "center" && "justify-center", t.align === "right" && "justify-end", (s = t.className) == null ? void 0 : s.call(t, t, r)), children: [
396
- t.label,
397
- t.filter && ne(t),
398
- t.sort && /* @__PURE__ */ e(D, { src: Pe, alt: "sort", className: v("w-4 h-4 cursor-pointer", x === t.key && "opacity-100", L === "desc" && "rotate-180"), onClick: () => oe(t.key) })
399
- ] }) }, r);
400
- }) }) }),
401
- /* @__PURE__ */ e(me, { className: v("[&_tr:last-child]:border-b-0", m), children: (a == null ? void 0 : a.length) > 0 ? a.map((t, r) => /* @__PURE__ */ l(he.Fragment, { children: [
402
- /* @__PURE__ */ e(E, { className: v("border-r-0 border-l-0 border-t-0 border-b border-border hover:bg-background", A), children: F.map((s, u) => {
403
- var j;
404
- return /* @__PURE__ */ e(K, { className: v("text-left min-w-fit py-4", s.align === "center" && "text-center", s.align === "right" && "text-right", "whitespace-nowrap", (j = s.className) == null ? void 0 : j.call(s, s, r, a[r])), style: { width: s.width }, children: s.render ? s.render(t[s.key], t, r) : Fe(t[s.key]) }, u);
405
- }) }, r),
406
- b && /* @__PURE__ */ e(E, { className: "border-b-0", children: /* @__PURE__ */ e(K, { colSpan: F.length, className: "p-0", children: b(t, r) }) })
407
- ] }, r)) : /* @__PURE__ */ e(E, { className: "hover:bg-transparent data-[state=selected]:bg-transparent", children: /* @__PURE__ */ e(K, { colSpan: F.length, className: "w-full text-center", children: /* @__PURE__ */ e(ye, { className: v("w-full h-38", R) }) }) }) })
568
+ /* @__PURE__ */ jsxs(Table, { className: twMerge("", tableClassName), children: [
569
+ showHeader && /* @__PURE__ */ jsx(TableHeader, { className: twMerge("border-b border-border", headerClassName), children: /* @__PURE__ */ jsx(TableRow, { className: "border-b-0 hover:bg-transparent", children: showColumn.map((column, index) => /* @__PURE__ */ jsx(TableHead, { className: twMerge("text-left", "whitespace-nowrap"), style: { width: column.width }, children: /* @__PURE__ */ jsxs("div", { className: twMerge("flex items-center gap-1 min-w-fit w-full whitespace-nowrap", column.align === "center" && "justify-center", column.align === "right" && "justify-end", column.className?.(column, index)), children: [
570
+ column.label,
571
+ column.filter && renderFilter(column),
572
+ column.sort && /* @__PURE__ */ jsx(ImageBar, { src: SortIcon, alt: "sort", className: twMerge("w-4 h-4 cursor-pointer", sortKey === column.key && "opacity-100", sortOrder === "desc" && "rotate-180"), onClick: () => handleSort(column.key) })
573
+ ] }) }, index)) }) }),
574
+ /* @__PURE__ */ jsx(TableBody, { className: twMerge("[&_tr:last-child]:border-b-0", bodyClassName), children: data?.length > 0 ? data.map((row, index) => /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
575
+ /* @__PURE__ */ jsx(TableRow, { className: twMerge("border-r-0 border-l-0 border-t-0 border-b border-border hover:bg-background", rowClassName), children: showColumn.map((column, columnIndex) => /* @__PURE__ */ jsx(TableCell, { className: twMerge("text-left min-w-fit py-4", column.align === "center" && "text-center", column.align === "right" && "text-right", "whitespace-nowrap", column.className?.(column, index, data[index])), style: { width: column.width }, children: column.render ? column.render(row[column.key], row, index) : formatValue(row[column.key]) }, columnIndex)) }, index),
576
+ renderChildren && /* @__PURE__ */ jsx(TableRow, { className: "border-b-0", children: /* @__PURE__ */ jsx(TableCell, { colSpan: showColumn.length, className: "p-0", children: renderChildren(row, index) }) })
577
+ ] }, index)) : /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent data-[state=selected]:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: showColumn.length, className: "w-full text-center", children: /* @__PURE__ */ jsx(Empty, { className: twMerge("w-full h-38", emptyClassName) }) }) }) })
408
578
  ] })
409
579
  ] });
410
580
  }
411
581
  export {
412
- dt as default,
413
- ct as formatFilterValue
582
+ CustomTable as default,
583
+ formatFilterValue
414
584
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xchain/table",
3
- "version": "1.1.0-beta.18",
3
+ "version": "1.1.0-beta.19",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -17,31 +17,47 @@
17
17
  "dist",
18
18
  "!**/*.tsbuildinfo"
19
19
  ],
20
- "devDependencies": {
21
- "rollup-plugin-preserve-use-client": "3.0.1"
22
- },
23
- "dependencies": {
24
- "react": "19.1.1",
25
- "react-dom": "19.1.1",
26
- "tailwind-merge": "3.3.1",
27
- "lucide-react": "0.539.0",
20
+ "peerDependencies": {
21
+ "@radix-ui/react-slider": "1.3.6",
22
+ "ahooks": "3.9.5",
23
+ "antd": "6.1.1",
24
+ "date-fns": "4.1.0",
28
25
  "dayjs": "1.11.19",
29
- "next-intl": "4.8.2",
26
+ "lucide-react": "0.539.0",
30
27
  "next": "16.1.6",
28
+ "next-intl": "4.8.2",
29
+ "react": "19.1.1",
30
+ "react-dom": "19.1.1",
31
+ "tailwind-merge": "3.3.1"
32
+ },
33
+ "devDependencies": {
31
34
  "@0xchain/next-themes": "1.0.0",
32
- "date-fns": "4.1.0",
33
- "antd": "6.1.1",
34
- "ahooks": "3.9.5",
35
35
  "@radix-ui/react-slider": "1.3.6",
36
- "@0xchain/ui": "1.1.0-beta.18",
37
- "@0xchain/empty": "1.1.0-beta.18",
38
- "@0xchain/loading": "1.1.0-beta.18",
39
- "@0xchain/image": "1.1.0-beta.18",
40
- "@0xchain/i18n": "1.1.0-beta.18",
41
- "@0xchain/iconfont": "1.1.0-beta.18",
42
- "@0xchain/translation": "1.1.0-beta.18",
43
- "@0xchain/request": "1.1.0-beta.18",
44
- "@0xchain/number-like": "1.1.0-beta.18"
36
+ "ahooks": "3.9.5",
37
+ "antd": "6.1.1",
38
+ "date-fns": "4.1.0",
39
+ "dayjs": "1.11.19",
40
+ "lucide-react": "0.539.0",
41
+ "next": "16.1.6",
42
+ "next-intl": "4.8.2",
43
+ "react": "19.1.1",
44
+ "react-dom": "19.1.1",
45
+ "rollup-plugin-preserve-use-client": "3.0.1",
46
+ "tailwind-merge": "3.3.1"
47
+ },
48
+ "dependencies": {
49
+ "@0xchain/ui": "1.1.0-beta.19",
50
+ "@0xchain/image": "1.1.0-beta.19",
51
+ "@0xchain/translation": "1.1.0-beta.19",
52
+ "@0xchain/request": "1.1.0-beta.19",
53
+ "@0xchain/empty": "1.1.0-beta.19",
54
+ "@0xchain/loading": "1.1.0-beta.19",
55
+ "@0xchain/number-like": "1.1.0-beta.19"
56
+ },
57
+ "nx": {
58
+ "tags": [
59
+ "type:ui"
60
+ ]
45
61
  },
46
62
  "publishConfig": {
47
63
  "access": "public"