bj-web-components 0.2.8 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +29 -15
- package/dist/style.css +1 -1
- package/dist/web/CategoryDropdown/CategoryDropdown.js +1 -0
- package/dist/web/CategoryDropdown/CategoryDropdown.mjs +260 -0
- package/dist/web/EmptyInputBox/EmptyInputBox.js +1 -0
- package/dist/web/EmptyInputBox/EmptyInputBox.mjs +74 -0
- package/dist/web/FileCard/FileCard.js +1 -0
- package/dist/web/FileCard/FileCard.mjs +128 -0
- package/dist/web/Icon/Icon.js +1 -0
- package/dist/web/Icon/Icon.mjs +10 -0
- package/dist/web/Input/Input.js +1 -0
- package/dist/web/Input/Input.mjs +173 -0
- package/dist/web/InputNumber/BInputNumber.js +1 -0
- package/dist/web/InputNumber/BInputNumber.mjs +204 -0
- package/dist/web/InputNumber/StepHandler.js +1 -0
- package/dist/web/InputNumber/StepHandler.mjs +64 -0
- package/dist/web/InputNumber/hooks/useCursor.js +1 -0
- package/dist/web/InputNumber/hooks/useCursor.mjs +39 -0
- package/dist/web/InputNumber/hooks/useFrame.js +1 -0
- package/dist/web/InputNumber/hooks/useFrame.mjs +10 -0
- package/dist/web/InputNumber/utils/decimal.js +1 -0
- package/dist/web/InputNumber/utils/decimal.mjs +119 -0
- package/dist/web/Modal/Modal.js +1 -0
- package/dist/web/Modal/Modal.mjs +82 -0
- package/dist/web/Pagination/Pagination.js +1 -0
- package/dist/web/Pagination/Pagination.mjs +253 -0
- package/dist/web/ProductField/ProductField.js +1 -0
- package/dist/web/ProductField/ProductField.mjs +226 -0
- package/dist/web/ProductField/arrow-up.svg.js +1 -0
- package/dist/web/ProductField/arrow-up.svg.mjs +4 -0
- package/dist/web/ProductField/checkbox-no.svg.js +1 -0
- package/dist/web/ProductField/checkbox-no.svg.mjs +4 -0
- package/dist/web/ProductField/checkbox-ok.svg.js +1 -0
- package/dist/web/ProductField/checkbox-ok.svg.mjs +4 -0
- package/dist/web/ProductField/no_data_light.png.js +1 -0
- package/dist/web/ProductField/no_data_light.png.mjs +4 -0
- package/dist/web/ProductField/search.svg.js +1 -0
- package/dist/web/ProductField/search.svg.mjs +4 -0
- package/dist/web/ProductField/sort.svg.js +1 -0
- package/dist/web/ProductField/sort.svg.mjs +4 -0
- package/dist/web/SkuInputCard/SkuInputCard.js +1 -0
- package/dist/web/SkuInputCard/SkuInputCard.mjs +238 -0
- package/dist/web/SkuInputCard/spin_loading_red.gif.js +1 -0
- package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +4 -0
- package/dist/web/Switch/Switch.js +1 -0
- package/dist/web/Switch/Switch.mjs +61 -0
- package/dist/web/Tooltip/ConfirmTooltip.js +1 -0
- package/dist/web/Tooltip/ConfirmTooltip.mjs +26 -0
- package/dist/web/Tooltip/ContentTooltip.js +1 -0
- package/dist/web/Tooltip/ContentTooltip.mjs +29 -0
- package/dist/web/Tooltip/ProgressTooltip.js +1 -0
- package/dist/web/Tooltip/ProgressTooltip.mjs +35 -0
- package/dist/web/Tooltip/TooltipWrapper.js +1 -0
- package/dist/web/Tooltip/TooltipWrapper.mjs +13 -0
- package/dist/web/Tooltip/useAutoPlacement.js +1 -0
- package/dist/web/Tooltip/useAutoPlacement.mjs +32 -0
- package/dist/web.js +1 -1
- package/dist/web.mjs +29 -15
- package/package.json +4 -2
- package/dist/BInputNumber-CCOxUWi5.mjs +0 -1964
- package/dist/BInputNumber-DCMCtHTu.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react");function c(){const e=t.useRef(0),r=()=>cancelAnimationFrame(e.current);return t.useEffect(()=>r,[]),n=>{r(),e.current=requestAnimationFrame(n)}}module.exports=c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function d(r){return!r&&r!==0&&!Number.isNaN(r)||!String(r).trim()}function N(r){let t=r.trim(),e=t.startsWith("-");e&&(t=t.slice(1)),t=t.replace(/(\.\d*[^0])0*$/,"$1").replace(/\.0*$/,"").replace(/^0+/,""),t.startsWith(".")&&(t=`0${t}`);const i=t||"0",u=i.split("."),m=u[0]||"0",s=u[1]||"0";m==="0"&&s==="0"&&(e=!1);const o=e?"-":"";return{negative:e,negativeStr:o,trimStr:i,integerStr:m,decimalStr:s,fullStr:`${o}${i}`}}function S(r){const t=String(r);return!Number.isNaN(Number(t))&&t.includes("e")}function a(r){const t=String(r);if(S(r)){const[,e="0"]=t.toLowerCase().split("e");return Math.max(0,-Number(e))}return t.includes(".")&&b(t)?t.length-t.indexOf(".")-1:0}function f(r){const t=String(r);return S(r)?r>Number.MAX_SAFE_INTEGER?String(Number.MAX_SAFE_INTEGER):r<Number.MIN_SAFE_INTEGER?String(Number.MIN_SAFE_INTEGER):N(r.toFixed(a(r))).fullStr:N(t).fullStr}function b(r){if(typeof r=="number")return!Number.isNaN(r);if(!r)return!1;const t=String(r);return/^\s*-?\d+(\.\d+)?\s*$/.test(t)||/^\s*-?\d+\.\s*$/.test(t)||/^\s*-?\.\d+\s*$/.test(t)}class n{constructor(t){if(this.origin="",d(t)){this.empty=!0;return}this.origin=String(t),this.number=Number(t)}negate(){return new n(-this.toNumber())}add(t){if(this.isInvalidate())return new n(t);const e=Number(t);if(Number.isNaN(e))return this;const i=this.number+e;if(i>Number.MAX_SAFE_INTEGER)return new n(Number.MAX_SAFE_INTEGER);if(i<Number.MIN_SAFE_INTEGER)return new n(Number.MIN_SAFE_INTEGER);const u=Math.max(a(this.number),a(e));return new n(i.toFixed(u))}isEmpty(){return!!this.empty}isNaN(){return Number.isNaN(this.number)}isInvalidate(){return this.isEmpty()||this.isNaN()}equals(t){return this.toNumber()===(t==null?void 0:t.toNumber())}lessEquals(t){return this.add(t.negate().toString()).toNumber()<=0}toNumber(){return this.number}toString(t=!0){return t?this.isInvalidate()?"":f(this.number):this.origin}}function E(r){return new n(r)}function g(r,t,e,i=!1){if(r==="")return"";const{negativeStr:u,integerStr:m,decimalStr:s}=N(r),o=`${t}${s}`,c=`${u}${m}`;if(e!==void 0&&e>=0){const l=Number(s[e]);if(l>=5&&!i){const h=E(r).add(`${u}0.${"0".repeat(e)}${10-l}`);return g(h.toString(),t,e,i)}return e===0?c:`${c}${t}${s.padEnd(e,"0").slice(0,e)}`}return o===".0"?c:`${c}${o}`}function $(r){const t=typeof r=="number"?f(r):N(String(r)).fullStr;return t.includes(".")?N(t.replace(/(\d)\.(\d)/g,"$1$2.")).fullStr:`${r}0`}exports.Decimal=n;exports.getDecimal=E;exports.getDecupleSteps=$;exports.getNumberPrecision=a;exports.isEmptyValue=d;exports.num2str=f;exports.toFixed=g;exports.trimNumber=N;exports.validateNumber=b;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
function b(r) {
|
|
2
|
+
return !r && r !== 0 && !Number.isNaN(r) || !String(r).trim();
|
|
3
|
+
}
|
|
4
|
+
function o(r) {
|
|
5
|
+
let t = r.trim(), e = t.startsWith("-");
|
|
6
|
+
e && (t = t.slice(1)), t = t.replace(/(\.\d*[^0])0*$/, "$1").replace(/\.0*$/, "").replace(/^0+/, ""), t.startsWith(".") && (t = `0${t}`);
|
|
7
|
+
const n = t || "0", i = n.split("."), m = i[0] || "0", s = i[1] || "0";
|
|
8
|
+
m === "0" && s === "0" && (e = !1);
|
|
9
|
+
const N = e ? "-" : "";
|
|
10
|
+
return {
|
|
11
|
+
negative: e,
|
|
12
|
+
negativeStr: N,
|
|
13
|
+
trimStr: n,
|
|
14
|
+
integerStr: m,
|
|
15
|
+
decimalStr: s,
|
|
16
|
+
fullStr: `${N}${n}`
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function S(r) {
|
|
20
|
+
const t = String(r);
|
|
21
|
+
return !Number.isNaN(Number(t)) && t.includes("e");
|
|
22
|
+
}
|
|
23
|
+
function f(r) {
|
|
24
|
+
const t = String(r);
|
|
25
|
+
if (S(r)) {
|
|
26
|
+
const [, e = "0"] = t.toLowerCase().split("e");
|
|
27
|
+
return Math.max(0, -Number(e));
|
|
28
|
+
}
|
|
29
|
+
return t.includes(".") && E(t) ? t.length - t.indexOf(".") - 1 : 0;
|
|
30
|
+
}
|
|
31
|
+
function d(r) {
|
|
32
|
+
const t = String(r);
|
|
33
|
+
return S(r) ? r > Number.MAX_SAFE_INTEGER ? String(Number.MAX_SAFE_INTEGER) : r < Number.MIN_SAFE_INTEGER ? String(Number.MIN_SAFE_INTEGER) : o(r.toFixed(f(r))).fullStr : o(t).fullStr;
|
|
34
|
+
}
|
|
35
|
+
function E(r) {
|
|
36
|
+
if (typeof r == "number")
|
|
37
|
+
return !Number.isNaN(r);
|
|
38
|
+
if (!r) return !1;
|
|
39
|
+
const t = String(r);
|
|
40
|
+
return /^\s*-?\d+(\.\d+)?\s*$/.test(t) || // 11.28
|
|
41
|
+
/^\s*-?\d+\.\s*$/.test(t) || // 1.
|
|
42
|
+
/^\s*-?\.\d+\s*$/.test(t);
|
|
43
|
+
}
|
|
44
|
+
class u {
|
|
45
|
+
constructor(t) {
|
|
46
|
+
if (this.origin = "", b(t)) {
|
|
47
|
+
this.empty = !0;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this.origin = String(t), this.number = Number(t);
|
|
51
|
+
}
|
|
52
|
+
negate() {
|
|
53
|
+
return new u(-this.toNumber());
|
|
54
|
+
}
|
|
55
|
+
add(t) {
|
|
56
|
+
if (this.isInvalidate()) return new u(t);
|
|
57
|
+
const e = Number(t);
|
|
58
|
+
if (Number.isNaN(e)) return this;
|
|
59
|
+
const n = this.number + e;
|
|
60
|
+
if (n > Number.MAX_SAFE_INTEGER) return new u(Number.MAX_SAFE_INTEGER);
|
|
61
|
+
if (n < Number.MIN_SAFE_INTEGER) return new u(Number.MIN_SAFE_INTEGER);
|
|
62
|
+
const i = Math.max(f(this.number), f(e));
|
|
63
|
+
return new u(n.toFixed(i));
|
|
64
|
+
}
|
|
65
|
+
isEmpty() {
|
|
66
|
+
return !!this.empty;
|
|
67
|
+
}
|
|
68
|
+
isNaN() {
|
|
69
|
+
return Number.isNaN(this.number);
|
|
70
|
+
}
|
|
71
|
+
isInvalidate() {
|
|
72
|
+
return this.isEmpty() || this.isNaN();
|
|
73
|
+
}
|
|
74
|
+
equals(t) {
|
|
75
|
+
return this.toNumber() === (t == null ? void 0 : t.toNumber());
|
|
76
|
+
}
|
|
77
|
+
lessEquals(t) {
|
|
78
|
+
return this.add(t.negate().toString()).toNumber() <= 0;
|
|
79
|
+
}
|
|
80
|
+
toNumber() {
|
|
81
|
+
return this.number;
|
|
82
|
+
}
|
|
83
|
+
toString(t = !0) {
|
|
84
|
+
return t ? this.isInvalidate() ? "" : d(this.number) : this.origin;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function h(r) {
|
|
88
|
+
return new u(r);
|
|
89
|
+
}
|
|
90
|
+
function g(r, t, e, n = !1) {
|
|
91
|
+
if (r === "") return "";
|
|
92
|
+
const { negativeStr: i, integerStr: m, decimalStr: s } = o(r), N = `${t}${s}`, c = `${i}${m}`;
|
|
93
|
+
if (e !== void 0 && e >= 0) {
|
|
94
|
+
const a = Number(s[e]);
|
|
95
|
+
if (a >= 5 && !n) {
|
|
96
|
+
const l = h(r).add(
|
|
97
|
+
`${i}0.${"0".repeat(e)}${10 - a}`
|
|
98
|
+
);
|
|
99
|
+
return g(l.toString(), t, e, n);
|
|
100
|
+
}
|
|
101
|
+
return e === 0 ? c : `${c}${t}${s.padEnd(e, "0").slice(0, e)}`;
|
|
102
|
+
}
|
|
103
|
+
return N === ".0" ? c : `${c}${N}`;
|
|
104
|
+
}
|
|
105
|
+
function $(r) {
|
|
106
|
+
const t = typeof r == "number" ? d(r) : o(String(r)).fullStr;
|
|
107
|
+
return t.includes(".") ? o(t.replace(/(\d)\.(\d)/g, "$1$2.")).fullStr : `${r}0`;
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
u as Decimal,
|
|
111
|
+
h as getDecimal,
|
|
112
|
+
$ as getDecupleSteps,
|
|
113
|
+
f as getNumberPrecision,
|
|
114
|
+
b as isEmptyValue,
|
|
115
|
+
d as num2str,
|
|
116
|
+
g as toFixed,
|
|
117
|
+
o as trimNumber,
|
|
118
|
+
E as validateNumber
|
|
119
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const l=require("react/jsx-runtime");;/* empty css */function w({open:u=!1,title:r="标题",mode:o="standard",children:_,okText:b="确认",cancelText:m="取消",onOk:x,onCancel:j,onClose:i,activeLang:n="zh",onLangChange:s,labels:t,hint:c,confirmLoading:e=!1,width:a,className:N,style:d}){const h=(t==null?void 0:t.zh)??"中文",p=(t==null?void 0:t.en)??"EN";if(!u)return null;const v=o==="bilingual",k=o==="single",y=a!=null?{width:a,...d}:d;return l.jsx("div",{className:["bu-modal__overlay",N].filter(Boolean).join(" "),onClick:i,children:l.jsxs("div",{className:"bu-modal__container",style:y,onClick:f=>f.stopPropagation(),children:[l.jsxs("div",{className:"bu-modal__header",children:[l.jsx("p",{className:"bu-modal__title",children:r}),v&&l.jsxs("div",{className:"bu-modal__lang-toggle",children:[l.jsx("button",{type:"button",className:`bu-modal__lang-btn${n==="zh"?" bu-modal__lang-btn--active":""}`,onClick:()=>s==null?void 0:s("zh"),children:h}),l.jsx("button",{type:"button",className:`bu-modal__lang-btn${n==="en"?" bu-modal__lang-btn--active":""}`,onClick:()=>s==null?void 0:s("en"),children:p})]}),l.jsx("button",{type:"button",className:"bu-modal__close",onClick:i,children:l.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{d:"M16.5613 6.73027C16.7558 6.53571 17.0723 6.53442 17.2684 6.72736C17.4644 6.92032 17.4657 7.23444 17.2713 7.42901L12.7036 12.0002L17.2713 16.5714C17.4657 16.766 17.4644 17.0801 17.2684 17.273C17.0723 17.4659 16.7558 17.4646 16.5613 17.2701L11.9996 12.7047L7.43794 17.2701C7.24352 17.4647 6.92699 17.4659 6.73091 17.273C6.53485 17.0801 6.53355 16.7659 6.72798 16.5714L11.2955 12.0002L6.72798 7.42901C6.53355 7.23442 6.53485 6.92032 6.73091 6.72736C6.92698 6.53442 7.2435 6.53571 7.43794 6.73027L11.9996 11.2955L16.5613 6.73027Z",fill:"currentColor"})})})]}),l.jsx("div",{className:"bu-modal__body",children:_}),l.jsxs("div",{className:"bu-modal__footer",children:[c&&l.jsx("p",{className:"bu-modal__hint",children:c}),l.jsxs("div",{className:"bu-modal__btn-row",children:[!k&&l.jsx("button",{type:"button",className:"bu-modal__btn-cancel",onClick:j??i,children:m}),l.jsxs("button",{type:"button",className:["bu-modal__btn-ok",e?"bu-modal__btn-ok--loading":""].filter(Boolean).join(" "),disabled:e,onClick:e?void 0:x,children:[e&&l.jsx("span",{className:"bu-modal__btn-ok-spinner"}),b]})]})]})]})})}module.exports=w;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as l, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
/* empty css */
|
|
3
|
+
function j({
|
|
4
|
+
open: _ = !1,
|
|
5
|
+
title: r = "标题",
|
|
6
|
+
mode: n = "standard",
|
|
7
|
+
children: b,
|
|
8
|
+
okText: m = "确认",
|
|
9
|
+
cancelText: p = "取消",
|
|
10
|
+
onOk: N,
|
|
11
|
+
onCancel: h,
|
|
12
|
+
onClose: a,
|
|
13
|
+
activeLang: c = "zh",
|
|
14
|
+
onLangChange: t,
|
|
15
|
+
labels: o,
|
|
16
|
+
hint: d,
|
|
17
|
+
confirmLoading: e = !1,
|
|
18
|
+
width: s,
|
|
19
|
+
className: v,
|
|
20
|
+
style: u
|
|
21
|
+
}) {
|
|
22
|
+
const k = (o == null ? void 0 : o.zh) ?? "中文", f = (o == null ? void 0 : o.en) ?? "EN";
|
|
23
|
+
if (!_) return null;
|
|
24
|
+
const y = n === "bilingual", w = n === "single", x = s != null ? { width: s, ...u } : u;
|
|
25
|
+
return /* @__PURE__ */ l("div", { className: ["bu-modal__overlay", v].filter(Boolean).join(" "), onClick: a, children: /* @__PURE__ */ i(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
className: "bu-modal__container",
|
|
29
|
+
style: x,
|
|
30
|
+
onClick: (z) => z.stopPropagation(),
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ i("div", { className: "bu-modal__header", children: [
|
|
33
|
+
/* @__PURE__ */ l("p", { className: "bu-modal__title", children: r }),
|
|
34
|
+
y && /* @__PURE__ */ i("div", { className: "bu-modal__lang-toggle", children: [
|
|
35
|
+
/* @__PURE__ */ l(
|
|
36
|
+
"button",
|
|
37
|
+
{
|
|
38
|
+
type: "button",
|
|
39
|
+
className: `bu-modal__lang-btn${c === "zh" ? " bu-modal__lang-btn--active" : ""}`,
|
|
40
|
+
onClick: () => t == null ? void 0 : t("zh"),
|
|
41
|
+
children: k
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ l(
|
|
45
|
+
"button",
|
|
46
|
+
{
|
|
47
|
+
type: "button",
|
|
48
|
+
className: `bu-modal__lang-btn${c === "en" ? " bu-modal__lang-btn--active" : ""}`,
|
|
49
|
+
onClick: () => t == null ? void 0 : t("en"),
|
|
50
|
+
children: f
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
] }),
|
|
54
|
+
/* @__PURE__ */ l("button", { type: "button", className: "bu-modal__close", onClick: a, children: /* @__PURE__ */ l("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ l("path", { d: "M16.5613 6.73027C16.7558 6.53571 17.0723 6.53442 17.2684 6.72736C17.4644 6.92032 17.4657 7.23444 17.2713 7.42901L12.7036 12.0002L17.2713 16.5714C17.4657 16.766 17.4644 17.0801 17.2684 17.273C17.0723 17.4659 16.7558 17.4646 16.5613 17.2701L11.9996 12.7047L7.43794 17.2701C7.24352 17.4647 6.92699 17.4659 6.73091 17.273C6.53485 17.0801 6.53355 16.7659 6.72798 16.5714L11.2955 12.0002L6.72798 7.42901C6.53355 7.23442 6.53485 6.92032 6.73091 6.72736C6.92698 6.53442 7.2435 6.53571 7.43794 6.73027L11.9996 11.2955L16.5613 6.73027Z", fill: "currentColor" }) }) })
|
|
55
|
+
] }),
|
|
56
|
+
/* @__PURE__ */ l("div", { className: "bu-modal__body", children: b }),
|
|
57
|
+
/* @__PURE__ */ i("div", { className: "bu-modal__footer", children: [
|
|
58
|
+
d && /* @__PURE__ */ l("p", { className: "bu-modal__hint", children: d }),
|
|
59
|
+
/* @__PURE__ */ i("div", { className: "bu-modal__btn-row", children: [
|
|
60
|
+
!w && /* @__PURE__ */ l("button", { type: "button", className: "bu-modal__btn-cancel", onClick: h ?? a, children: p }),
|
|
61
|
+
/* @__PURE__ */ i(
|
|
62
|
+
"button",
|
|
63
|
+
{
|
|
64
|
+
type: "button",
|
|
65
|
+
className: ["bu-modal__btn-ok", e ? "bu-modal__btn-ok--loading" : ""].filter(Boolean).join(" "),
|
|
66
|
+
disabled: e,
|
|
67
|
+
onClick: e ? void 0 : N,
|
|
68
|
+
children: [
|
|
69
|
+
e && /* @__PURE__ */ l("span", { className: "bu-modal__btn-ok-spinner" }),
|
|
70
|
+
m
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] })
|
|
75
|
+
] })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
) });
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
j as default
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),l=require("react"),ae=require("react-dom");;/* empty css */function le({triggerRect:w,dropdownHeight:r,viewportHeight:L}){const x=L-w.bottom,b=w.top;return x<r&&b>=r?"top":"bottom"}const re=w=>{const{current:r,defaultCurrent:L=1,pageSize:x,defaultPageSize:b=10,total:v=0,onChange:c,onShowSizeChange:N,showSizeChanger:A=!1,showQuickJumper:q=!1,pageSizeOptions:S=[10,20,50,100],disabled:a=!1,hideOnSinglePage:T=!1,showTotal:y,size:H="medium",align:J="start",simple:Q=!1,popupPlacement:d,resolvePopupPlacement:k,dropdownClassName:P,t:j=e=>e,className:$,style:M}=w,[W,E]=l.useState(L),[F,G]=l.useState(b),[g,f]=l.useState(!1),[C,K]=l.useState("bottom"),[z,U]=l.useState(null),p=l.useRef(null),R=l.useRef(null),s=r??W,u=x??F,o=Math.ceil(v/u);if(T&&o<=1)return null;const h=e=>{a||e<1||e>o||e===s||(r===void 0&&E(e),c==null||c(e,u))},V=e=>{const i=Math.ceil(v/e),n=Math.min(s,i)||1;x===void 0&&(G(e),r===void 0&&E(n)),N==null||N(n,e),c==null||c(n,e)},B=e=>{if(!p.current)return;const i=p.current.getBoundingClientRect();U({left:i.left+i.width/2,top:e==="bottom"?i.bottom+4:i.top-4})},X=()=>{if(a)return;if(g){f(!1);return}let e=C;if(d===void 0&&p.current){const i=p.current.getBoundingClientRect(),n=S.length*40+8,m=window.innerHeight;e=(k==null?void 0:k({triggerRect:i,dropdownHeight:n,viewportHeight:m}))??le({triggerRect:i,dropdownHeight:n,viewportHeight:m}),K(e)}B(d??e),f(!0)},Y=e=>{V(e),f(!1)};l.useEffect(()=>{const e=m=>{var I,Z;const O=m.target;(I=p.current)!=null&&I.contains(O)||(Z=R.current)!=null&&Z.contains(O)||f(!1)},i=()=>f(!1),n=()=>B(d??C);if(g)return document.addEventListener("mousedown",e),document.addEventListener("scroll",i,!0),window.addEventListener("resize",n),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("scroll",i,!0),window.removeEventListener("resize",n)}},[g,d,C]);const _=e=>{const i=parseInt(e.target.value);!isNaN(i)&&i>=1&&i<=o&&h(i)},ee=l.useMemo(()=>{const e=[];if(o<=7)for(let n=1;n<=o;n++)e.push(n);else if(s<=4){for(let n=1;n<=5;n++)e.push(n);e.push("..."),e.push(o)}else if(s>=o-3){e.push(1),e.push("...");for(let n=o-4;n<=o;n++)e.push(n)}else{e.push(1),e.push("...");for(let n=s-1;n<=s+1;n++)e.push(n);e.push("..."),e.push(o)}return e},[s,o]),te=(s-1)*u+1,ne=Math.min(s*u,v),ie=`pagination-${H}`,se=`pagination-${J}`,D=a?"pagination-disabled":"",oe=(e,i)=>{if(e==="...")return t.jsx("span",{className:"pagination-item pagination-ellipsis",children:"..."},`ellipsis-${i}`);const m=e===s?"pagination-item-active":"";return t.jsx("button",{type:"button",className:`pagination-item ${m}`,onClick:()=>h(e),disabled:a,children:e},e)};return Q?t.jsx("div",{className:`pagination pagination-simple ${D} ${$||""}`,style:M,children:t.jsxs("div",{className:"pagination-simple-list",children:[t.jsx("button",{type:"button",className:"pagination-simple-item pagination-simple-prev",onClick:()=>h(s-1),disabled:a||s===1,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:t.jsx("path",{d:"M8 2L4 6L8 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),t.jsxs("span",{className:"pagination-simple-text",children:[s," / ",o||0]}),t.jsx("button",{type:"button",className:"pagination-simple-item pagination-simple-next",onClick:()=>h(s+1),disabled:a||s===o,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:t.jsx("path",{d:"M4 2L8 6L4 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}):t.jsxs("div",{className:`pagination ${ie} ${se} ${D} ${$||""}`,style:M,children:[y&&t.jsx("div",{className:"pagination-total",children:y(v,[te,ne])}),t.jsxs("div",{className:"pagination-list",children:[t.jsx("button",{type:"button",className:"pagination-item pagination-prev",onClick:()=>h(s-1),disabled:a||s===1,children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M11.1749 5.57516C11.3377 5.41245 11.6014 5.41245 11.7641 5.57516C11.9268 5.73788 11.9268 6.00164 11.7641 6.16436L7.8945 10.034L11.7617 13.8366C11.9257 13.998 11.9279 14.2617 11.7666 14.4258C11.6052 14.5899 11.3414 14.592 11.1774 14.4307L7.2105 10.5299C6.93541 10.2594 6.93349 9.81648 7.20629 9.54367L11.1749 5.57516Z",fill:"#333333"}),t.jsx("path",{d:"M11.1749 5.57516C11.3377 5.41245 11.6014 5.41245 11.7641 5.57516C11.9268 5.73788 11.9268 6.00164 11.7641 6.16436L7.8945 10.034L11.7617 13.8366C11.9257 13.998 11.9279 14.2617 11.7666 14.4258C11.6052 14.5899 11.3414 14.592 11.1774 14.4307L7.2105 10.5299C6.93541 10.2594 6.93349 9.81648 7.20629 9.54367L11.1749 5.57516Z",fill:"black",fillOpacity:"0.2"})]})}),ee.map((e,i)=>oe(e,i)),t.jsx("button",{type:"button",className:"pagination-item pagination-next",onClick:()=>h(s+1),disabled:a||s===o,children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M8.82507 5.57516C8.66235 5.41245 8.39859 5.41245 8.23587 5.57516C8.07315 5.73788 8.07315 6.00164 8.23587 6.16436L12.1055 10.034L8.23831 13.8366C8.07427 13.998 8.0721 14.2617 8.23343 14.4258C8.39478 14.5899 8.65856 14.592 8.82262 14.4307L12.7895 10.5299C13.0646 10.2594 13.0665 9.81648 12.7937 9.54367L8.82507 5.57516Z",fill:"#333333"}),t.jsx("path",{d:"M8.82507 5.57516C8.66235 5.41245 8.39859 5.41245 8.23587 5.57516C8.07315 5.73788 8.07315 6.00164 8.23587 6.16436L12.1055 10.034L8.23831 13.8366C8.07427 13.998 8.0721 14.2617 8.23343 14.4258C8.39478 14.5899 8.65856 14.592 8.82262 14.4307L12.7895 10.5299C13.0646 10.2594 13.0665 9.81648 12.7937 9.54367L8.82507 5.57516Z",fill:"black","fill-opacity":"0.2"})]})})]}),A&&t.jsxs("div",{className:"pagination-sizer",ref:p,children:[t.jsxs("button",{type:"button",className:"pagination-sizer-select",onClick:X,disabled:a,children:[u,j("条每页"),t.jsxs("svg",{className:`pagination-sizer-icon${g?" pagination-sizer-icon-open":""}`,width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M5.57321 8.828C5.41049 8.66528 5.41049 8.40152 5.57321 8.2388C5.73593 8.07608 5.99969 8.07608 6.1624 8.2388L10.032 12.1084L13.8347 8.24124C13.996 8.0772 14.2598 8.07503 14.4239 8.23636C14.5879 8.39771 14.5901 8.66149 14.4287 8.82555L10.5279 12.7924C10.2574 13.0675 9.81452 13.0694 9.54172 12.7966L5.57321 8.828Z",fill:"#333333"}),t.jsx("path",{d:"M5.57321 8.828C5.41049 8.66528 5.41049 8.40152 5.57321 8.2388C5.73593 8.07608 5.99969 8.07608 6.1624 8.2388L10.032 12.1084L13.8347 8.24124C13.996 8.0772 14.2598 8.07503 14.4239 8.23636C14.5879 8.39771 14.5901 8.66149 14.4287 8.82555L10.5279 12.7924C10.2574 13.0675 9.81452 13.0694 9.54172 12.7966L5.57321 8.828Z",fill:"black",fillOpacity:"0.2"})]})]}),g&&z&&ae.createPortal(t.jsx("div",{ref:R,className:`pagination-sizer-dropdown pagination-sizer-dropdown-${d??C}${P?` ${P}`:""}`,style:{position:"fixed",left:z.left,top:z.top,zIndex:99999,transform:(d??C)==="bottom"?"translate(-50%, 0)":"translate(-50%, -100%)"},children:S.map(e=>t.jsxs("button",{type:"button",className:"pagination-sizer-option",onClick:()=>Y(e),"data-selected":e===u,children:[e,j("条/页")]},e))}),document.body)]}),q&&t.jsxs("div",{className:"pagination-jumper",children:[t.jsx("span",{children:j("跳至")}),t.jsx("input",{type:"number",className:"pagination-jumper-input",min:1,max:o,onChange:_,disabled:a,placeholder:""}),t.jsx("span",{children:j("页")})]})]})};module.exports=re;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useRef as T, useEffect as rt, useMemo as ct } from "react";
|
|
3
|
+
import { createPortal as dt } from "react-dom";
|
|
4
|
+
/* empty css */
|
|
5
|
+
function pt({
|
|
6
|
+
triggerRect: v,
|
|
7
|
+
dropdownHeight: r,
|
|
8
|
+
viewportHeight: k
|
|
9
|
+
}) {
|
|
10
|
+
const L = k - v.bottom, z = v.top;
|
|
11
|
+
return L < r && z >= r ? "top" : "bottom";
|
|
12
|
+
}
|
|
13
|
+
const ft = (v) => {
|
|
14
|
+
const {
|
|
15
|
+
current: r,
|
|
16
|
+
defaultCurrent: k = 1,
|
|
17
|
+
pageSize: L,
|
|
18
|
+
defaultPageSize: z = 10,
|
|
19
|
+
total: b = 0,
|
|
20
|
+
onChange: c,
|
|
21
|
+
onShowSizeChange: x,
|
|
22
|
+
showSizeChanger: H = !1,
|
|
23
|
+
showQuickJumper: J = !1,
|
|
24
|
+
pageSizeOptions: $ = [10, 20, 50, 100],
|
|
25
|
+
disabled: l = !1,
|
|
26
|
+
hideOnSinglePage: Q = !1,
|
|
27
|
+
showTotal: M,
|
|
28
|
+
size: W = "medium",
|
|
29
|
+
align: q = "start",
|
|
30
|
+
simple: F = !1,
|
|
31
|
+
popupPlacement: d,
|
|
32
|
+
resolvePopupPlacement: y,
|
|
33
|
+
dropdownClassName: S,
|
|
34
|
+
t: N = (t) => t,
|
|
35
|
+
className: E,
|
|
36
|
+
style: B
|
|
37
|
+
} = v, [G, O] = w(k), [K, U] = w(z), [m, g] = w(!1), [f, V] = w("bottom"), [P, X] = w(null), p = T(null), R = T(null), o = r ?? G, u = L ?? K, s = Math.ceil(b / u);
|
|
38
|
+
if (Q && s <= 1)
|
|
39
|
+
return null;
|
|
40
|
+
const h = (t) => {
|
|
41
|
+
l || t < 1 || t > s || t === o || (r === void 0 && O(t), c == null || c(t, u));
|
|
42
|
+
}, Y = (t) => {
|
|
43
|
+
const n = Math.ceil(b / t), e = Math.min(o, n) || 1;
|
|
44
|
+
L === void 0 && (U(t), r === void 0 && O(e)), x == null || x(e, t), c == null || c(e, t);
|
|
45
|
+
}, D = (t) => {
|
|
46
|
+
if (!p.current) return;
|
|
47
|
+
const n = p.current.getBoundingClientRect();
|
|
48
|
+
X({
|
|
49
|
+
left: n.left + n.width / 2,
|
|
50
|
+
top: t === "bottom" ? n.bottom + 4 : n.top - 4
|
|
51
|
+
});
|
|
52
|
+
}, _ = () => {
|
|
53
|
+
if (l) return;
|
|
54
|
+
if (m) {
|
|
55
|
+
g(!1);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let t = f;
|
|
59
|
+
if (d === void 0 && p.current) {
|
|
60
|
+
const n = p.current.getBoundingClientRect(), e = $.length * 40 + 8, C = window.innerHeight;
|
|
61
|
+
t = (y == null ? void 0 : y({ triggerRect: n, dropdownHeight: e, viewportHeight: C })) ?? pt({ triggerRect: n, dropdownHeight: e, viewportHeight: C }), V(t);
|
|
62
|
+
}
|
|
63
|
+
D(d ?? t), g(!0);
|
|
64
|
+
}, tt = (t) => {
|
|
65
|
+
Y(t), g(!1);
|
|
66
|
+
};
|
|
67
|
+
rt(() => {
|
|
68
|
+
const t = (C) => {
|
|
69
|
+
var Z, A;
|
|
70
|
+
const I = C.target;
|
|
71
|
+
(Z = p.current) != null && Z.contains(I) || (A = R.current) != null && A.contains(I) || g(!1);
|
|
72
|
+
}, n = () => g(!1), e = () => D(d ?? f);
|
|
73
|
+
if (m)
|
|
74
|
+
return document.addEventListener("mousedown", t), document.addEventListener("scroll", n, !0), window.addEventListener("resize", e), () => {
|
|
75
|
+
document.removeEventListener("mousedown", t), document.removeEventListener("scroll", n, !0), window.removeEventListener("resize", e);
|
|
76
|
+
};
|
|
77
|
+
}, [m, d, f]);
|
|
78
|
+
const et = (t) => {
|
|
79
|
+
const n = parseInt(t.target.value);
|
|
80
|
+
!isNaN(n) && n >= 1 && n <= s && h(n);
|
|
81
|
+
}, nt = ct(() => {
|
|
82
|
+
const t = [];
|
|
83
|
+
if (s <= 7)
|
|
84
|
+
for (let e = 1; e <= s; e++)
|
|
85
|
+
t.push(e);
|
|
86
|
+
else if (o <= 4) {
|
|
87
|
+
for (let e = 1; e <= 5; e++)
|
|
88
|
+
t.push(e);
|
|
89
|
+
t.push("..."), t.push(s);
|
|
90
|
+
} else if (o >= s - 3) {
|
|
91
|
+
t.push(1), t.push("...");
|
|
92
|
+
for (let e = s - 4; e <= s; e++)
|
|
93
|
+
t.push(e);
|
|
94
|
+
} else {
|
|
95
|
+
t.push(1), t.push("...");
|
|
96
|
+
for (let e = o - 1; e <= o + 1; e++)
|
|
97
|
+
t.push(e);
|
|
98
|
+
t.push("..."), t.push(s);
|
|
99
|
+
}
|
|
100
|
+
return t;
|
|
101
|
+
}, [o, s]), it = (o - 1) * u + 1, ot = Math.min(o * u, b), st = `pagination-${W}`, at = `pagination-${q}`, j = l ? "pagination-disabled" : "", lt = (t, n) => t === "..." ? /* @__PURE__ */ i("span", { className: "pagination-item pagination-ellipsis", children: "..." }, `ellipsis-${n}`) : /* @__PURE__ */ i(
|
|
102
|
+
"button",
|
|
103
|
+
{
|
|
104
|
+
type: "button",
|
|
105
|
+
className: `pagination-item ${t === o ? "pagination-item-active" : ""}`,
|
|
106
|
+
onClick: () => h(t),
|
|
107
|
+
disabled: l,
|
|
108
|
+
children: t
|
|
109
|
+
},
|
|
110
|
+
t
|
|
111
|
+
);
|
|
112
|
+
return F ? /* @__PURE__ */ i(
|
|
113
|
+
"div",
|
|
114
|
+
{
|
|
115
|
+
className: `pagination pagination-simple ${j} ${E || ""}`,
|
|
116
|
+
style: B,
|
|
117
|
+
children: /* @__PURE__ */ a("div", { className: "pagination-simple-list", children: [
|
|
118
|
+
/* @__PURE__ */ i(
|
|
119
|
+
"button",
|
|
120
|
+
{
|
|
121
|
+
type: "button",
|
|
122
|
+
className: "pagination-simple-item pagination-simple-prev",
|
|
123
|
+
onClick: () => h(o - 1),
|
|
124
|
+
disabled: l || o === 1,
|
|
125
|
+
children: /* @__PURE__ */ i("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ i("path", { d: "M8 2L4 6L8 10", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
/* @__PURE__ */ a("span", { className: "pagination-simple-text", children: [
|
|
129
|
+
o,
|
|
130
|
+
" / ",
|
|
131
|
+
s || 0
|
|
132
|
+
] }),
|
|
133
|
+
/* @__PURE__ */ i(
|
|
134
|
+
"button",
|
|
135
|
+
{
|
|
136
|
+
type: "button",
|
|
137
|
+
className: "pagination-simple-item pagination-simple-next",
|
|
138
|
+
onClick: () => h(o + 1),
|
|
139
|
+
disabled: l || o === s,
|
|
140
|
+
children: /* @__PURE__ */ i("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ i("path", { d: "M4 2L8 6L4 10", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] })
|
|
144
|
+
}
|
|
145
|
+
) : /* @__PURE__ */ a(
|
|
146
|
+
"div",
|
|
147
|
+
{
|
|
148
|
+
className: `pagination ${st} ${at} ${j} ${E || ""}`,
|
|
149
|
+
style: B,
|
|
150
|
+
children: [
|
|
151
|
+
M && /* @__PURE__ */ i("div", { className: "pagination-total", children: M(b, [it, ot]) }),
|
|
152
|
+
/* @__PURE__ */ a("div", { className: "pagination-list", children: [
|
|
153
|
+
/* @__PURE__ */ i(
|
|
154
|
+
"button",
|
|
155
|
+
{
|
|
156
|
+
type: "button",
|
|
157
|
+
className: "pagination-item pagination-prev",
|
|
158
|
+
onClick: () => h(o - 1),
|
|
159
|
+
disabled: l || o === 1,
|
|
160
|
+
children: /* @__PURE__ */ a("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
161
|
+
/* @__PURE__ */ i("path", { d: "M11.1749 5.57516C11.3377 5.41245 11.6014 5.41245 11.7641 5.57516C11.9268 5.73788 11.9268 6.00164 11.7641 6.16436L7.8945 10.034L11.7617 13.8366C11.9257 13.998 11.9279 14.2617 11.7666 14.4258C11.6052 14.5899 11.3414 14.592 11.1774 14.4307L7.2105 10.5299C6.93541 10.2594 6.93349 9.81648 7.20629 9.54367L11.1749 5.57516Z", fill: "#333333" }),
|
|
162
|
+
/* @__PURE__ */ i("path", { d: "M11.1749 5.57516C11.3377 5.41245 11.6014 5.41245 11.7641 5.57516C11.9268 5.73788 11.9268 6.00164 11.7641 6.16436L7.8945 10.034L11.7617 13.8366C11.9257 13.998 11.9279 14.2617 11.7666 14.4258C11.6052 14.5899 11.3414 14.592 11.1774 14.4307L7.2105 10.5299C6.93541 10.2594 6.93349 9.81648 7.20629 9.54367L11.1749 5.57516Z", fill: "black", fillOpacity: "0.2" })
|
|
163
|
+
] })
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
nt.map((t, n) => lt(t, n)),
|
|
167
|
+
/* @__PURE__ */ i(
|
|
168
|
+
"button",
|
|
169
|
+
{
|
|
170
|
+
type: "button",
|
|
171
|
+
className: "pagination-item pagination-next",
|
|
172
|
+
onClick: () => h(o + 1),
|
|
173
|
+
disabled: l || o === s,
|
|
174
|
+
children: /* @__PURE__ */ a("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
175
|
+
/* @__PURE__ */ i("path", { d: "M8.82507 5.57516C8.66235 5.41245 8.39859 5.41245 8.23587 5.57516C8.07315 5.73788 8.07315 6.00164 8.23587 6.16436L12.1055 10.034L8.23831 13.8366C8.07427 13.998 8.0721 14.2617 8.23343 14.4258C8.39478 14.5899 8.65856 14.592 8.82262 14.4307L12.7895 10.5299C13.0646 10.2594 13.0665 9.81648 12.7937 9.54367L8.82507 5.57516Z", fill: "#333333" }),
|
|
176
|
+
/* @__PURE__ */ i("path", { d: "M8.82507 5.57516C8.66235 5.41245 8.39859 5.41245 8.23587 5.57516C8.07315 5.73788 8.07315 6.00164 8.23587 6.16436L12.1055 10.034L8.23831 13.8366C8.07427 13.998 8.0721 14.2617 8.23343 14.4258C8.39478 14.5899 8.65856 14.592 8.82262 14.4307L12.7895 10.5299C13.0646 10.2594 13.0665 9.81648 12.7937 9.54367L8.82507 5.57516Z", fill: "black", "fill-opacity": "0.2" })
|
|
177
|
+
] })
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }),
|
|
181
|
+
H && /* @__PURE__ */ a("div", { className: "pagination-sizer", ref: p, children: [
|
|
182
|
+
/* @__PURE__ */ a(
|
|
183
|
+
"button",
|
|
184
|
+
{
|
|
185
|
+
type: "button",
|
|
186
|
+
className: "pagination-sizer-select",
|
|
187
|
+
onClick: _,
|
|
188
|
+
disabled: l,
|
|
189
|
+
children: [
|
|
190
|
+
u,
|
|
191
|
+
N("条每页"),
|
|
192
|
+
/* @__PURE__ */ a("svg", { className: `pagination-sizer-icon${m ? " pagination-sizer-icon-open" : ""}`, width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
193
|
+
/* @__PURE__ */ i("path", { d: "M5.57321 8.828C5.41049 8.66528 5.41049 8.40152 5.57321 8.2388C5.73593 8.07608 5.99969 8.07608 6.1624 8.2388L10.032 12.1084L13.8347 8.24124C13.996 8.0772 14.2598 8.07503 14.4239 8.23636C14.5879 8.39771 14.5901 8.66149 14.4287 8.82555L10.5279 12.7924C10.2574 13.0675 9.81452 13.0694 9.54172 12.7966L5.57321 8.828Z", fill: "#333333" }),
|
|
194
|
+
/* @__PURE__ */ i("path", { d: "M5.57321 8.828C5.41049 8.66528 5.41049 8.40152 5.57321 8.2388C5.73593 8.07608 5.99969 8.07608 6.1624 8.2388L10.032 12.1084L13.8347 8.24124C13.996 8.0772 14.2598 8.07503 14.4239 8.23636C14.5879 8.39771 14.5901 8.66149 14.4287 8.82555L10.5279 12.7924C10.2574 13.0675 9.81452 13.0694 9.54172 12.7966L5.57321 8.828Z", fill: "black", fillOpacity: "0.2" })
|
|
195
|
+
] })
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
m && P && dt(
|
|
200
|
+
/* @__PURE__ */ i(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
ref: R,
|
|
204
|
+
className: `pagination-sizer-dropdown pagination-sizer-dropdown-${d ?? f}${S ? ` ${S}` : ""}`,
|
|
205
|
+
style: {
|
|
206
|
+
position: "fixed",
|
|
207
|
+
left: P.left,
|
|
208
|
+
top: P.top,
|
|
209
|
+
zIndex: 99999,
|
|
210
|
+
transform: (d ?? f) === "bottom" ? "translate(-50%, 0)" : "translate(-50%, -100%)"
|
|
211
|
+
},
|
|
212
|
+
children: $.map((t) => /* @__PURE__ */ a(
|
|
213
|
+
"button",
|
|
214
|
+
{
|
|
215
|
+
type: "button",
|
|
216
|
+
className: "pagination-sizer-option",
|
|
217
|
+
onClick: () => tt(t),
|
|
218
|
+
"data-selected": t === u,
|
|
219
|
+
children: [
|
|
220
|
+
t,
|
|
221
|
+
N("条/页")
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
t
|
|
225
|
+
))
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
document.body
|
|
229
|
+
)
|
|
230
|
+
] }),
|
|
231
|
+
J && /* @__PURE__ */ a("div", { className: "pagination-jumper", children: [
|
|
232
|
+
/* @__PURE__ */ i("span", { children: N("跳至") }),
|
|
233
|
+
/* @__PURE__ */ i(
|
|
234
|
+
"input",
|
|
235
|
+
{
|
|
236
|
+
type: "number",
|
|
237
|
+
className: "pagination-jumper-input",
|
|
238
|
+
min: 1,
|
|
239
|
+
max: s,
|
|
240
|
+
onChange: et,
|
|
241
|
+
disabled: l,
|
|
242
|
+
placeholder: ""
|
|
243
|
+
}
|
|
244
|
+
),
|
|
245
|
+
/* @__PURE__ */ i("span", { children: N("页") })
|
|
246
|
+
] })
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
export {
|
|
252
|
+
ft as default
|
|
253
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),c=require("react"),ne=require("react-dom");;/* empty css */const ce=require("./no_data_light.png.js"),B=require("./arrow-up.svg.js"),oe=require("./sort.svg.js"),ie=require("./search.svg.js"),ae=require("./checkbox-no.svg.js"),ue=require("./checkbox-ok.svg.js");function Z({size:u=20}){return t.jsx("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M16.5613 6.73027C16.7558 6.53571 17.0723 6.53442 17.2684 6.72736C17.4644 6.92032 17.4657 7.23444 17.2713 7.42901L12.7036 12.0002L17.2713 16.5714C17.4657 16.766 17.4644 17.0801 17.2684 17.273C17.0723 17.4659 16.7558 17.4646 16.5613 17.2701L11.9996 12.7047L7.43794 17.2701C7.24352 17.4647 6.92699 17.4659 6.73091 17.273C6.53485 17.0801 6.53355 16.7659 6.72798 16.5714L11.2955 12.0002L6.72798 7.42901C6.53355 7.23442 6.53485 6.92032 6.73091 6.72736C6.92698 6.53442 7.2435 6.53571 7.43794 6.73027L11.9996 11.2955L16.5613 6.73027Z",fill:"currentColor"})})}function le({options:u=[],value:a=[],onChange:o,placeholder:R="请选择",emptyText:D="暂无产品数据",onManageField:I,multiple:d=!0,showSearch:E=!0,showSort:q=!0,addButtonText:y,onAdd:U,labels:s,className:H,style:G,getPopupContainer:x}){const J=(s==null?void 0:s.searchPlaceholder)??"搜索",K=(s==null?void 0:s.sortDefault)??"默认顺序",Q=(s==null?void 0:s.sortAsc)??"名称A-Z",V=(s==null?void 0:s.sortDesc)??"名称Z-A",O=(s==null?void 0:s.noMatchText)??"暂无选项",W=(s==null?void 0:s.manageFieldPre)??"请前往",Y=(s==null?void 0:s.manageFieldLink)??"管理字段",ee=(s==null?void 0:s.manageFieldPost)??"添加",[f,C]=c.useState(!1),[j,M]=c.useState(""),[p,F]=c.useState("none"),[w,N]=c.useState(!1),m=c.useRef(null),b=c.useRef(null),P=c.useRef(null),[v,te]=c.useState({top:0,left:0,width:0}),l=c.useCallback(()=>{if(!m.current)return;const e=m.current.getBoundingClientRect();te({top:e.bottom+4,left:e.left,width:e.width})},[]);c.useLayoutEffect(()=>{f&&l()},[f,l]),c.useEffect(()=>{if(!f)return;const e=r=>{var i,g;const n=r.target;(i=P.current)!=null&&i.contains(n)||(g=m.current)!=null&&g.contains(n)||L()};return document.addEventListener("mousedown",e),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l)}},[f,l]),c.useEffect(()=>{if(!w)return;const e=r=>{b.current&&!b.current.contains(r.target)&&N(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[w]);const S=c.useRef(null),$=c.useRef(null),h=c.useRef({dragging:!1,startX:0,scrollLeft:0,target:null}),T=c.useCallback(e=>({onMouseDown:r=>{const n=e.current;n&&(h.current={dragging:!0,startX:r.clientX,scrollLeft:n.scrollLeft,target:n})},onMouseMove:r=>{const{dragging:n,startX:i,scrollLeft:g,target:A}=h.current;!n||!A||(r.preventDefault(),A.scrollLeft=g-(r.clientX-i))},onMouseUp:()=>{h.current.dragging=!1},onMouseLeave:()=>{h.current.dragging=!1}}),[]);function se(e){if(!d){o==null||o(a.includes(e)?[]:[e]),a.includes(e)||L();return}const r=a.includes(e)?a.filter(n=>n!==e):[...a,e];o==null||o(r)}function X(e){o==null||o(a.filter(r=>r!==e))}function L(){C(!1),M(""),F("none")}function re(e){F(e),N(!1)}const z=c.useMemo(()=>{let e=u.filter(n=>(n.searchText??(typeof n.label=="string"?n.label:"")).toLowerCase().includes(j.toLowerCase()));const r=n=>n.searchText??(typeof n.label=="string"?n.label:"");return p==="asc"&&(e=[...e].sort((n,i)=>r(n).localeCompare(r(i)))),p==="desc"&&(e=[...e].sort((n,i)=>r(i).localeCompare(r(n)))),e},[u,j,p]),_=u.filter(e=>a.includes(e.value)),k=u.length>0;return t.jsxs("div",{ref:m,className:["bu-pf",H].filter(Boolean).join(" "),style:G,children:[!f&&t.jsxs("div",{className:`bu-pf__trigger${_.length>0?" bu-pf__trigger--selected":""}`,onClick:()=>C(!0),children:[_.length>0?t.jsx("div",{className:"bu-pf__trigger-tags",ref:$,...T($),children:_.map(e=>t.jsxs("span",{className:`bu-pf__tag${d?"":" bu-pf__tag--single"}`,children:[t.jsx("span",{className:"bu-pf__tag-text",children:e.label}),t.jsx("button",{type:"button",className:"bu-pf__tag-close",onClick:r=>{r.stopPropagation(),X(e.value)},children:t.jsx(Z,{size:12})})]},e.value))}):t.jsx("span",{className:"bu-pf__placeholder",children:R}),t.jsx("span",{className:"bu-pf__arrow",children:t.jsx("img",{src:B,width:24,height:24,alt:""})})]}),f&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bu-pf__panel",children:t.jsxs("div",{className:"bu-pf__header",children:[t.jsx("div",{className:"bu-pf__tags",ref:S,...T(S),children:_.length>0?_.map(e=>t.jsxs("span",{className:`bu-pf__tag${d?"":" bu-pf__tag--single"}`,children:[t.jsx("span",{className:"bu-pf__tag-text",children:e.label}),t.jsx("button",{type:"button",className:"bu-pf__tag-close",onClick:()=>X(e.value),children:t.jsx(Z,{size:12})})]},e.value)):t.jsx("span",{className:"bu-pf__placeholder-inline",children:R})}),t.jsx("button",{type:"button",className:"bu-pf__close",onClick:L,children:t.jsx("img",{src:B,width:24,height:24,alt:""})})]})}),ne.createPortal(t.jsx("div",{ref:P,className:"bu-pf__portal",style:{position:"fixed",top:v.top,left:v.left,width:v.width,zIndex:1050},children:t.jsxs("div",{className:"bu-pf__dropdown",children:[(E||q)&&t.jsxs("div",{className:"bu-pf__toolbar",children:[E&&t.jsxs("div",{className:"bu-pf__search",children:[t.jsx("span",{className:"bu-pf__search-icon",children:t.jsx("img",{src:ie,width:20,height:20,alt:""})}),t.jsx("input",{className:"bu-pf__search-input",placeholder:J,value:j,onChange:e=>M(e.target.value)})]}),q&&t.jsxs("div",{ref:b,className:"bu-pf__sort-wrap",children:[t.jsx("button",{type:"button",className:`bu-pf__sort-btn${p!=="none"?" bu-pf__sort-btn--active":""}`,onClick:()=>N(e=>!e),children:t.jsx("img",{src:oe,width:24,height:24,alt:""})}),w&&t.jsx("div",{className:"bu-pf__sort-dropdown",children:[{key:"none",label:K},{key:"asc",label:Q},{key:"desc",label:V}].map(({key:e,label:r})=>t.jsx("div",{className:`bu-pf__sort-option${p===e?" bu-pf__sort-option--active":""}`,onClick:()=>re(e),children:r},e))})]})]}),t.jsx("div",{className:"bu-pf__list",children:k&&z.length>0?z.map(e=>{const r=a.includes(e.value);return t.jsxs("div",{className:`bu-pf__option${d?" bu-pf__option--multiple":""}${r&&!d?" bu-pf__option--selected":""}`,onClick:()=>se(e.value),children:[d&&t.jsx("img",{className:"bu-pf__checkbox-img",src:r?ue:ae,alt:""}),t.jsx("span",{className:"bu-pf__option-label",children:e.label})]},e.value)}):t.jsxs("div",{className:"bu-pf__no-match",children:[t.jsx("img",{className:"bu-pf__no-match-img",src:ce,alt:k?O:D}),t.jsx("p",{className:"bu-pf__no-match-text",children:k?O:D}),t.jsxs("p",{className:"bu-pf__no-match-hint",children:[W,t.jsx("button",{type:"button",className:"bu-pf__manage-btn",onClick:I,children:Y}),ee]})]})}),y&&t.jsx("div",{className:"bu-pf__add-row",onClick:U,children:y})]})}),(x==null?void 0:x())??document.body)]})]})}module.exports=le;
|