@neut/ui 0.0.7 → 0.0.9
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 +84 -54
- package/README.zh-CN.md +137 -0
- package/dist/components/alert-dialog/AlertDialogCancel/AlertDialogCancel.js +5 -2
- package/dist/components/alert-dialog/AlertDialogCancel/AlertDialogCancel.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogCancel/AlertDialogCancel.types.d.ts +1 -1
- package/dist/components/button/Button.js +26 -55
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/button/Button.types.d.ts +25 -7
- package/dist/components/collapsible/CollapsibleContent/CollapsibleContent.js +3 -3
- package/dist/components/collapsible/CollapsibleContent/CollapsibleContent.js.map +1 -1
- package/dist/components/collapsible/CollapsibleTrigger/CollapsibleTrigger.js +2 -2
- package/dist/components/collapsible/CollapsibleTrigger/CollapsibleTrigger.js.map +1 -1
- package/dist/components/dialog/Dialog/Dialog.context.d.ts +10 -0
- package/dist/components/dialog/Dialog/Dialog.context.js +11 -0
- package/dist/components/dialog/Dialog/Dialog.context.js.map +1 -0
- package/dist/components/dialog/Dialog/Dialog.d.ts +2 -0
- package/dist/components/dialog/Dialog/Dialog.js +23 -0
- package/dist/components/dialog/Dialog/Dialog.js.map +1 -0
- package/dist/components/dialog/Dialog/Dialog.styles.d.ts +0 -0
- package/dist/components/dialog/Dialog/Dialog.types.d.ts +2 -0
- package/dist/components/dialog/Dialog/index.d.ts +2 -0
- package/dist/components/dialog/DialogClose/DialogClose.d.ts +2 -0
- package/dist/components/dialog/DialogClose/DialogClose.js +46 -0
- package/dist/components/dialog/DialogClose/DialogClose.js.map +1 -0
- package/dist/components/dialog/DialogClose/DialogClose.styles.d.ts +1 -0
- package/dist/components/dialog/DialogClose/DialogClose.styles.js +6 -0
- package/dist/components/dialog/DialogClose/DialogClose.styles.js.map +1 -0
- package/dist/components/dialog/DialogClose/DialogClose.types.d.ts +2 -0
- package/dist/components/dialog/DialogClose/index.d.ts +1 -0
- package/dist/components/dialog/DialogContent/DialogContent.context.d.ts +8 -0
- package/dist/components/dialog/DialogContent/DialogContent.context.js +11 -0
- package/dist/components/dialog/DialogContent/DialogContent.context.js.map +1 -0
- package/dist/components/dialog/DialogContent/DialogContent.d.ts +2 -0
- package/dist/components/dialog/DialogContent/DialogContent.js +71 -0
- package/dist/components/dialog/DialogContent/DialogContent.js.map +1 -0
- package/dist/components/dialog/DialogContent/DialogContent.styles.d.ts +1 -0
- package/dist/components/dialog/DialogContent/DialogContent.styles.js +6 -0
- package/dist/components/dialog/DialogContent/DialogContent.styles.js.map +1 -0
- package/dist/components/dialog/DialogContent/DialogContent.types.d.ts +4 -0
- package/dist/components/dialog/DialogContent/index.d.ts +2 -0
- package/dist/components/dialog/DialogDescription/DialogDescription.d.ts +2 -0
- package/dist/components/dialog/DialogDescription/DialogDescription.js +21 -0
- package/dist/components/dialog/DialogDescription/DialogDescription.js.map +1 -0
- package/dist/components/dialog/DialogDescription/DialogDescription.styles.d.ts +1 -0
- package/dist/components/dialog/DialogDescription/DialogDescription.styles.js +6 -0
- package/dist/components/dialog/DialogDescription/DialogDescription.styles.js.map +1 -0
- package/dist/components/dialog/DialogDescription/DialogDescription.types.d.ts +2 -0
- package/dist/components/dialog/DialogDescription/index.d.ts +1 -0
- package/dist/components/dialog/DialogFooter/DialogFooter.d.ts +2 -0
- package/dist/components/dialog/DialogFooter/DialogFooter.js +18 -0
- package/dist/components/dialog/DialogFooter/DialogFooter.js.map +1 -0
- package/dist/components/dialog/DialogFooter/DialogFooter.styles.d.ts +1 -0
- package/dist/components/dialog/DialogFooter/DialogFooter.styles.js +6 -0
- package/dist/components/dialog/DialogFooter/DialogFooter.styles.js.map +1 -0
- package/dist/components/dialog/DialogFooter/DialogFooter.types.d.ts +2 -0
- package/dist/components/dialog/DialogFooter/index.d.ts +1 -0
- package/dist/components/dialog/DialogHeader/DialogHeader.d.ts +2 -0
- package/dist/components/dialog/DialogHeader/DialogHeader.js +18 -0
- package/dist/components/dialog/DialogHeader/DialogHeader.js.map +1 -0
- package/dist/components/dialog/DialogHeader/DialogHeader.styles.d.ts +1 -0
- package/dist/components/dialog/DialogHeader/DialogHeader.styles.js +6 -0
- package/dist/components/dialog/DialogHeader/DialogHeader.styles.js.map +1 -0
- package/dist/components/dialog/DialogHeader/DialogHeader.types.d.ts +2 -0
- package/dist/components/dialog/DialogHeader/index.d.ts +1 -0
- package/dist/components/dialog/DialogOverlay/DialogOverlay.d.ts +2 -0
- package/dist/components/dialog/DialogOverlay/DialogOverlay.js +27 -0
- package/dist/components/dialog/DialogOverlay/DialogOverlay.js.map +1 -0
- package/dist/components/dialog/DialogOverlay/DialogOverlay.styles.d.ts +1 -0
- package/dist/components/dialog/DialogOverlay/DialogOverlay.styles.js +6 -0
- package/dist/components/dialog/DialogOverlay/DialogOverlay.styles.js.map +1 -0
- package/dist/components/dialog/DialogOverlay/DialogOverlay.types.d.ts +2 -0
- package/dist/components/dialog/DialogOverlay/index.d.ts +1 -0
- package/dist/components/dialog/DialogPortal/DialogPortal.d.ts +2 -0
- package/dist/components/dialog/DialogPortal/DialogPortal.js +10 -0
- package/dist/components/dialog/DialogPortal/DialogPortal.js.map +1 -0
- package/dist/components/dialog/DialogPortal/DialogPortal.types.d.ts +2 -0
- package/dist/components/dialog/DialogPortal/index.d.ts +1 -0
- package/dist/components/dialog/DialogTitle/DialogTitle.d.ts +2 -0
- package/dist/components/dialog/DialogTitle/DialogTitle.js +21 -0
- package/dist/components/dialog/DialogTitle/DialogTitle.js.map +1 -0
- package/dist/components/dialog/DialogTitle/DialogTitle.styles.d.ts +1 -0
- package/dist/components/dialog/DialogTitle/DialogTitle.styles.js +6 -0
- package/dist/components/dialog/DialogTitle/DialogTitle.styles.js.map +1 -0
- package/dist/components/dialog/DialogTitle/DialogTitle.types.d.ts +2 -0
- package/dist/components/dialog/DialogTitle/index.d.ts +1 -0
- package/dist/components/dialog/DialogTrigger/DialogTrigger.d.ts +2 -0
- package/dist/components/dialog/DialogTrigger/DialogTrigger.js +11 -0
- package/dist/components/dialog/DialogTrigger/DialogTrigger.js.map +1 -0
- package/dist/components/dialog/DialogTrigger/DialogTrigger.types.d.ts +0 -0
- package/dist/components/dialog/DialogTrigger/index.d.ts +1 -0
- package/dist/components/dialog/DialogTrigger/useDialogTrigger.d.ts +2 -0
- package/dist/components/dialog/DialogTrigger/useDialogTrigger.js +26 -0
- package/dist/components/dialog/DialogTrigger/useDialogTrigger.js.map +1 -0
- package/dist/components/dialog/index.d.ts +10 -0
- package/dist/components/dialog/index.js +13 -0
- package/dist/components/input-group/InputGroupButton/InputGroupButton.js +13 -13
- package/dist/components/input-group/InputGroupButton/InputGroupButton.js.map +1 -1
- package/dist/components/pagination/PaginationLink/PaginationLink.js.map +1 -1
- package/dist/components/pagination/PaginationLink/PaginationLink.types.d.ts +3 -2
- package/dist/components/switch/Switch.js +23 -30
- package/dist/components/switch/Switch.js.map +1 -1
- package/dist/components/switch/Switch.styles.d.ts +0 -1
- package/dist/components/switch/Switch.styles.js +2 -3
- package/dist/components/switch/Switch.styles.js.map +1 -1
- package/dist/components/switch/Switch.types.d.ts +2 -1
- package/dist/components/toast/components/Toast.js +4 -1
- package/dist/components/toast/components/Toast.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +92 -80
- package/dist/types/props.types.d.ts +4 -2
- package/dist/ui.css +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,107 +1,137 @@
|
|
|
1
|
-
|
|
1
|
+
# Neut
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **SolidJS Native Component Library, Zero External Dependencies**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
> 本项目仍在开发中,不推荐用于生产项目。
|
|
7
|
-
> 本项目中部分组件代码并未完全参考shadcn。
|
|
5
|
+
Neut is inspired by [shadcn/ui](https://ui.shadcn.com), but reimplemented entirely from scratch with SolidJS. Unlike shadcn, Neut **does not depend on any upstream component library** (like `@radix-ui` or `@base-ui`).
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
**Advantages:**
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
- **Fully Controllable**: All component source code lives in your project — modify them however you want.
|
|
10
|
+
- **No Upstream Limitations**: You won't get blocked by third-party component bugs (styling or logic). Fix issues without waiting for a release.
|
|
11
|
+
- **SolidJS Native**: Leverages SolidJS's fine-grained reactivity for better performance.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
**Let's be clear about the downsides:**
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
To be honest, because Neut doesn't rely on more mature upstream component libraries, it may not cover all edge cases. There will be fixable but still unresolved issues — such as bugs, accessibility gaps, etc. Therefore, **it is not recommended for large projects or scenarios with strict quality requirements**.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
> [!WARNING]
|
|
18
|
+
>
|
|
19
|
+
> **Under active development — use with caution**
|
|
20
|
+
>
|
|
21
|
+
> The project is still evolving rapidly, APIs may change. **Do not use in production yet.**
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
- toast.css
|
|
23
|
+
---
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
## 🚀 Quick Start
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
Neut follows a **"copy-paste, then use"** pattern (similar to shadcn), though you can also install it as a regular dependency.
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
### 1. Prerequisites (Peer Dependencies)
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
31
|
+
Before using any components, make sure these dependencies are installed in your project:
|
|
32
|
+
|
|
33
|
+
| Dependency | Purpose | Install Command |
|
|
34
|
+
| :--------------------------- | :----------------------- | :------------------------------- |
|
|
35
|
+
| **Tailwind CSS** | Styling engine | `bun i -D tailwindcss` |
|
|
36
|
+
| **Lucide Solid** | Icon library | `bun i lucide-solid` |
|
|
37
|
+
| **Tailwind Merge** | Style merging tool | `bun i tailwind-merge` |
|
|
38
|
+
| **Class Variance Authority** | Style variant definition | `bun i class-variance-authority` |
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
**Configure your stylesheet**
|
|
41
|
+
|
|
42
|
+
In your main stylesheet (e.g., `index.css` or `globals.css`), import in this order:
|
|
36
43
|
|
|
37
44
|
```css
|
|
38
|
-
@
|
|
45
|
+
@tailwind base;
|
|
46
|
+
@tailwind components;
|
|
47
|
+
@tailwind utilities;
|
|
48
|
+
|
|
49
|
+
/* Neut built-in styles (from animate.css and toast.css) */
|
|
39
50
|
@import "./styles/animate.css";
|
|
40
51
|
@import "./styles/toast.css";
|
|
41
52
|
```
|
|
42
53
|
|
|
43
|
-
|
|
54
|
+
**Create a utility function**
|
|
44
55
|
|
|
45
|
-
|
|
46
|
-
bun i tailwind-merge class-variance-authority
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
然后在`lib/utils`中创建一个`clsx.ts`文件,内容如下:
|
|
56
|
+
Write a style merging function in `src/lib/utils/clsx.ts`:
|
|
50
57
|
|
|
51
58
|
```ts
|
|
52
59
|
import { twMerge } from "tailwind-merge";
|
|
53
60
|
|
|
54
61
|
export const clsx = (...classes: (string | undefined | false)[]): string => {
|
|
55
|
-
|
|
62
|
+
return twMerge(classes.filter(Boolean));
|
|
56
63
|
};
|
|
57
64
|
```
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
> [!NOTE]
|
|
67
|
+
> **About the stylesheet files**
|
|
68
|
+
> `toast.css` is currently a temporary solution (ported from Sonner). We will rewrite the styles later to remove this external dependency.
|
|
60
69
|
|
|
61
|
-
|
|
62
|
-
bun i lucide-solid
|
|
63
|
-
```
|
|
70
|
+
### 2. Method A: Copy the source code (recommended)
|
|
64
71
|
|
|
65
|
-
|
|
72
|
+
This is the most flexible approach. Non-primitive components may have overlapping functionality (e.g., `AlertDialog` and `Dialog`), but they are standalone and independent.
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
1. Check the component source code in the [GitHub repo - Components](https://github.com/thep0y/neut).
|
|
75
|
+
2. Copy the directory of the component you need (e.g., `button`) into your project.
|
|
68
76
|
|
|
77
|
+
**Example directory structure:**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
src/
|
|
81
|
+
└── components/
|
|
82
|
+
└── button/
|
|
83
|
+
├── Button.styles.ts # Styling logic
|
|
84
|
+
├── Button.tsx # Component implementation
|
|
85
|
+
├── Button.types.ts # Type definitions
|
|
86
|
+
└── index.ts # Export entry
|
|
69
87
|
```
|
|
70
|
-
./src/components/button/
|
|
71
|
-
└── Button.styles.ts
|
|
72
|
-
└── Button.tsx
|
|
73
|
-
└── Button.types.ts
|
|
74
|
-
└── index.ts
|
|
75
|
-
```
|
|
76
88
|
|
|
77
|
-
###
|
|
89
|
+
### 3. Method B: Install as a dependency
|
|
90
|
+
|
|
91
|
+
If you prefer version management, you can also install via a package manager.
|
|
78
92
|
|
|
79
|
-
|
|
93
|
+
**Install:**
|
|
80
94
|
|
|
81
95
|
```bash
|
|
82
96
|
bun i @neut/ui
|
|
83
97
|
```
|
|
84
98
|
|
|
85
|
-
|
|
99
|
+
**Import styles:**
|
|
100
|
+
|
|
101
|
+
Add this to your root stylesheet:
|
|
86
102
|
|
|
87
103
|
```css
|
|
88
|
-
@import "tailwindcss";
|
|
89
104
|
@import "../node_modules/@neut/ui/dist/ui.css";
|
|
90
105
|
```
|
|
91
106
|
|
|
92
|
-
|
|
107
|
+
**Use components:**
|
|
93
108
|
|
|
94
109
|
```tsx
|
|
95
110
|
import { Button } from "@neut/ui";
|
|
96
111
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
112
|
+
function App() {
|
|
113
|
+
return <Button>Neut Button</Button>;
|
|
114
|
+
}
|
|
100
115
|
```
|
|
101
116
|
|
|
102
|
-
|
|
117
|
+
**Full example:** [Neut Example Project](https://github.com/thep0y/neut/tree/main/example)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 📚 References & Acknowledgements
|
|
122
|
+
|
|
123
|
+
The project's design and inspiration come from these great projects:
|
|
124
|
+
|
|
125
|
+
- **shadcn/ui**: [Installation Guide](https://ui.shadcn.com/docs/installation)
|
|
126
|
+
- **Sonner**: [Getting Started](https://sonner.emilkowal.ski/getting-started)
|
|
127
|
+
- **SolidJS**: [Official Website](https://www.solidjs.com/)
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 💡 Why this pattern?
|
|
103
132
|
|
|
104
|
-
|
|
133
|
+
Neut follows the philosophy of **"headless components"** and **"building your own blocks"**. That means:
|
|
105
134
|
|
|
106
|
-
|
|
107
|
-
|
|
135
|
+
1. **No overhead**: Only the code you actually include is used.
|
|
136
|
+
2. **Freely customizable styles**: Tailwind classes are right in front of you — tweak them anytime.
|
|
137
|
+
3. **Leverage SolidJS strengths**: Compared to React, SolidJS's fine-grained reactivity gives you high-performance components with less code and cleaner logic.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Neut
|
|
2
|
+
|
|
3
|
+
> **SolidJS 原生组件库,零外部依赖**
|
|
4
|
+
|
|
5
|
+
Neut 的灵感来自 [shadcn/ui](https://ui.shadcn.com),但完全用 SolidJS 从头实现。和 shadcn 不一样的是,Neut **不依赖任何上游组件库**(比如 `@radix-ui` 或 `@base-ui`)。
|
|
6
|
+
|
|
7
|
+
**优点:**
|
|
8
|
+
|
|
9
|
+
- **完全可控**:所有组件源码都在你的项目里,想怎么改就怎么改。
|
|
10
|
+
- **不受上游限制**:不会因为第三方组件的样式或逻辑 Bug 而卡住,修问题不用等发版。
|
|
11
|
+
- **SolidJS 原生**:充分利用 SolidJS 的细粒度响应式,性能更好。
|
|
12
|
+
|
|
13
|
+
**缺点也要说清楚:**
|
|
14
|
+
|
|
15
|
+
坦白讲,因为没有依赖那些更成熟的上游组件库,Neut 在一些边缘场景上可能覆盖不够,会有一些能修但还没修的缺陷,比如 Bug、无障碍支持等。所以**不建议用在大型项目或对质量要求严格的场景**。
|
|
16
|
+
|
|
17
|
+
> [!WARNING]
|
|
18
|
+
>
|
|
19
|
+
> **开发中,慎用**
|
|
20
|
+
>
|
|
21
|
+
> 项目还在活跃开发,API 可能会变,**生产环境先别用**。
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 🚀 快速上手
|
|
26
|
+
|
|
27
|
+
Neut 采用的是 **“复制即用”** 的模式(类似 shadcn),当然你也可以把它当成普通依赖来安装。
|
|
28
|
+
|
|
29
|
+
### 1. 准备工作 (Peer Dependencies)
|
|
30
|
+
|
|
31
|
+
用组件之前,先确保项目里装好了下面这些依赖:
|
|
32
|
+
|
|
33
|
+
| 依赖库 | 用途 | 安装命令 |
|
|
34
|
+
| :--------------------------- | :----------- | :------------------------------- |
|
|
35
|
+
| **Tailwind CSS** | 样式引擎 | `bun i -D tailwindcss` |
|
|
36
|
+
| **Lucide Solid** | 图标库 | `bun i lucide-solid` |
|
|
37
|
+
| **Tailwind Merge** | 样式合并工具 | `bun i tailwind-merge` |
|
|
38
|
+
| **Class Variance Authority** | 样式变体定义 | `bun i class-variance-authority` |
|
|
39
|
+
|
|
40
|
+
**配置样式文件**
|
|
41
|
+
|
|
42
|
+
在主样式文件(比如 `index.css` 或 `globals.css`)里按顺序引入:
|
|
43
|
+
|
|
44
|
+
```css
|
|
45
|
+
@tailwind base;
|
|
46
|
+
@tailwind components;
|
|
47
|
+
@tailwind utilities;
|
|
48
|
+
|
|
49
|
+
/* Neut 内置样式(来自 animate.css 和 toast.css) */
|
|
50
|
+
@import "./styles/animate.css";
|
|
51
|
+
@import "./styles/toast.css";
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**创建工具函数**
|
|
55
|
+
|
|
56
|
+
在 `src/lib/utils/clsx.ts` 里写一个样式合并函数:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { twMerge } from "tailwind-merge";
|
|
60
|
+
|
|
61
|
+
export const clsx = (...classes: (string | undefined | false)[]): string => {
|
|
62
|
+
return twMerge(classes.filter(Boolean));
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> [!NOTE]
|
|
67
|
+
> **关于样式文件**
|
|
68
|
+
> `toast.css` 目前是临时方案(从 Sonner 移植过来的)。后面我们会重写样式,把这个外部依赖去掉。
|
|
69
|
+
|
|
70
|
+
### 2. 方式 A:复制源码(推荐)
|
|
71
|
+
|
|
72
|
+
这种方式最灵活。非基础组件之间可能存在功能重叠(比如 `AlertDialog` 和 `Dialog`),但各自独立,互不依赖。
|
|
73
|
+
|
|
74
|
+
1. 去 [GitHub 仓库 - Components](https://github.com/thep0y/neut) 看组件源码。
|
|
75
|
+
2. 把你需要的组件目录(比如 `button`)复制到项目里。
|
|
76
|
+
|
|
77
|
+
**目录结构示例:**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
src/
|
|
81
|
+
└── components/
|
|
82
|
+
└── button/
|
|
83
|
+
├── Button.styles.ts # 样式逻辑
|
|
84
|
+
├── Button.tsx # 组件实现
|
|
85
|
+
├── Button.types.ts # 类型定义
|
|
86
|
+
└── index.ts # 导出入口
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 3. 方式 B:作为依赖安装
|
|
90
|
+
|
|
91
|
+
如果想直接管理版本,也可以走包管理器安装。
|
|
92
|
+
|
|
93
|
+
**安装:**
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
bun i @neut/ui
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**引入样式:**
|
|
100
|
+
|
|
101
|
+
在根样式文件里加上:
|
|
102
|
+
|
|
103
|
+
```css
|
|
104
|
+
@import "../node_modules/@neut/ui/dist/ui.css";
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**使用组件:**
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import { Button } from "@neut/ui";
|
|
111
|
+
|
|
112
|
+
function App() {
|
|
113
|
+
return <Button>Neut Button</Button>;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**完整示例参考:** [Neut Example Project](https://github.com/thep0y/neut/tree/main/example)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 📚 参考与致谢
|
|
122
|
+
|
|
123
|
+
项目设计和灵感来自下面这些优秀项目:
|
|
124
|
+
|
|
125
|
+
- **shadcn/ui**: [Installation Guide](https://ui.shadcn.com/docs/installation)
|
|
126
|
+
- **Sonner**: [Getting Started](https://sonner.emilkowal.ski/getting-started)
|
|
127
|
+
- **SolidJS**: [Official Website](https://www.solidjs.com/)
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 💡 为什么选这种模式?
|
|
132
|
+
|
|
133
|
+
Neut 遵循 **“无头组件”**和 **“自己搭积木”** 的理念。也就是说:
|
|
134
|
+
|
|
135
|
+
1. **没有多余开销**:只用你实际引入的代码。
|
|
136
|
+
2. **样式随便改**:Tailwind 的 class 就在你眼皮底下,想调就调。
|
|
137
|
+
3. **发挥 SolidJS 优势**:相比 React,SolidJS 的细粒度响应式让组件在高性能的同时,代码量更少、逻辑更清爽。
|
|
@@ -5,10 +5,13 @@ import { mergeProps as i } from "solid-js";
|
|
|
5
5
|
//#region src/components/alert-dialog/AlertDialogCancel/AlertDialogCancel.tsx
|
|
6
6
|
var a = (a) => {
|
|
7
7
|
let { setOpen: o } = e();
|
|
8
|
-
return n(t, r(
|
|
8
|
+
return n(t, r(i({
|
|
9
9
|
variant: "outline",
|
|
10
10
|
size: "md"
|
|
11
|
-
}, a), {
|
|
11
|
+
}, a), {
|
|
12
|
+
"data-slot": "alert-dialog-cancel",
|
|
13
|
+
onClick: () => o(!1)
|
|
14
|
+
}));
|
|
12
15
|
};
|
|
13
16
|
//#endregion
|
|
14
17
|
export { a as AlertDialogCancel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertDialogCancel.js","names":["mergeProps","AlertDialogCancelProps","Button","useAlertDialogContext","AlertDialogCancel","props","setOpen","merged","variant","size","const","_$createComponent","_$mergeProps","onClick"],"sources":["../../../../src/components/alert-dialog/AlertDialogCancel/AlertDialogCancel.tsx"],"sourcesContent":["import { mergeProps } from \"solid-js\";\nimport type { AlertDialogCancelProps } from \"./AlertDialogCancel.types\";\nimport { Button } from \"~/components/button\";\nimport { useAlertDialogContext } from \"../AlertDialog\";\n\nexport const AlertDialogCancel = (props: AlertDialogCancelProps) => {\n const { setOpen } = useAlertDialogContext();\n\n const merged = mergeProps({ variant: \"outline\", size: \"md\" } as const, props);\n\n return (\n <Button\n data-slot=\"alert-dialog-cancel\"\n
|
|
1
|
+
{"version":3,"file":"AlertDialogCancel.js","names":["mergeProps","AlertDialogCancelProps","Button","useAlertDialogContext","AlertDialogCancel","props","setOpen","merged","variant","size","const","_$createComponent","_$mergeProps","onClick"],"sources":["../../../../src/components/alert-dialog/AlertDialogCancel/AlertDialogCancel.tsx"],"sourcesContent":["import { mergeProps } from \"solid-js\";\nimport type { AlertDialogCancelProps } from \"./AlertDialogCancel.types\";\nimport { Button } from \"~/components/button\";\nimport { useAlertDialogContext } from \"../AlertDialog\";\n\nexport const AlertDialogCancel = (props: AlertDialogCancelProps) => {\n const { setOpen } = useAlertDialogContext();\n\n const merged = mergeProps({ variant: \"outline\", size: \"md\" } as const, props);\n\n return (\n <Button\n {...merged}\n data-slot=\"alert-dialog-cancel\"\n onClick={() => setOpen(false)}\n />\n );\n};\n"],"mappings":";;;;;AAKA,IAAaI,KAAqBC,MAAkC;CAClE,IAAM,EAAEC,eAAYH,GAAuB;AAI3C,QAAAQ,EACGT,GAAMU,EAHMZ,EAAW;EAAEQ,SAAS;EAAWC,MAAM;EAAM,EAAWJ,EAAM,EAI/D;EAAA,aAAA;EAEVQ,eAAeP,EAAQ,GAAK;EAAC,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ButtonProps } from '../../button';
|
|
2
|
-
export type AlertDialogCancelProps =
|
|
2
|
+
export type AlertDialogCancelProps = ButtonProps<"button">;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { clsx as e } from "../../utils/clsx.js";
|
|
2
2
|
import t from "./Button.styles.js";
|
|
3
3
|
import { Dynamic as n, createComponent as r, insert as i, memo as a, mergeProps as o, setAttribute as s, template as c } from "solid-js/web";
|
|
4
|
-
import {
|
|
4
|
+
import { children as l, createMemo as u, createUniqueId as d, mergeProps as f, splitProps as p } from "solid-js";
|
|
5
5
|
//#region src/components/button/Button.tsx
|
|
6
|
-
var m = /* @__PURE__ */ c("<span>"), h = (c) => {
|
|
7
|
-
let [
|
|
6
|
+
var m = /* @__PURE__ */ c("<span>"), h = /* @__PURE__ */ c("<span class=sr-only>"), g = (c) => {
|
|
7
|
+
let [g, _] = p(f({
|
|
8
8
|
variant: "primary",
|
|
9
9
|
size: "md",
|
|
10
10
|
as: "button",
|
|
11
|
-
iconPosition: "left",
|
|
12
11
|
id: d()
|
|
13
12
|
}, c), [
|
|
14
13
|
"as",
|
|
@@ -20,68 +19,40 @@ var m = /* @__PURE__ */ c("<span>"), h = (c) => {
|
|
|
20
19
|
"classList",
|
|
21
20
|
"children",
|
|
22
21
|
"onClick"
|
|
23
|
-
]),
|
|
24
|
-
var
|
|
25
|
-
return s(
|
|
26
|
-
})()
|
|
22
|
+
]), v = u(() => g.icon && typeof g.icon == "object" && "ariaLabel" in g.icon && "icon" in g.icon || !!g.icon && !g.children), y = (e, t) => (() => {
|
|
23
|
+
var n = m();
|
|
24
|
+
return s(n, "data-icon", t), i(n, e), n;
|
|
25
|
+
})(), b = l(() => g.icon ? typeof g.icon == "object" && "ariaLabel" in g.icon && "icon" in g.icon ? [a(() => g.icon.icon), (() => {
|
|
26
|
+
var e = h();
|
|
27
|
+
return i(e, () => g.icon.ariaLabel), e;
|
|
28
|
+
})()] : [
|
|
29
|
+
a(() => a(() => !g.iconPosition || g.iconPosition === "left")() && y(g.icon, "inline-start")),
|
|
30
|
+
a(() => g.children),
|
|
31
|
+
a(() => a(() => g.iconPosition === "right")() && y(g.icon, "inline-end"))
|
|
32
|
+
] : g.children);
|
|
27
33
|
return r(n, o({
|
|
28
34
|
"data-slot": "button",
|
|
29
35
|
get component() {
|
|
30
|
-
return
|
|
36
|
+
return g.as;
|
|
37
|
+
},
|
|
38
|
+
get type() {
|
|
39
|
+
return a(() => g.as === "button")() ? _.type ?? "button" : void 0;
|
|
31
40
|
},
|
|
32
41
|
get onClick() {
|
|
33
|
-
return
|
|
42
|
+
return g.onClick;
|
|
34
43
|
},
|
|
35
44
|
get class() {
|
|
36
45
|
return e(t({
|
|
37
|
-
variant:
|
|
38
|
-
size:
|
|
39
|
-
iconSize:
|
|
40
|
-
}),
|
|
46
|
+
variant: g.variant,
|
|
47
|
+
size: v() ? void 0 : g.size,
|
|
48
|
+
iconSize: v() ? g.size : void 0
|
|
49
|
+
}), g.class);
|
|
41
50
|
}
|
|
42
|
-
},
|
|
43
|
-
return
|
|
44
|
-
r(l, {
|
|
45
|
-
get when() {
|
|
46
|
-
return a(() => !!h.icon)() && h.iconPosition === "left";
|
|
47
|
-
},
|
|
48
|
-
get children() {
|
|
49
|
-
return r(l, {
|
|
50
|
-
get when() {
|
|
51
|
-
return !_();
|
|
52
|
-
},
|
|
53
|
-
get fallback() {
|
|
54
|
-
return h.icon;
|
|
55
|
-
},
|
|
56
|
-
get children() {
|
|
57
|
-
return v("inline-start");
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
a(() => h.children),
|
|
63
|
-
r(l, {
|
|
64
|
-
get when() {
|
|
65
|
-
return a(() => !!h.icon)() && h.iconPosition === "right";
|
|
66
|
-
},
|
|
67
|
-
get children() {
|
|
68
|
-
return r(l, {
|
|
69
|
-
get when() {
|
|
70
|
-
return !_();
|
|
71
|
-
},
|
|
72
|
-
get fallback() {
|
|
73
|
-
return h.icon;
|
|
74
|
-
},
|
|
75
|
-
get children() {
|
|
76
|
-
return v("inline-end");
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
];
|
|
51
|
+
}, _, { get children() {
|
|
52
|
+
return b();
|
|
82
53
|
} }));
|
|
83
54
|
};
|
|
84
55
|
//#endregion
|
|
85
|
-
export {
|
|
56
|
+
export { g as Button };
|
|
86
57
|
|
|
87
58
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["createMemo","createUniqueId","
|
|
1
|
+
{"version":3,"file":"Button.js","names":["children","createMemo","createUniqueId","JSXElement","mergeProps","splitProps","Dynamic","clsx","s","ButtonProps","ButtonValidElement","DefaultStyleProps","ResolvedButtonProps","Button","props","T","merged","variant","size","as","id","Partial","local","others","iconOnly","icon","iconWithAttr","position","_el$","_tmpl$","_$setAttribute","_$insert","resolved","_$memo","_el$2","_tmpl$2","ariaLabel","iconPosition","_$createComponent","_$mergeProps","component","type","undefined","onClick","class","iconSize"],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import {\n children,\n createMemo,\n createUniqueId,\n type JSXElement,\n mergeProps,\n splitProps,\n} from \"solid-js\";\nimport { Dynamic } from \"solid-js/web\";\nimport { clsx } from \"~/utils\";\nimport s from \"./Button.styles\";\nimport type {\n ButtonProps,\n ButtonValidElement,\n DefaultStyleProps,\n ResolvedButtonProps,\n} from \"./Button.types\";\n\nexport const Button = <T extends ButtonValidElement = \"button\">(\n props: ButtonProps<T>,\n) => {\n const merged = mergeProps(\n {\n variant: \"primary\",\n size: \"md\",\n as: \"button\",\n id: createUniqueId(),\n } satisfies Partial<DefaultStyleProps>,\n props as ResolvedButtonProps<T>,\n );\n\n const [local, others] = splitProps(merged, [\n \"as\",\n \"variant\",\n \"size\",\n \"icon\",\n \"iconPosition\",\n \"class\",\n \"classList\",\n \"children\",\n \"onClick\",\n ]);\n\n const iconOnly = createMemo(\n () =>\n (local.icon &&\n typeof local.icon === \"object\" &&\n \"ariaLabel\" in local.icon &&\n \"icon\" in local.icon) ||\n (!!local.icon && !local.children),\n );\n\n const iconWithAttr = (\n icon: JSXElement,\n position: \"inline-start\" | \"inline-end\",\n ) => <span data-icon={position}>{icon}</span>;\n\n const resolved = children(() =>\n local.icon ? (\n typeof local.icon === \"object\" &&\n \"ariaLabel\" in local.icon &&\n \"icon\" in local.icon ? (\n <>\n {local.icon.icon}\n <span class=\"sr-only\">{local.icon.ariaLabel}</span>\n </>\n ) : (\n <>\n {(!local.iconPosition || local.iconPosition === \"left\") &&\n iconWithAttr(local.icon, \"inline-start\")}\n {local.children}\n {local.iconPosition === \"right\" &&\n iconWithAttr(local.icon, \"inline-end\")}\n </>\n )\n ) : (\n local.children\n ),\n );\n\n return (\n // @ts-expect-error\n <Dynamic\n data-slot=\"button\"\n component={local.as}\n type={local.as === \"button\" ? (others.type ?? \"button\") : undefined}\n onClick={local.onClick}\n class={clsx(\n s({\n variant: local.variant,\n size: iconOnly() ? undefined : local.size,\n iconSize: iconOnly() ? local.size : undefined,\n }),\n local.class,\n )}\n {...others}\n >\n {resolved()}\n </Dynamic>\n );\n};\n"],"mappings":";;;;;oFAkBaa,KACXC,MACG;CAWH,IAAM,CAACQ,GAAOC,KAAUlB,EAVTD,EACb;EACEa,SAAS;EACTC,MAAM;EACNC,IAAI;EACJC,IAAIlB,GAAe;EACpB,EACDY,EACD,EAE0C;EACzC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,EAEIU,IAAWvB,QAEZqB,EAAMG,QACL,OAAOH,EAAMG,QAAS,YACtB,eAAeH,EAAMG,QACrB,UAAUH,EAAMG,QACjB,CAAC,CAACH,EAAMG,QAAQ,CAACH,EAAMtB,SAC3B,EAEK0B,KACJD,GACAE,aAAuC;EAAA,IAAAC,IAAAC,GAAA;AACJ,SADIC,EAAAF,GAAA,aACnBD,EAAQ,EAAAI,EAAAH,GAAGH,EAAI,EAAAG;KAAQ,EAEvCI,IAAWhC,QACfsB,EAAMG,OACJ,OAAOH,EAAMG,QAAS,YACtB,eAAeH,EAAMG,QACrB,UAAUH,EAAMG,OAAI,CAAAQ,QAEfX,EAAMG,KAAKA,KAAI,SAAA;EAAA,IAAAS,IAAAC,GAAA;AAC2B,SAD3BJ,EAAAG,SACOZ,EAAMG,KAAKW,UAAS,EAAAF;KAAA,CAAA,GAAA;EAAAD,QAI1CA,QAAC,CAACX,EAAMe,gBAAgBf,EAAMe,iBAAiB,OAAM,EAAA,IACpDX,EAAaJ,EAAMG,MAAM,eAAe,CAAA;EAAAQ,QACzCX,EAAMtB,SAAQ;EAAAiC,QACdA,QAAAX,EAAMe,iBAAiB,QAAO,EAAA,IAC7BX,EAAaJ,EAAMG,MAAM,aAAa,CAAA;EAE3C,GAEDH,EAAMtB,SAET;AAED,QACEsC,EACChC,GAAOiC,EAAA;EAAA,aAAA;EAAA,IAENC,YAAS;AAAA,UAAElB,EAAMH;;EAAE,IACnBsB,OAAI;AAAA,UAAER,QAAAX,EAAMH,OAAO,SAAQ,EAAA,GAAII,EAAOkB,QAAQ,WAAYC,KAAAA;;EAAS,IACnEC,UAAO;AAAA,UAAErB,EAAMqB;;EAAO,IAAA,QAAA;AAAA,UACfpC,EACLC,EAAE;IACAS,SAASK,EAAML;IACfC,MAAMM,GAAU,GAAGkB,KAAAA,IAAYpB,EAAMJ;IACrC2B,UAAUrB,GAAU,GAAGF,EAAMJ,OAAOwB,KAAAA;IACrC,CAAC,EACFpB,EAAMsB,MACP;;EAAA,EACGrB,GAAM,EAAA,IAAAvB,WAAA;AAAA,SAETgC,GAAU;IAAA,CAAA,CAAA"}
|
|
@@ -2,23 +2,41 @@ import { JSXElement } from 'solid-js';
|
|
|
2
2
|
import { BaseProps, MakeRequired, MouseEventHandler, PolymorphicProps } from '../../types';
|
|
3
3
|
export type ButtonVariant = "primary" | "outline" | "secondary" | "ghost" | "destructive" | "link";
|
|
4
4
|
export type ButtonSize = "md" | "xs" | "sm" | "lg";
|
|
5
|
-
interface BaseButtonProps extends BaseProps {
|
|
5
|
+
export interface BaseButtonProps extends BaseProps {
|
|
6
6
|
variant?: ButtonVariant;
|
|
7
7
|
size?: ButtonSize;
|
|
8
|
+
id?: string;
|
|
9
|
+
}
|
|
10
|
+
export type ButtonIconProps = {
|
|
8
11
|
/** Button content */
|
|
9
|
-
children
|
|
12
|
+
children: JSXElement;
|
|
10
13
|
icon?: JSXElement;
|
|
11
14
|
iconPosition?: "left" | "right";
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
} | {
|
|
16
|
+
icon: {
|
|
17
|
+
icon: JSXElement;
|
|
18
|
+
ariaLabel: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
14
21
|
export type ButtonValidElement = "button" | "a";
|
|
15
|
-
export type ButtonProps<T extends ButtonValidElement> = PolymorphicProps<T, BaseButtonProps & {
|
|
22
|
+
export type ButtonProps<T extends ButtonValidElement> = Omit<PolymorphicProps<T, BaseButtonProps & {
|
|
16
23
|
onClick?: MouseEventHandler<T>;
|
|
17
|
-
}
|
|
24
|
+
}>, "children"> & ButtonIconProps;
|
|
25
|
+
export type ResolvedBaseButtonProps = {
|
|
26
|
+
/** Button content */
|
|
27
|
+
children?: JSXElement;
|
|
28
|
+
icon?: JSXElement | {
|
|
29
|
+
icon: JSXElement;
|
|
30
|
+
ariaLabel: string;
|
|
31
|
+
};
|
|
32
|
+
iconPosition?: "left" | "right";
|
|
33
|
+
};
|
|
34
|
+
export type ResolvedButtonProps<T extends ButtonValidElement> = PolymorphicProps<T, BaseButtonProps & {
|
|
35
|
+
onClick?: MouseEventHandler<T>;
|
|
36
|
+
}> & ResolvedBaseButtonProps;
|
|
18
37
|
export type DefaultStyleProps = MakeRequired<BaseButtonProps, "size" | "variant"> & {
|
|
19
38
|
as: ButtonValidElement;
|
|
20
39
|
};
|
|
21
40
|
export type ButtonPropsWithDefault<T extends ButtonValidElement> = PolymorphicProps<T, BaseButtonProps & {
|
|
22
41
|
onClick?: MouseEventHandler<T>;
|
|
23
42
|
}>;
|
|
24
|
-
export {};
|
|
@@ -3,14 +3,14 @@ import { createComponent as t, insert as n, spread as r, template as i } from "s
|
|
|
3
3
|
import { Show as a, splitProps as o } from "solid-js";
|
|
4
4
|
//#region src/components/collapsible/CollapsibleContent/CollapsibleContent.tsx
|
|
5
5
|
var s = /* @__PURE__ */ i("<div data-slot=collapsible-content>"), c = (i) => {
|
|
6
|
-
let {
|
|
6
|
+
let { open: c } = e(), [l, u] = o(i, ["children"]);
|
|
7
7
|
return t(a, {
|
|
8
8
|
get when() {
|
|
9
|
-
return
|
|
9
|
+
return c();
|
|
10
10
|
},
|
|
11
11
|
get children() {
|
|
12
12
|
var e = s();
|
|
13
|
-
return r(e,
|
|
13
|
+
return r(e, u, !1, !0), n(e, () => l.children), e;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollapsibleContent.js","names":["Show","splitProps","CollapsibleContentProps","useCollapsibleContext","CollapsibleContent","props","
|
|
1
|
+
{"version":3,"file":"CollapsibleContent.js","names":["Show","splitProps","CollapsibleContentProps","useCollapsibleContext","CollapsibleContent","props","open","local","others","_$createComponent","when","children","_el$","_tmpl$","_$spread","_$insert"],"sources":["../../../../src/components/collapsible/CollapsibleContent/CollapsibleContent.tsx"],"sourcesContent":["import { Show, splitProps } from \"solid-js\";\nimport type { CollapsibleContentProps } from \"./CollapsibleContent.types\";\nimport { useCollapsibleContext } from \"../Collapsible\";\n\nexport const CollapsibleContent = (props: CollapsibleContentProps) => {\n const { open } = useCollapsibleContext();\n\n const [local, others] = splitProps(props, [\"children\"]);\n\n return (\n <Show when={open()}>\n <div data-slot=\"collapsible-content\" {...others}>\n {local.children}\n </div>\n </Show>\n );\n};\n"],"mappings":";;;;kEAIaI,KAAsBC,MAAmC;CACpE,IAAM,EAAEC,YAASH,GAAuB,EAElC,CAACI,GAAOC,KAAUP,EAAWI,GAAO,CAAC,WAAW,CAAC;AAEvD,QAAAI,EACGT,GAAI;EAAA,IAACU,OAAI;AAAA,UAAEJ,GAAM;;EAAA,IAAAK,WAAA;GAAA,IAAAC,IAAAC,GAAA;AAEC,UAFDC,EAAAF,GACyBJ,GAAM,IAAA,GAAA,EAAAO,EAAAH,SAC5CL,EAAMI,SAAQ,EAAAC;;EAAA,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { createComponent as n, mergeProps as r } from "solid-js/web";
|
|
|
4
4
|
//#region src/components/collapsible/CollapsibleTrigger/CollapsibleTrigger.tsx
|
|
5
5
|
var i = (i) => {
|
|
6
6
|
let { onOpenChange: a, open: o, setInternalOpen: s } = t();
|
|
7
|
-
return n(e, r({
|
|
7
|
+
return n(e, r(i, {
|
|
8
8
|
"data-slot": "collapsible-trigger",
|
|
9
9
|
get "data-panel-open"() {
|
|
10
10
|
return o();
|
|
@@ -16,7 +16,7 @@ var i = (i) => {
|
|
|
16
16
|
let e = !o();
|
|
17
17
|
s(e), a?.(e);
|
|
18
18
|
}
|
|
19
|
-
}
|
|
19
|
+
}));
|
|
20
20
|
};
|
|
21
21
|
//#endregion
|
|
22
22
|
export { i as CollapsibleTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollapsibleTrigger.js","names":["useCollapsibleContext","CollapsibleTriggerProps","Button","CollapsibleTrigger","props","onOpenChange","open","setInternalOpen","handleClick","next","_$createComponent","_$mergeProps","data-panel-open","aria-expanded","onClick"],"sources":["../../../../src/components/collapsible/CollapsibleTrigger/CollapsibleTrigger.tsx"],"sourcesContent":["import { useCollapsibleContext } from \"../Collapsible\";\nimport type { CollapsibleTriggerProps } from \"./CollapsibleTrigger.types\";\nimport { Button } from \"~/components/button\";\n\nexport const CollapsibleTrigger = (props: CollapsibleTriggerProps) => {\n const { onOpenChange, open, setInternalOpen } = useCollapsibleContext();\n\n const handleClick = () => {\n const next = !open();\n setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n return (\n <Button\n data-slot=\"collapsible-trigger\"\n data-panel-open={open()}\n aria-expanded={open()}\n onClick={handleClick}\n
|
|
1
|
+
{"version":3,"file":"CollapsibleTrigger.js","names":["useCollapsibleContext","CollapsibleTriggerProps","Button","CollapsibleTrigger","props","onOpenChange","open","setInternalOpen","handleClick","next","_$createComponent","_$mergeProps","data-panel-open","aria-expanded","onClick"],"sources":["../../../../src/components/collapsible/CollapsibleTrigger/CollapsibleTrigger.tsx"],"sourcesContent":["import { useCollapsibleContext } from \"../Collapsible\";\nimport type { CollapsibleTriggerProps } from \"./CollapsibleTrigger.types\";\nimport { Button } from \"~/components/button\";\n\nexport const CollapsibleTrigger = (props: CollapsibleTriggerProps) => {\n const { onOpenChange, open, setInternalOpen } = useCollapsibleContext();\n\n const handleClick = () => {\n const next = !open();\n setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n return (\n // @ts-expect-error\n <Button\n {...props}\n data-slot=\"collapsible-trigger\"\n data-panel-open={open()}\n aria-expanded={open()}\n onClick={handleClick}\n />\n );\n};\n"],"mappings":";;;;AAIA,IAAaG,KAAsBC,MAAmC;CACpE,IAAM,EAAEC,iBAAcC,SAAMC,uBAAoBP,GAAuB;AAQvE,QACEU,EACCR,GAAMS,EACDP,GAAK;EAAA,aAAA;EAAA,IAAA,oBAAA;AAAA,UAEQE,GAAM;;EAAA,IAAA,kBAAA;AAAA,UACRA,GAAM;;EACrBQ,eAbsB;GACxB,IAAML,IAAO,CAACH,GAAM;AAEpBD,GADAE,EAAgBE,EAAK,EACrBJ,IAAeI,EAAK;;EAUE,CAAA,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Accessor, Setter } from 'solid-js';
|
|
2
|
+
interface DialogContextValue {
|
|
3
|
+
show: Accessor<boolean>;
|
|
4
|
+
setShow: Setter<boolean>;
|
|
5
|
+
open: Accessor<boolean>;
|
|
6
|
+
setOpen: Setter<boolean>;
|
|
7
|
+
}
|
|
8
|
+
export declare const DialogContext: import('solid-js').Context<DialogContextValue | undefined>;
|
|
9
|
+
export declare const useDialogContext: () => DialogContextValue;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext as e, useContext as t } from "solid-js";
|
|
2
|
+
//#region src/components/dialog/Dialog/Dialog.context.ts
|
|
3
|
+
var n = e(), r = () => {
|
|
4
|
+
let e = t(n);
|
|
5
|
+
if (!e) throw Error("useDialogContext must be used within a DialogProvider");
|
|
6
|
+
return e;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { n as DialogContext, r as useDialogContext };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=Dialog.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.context.js","names":[],"sources":["../../../../src/components/dialog/Dialog/Dialog.context.ts"],"sourcesContent":["import {\n type Accessor,\n createContext,\n type Setter,\n useContext,\n} from \"solid-js\";\n\ninterface DialogContextValue {\n show: Accessor<boolean>;\n setShow: Setter<boolean>;\n open: Accessor<boolean>;\n setOpen: Setter<boolean>;\n}\n\nexport const DialogContext = createContext<DialogContextValue>();\n\nexport const useDialogContext = () => {\n const context = useContext(DialogContext);\n if (!context) {\n throw new Error(\"useDialogContext must be used within a DialogProvider\");\n }\n return context;\n};\n"],"mappings":";;AAcA,IAAa,IAAgB,GAAmC,EAEnD,UAAyB;CACpC,IAAM,IAAU,EAAW,EAAc;AACzC,KAAI,CAAC,EACH,OAAU,MAAM,wDAAwD;AAE1E,QAAO"}
|