avt-rct-lib 1.0.0 → 1.0.1
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 +144 -22
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
# avt-rct-lib
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/avt-rct-lib)
|
|
4
|
+
[](https://www.npmjs.com/package/avt-rct-lib)
|
|
5
|
+
[](LICENSE)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
React component library dengan desain **macOS/iOS**. Hanya butuh **Tailwind CSS** — tanpa Radix UI, tanpa library komponen lain.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| `Navbar` | Left/center/right slots, search, icon buttons |
|
|
19
|
-
| `Sidebar` | Push mode (desktop) + overlay mode (mobile) |
|
|
20
|
-
| `Scrollbar` | Thin macOS-style scrollbar wrapper |
|
|
9
|
+
📦 [npmjs.com/package/avt-rct-lib](https://www.npmjs.com/package/avt-rct-lib)
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install avt-rct-lib
|
|
15
|
+
# atau
|
|
16
|
+
bun add avt-rct-lib
|
|
17
|
+
# atau
|
|
18
|
+
pnpm add avt-rct-lib
|
|
19
|
+
```
|
|
21
20
|
|
|
22
21
|
## Setup
|
|
23
22
|
|
|
24
23
|
### 1. Tailwind Config
|
|
25
24
|
|
|
25
|
+
Tambahkan path library ke `content` agar Tailwind men-scan class yang digunakan:
|
|
26
|
+
|
|
26
27
|
```js
|
|
27
28
|
// tailwind.config.js
|
|
28
29
|
export default {
|
|
@@ -33,7 +34,9 @@ export default {
|
|
|
33
34
|
}
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
### 2. Import CSS
|
|
37
|
+
### 2. Import CSS
|
|
38
|
+
|
|
39
|
+
Import satu kali di entry point aplikasi (animasi & scrollbar macOS-style):
|
|
37
40
|
|
|
38
41
|
```ts
|
|
39
42
|
// main.tsx
|
|
@@ -43,17 +46,136 @@ import 'avt-rct-lib/styles'
|
|
|
43
46
|
### 3. Gunakan komponen
|
|
44
47
|
|
|
45
48
|
```tsx
|
|
46
|
-
import { Button, Badge, Card, toast,
|
|
49
|
+
import { Button, Badge, Card, Sidebar, toast, Toaster } from 'avt-rct-lib'
|
|
47
50
|
|
|
51
|
+
// Pasang Toaster di root layout
|
|
52
|
+
<Toaster position="bottom-right" />
|
|
53
|
+
|
|
54
|
+
// Gunakan komponen
|
|
48
55
|
<Button variant="primary">Simpan</Button>
|
|
49
56
|
<Badge variant="success" dot>Online</Badge>
|
|
50
57
|
toast({ title: 'Berhasil!', variant: 'success' })
|
|
51
58
|
```
|
|
52
59
|
|
|
53
|
-
##
|
|
60
|
+
## Komponen
|
|
61
|
+
|
|
62
|
+
| Komponen | Deskripsi |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `Button` | 6 variant, 5 ukuran, loading state, icon support |
|
|
65
|
+
| `Badge` | 7 variant warna + dot indicator |
|
|
66
|
+
| `Input` / `Textarea` | Label, hint, error state, addons kiri/kanan |
|
|
67
|
+
| `Card` | Padding variant, hover effect, glass morphism |
|
|
68
|
+
| `Tabs` | 3 variant: pills, underline, segment — scroll horizontal mobile |
|
|
69
|
+
| `MenuRoot` | Dropdown via `createPortal` — tidak terhalangi overflow/z-index |
|
|
70
|
+
| `Sheet` / `Drawer` | Slide panel right/left/bottom via `createPortal` |
|
|
71
|
+
| `Toast` | Singleton store — bisa dipanggil di luar React |
|
|
72
|
+
| `Table` | Toolbar, pagination, responsive columns |
|
|
73
|
+
| `Navbar` | Left/center/right slots, search, icon buttons, glass |
|
|
74
|
+
| `Sidebar` | Push mode (desktop) + overlay mode (mobile) |
|
|
75
|
+
| `Scrollbar` | Thin macOS-style scrollbar wrapper |
|
|
76
|
+
|
|
77
|
+
## Contoh Penggunaan
|
|
78
|
+
|
|
79
|
+
### Button
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { Button } from 'avt-rct-lib'
|
|
83
|
+
|
|
84
|
+
<Button variant="primary">Simpan</Button>
|
|
85
|
+
<Button variant="destructive" loading>Menghapus...</Button>
|
|
86
|
+
<Button variant="outline" leftIcon={<PlusIcon />}>Tambah</Button>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Sidebar (Desktop + Mobile)
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { Sidebar, SidebarHeader, SidebarBrand, SidebarContent,
|
|
93
|
+
SidebarGroup, SidebarItem, SidebarFooter, SidebarUser,
|
|
94
|
+
SidebarToggle } from 'avt-rct-lib'
|
|
95
|
+
|
|
96
|
+
// Desktop — push mode
|
|
97
|
+
const [collapsed, setCollapsed] = useState(false)
|
|
98
|
+
<Sidebar collapsed={collapsed} width="240px" collapsedWidth="64px">
|
|
99
|
+
...
|
|
100
|
+
</Sidebar>
|
|
101
|
+
|
|
102
|
+
// Mobile — overlay mode
|
|
103
|
+
const [open, setOpen] = useState(false)
|
|
104
|
+
<Sidebar overlay collapsed={!open} onOverlayClose={() => setOpen(false)} width="280px">
|
|
105
|
+
...
|
|
106
|
+
</Sidebar>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Menu Dropdown
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { MenuRoot, MenuButton, MenuContent, MenuItem, MenuSeparator } from 'avt-rct-lib'
|
|
113
|
+
|
|
114
|
+
// MenuContent menggunakan createPortal — selalu di atas semua elemen
|
|
115
|
+
<MenuRoot>
|
|
116
|
+
<MenuButton className="...">Opsi</MenuButton>
|
|
117
|
+
<MenuContent align="end">
|
|
118
|
+
<MenuItem icon={<EditIcon />}>Edit</MenuItem>
|
|
119
|
+
<MenuSeparator />
|
|
120
|
+
<MenuItem icon={<TrashIcon />} variant="destructive">Hapus</MenuItem>
|
|
121
|
+
</MenuContent>
|
|
122
|
+
</MenuRoot>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Toast
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { toast, dismissToast, Toaster } from 'avt-rct-lib'
|
|
129
|
+
|
|
130
|
+
// Di root layout
|
|
131
|
+
<Toaster position="bottom-right" />
|
|
132
|
+
|
|
133
|
+
// Panggil dari mana saja — bahkan dari luar React (API interceptor, dll)
|
|
134
|
+
toast({ title: 'Berhasil!', variant: 'success' })
|
|
135
|
+
toast({ title: 'Error', description: 'Detail...', variant: 'destructive' })
|
|
136
|
+
|
|
137
|
+
const id = toast({ title: 'Loading...', duration: Infinity })
|
|
138
|
+
dismissToast(id)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Table
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import { Table, TableHeader, TableBody, TableRow, TableHead,
|
|
145
|
+
TableCell, TableToolbar, TablePagination } from 'avt-rct-lib'
|
|
146
|
+
|
|
147
|
+
<Table>
|
|
148
|
+
<TableToolbar>
|
|
149
|
+
<Input leftAddon={<SearchIcon />} placeholder="Cari..." />
|
|
150
|
+
<Button size="sm">Tambah</Button>
|
|
151
|
+
</TableToolbar>
|
|
152
|
+
<TableHeader>
|
|
153
|
+
<TableRow>
|
|
154
|
+
<TableHead>Nama</TableHead>
|
|
155
|
+
<TableHead className="hidden sm:table-cell">Status</TableHead>
|
|
156
|
+
</TableRow>
|
|
157
|
+
</TableHeader>
|
|
158
|
+
<TableBody>
|
|
159
|
+
{data.map(row => (
|
|
160
|
+
<TableRow key={row.id}>
|
|
161
|
+
<TableCell>{row.name}</TableCell>
|
|
162
|
+
<TableCell className="hidden sm:table-cell">
|
|
163
|
+
<Badge variant="success" dot>Aktif</Badge>
|
|
164
|
+
</TableCell>
|
|
165
|
+
</TableRow>
|
|
166
|
+
))}
|
|
167
|
+
</TableBody>
|
|
168
|
+
<TablePagination page={page} pageCount={total}
|
|
169
|
+
canPrev={page > 1} canNext={page < total}
|
|
170
|
+
onPrev={() => setPage(p => p - 1)}
|
|
171
|
+
onNext={() => setPage(p => p + 1)} />
|
|
172
|
+
</Table>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Development (dari source lokal)
|
|
54
176
|
|
|
55
177
|
```js
|
|
56
|
-
// vite.config.ts — alias
|
|
178
|
+
// vite.config.ts — alias ke source langsung
|
|
57
179
|
resolve: {
|
|
58
180
|
alias: {
|
|
59
181
|
'avt-rct-lib': path.resolve(__dirname, '../avt-rct-lib/src/index.ts'),
|
|
@@ -65,7 +187,7 @@ content: [
|
|
|
65
187
|
'../avt-rct-lib/src/**/*.{ts,tsx}',
|
|
66
188
|
]
|
|
67
189
|
|
|
68
|
-
// main.tsx — import CSS
|
|
190
|
+
// main.tsx — import CSS dari source
|
|
69
191
|
import '../avt-rct-lib/src/styles/base.css'
|
|
70
192
|
```
|
|
71
193
|
|
|
@@ -73,7 +195,7 @@ import '../avt-rct-lib/src/styles/base.css'
|
|
|
73
195
|
|
|
74
196
|
```bash
|
|
75
197
|
bun run build # kompilasi ke dist/
|
|
76
|
-
npm version patch # bump versi
|
|
198
|
+
npm version patch # bump versi (1.0.0 → 1.0.1)
|
|
77
199
|
npm publish # upload ke npm registry
|
|
78
200
|
```
|
|
79
201
|
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "avt-rct-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "AVT React Component Library — Tailwind only, zero other deps",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.
|
|
7
|
-
"module": "./dist/index.
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"import": {
|
|
12
|
-
"types": "./dist/index.d.mts",
|
|
13
|
-
"default": "./dist/index.mjs"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
12
|
"types": "./dist/index.d.ts",
|
|
17
13
|
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"./styles": "./src/styles/base.css"
|