klun-ui 0.1.7 → 0.1.9
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/CHANGELOG.md +25 -0
- package/dist/{chunk-Z2TY6K3O.js → chunk-N3A4NTMY.js} +103 -38
- package/dist/chunk-N3A4NTMY.js.map +1 -0
- package/dist/{chunk-LDENBMG5.cjs → chunk-PRDLMM4A.cjs} +103 -38
- package/dist/chunk-PRDLMM4A.cjs.map +1 -0
- package/dist/index.cjs +144 -144
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +2 -2
- package/dist/templates/index.cjs +82 -82
- package/dist/templates/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-LDENBMG5.cjs.map +0 -1
- package/dist/chunk-Z2TY6K3O.js.map +0 -1
|
@@ -10101,6 +10101,8 @@ var Modal = react.forwardRef(function Modal2({
|
|
|
10101
10101
|
);
|
|
10102
10102
|
});
|
|
10103
10103
|
Modal.displayName = "Modal";
|
|
10104
|
+
var GAP2 = 8;
|
|
10105
|
+
var MARGIN = 8;
|
|
10104
10106
|
var Popconfirm = react.forwardRef(function Popconfirm2({
|
|
10105
10107
|
title: titleProp,
|
|
10106
10108
|
description,
|
|
@@ -10123,11 +10125,15 @@ var Popconfirm = react.forwardRef(function Popconfirm2({
|
|
|
10123
10125
|
const cancelText = cancelTextProp ?? popconfirm.cancel;
|
|
10124
10126
|
const [open, setOpen] = react.useState(false);
|
|
10125
10127
|
const [busy, setBusy] = react.useState(false);
|
|
10128
|
+
const [pos, setPos] = react.useState(null);
|
|
10126
10129
|
const innerRef = react.useRef(null);
|
|
10130
|
+
const bubbleRef = react.useRef(null);
|
|
10127
10131
|
react.useEffect(() => {
|
|
10128
10132
|
if (!open) return;
|
|
10129
10133
|
const h = (e) => {
|
|
10130
|
-
|
|
10134
|
+
const t = e.target;
|
|
10135
|
+
if (innerRef.current?.contains(t) || bubbleRef.current?.contains(t)) return;
|
|
10136
|
+
setOpen(false);
|
|
10131
10137
|
};
|
|
10132
10138
|
const k = (e) => {
|
|
10133
10139
|
if (e.key === "Escape") setOpen(false);
|
|
@@ -10139,6 +10145,51 @@ var Popconfirm = react.forwardRef(function Popconfirm2({
|
|
|
10139
10145
|
document.removeEventListener("keydown", k);
|
|
10140
10146
|
};
|
|
10141
10147
|
}, [open]);
|
|
10148
|
+
react.useLayoutEffect(() => {
|
|
10149
|
+
if (!open) {
|
|
10150
|
+
setPos(null);
|
|
10151
|
+
return;
|
|
10152
|
+
}
|
|
10153
|
+
const place = () => {
|
|
10154
|
+
const trigger = innerRef.current;
|
|
10155
|
+
const bubble = bubbleRef.current;
|
|
10156
|
+
if (!trigger || !bubble) return;
|
|
10157
|
+
const tr = trigger.getBoundingClientRect();
|
|
10158
|
+
const bw = bubble.offsetWidth;
|
|
10159
|
+
const bh = bubble.offsetHeight;
|
|
10160
|
+
const vw = document.documentElement.clientWidth;
|
|
10161
|
+
const vh = document.documentElement.clientHeight;
|
|
10162
|
+
let top;
|
|
10163
|
+
let left;
|
|
10164
|
+
switch (placement) {
|
|
10165
|
+
case "bottom":
|
|
10166
|
+
top = tr.bottom + GAP2;
|
|
10167
|
+
left = tr.left + tr.width / 2 - bw / 2;
|
|
10168
|
+
break;
|
|
10169
|
+
case "left":
|
|
10170
|
+
left = tr.left - bw - GAP2;
|
|
10171
|
+
top = tr.top + tr.height / 2 - bh / 2;
|
|
10172
|
+
break;
|
|
10173
|
+
case "right":
|
|
10174
|
+
left = tr.right + GAP2;
|
|
10175
|
+
top = tr.top + tr.height / 2 - bh / 2;
|
|
10176
|
+
break;
|
|
10177
|
+
default:
|
|
10178
|
+
top = tr.top - bh - GAP2;
|
|
10179
|
+
left = tr.left + tr.width / 2 - bw / 2;
|
|
10180
|
+
}
|
|
10181
|
+
left = Math.max(MARGIN, Math.min(left, vw - bw - MARGIN));
|
|
10182
|
+
top = Math.max(MARGIN, Math.min(top, vh - bh - MARGIN));
|
|
10183
|
+
setPos({ top, left });
|
|
10184
|
+
};
|
|
10185
|
+
place();
|
|
10186
|
+
window.addEventListener("scroll", place, true);
|
|
10187
|
+
window.addEventListener("resize", place);
|
|
10188
|
+
return () => {
|
|
10189
|
+
window.removeEventListener("scroll", place, true);
|
|
10190
|
+
window.removeEventListener("resize", place);
|
|
10191
|
+
};
|
|
10192
|
+
}, [open, placement, title, description]);
|
|
10142
10193
|
const setRefs = (node) => {
|
|
10143
10194
|
innerRef.current = node;
|
|
10144
10195
|
if (typeof ref === "function") ref(node);
|
|
@@ -10157,6 +10208,16 @@ var Popconfirm = react.forwardRef(function Popconfirm2({
|
|
|
10157
10208
|
onCancel?.();
|
|
10158
10209
|
setOpen(false);
|
|
10159
10210
|
};
|
|
10211
|
+
const bubbleStyle = {
|
|
10212
|
+
position: "fixed",
|
|
10213
|
+
top: pos ? pos.top : 0,
|
|
10214
|
+
left: pos ? pos.left : 0,
|
|
10215
|
+
right: "auto",
|
|
10216
|
+
bottom: "auto",
|
|
10217
|
+
transform: "none",
|
|
10218
|
+
visibility: pos ? "visible" : "hidden",
|
|
10219
|
+
["--klun-popconfirm-tint"]: `var(--klun-state-${status}-base)`
|
|
10220
|
+
};
|
|
10160
10221
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { ref: setRefs, className: chunkTPGAXYFU_cjs.cx("klun-popconfirm", className), ...props, children: [
|
|
10161
10222
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10162
10223
|
"span",
|
|
@@ -10169,42 +10230,46 @@ var Popconfirm = react.forwardRef(function Popconfirm2({
|
|
|
10169
10230
|
children
|
|
10170
10231
|
}
|
|
10171
10232
|
),
|
|
10172
|
-
open
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-
|
|
10183
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
10184
|
-
|
|
10233
|
+
open && typeof document !== "undefined" ? reactDom.createPortal(
|
|
10234
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10235
|
+
"div",
|
|
10236
|
+
{
|
|
10237
|
+
ref: bubbleRef,
|
|
10238
|
+
role: "dialog",
|
|
10239
|
+
className: chunkTPGAXYFU_cjs.cx("klun-popconfirm__bubble", `klun-popconfirm__bubble--${placement}`),
|
|
10240
|
+
style: bubbleStyle,
|
|
10241
|
+
onClick: (e) => e.stopPropagation(),
|
|
10242
|
+
children: [
|
|
10243
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-popconfirm__head", children: [
|
|
10244
|
+
icon ? /* @__PURE__ */ jsxRuntime.jsx("i", { className: chunkTPGAXYFU_cjs.cx("klun-popconfirm__icon", icon) }) : null,
|
|
10245
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-popconfirm__body", children: [
|
|
10246
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-popconfirm__title", children: title }),
|
|
10247
|
+
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-popconfirm__desc", children: description }) : null
|
|
10248
|
+
] })
|
|
10249
|
+
] }),
|
|
10250
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-popconfirm__actions", children: [
|
|
10251
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "klun-popconfirm__cancel", onClick: cancel, children: cancelText }),
|
|
10252
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10253
|
+
"button",
|
|
10254
|
+
{
|
|
10255
|
+
type: "button",
|
|
10256
|
+
className: chunkTPGAXYFU_cjs.cx(
|
|
10257
|
+
"klun-popconfirm__confirm",
|
|
10258
|
+
okDanger && "klun-popconfirm__confirm--danger"
|
|
10259
|
+
),
|
|
10260
|
+
onClick: confirm,
|
|
10261
|
+
disabled: busy,
|
|
10262
|
+
children: [
|
|
10263
|
+
busy ? /* @__PURE__ */ jsxRuntime.jsx("i", { className: "ri-loader-4-line klun-popconfirm__spinner" }) : null,
|
|
10264
|
+
okText
|
|
10265
|
+
]
|
|
10266
|
+
}
|
|
10267
|
+
)
|
|
10185
10268
|
] })
|
|
10186
|
-
]
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
"button",
|
|
10191
|
-
{
|
|
10192
|
-
type: "button",
|
|
10193
|
-
className: chunkTPGAXYFU_cjs.cx(
|
|
10194
|
-
"klun-popconfirm__confirm",
|
|
10195
|
-
okDanger && "klun-popconfirm__confirm--danger"
|
|
10196
|
-
),
|
|
10197
|
-
onClick: confirm,
|
|
10198
|
-
disabled: busy,
|
|
10199
|
-
children: [
|
|
10200
|
-
busy ? /* @__PURE__ */ jsxRuntime.jsx("i", { className: "ri-loader-4-line klun-popconfirm__spinner" }) : null,
|
|
10201
|
-
okText
|
|
10202
|
-
]
|
|
10203
|
-
}
|
|
10204
|
-
)
|
|
10205
|
-
] })
|
|
10206
|
-
]
|
|
10207
|
-
}
|
|
10269
|
+
]
|
|
10270
|
+
}
|
|
10271
|
+
),
|
|
10272
|
+
document.body
|
|
10208
10273
|
) : null
|
|
10209
10274
|
] });
|
|
10210
10275
|
});
|
|
@@ -10353,5 +10418,5 @@ exports.useSize = useSize;
|
|
|
10353
10418
|
exports.viVN = viVN;
|
|
10354
10419
|
exports.zhCN = zhCN;
|
|
10355
10420
|
exports.zhTW = zhTW;
|
|
10356
|
-
//# sourceMappingURL=chunk-
|
|
10357
|
-
//# sourceMappingURL=chunk-
|
|
10421
|
+
//# sourceMappingURL=chunk-PRDLMM4A.cjs.map
|
|
10422
|
+
//# sourceMappingURL=chunk-PRDLMM4A.cjs.map
|