@pactor-app/ui 1.1.0 → 1.2.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.
package/dist/index.cjs CHANGED
@@ -31,11 +31,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  Accordion: () => Accordion2,
34
+ AdminLayout: () => AdminLayout,
34
35
  Alert: () => Alert2,
35
36
  AlertDialog: () => AlertDialog2,
36
37
  AspectRatio: () => AspectRatio2,
37
38
  Avatar: () => Avatar2,
38
39
  Badge: () => Badge2,
40
+ BlankLayout: () => BlankLayout,
39
41
  Breadcrumb: () => Breadcrumb2,
40
42
  Button: () => Button2,
41
43
  ButtonGroup: () => ButtonGroup2,
@@ -43,6 +45,7 @@ __export(index_exports, {
43
45
  Card: () => Card2,
44
46
  Carousel: () => Carousel2,
45
47
  Chart: () => Chart,
48
+ ChatLayout: () => ChatLayout,
46
49
  Checkbox: () => Checkbox2,
47
50
  Collapsible: () => Collapsible2,
48
51
  Combobox: () => Combobox2,
@@ -66,15 +69,19 @@ __export(index_exports, {
66
69
  Input: () => Input2,
67
70
  InputGroup: () => InputGroup2,
68
71
  InputOTP: () => InputOTP2,
72
+ InteractionProvider: () => InteractionProvider,
69
73
  Item: () => Item2,
70
74
  Kbd: () => Kbd2,
71
75
  Label: () => Label2,
76
+ LandingLayout: () => LandingLayout,
72
77
  Layout: () => Layout,
73
78
  Link: () => Link2,
79
+ LoginLayout: () => LoginLayout,
74
80
  Menu: () => Menu2,
75
81
  Menubar: () => Menubar2,
76
82
  NavigationMenu: () => NavigationMenu2,
77
83
  OVERLAY_CANCEL_PAYLOAD: () => OVERLAY_CANCEL_PAYLOAD,
84
+ OverlayHost: () => OverlayHost,
78
85
  OverlayManager: () => OverlayManager,
79
86
  Page: () => Page,
80
87
  Pagination: () => Pagination2,
@@ -86,12 +93,6 @@ __export(index_exports, {
86
93
  ScrollArea: () => ScrollArea2,
87
94
  Select: () => Select2,
88
95
  Separator: () => Separator2,
89
- ShadcnAdminLayout: () => ShadcnAdminLayout,
90
- ShadcnBlankLayout: () => ShadcnBlankLayout,
91
- ShadcnInteractionProvider: () => ShadcnInteractionProvider,
92
- ShadcnLandingLayout: () => ShadcnLandingLayout,
93
- ShadcnLoginLayout: () => ShadcnLoginLayout,
94
- ShadcnOverlayHost: () => ShadcnOverlayHost,
95
96
  Sheet: () => Sheet2,
96
97
  Sidebar: () => Sidebar,
97
98
  Sider: () => Sider,
@@ -109,18 +110,17 @@ __export(index_exports, {
109
110
  ToggleGroup: () => ToggleGroup2,
110
111
  Tooltip: () => Tooltip3,
111
112
  Typography: () => Typography2,
113
+ builtinComponents: () => builtinComponents,
112
114
  collectDefaultOpenKeys: () => collectDefaultOpenKeys,
113
- createShadcnComponentRegistry: () => createShadcnComponentRegistry,
114
- createShadcnLayoutRegistry: () => createShadcnLayoutRegistry,
115
+ createComponentRegistry: () => createComponentRegistry,
116
+ createLayoutRegistry: () => createLayoutRegistry,
115
117
  createUiBridge: () => createUiBridge,
116
118
  findMenuChain: () => findMenuChain,
117
119
  normalizeIconName: () => normalizeIconName,
120
+ registerBuiltinComponents: () => registerBuiltinComponents,
121
+ registerBuiltinLayouts: () => registerBuiltinLayouts,
118
122
  registerInteractionActions: () => registerInteractionActions,
119
- registerShadcnComponents: () => registerShadcnComponents,
120
- registerShadcnLayouts: () => registerShadcnLayouts,
121
123
  resolveLayout: () => resolveLayout,
122
- shadcnComponents: () => shadcnComponents,
123
- shadcnUiKit: () => shadcnUiKit,
124
124
  useFormContext: () => useFormContext,
125
125
  useSidebarDrawer: () => useSidebarDrawer
126
126
  });
@@ -4256,31 +4256,38 @@ function Sidebar({
4256
4256
  ]
4257
4257
  }
4258
4258
  ),
4259
- /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("main", { "data-slot": "sidebar-content", className: "min-w-0 flex-1", children: [
4260
- drawer ? /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
4261
- "div",
4262
- {
4263
- "data-slot": "sidebar-topbar",
4264
- className: "flex h-14 items-center gap-2 border-b border-sidebar-border bg-sidebar px-3 md:hidden",
4265
- children: [
4266
- /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
4267
- "button",
4268
- {
4269
- type: "button",
4270
- "data-slot": "sidebar-menu-trigger",
4271
- "aria-label": t("pactor.layout.openNavigation"),
4272
- "aria-expanded": drawerOpen,
4273
- className: "flex size-8 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent hover:text-sidebar-foreground",
4274
- onClick: () => setDrawerOpen(true),
4275
- children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Icon, { name: "menu", size: 18 })
4276
- }
4277
- ),
4278
- brandNode
4279
- ]
4280
- }
4281
- ) : null,
4282
- children
4283
- ] })
4259
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
4260
+ "main",
4261
+ {
4262
+ "data-slot": "sidebar-content",
4263
+ className: "flex min-w-0 flex-1 flex-col",
4264
+ children: [
4265
+ drawer ? /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
4266
+ "div",
4267
+ {
4268
+ "data-slot": "sidebar-topbar",
4269
+ className: "flex h-14 items-center gap-2 border-b border-sidebar-border bg-sidebar px-3 md:hidden",
4270
+ children: [
4271
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
4272
+ "button",
4273
+ {
4274
+ type: "button",
4275
+ "data-slot": "sidebar-menu-trigger",
4276
+ "aria-label": t("pactor.layout.openNavigation"),
4277
+ "aria-expanded": drawerOpen,
4278
+ className: "flex size-8 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent hover:text-sidebar-foreground",
4279
+ onClick: () => setDrawerOpen(true),
4280
+ children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Icon, { name: "menu", size: 18 })
4281
+ }
4282
+ ),
4283
+ brandNode
4284
+ ]
4285
+ }
4286
+ ) : null,
4287
+ children
4288
+ ]
4289
+ }
4290
+ )
4284
4291
  ]
4285
4292
  }
4286
4293
  )
@@ -4405,7 +4412,7 @@ function MenuEntry({
4405
4412
  "flex w-full items-center gap-2 rounded-md text-sm transition-colors",
4406
4413
  mode === "horizontal" ? "px-3 py-2" : "px-3 py-2 text-left",
4407
4414
  collapsed && "justify-center px-0",
4408
- selected ? "bg-accent font-medium text-accent-foreground" : "text-muted-foreground hover:bg-accent/50 hover:text-foreground",
4415
+ selected ? "bg-accent font-medium text-accent-foreground" : "cursor-pointer text-muted-foreground hover:bg-accent/50 hover:text-foreground",
4409
4416
  item.disabled && "cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted-foreground"
4410
4417
  ),
4411
4418
  style: mode === "inline" && depth > 0 && !collapsed ? { paddingLeft: 12 + depth * 16 } : void 0,
@@ -6641,7 +6648,7 @@ function Typography2({
6641
6648
  }
6642
6649
 
6643
6650
  // src/components/register.ts
6644
- var shadcnComponents = {
6651
+ var builtinComponents = {
6645
6652
  Page,
6646
6653
  Grid,
6647
6654
  Flex,
@@ -6721,14 +6728,14 @@ var shadcnComponents = {
6721
6728
  // 图标(lucide 白名单)
6722
6729
  Icon
6723
6730
  };
6724
- function registerShadcnComponents(registry) {
6725
- for (const [type, component] of Object.entries(shadcnComponents)) {
6731
+ function registerBuiltinComponents(registry) {
6732
+ for (const [type, component] of Object.entries(builtinComponents)) {
6726
6733
  registry.register(type, component);
6727
6734
  }
6728
6735
  }
6729
- function createShadcnComponentRegistry() {
6736
+ function createComponentRegistry() {
6730
6737
  const registry = new import_core2.Registry("ComponentRegistry");
6731
- registerShadcnComponents(registry);
6738
+ registerBuiltinComponents(registry);
6732
6739
  return registry;
6733
6740
  }
6734
6741
 
@@ -6776,7 +6783,7 @@ function collectDefaultOpenKeys(registry, activeMenuId) {
6776
6783
  return keys;
6777
6784
  }
6778
6785
 
6779
- // src/layout/admin/ShadcnAdminLayout.tsx
6786
+ // src/layout/admin/AdminLayout.tsx
6780
6787
  var import_permission = require("@pactor-app/permission");
6781
6788
  var import_router = require("@pactor-app/router");
6782
6789
  var import_runtime20 = require("@pactor-app/runtime");
@@ -6815,7 +6822,7 @@ function useBreakpointBelow(breakpoint) {
6815
6822
  return breakpoint !== void 0 && matches;
6816
6823
  }
6817
6824
 
6818
- // src/layout/admin/ShadcnAdminLayout.tsx
6825
+ // src/layout/admin/AdminLayout.tsx
6819
6826
  var import_jsx_runtime127 = require("react/jsx-runtime");
6820
6827
  function buildVisibleMenuTree(registry, permissionChecker) {
6821
6828
  const tree = registry.tree();
@@ -7016,7 +7023,7 @@ function MenuTree({
7016
7023
  }
7017
7024
  );
7018
7025
  }
7019
- function ShadcnAdminLayout({
7026
+ function AdminLayout({
7020
7027
  config = {},
7021
7028
  brand,
7022
7029
  registry,
@@ -7323,9 +7330,9 @@ function ShadcnAdminLayout({
7323
7330
  );
7324
7331
  }
7325
7332
 
7326
- // src/layout/basic/ShadcnBlankLayout.tsx
7333
+ // src/layout/basic/BlankLayout.tsx
7327
7334
  var import_jsx_runtime128 = require("react/jsx-runtime");
7328
- function ShadcnBlankLayout({ children }) {
7335
+ function BlankLayout({ children }) {
7329
7336
  return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
7330
7337
  "div",
7331
7338
  {
@@ -7336,27 +7343,154 @@ function ShadcnBlankLayout({ children }) {
7336
7343
  );
7337
7344
  }
7338
7345
 
7339
- // src/layout/basic/ShadcnLoginLayout.tsx
7346
+ // src/layout/chat/ChatLayout.tsx
7347
+ var import_permission2 = require("@pactor-app/permission");
7348
+ var import_react28 = require("react");
7340
7349
  var import_jsx_runtime129 = require("react/jsx-runtime");
7341
- function ShadcnLoginLayout({
7350
+ function ChatLayout({
7351
+ brand,
7352
+ menu,
7353
+ registry,
7354
+ bridge,
7355
+ route: routeProp,
7356
+ permissionChecker,
7357
+ activeMenuKey,
7358
+ onMenuSelect,
7359
+ collapsible,
7360
+ sidebar,
7361
+ sidebarFooter,
7362
+ children
7363
+ }) {
7364
+ const registryMenus = (0, import_react28.useMemo)(() => {
7365
+ if (menu !== void 0 || registry === void 0) {
7366
+ return [];
7367
+ }
7368
+ const tree = registry.tree();
7369
+ const visible = permissionChecker !== void 0 ? (0, import_permission2.filterMenusByPermission)(tree, permissionChecker) : tree;
7370
+ return visible.flatMap((item) => menuItemToMenuData(item));
7371
+ }, [menu, registry, permissionChecker]);
7372
+ const menuItems = menu ?? registryMenus;
7373
+ const [bridgePath, setBridgePath] = (0, import_react28.useState)(
7374
+ () => bridge?.getLocation().pathname ?? "/"
7375
+ );
7376
+ (0, import_react28.useEffect)(() => {
7377
+ if (bridge === void 0) {
7378
+ return;
7379
+ }
7380
+ return bridge.subscribe((location) => {
7381
+ setBridgePath(location.pathname);
7382
+ });
7383
+ }, [bridge]);
7384
+ const activeKey = (0, import_react28.useMemo)(() => {
7385
+ if (activeMenuKey !== void 0) {
7386
+ return activeMenuKey;
7387
+ }
7388
+ const path = routeProp?.path ?? bridgePath;
7389
+ return menuItems.find((item) => item.path === path)?.key;
7390
+ }, [activeMenuKey, routeProp, bridgePath, menuItems]);
7391
+ const handleSelect = (key) => {
7392
+ const item = menuItems.find((m) => m.key === key);
7393
+ if (item === void 0 || item.disabled === true) {
7394
+ return;
7395
+ }
7396
+ if (onMenuSelect !== void 0) {
7397
+ onMenuSelect(key, item);
7398
+ return;
7399
+ }
7400
+ if (bridge !== void 0 && item.path !== void 0) {
7401
+ bridge.push(item.path);
7402
+ }
7403
+ };
7404
+ const sidebarContent = sidebar !== void 0 && sidebar !== null ? sidebar : menuItems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
7405
+ Menu2,
7406
+ {
7407
+ items: menuItems.map((item) => chatMenuItemToUiMenuItem(item)),
7408
+ selectedKey: activeKey,
7409
+ onSelect: handleSelect
7410
+ }
7411
+ ) : void 0;
7412
+ return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
7413
+ Sidebar,
7414
+ {
7415
+ brand,
7416
+ content: sidebarContent,
7417
+ sidebarFooter,
7418
+ collapsible,
7419
+ locationKey: routeProp?.path ?? bridgePath,
7420
+ children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
7421
+ "div",
7422
+ {
7423
+ "data-slot": "chat-layout-content",
7424
+ className: "flex min-h-0 flex-1 flex-col",
7425
+ children
7426
+ }
7427
+ )
7428
+ }
7429
+ );
7430
+ }
7431
+ function chatMenuItemToUiMenuItem(item) {
7432
+ return {
7433
+ key: item.key,
7434
+ label: item.label,
7435
+ icon: item.icon,
7436
+ badge: item.badge,
7437
+ dot: item.dot,
7438
+ group: item.group,
7439
+ disabled: item.disabled
7440
+ };
7441
+ }
7442
+ function menuItemToMenuData(item) {
7443
+ if (item.type === "group") {
7444
+ const children = (item.children ?? []).flatMap(
7445
+ (child) => menuItemToMenuData(child)
7446
+ );
7447
+ if (children.length === 0) {
7448
+ return [];
7449
+ }
7450
+ return children.map((child, index) => ({
7451
+ ...child,
7452
+ group: index === 0 ? item.title : void 0
7453
+ }));
7454
+ }
7455
+ if (item.hidden === true) {
7456
+ return [];
7457
+ }
7458
+ const ext = item;
7459
+ return [
7460
+ {
7461
+ key: item.id,
7462
+ label: item.title,
7463
+ icon: item.icon,
7464
+ path: item.path,
7465
+ badge: item.badge,
7466
+ dot: ext.dot,
7467
+ group: ext.group,
7468
+ disabled: item.disabled
7469
+ }
7470
+ ];
7471
+ }
7472
+
7473
+ // src/layout/basic/LoginLayout.tsx
7474
+ var import_jsx_runtime130 = require("react/jsx-runtime");
7475
+ function LoginLayout({
7342
7476
  variant = "center",
7343
7477
  brand,
7344
7478
  children
7345
7479
  }) {
7346
- const brandBlock = /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { "data-slot": "login-brand", className: "flex flex-col items-center gap-2", children: [
7480
+ const brandBlock = /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("div", { "data-slot": "login-brand", className: "flex flex-col items-center gap-2", children: [
7347
7481
  brand.logo,
7348
- /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("h1", { className: "text-xl font-semibold", children: brand.title }),
7349
- brand.description !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("div", { className: "text-sm text-muted-foreground", children: brand.description })
7482
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("h1", { className: "text-xl font-semibold", children: brand.title }),
7483
+ brand.description !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("div", { className: "text-sm text-muted-foreground", children: brand.description })
7350
7484
  ] });
7351
7485
  if (variant === "split") {
7352
- return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
7486
+ return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
7353
7487
  "div",
7354
7488
  {
7355
7489
  "data-slot": "login-layout",
7356
7490
  "data-variant": "split",
7357
7491
  className: "grid min-h-screen grid-cols-2 bg-background text-foreground",
7358
7492
  children: [
7359
- /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
7493
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
7360
7494
  "div",
7361
7495
  {
7362
7496
  "data-slot": "login-brand-panel",
@@ -7364,7 +7498,7 @@ function ShadcnLoginLayout({
7364
7498
  children: brandBlock
7365
7499
  }
7366
7500
  ),
7367
- /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
7501
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
7368
7502
  "div",
7369
7503
  {
7370
7504
  "data-slot": "login-form-panel",
@@ -7376,37 +7510,37 @@ function ShadcnLoginLayout({
7376
7510
  }
7377
7511
  );
7378
7512
  }
7379
- return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
7513
+ return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
7380
7514
  "div",
7381
7515
  {
7382
7516
  "data-slot": "login-layout",
7383
7517
  "data-variant": "center",
7384
7518
  className: "flex min-h-screen items-center justify-center bg-muted/40 text-foreground",
7385
- children: /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(Card, { "data-slot": "login-card", className: "w-full max-w-sm gap-4 py-6", children: [
7386
- /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(CardHeader, { className: "px-6", children: [
7387
- /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(CardTitle, { className: "sr-only", children: brand.title }),
7519
+ children: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(Card, { "data-slot": "login-card", className: "w-full max-w-sm gap-4 py-6", children: [
7520
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(CardHeader, { className: "px-6", children: [
7521
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(CardTitle, { className: "sr-only", children: brand.title }),
7388
7522
  brandBlock
7389
7523
  ] }),
7390
- /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(CardContent, { className: "flex flex-col gap-4 px-6", children })
7524
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(CardContent, { className: "flex flex-col gap-4 px-6", children })
7391
7525
  ] })
7392
7526
  }
7393
7527
  );
7394
7528
  }
7395
7529
 
7396
- // src/layout/basic/ShadcnLandingLayout.tsx
7397
- var import_jsx_runtime130 = require("react/jsx-runtime");
7398
- function ShadcnLandingLayout({
7530
+ // src/layout/basic/LandingLayout.tsx
7531
+ var import_jsx_runtime131 = require("react/jsx-runtime");
7532
+ function LandingLayout({
7399
7533
  navbar,
7400
7534
  footer,
7401
7535
  children
7402
7536
  }) {
7403
- return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
7537
+ return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(
7404
7538
  "div",
7405
7539
  {
7406
7540
  "data-slot": "landing-layout",
7407
7541
  className: "flex min-h-screen flex-col bg-background text-foreground",
7408
7542
  children: [
7409
- navbar !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
7543
+ navbar !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
7410
7544
  "header",
7411
7545
  {
7412
7546
  "data-slot": "landing-navbar",
@@ -7414,8 +7548,8 @@ function ShadcnLandingLayout({
7414
7548
  children: navbar
7415
7549
  }
7416
7550
  ),
7417
- /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("main", { "data-slot": "landing-content", className: "flex-1", children }),
7418
- footer !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
7551
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("main", { "data-slot": "landing-content", className: "flex-1", children }),
7552
+ footer !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
7419
7553
  "footer",
7420
7554
  {
7421
7555
  "data-slot": "landing-footer",
@@ -7430,15 +7564,16 @@ function ShadcnLandingLayout({
7430
7564
 
7431
7565
  // src/layout/registry.ts
7432
7566
  var import_core3 = require("@pactor-app/core");
7433
- function registerShadcnLayouts(registry) {
7434
- registry.register("admin", ShadcnAdminLayout);
7435
- registry.register("blank", ShadcnBlankLayout);
7436
- registry.register("login", ShadcnLoginLayout);
7437
- registry.register("landing", ShadcnLandingLayout);
7438
- }
7439
- function createShadcnLayoutRegistry() {
7567
+ function registerBuiltinLayouts(registry) {
7568
+ registry.register("admin", AdminLayout);
7569
+ registry.register("blank", BlankLayout);
7570
+ registry.register("login", LoginLayout);
7571
+ registry.register("landing", LandingLayout);
7572
+ registry.register("chat", ChatLayout);
7573
+ }
7574
+ function createLayoutRegistry() {
7440
7575
  const registry = new import_core3.Registry("LayoutRegistry");
7441
- registerShadcnLayouts(registry);
7576
+ registerBuiltinLayouts(registry);
7442
7577
  return registry;
7443
7578
  }
7444
7579
  function resolveLayout(registry, type) {
@@ -7447,7 +7582,7 @@ function resolveLayout(registry, type) {
7447
7582
  console.warn(
7448
7583
  `[pactor-layout] unknown layout type "${type}", fallback to BlankLayout`
7449
7584
  );
7450
- return ShadcnBlankLayout;
7585
+ return BlankLayout;
7451
7586
  }
7452
7587
  return component;
7453
7588
  }
@@ -7621,9 +7756,9 @@ function isRecord(value) {
7621
7756
 
7622
7757
  // src/interaction/provider.tsx
7623
7758
  var import_runtime22 = require("@pactor-app/runtime");
7624
- var import_react28 = require("react");
7759
+ var import_react29 = require("react");
7625
7760
  var import_react_dom = require("react-dom");
7626
- var import_jsx_runtime131 = require("react/jsx-runtime");
7761
+ var import_jsx_runtime132 = require("react/jsx-runtime");
7627
7762
  var TOAST_DURATION = 3e3;
7628
7763
  var toastTypeClass = {
7629
7764
  success: "border-l-4 border-l-success",
@@ -7631,14 +7766,14 @@ var toastTypeClass = {
7631
7766
  info: "border-l-4 border-l-info",
7632
7767
  warning: "border-l-4 border-l-warning"
7633
7768
  };
7634
- function ShadcnInteractionProvider({
7769
+ function InteractionProvider({
7635
7770
  bridge,
7636
7771
  children
7637
7772
  }) {
7638
- const [confirmState, setConfirmState] = (0, import_react28.useState)(null);
7639
- const [toasts, setToasts] = (0, import_react28.useState)([]);
7773
+ const [confirmState, setConfirmState] = (0, import_react29.useState)(null);
7774
+ const [toasts, setToasts] = (0, import_react29.useState)([]);
7640
7775
  const { t } = (0, import_runtime22.useI18n)();
7641
- const { modal, message } = (0, import_react28.useMemo)(() => {
7776
+ const { modal, message } = (0, import_react29.useMemo)(() => {
7642
7777
  const pushToast = (type, content) => {
7643
7778
  const id = Date.now() + Math.random();
7644
7779
  setToasts((prev) => [...prev, { id, type, content }]);
@@ -7659,7 +7794,7 @@ function ShadcnInteractionProvider({
7659
7794
  };
7660
7795
  return { modal: modalImpl, message: messageImpl };
7661
7796
  }, []);
7662
- (0, import_react28.useEffect)(() => {
7797
+ (0, import_react29.useEffect)(() => {
7663
7798
  bridge.modal = modal;
7664
7799
  bridge.message = message;
7665
7800
  return () => {
@@ -7677,11 +7812,11 @@ function ShadcnInteractionProvider({
7677
7812
  setConfirmState(null);
7678
7813
  state?.onCancel?.();
7679
7814
  };
7680
- return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(import_jsx_runtime131.Fragment, { children: [
7815
+ return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_jsx_runtime132.Fragment, { children: [
7681
7816
  children,
7682
7817
  typeof document !== "undefined" && (0, import_react_dom.createPortal)(
7683
- /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(import_jsx_runtime131.Fragment, { children: [
7684
- /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
7818
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_jsx_runtime132.Fragment, { children: [
7819
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7685
7820
  Dialog,
7686
7821
  {
7687
7822
  open: confirmState !== null,
@@ -7690,29 +7825,29 @@ function ShadcnInteractionProvider({
7690
7825
  handleCancel();
7691
7826
  }
7692
7827
  },
7693
- children: /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(DialogContent, { "data-slot": "confirm-dialog", className: "sm:max-w-sm", children: [
7694
- /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(DialogHeader, { children: [
7695
- /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(DialogTitle, { children: confirmState?.title ?? "" }),
7696
- confirmState?.content !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
7828
+ children: /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(DialogContent, { "data-slot": "confirm-dialog", className: "sm:max-w-sm", children: [
7829
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(DialogHeader, { children: [
7830
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(DialogTitle, { children: confirmState?.title ?? "" }),
7831
+ confirmState?.content !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7697
7832
  DialogDescription,
7698
7833
  {
7699
- render: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { children: confirmState.content })
7834
+ render: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { children: confirmState.content })
7700
7835
  }
7701
7836
  )
7702
7837
  ] }),
7703
- /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(DialogFooter, { children: [
7704
- /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(Button, { type: "button", variant: "outline", onClick: handleCancel, children: t("pactor.alertDialog.cancel") }),
7705
- /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(Button, { type: "button", onClick: handleOk, children: t("pactor.alertDialog.confirm") })
7838
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(DialogFooter, { children: [
7839
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Button, { type: "button", variant: "outline", onClick: handleCancel, children: t("pactor.alertDialog.cancel") }),
7840
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Button, { type: "button", onClick: handleOk, children: t("pactor.alertDialog.confirm") })
7706
7841
  ] })
7707
7842
  ] })
7708
7843
  }
7709
7844
  ),
7710
- toasts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
7845
+ toasts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7711
7846
  "div",
7712
7847
  {
7713
7848
  "data-slot": "toast-container",
7714
7849
  className: "fixed top-4 right-4 z-[100] flex w-80 flex-col gap-2",
7715
- children: toasts.map((toast2) => /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
7850
+ children: toasts.map((toast2) => /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7716
7851
  "div",
7717
7852
  {
7718
7853
  "data-slot": "toast",
@@ -7737,21 +7872,21 @@ function ShadcnInteractionProvider({
7737
7872
  // src/interaction/host.tsx
7738
7873
  var import_lucide_react26 = require("lucide-react");
7739
7874
  var import_runtime23 = require("@pactor-app/runtime");
7740
- var import_react29 = require("react");
7741
- var import_jsx_runtime132 = require("react/jsx-runtime");
7875
+ var import_react30 = require("react");
7876
+ var import_jsx_runtime133 = require("react/jsx-runtime");
7742
7877
  function toCssWidth(width) {
7743
7878
  if (width === void 0) {
7744
7879
  return void 0;
7745
7880
  }
7746
7881
  return typeof width === "number" ? `${width}px` : width;
7747
7882
  }
7748
- function ShadcnOverlayHost({ manager, resolvePage }) {
7883
+ function OverlayHost({ manager, resolvePage }) {
7749
7884
  const renderer = (0, import_runtime23.useRenderer)();
7750
- const stack = (0, import_react29.useSyncExternalStore)(
7885
+ const stack = (0, import_react30.useSyncExternalStore)(
7751
7886
  (onChange) => manager.subscribe(onChange),
7752
7887
  () => manager.stack()
7753
7888
  );
7754
- (0, import_react29.useSyncExternalStore)(
7889
+ (0, import_react30.useSyncExternalStore)(
7755
7890
  (onChange) => {
7756
7891
  const offState = renderer.context.state.subscribe(onChange);
7757
7892
  const offData = renderer.context.data.subscribe(onChange);
@@ -7762,7 +7897,7 @@ function ShadcnOverlayHost({ manager, resolvePage }) {
7762
7897
  },
7763
7898
  () => `${renderer.context.state.getVersion()}:${renderer.context.data.getVersion()}`
7764
7899
  );
7765
- return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_jsx_runtime132.Fragment, { children: stack.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7900
+ return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_jsx_runtime133.Fragment, { children: stack.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7766
7901
  OverlayEntryView,
7767
7902
  {
7768
7903
  entry,
@@ -7788,7 +7923,7 @@ function OverlayEntryView({
7788
7923
  parent: manager.parentScopeOf(entry.id)
7789
7924
  });
7790
7925
  } else if (entry.page) {
7791
- body = /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7926
+ body = /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7792
7927
  PageOverlayBody,
7793
7928
  {
7794
7929
  entry,
@@ -7798,9 +7933,9 @@ function OverlayEntryView({
7798
7933
  );
7799
7934
  }
7800
7935
  if (entry.type === "drawer") {
7801
- return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(ShadcnDrawerView, { entry, onCancel: handleCancel, children: body });
7936
+ return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(ShadcnDrawerView, { entry, onCancel: handleCancel, children: body });
7802
7937
  }
7803
- return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7938
+ return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7804
7939
  Dialog,
7805
7940
  {
7806
7941
  open: true,
@@ -7809,7 +7944,7 @@ function OverlayEntryView({
7809
7944
  handleCancel();
7810
7945
  }
7811
7946
  },
7812
- children: /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
7947
+ children: /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(
7813
7948
  DialogContent,
7814
7949
  {
7815
7950
  "data-slot": "overlay-modal",
@@ -7817,25 +7952,25 @@ function OverlayEntryView({
7817
7952
  style: entry.width === void 0 ? void 0 : { width: toCssWidth(entry.width) },
7818
7953
  showCloseButton: false,
7819
7954
  children: [
7820
- /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(DialogHeader, { children: [
7821
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(DialogTitle, { children: entry.title ?? "" }),
7822
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7955
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(DialogHeader, { children: [
7956
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(DialogTitle, { children: entry.title ?? "" }),
7957
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7823
7958
  DialogClose,
7824
7959
  {
7825
- render: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7960
+ render: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7826
7961
  "button",
7827
7962
  {
7828
7963
  type: "button",
7829
7964
  "data-slot": "overlay-modal-close",
7830
7965
  "aria-label": t("pactor.overlay.close"),
7831
7966
  className: "absolute top-4 right-4 cursor-pointer rounded-xs opacity-70 transition-opacity hover:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none",
7832
- children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_lucide_react26.XIcon, { className: "size-4" })
7967
+ children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_lucide_react26.XIcon, { className: "size-4" })
7833
7968
  }
7834
7969
  )
7835
7970
  }
7836
7971
  )
7837
7972
  ] }),
7838
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { "data-slot": "overlay-modal-body", children: body })
7973
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { "data-slot": "overlay-modal-body", children: body })
7839
7974
  ]
7840
7975
  }
7841
7976
  )
@@ -7849,7 +7984,7 @@ function ShadcnDrawerView({
7849
7984
  }) {
7850
7985
  const { t } = (0, import_runtime23.useI18n)();
7851
7986
  const panelStyle = entry.width === void 0 ? void 0 : { width: toCssWidth(entry.width) };
7852
- return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
7987
+ return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7853
7988
  Drawer,
7854
7989
  {
7855
7990
  direction: "right",
@@ -7859,34 +7994,34 @@ function ShadcnDrawerView({
7859
7994
  onCancel();
7860
7995
  }
7861
7996
  },
7862
- children: /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
7997
+ children: /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(
7863
7998
  DrawerContent,
7864
7999
  {
7865
8000
  "data-slot": "drawer-panel",
7866
8001
  className: cn(entry.width !== void 0 && "sm:max-w-none"),
7867
8002
  style: panelStyle,
7868
8003
  children: [
7869
- /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
8004
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(
7870
8005
  DrawerHeader,
7871
8006
  {
7872
8007
  "data-slot": "drawer-header",
7873
8008
  className: "flex flex-row items-center justify-between border-b border-border px-6 py-4",
7874
8009
  children: [
7875
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(DrawerTitle, { className: "text-lg", children: entry.title ?? "" }),
7876
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(DrawerClose, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
8010
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(DrawerTitle, { className: "text-lg", children: entry.title ?? "" }),
8011
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(DrawerClose, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7877
8012
  "button",
7878
8013
  {
7879
8014
  type: "button",
7880
8015
  "data-slot": "drawer-close",
7881
8016
  "aria-label": t("pactor.overlay.close"),
7882
8017
  className: "cursor-pointer rounded-xs opacity-70 transition-opacity hover:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none",
7883
- children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_lucide_react26.XIcon, { className: "size-4" })
8018
+ children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_lucide_react26.XIcon, { className: "size-4" })
7884
8019
  }
7885
8020
  ) })
7886
8021
  ]
7887
8022
  }
7888
8023
  ),
7889
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { "data-slot": "drawer-body", className: "flex-1 overflow-auto p-6", children })
8024
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { "data-slot": "drawer-body", className: "flex-1 overflow-auto p-6", children })
7890
8025
  ]
7891
8026
  }
7892
8027
  )
@@ -7898,13 +8033,13 @@ function PageOverlayBody({
7898
8033
  renderer,
7899
8034
  resolvePage
7900
8035
  }) {
7901
- const [child, setChild] = (0, import_react29.useState)(null);
7902
- const [error, setError] = (0, import_react29.useState)(null);
7903
- (0, import_react29.useEffect)(() => {
8036
+ const [child, setChild] = (0, import_react30.useState)(null);
8037
+ const [error, setError] = (0, import_react30.useState)(null);
8038
+ (0, import_react30.useEffect)(() => {
7904
8039
  if (!resolvePage) {
7905
8040
  setError(
7906
8041
  new Error(
7907
- `[@pactor-app/ui] page overlay\uFF08pageId: "${entry.page?.pageId}"\uFF09\u9700\u8981 ShadcnOverlayHost \u6CE8\u5165 resolvePage`
8042
+ `[@pactor-app/ui] page overlay\uFF08pageId: "${entry.page?.pageId}"\uFF09\u9700\u8981 OverlayHost \u6CE8\u5165 resolvePage`
7908
8043
  )
7909
8044
  );
7910
8045
  return;
@@ -7942,31 +8077,23 @@ function PageOverlayBody({
7942
8077
  };
7943
8078
  }, [entry.id]);
7944
8079
  if (error) {
7945
- return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { role: "alert", children: error.message });
8080
+ return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { role: "alert", children: error.message });
7946
8081
  }
7947
8082
  if (!child) {
7948
8083
  return null;
7949
8084
  }
7950
- return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_runtime23.PageRuntimeView, { runtime: child });
8085
+ return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_runtime23.PageRuntimeView, { runtime: child });
7951
8086
  }
7952
-
7953
- // src/index.ts
7954
- var shadcnUiKit = {
7955
- componentRegistry: createShadcnComponentRegistry,
7956
- layoutRegistry: createShadcnLayoutRegistry,
7957
- interactionKit: {
7958
- Provider: ShadcnInteractionProvider,
7959
- OverlayHost: ShadcnOverlayHost
7960
- }
7961
- };
7962
8087
  // Annotate the CommonJS export names for ESM import in node:
7963
8088
  0 && (module.exports = {
7964
8089
  Accordion,
8090
+ AdminLayout,
7965
8091
  Alert,
7966
8092
  AlertDialog,
7967
8093
  AspectRatio,
7968
8094
  Avatar,
7969
8095
  Badge,
8096
+ BlankLayout,
7970
8097
  Breadcrumb,
7971
8098
  Button,
7972
8099
  ButtonGroup,
@@ -7974,6 +8101,7 @@ var shadcnUiKit = {
7974
8101
  Card,
7975
8102
  Carousel,
7976
8103
  Chart,
8104
+ ChatLayout,
7977
8105
  Checkbox,
7978
8106
  Collapsible,
7979
8107
  Combobox,
@@ -7997,15 +8125,19 @@ var shadcnUiKit = {
7997
8125
  Input,
7998
8126
  InputGroup,
7999
8127
  InputOTP,
8128
+ InteractionProvider,
8000
8129
  Item,
8001
8130
  Kbd,
8002
8131
  Label,
8132
+ LandingLayout,
8003
8133
  Layout,
8004
8134
  Link,
8135
+ LoginLayout,
8005
8136
  Menu,
8006
8137
  Menubar,
8007
8138
  NavigationMenu,
8008
8139
  OVERLAY_CANCEL_PAYLOAD,
8140
+ OverlayHost,
8009
8141
  OverlayManager,
8010
8142
  Page,
8011
8143
  Pagination,
@@ -8017,12 +8149,6 @@ var shadcnUiKit = {
8017
8149
  ScrollArea,
8018
8150
  Select,
8019
8151
  Separator,
8020
- ShadcnAdminLayout,
8021
- ShadcnBlankLayout,
8022
- ShadcnInteractionProvider,
8023
- ShadcnLandingLayout,
8024
- ShadcnLoginLayout,
8025
- ShadcnOverlayHost,
8026
8152
  Sheet,
8027
8153
  Sidebar,
8028
8154
  Sider,
@@ -8040,18 +8166,17 @@ var shadcnUiKit = {
8040
8166
  ToggleGroup,
8041
8167
  Tooltip,
8042
8168
  Typography,
8169
+ builtinComponents,
8043
8170
  collectDefaultOpenKeys,
8044
- createShadcnComponentRegistry,
8045
- createShadcnLayoutRegistry,
8171
+ createComponentRegistry,
8172
+ createLayoutRegistry,
8046
8173
  createUiBridge,
8047
8174
  findMenuChain,
8048
8175
  normalizeIconName,
8176
+ registerBuiltinComponents,
8177
+ registerBuiltinLayouts,
8049
8178
  registerInteractionActions,
8050
- registerShadcnComponents,
8051
- registerShadcnLayouts,
8052
8179
  resolveLayout,
8053
- shadcnComponents,
8054
- shadcnUiKit,
8055
8180
  useFormContext,
8056
8181
  useSidebarDrawer
8057
8182
  });