@ahrowe/ui 0.14.0 → 0.15.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/esm/common/errorBoundary/errorBoundary.mjs +4 -0
- package/dist/esm/common/errorBoundary/errorBoundary.mjs.map +1 -0
- package/dist/esm/common/errorBoundary/errorBoundary.module.mjs +2 -0
- package/dist/esm/common/errorBoundary/errorBoundary.module.mjs.map +1 -0
- package/dist/esm/common/interactableDiv/interactableDiv.mjs +1 -1
- package/dist/esm/common/interactableDiv/interactableDiv.mjs.map +1 -1
- package/dist/esm/common/kanbanBoard/KanbanBoard.mjs +6 -1
- package/dist/esm/common/kanbanBoard/KanbanBoard.mjs.map +1 -1
- package/dist/esm/common/kanbanBoard/KanbanColumn.mjs +1 -1
- package/dist/esm/common/kanbanBoard/KanbanColumn.mjs.map +1 -1
- package/dist/esm/common/kanbanBoard/KanbanItem.mjs +1 -1
- package/dist/esm/common/kanbanBoard/KanbanItem.mjs.map +1 -1
- package/dist/esm/common/kanbanBoard/kanbanBoard.module.mjs +1 -1
- package/dist/esm/common/kanbanBoard/kanbanBoard.module.mjs.map +1 -1
- package/dist/esm/common/kanbanBoard/kanbanBoard.utils.mjs +2 -0
- package/dist/esm/common/kanbanBoard/kanbanBoard.utils.mjs.map +1 -0
- package/dist/esm/common/timeline/timeline.mjs +2 -0
- package/dist/esm/common/timeline/timeline.mjs.map +1 -0
- package/dist/esm/common/timeline/timeline.module.mjs +2 -0
- package/dist/esm/common/timeline/timeline.module.mjs.map +1 -0
- package/dist/esm/common/timeline/timeline.types.mjs +2 -0
- package/dist/esm/common/timeline/timeline.types.mjs.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/index.cjs +11 -4
- package/dist/index.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/package/common/errorBoundary/errorBoundary.d.ts +14 -0
- package/dist/types/package/common/errorBoundary/errorBoundary.types.d.ts +57 -0
- package/dist/types/package/common/errorBoundary/index.d.ts +2 -0
- package/dist/types/package/common/kanbanBoard/KanbanBoard.d.ts +1 -1
- package/dist/types/package/common/kanbanBoard/KanbanColumn.d.ts +37 -1
- package/dist/types/package/common/kanbanBoard/KanbanItem.d.ts +2 -6
- package/dist/types/package/common/kanbanBoard/kanbanBoard.types.d.ts +99 -5
- package/dist/types/package/common/kanbanBoard/kanbanBoard.utils.d.ts +60 -0
- package/dist/types/package/common/themeProvider/theme.types.d.ts +2 -0
- package/dist/types/package/common/timeline/index.d.ts +2 -0
- package/dist/types/package/common/timeline/timeline.d.ts +2 -0
- package/dist/types/package/common/timeline/timeline.types.d.ts +51 -0
- package/dist/types/package/index.d.ts +4 -0
- package/docs/CLAUDE.md +2 -0
- package/docs/ErrorBoundary.md +93 -0
- package/docs/KanbanBoard.md +165 -4
- package/docs/Timeline.md +127 -0
- package/package.json +2 -4
package/docs/Timeline.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Timeline
|
|
2
|
+
|
|
3
|
+
**When to use:** A vertical list of dated events, connected by a line, for audit logs, activity feeds, order status history, and deploy logs. Each entry can carry a title, timestamp, description, an icon or status colour, and arbitrary extra content.
|
|
4
|
+
|
|
5
|
+
**Import:** `import { Timeline, TimelineAlignment, TimelineItemStatus } from '@ahrowe/ui'`
|
|
6
|
+
**Types:** `import type { TimelineItem, TimelineProps } from '@ahrowe/ui'`
|
|
7
|
+
|
|
8
|
+
**Enums:**
|
|
9
|
+
- `TimelineAlignment`: `Left` (default) | `Right` | `Alternate`
|
|
10
|
+
- `TimelineItemStatus`: `Default` (default) | `Primary` | `Success` | `Warn` | `Error`
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { Timeline, TimelineItemStatus } from '@ahrowe/ui';
|
|
14
|
+
import type { TimelineItem } from '@ahrowe/ui';
|
|
15
|
+
|
|
16
|
+
const items: TimelineItem[] = [
|
|
17
|
+
{ title: 'Invoice created', description: 'by Jane Doe', timestamp: '09:12' },
|
|
18
|
+
{ title: 'Invoice sent to client', description: 'via email', timestamp: '09:15' },
|
|
19
|
+
{ title: 'Payment received', status: TimelineItemStatus.Success, timestamp: '2 days later' },
|
|
20
|
+
{ title: 'Invoice closed', status: TimelineItemStatus.Success, timestamp: 'Today' },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
// Default: left-aligned line and markers, content to the right
|
|
24
|
+
<Timeline items={items} />
|
|
25
|
+
|
|
26
|
+
// Icon markers instead of plain dots
|
|
27
|
+
import { faUserPlus, faCheck } from '@fortawesome/free-solid-svg-icons';
|
|
28
|
+
<Timeline
|
|
29
|
+
items={[
|
|
30
|
+
{ title: 'Account created', icon: faUserPlus, timestamp: 'Mon' },
|
|
31
|
+
{ title: 'Email verified', icon: faCheck, status: TimelineItemStatus.Success, timestamp: 'Wed' },
|
|
32
|
+
]}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
// Right-aligned: line and markers on the right, content on the left
|
|
36
|
+
import { TimelineAlignment } from '@ahrowe/ui';
|
|
37
|
+
<Timeline items={items} alignment={TimelineAlignment.Right} />
|
|
38
|
+
|
|
39
|
+
// Alternate: entries alternate either side of a centered line
|
|
40
|
+
<Timeline items={items} alignment={TimelineAlignment.Alternate} />
|
|
41
|
+
|
|
42
|
+
// Extra content per entry: a diff, an attachment, an actor avatar
|
|
43
|
+
<Timeline
|
|
44
|
+
items={[
|
|
45
|
+
{
|
|
46
|
+
title: 'Deploy #128 started',
|
|
47
|
+
description: 'main @ a93d12d',
|
|
48
|
+
timestamp: '14:02',
|
|
49
|
+
content: <p>Triggered by Jon Snow.</p>,
|
|
50
|
+
},
|
|
51
|
+
]}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
// Clickable entries: e.g. open the full audit log record in a Modal.
|
|
55
|
+
// An item without onClick stays a plain, non-interactive row.
|
|
56
|
+
import { Modal } from '@ahrowe/ui';
|
|
57
|
+
|
|
58
|
+
function AuditLog() {
|
|
59
|
+
const [selected, setSelected] = useState<(typeof items)[number] | null>(null);
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<Timeline
|
|
63
|
+
items={items.map((entry) => ({ ...entry, onClick: () => setSelected(entry) }))}
|
|
64
|
+
/>
|
|
65
|
+
<Modal isOpen={selected != null} title={selected?.title} onClose={() => setSelected(null)}>
|
|
66
|
+
{selected?.description}
|
|
67
|
+
</Modal>
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Lock an individual entry: dimmed, never clickable, even with onClick set
|
|
73
|
+
<Timeline
|
|
74
|
+
items={[
|
|
75
|
+
{ title: 'Archived entry', onClick: () => openDetail(), disabled: true },
|
|
76
|
+
]}
|
|
77
|
+
/>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**TimelineItem:**
|
|
81
|
+
|
|
82
|
+
| Field | Type | Description |
|
|
83
|
+
|-------|------|-------------|
|
|
84
|
+
| `id` | `string \| number` | Stable identity used as the entry's React key. Falls back to its array index when omitted; pass one whenever `items` can be reordered or have entries prepended (e.g. a live "newest first" audit log) |
|
|
85
|
+
| `title` | `ReactNode` | Primary label for the entry |
|
|
86
|
+
| `description` | `ReactNode` | Secondary line under the title |
|
|
87
|
+
| `timestamp` | `ReactNode` | Rendered next to the title, e.g. a date or relative time ("2 hours ago") |
|
|
88
|
+
| `icon` | `IconDefinition` | FontAwesome icon shown in the marker instead of a plain dot |
|
|
89
|
+
| `status` | `TimelineItemStatus` | Semantic marker colour (default `Default`) |
|
|
90
|
+
| `content` | `ReactNode` | Extra content rendered under the description, e.g. a diff, an attachment, an actor avatar |
|
|
91
|
+
| `onClick` | `(event: MouseEvent<HTMLDivElement>) => void` | Makes the whole entry clickable, rendering it as an accessible button (`role="button"`, focusable, click and Enter both fire it). Omit to render a plain, non-interactive row |
|
|
92
|
+
| `disabled` | `boolean` | Disables the entry: never clickable, dimmed. Only relevant alongside `onClick` |
|
|
93
|
+
|
|
94
|
+
**Key props:**
|
|
95
|
+
|
|
96
|
+
| Prop | Type | Description |
|
|
97
|
+
|------|------|-------------|
|
|
98
|
+
| `items` | `TimelineItem[]` | The entries to render, in display order (typically newest first for an audit log) |
|
|
99
|
+
| `alignment` | `TimelineAlignment` | Layout of entries relative to the connecting line (default `Left`) |
|
|
100
|
+
|
|
101
|
+
**Theming:** these are theme variables (typed on `ThemeVariables`). Set them theme-wide via `ThemeProvider`'s `variables`, or per instance via `style`, without fighting specificity. Each falls back to a built-in default when unset:
|
|
102
|
+
|
|
103
|
+
| Variable | Falls back to |
|
|
104
|
+
|----------|---------------|
|
|
105
|
+
| `--timeline-dot-size` | `14px` |
|
|
106
|
+
| `--timeline-dot-color` | `var(--primary-color)` |
|
|
107
|
+
| `--timeline-dot-border` | `var(--background)` |
|
|
108
|
+
| `--timeline-line-color` | `var(--border-color)` |
|
|
109
|
+
| `--timeline-line-thickness` | `2px` |
|
|
110
|
+
| `--timeline-gap` | `16px` (gap between marker column and content) |
|
|
111
|
+
| `--timeline-item-gap` | `20px` (vertical gap between entries) |
|
|
112
|
+
| `--timeline-icon-dot-size` | `28px` (marker size when an entry has `icon`) |
|
|
113
|
+
|
|
114
|
+
`TimelineItemStatus` values other than `Default` resolve directly to the matching theme colour (`--primary-color`, `--success-color`, `--warn-color`, `--error-color`) rather than a dedicated `--timeline-*` variable, so they always match the rest of the app's semantic colours.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
// Theme-wide, via ThemeProvider: thicker line, larger dots
|
|
118
|
+
const theme: Theme = {
|
|
119
|
+
id: 'brand',
|
|
120
|
+
variables: {
|
|
121
|
+
'--timeline-line-thickness': '3px',
|
|
122
|
+
'--timeline-dot-size': '18px',
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Slots:** `root` `item` `marker` `dot` `connector` `content` `title` `description` `timestamp`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahrowe/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"build:mcp": "vite build --config vite.mcp.config.ts",
|
|
56
56
|
"preview": "vite preview",
|
|
57
57
|
"gen-barrel": "tsx scripts/gen-barrel.ts",
|
|
58
|
-
"gc": "bash src/scripts/generateComponent.sh
|
|
58
|
+
"gc": "bash src/scripts/generateComponent.sh",
|
|
59
59
|
"changeset": "changeset",
|
|
60
60
|
"lint": "eslint .",
|
|
61
61
|
"lint:fix": "eslint . --fix",
|
|
@@ -84,7 +84,6 @@
|
|
|
84
84
|
"@mona-health/react-input-mask": "^3.0.3",
|
|
85
85
|
"classnames": "^2.5.1",
|
|
86
86
|
"downshift": "^9.3.3",
|
|
87
|
-
"prop-types": "^15.8.1",
|
|
88
87
|
"react-number-format": "^5.4.5",
|
|
89
88
|
"zod": "^4.4.3"
|
|
90
89
|
},
|
|
@@ -101,7 +100,6 @@
|
|
|
101
100
|
"@types/node": "^25.9.1",
|
|
102
101
|
"@types/react": "^19.2.15",
|
|
103
102
|
"@types/react-dom": "^19.2.3",
|
|
104
|
-
"@types/react-helmet": "^6.1.11",
|
|
105
103
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
106
104
|
"@vitejs/plugin-react": "^6.0.2",
|
|
107
105
|
"@vitest/ui": "^4.1.7",
|