@iankibetsh/shframework 5.7.9 → 5.8.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 CHANGED
@@ -1,12 +1,138 @@
1
- # Installation
1
+ # SH Framework (@iankibetsh/shframework)
2
2
 
3
- Install this package in your existing or freshly installed vue 3 framework
4
- using vite
3
+ [![npm version](https://img.shields.io/npm/v/@iankibetsh/shframework.svg)](https://www.npmjs.com/package/@iankibetsh/shframework)
4
+
5
+ A powerful Vue 3 library for rapid application development, specifically designed to integrate seamlessly with Laravel-based backends.
6
+
7
+ ## 🚀 Installation
8
+
9
+ Install the package using npm:
5
10
 
6
11
  ```shell
7
12
  npm install @iankibetsh/shframework
8
13
  ```
9
14
 
10
- Read more here
15
+ ## 🛠 Core Components
16
+
17
+ ### 1. ShTable
18
+
19
+ A robust table component that handles server-side pagination, searching, and custom formatting.
20
+
21
+ - **Nested Key Support**: Access nested properties using dot notation (e.g., `user.name`).
22
+ - **Auto-Label Generation**: Automatically generates human-readable labels from keys if not explicitly provided (e.g., `user.first_name` becomes "First Name").
23
+ - **Named Slots for Custom Formatting**: Use named slots for columns to provide custom formatting (e.g., `<template #age="{ row }">`).
24
+ - **Multi-Action Support**: Enable row selection and collective operations with a floating action bar.
25
+ - **Links & Actions**: Easily define column links and action buttons.
26
+
27
+ ```html
28
+ <sh-table :headers="['id', 'user.name', 'email']" end-point="users/list">
29
+ <template #user.name="{ row }">
30
+ <strong>{{ row.user.name }}</strong>
31
+ </template>
32
+ </sh-table>
33
+ ```
34
+
35
+ ### Multi-Action Support
36
+
37
+ Enable multi-row selection and perform collective actions by passing the `multi-actions` prop.
38
+
39
+ ```html
40
+ <sh-table
41
+ :headers="['id', 'name']"
42
+ end-point="users/list"
43
+ :multi-actions="[
44
+ {
45
+ label: 'Delete Selected',
46
+ class: 'btn-outline-danger',
47
+ icon: 'bi-trash',
48
+ permission: 'delete_users',
49
+ callback: (selectedRecords) => {
50
+ // Handle action, e.g., send IDs to backend
51
+ const ids = selectedRecords.map(r => r.id);
52
+ console.log('Selected IDs:', ids);
53
+ }
54
+ }
55
+ ]"
56
+ />
57
+ ```
58
+
59
+ ### 2. ShAutoForm
60
+
61
+ The flagship component for generating complex forms from simple configurations.
62
+
63
+ - **Auto-Detection**: Infers input types from field names (email, phone, date, etc.).
64
+ - **Multi-Step Support**: Break long forms into logical steps with progress indicators.
65
+ - **Validation**: Seamlessly handles and displays Laravel validation errors (422).
66
+ - **GraphQL Support**: Integrate with GraphQL mutations via the `gqlMutation` prop.
67
+
68
+ ```html
69
+ <sh-auto-form
70
+ :fields="['name', 'email', 'password', 'gender']"
71
+ :required="['name', 'email']"
72
+ action="auth/register"
73
+ :successCallback="onRegistered"
74
+ />
75
+ ```
76
+
77
+ ### 3. ShForm
78
+
79
+ The underlying engine for `ShAutoForm`, used for more granular control over form layouts and field types.
80
+
81
+ ### 4. ShModalForm
82
+
83
+ A convenience component that wraps a trigger button, a Bootstrap modal, and an `ShForm` into one.
84
+
85
+ ```html
86
+ <sh-modal-form
87
+ modal-id="addTaskModal"
88
+ modal-title="Create New Task"
89
+ :fields="['title', 'description']"
90
+ action="tasks/store"
91
+ >
92
+ Add Task
93
+ </sh-modal-form>
94
+ ```
95
+
96
+ ---
97
+
98
+ ## 🏗 Helpers & Utilities
99
+
100
+ ### shApis
101
+
102
+ A thin wrapper around Axios for making API requests. It uses `VITE_APP_API_URL` from your `.env` as the base.
103
+
104
+ - `shApis.doGet(endpoint, params)`
105
+ - `shApis.doPost(endpoint, data)`
106
+
107
+ ### shRepo
108
+
109
+ A collection of common UI and data utilities.
110
+
111
+ - `shRepo.runPlainRequest(url, message)`: Post request with a confirmation prompt.
112
+ - `shRepo.runSilentRequest(url)`: Direct post request without prompt.
113
+ - `shRepo.showToast(message, type)`: Displays a sweetalert2 toast.
114
+ - `shRepo.swalSuccess(message)` / `shRepo.swalError(message)`: Standard success/error popups.
115
+
116
+ ### shUser (State Management)
117
+
118
+ Pinia-based store for managing authenticated user state and sessions.
119
+
120
+ ```javascript
121
+ import { useUserStore } from "@iankibetsh/shframework";
122
+ const userStore = useUserStore();
123
+
124
+ userStore.setUser(); // Fetches current user
125
+ userStore.logOut(); // Clears session and local storage
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 📄 Documentation
131
+
132
+ For full details, property lists, and advanced usage, visit our documentation:
133
+
134
+ 👉 [https://frontend-documentation.pages.dev/](https://frontend-documentation.pages.dev/)
135
+
136
+ ## License
11
137
 
12
- https://frontend-documentation.pages.dev/
138
+ MIT
@@ -324,6 +324,15 @@
324
324
  color: white;
325
325
  }
326
326
 
327
+ .sh-multi-actions-bar {
328
+ position: fixed;
329
+ bottom: 20px;
330
+ left: 50%;
331
+ transform: translateX(-50%);
332
+ z-index: 1050;
333
+ min-width: 300px;
334
+ }
335
+
327
336
  .permissions-main {
328
337
  background: #edeff2;
329
338
  }