klun-ui 0.1.3 → 0.1.5
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 +29 -0
- package/dist/{chunk-SUH5CQ55.cjs → chunk-LDENBMG5.cjs} +187 -46
- package/dist/chunk-LDENBMG5.cjs.map +1 -0
- package/dist/{chunk-7EOW4LHP.js → chunk-Z2TY6K3O.js} +187 -46
- package/dist/chunk-Z2TY6K3O.js.map +1 -0
- package/dist/index.cjs +144 -144
- package/dist/index.d.cts +71 -5
- package/dist/index.d.ts +71 -5
- package/dist/index.js +1 -1
- package/dist/styles.css +64 -3
- package/dist/templates/index.cjs +82 -82
- package/dist/templates/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7EOW4LHP.js.map +0 -1
- package/dist/chunk-SUH5CQ55.cjs.map +0 -1
|
@@ -9836,29 +9836,83 @@ function Confirm(opts = {}) {
|
|
|
9836
9836
|
root.render(/* @__PURE__ */ jsx(ConfirmDialog, { opts, onClose: close }));
|
|
9837
9837
|
});
|
|
9838
9838
|
}
|
|
9839
|
-
var Drawer = forwardRef(function Drawer2({
|
|
9839
|
+
var Drawer = forwardRef(function Drawer2({
|
|
9840
|
+
open,
|
|
9841
|
+
onClose,
|
|
9842
|
+
title,
|
|
9843
|
+
placement,
|
|
9844
|
+
side,
|
|
9845
|
+
width = 378,
|
|
9846
|
+
height = 378,
|
|
9847
|
+
size = "default",
|
|
9848
|
+
closable = true,
|
|
9849
|
+
maskClosable = true,
|
|
9850
|
+
mask = true,
|
|
9851
|
+
keyboard = true,
|
|
9852
|
+
extra,
|
|
9853
|
+
footer,
|
|
9854
|
+
zIndex,
|
|
9855
|
+
afterOpenChange,
|
|
9856
|
+
children,
|
|
9857
|
+
className,
|
|
9858
|
+
style,
|
|
9859
|
+
...props
|
|
9860
|
+
}, ref) {
|
|
9840
9861
|
const { drawer } = useLocale();
|
|
9862
|
+
const place = placement ?? side ?? "right";
|
|
9863
|
+
const horizontal = place === "left" || place === "right";
|
|
9864
|
+
const prevOpen = useRef(open);
|
|
9865
|
+
useEffect(() => {
|
|
9866
|
+
if (!open) return;
|
|
9867
|
+
const onKey = (e) => {
|
|
9868
|
+
if (e.key === "Escape" && keyboard && closable) onClose?.();
|
|
9869
|
+
};
|
|
9870
|
+
document.addEventListener("keydown", onKey);
|
|
9871
|
+
const prevOverflow = document.body.style.overflow;
|
|
9872
|
+
document.body.style.overflow = "hidden";
|
|
9873
|
+
return () => {
|
|
9874
|
+
document.removeEventListener("keydown", onKey);
|
|
9875
|
+
document.body.style.overflow = prevOverflow;
|
|
9876
|
+
};
|
|
9877
|
+
}, [open, keyboard, closable, onClose]);
|
|
9878
|
+
useEffect(() => {
|
|
9879
|
+
if (prevOpen.current !== open) {
|
|
9880
|
+
afterOpenChange?.(open);
|
|
9881
|
+
prevOpen.current = open;
|
|
9882
|
+
}
|
|
9883
|
+
}, [open]);
|
|
9841
9884
|
if (!open) return null;
|
|
9842
|
-
|
|
9885
|
+
const axis = size === "large" ? 736 : horizontal ? width : height;
|
|
9886
|
+
const panelStyle = horizontal ? { width: axis, height: "100%", ...style } : { height: axis, width: "100%", ...style };
|
|
9887
|
+
return /* @__PURE__ */ jsx(
|
|
9843
9888
|
"div",
|
|
9844
9889
|
{
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9890
|
+
className: cx("klun-drawer", `klun-drawer--${place}`, !mask && "klun-drawer--no-mask"),
|
|
9891
|
+
style: zIndex != null ? { zIndex } : void 0,
|
|
9892
|
+
onClick: maskClosable ? onClose : void 0,
|
|
9893
|
+
children: /* @__PURE__ */ jsxs(
|
|
9894
|
+
"div",
|
|
9895
|
+
{
|
|
9896
|
+
ref,
|
|
9897
|
+
role: "dialog",
|
|
9898
|
+
"aria-modal": "true",
|
|
9899
|
+
onClick: (e) => e.stopPropagation(),
|
|
9900
|
+
className: cx("klun-drawer__panel", className),
|
|
9901
|
+
style: panelStyle,
|
|
9902
|
+
...props,
|
|
9903
|
+
children: [
|
|
9904
|
+
/* @__PURE__ */ jsxs("div", { className: "klun-drawer__header", children: [
|
|
9905
|
+
/* @__PURE__ */ jsx("div", { className: "klun-drawer__title", children: title }),
|
|
9906
|
+
extra ? /* @__PURE__ */ jsx("div", { className: "klun-drawer__extra", children: extra }) : null,
|
|
9907
|
+
closable ? /* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, "aria-label": drawer.close, className: "klun-drawer__close", children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M5 5l10 10M15 5L5 15", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) }) : null
|
|
9908
|
+
] }),
|
|
9909
|
+
/* @__PURE__ */ jsx("div", { className: "klun-drawer__body", children }),
|
|
9910
|
+
footer ? /* @__PURE__ */ jsx("div", { className: "klun-drawer__footer", children: footer }) : null
|
|
9911
|
+
]
|
|
9912
|
+
}
|
|
9913
|
+
)
|
|
9860
9914
|
}
|
|
9861
|
-
)
|
|
9915
|
+
);
|
|
9862
9916
|
});
|
|
9863
9917
|
Drawer.displayName = "Drawer";
|
|
9864
9918
|
var Dropdown = forwardRef(function Dropdown2({ trigger, items: items2 = [], align = "left", width = 220, className, ...props }, ref) {
|
|
@@ -9916,46 +9970,133 @@ var Dropdown = forwardRef(function Dropdown2({ trigger, items: items2 = [], alig
|
|
|
9916
9970
|
] });
|
|
9917
9971
|
});
|
|
9918
9972
|
Dropdown.displayName = "Dropdown";
|
|
9919
|
-
var Modal = forwardRef(function Modal2({
|
|
9973
|
+
var Modal = forwardRef(function Modal2({
|
|
9974
|
+
open,
|
|
9975
|
+
onClose,
|
|
9976
|
+
onOk,
|
|
9977
|
+
onCancel,
|
|
9978
|
+
title,
|
|
9979
|
+
description,
|
|
9980
|
+
icon,
|
|
9981
|
+
footer,
|
|
9982
|
+
okText,
|
|
9983
|
+
cancelText,
|
|
9984
|
+
confirmLoading = false,
|
|
9985
|
+
okType = "primary",
|
|
9986
|
+
okButtonProps,
|
|
9987
|
+
cancelButtonProps,
|
|
9988
|
+
width = 520,
|
|
9989
|
+
centered = false,
|
|
9990
|
+
closable = true,
|
|
9991
|
+
maskClosable,
|
|
9992
|
+
closeOnBackdrop,
|
|
9993
|
+
keyboard = true,
|
|
9994
|
+
mask = true,
|
|
9995
|
+
draggable = false,
|
|
9996
|
+
zIndex,
|
|
9997
|
+
afterClose,
|
|
9998
|
+
afterOpenChange,
|
|
9999
|
+
children,
|
|
10000
|
+
className,
|
|
10001
|
+
style,
|
|
10002
|
+
...props
|
|
10003
|
+
}, ref) {
|
|
9920
10004
|
const { modal } = useLocale();
|
|
10005
|
+
const cancel = onCancel ?? onClose;
|
|
10006
|
+
const backdropClosable = maskClosable ?? closeOnBackdrop ?? true;
|
|
10007
|
+
const [pos, setPos] = useState({ x: 0, y: 0 });
|
|
10008
|
+
const drag = useRef(null);
|
|
10009
|
+
const prevOpen = useRef(open);
|
|
9921
10010
|
useEffect(() => {
|
|
9922
10011
|
if (!open) return;
|
|
9923
10012
|
const onKey = (e) => {
|
|
9924
|
-
if (e.key === "Escape" && closable)
|
|
10013
|
+
if (e.key === "Escape" && keyboard && closable) cancel?.();
|
|
9925
10014
|
};
|
|
9926
10015
|
document.addEventListener("keydown", onKey);
|
|
9927
|
-
const
|
|
10016
|
+
const prevOverflow = document.body.style.overflow;
|
|
9928
10017
|
document.body.style.overflow = "hidden";
|
|
9929
10018
|
return () => {
|
|
9930
10019
|
document.removeEventListener("keydown", onKey);
|
|
9931
|
-
document.body.style.overflow =
|
|
10020
|
+
document.body.style.overflow = prevOverflow;
|
|
9932
10021
|
};
|
|
9933
|
-
}, [open, closable,
|
|
10022
|
+
}, [open, keyboard, closable, cancel]);
|
|
10023
|
+
useEffect(() => {
|
|
10024
|
+
if (open) setPos({ x: 0, y: 0 });
|
|
10025
|
+
if (prevOpen.current !== open) {
|
|
10026
|
+
afterOpenChange?.(open);
|
|
10027
|
+
if (!open) afterClose?.();
|
|
10028
|
+
prevOpen.current = open;
|
|
10029
|
+
}
|
|
10030
|
+
}, [open]);
|
|
9934
10031
|
if (!open) return null;
|
|
9935
|
-
|
|
10032
|
+
const startDrag = (e) => {
|
|
10033
|
+
if (!draggable) return;
|
|
10034
|
+
if (e.target.closest(".klun-modal__close")) return;
|
|
10035
|
+
drag.current = { sx: e.clientX, sy: e.clientY, ox: pos.x, oy: pos.y };
|
|
10036
|
+
const move = (ev) => {
|
|
10037
|
+
if (!drag.current) return;
|
|
10038
|
+
setPos({
|
|
10039
|
+
x: drag.current.ox + (ev.clientX - drag.current.sx),
|
|
10040
|
+
y: drag.current.oy + (ev.clientY - drag.current.sy)
|
|
10041
|
+
});
|
|
10042
|
+
};
|
|
10043
|
+
const up = () => {
|
|
10044
|
+
drag.current = null;
|
|
10045
|
+
document.removeEventListener("mousemove", move);
|
|
10046
|
+
document.removeEventListener("mouseup", up);
|
|
10047
|
+
};
|
|
10048
|
+
document.addEventListener("mousemove", move);
|
|
10049
|
+
document.addEventListener("mouseup", up);
|
|
10050
|
+
};
|
|
10051
|
+
const defaultFooter = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10052
|
+
/* @__PURE__ */ jsx(Button, { variant: "neutral", appearance: "stroke", disabled: confirmLoading, onClick: cancel, ...cancelButtonProps, children: cancelText ?? "Cancel" }),
|
|
10053
|
+
/* @__PURE__ */ jsx(Button, { variant: okType === "danger" ? "error" : "primary", loading: confirmLoading, onClick: onOk, ...okButtonProps, children: okText ?? "OK" })
|
|
10054
|
+
] });
|
|
10055
|
+
const resolvedFooter = footer === null ? null : footer !== void 0 ? footer : defaultFooter;
|
|
10056
|
+
const dialogStyle = {
|
|
10057
|
+
width,
|
|
10058
|
+
...pos.x || pos.y ? { transform: `translate(${pos.x}px, ${pos.y}px)` } : null,
|
|
10059
|
+
...style
|
|
10060
|
+
};
|
|
10061
|
+
return /* @__PURE__ */ jsx(
|
|
9936
10062
|
"div",
|
|
9937
10063
|
{
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
10064
|
+
className: cx("klun-modal", centered && "klun-modal--centered", !mask && "klun-modal--no-mask"),
|
|
10065
|
+
style: zIndex != null ? { zIndex } : void 0,
|
|
10066
|
+
onClick: backdropClosable && closable ? cancel : void 0,
|
|
10067
|
+
children: /* @__PURE__ */ jsxs(
|
|
10068
|
+
"div",
|
|
10069
|
+
{
|
|
10070
|
+
ref,
|
|
10071
|
+
role: "dialog",
|
|
10072
|
+
"aria-modal": "true",
|
|
10073
|
+
onClick: (e) => e.stopPropagation(),
|
|
10074
|
+
className: cx("klun-modal__dialog", className),
|
|
10075
|
+
style: dialogStyle,
|
|
10076
|
+
...props,
|
|
10077
|
+
children: [
|
|
10078
|
+
title || icon ? /* @__PURE__ */ jsxs(
|
|
10079
|
+
"div",
|
|
10080
|
+
{
|
|
10081
|
+
className: cx("klun-modal__header", draggable && "klun-modal__header--draggable"),
|
|
10082
|
+
onMouseDown: startDrag,
|
|
10083
|
+
children: [
|
|
10084
|
+
icon ? /* @__PURE__ */ jsx("div", { className: "klun-modal__icon", children: icon }) : null,
|
|
10085
|
+
/* @__PURE__ */ jsxs("div", { className: "klun-modal__heading", children: [
|
|
10086
|
+
title ? /* @__PURE__ */ jsx("div", { className: "klun-modal__title", children: title }) : null,
|
|
10087
|
+
description ? /* @__PURE__ */ jsx("div", { className: "klun-modal__description", children: description }) : null
|
|
10088
|
+
] }),
|
|
10089
|
+
closable ? /* @__PURE__ */ jsx("button", { type: "button", onClick: cancel, "aria-label": modal.close, className: "klun-modal__close", children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M5 5l10 10M15 5L5 15", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) }) : null
|
|
10090
|
+
]
|
|
10091
|
+
}
|
|
10092
|
+
) : null,
|
|
10093
|
+
children ? /* @__PURE__ */ jsx("div", { className: "klun-modal__body", children }) : null,
|
|
10094
|
+
resolvedFooter ? /* @__PURE__ */ jsx("div", { className: cx("klun-modal__footer", !children && "klun-modal__footer--flush"), children: resolvedFooter }) : null
|
|
10095
|
+
]
|
|
10096
|
+
}
|
|
10097
|
+
)
|
|
9957
10098
|
}
|
|
9958
|
-
)
|
|
10099
|
+
);
|
|
9959
10100
|
});
|
|
9960
10101
|
Modal.displayName = "Modal";
|
|
9961
10102
|
var Popconfirm = forwardRef(function Popconfirm2({
|
|
@@ -10068,5 +10209,5 @@ var Popconfirm = forwardRef(function Popconfirm2({
|
|
|
10068
10209
|
Popconfirm.displayName = "Popconfirm";
|
|
10069
10210
|
|
|
10070
10211
|
export { Accordion, Alert, AutoComplete, Avatar, AvatarGroup, Badge, Banner, Breadcrumb, BulkAction, BulkActionBar, Button, ButtonGroup, Card, Carousel, Cascader, CharacterCounter, ChartLegend, ChartTooltip, Checkbox, CheckboxCard, Chip, CircularProgress, CodeViewer, Col, ColorDot, ColorPicker, ColorSlider, CommandMenu, CompactSelect, CompactSelectForInput, ConfigProvider, Confirm, ContentLabel, CopyButton, CounterInput, DatePicker, DateRangePicker, DateTimePicker, Descriptions, DigitInput, Divider, Drawer, Dropdown, ExpiryCountdown, FileUpload, Flex, Form, FormItem, FormList, Format, GaugeBar, Grid, Hint, HorizontalFilter, ImageUpload, InlineInput, InlineSelect, Input, Kbd, KeyIcon, Label, Layout, LayoutContent, LayoutFooter, LayoutHeader, LayoutSider, List, ListItem, LiveDot, LogViewer, Masonry, Menu, Message, Modal, Money, Notification, Pagination, PasswordStrength, Popconfirm, Popover, ProgressBar, Radio, RadioCard, RangeSlider, Rating, RelativeTime, RichEditorToolbar, Row, SegmentedControl, SegmentedProgress, Select, SelectMenu, Skeleton, Slider, Space, Spinner2 as Spinner, Splitter2 as Splitter, SplitterPanel, Statistic, StatusBadge, StatusDot, StepIndicator, Switch, Table, Tabs, Tag, Textarea, TimePicker, Timeline, Toast, Toaster, Tooltip, Tree, Wizard, arSA, deDE, enUS, esES, fmt, frFR, idID, itIT, jaJP, koKR, locales, nlNL, plPL, primaryColorVars, ptBR, ruRU, toast, trTR, useBreakpoint, useConfig, useForm, useLocale, useMappedSize, useMessage, useNotification, useSize, viVN, zhCN, zhTW };
|
|
10071
|
-
//# sourceMappingURL=chunk-
|
|
10072
|
-
//# sourceMappingURL=chunk-
|
|
10212
|
+
//# sourceMappingURL=chunk-Z2TY6K3O.js.map
|
|
10213
|
+
//# sourceMappingURL=chunk-Z2TY6K3O.js.map
|