@stsdti/auditing-vue 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +197 -2
- package/dist/auditing-vue.mjs +2278 -0
- package/dist/auditing-vue.mjs.map +1 -0
- package/package.json +68 -4
- package/scripts/vendor-funky-styles.mjs +135 -0
- package/src/components/audit/AuditChanges.vue +181 -0
- package/src/components/audit/AuditChangesDialog.vue +106 -0
- package/src/components/audit/AuditEventBadge.vue +51 -0
- package/src/components/audit/AuditFilterSelect.vue +303 -0
- package/src/components/audit/AuditFilters.vue +164 -0
- package/src/components/audit/AuditHistory.vue +133 -0
- package/src/components/audit/AuditHistoryButton.vue +99 -0
- package/src/components/audit/AuditTable.vue +622 -0
- package/src/components/audit/AuditTimeline.vue +311 -0
- package/src/components/ui/UiDialog.vue +166 -0
- package/src/components/ui/UiLoadingBlur.vue +29 -0
- package/src/index.js +61 -0
- package/src/shared.js +95 -0
- package/src/styles/base.css +104 -0
- package/src/styles/generated/style-nova.css +256 -0
- package/src/styles/generated/style-rhea.css +256 -0
- package/src/styles/generated/tokens.css +288 -0
- package/src/styles/nova.css +8 -0
- package/src/styles/rhea.css +8 -0
- package/src/themes/nova.css +2 -0
- package/src/themes/rhea.css +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 STSDTI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,198 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @stsdti/auditing-vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vue 3 components for [laravel-auditing](../../../README.md): the audit log, filters, a record's history and
|
|
4
|
+
the change diff — on the same design system as [funky-ui-kit](../../../../funky-ui-kit) 3.0: its tokens, its Nova and
|
|
5
|
+
Rhea styles, the radius canon (`rounded-surface` / `rounded-control` / `rounded-item`), `focus-ring` and Lucide icons
|
|
6
|
+
(`@lucide/vue`). The styles are compiled in the package and scoped, so the application needs no Tailwind and no
|
|
7
|
+
funky-ui-kit; inside a funky app the components take the app's tokens and look like its own.
|
|
8
|
+
|
|
9
|
+
UI only: the components make no requests. The application loads audits and hands them in through `load`
|
|
10
|
+
functions. Behaviour lives in [@stsdti/auditing-core](../core/README.md); this package renders it.
|
|
11
|
+
The documentation (`examples/vue`, `npm run dev` at the repository root) shows every component, prop,
|
|
12
|
+
slot and state.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @stsdti/auditing-vue
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import AuditingVue from '@stsdti/auditing-vue'
|
|
22
|
+
import '@stsdti/auditing-vue/themes/nova.css' // or rhea.css: the same style as the app's funky-ui-kit
|
|
23
|
+
|
|
24
|
+
app.use(AuditingVue, {
|
|
25
|
+
messages: { title: 'Jurnal' } // optional: labels are Romanian; any subset overrides
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`app.use` registers the components globally; `register: false` only applies the messages, for
|
|
30
|
+
applications that import components where they use them.
|
|
31
|
+
|
|
32
|
+
## Loading data
|
|
33
|
+
|
|
34
|
+
| function | used by | |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| `({ filters, page, perPage, signal }) => Promise<{ rows, total }>` | `AuditTable` `load` | one page, newest first |
|
|
37
|
+
| `({ auditableType, auditableId, batch, signal }) => Promise<audit[]>` | `AuditHistory` / `AuditHistoryButton` `load` | a record's audits, or one action's |
|
|
38
|
+
| `(query, { signal }) => Promise<user[]>` | `search-users` | the user filter (hidden without it) |
|
|
39
|
+
| `(query, { signal }) => Promise<type[]>` | `search-resources` | the resource filter |
|
|
40
|
+
|
|
41
|
+
Throw on failure and the component shows its error state. `toParams(filters)` turns the filters into query
|
|
42
|
+
parameters (`event[]`, `user[]`, `auditable_type[]`, `start_date`, `end_date`, `search`).
|
|
43
|
+
|
|
44
|
+
## Components
|
|
45
|
+
|
|
46
|
+
| component | what it is |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `AuditTable` | the log: search (sent on Enter or Aplică), Filtre drawer + Aplică, result count and chips, loading blur, empty / error states, pagination, change dialog |
|
|
49
|
+
| `AuditFilters` | the filter form (event, user, resource, period, search) — `v-model` an `emptyFilters()` object |
|
|
50
|
+
| `AuditFilterSelect` | multi-select combobox: fixed `options` or an async `search` |
|
|
51
|
+
| `AuditHistory` | one record's history (`auditable-type` + `auditable-id`) or one action's (`batch`), through your `load` |
|
|
52
|
+
| `AuditHistoryButton` | a button opening `AuditHistory` in a dialog — for any form |
|
|
53
|
+
| `AuditTimeline` | a timeline in a Card: give it audits; marks batches, highlights one |
|
|
54
|
+
| `AuditChanges` | Câmp / Valoare veche / Valoare nouă in a Table (`layout="table"`, default), or `field: old → new` as a list (`layout="list"`) |
|
|
55
|
+
| `AuditChangesDialog` | one audit in full, with url / ip / user agent / batch |
|
|
56
|
+
| `AuditEventBadge` | tinted badge per event; your own events render neutral |
|
|
57
|
+
|
|
58
|
+
### AuditTable
|
|
59
|
+
|
|
60
|
+
```vue
|
|
61
|
+
<audit-table
|
|
62
|
+
:load="loadAudits"
|
|
63
|
+
:search-users="searchUsers"
|
|
64
|
+
persistence-key="admin-audit"
|
|
65
|
+
:type-label="(type) => labels[type] ?? type"
|
|
66
|
+
:field-label="(field) => columns[field] ?? field"
|
|
67
|
+
>
|
|
68
|
+
<template #row-actions="{ audit }">
|
|
69
|
+
<audit-history-button :auditable-type="audit.auditable_type" :auditable-id="audit.auditable_id" :highlight="audit.id" :load="loadHistory" icon-only />
|
|
70
|
+
</template>
|
|
71
|
+
</audit-table>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
| prop | default | |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `load` | required | `({ filters, page, perPage, signal }) => Promise<{ rows, total }>`; throw to show the error state |
|
|
77
|
+
| `search-users` | `null` | `(query, { signal }) => Promise<user[]>`; hides the user filter when null |
|
|
78
|
+
| `search-resources` / `resources` | `null` / `[]` | async or fixed resource options |
|
|
79
|
+
| `events` | built-in | event codes of the event filter |
|
|
80
|
+
| `initial-filters` | `null` | starting filters |
|
|
81
|
+
| `type-label` / `field-label` / `format-value` | short class name / identity / `formatValue` | how types, columns and values read |
|
|
82
|
+
| `user-label` | `'name'` | author text |
|
|
83
|
+
| `title` / `description` | messages | `description=""` hides it |
|
|
84
|
+
| `per-page-options` / `changes-limit` | `[10, 25, 50]` / `3` | |
|
|
85
|
+
| `persistence-key` | `null` | remember filters and page size in localStorage |
|
|
86
|
+
| `show-header` / `show-toolbar` / `show-filters` | `true` | |
|
|
87
|
+
| `messages` | plugin / defaults | per-instance overrides |
|
|
88
|
+
|
|
89
|
+
`ui`: classes per part, merged with `cn()` as on funky's components: `root`, `card`, `header`, `toolbar`,
|
|
90
|
+
`chips`, `table`, `row`, `footer`, `loading` (`{ root, label, content }`), `drawer` and `dialog` (`{ overlay, content,
|
|
91
|
+
header, title, description, body, footer, close }`).
|
|
92
|
+
|
|
93
|
+
Slots: `actions`, `toolbar="{ filters }"`, `row-actions="{ audit, openChanges }"`, `cell-resource` /
|
|
94
|
+
`cell-user="{ audit }"`, `empty="{ reset }"`, `dialog-actions="{ audit }"`.
|
|
95
|
+
Events: `loaded({ rows, total })`, `error(error)`, `update:filters`. Exposed: `refresh()`, `reset()`,
|
|
96
|
+
`openChanges(audit)`, `filters`.
|
|
97
|
+
|
|
98
|
+
Filters reach `load` as `{ search, event: [code], user: [user], auditable_type: [type], start_date, end_date }`
|
|
99
|
+
(`toParams(filters)` from the core turns them into the API's query).
|
|
100
|
+
|
|
101
|
+
### AuditHistory / AuditHistoryButton
|
|
102
|
+
|
|
103
|
+
```vue
|
|
104
|
+
<audit-history auditable-type="App\Models\Personal\Leave" :auditable-id="leave.id" :highlight="$route.query.highlight" />
|
|
105
|
+
<audit-history :batch="audit.batch" order="asc" />
|
|
106
|
+
<audit-history-button auditable-type="App\Models\Personal\Leave" :auditable-id="leave.id" />
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`AuditHistory`: `auditable-type`, `auditable-id`, `batch`, `load` (`({ auditableType, auditableId, batch, signal })
|
|
110
|
+
=> audit[]`), `order` (`desc`), `highlight`, `bare`, `refreshable`, `show-resource` (default: only for a batch),
|
|
111
|
+
`subject` (the badge next to the title; default `Concediu #1` from `type-label` and the id, `false` hides it),
|
|
112
|
+
plus any `AuditTimeline` prop and its `change-value` slot. Events `loaded`, `error`, `expand`; exposes `refresh()`, `audits`.
|
|
113
|
+
|
|
114
|
+
`AuditHistoryButton`: the same, plus `label`, `variant` (`outline`), `size` (`sm`), `icon-only` (just the eye, for a
|
|
115
|
+
table row; the label becomes its tooltip), `count` (a number badge, when you know it), `title`, `description`.
|
|
116
|
+
The history loads when the dialog opens.
|
|
117
|
+
|
|
118
|
+
### AuditTimeline
|
|
119
|
+
|
|
120
|
+
`audits`, `loading`, `error` (bool or message) + `retry`, `highlight`, `group-batches` (`true`),
|
|
121
|
+
`show-resource`, `changes-limit`, `bare`, the label props, `title`, `description`, `subject`.
|
|
122
|
+
Each entry shows the event, how many fields it touched, the author's photo (`user-avatar`, `(user) => url | null`;
|
|
123
|
+
a silhouette without one) and the time.
|
|
124
|
+
Slots `actions`, `empty`, `entry-actions="{ audit }"`, `change-value` (see below); event `expand` (“Vezi toate” also shows the rest in place).
|
|
125
|
+
|
|
126
|
+
### AuditChanges / AuditChangesDialog / AuditEventBadge
|
|
127
|
+
|
|
128
|
+
`AuditChanges`: `value`, `layout` (`table` · `list`), `size` (`default` · `sm`), `limit` (emits `expand`), `max-length`, `field-label`, `format-value(raw, field, audit)`.
|
|
129
|
+
Fields keep the record's order. The `value="{ audit, field, side, value, text }"` slot renders one value
|
|
130
|
+
(`side` is `old` or `new`, `value` the raw one, `text` the formatted one), e.g. a status badge or a link:
|
|
131
|
+
|
|
132
|
+
```vue
|
|
133
|
+
<audit-history :auditable-type="type" :auditable-id="id" :load="load">
|
|
134
|
+
<template #change-value="{ field, value, text }">
|
|
135
|
+
<status-badge v-if="field === 'status'" :status="value" />
|
|
136
|
+
<router-link v-else-if="field === 'employee_id'" :to="`/employees/${value}`">Angajat #{{ value }}</router-link>
|
|
137
|
+
<template v-else>{{ text }}</template>
|
|
138
|
+
</template>
|
|
139
|
+
</audit-history>
|
|
140
|
+
```
|
|
141
|
+
`AuditChangesDialog`: `v-model:open`, `audit`, `show-context`, label props; default and `footer="{ audit }"` slots.
|
|
142
|
+
`AuditEventBadge`: `event`, `label`, `icon`, `icon-only` (the label becomes a tooltip).
|
|
143
|
+
|
|
144
|
+
## Theming
|
|
145
|
+
|
|
146
|
+
Two stylesheets, funky-ui-kit's two styles; import the one your app uses:
|
|
147
|
+
|
|
148
|
+
| | `themes/nova.css` | `themes/rhea.css` |
|
|
149
|
+
|---|---|---|
|
|
150
|
+
| feel | compact, bordered | airy, pill-shaped |
|
|
151
|
+
| `rounded-control` / `rounded-item` | `--radius` / `× 0.8` | `× 1.8` / `× 1.4` |
|
|
152
|
+
| `--surface-padding`, `--layout-gap`, `--form-gap` | 16px, 16px, 12px | 20px, 24px, 16px |
|
|
153
|
+
| `focus-ring` opacity | 50% | 30% |
|
|
154
|
+
|
|
155
|
+
The tokens are funky-ui-kit's (`--background`, `--foreground`, `--card`, `--popover`, `--primary`, `--secondary`,
|
|
156
|
+
`--muted`, `--accent` and their `-foreground`, `--destructive`, `--success`, `--warning`, `--info`, `--border`,
|
|
157
|
+
`--input`, `--ring`, `--radius`, `--font-sans`, `--font-heading`, `--font-mono`) with zero-specificity defaults.
|
|
158
|
+
A funky-ui-kit app already defines them, so the components follow its theme; anywhere else, set the ones to change:
|
|
159
|
+
|
|
160
|
+
```css
|
|
161
|
+
:root {
|
|
162
|
+
--primary: oklch(0.55 0.2 260);
|
|
163
|
+
--radius: 0.5rem;
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Dark mode is a `.dark` class on an ancestor. If the application does not toggle one already:
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
import { setAuditingColorScheme } from '@stsdti/auditing-vue'
|
|
171
|
+
setAuditingColorScheme(isDark ? 'dark' : 'light')
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The stylesheets have no preflight and emit every rule under `.laravel-auditing`, so an application's
|
|
175
|
+
`.badge`, `.table` or Bootstrap rules are never touched. The cascade is kept without layers: cn-* rules
|
|
176
|
+
are emitted as `.laravel-auditing :where(.cn-x)`, so — as with Tailwind's `components` / `utilities` layers —
|
|
177
|
+
a utility always wins over a component rule, and both win over the host's element rules. Dialogs and the drawer
|
|
178
|
+
teleport to `<body>` in their own root.
|
|
179
|
+
|
|
180
|
+
## Developing
|
|
181
|
+
|
|
182
|
+
The components follow funky-ui-kit's [AGENTS.md](../../../../funky-ui-kit/AGENTS.md) rules: `<script setup>`,
|
|
183
|
+
`<template>` first, kebab-case tags, object `defineProps` / `const emits`, no comments, `cn()` for overridable
|
|
184
|
+
classes, semantic tokens and the radius canon only, `focus-ring`, Lucide icons with `aria-hidden`, a `ui` prop on
|
|
185
|
+
multi-part components, `type="button"` on non-submit buttons, reduced motion respected.
|
|
186
|
+
|
|
187
|
+
- `src/styles/generated/` is vendored from funky-ui-kit by `npm run vendor:styles` (tokens, the Nova and Rhea
|
|
188
|
+
`cn-*` rules the components use, `status.css`, `surface.css`). Don't edit it by hand: after a funky-ui-kit
|
|
189
|
+
update, or when a component starts using another `cn-*` class, run the script and review the diff. It reads
|
|
190
|
+
`node_modules/@stsdti/funky-ui-kit/dist/styles`, else a sibling `funky-ui-kit/src/styles` checkout; `--from <dir>`
|
|
191
|
+
or `FUNKY_UI_KIT_STYLES` points it elsewhere.
|
|
192
|
+
- `src/styles/nova.css` / `rhea.css` are the entries (`base.css` holds the scoped reset); `npm run build:theme`
|
|
193
|
+
compiles them into `src/themes/`, scanning `src/components` and `src/shared.js` (`npm run dev` at the repository
|
|
194
|
+
root watches both).
|
|
195
|
+
- `src/shared.js` holds what the components share: the messages, `cn()`, the event icons, shadcn's recipes and
|
|
196
|
+
Button / Badge; `src/components/ui/` the larger internal pieces (dialog / drawer, loading blur).
|
|
197
|
+
- At the repository root, `npm test` runs ESLint (funky's `@antfu/eslint-config` setup) and `check:legacy`
|
|
198
|
+
(funky's guard: raw palette colours, fixed radii, px arbitrary values, off-canon focus rings, `!important`).
|