@innertia-solutions/innertia-nuxt 0.1.12 → 0.1.13

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.
Files changed (51) hide show
  1. package/components/Attention.vue +269 -0
  2. package/components/Chart/index.vue +193 -0
  3. package/components/Container.vue +116 -0
  4. package/components/CopyButton.vue +98 -0
  5. package/components/Files/Card.vue +215 -0
  6. package/components/Files/Preview.vue +675 -0
  7. package/components/Files/Upload.vue +408 -0
  8. package/components/Files/UploadModal.vue +83 -0
  9. package/components/Forms/InputPin.vue +162 -0
  10. package/components/InfoToolbar.vue +54 -0
  11. package/components/Kanban/Standard.vue +588 -0
  12. package/components/Loader.vue +358 -0
  13. package/components/Modal/Base.vue +6 -0
  14. package/components/Modal/Confirm.vue +89 -0
  15. package/components/Modal/DeleteConfirm.vue +14 -31
  16. package/components/Modal/Form.vue +76 -0
  17. package/components/Modal/Host.vue +58 -0
  18. package/components/Modal/Prompt.vue +74 -0
  19. package/components/Modal.vue +119 -34
  20. package/components/Table/Standard.vue +198 -25
  21. package/components/Table/index.vue +169 -369
  22. package/components/Table/views/ViewCards.vue +74 -0
  23. package/components/Table/views/ViewDatabase.vue +236 -0
  24. package/components/Table/views/ViewTable.vue +299 -0
  25. package/components/Toast/Alert.vue +16 -111
  26. package/components/Toast/Container.vue +4 -29
  27. package/components/Toast/Notification.vue +8 -43
  28. package/components/Toast/Process.vue +8 -86
  29. package/components/Toast/Stack.vue +59 -0
  30. package/components/Toast/Standard.vue +115 -0
  31. package/components/Tree/Standard.vue +49 -4
  32. package/components/Workflow/Board.vue +356 -0
  33. package/components/Workflow/Builder.vue +454 -0
  34. package/components/Workflow/Form.vue +526 -0
  35. package/components/Workflow/Viewer.vue +225 -0
  36. package/components/Workflow/edges/TransitionEdge.vue +84 -0
  37. package/components/Workflow/nodes/StepNode.vue +88 -0
  38. package/composables/useClipboard.js +79 -0
  39. package/composables/useConfetti.js +194 -0
  40. package/composables/useFile.js +189 -0
  41. package/composables/useModal.js +71 -0
  42. package/composables/useToast.js +38 -65
  43. package/composables/useWorkflow/form.js +162 -0
  44. package/composables/useWorkflow/index.js +18 -0
  45. package/composables/useWorkflow/view.js +220 -0
  46. package/composables/useWorkflowLayout.js +162 -0
  47. package/css/tokens.css +10 -10
  48. package/nuxt.config.ts +1 -1
  49. package/package.json +13 -8
  50. package/stores/modal.js +48 -0
  51. package/stores/toast.js +156 -117
package/stores/toast.js CHANGED
@@ -1,129 +1,168 @@
1
1
  // stores/toast.js
2
2
  import { defineStore } from 'pinia'
3
- import { v4 as uuid } from 'uuid'
3
+ import { markRaw } from 'vue'
4
4
 
5
- const toastConfig = {
6
- severity: 'info',
7
- title: null,
8
- message: null,
9
- duration: 5000,
10
- progress: true,
11
- position: 'top-right',
12
- icon: null,
5
+ /**
6
+ * Store unificado de toasts. Soporta tres variants:
7
+ *
8
+ * - 'alert' → toast simple con severity + título opcional + mensaje
9
+ * - 'notification' → más prominente, soporta acción y no auto-dismiss
10
+ * - 'process' → con barra de progreso, no auto-dismiss
11
+ *
12
+ * Y 6 posiciones: top-left|center|right · bottom-left|center|right
13
+ *
14
+ * Action opcional para cualquier variant:
15
+ * action: { label: 'Deshacer', onClick: () => { ... } }
16
+ */
17
+
18
+ const POSITIONS = ['top-left','top-center','top-right','bottom-left','bottom-center','bottom-right']
19
+ const SEVERITIES = ['success','error','warning','info']
20
+
21
+ const DEFAULTS = {
22
+ variant: 'alert',
23
+ severity: 'info',
24
+ position: 'top-right',
25
+ duration: 5000,
26
+ closable: true,
27
+ }
28
+
29
+ let _id = 0
30
+ const nextId = () => `t${++_id}`
31
+
32
+ function normalize(input, override = {}) {
33
+ const cfg = typeof input === 'string' ? { message: input } : { ...input }
34
+ const merged = { ...DEFAULTS, ...cfg, ...override }
35
+ if (!POSITIONS.includes(merged.position)) merged.position = 'top-right'
36
+ if (merged.action && typeof merged.action.onClick === 'function') {
37
+ // Pinia evita reactivear funciones — markRaw el objeto
38
+ merged.action = markRaw(merged.action)
39
+ }
40
+ return { ...merged, id: nextId(), createdAt: Date.now() }
13
41
  }
14
42
 
15
43
  export const useToastStore = defineStore('toast', {
16
- state: () => ({
17
- toasts: {
18
- 'top-left': [],
19
- 'top-center': [],
20
- 'top-right': [],
21
- 'bottom-left': [],
22
- 'bottom-center': [],
23
- 'bottom-right': [],
24
- },
25
- timeouts: {}, // id → timeoutId (plain object, JSON-safe)
26
- }),
27
- actions: {
28
- success(config) {
29
- const normalizedConfig = typeof config === 'string' ? { message: config } : config
30
- const toast = {
31
- ...toastConfig,
32
- id: uuid(),
33
- severity: 'success',
34
- icon: 'ti ti-circle-check text-green-500',
35
- position: 'top-center',
36
- ...normalizedConfig,
37
- }
38
- this.toasts[toast.position].push(toast)
39
- this._scheduleRemoval(toast)
40
- },
41
- info(config) {
42
- const normalizedConfig = typeof config === 'string' ? { message: config } : config
43
- const toast = {
44
- ...toastConfig,
45
- id: uuid(),
46
- severity: 'info',
47
- icon: 'ti ti-info-circle',
48
- title: 'Info',
49
- position: 'top-right',
50
- ...normalizedConfig,
51
- }
52
- this.toasts[toast.position].push(toast)
53
- this._scheduleRemoval(toast)
54
- },
55
- error(config) {
56
- const normalizedConfig = typeof config === 'string' ? { message: config } : config
57
- const toast = {
58
- ...toastConfig,
59
- id: uuid(),
60
- severity: 'danger',
61
- icon: 'ti ti-exclamation-circle',
62
- title: 'Atención',
63
- position: 'top-right',
64
- ...normalizedConfig,
65
- }
66
- this.toasts[toast.position].push(toast)
67
- this._scheduleRemoval(toast)
68
- },
69
- show(config) {
70
- const toast = {
71
- id: uuid(),
72
- severity: 'info',
73
- position: 'top-right',
74
- ...toastConfig,
75
- ...config,
76
- }
77
- this.toasts[toast.position].push(toast)
78
- this._scheduleRemoval(toast)
79
- },
80
- update(id, data) {
81
- for (const key in this.toasts) {
82
- const idx = this.toasts[key].findIndex(t => t.id === id)
83
- if (idx !== -1) {
84
- this.toasts[key][idx] = { ...this.toasts[key][idx], ...data }
85
- break
86
- }
87
- }
88
- },
89
- remove(id) {
90
- if (this.timeouts[id] !== undefined) {
91
- clearTimeout(this.timeouts[id])
92
- delete this.timeouts[id]
93
- }
44
+ state: () => ({
45
+ toasts: Object.fromEntries(POSITIONS.map(p => [p, []])),
46
+ timeouts: {},
47
+ }),
48
+ getters: {
49
+ flat(state) {
50
+ return POSITIONS.flatMap(p => state.toasts[p])
51
+ },
52
+ },
53
+ actions: {
54
+ _push(toast) {
55
+ this.toasts[toast.position].push(toast)
56
+ this._scheduleRemoval(toast)
57
+ return toast.id
58
+ },
59
+ _scheduleRemoval(toast) {
60
+ if (!toast.duration || toast.duration <= 0) return
61
+ const tid = setTimeout(() => this.dismiss(toast.id), toast.duration)
62
+ this.timeouts[toast.id] = tid
63
+ },
64
+
65
+ // ── API pública ──────────────────────────────────────────────────
66
+ show(config) {
67
+ return this._push(normalize(config))
68
+ },
69
+ success(input, config = {}) {
70
+ return this._push(normalize(input, { ...config, severity: 'success' }))
71
+ },
72
+ error(input, config = {}) {
73
+ return this._push(normalize(input, { ...config, severity: 'error', duration: config.duration ?? 7000 }))
74
+ },
75
+ warning(input, config = {}) {
76
+ return this._push(normalize(input, { ...config, severity: 'warning' }))
77
+ },
78
+ info(input, config = {}) {
79
+ return this._push(normalize(input, { ...config, severity: 'info' }))
80
+ },
94
81
 
95
- for (const key in this.toasts) {
96
- this.toasts[key] = this.toasts[key].filter(t => t.id !== id)
97
- }
98
- },
99
- _scheduleRemoval(toast) {
100
- if (toast.duration && toast.duration > 0) {
101
- const timeoutId = setTimeout(() => {
102
- this.remove(toast.id)
103
- }, toast.duration)
82
+ /** Notification — variant prominente, NO auto-dismiss por defecto. */
83
+ notify(config = {}) {
84
+ return this._push(normalize({ ...config, variant: 'notification', duration: config.duration ?? 0 }))
85
+ },
104
86
 
105
- this.timeouts[toast.id] = timeoutId
106
- }
107
- },
87
+ /** Process — toast con barra de progreso. Devuelve id para actualizar. */
88
+ process(title, config = {}) {
89
+ return this._push(normalize({
90
+ ...config,
91
+ variant: 'process',
92
+ title,
93
+ progress: 0,
94
+ progressLabel: config.progressLabel ?? 'Iniciando…',
95
+ duration: 0,
96
+ closable: config.closable ?? false,
97
+ }))
98
+ },
108
99
 
109
- // Método específico para actualizar progreso de un toast tipo process
110
- updateProgress(id, progress, progressLabel = null) {
111
- const updateData = { progress }
112
- if (progressLabel) {
113
- updateData.progressLabel = progressLabel
114
- }
115
- this.update(id, updateData)
116
- },
100
+ update(id, patch) {
101
+ for (const p of POSITIONS) {
102
+ const idx = this.toasts[p].findIndex(t => t.id === id)
103
+ if (idx !== -1) {
104
+ this.toasts[p][idx] = { ...this.toasts[p][idx], ...patch }
105
+ return
106
+ }
107
+ }
108
+ },
109
+ updateProgress(id, progress, progressLabel) {
110
+ const patch = { progress: Math.min(100, Math.max(0, progress)) }
111
+ if (progressLabel != null) patch.progressLabel = progressLabel
112
+ this.update(id, patch)
113
+ },
114
+ completeProcess(id, message = 'Completado') {
115
+ this.update(id, {
116
+ progress: 100,
117
+ progressLabel: message,
118
+ severity: 'success',
119
+ closable: true,
120
+ })
121
+ // Auto-dismiss después de 2.5s
122
+ const tid = setTimeout(() => this.dismiss(id), 2500)
123
+ this.timeouts[id] = tid
124
+ },
125
+ failProcess(id, message = 'Error') {
126
+ this.update(id, {
127
+ progressLabel: message,
128
+ severity: 'error',
129
+ closable: true,
130
+ duration: 7000,
131
+ })
132
+ const tid = setTimeout(() => this.dismiss(id), 7000)
133
+ this.timeouts[id] = tid
134
+ },
117
135
 
118
- // Método para completar un proceso
119
- completeProcess(id, message = 'Completado') {
120
- this.update(id, {
121
- progress: 100,
122
- progressLabel: message,
123
- duration: 3000, // Auto-remove después de completar
124
- })
125
- // Programar removal para el proceso completado
126
- this._scheduleRemoval({ id, duration: 3000 })
127
- },
136
+ dismiss(id) {
137
+ if (this.timeouts[id] != null) {
138
+ clearTimeout(this.timeouts[id])
139
+ delete this.timeouts[id]
140
+ }
141
+ for (const p of POSITIONS) {
142
+ const idx = this.toasts[p].findIndex(t => t.id === id)
143
+ if (idx !== -1) {
144
+ this.toasts[p].splice(idx, 1)
145
+ return
146
+ }
147
+ }
128
148
  },
149
+ clear(position) {
150
+ if (position && this.toasts[position]) {
151
+ for (const t of this.toasts[position]) {
152
+ if (this.timeouts[t.id]) { clearTimeout(this.timeouts[t.id]); delete this.timeouts[t.id] }
153
+ }
154
+ this.toasts[position] = []
155
+ } else {
156
+ for (const p of POSITIONS) {
157
+ for (const t of this.toasts[p]) {
158
+ if (this.timeouts[t.id]) { clearTimeout(this.timeouts[t.id]); delete this.timeouts[t.id] }
159
+ }
160
+ this.toasts[p] = []
161
+ }
162
+ }
163
+ },
164
+
165
+ // ── Compat (deprecated) ────────────────────────────────────────
166
+ remove(id) { this.dismiss(id) },
167
+ },
129
168
  })