@pactor-app/ui 1.8.0 → 1.10.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.
@@ -141,7 +141,7 @@ import {
141
141
  chartColor,
142
142
  navigationMenuTriggerStyle,
143
143
  toast
144
- } from "./chunk-XUIXZJDQ.js";
144
+ } from "./chunk-VT5XP4U4.js";
145
145
  import {
146
146
  Dialog,
147
147
  DialogContent,
@@ -153,7 +153,7 @@ import {
153
153
  DrawerContent,
154
154
  DrawerHeader,
155
155
  DrawerTitle
156
- } from "./chunk-F42SGQNW.js";
156
+ } from "./chunk-XUHJ5YSG.js";
157
157
  import {
158
158
  Accordion,
159
159
  AccordionContent,
@@ -217,8 +217,24 @@ var variantMap = {
217
217
  warning: "warning",
218
218
  error: "destructive"
219
219
  };
220
- function Alert2({ message, description, variant = "info", className, style }) {
220
+ var defaultIconMap = {
221
+ success: "check-circle",
222
+ info: "info",
223
+ warning: "warning",
224
+ error: "x-circle"
225
+ };
226
+ function Alert2({
227
+ message,
228
+ description,
229
+ variant = "info",
230
+ showIcon,
231
+ icon,
232
+ className,
233
+ style
234
+ }) {
235
+ const iconName = icon ?? (showIcon === true ? defaultIconMap[variant] : void 0);
221
236
  return /* @__PURE__ */ jsxs2(Alert, { variant: variantMap[variant], className, style, children: [
237
+ iconName ? /* @__PURE__ */ jsx2(Icon, { name: iconName, size: "sm" }) : null,
222
238
  message ? /* @__PURE__ */ jsx2(AlertTitle, { children: message }) : null,
223
239
  description ? /* @__PURE__ */ jsx2(AlertDescription, { children: description }) : null
224
240
  ] });
@@ -2018,6 +2034,7 @@ function HoverCard2({ content, children, className, style }) {
2018
2034
  }
2019
2035
 
2020
2036
  // src/components/components/Input/index.tsx
2037
+ import { useI18n as useI18n6 } from "@pactor-app/runtime";
2021
2038
  import { useEffect as useEffect7, useId as useId4 } from "react";
2022
2039
  import { jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
2023
2040
  function Input2({
@@ -2028,11 +2045,13 @@ function Input2({
2028
2045
  type = "text",
2029
2046
  placeholder,
2030
2047
  disabled,
2048
+ allowClear,
2031
2049
  onChange,
2032
2050
  className,
2033
2051
  style
2034
2052
  }) {
2035
2053
  const form = useFormContext();
2054
+ const { t } = useI18n6();
2036
2055
  const controlId = useId4();
2037
2056
  const inForm = form?.inForm === true && typeof name === "string" && name !== "";
2038
2057
  useEffect7(() => {
@@ -2042,8 +2061,56 @@ function Input2({
2042
2061
  }
2043
2062
  return void 0;
2044
2063
  });
2064
+ const fieldValue = inForm && form && name ? form.values[name] : void 0;
2065
+ const currentValue = typeof fieldValue === "string" ? fieldValue : inForm ? "" : value ?? "";
2066
+ const showClear = allowClear === true && disabled !== true && currentValue !== "";
2067
+ const handleClear = () => {
2068
+ if (inForm && form && name) {
2069
+ form.setValue(name, "");
2070
+ }
2071
+ onChange?.("");
2072
+ };
2073
+ const inFormRoot = inForm === true;
2074
+ const input = /* @__PURE__ */ jsx35(
2075
+ Input,
2076
+ {
2077
+ id: controlId,
2078
+ type,
2079
+ value: currentValue,
2080
+ placeholder,
2081
+ disabled,
2082
+ className: !inFormRoot && allowClear !== true ? className : void 0,
2083
+ style: !inFormRoot && allowClear !== true ? style : void 0,
2084
+ onChange: (event) => {
2085
+ if (inForm && form && name) {
2086
+ form.setValue(name, event.target.value);
2087
+ }
2088
+ onChange?.(event.target.value);
2089
+ }
2090
+ }
2091
+ );
2092
+ const clearButton = showClear ? /* @__PURE__ */ jsx35(
2093
+ "button",
2094
+ {
2095
+ type: "button",
2096
+ "aria-label": t("pactor.input.clear"),
2097
+ className: "shrink-0 cursor-pointer text-muted-foreground hover:text-foreground",
2098
+ onClick: handleClear,
2099
+ children: "\xD7"
2100
+ }
2101
+ ) : null;
2102
+ const control = allowClear === true ? /* @__PURE__ */ jsxs26(
2103
+ "span",
2104
+ {
2105
+ className: cn("flex items-center gap-1", !inFormRoot && className),
2106
+ style: inFormRoot ? void 0 : style,
2107
+ children: [
2108
+ input,
2109
+ clearButton
2110
+ ]
2111
+ }
2112
+ ) : input;
2045
2113
  if (inForm && form && name) {
2046
- const fieldValue = form.values[name];
2047
2114
  const error = form.errors[name];
2048
2115
  return /* @__PURE__ */ jsxs26(
2049
2116
  "div",
@@ -2060,37 +2127,13 @@ function Input2({
2060
2127
  children: label
2061
2128
  }
2062
2129
  ) : null,
2063
- /* @__PURE__ */ jsx35(
2064
- Input,
2065
- {
2066
- id: controlId,
2067
- type,
2068
- value: typeof fieldValue === "string" ? fieldValue : "",
2069
- placeholder,
2070
- disabled,
2071
- onChange: (event) => {
2072
- form.setValue(name, event.target.value);
2073
- onChange?.(event.target.value);
2074
- }
2075
- }
2076
- ),
2130
+ control,
2077
2131
  error ? /* @__PURE__ */ jsx35("div", { "data-slot": "form-error", className: "text-sm text-destructive", children: error }) : null
2078
2132
  ]
2079
2133
  }
2080
2134
  );
2081
2135
  }
2082
- return /* @__PURE__ */ jsx35(
2083
- Input,
2084
- {
2085
- type,
2086
- value: value ?? "",
2087
- placeholder,
2088
- disabled,
2089
- className,
2090
- style,
2091
- onChange: (event) => onChange?.(event.target.value)
2092
- }
2093
- );
2136
+ return control;
2094
2137
  }
2095
2138
 
2096
2139
  // src/components/components/InputGroup/index.tsx
@@ -2470,6 +2513,7 @@ function RadioGroup2({
2470
2513
  label,
2471
2514
  rules,
2472
2515
  options = [],
2516
+ direction = "vertical",
2473
2517
  value,
2474
2518
  disabled,
2475
2519
  onChange,
@@ -2501,10 +2545,14 @@ function RadioGroup2({
2501
2545
  onValueChange: handleChange,
2502
2546
  disabled,
2503
2547
  name: inForm ? name : void 0,
2504
- className: cn(!inForm && className),
2548
+ className: cn(
2549
+ direction === "horizontal" && "flex flex-wrap items-center gap-x-6 gap-y-2",
2550
+ !inForm && className
2551
+ ),
2505
2552
  style: inForm ? void 0 : style,
2506
2553
  children: options.map((option, index) => {
2507
2554
  const optionId = `${controlId}-${index}`;
2555
+ const optionDisabled = disabled || option.disabled;
2508
2556
  return /* @__PURE__ */ jsxs35("span", { className: "inline-flex items-center gap-2", children: [
2509
2557
  /* @__PURE__ */ jsx50(
2510
2558
  RadioGroupItem,
@@ -2514,7 +2562,17 @@ function RadioGroup2({
2514
2562
  disabled: option.disabled
2515
2563
  }
2516
2564
  ),
2517
- /* @__PURE__ */ jsx50("label", { htmlFor: optionId, className: "text-sm leading-none font-medium", children: option.label })
2565
+ /* @__PURE__ */ jsx50(
2566
+ "label",
2567
+ {
2568
+ htmlFor: optionId,
2569
+ className: cn(
2570
+ "text-sm leading-none font-medium",
2571
+ optionDisabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"
2572
+ ),
2573
+ children: option.label
2574
+ }
2575
+ )
2518
2576
  ] }, String(option.value));
2519
2577
  })
2520
2578
  }
@@ -2580,7 +2638,7 @@ function ScrollArea2({
2580
2638
  }
2581
2639
 
2582
2640
  // src/components/components/Select/index.tsx
2583
- import { useI18n as useI18n6 } from "@pactor-app/runtime";
2641
+ import { useI18n as useI18n7 } from "@pactor-app/runtime";
2584
2642
  import { useEffect as useEffect10, useId as useId6 } from "react";
2585
2643
  import { jsx as jsx53, jsxs as jsxs37 } from "react/jsx-runtime";
2586
2644
  function Select2({
@@ -2597,7 +2655,7 @@ function Select2({
2597
2655
  style
2598
2656
  }) {
2599
2657
  const form = useFormContext();
2600
- const { t } = useI18n6();
2658
+ const { t } = useI18n7();
2601
2659
  const controlId = useId6();
2602
2660
  const inForm = form?.inForm === true && typeof name === "string" && name !== "";
2603
2661
  useEffect10(() => {
@@ -2972,7 +3030,7 @@ function Switch2({
2972
3030
  }
2973
3031
 
2974
3032
  // src/components/components/Table/index.tsx
2975
- import { useI18n as useI18n7, useRenderer as useRenderer14 } from "@pactor-app/runtime";
3033
+ import { useI18n as useI18n8, useRenderer as useRenderer14 } from "@pactor-app/runtime";
2976
3034
  import { useState as useState12 } from "react";
2977
3035
  import { jsx as jsx63, jsxs as jsxs43 } from "react/jsx-runtime";
2978
3036
  function renderCellValue2(value) {
@@ -2995,7 +3053,7 @@ function Table2({
2995
3053
  style
2996
3054
  }) {
2997
3055
  const { renderChildren } = useRenderer14();
2998
- const { t } = useI18n7();
3056
+ const { t } = useI18n8();
2999
3057
  const [current, setCurrent] = useState12(1);
3000
3058
  const pageSize = pagination === false ? void 0 : pagination?.pageSize;
3001
3059
  const total = dataSource.length;
@@ -3063,7 +3121,7 @@ function Table2({
3063
3121
  // src/components/components/Tabs/index.tsx
3064
3122
  import { useRenderer as useRenderer15 } from "@pactor-app/runtime";
3065
3123
  import { jsx as jsx64, jsxs as jsxs44 } from "react/jsx-runtime";
3066
- function Tabs2({ items = [], activeKey, onChange, className, style }) {
3124
+ function Tabs2({ items = [], activeKey, variant, onChange, className, style }) {
3067
3125
  const { renderChildren } = useRenderer15();
3068
3126
  return /* @__PURE__ */ jsxs44(
3069
3127
  Tabs,
@@ -3074,7 +3132,7 @@ function Tabs2({ items = [], activeKey, onChange, className, style }) {
3074
3132
  className,
3075
3133
  style,
3076
3134
  children: [
3077
- /* @__PURE__ */ jsx64(TabsList, { children: items.map((item) => /* @__PURE__ */ jsx64(TabsTrigger, { value: item.key, children: item.label }, item.key)) }),
3135
+ /* @__PURE__ */ jsx64(TabsList, { variant, children: items.map((item) => /* @__PURE__ */ jsx64(TabsTrigger, { value: item.key, children: item.label }, item.key)) }),
3078
3136
  items.map((item) => /* @__PURE__ */ jsx64(TabsContent, { value: item.key, children: renderChildren(item.children) }, item.key))
3079
3137
  ]
3080
3138
  }
@@ -11,7 +11,7 @@ import {
11
11
  DrawerContent,
12
12
  DrawerHeader,
13
13
  DrawerTitle
14
- } from "./chunk-F42SGQNW.js";
14
+ } from "./chunk-XUHJ5YSG.js";
15
15
  import {
16
16
  Button,
17
17
  cn
@@ -201,6 +201,7 @@ function InteractionProvider({
201
201
  children
202
202
  }) {
203
203
  const [confirmState, setConfirmState] = useState(null);
204
+ const [confirmOpen, setConfirmOpen] = useState(false);
204
205
  const [toasts, setToasts] = useState([]);
205
206
  const { t } = useI18n();
206
207
  const { modal, message } = useMemo(() => {
@@ -214,6 +215,7 @@ function InteractionProvider({
214
215
  const modalImpl = {
215
216
  confirm(config) {
216
217
  setConfirmState({ ...config });
218
+ setConfirmOpen(true);
217
219
  }
218
220
  };
219
221
  const messageImpl = {
@@ -234,12 +236,12 @@ function InteractionProvider({
234
236
  }, [bridge, modal, message]);
235
237
  const handleOk = () => {
236
238
  const state = confirmState;
237
- setConfirmState(null);
239
+ setConfirmOpen(false);
238
240
  state?.onOk?.();
239
241
  };
240
242
  const handleCancel = () => {
241
243
  const state = confirmState;
242
- setConfirmState(null);
244
+ setConfirmOpen(false);
243
245
  state?.onCancel?.();
244
246
  };
245
247
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -249,12 +251,17 @@ function InteractionProvider({
249
251
  /* @__PURE__ */ jsx(
250
252
  Dialog,
251
253
  {
252
- open: confirmState !== null,
254
+ open: confirmOpen,
253
255
  onOpenChange: (open) => {
254
256
  if (!open) {
255
257
  handleCancel();
256
258
  }
257
259
  },
260
+ onOpenChangeComplete: (open) => {
261
+ if (!open) {
262
+ setConfirmState(null);
263
+ }
264
+ },
258
265
  children: /* @__PURE__ */ jsxs(DialogContent, { "data-slot": "confirm-dialog", className: "sm:max-w-sm", children: [
259
266
  /* @__PURE__ */ jsxs(DialogHeader, { children: [
260
267
  /* @__PURE__ */ jsx(DialogTitle, { children: confirmState?.title ?? "" }),
@@ -2439,6 +2439,7 @@ function Switch({ className, ...props }) {
2439
2439
 
2440
2440
  // src/ui/tabs.tsx
2441
2441
  import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
2442
+ import { cva as cva4 } from "class-variance-authority";
2442
2443
  import { jsx as jsx39 } from "react/jsx-runtime";
2443
2444
  function Tabs({
2444
2445
  className,
@@ -2453,18 +2454,31 @@ function Tabs({
2453
2454
  }
2454
2455
  );
2455
2456
  }
2457
+ var tabsListVariants = cva4(
2458
+ "group/tabs-list inline-flex w-fit items-center justify-center text-muted-foreground",
2459
+ {
2460
+ variants: {
2461
+ variant: {
2462
+ default: "h-9 rounded-lg bg-muted p-[3px]",
2463
+ line: "h-auto gap-1 rounded-none border-b border-border bg-transparent p-0"
2464
+ }
2465
+ },
2466
+ defaultVariants: {
2467
+ variant: "default"
2468
+ }
2469
+ }
2470
+ );
2456
2471
  function TabsList({
2457
2472
  className,
2473
+ variant,
2458
2474
  ...props
2459
2475
  }) {
2460
2476
  return /* @__PURE__ */ jsx39(
2461
2477
  TabsPrimitive.List,
2462
2478
  {
2463
2479
  "data-slot": "tabs-list",
2464
- className: cn(
2465
- "inline-flex h-9 w-fit items-center justify-center rounded-lg bg-muted p-[3px] text-muted-foreground",
2466
- className
2467
- ),
2480
+ "data-variant": variant ?? "default",
2481
+ className: cn(tabsListVariants({ variant }), className),
2468
2482
  ...props
2469
2483
  }
2470
2484
  );
@@ -2478,7 +2492,12 @@ function TabsTrigger({
2478
2492
  {
2479
2493
  "data-slot": "tabs-trigger",
2480
2494
  className: cn(
2481
- "inline-flex h-[calc(100%-1px)] flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground transition-colors focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-active:border-border data-active:bg-card data-active:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
2495
+ "inline-flex h-[calc(100%-1px)] flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground transition-colors focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
2496
+ // default 变体:激活态胶囊(边框 + 卡片底 + 阴影)
2497
+ "group-data-[variant=default]/tabs-list:data-active:border-border group-data-[variant=default]/tabs-list:data-active:bg-card group-data-[variant=default]/tabs-list:data-active:shadow-sm",
2498
+ // line 变体:下划线指示——弱化未激活文字,激活态底部 2px 主色线
2499
+ //(叠在 List 的底边轨道上),无底色/圆角/阴影
2500
+ "group-data-[variant=line]/tabs-list:-mb-px group-data-[variant=line]/tabs-list:h-9 group-data-[variant=line]/tabs-list:rounded-none group-data-[variant=line]/tabs-list:border-x-0 group-data-[variant=line]/tabs-list:border-t-0 group-data-[variant=line]/tabs-list:border-b-2 group-data-[variant=line]/tabs-list:py-1.5 group-data-[variant=line]/tabs-list:text-muted-foreground group-data-[variant=line]/tabs-list:data-active:border-b-primary group-data-[variant=line]/tabs-list:data-active:text-foreground",
2482
2501
  className
2483
2502
  ),
2484
2503
  ...props
@@ -2501,9 +2520,9 @@ function TabsContent({
2501
2520
 
2502
2521
  // src/ui/toggle.tsx
2503
2522
  import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
2504
- import { cva as cva4 } from "class-variance-authority";
2523
+ import { cva as cva5 } from "class-variance-authority";
2505
2524
  import { jsx as jsx40 } from "react/jsx-runtime";
2506
- var toggleVariants = cva4(
2525
+ var toggleVariants = cva5(
2507
2526
  "inline-flex cursor-pointer items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-muted hover:text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 data-pressed:bg-accent data-pressed:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
2508
2527
  {
2509
2528
  variants: {
@@ -2599,9 +2618,9 @@ function ToggleGroupItem({
2599
2618
  }
2600
2619
 
2601
2620
  // src/ui/typography.tsx
2602
- import { cva as cva5 } from "class-variance-authority";
2621
+ import { cva as cva6 } from "class-variance-authority";
2603
2622
  import { jsx as jsx42 } from "react/jsx-runtime";
2604
- var typographyVariants = cva5("", {
2623
+ var typographyVariants = cva6("", {
2605
2624
  variants: {
2606
2625
  variant: {
2607
2626
  h1: "scroll-m-20 text-4xl font-extrabold tracking-tight text-balance",
@@ -35,7 +35,7 @@ function DialogOverlay({
35
35
  {
36
36
  "data-slot": "dialog-overlay",
37
37
  className: cn(
38
- "fixed inset-0 z-50 bg-(--overlay-background) data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
38
+ "fixed inset-0 z-50 bg-(--overlay-background) data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards",
39
39
  className
40
40
  ),
41
41
  ...props
@@ -55,7 +55,7 @@ function DialogContent({
55
55
  {
56
56
  "data-slot": "dialog-content",
57
57
  className: cn(
58
- "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border border-border bg-popover p-6 shadow-lg shadow-(color:--shadow-color) duration-200 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 sm:max-w-lg",
58
+ "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border border-border bg-popover p-6 shadow-lg shadow-(color:--shadow-color) duration-200 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-closed:fill-mode-forwards sm:max-w-lg",
59
59
  className
60
60
  ),
61
61
  ...props,