@pactor-app/ui 1.10.0 → 1.12.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-VM4FESQB.js";
19
+ } from "./chunk-AUSWAD26.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-PECP7DJB.js";
5
+ } from "./chunk-2B5YV2HR.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-VT5XP4U4.js";
144
+ } from "./chunk-XEK5NQJA.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-VM4FESQB.js";
179
+ } from "./chunk-AUSWAD26.js";
180
180
  import {
181
181
  Button,
182
182
  cn
@@ -325,13 +325,38 @@ function Badge2({ text, variant = "default", className, style }) {
325
325
 
326
326
  // src/components/components/Breadcrumb/index.tsx
327
327
  import { Fragment } from "react";
328
+
329
+ // src/components/spa-link.ts
330
+ import { useRenderer as useRenderer3 } from "@pactor-app/runtime";
331
+ function shouldInterceptLinkClick(event, href, target) {
332
+ return typeof href === "string" && href.startsWith("/") && (target === void 0 || target === "_self") && event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
333
+ }
334
+ function useSpaLinkClick() {
335
+ const { context } = useRenderer3();
336
+ return (event, href, target) => {
337
+ if (shouldInterceptLinkClick(event, href, target)) {
338
+ event.preventDefault();
339
+ context.route.navigate(href);
340
+ }
341
+ };
342
+ }
343
+
344
+ // src/components/components/Breadcrumb/index.tsx
328
345
  import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
329
346
  function Breadcrumb2({ items = [], className, style }) {
347
+ const handleSpaClick = useSpaLinkClick();
330
348
  return /* @__PURE__ */ jsx8(Breadcrumb, { className, style, children: /* @__PURE__ */ jsx8(BreadcrumbList, { children: items.map((item, index) => {
331
349
  const isLast = index === items.length - 1;
332
350
  return /* @__PURE__ */ jsxs5(Fragment, { children: [
333
351
  index > 0 ? /* @__PURE__ */ jsx8(BreadcrumbSeparator, {}) : null,
334
- /* @__PURE__ */ jsx8(BreadcrumbItem, { children: isLast || !item.href ? /* @__PURE__ */ jsx8(BreadcrumbPage, { children: item.label }) : /* @__PURE__ */ jsx8(BreadcrumbLink, { href: item.href, children: item.label }) })
352
+ /* @__PURE__ */ jsx8(BreadcrumbItem, { children: isLast || !item.href ? /* @__PURE__ */ jsx8(BreadcrumbPage, { children: item.label }) : /* @__PURE__ */ jsx8(
353
+ BreadcrumbLink,
354
+ {
355
+ href: item.href,
356
+ onClick: (event) => handleSpaClick(event, item.href),
357
+ children: item.label
358
+ }
359
+ ) })
335
360
  ] }, `${item.label}-${index}`);
336
361
  }) }) });
337
362
  }
@@ -353,6 +378,8 @@ var sizeMap = {
353
378
  };
354
379
  function Button2({
355
380
  text,
381
+ icon,
382
+ tooltip,
356
383
  variant = "default",
357
384
  danger,
358
385
  size = "middle",
@@ -365,7 +392,7 @@ function Button2({
365
392
  children
366
393
  }) {
367
394
  const textual = variant === "link" || variant === "text";
368
- return /* @__PURE__ */ jsxs6(
395
+ const button = /* @__PURE__ */ jsxs6(
369
396
  Button,
370
397
  {
371
398
  type: submit ? "submit" : "button",
@@ -381,11 +408,18 @@ function Button2({
381
408
  className
382
409
  ),
383
410
  children: [
384
- loading ? /* @__PURE__ */ jsx9(Loader2, { "aria-hidden": true, className: "animate-spin" }) : null,
411
+ loading ? /* @__PURE__ */ jsx9(Loader2, { "aria-hidden": true, className: "animate-spin" }) : icon ? /* @__PURE__ */ jsx9(Icon, { name: icon, size: "sm" }) : null,
385
412
  text ?? children
386
413
  ]
387
414
  }
388
415
  );
416
+ if (tooltip) {
417
+ return /* @__PURE__ */ jsxs6(Tooltip, { children: [
418
+ /* @__PURE__ */ jsx9(TooltipTrigger, { render: button }),
419
+ /* @__PURE__ */ jsx9(TooltipContent, { children: tooltip })
420
+ ] });
421
+ }
422
+ return button;
389
423
  }
390
424
 
391
425
  // src/components/components/ButtonGroup/index.tsx
@@ -499,7 +533,7 @@ function Card2({ title, bordered = true, rounded, className, style, children })
499
533
  }
500
534
 
501
535
  // src/components/components/Carousel/index.tsx
502
- import { useRenderer as useRenderer3 } from "@pactor-app/runtime";
536
+ import { useRenderer as useRenderer4 } from "@pactor-app/runtime";
503
537
  import { useEffect as useEffect2, useState as useState2 } from "react";
504
538
  import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
505
539
  function isDslNode(item) {
@@ -512,7 +546,7 @@ function Carousel2({
512
546
  className,
513
547
  style
514
548
  }) {
515
- const { renderChildren } = useRenderer3();
549
+ const { renderChildren } = useRenderer4();
516
550
  const [api, setApi] = useState2();
517
551
  useEffect2(() => {
518
552
  if (!api || !autoplay) return;
@@ -890,7 +924,7 @@ function Chart({
890
924
  }
891
925
 
892
926
  // src/components/components/ChatInput/index.tsx
893
- import { useRenderer as useRenderer4 } from "@pactor-app/runtime";
927
+ import { useRenderer as useRenderer5 } from "@pactor-app/runtime";
894
928
  import { ArrowUp } from "lucide-react";
895
929
  import {
896
930
  useRef,
@@ -912,7 +946,7 @@ function ChatInput({
912
946
  className,
913
947
  style
914
948
  }) {
915
- const { renderChildren } = useRenderer4();
949
+ const { renderChildren } = useRenderer5();
916
950
  const controlled = value !== void 0;
917
951
  const [draft, setDraft] = useState5("");
918
952
  const text = controlled ? value : draft;
@@ -1032,7 +1066,7 @@ function ContextMenu2({
1032
1066
  }
1033
1067
 
1034
1068
  // src/components/components/DataTable/index.tsx
1035
- import { useI18n as useI18n3, useRenderer as useRenderer5 } from "@pactor-app/runtime";
1069
+ import { useI18n as useI18n3, useRenderer as useRenderer6 } from "@pactor-app/runtime";
1036
1070
  import { ArrowDown, ArrowUp as ArrowUp2, ArrowUpDown } from "lucide-react";
1037
1071
  import { useMemo, useState as useState6 } from "react";
1038
1072
  import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
@@ -1062,7 +1096,7 @@ function DataTable({
1062
1096
  className,
1063
1097
  style
1064
1098
  }) {
1065
- const { renderChildren } = useRenderer5();
1099
+ const { renderChildren } = useRenderer6();
1066
1100
  const { t } = useI18n3();
1067
1101
  const [sortState, setSortState] = useState6(sort);
1068
1102
  const [filters, setFilters] = useState6({});
@@ -1484,7 +1518,7 @@ function DatePicker(props) {
1484
1518
  }
1485
1519
 
1486
1520
  // src/components/components/Dialog/index.tsx
1487
- import { useRenderer as useRenderer6 } from "@pactor-app/runtime";
1521
+ import { useRenderer as useRenderer7 } from "@pactor-app/runtime";
1488
1522
  import { useState as useState8 } from "react";
1489
1523
  import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
1490
1524
  function Dialog2({
@@ -1497,7 +1531,7 @@ function Dialog2({
1497
1531
  className,
1498
1532
  style
1499
1533
  }) {
1500
- const { renderChildren } = useRenderer6();
1534
+ const { renderChildren } = useRenderer7();
1501
1535
  const [innerOpen, setInnerOpen] = useState8(false);
1502
1536
  const controlled = open !== void 0;
1503
1537
  const visible = controlled ? open : innerOpen;
@@ -1611,9 +1645,15 @@ function Empty2({ title, description, children, className, style }) {
1611
1645
 
1612
1646
  // src/components/components/Field/index.tsx
1613
1647
  import { jsx as jsx28, jsxs as jsxs23 } from "react/jsx-runtime";
1614
- function Field2({ label, description, error, children, className, style }) {
1648
+ function Field2({ label, required, description, error, children, className, style }) {
1615
1649
  return /* @__PURE__ */ jsxs23(Field, { className, style, children: [
1616
- label ? /* @__PURE__ */ jsx28(FieldLabel, { children: label }) : null,
1650
+ label ? /* @__PURE__ */ jsxs23(FieldLabel, { children: [
1651
+ required ? /* @__PURE__ */ jsxs23("span", { "aria-hidden": true, className: "text-destructive", children: [
1652
+ "*",
1653
+ " "
1654
+ ] }) : null,
1655
+ label
1656
+ ] }) : null,
1617
1657
  children,
1618
1658
  description ? /* @__PURE__ */ jsx28(FieldDescription, { children: description }) : null,
1619
1659
  error ? /* @__PURE__ */ jsx28(FieldError, { match: true, children: error }) : null
@@ -1688,7 +1728,7 @@ function Footer({ className, style, children }) {
1688
1728
  }
1689
1729
 
1690
1730
  // src/components/components/Form/index.tsx
1691
- import { useRenderer as useRenderer7 } from "@pactor-app/runtime";
1731
+ import { useRenderer as useRenderer8 } from "@pactor-app/runtime";
1692
1732
  import {
1693
1733
  useCallback,
1694
1734
  useEffect as useEffect6,
@@ -1710,7 +1750,7 @@ function Form({
1710
1750
  onSubmit,
1711
1751
  onValuesChange
1712
1752
  }) {
1713
- const { context } = useRenderer7();
1753
+ const { context } = useRenderer8();
1714
1754
  const [values, setValues] = useState9(() => ({
1715
1755
  ...initialValues
1716
1756
  }));
@@ -2020,13 +2060,13 @@ function HeaderLocalesArea({
2020
2060
  }
2021
2061
 
2022
2062
  // src/components/components/HoverCard/index.tsx
2023
- import { useRenderer as useRenderer8 } from "@pactor-app/runtime";
2063
+ import { useRenderer as useRenderer9 } from "@pactor-app/runtime";
2024
2064
  import { jsx as jsx34, jsxs as jsxs25 } from "react/jsx-runtime";
2025
2065
  function isDslNode2(value) {
2026
2066
  return typeof value === "object" && value !== null && typeof value.type === "string";
2027
2067
  }
2028
2068
  function HoverCard2({ content, children, className, style }) {
2029
- const { renderChildren } = useRenderer8();
2069
+ const { renderChildren } = useRenderer9();
2030
2070
  return /* @__PURE__ */ jsxs25(HoverCard, { children: [
2031
2071
  /* @__PURE__ */ jsx34(HoverCardTrigger, { render: triggerWrapper("hover-card-trigger-wrap"), children }),
2032
2072
  /* @__PURE__ */ jsx34(HoverCardContent, { className, style, children: isDslNode2(content) ? renderChildren([content]) : content })
@@ -2048,6 +2088,7 @@ function Input2({
2048
2088
  allowClear,
2049
2089
  onChange,
2050
2090
  className,
2091
+ controlClassName,
2051
2092
  style
2052
2093
  }) {
2053
2094
  const form = useFormContext();
@@ -2079,7 +2120,10 @@ function Input2({
2079
2120
  value: currentValue,
2080
2121
  placeholder,
2081
2122
  disabled,
2082
- className: !inFormRoot && allowClear !== true ? className : void 0,
2123
+ className: cn(
2124
+ !inFormRoot && allowClear !== true && className,
2125
+ allowClear !== true && controlClassName
2126
+ ),
2083
2127
  style: !inFormRoot && allowClear !== true ? style : void 0,
2084
2128
  onChange: (event) => {
2085
2129
  if (inForm && form && name) {
@@ -2102,7 +2146,11 @@ function Input2({
2102
2146
  const control = allowClear === true ? /* @__PURE__ */ jsxs26(
2103
2147
  "span",
2104
2148
  {
2105
- className: cn("flex items-center gap-1", !inFormRoot && className),
2149
+ className: cn(
2150
+ "flex items-center gap-1",
2151
+ !inFormRoot && className,
2152
+ controlClassName
2153
+ ),
2106
2154
  style: inFormRoot ? void 0 : style,
2107
2155
  children: [
2108
2156
  input,
@@ -2212,7 +2260,7 @@ function InputOTP2({
2212
2260
  }
2213
2261
 
2214
2262
  // src/components/components/Item/index.tsx
2215
- import { useRenderer as useRenderer9 } from "@pactor-app/runtime";
2263
+ import { useRenderer as useRenderer10 } from "@pactor-app/runtime";
2216
2264
  import { jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
2217
2265
  function Item2({
2218
2266
  title,
@@ -2222,7 +2270,7 @@ function Item2({
2222
2270
  className,
2223
2271
  style
2224
2272
  }) {
2225
- const { renderChildren } = useRenderer9();
2273
+ const { renderChildren } = useRenderer10();
2226
2274
  const mediaNodes = media === void 0 ? [] : Array.isArray(media) ? media : [media];
2227
2275
  return /* @__PURE__ */ jsxs28(Item, { className, style, children: [
2228
2276
  mediaNodes.length > 0 ? /* @__PURE__ */ jsx38(ItemMedia, { children: renderChildren(mediaNodes) }) : null,
@@ -2248,10 +2296,10 @@ function Label2({ text, htmlFor, className, style }) {
2248
2296
 
2249
2297
  // src/components/components/Layout/index.tsx
2250
2298
  import { isDslSourceRef } from "@pactor-app/core";
2251
- import { useRenderer as useRenderer10 } from "@pactor-app/runtime";
2299
+ import { useRenderer as useRenderer11 } from "@pactor-app/runtime";
2252
2300
  import { jsx as jsx41 } from "react/jsx-runtime";
2253
2301
  function Layout({ direction, className, style, dslChildren }) {
2254
- const { renderChildren, context } = useRenderer10();
2302
+ const { renderChildren, context } = useRenderer11();
2255
2303
  const hasSider = Array.isArray(dslChildren) ? dslChildren.some(
2256
2304
  (child) => !isDslSourceRef(child) && resolveRootType(child, context) === "Sider"
2257
2305
  ) : false;
@@ -2282,6 +2330,7 @@ function resolveRootType(node, context) {
2282
2330
  // src/components/components/Link/index.tsx
2283
2331
  import { jsx as jsx42 } from "react/jsx-runtime";
2284
2332
  function Link({ href, text, target, className, style, children }) {
2333
+ const handleSpaClick = useSpaLinkClick();
2285
2334
  return /* @__PURE__ */ jsx42(
2286
2335
  "a",
2287
2336
  {
@@ -2291,6 +2340,7 @@ function Link({ href, text, target, className, style, children }) {
2291
2340
  rel: target === "_blank" ? "noreferrer" : void 0,
2292
2341
  className: cn("text-primary underline-offset-4 hover:underline", className),
2293
2342
  style,
2343
+ onClick: (event) => handleSpaClick(event, href, target),
2294
2344
  children: text ?? children
2295
2345
  }
2296
2346
  );
@@ -2443,13 +2493,13 @@ function Pagination2({
2443
2493
  }
2444
2494
 
2445
2495
  // src/components/components/Popover/index.tsx
2446
- import { useRenderer as useRenderer11 } from "@pactor-app/runtime";
2496
+ import { useRenderer as useRenderer12 } from "@pactor-app/runtime";
2447
2497
  import { jsx as jsx47, jsxs as jsxs33 } from "react/jsx-runtime";
2448
2498
  function isDslNode3(value) {
2449
2499
  return typeof value === "object" && value !== null && typeof value.type === "string";
2450
2500
  }
2451
2501
  function Popover2({ content, children, className, style }) {
2452
- const { renderChildren } = useRenderer11();
2502
+ const { renderChildren } = useRenderer12();
2453
2503
  return /* @__PURE__ */ jsxs33(Popover, { children: [
2454
2504
  /* @__PURE__ */ jsx47(
2455
2505
  PopoverTrigger,
@@ -2594,7 +2644,7 @@ function RadioGroup2({
2594
2644
  }
2595
2645
 
2596
2646
  // src/components/components/Resizable/index.tsx
2597
- import { useRenderer as useRenderer12 } from "@pactor-app/runtime";
2647
+ import { useRenderer as useRenderer13 } from "@pactor-app/runtime";
2598
2648
  import { Fragment as Fragment4 } from "react";
2599
2649
  import { jsx as jsx51, jsxs as jsxs36 } from "react/jsx-runtime";
2600
2650
  function Resizable({
@@ -2603,7 +2653,7 @@ function Resizable({
2603
2653
  className,
2604
2654
  style
2605
2655
  }) {
2606
- const { renderChildren } = useRenderer12();
2656
+ const { renderChildren } = useRenderer13();
2607
2657
  return /* @__PURE__ */ jsx51(PanelGroup, { orientation: direction, className, style, children: panels.map((panel, index) => /* @__PURE__ */ jsxs36(Fragment4, { children: [
2608
2658
  index > 0 ? /* @__PURE__ */ jsx51(ResizableHandle, { withHandle: true }) : null,
2609
2659
  /* @__PURE__ */ jsx51(
@@ -2652,6 +2702,7 @@ function Select2({
2652
2702
  allowClear,
2653
2703
  onChange,
2654
2704
  className,
2705
+ controlClassName,
2655
2706
  style
2656
2707
  }) {
2657
2708
  const form = useFormContext();
@@ -2677,7 +2728,12 @@ function Select2({
2677
2728
  const select = /* @__PURE__ */ jsxs37(
2678
2729
  "span",
2679
2730
  {
2680
- className: cn("inline-flex items-center gap-1", !inFormRoot && className),
2731
+ className: cn(
2732
+ // Form / Field(Form 上下文)内控件占满整行宽度;独立渲染保持内容自然宽度
2733
+ inFormRoot ? "flex w-full items-center gap-1" : "inline-flex items-center gap-1",
2734
+ !inFormRoot && className,
2735
+ controlClassName
2736
+ ),
2681
2737
  style: inFormRoot ? void 0 : style,
2682
2738
  children: [
2683
2739
  /* @__PURE__ */ jsxs37(
@@ -2689,7 +2745,7 @@ function Select2({
2689
2745
  disabled,
2690
2746
  name: inForm ? name : void 0,
2691
2747
  children: [
2692
- /* @__PURE__ */ jsx53(SelectTrigger, { id: controlId, children: /* @__PURE__ */ jsx53(SelectValue, { placeholder }) }),
2748
+ /* @__PURE__ */ jsx53(SelectTrigger, { id: controlId, className: inFormRoot ? "w-full" : void 0, children: /* @__PURE__ */ jsx53(SelectValue, { placeholder }) }),
2693
2749
  /* @__PURE__ */ jsx53(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx53(
2694
2750
  SelectItem,
2695
2751
  {
@@ -2915,11 +2971,11 @@ function Slider2({
2915
2971
  }
2916
2972
 
2917
2973
  // src/components/components/Sonner/index.tsx
2918
- import { useRenderer as useRenderer13 } from "@pactor-app/runtime";
2974
+ import { useRenderer as useRenderer14 } from "@pactor-app/runtime";
2919
2975
  import { useEffect as useEffect12 } from "react";
2920
2976
  import { jsx as jsx59 } from "react/jsx-runtime";
2921
2977
  function Sonner({ className, style }) {
2922
- const { context } = useRenderer13();
2978
+ const { context } = useRenderer14();
2923
2979
  useEffect12(() => {
2924
2980
  const { actions } = context;
2925
2981
  if (actions.has("toast")) {
@@ -3030,7 +3086,7 @@ function Switch2({
3030
3086
  }
3031
3087
 
3032
3088
  // src/components/components/Table/index.tsx
3033
- import { useI18n as useI18n8, useRenderer as useRenderer14 } from "@pactor-app/runtime";
3089
+ import { useI18n as useI18n8, useRenderer as useRenderer15 } from "@pactor-app/runtime";
3034
3090
  import { useState as useState12 } from "react";
3035
3091
  import { jsx as jsx63, jsxs as jsxs43 } from "react/jsx-runtime";
3036
3092
  function renderCellValue2(value) {
@@ -3052,7 +3108,7 @@ function Table2({
3052
3108
  className,
3053
3109
  style
3054
3110
  }) {
3055
- const { renderChildren } = useRenderer14();
3111
+ const { renderChildren } = useRenderer15();
3056
3112
  const { t } = useI18n8();
3057
3113
  const [current, setCurrent] = useState12(1);
3058
3114
  const pageSize = pagination === false ? void 0 : pagination?.pageSize;
@@ -3119,10 +3175,10 @@ function Table2({
3119
3175
  }
3120
3176
 
3121
3177
  // src/components/components/Tabs/index.tsx
3122
- import { useRenderer as useRenderer15 } from "@pactor-app/runtime";
3178
+ import { useRenderer as useRenderer16 } from "@pactor-app/runtime";
3123
3179
  import { jsx as jsx64, jsxs as jsxs44 } from "react/jsx-runtime";
3124
3180
  function Tabs2({ items = [], activeKey, variant, onChange, className, style }) {
3125
- const { renderChildren } = useRenderer15();
3181
+ const { renderChildren } = useRenderer16();
3126
3182
  return /* @__PURE__ */ jsxs44(
3127
3183
  Tabs,
3128
3184
  {
@@ -3148,9 +3204,15 @@ var typeClassMap = {
3148
3204
  warning: "text-warning",
3149
3205
  danger: "text-destructive"
3150
3206
  };
3207
+ var sizeClassMap = {
3208
+ small: "text-xs",
3209
+ middle: "",
3210
+ large: "text-lg"
3211
+ };
3151
3212
  function Text({
3152
3213
  text,
3153
3214
  type = "default",
3215
+ size = "middle",
3154
3216
  strong,
3155
3217
  delete: del,
3156
3218
  underline,
@@ -3166,6 +3228,7 @@ function Text({
3166
3228
  "data-type": type,
3167
3229
  className: cn(
3168
3230
  typeClassMap[type],
3231
+ sizeClassMap[size],
3169
3232
  strong && "font-semibold",
3170
3233
  del && "line-through",
3171
3234
  underline && "underline",