@iankibetsh/shframework 5.7.9 → 5.8.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/README.md CHANGED
@@ -1,12 +1,137 @@
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
+ callback: (selectedRecords) => {
49
+ // Handle action, e.g., send IDs to backend
50
+ const ids = selectedRecords.map(r => r.id);
51
+ console.log('Selected IDs:', ids);
52
+ }
53
+ }
54
+ ]"
55
+ />
56
+ ```
57
+
58
+ ### 2. ShAutoForm
59
+
60
+ The flagship component for generating complex forms from simple configurations.
61
+
62
+ - **Auto-Detection**: Infers input types from field names (email, phone, date, etc.).
63
+ - **Multi-Step Support**: Break long forms into logical steps with progress indicators.
64
+ - **Validation**: Seamlessly handles and displays Laravel validation errors (422).
65
+ - **GraphQL Support**: Integrate with GraphQL mutations via the `gqlMutation` prop.
66
+
67
+ ```html
68
+ <sh-auto-form
69
+ :fields="['name', 'email', 'password', 'gender']"
70
+ :required="['name', 'email']"
71
+ action="auth/register"
72
+ :successCallback="onRegistered"
73
+ />
74
+ ```
75
+
76
+ ### 3. ShForm
77
+
78
+ The underlying engine for `ShAutoForm`, used for more granular control over form layouts and field types.
79
+
80
+ ### 4. ShModalForm
81
+
82
+ A convenience component that wraps a trigger button, a Bootstrap modal, and an `ShForm` into one.
83
+
84
+ ```html
85
+ <sh-modal-form
86
+ modal-id="addTaskModal"
87
+ modal-title="Create New Task"
88
+ :fields="['title', 'description']"
89
+ action="tasks/store"
90
+ >
91
+ Add Task
92
+ </sh-modal-form>
93
+ ```
94
+
95
+ ---
96
+
97
+ ## 🏗 Helpers & Utilities
98
+
99
+ ### shApis
100
+
101
+ A thin wrapper around Axios for making API requests. It uses `VITE_APP_API_URL` from your `.env` as the base.
102
+
103
+ - `shApis.doGet(endpoint, params)`
104
+ - `shApis.doPost(endpoint, data)`
105
+
106
+ ### shRepo
107
+
108
+ A collection of common UI and data utilities.
109
+
110
+ - `shRepo.runPlainRequest(url, message)`: Post request with a confirmation prompt.
111
+ - `shRepo.runSilentRequest(url)`: Direct post request without prompt.
112
+ - `shRepo.showToast(message, type)`: Displays a sweetalert2 toast.
113
+ - `shRepo.swalSuccess(message)` / `shRepo.swalError(message)`: Standard success/error popups.
114
+
115
+ ### shUser (State Management)
116
+
117
+ Pinia-based store for managing authenticated user state and sessions.
118
+
119
+ ```javascript
120
+ import { useUserStore } from "@iankibetsh/shframework";
121
+ const userStore = useUserStore();
122
+
123
+ userStore.setUser(); // Fetches current user
124
+ userStore.logOut(); // Clears session and local storage
125
+ ```
126
+
127
+ ---
128
+
129
+ ## 📄 Documentation
130
+
131
+ For full details, property lists, and advanced usage, visit our documentation:
132
+
133
+ 👉 [https://frontend-documentation.pages.dev/](https://frontend-documentation.pages.dev/)
134
+
135
+ ## License
11
136
 
12
- https://frontend-documentation.pages.dev/
137
+ MIT
@@ -1,4 +1,36 @@
1
1
 
2
+ .sh-phone{
3
+ display: flex;
4
+ width: 100%;
5
+ align-items: center;
6
+ padding: 0 0.25rem;
7
+ }
8
+ .phone-country{
9
+ width: 2rem;
10
+ border: none;
11
+ align-self: center;
12
+ outline: none !important;
13
+ padding: 0.4rem;
14
+ border-right: 1px solid #0003;
15
+ }
16
+ .phone-number{
17
+ width: calc(100% - 2.2rem);
18
+ border: none;
19
+ align-self: center;
20
+ outline: none;
21
+ margin-bottom: 0;
22
+ padding: 0.4rem;
23
+ }
24
+ .sh-phone img{
25
+ padding: 0.125rem;
26
+ width: 2rem;
27
+ height: 2rem;
28
+ }
29
+ .phone-number::placeholder{
30
+ font-weight: 300;
31
+ opacity: 0.5;
32
+ }
33
+
2
34
  /* Step Container */
3
35
  .sh-form-steps-container {
4
36
  margin-bottom: 2.5rem;
@@ -260,38 +292,6 @@
260
292
  }
261
293
  }
262
294
 
263
- .sh-phone{
264
- display: flex;
265
- width: 100%;
266
- align-items: center;
267
- padding: 0 0.25rem;
268
- }
269
- .phone-country{
270
- width: 2rem;
271
- border: none;
272
- align-self: center;
273
- outline: none !important;
274
- padding: 0.4rem;
275
- border-right: 1px solid #0003;
276
- }
277
- .phone-number{
278
- width: calc(100% - 2.2rem);
279
- border: none;
280
- align-self: center;
281
- outline: none;
282
- margin-bottom: 0;
283
- padding: 0.4rem;
284
- }
285
- .sh-phone img{
286
- padding: 0.125rem;
287
- width: 2rem;
288
- height: 2rem;
289
- }
290
- .phone-number::placeholder{
291
- font-weight: 300;
292
- opacity: 0.5;
293
- }
294
-
295
295
  .colored-toast.swal2-icon-success {
296
296
  background-color: #a5dc86 !important;
297
297
  }
@@ -324,6 +324,31 @@
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
+
336
+ .sh-selected-item{
337
+ line-height: unset!important;
338
+ }
339
+ .sh-suggestion-input{
340
+ padding: 0.375rem 0.75rem;
341
+ }
342
+ .sh-suggest{
343
+ margin-bottom: 1rem;
344
+ padding: 0rem 0rem;
345
+ }
346
+ .sh-suggest-control::after{
347
+ margin-top: auto;
348
+ margin-bottom: auto;
349
+ margin-right: 0.255em;
350
+ }
351
+
327
352
  .permissions-main {
328
353
  background: #edeff2;
329
354
  }
@@ -356,22 +381,6 @@
356
381
  flex-grow: 1;
357
382
  }
358
383
 
359
- .sh-selected-item{
360
- line-height: unset!important;
361
- }
362
- .sh-suggestion-input{
363
- padding: 0.375rem 0.75rem;
364
- }
365
- .sh-suggest{
366
- margin-bottom: 1rem;
367
- padding: 0rem 0rem;
368
- }
369
- .sh-suggest-control::after{
370
- margin-top: auto;
371
- margin-bottom: auto;
372
- margin-right: 0.255em;
373
- }
374
-
375
384
  .callout{
376
385
  --bs-link-color-rgb: 110,168,254;
377
386
  --bs-code-color: #e685b5;