@sarunyu/system-one 4.4.1 → 4.5.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/AGENTS.md +9 -0
- package/README.md +7 -0
- package/dist/index.cjs +427 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +429 -2
- package/dist/index.js.map +1 -1
- package/dist/src/components/alert.d.ts +9 -0
- package/dist/src/components/alert.d.ts.map +1 -0
- package/dist/src/components/badge.d.ts +23 -0
- package/dist/src/components/badge.d.ts.map +1 -0
- package/dist/src/components/notification.d.ts +47 -0
- package/dist/src/components/notification.d.ts.map +1 -0
- package/dist/src/components/toast.d.ts +25 -0
- package/dist/src/components/toast.d.ts.map +1 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/llms.txt +127 -2
- package/package.json +1 -1
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @sarunyu/system-one — AI usage guide
|
|
2
2
|
|
|
3
|
-
React component library. Tailwind CSS v4 + CSS custom properties.
|
|
3
|
+
React component library. Tailwind CSS v4 + CSS custom properties. 24 components.
|
|
4
4
|
Built for AI-powered UI generation (v0, Lovable, Figma Make, Cursor).
|
|
5
5
|
|
|
6
6
|
**This file is the contract.** Read it top-to-bottom before generating any screen
|
|
@@ -12,7 +12,7 @@ that uses this library. The rules are non-negotiable.
|
|
|
12
12
|
|
|
13
13
|
1. **Use library components for every element it provides.** Never recreate
|
|
14
14
|
Button, Input, Tag, Dropdown, Card, Tab, Checkbox, Toggle, Radio, DateInput, TimeInput,
|
|
15
|
-
Table, SearchInput, TextArea, Chip, Modal, BottomSheet as raw HTML.
|
|
15
|
+
Table, SearchInput, TextArea, Chip, Modal, BottomSheet, Alert, Toast, Notification, Badge as raw HTML.
|
|
16
16
|
2. **Use design-token classes for color and typography.** Never `text-blue-600`,
|
|
17
17
|
`bg-gray-100`, `text-[#3b82f6]`. The token table below is exhaustive — if a
|
|
18
18
|
color you need is not in it, use `text-foreground` / `bg-card`.
|
|
@@ -68,6 +68,11 @@ import {
|
|
|
68
68
|
Tab, TabGroup,
|
|
69
69
|
Card,
|
|
70
70
|
Table, TableRow, TableHeaderCell, TableCell,
|
|
71
|
+
// Feedback
|
|
72
|
+
Alert,
|
|
73
|
+
Toast, ToastStack,
|
|
74
|
+
Notification,
|
|
75
|
+
Badge,
|
|
71
76
|
// Overlay
|
|
72
77
|
Modal, BottomSheet,
|
|
73
78
|
// Utility
|
|
@@ -634,6 +639,126 @@ Raw option rows. Use when you need a custom dropdown or a sidebar menu — other
|
|
|
634
639
|
|
|
635
640
|
---
|
|
636
641
|
|
|
642
|
+
### Alert
|
|
643
|
+
|
|
644
|
+
Inline, persistent status banner — anchored inside the page or form layout. Never use as a floating notification; use `Toast` for transient messages.
|
|
645
|
+
|
|
646
|
+
```tsx
|
|
647
|
+
type AlertStatus = "normal" | "information" | "success" | "warning" | "critical";
|
|
648
|
+
|
|
649
|
+
<Alert status="normal" message="This field is required." />
|
|
650
|
+
<Alert status="information" message="Your session expires in 10 minutes." />
|
|
651
|
+
<Alert status="success" message="Payment confirmed." />
|
|
652
|
+
<Alert status="warning" message="Incomplete profile — some features are limited." />
|
|
653
|
+
<Alert status="critical" message="Authentication failed. Please try again." />
|
|
654
|
+
<Alert status="warning" message="A longer message that wraps to a second line." multiline />
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
Props: `status?` (default `"normal"`), `message` (required), `multiline?` (default `false` — `false` truncates to one line, `true` clamps to 2 lines), `className`.
|
|
658
|
+
|
|
659
|
+
---
|
|
660
|
+
|
|
661
|
+
### Toast / ToastStack
|
|
662
|
+
|
|
663
|
+
Transient floating feedback — appears at screen edges, dismissed manually or auto-closes. Place in a `fixed` portal; use `ToastStack` for a queued list.
|
|
664
|
+
|
|
665
|
+
```tsx
|
|
666
|
+
type ToastVariant = "default" | "broadcast";
|
|
667
|
+
type ToastStatus = "information" | "success" | "warning" | "critical";
|
|
668
|
+
|
|
669
|
+
// Default toast
|
|
670
|
+
<Toast status="success" message="File uploaded." onClose={dismiss} />
|
|
671
|
+
<Toast status="warning" message="Low storage — 100 MB remaining." actionLabel="Free up space" onActionClick={open} onClose={dismiss} />
|
|
672
|
+
<Toast status="critical" message="Connection lost. Retrying…" multiline onClose={dismiss} />
|
|
673
|
+
|
|
674
|
+
// Broadcast — system announcement banner (no close button)
|
|
675
|
+
<Toast variant="broadcast" status="information" message="Maintenance window: Saturday 02:00–04:00." />
|
|
676
|
+
|
|
677
|
+
// Stack — multiple toasts at once
|
|
678
|
+
<div className="fixed bottom-4 right-4 z-50 w-[343px]">
|
|
679
|
+
<ToastStack items={toasts} />
|
|
680
|
+
</div>
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
Props (Toast): `variant?` (default `"default"`), `status?` (default `"information"`), `message`, `multiline?`, `actionLabel?`, `onActionClick?`, `onClose?`, `className`.
|
|
684
|
+
Props (ToastStack): `items: (ToastProps & { id: string })[]`, `className`, `renderItem?`.
|
|
685
|
+
|
|
686
|
+
---
|
|
687
|
+
|
|
688
|
+
### Badge
|
|
689
|
+
|
|
690
|
+
Button with a count indicator. Two variants:
|
|
691
|
+
|
|
692
|
+
- `"button"` (default) — filter/action button (funnel icon) that shows a count badge when active. Use in toolbars and filter bars.
|
|
693
|
+
- `"notification"` — bell icon button used **internally** by `<Notification>`. Do not use standalone.
|
|
694
|
+
|
|
695
|
+
**Critical rule:** `<Badge variant="notification">` is an internal building block of `<Notification>`. Never wire it to your own `onClick` (a toast, a custom popover, etc.). If you need a notification bell that opens a list, use `<Notification>` — it renders the bell and the panel together.
|
|
696
|
+
|
|
697
|
+
```tsx
|
|
698
|
+
// Filter button — inactive and active states
|
|
699
|
+
<Badge label="Filter" count={0} onClick={openFilter} />
|
|
700
|
+
<Badge label="Filter" count={3} onClick={openFilter} />
|
|
701
|
+
<Badge iconOnly count={2} onClick={openFilter} />
|
|
702
|
+
|
|
703
|
+
// WRONG — do not do this:
|
|
704
|
+
// <Badge variant="notification" count={5} onClick={showToast} />
|
|
705
|
+
|
|
706
|
+
// CORRECT — for a notification bell + list, always use <Notification>:
|
|
707
|
+
<Notification groups={groups} onItemClick={handleClick} />
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
Props: `variant?` (`"button"` | `"notification"`, default `"button"`), `count?`, `maxCount?` (default 99), `label?` (button variant, default `"Filter"`), `iconOnly?`, `icon?` (custom icon), `notificationState?` (`"default"` | `"active"` | `"noti"`), plus native `<button>` props.
|
|
711
|
+
|
|
712
|
+
---
|
|
713
|
+
|
|
714
|
+
### Notification
|
|
715
|
+
|
|
716
|
+
Bell-icon trigger + popover panel showing grouped notification rows. Handles badge count, auto-clear on open, and keyboard navigation. Uses `<Badge variant="notification">` internally.
|
|
717
|
+
|
|
718
|
+
```tsx
|
|
719
|
+
const groups: NotificationGroup[] = [
|
|
720
|
+
{
|
|
721
|
+
label: "25 ก.ค. 2567",
|
|
722
|
+
items: [
|
|
723
|
+
{
|
|
724
|
+
id: "1",
|
|
725
|
+
title: "ยืนยันการชำระเงิน",
|
|
726
|
+
description: "รายการ TXN-00234 ได้รับการยืนยันแล้ว",
|
|
727
|
+
time: "10:45",
|
|
728
|
+
unread: true,
|
|
729
|
+
type: "icon",
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
id: "2",
|
|
733
|
+
title: "อัปเดตระบบ",
|
|
734
|
+
description: "เวอร์ชัน 4.4 พร้อมใช้งานแล้ว",
|
|
735
|
+
time: "08:30",
|
|
736
|
+
type: "image",
|
|
737
|
+
imageSrc: "/img/system.png",
|
|
738
|
+
actionLabel: "อัปเดต",
|
|
739
|
+
onActionClick: handleUpdate,
|
|
740
|
+
},
|
|
741
|
+
],
|
|
742
|
+
},
|
|
743
|
+
];
|
|
744
|
+
|
|
745
|
+
<Notification groups={groups} onItemClick={handleClick} />
|
|
746
|
+
<Notification groups={groups} badgeCount={12} clearBadgeOnOpen />
|
|
747
|
+
<Notification groups={[]} emptyText="ไม่มีการแจ้งเตือน" />
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
Props: `groups`, `badgeCount?` (overrides computed unread count), `panelWidth?` (default 375), `emptyText?`, `clearBadgeOnOpen?` (default `true`), `open?`, `defaultOpen?`, `onOpenChange?`, `onBadgeCleared?`, `onItemClick?`, `className`, `panelClassName`.
|
|
751
|
+
|
|
752
|
+
**When to use which:**
|
|
753
|
+
|
|
754
|
+
| Component | Pattern | Lifetime |
|
|
755
|
+
|---|---|---|
|
|
756
|
+
| `Alert` | Inline, anchored to related content (form, section) | Persistent |
|
|
757
|
+
| `Toast` | Floating, screen edge (top/bottom) | Transient — auto or manual dismiss |
|
|
758
|
+
| `Notification` | Bell icon → popover history panel | On-demand |
|
|
759
|
+
|
|
760
|
+
---
|
|
761
|
+
|
|
637
762
|
### Modal
|
|
638
763
|
|
|
639
764
|
Centered overlay surface for confirmations, richer content, or status alerts.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sarunyu/system-one",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A production-ready React design system built for AI-powered web generation tools (Figma Make, Lovable, V0). Tailwind CSS v4 + CSS custom properties for full theming support.",
|
|
6
6
|
"keywords": [
|