@pactor-app/ui 1.13.0 → 1.15.0

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.
@@ -16,7 +16,7 @@ import {
16
16
  TooltipTrigger,
17
17
  useIsMobile,
18
18
  useSidebar
19
- } from "./chunk-AUSWAD26.js";
19
+ } from "./chunk-HGVZUEZG.js";
20
20
  import {
21
21
  cn
22
22
  } from "./chunk-WKJUCGV4.js";
@@ -2,7 +2,7 @@ import {
2
2
  Icon,
3
3
  Menu,
4
4
  Sidebar
5
- } from "./chunk-GQE62HDV.js";
5
+ } from "./chunk-5PTCPU2F.js";
6
6
  import {
7
7
  Alert,
8
8
  AlertDescription,
@@ -141,7 +141,7 @@ import {
141
141
  chartColor,
142
142
  navigationMenuTriggerStyle,
143
143
  toast
144
- } from "./chunk-NQQAPB7Q.js";
144
+ } from "./chunk-VFPLY2GI.js";
145
145
  import {
146
146
  Dialog,
147
147
  DialogContent,
@@ -176,7 +176,7 @@ import {
176
176
  Tooltip,
177
177
  TooltipContent,
178
178
  TooltipTrigger
179
- } from "./chunk-AUSWAD26.js";
179
+ } from "./chunk-HGVZUEZG.js";
180
180
  import {
181
181
  Button,
182
182
  cn
@@ -1645,18 +1645,49 @@ function Empty2({ title, description, children, className, style }) {
1645
1645
 
1646
1646
  // src/components/components/Field/index.tsx
1647
1647
  import { jsx as jsx28, jsxs as jsxs23 } from "react/jsx-runtime";
1648
- function Field2({ label, required, description, error, children, className, style }) {
1648
+ function Field2({
1649
+ label,
1650
+ required,
1651
+ description,
1652
+ error,
1653
+ children,
1654
+ className,
1655
+ style,
1656
+ labelClassName,
1657
+ labelStyle,
1658
+ controlClassName,
1659
+ controlStyle,
1660
+ descriptionClassName,
1661
+ descriptionStyle,
1662
+ errorClassName,
1663
+ errorStyle
1664
+ }) {
1649
1665
  return /* @__PURE__ */ jsxs23(Field, { className, style, children: [
1650
- label ? /* @__PURE__ */ jsxs23(FieldLabel, { children: [
1666
+ label ? /* @__PURE__ */ jsxs23(FieldLabel, { className: labelClassName, style: labelStyle, children: [
1651
1667
  required ? /* @__PURE__ */ jsxs23("span", { "aria-hidden": true, className: "text-destructive", children: [
1652
1668
  "*",
1653
1669
  " "
1654
1670
  ] }) : null,
1655
1671
  label
1656
1672
  ] }) : null,
1657
- children,
1658
- description ? /* @__PURE__ */ jsx28(FieldDescription, { children: description }) : null,
1659
- error ? /* @__PURE__ */ jsx28(FieldError, { match: true, children: error }) : null
1673
+ /* @__PURE__ */ jsx28(
1674
+ "div",
1675
+ {
1676
+ "data-slot": "field-control",
1677
+ className: cn(label ? "mt-2" : void 0, controlClassName),
1678
+ style: controlStyle,
1679
+ children
1680
+ }
1681
+ ),
1682
+ description ? /* @__PURE__ */ jsx28(
1683
+ FieldDescription,
1684
+ {
1685
+ className: descriptionClassName,
1686
+ style: descriptionStyle,
1687
+ children: description
1688
+ }
1689
+ ) : null,
1690
+ error ? /* @__PURE__ */ jsx28(FieldError, { match: true, className: errorClassName, style: errorStyle, children: error }) : null
1660
1691
  ] });
1661
1692
  }
1662
1693
 
@@ -1853,6 +1884,7 @@ function Grid({ columns = 1, gap, className, style, children }) {
1853
1884
  // src/components/components/Header/index.tsx
1854
1885
  import { useI18n as useI18n5 } from "@pactor-app/runtime";
1855
1886
  import { ChevronDownIcon } from "lucide-react";
1887
+ import { useState as useState10 } from "react";
1856
1888
  import { Fragment as Fragment2, jsx as jsx33, jsxs as jsxs24 } from "react/jsx-runtime";
1857
1889
  var menuItemClass = "flex items-center gap-1 rounded-md px-3 py-2 text-sm transition-colors text-muted-foreground hover:bg-accent/50 hover:text-foreground";
1858
1890
  function Header({
@@ -1863,6 +1895,8 @@ function Header({
1863
1895
  menu,
1864
1896
  user,
1865
1897
  locales,
1898
+ themeToggle = false,
1899
+ onThemeChange,
1866
1900
  onMenuSelect,
1867
1901
  onDropdownSelect,
1868
1902
  onUserSelect,
@@ -1883,7 +1917,7 @@ function Header({
1883
1917
  "flex h-14 shrink-0 items-center gap-4 border-b bg-card px-4",
1884
1918
  className
1885
1919
  );
1886
- if (!hasBrand && !dropdown && !hasMenu && !hasUser && !hasLocales) {
1920
+ if (!hasBrand && !dropdown && !hasMenu && !hasUser && !hasLocales && !themeToggle) {
1887
1921
  return /* @__PURE__ */ jsx33("header", { "data-slot": "layout-header", className: rootClass, style, children });
1888
1922
  }
1889
1923
  const brandNode = hasBrand && /* @__PURE__ */ jsxs24("div", { "data-slot": "header-brand", className: "flex items-center gap-2", children: [
@@ -1900,7 +1934,7 @@ function Header({
1900
1934
  ] });
1901
1935
  const dropdownNode = dropdown !== void 0 && /* @__PURE__ */ jsx33(HeaderDropdownArea, { dropdown, onSelect: onDropdownSelect });
1902
1936
  const showLeft = brandLeft || dropdownLeft || hasMenu;
1903
- const showRight = dropdownRight || brandRight || hasLocales || hasUser;
1937
+ const showRight = dropdownRight || brandRight || hasLocales || hasUser || themeToggle;
1904
1938
  return /* @__PURE__ */ jsxs24("header", { "data-slot": "layout-header", className: rootClass, style, children: [
1905
1939
  showLeft && /* @__PURE__ */ jsxs24("div", { "data-slot": "header-left", className: "flex items-center gap-4", children: [
1906
1940
  brandLeft && brandNode,
@@ -1911,6 +1945,7 @@ function Header({
1911
1945
  showRight && /* @__PURE__ */ jsxs24("div", { "data-slot": "header-right", className: "flex items-center gap-4", children: [
1912
1946
  dropdownRight && dropdownNode,
1913
1947
  brandRight && brandNode,
1948
+ themeToggle && /* @__PURE__ */ jsx33(HeaderThemeToggle, { onSelect: onThemeChange }),
1914
1949
  hasLocales && /* @__PURE__ */ jsx33(HeaderLocalesArea, { locales, onSelect: onLocaleChange }),
1915
1950
  hasUser && /* @__PURE__ */ jsx33(HeaderUserArea, { user, onSelect: onUserSelect })
1916
1951
  ] })
@@ -2058,6 +2093,39 @@ function HeaderLocalesArea({
2058
2093
  )) })
2059
2094
  ] });
2060
2095
  }
2096
+ function readCurrentTheme() {
2097
+ if (typeof document === "undefined") {
2098
+ return "light";
2099
+ }
2100
+ return document.documentElement.getAttribute("data-pactor-theme") === "dark" ? "dark" : "light";
2101
+ }
2102
+ function HeaderThemeToggle({
2103
+ onSelect
2104
+ }) {
2105
+ const [theme, setTheme] = useState10(readCurrentTheme);
2106
+ const handleToggle = () => {
2107
+ const next = readCurrentTheme() === "dark" ? "light" : "dark";
2108
+ if (next === "dark") {
2109
+ document.documentElement.setAttribute("data-pactor-theme", "dark");
2110
+ } else {
2111
+ document.documentElement.removeAttribute("data-pactor-theme");
2112
+ }
2113
+ setTheme(next);
2114
+ onSelect?.(next);
2115
+ };
2116
+ return /* @__PURE__ */ jsx33(
2117
+ "button",
2118
+ {
2119
+ type: "button",
2120
+ "data-slot": "header-theme-toggle",
2121
+ className: "flex size-8 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",
2122
+ title: theme === "dark" ? "\u5207\u6362\u4E3A\u6D45\u8272" : "\u5207\u6362\u4E3A\u6DF1\u8272",
2123
+ "aria-label": "\u5207\u6362\u660E\u6697\u4E3B\u9898",
2124
+ onClick: handleToggle,
2125
+ children: theme === "dark" ? /* @__PURE__ */ jsx33(Icon, { name: "sun", size: "sm" }) : /* @__PURE__ */ jsx33(Icon, { name: "moon", size: "sm" })
2126
+ }
2127
+ );
2128
+ }
2061
2129
 
2062
2130
  // src/components/components/HoverCard/index.tsx
2063
2131
  import { useRenderer as useRenderer9 } from "@pactor-app/runtime";
@@ -2191,7 +2259,7 @@ function InputGroup2({ className, style, children }) {
2191
2259
  }
2192
2260
 
2193
2261
  // src/components/components/InputOTP/index.tsx
2194
- import { useEffect as useEffect8, useState as useState10 } from "react";
2262
+ import { useEffect as useEffect8, useState as useState11 } from "react";
2195
2263
  import { jsx as jsx37, jsxs as jsxs27 } from "react/jsx-runtime";
2196
2264
  function InputOTP2({
2197
2265
  name,
@@ -2214,7 +2282,7 @@ function InputOTP2({
2214
2282
  }
2215
2283
  return void 0;
2216
2284
  });
2217
- const [innerValue, setInnerValue] = useState10(typeof value === "string" ? value : "");
2285
+ const [innerValue, setInnerValue] = useState11(typeof value === "string" ? value : "");
2218
2286
  useEffect8(() => {
2219
2287
  if (!inForm) setInnerValue(typeof value === "string" ? value : "");
2220
2288
  }, [inForm, value]);
@@ -2419,7 +2487,7 @@ function Page({ title, className, style, children }) {
2419
2487
  }
2420
2488
 
2421
2489
  // src/components/components/Pagination/index.tsx
2422
- import { useState as useState11 } from "react";
2490
+ import { useState as useState12 } from "react";
2423
2491
  import { jsx as jsx46, jsxs as jsxs32 } from "react/jsx-runtime";
2424
2492
  function pageItems(current, count) {
2425
2493
  if (count <= 7) {
@@ -2441,7 +2509,7 @@ function Pagination2({
2441
2509
  className,
2442
2510
  style
2443
2511
  }) {
2444
- const [innerPage, setInnerPage] = useState11(1);
2512
+ const [innerPage, setInnerPage] = useState12(1);
2445
2513
  const pageCount = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));
2446
2514
  const current = Math.min(Math.max(1, page ?? innerPage), pageCount);
2447
2515
  const goTo = (next) => {
@@ -3087,7 +3155,7 @@ function Switch2({
3087
3155
 
3088
3156
  // src/components/components/Table/index.tsx
3089
3157
  import { useI18n as useI18n8, useRenderer as useRenderer15 } from "@pactor-app/runtime";
3090
- import { useState as useState12 } from "react";
3158
+ import { useState as useState13 } from "react";
3091
3159
  import { jsx as jsx63, jsxs as jsxs43 } from "react/jsx-runtime";
3092
3160
  function renderCellValue2(value) {
3093
3161
  if (value === void 0 || value === null) {
@@ -3110,7 +3178,7 @@ function Table2({
3110
3178
  }) {
3111
3179
  const { renderChildren } = useRenderer15();
3112
3180
  const { t } = useI18n8();
3113
- const [current, setCurrent] = useState12(1);
3181
+ const [current, setCurrent] = useState13(1);
3114
3182
  const pageSize = pagination === false ? void 0 : pagination?.pageSize;
3115
3183
  const total = dataSource.length;
3116
3184
  const pageCount = pageSize !== void 0 && pageSize > 0 ? Math.max(1, Math.ceil(total / pageSize)) : 1;
@@ -663,7 +663,12 @@ function SidebarRoot({
663
663
  className: cn(
664
664
  "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
665
665
  side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
666
- variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
666
+ variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : (
667
+ // 边框色显式声明:不能只给宽度——宿主引入 Tailwind 时其
668
+ // preflight(同为 base 层且后加载)会把默认 border-color
669
+ // 重置为 currentColor,宽度型边框会脱离皮肤令牌
670
+ "border-sidebar-border group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l"
671
+ ),
667
672
  className
668
673
  ),
669
674
  ...props,
@@ -2,7 +2,7 @@ import {
2
2
  Icon,
3
3
  Menu,
4
4
  Sidebar
5
- } from "./chunk-GQE62HDV.js";
5
+ } from "./chunk-5PTCPU2F.js";
6
6
  import {
7
7
  Accordion,
8
8
  AccordionContent,
@@ -15,7 +15,7 @@ import {
15
15
  Popover,
16
16
  PopoverContent,
17
17
  PopoverTrigger
18
- } from "./chunk-AUSWAD26.js";
18
+ } from "./chunk-HGVZUEZG.js";
19
19
  import {
20
20
  cn
21
21
  } from "./chunk-WKJUCGV4.js";
@@ -2,7 +2,7 @@ import {
2
2
  Popover,
3
3
  PopoverContent,
4
4
  PopoverTrigger
5
- } from "./chunk-AUSWAD26.js";
5
+ } from "./chunk-HGVZUEZG.js";
6
6
  import {
7
7
  Button,
8
8
  buttonVariants,