klun-ui 0.1.11 → 0.1.13
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 +16 -0
- package/dist/{chunk-N4NBEKYR.js → chunk-O2CR4NDQ.js} +75 -16
- package/dist/chunk-O2CR4NDQ.js.map +1 -0
- package/dist/{chunk-F7D5VPDL.cjs → chunk-Y2R5PBYN.cjs} +75 -15
- package/dist/chunk-Y2R5PBYN.cjs.map +1 -0
- package/dist/index.cjs +152 -148
- package/dist/index.d.cts +45 -5
- package/dist/index.d.ts +45 -5
- package/dist/index.js +1 -1
- package/dist/styles.css +56 -4
- package/dist/templates/index.cjs +89 -89
- package/dist/templates/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-F7D5VPDL.cjs.map +0 -1
- package/dist/chunk-N4NBEKYR.js.map +0 -1
|
@@ -190,7 +190,7 @@ var enUS = {
|
|
|
190
190
|
},
|
|
191
191
|
timePicker: { am: "AM", pm: "PM" },
|
|
192
192
|
pagination: { previous: "Previous", next: "Next" },
|
|
193
|
-
modal: { close: "Close" },
|
|
193
|
+
modal: { close: "Close", maximize: "Maximize", restore: "Restore" },
|
|
194
194
|
drawer: { close: "Close" },
|
|
195
195
|
alert: { dismiss: "Dismiss" },
|
|
196
196
|
banner: { dismiss: "Dismiss" },
|
|
@@ -284,7 +284,7 @@ var zhCN = {
|
|
|
284
284
|
},
|
|
285
285
|
timePicker: { am: "\u4E0A\u5348", pm: "\u4E0B\u5348" },
|
|
286
286
|
pagination: { previous: "\u4E0A\u4E00\u9875", next: "\u4E0B\u4E00\u9875" },
|
|
287
|
-
modal: { close: "\u5173\u95ED" },
|
|
287
|
+
modal: { close: "\u5173\u95ED", maximize: "\u6700\u5927\u5316", restore: "\u8FD8\u539F" },
|
|
288
288
|
drawer: { close: "\u5173\u95ED" },
|
|
289
289
|
alert: { dismiss: "\u5173\u95ED" },
|
|
290
290
|
banner: { dismiss: "\u5173\u95ED" },
|
|
@@ -6016,7 +6016,7 @@ var CharacterCounter = react.forwardRef(
|
|
|
6016
6016
|
}
|
|
6017
6017
|
);
|
|
6018
6018
|
CharacterCounter.displayName = "CharacterCounter";
|
|
6019
|
-
var Checkbox = react.forwardRef(function Checkbox2({ indeterminate = false, disabled = false, error = false, size: sizeProp, onChange, className, style, ...props }, ref) {
|
|
6019
|
+
var Checkbox = react.forwardRef(function Checkbox2({ indeterminate = false, disabled = false, error = false, size: sizeProp, onChange, className, style, children, ...props }, ref) {
|
|
6020
6020
|
const size = useSize(sizeProp);
|
|
6021
6021
|
const innerRef = react.useRef(null);
|
|
6022
6022
|
const setRef = (node) => {
|
|
@@ -6035,6 +6035,7 @@ var Checkbox = react.forwardRef(function Checkbox2({ indeterminate = false, disa
|
|
|
6035
6035
|
`klun-checkbox--${size}`,
|
|
6036
6036
|
disabled && "klun-checkbox--disabled",
|
|
6037
6037
|
error && "klun-checkbox--error",
|
|
6038
|
+
children != null && children !== false && "klun-checkbox--with-label",
|
|
6038
6039
|
className
|
|
6039
6040
|
),
|
|
6040
6041
|
style,
|
|
@@ -6054,12 +6055,52 @@ var Checkbox = react.forwardRef(function Checkbox2({ indeterminate = false, disa
|
|
|
6054
6055
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "klun-checkbox__box", "aria-hidden": true, children: [
|
|
6055
6056
|
/* @__PURE__ */ jsxRuntime.jsx("svg", { className: "klun-checkbox__check", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 8.5l3 3 6-6.5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
6056
6057
|
/* @__PURE__ */ jsxRuntime.jsx("svg", { className: "klun-checkbox__dash", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 8h9", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) })
|
|
6057
|
-
] })
|
|
6058
|
+
] }),
|
|
6059
|
+
children != null && children !== false && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-checkbox__label", children })
|
|
6058
6060
|
]
|
|
6059
6061
|
}
|
|
6060
6062
|
);
|
|
6061
6063
|
});
|
|
6062
6064
|
Checkbox.displayName = "Checkbox";
|
|
6065
|
+
var CheckboxGroup = react.forwardRef(function CheckboxGroup2({ options, value, defaultValue, onChange, disabled = false, size, name, direction = "horizontal", className, style, children }, ref) {
|
|
6066
|
+
const [internal, setInternal] = react.useState(defaultValue ?? []);
|
|
6067
|
+
const controlled = value != null;
|
|
6068
|
+
const current = controlled ? value : internal;
|
|
6069
|
+
const toggle = (val, checked) => {
|
|
6070
|
+
const next = checked ? [...current, val] : current.filter((v) => v !== val);
|
|
6071
|
+
if (!controlled) setInternal(next);
|
|
6072
|
+
onChange?.(next);
|
|
6073
|
+
};
|
|
6074
|
+
const norm2 = (options ?? []).map(
|
|
6075
|
+
(o) => typeof o === "string" ? { label: o, value: o } : o
|
|
6076
|
+
);
|
|
6077
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6078
|
+
"div",
|
|
6079
|
+
{
|
|
6080
|
+
ref,
|
|
6081
|
+
role: "group",
|
|
6082
|
+
className: chunkTPGAXYFU_cjs.cx("klun-checkbox-group", `klun-checkbox-group--${direction}`, className),
|
|
6083
|
+
style,
|
|
6084
|
+
children: [
|
|
6085
|
+
norm2.map((o) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6086
|
+
Checkbox,
|
|
6087
|
+
{
|
|
6088
|
+
name,
|
|
6089
|
+
size,
|
|
6090
|
+
value: o.value,
|
|
6091
|
+
checked: current.includes(o.value),
|
|
6092
|
+
disabled: disabled || o.disabled,
|
|
6093
|
+
onChange: (checked) => toggle(o.value, checked),
|
|
6094
|
+
children: o.label
|
|
6095
|
+
},
|
|
6096
|
+
o.value
|
|
6097
|
+
)),
|
|
6098
|
+
children
|
|
6099
|
+
]
|
|
6100
|
+
}
|
|
6101
|
+
);
|
|
6102
|
+
});
|
|
6103
|
+
CheckboxGroup.displayName = "CheckboxGroup";
|
|
6063
6104
|
var CheckboxCard = react.forwardRef(
|
|
6064
6105
|
function CheckboxCard2({
|
|
6065
6106
|
title,
|
|
@@ -10091,8 +10132,8 @@ var Drawer = react.forwardRef(function Drawer2({
|
|
|
10091
10132
|
title,
|
|
10092
10133
|
placement,
|
|
10093
10134
|
side,
|
|
10094
|
-
width =
|
|
10095
|
-
height =
|
|
10135
|
+
width = "50%",
|
|
10136
|
+
height = "50%",
|
|
10096
10137
|
size = "default",
|
|
10097
10138
|
closable = true,
|
|
10098
10139
|
maskClosable = true,
|
|
@@ -10382,6 +10423,8 @@ var Modal = react.forwardRef(function Modal2({
|
|
|
10382
10423
|
keyboard = true,
|
|
10383
10424
|
mask = true,
|
|
10384
10425
|
draggable = false,
|
|
10426
|
+
maximizable = false,
|
|
10427
|
+
defaultMaximized = false,
|
|
10385
10428
|
zIndex,
|
|
10386
10429
|
afterClose,
|
|
10387
10430
|
afterOpenChange,
|
|
@@ -10394,6 +10437,7 @@ var Modal = react.forwardRef(function Modal2({
|
|
|
10394
10437
|
const cancel = onCancel ?? onClose;
|
|
10395
10438
|
const backdropClosable = maskClosable ?? closeOnBackdrop ?? true;
|
|
10396
10439
|
const [pos, setPos] = react.useState({ x: 0, y: 0 });
|
|
10440
|
+
const [maximized, setMaximized] = react.useState(defaultMaximized);
|
|
10397
10441
|
const drag = react.useRef(null);
|
|
10398
10442
|
const prevOpen = react.useRef(open);
|
|
10399
10443
|
react.useEffect(() => {
|
|
@@ -10410,7 +10454,10 @@ var Modal = react.forwardRef(function Modal2({
|
|
|
10410
10454
|
};
|
|
10411
10455
|
}, [open, keyboard, closable, cancel]);
|
|
10412
10456
|
react.useEffect(() => {
|
|
10413
|
-
if (open)
|
|
10457
|
+
if (open) {
|
|
10458
|
+
setPos({ x: 0, y: 0 });
|
|
10459
|
+
setMaximized(defaultMaximized);
|
|
10460
|
+
}
|
|
10414
10461
|
if (prevOpen.current !== open) {
|
|
10415
10462
|
afterOpenChange?.(open);
|
|
10416
10463
|
if (!open) afterClose?.();
|
|
@@ -10419,8 +10466,8 @@ var Modal = react.forwardRef(function Modal2({
|
|
|
10419
10466
|
}, [open]);
|
|
10420
10467
|
if (!open) return null;
|
|
10421
10468
|
const startDrag = (e) => {
|
|
10422
|
-
if (!draggable) return;
|
|
10423
|
-
if (e.target.closest(".klun-
|
|
10469
|
+
if (!draggable || maximized) return;
|
|
10470
|
+
if (e.target.closest(".klun-modal__actions")) return;
|
|
10424
10471
|
drag.current = { sx: e.clientX, sy: e.clientY, ox: pos.x, oy: pos.y };
|
|
10425
10472
|
const move = (ev) => {
|
|
10426
10473
|
if (!drag.current) return;
|
|
@@ -10442,7 +10489,7 @@ var Modal = react.forwardRef(function Modal2({
|
|
|
10442
10489
|
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: okType === "danger" ? "error" : "primary", loading: confirmLoading, onClick: onOk, ...okButtonProps, children: okText ?? "OK" })
|
|
10443
10490
|
] });
|
|
10444
10491
|
const resolvedFooter = footer === null ? null : footer !== void 0 ? footer : defaultFooter;
|
|
10445
|
-
const dialogStyle = {
|
|
10492
|
+
const dialogStyle = maximized ? { ...style } : {
|
|
10446
10493
|
width,
|
|
10447
10494
|
...pos.x || pos.y ? { transform: `translate(${pos.x}px, ${pos.y}px)` } : null,
|
|
10448
10495
|
...style
|
|
@@ -10460,14 +10507,14 @@ var Modal = react.forwardRef(function Modal2({
|
|
|
10460
10507
|
role: "dialog",
|
|
10461
10508
|
"aria-modal": "true",
|
|
10462
10509
|
onClick: (e) => e.stopPropagation(),
|
|
10463
|
-
className: chunkTPGAXYFU_cjs.cx("klun-modal__dialog", className),
|
|
10510
|
+
className: chunkTPGAXYFU_cjs.cx("klun-modal__dialog", maximized && "klun-modal__dialog--maximized", className),
|
|
10464
10511
|
style: dialogStyle,
|
|
10465
10512
|
...props,
|
|
10466
10513
|
children: [
|
|
10467
10514
|
title || icon ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10468
10515
|
"div",
|
|
10469
10516
|
{
|
|
10470
|
-
className: chunkTPGAXYFU_cjs.cx("klun-modal__header", draggable && "klun-modal__header--draggable"),
|
|
10517
|
+
className: chunkTPGAXYFU_cjs.cx("klun-modal__header", draggable && !maximized && "klun-modal__header--draggable"),
|
|
10471
10518
|
onMouseDown: startDrag,
|
|
10472
10519
|
children: [
|
|
10473
10520
|
icon ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-modal__icon", children: icon }) : null,
|
|
@@ -10475,7 +10522,19 @@ var Modal = react.forwardRef(function Modal2({
|
|
|
10475
10522
|
title ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-modal__title", children: title }) : null,
|
|
10476
10523
|
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-modal__description", children: description }) : null
|
|
10477
10524
|
] }),
|
|
10478
|
-
closable ? /* @__PURE__ */ jsxRuntime.
|
|
10525
|
+
maximizable || closable ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-modal__actions", children: [
|
|
10526
|
+
maximizable ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10527
|
+
"button",
|
|
10528
|
+
{
|
|
10529
|
+
type: "button",
|
|
10530
|
+
onClick: () => setMaximized((m) => !m),
|
|
10531
|
+
"aria-label": maximized ? modal.restore ?? "Restore" : modal.maximize ?? "Maximize",
|
|
10532
|
+
className: "klun-modal__action",
|
|
10533
|
+
children: maximized ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 4v4H4M12 16v-4h4M12 4v4h4M8 16v-4H4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) : /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 8V4h4M16 12v4h-4M16 8V4h-4M4 12v4h4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
10534
|
+
}
|
|
10535
|
+
) : null,
|
|
10536
|
+
closable ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: cancel, "aria-label": modal.close, className: "klun-modal__action klun-modal__close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 5l10 10M15 5L5 15", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) }) : null
|
|
10537
|
+
] }) : null
|
|
10479
10538
|
]
|
|
10480
10539
|
}
|
|
10481
10540
|
) : null,
|
|
@@ -10682,6 +10741,7 @@ exports.ChartLegend = ChartLegend;
|
|
|
10682
10741
|
exports.ChartTooltip = ChartTooltip;
|
|
10683
10742
|
exports.Checkbox = Checkbox;
|
|
10684
10743
|
exports.CheckboxCard = CheckboxCard;
|
|
10744
|
+
exports.CheckboxGroup = CheckboxGroup;
|
|
10685
10745
|
exports.Chip = Chip;
|
|
10686
10746
|
exports.CircularProgress = CircularProgress;
|
|
10687
10747
|
exports.CodeViewer = CodeViewer;
|
|
@@ -10809,5 +10869,5 @@ exports.useSize = useSize;
|
|
|
10809
10869
|
exports.viVN = viVN;
|
|
10810
10870
|
exports.zhCN = zhCN;
|
|
10811
10871
|
exports.zhTW = zhTW;
|
|
10812
|
-
//# sourceMappingURL=chunk-
|
|
10813
|
-
//# sourceMappingURL=chunk-
|
|
10872
|
+
//# sourceMappingURL=chunk-Y2R5PBYN.cjs.map
|
|
10873
|
+
//# sourceMappingURL=chunk-Y2R5PBYN.cjs.map
|