@arronqzy/ui 0.0.0 → 1.0.2

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/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # @arronqzy/ui
2
+
3
+ Abuilder 的**共享 UI 组件库**,基于 [shadcn/ui](https://ui.shadcn.com/) + Radix UI + Tailwind CSS,为编辑器与蓝图提供统一视觉与交互。
4
+
5
+ ## 功能概览
6
+
7
+ - **基础组件**:Button、Input、Dialog、Dropdown、Tabs、Tooltip、Toast 等
8
+ - **表单**:与 `react-hook-form`、`zod` 集成的表单控件
9
+ - **布局**:Resizable Panels、ScrollArea、Separator
10
+ - **主题**:`ThemeProvider` 支持亮/暗色与 `class` 策略
11
+ - **层级管理**:`UI_Z_INDEX` / `MODAL_Z_INDEX` 统一浮层 z-index
12
+ - **图表**:封装 Recharts 常用图表(按需使用)
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ pnpm add @arronqzy/ui
18
+ ```
19
+
20
+ ```ts
21
+ import "@arronqzy/ui/styles.css";
22
+ ```
23
+
24
+ ## 使用
25
+
26
+ ```tsx
27
+ import { ThemeProvider, Button, toast } from "@arronqzy/ui";
28
+ import "@arronqzy/ui/styles.css";
29
+
30
+ function App() {
31
+ return (
32
+ <ThemeProvider defaultTheme="dark">
33
+ <Button onClick={() => toast({ title: "Hello" })}>点击</Button>
34
+ </ThemeProvider>
35
+ );
36
+ }
37
+ ```
38
+
39
+ ### 工具函数
40
+
41
+ ```ts
42
+ import { cn } from "@arronqzy/ui";
43
+ import { UI_Z_INDEX } from "@arronqzy/ui";
44
+ ```
45
+
46
+ ## 导出说明
47
+
48
+ - `@arronqzy/ui` — 全部组件、`cn`、`ThemeProvider`、`useToast`
49
+ - `@arronqzy/ui/styles.css` — 编译后的 Tailwind 样式
50
+
51
+ 组件源码位于 `src/ui/`,遵循 shadcn 可组合模式,可按需在本包内扩展。
52
+
53
+ ## 构建样式
54
+
55
+ ```bash
56
+ pnpm -C packages/ui build:css
57
+ ```
58
+
59
+ 依赖 `@arronqzy/tailwind` 预设保持与设计令牌一致。
60
+
61
+ ## 许可证
62
+
63
+ MIT
package/dist/styles.css CHANGED
@@ -754,14 +754,14 @@ body {
754
754
  z-index: 10000;
755
755
  }
756
756
 
757
- .z-\[100\] {
758
- z-index: 100;
759
- }
760
-
761
757
  .z-\[1\] {
762
758
  z-index: 1;
763
759
  }
764
760
 
761
+ .z-toast {
762
+ z-index: 99999;
763
+ }
764
+
765
765
  .-mx-1 {
766
766
  margin-left: -0.25rem;
767
767
  margin-right: -0.25rem;
@@ -2300,6 +2300,10 @@ body {
2300
2300
  pointer-events: none;
2301
2301
  }
2302
2302
 
2303
+ .data-\[state\=closed\]\:pointer-events-none[data-state="closed"] {
2304
+ pointer-events: none;
2305
+ }
2306
+
2303
2307
  .data-\[panel-group-direction\=vertical\]\:h-px[data-panel-group-direction="vertical"] {
2304
2308
  height: 1px;
2305
2309
  }
@@ -2769,18 +2773,6 @@ body {
2769
2773
  }
2770
2774
 
2771
2775
  @media (min-width: 640px) {
2772
- .sm\:bottom-0 {
2773
- bottom: 0px;
2774
- }
2775
-
2776
- .sm\:right-0 {
2777
- right: 0px;
2778
- }
2779
-
2780
- .sm\:top-auto {
2781
- top: auto;
2782
- }
2783
-
2784
2776
  .sm\:mt-0 {
2785
2777
  margin-top: 0px;
2786
2778
  }
@@ -2793,10 +2785,6 @@ body {
2793
2785
  flex-direction: row;
2794
2786
  }
2795
2787
 
2796
- .sm\:flex-col {
2797
- flex-direction: column;
2798
- }
2799
-
2800
2788
  .sm\:justify-end {
2801
2789
  justify-content: flex-end;
2802
2790
  }
@@ -2818,10 +2806,6 @@ body {
2818
2806
  .sm\:text-left {
2819
2807
  text-align: left;
2820
2808
  }
2821
-
2822
- .data-\[state\=open\]\:sm\:slide-in-from-bottom-full[data-state="open"] {
2823
- --tw-enter-translate-y: 100%;
2824
- }
2825
2809
  }
2826
2810
 
2827
2811
  @media (min-width: 768px) {
package/index.ts CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  export * from "./src/ui/index";
4
4
  export * from "./src/lib/utils";
5
- export { MODAL_Z_INDEX } from "./src/lib/overlay-z-index";
5
+ export { MODAL_Z_INDEX, UI_Z_INDEX } from "./src/lib/overlay-z-index";
6
6
  export * from "./src/hooks/use-toast";
7
7
  export * from "./src/theme-provider";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arronqzy/ui",
3
- "version": "0.0.0",
3
+ "version": "1.0.2",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./counter": "./components/counter.ts",
@@ -63,8 +63,8 @@
63
63
  "eslint": "^8.57.0",
64
64
  "typescript": "^5.5.4",
65
65
  "@arronqzy/eslint-config": "0.0.0",
66
- "@arronqzy/typescript-config": "0.0.0",
67
- "@arronqzy/tailwind": "0.0.1"
66
+ "@arronqzy/tailwind": "1.0.2",
67
+ "@arronqzy/typescript-config": "1.0.0"
68
68
  },
69
69
  "scripts": {
70
70
  "lint": "eslint \"**/*.{ts,tsx}\"",
@@ -1,8 +1,23 @@
1
1
  import type { CSSProperties } from "react";
2
2
 
3
- /** 弹窗层级:高于画布 Ruler(999)、工具栏(1200)、Menubar(10100) 等 */
4
- export const MODAL_Z_INDEX = 20000;
5
- export const MODAL_CONTENT_Z_INDEX = 20001;
3
+ /** 全局浮层 z-index 刻度 */
4
+ export const UI_Z_INDEX = {
5
+ tooltip: 10000,
6
+ dropdown: 10100,
7
+ popover: 10120,
8
+ alertDialog: 10150,
9
+ /** 弹窗:高于画布 Ruler、工具栏、Menubar 等 */
10
+ modal: 20000,
11
+ modalContent: 20001,
12
+ /** Toast 通知:始终置于最顶层 */
13
+ toast: 99999,
14
+ } as const;
6
15
 
7
- export const modalOverlayStyle: CSSProperties = { zIndex: MODAL_Z_INDEX };
8
- export const modalContentStyle: CSSProperties = { zIndex: MODAL_CONTENT_Z_INDEX };
16
+ /** @deprecated 使用 UI_Z_INDEX.modal */
17
+ export const MODAL_Z_INDEX = UI_Z_INDEX.modal;
18
+
19
+ /** @deprecated 使用 UI_Z_INDEX.modalContent */
20
+ export const MODAL_CONTENT_Z_INDEX = UI_Z_INDEX.modalContent;
21
+
22
+ export const modalOverlayStyle: CSSProperties = { zIndex: UI_Z_INDEX.modal };
23
+ export const modalContentStyle: CSSProperties = { zIndex: UI_Z_INDEX.modalContent };
package/src/ui/sonner.tsx CHANGED
@@ -10,6 +10,8 @@ import {
10
10
  import { useTheme } from "next-themes"
11
11
  import { Toaster as Sonner } from "sonner"
12
12
 
13
+ import { UI_Z_INDEX } from "../lib/overlay-z-index"
14
+
13
15
  type ToasterProps = React.ComponentProps<typeof Sonner>
14
16
 
15
17
  const Toaster = ({ ...props }: ToasterProps) => {
@@ -19,6 +21,7 @@ const Toaster = ({ ...props }: ToasterProps) => {
19
21
  <Sonner
20
22
  theme={theme as ToasterProps["theme"]}
21
23
  className="toaster group"
24
+ style={{ zIndex: UI_Z_INDEX.toast }}
22
25
  icons={{
23
26
  success: <CircleCheck className="h-4 w-4" />,
24
27
  info: <Info className="h-4 w-4" />,
package/src/ui/toast.tsx CHANGED
@@ -6,6 +6,7 @@ import { cva, type VariantProps } from "class-variance-authority"
6
6
  import { X } from "lucide-react"
7
7
 
8
8
  import { cn } from "../lib/utils"
9
+ import { UI_Z_INDEX } from "../lib/overlay-z-index"
9
10
 
10
11
  const ToastProvider = ToastPrimitives.Provider
11
12
 
@@ -15,8 +16,9 @@ const ToastViewport = React.forwardRef<
15
16
  >(({ className, ...props }, ref) => (
16
17
  <ToastPrimitives.Viewport
17
18
  ref={ref}
19
+ style={{ zIndex: UI_Z_INDEX.toast }}
18
20
  className={cn(
19
- "fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
21
+ "pointer-events-none fixed top-0 right-0 z-toast flex max-h-screen w-full flex-col gap-2 p-4 md:max-w-[420px]",
20
22
  className
21
23
  )}
22
24
  {...props}
@@ -25,7 +27,7 @@ const ToastViewport = React.forwardRef<
25
27
  ToastViewport.displayName = ToastPrimitives.Viewport.displayName
26
28
 
27
29
  const toastVariants = cva(
28
- "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
30
+ "group pointer-events-auto data-[state=closed]:pointer-events-none relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full",
29
31
  {
30
32
  variants: {
31
33
  variant: {
@@ -1,5 +1,7 @@
1
1
  "use client"
2
2
 
3
+ import { createPortal } from "react-dom"
4
+
3
5
  import { useToast } from "../hooks/use-toast"
4
6
  import {
5
7
  Toast,
@@ -13,8 +15,10 @@ import {
13
15
  export function Toaster() {
14
16
  const { toasts } = useToast()
15
17
 
16
- return (
17
- <ToastProvider>
18
+ if (typeof document === "undefined") return null
19
+
20
+ return createPortal(
21
+ <ToastProvider swipeDirection="right">
18
22
  {toasts.map(function ({ id, title, description, action, ...props }) {
19
23
  return (
20
24
  <Toast key={id} {...props}>
@@ -30,6 +34,7 @@ export function Toaster() {
30
34
  )
31
35
  })}
32
36
  <ToastViewport />
33
- </ToastProvider>
37
+ </ToastProvider>,
38
+ document.body
34
39
  )
35
40
  }
@@ -1,4 +0,0 @@
1
-
2
- > @arron/ui@0.0.0 lint /Users/arron/program/project/opensource/Abuilder26/packages/ui
3
- > eslint "**/*.{ts,tsx}"
4
-