klun-ui 0.1.11 → 0.1.12

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.
@@ -188,7 +188,7 @@ var enUS = {
188
188
  },
189
189
  timePicker: { am: "AM", pm: "PM" },
190
190
  pagination: { previous: "Previous", next: "Next" },
191
- modal: { close: "Close" },
191
+ modal: { close: "Close", maximize: "Maximize", restore: "Restore" },
192
192
  drawer: { close: "Close" },
193
193
  alert: { dismiss: "Dismiss" },
194
194
  banner: { dismiss: "Dismiss" },
@@ -282,7 +282,7 @@ var zhCN = {
282
282
  },
283
283
  timePicker: { am: "\u4E0A\u5348", pm: "\u4E0B\u5348" },
284
284
  pagination: { previous: "\u4E0A\u4E00\u9875", next: "\u4E0B\u4E00\u9875" },
285
- modal: { close: "\u5173\u95ED" },
285
+ modal: { close: "\u5173\u95ED", maximize: "\u6700\u5927\u5316", restore: "\u8FD8\u539F" },
286
286
  drawer: { close: "\u5173\u95ED" },
287
287
  alert: { dismiss: "\u5173\u95ED" },
288
288
  banner: { dismiss: "\u5173\u95ED" },
@@ -10380,6 +10380,8 @@ var Modal = forwardRef(function Modal2({
10380
10380
  keyboard = true,
10381
10381
  mask = true,
10382
10382
  draggable = false,
10383
+ maximizable = false,
10384
+ defaultMaximized = false,
10383
10385
  zIndex,
10384
10386
  afterClose,
10385
10387
  afterOpenChange,
@@ -10392,6 +10394,7 @@ var Modal = forwardRef(function Modal2({
10392
10394
  const cancel = onCancel ?? onClose;
10393
10395
  const backdropClosable = maskClosable ?? closeOnBackdrop ?? true;
10394
10396
  const [pos, setPos] = useState({ x: 0, y: 0 });
10397
+ const [maximized, setMaximized] = useState(defaultMaximized);
10395
10398
  const drag = useRef(null);
10396
10399
  const prevOpen = useRef(open);
10397
10400
  useEffect(() => {
@@ -10408,7 +10411,10 @@ var Modal = forwardRef(function Modal2({
10408
10411
  };
10409
10412
  }, [open, keyboard, closable, cancel]);
10410
10413
  useEffect(() => {
10411
- if (open) setPos({ x: 0, y: 0 });
10414
+ if (open) {
10415
+ setPos({ x: 0, y: 0 });
10416
+ setMaximized(defaultMaximized);
10417
+ }
10412
10418
  if (prevOpen.current !== open) {
10413
10419
  afterOpenChange?.(open);
10414
10420
  if (!open) afterClose?.();
@@ -10417,8 +10423,8 @@ var Modal = forwardRef(function Modal2({
10417
10423
  }, [open]);
10418
10424
  if (!open) return null;
10419
10425
  const startDrag = (e) => {
10420
- if (!draggable) return;
10421
- if (e.target.closest(".klun-modal__close")) return;
10426
+ if (!draggable || maximized) return;
10427
+ if (e.target.closest(".klun-modal__actions")) return;
10422
10428
  drag.current = { sx: e.clientX, sy: e.clientY, ox: pos.x, oy: pos.y };
10423
10429
  const move = (ev) => {
10424
10430
  if (!drag.current) return;
@@ -10440,7 +10446,7 @@ var Modal = forwardRef(function Modal2({
10440
10446
  /* @__PURE__ */ jsx(Button, { variant: okType === "danger" ? "error" : "primary", loading: confirmLoading, onClick: onOk, ...okButtonProps, children: okText ?? "OK" })
10441
10447
  ] });
10442
10448
  const resolvedFooter = footer === null ? null : footer !== void 0 ? footer : defaultFooter;
10443
- const dialogStyle = {
10449
+ const dialogStyle = maximized ? { ...style } : {
10444
10450
  width,
10445
10451
  ...pos.x || pos.y ? { transform: `translate(${pos.x}px, ${pos.y}px)` } : null,
10446
10452
  ...style
@@ -10458,14 +10464,14 @@ var Modal = forwardRef(function Modal2({
10458
10464
  role: "dialog",
10459
10465
  "aria-modal": "true",
10460
10466
  onClick: (e) => e.stopPropagation(),
10461
- className: cx("klun-modal__dialog", className),
10467
+ className: cx("klun-modal__dialog", maximized && "klun-modal__dialog--maximized", className),
10462
10468
  style: dialogStyle,
10463
10469
  ...props,
10464
10470
  children: [
10465
10471
  title || icon ? /* @__PURE__ */ jsxs(
10466
10472
  "div",
10467
10473
  {
10468
- className: cx("klun-modal__header", draggable && "klun-modal__header--draggable"),
10474
+ className: cx("klun-modal__header", draggable && !maximized && "klun-modal__header--draggable"),
10469
10475
  onMouseDown: startDrag,
10470
10476
  children: [
10471
10477
  icon ? /* @__PURE__ */ jsx("div", { className: "klun-modal__icon", children: icon }) : null,
@@ -10473,7 +10479,19 @@ var Modal = forwardRef(function Modal2({
10473
10479
  title ? /* @__PURE__ */ jsx("div", { className: "klun-modal__title", children: title }) : null,
10474
10480
  description ? /* @__PURE__ */ jsx("div", { className: "klun-modal__description", children: description }) : null
10475
10481
  ] }),
10476
- 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
10482
+ maximizable || closable ? /* @__PURE__ */ jsxs("div", { className: "klun-modal__actions", children: [
10483
+ maximizable ? /* @__PURE__ */ jsx(
10484
+ "button",
10485
+ {
10486
+ type: "button",
10487
+ onClick: () => setMaximized((m) => !m),
10488
+ "aria-label": maximized ? modal.restore ?? "Restore" : modal.maximize ?? "Maximize",
10489
+ className: "klun-modal__action",
10490
+ children: maximized ? /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M8 4v4H4M12 16v-4h4M12 4v4h4M8 16v-4H4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) : /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M4 8V4h4M16 12v4h-4M16 8V4h-4M4 12v4h4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
10491
+ }
10492
+ ) : null,
10493
+ closable ? /* @__PURE__ */ jsx("button", { type: "button", onClick: cancel, "aria-label": modal.close, className: "klun-modal__action 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
10494
+ ] }) : null
10477
10495
  ]
10478
10496
  }
10479
10497
  ) : null,
@@ -10661,5 +10679,5 @@ var Popconfirm = forwardRef(function Popconfirm2({
10661
10679
  Popconfirm.displayName = "Popconfirm";
10662
10680
 
10663
10681
  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, Collapse, ColorDot, ColorPicker, ColorSlider, CommandMenu, CompactSelect, CompactSelectForInput, ConfigProvider, Confirm, ContentLabel, ContextMenu2 as ContextMenu, CopyButton, CounterInput, DatePicker, DateRangePicker, DateTimePicker, Descriptions, DigitInput, Divider, Drawer, Dropdown, ExpiryCountdown, FileUpload, Flex, Form, FormItem, FormList, Format, GaugeBar, Grid, Hint, HorizontalFilter, ImageUpload, ImageViewer, 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, useContextMenu, useForm, useLocale, useMappedSize, useMessage, useNotification, useSize, viVN, zhCN, zhTW };
10664
- //# sourceMappingURL=chunk-N4NBEKYR.js.map
10665
- //# sourceMappingURL=chunk-N4NBEKYR.js.map
10682
+ //# sourceMappingURL=chunk-3XJ5FN4P.js.map
10683
+ //# sourceMappingURL=chunk-3XJ5FN4P.js.map