runeforge 0.0.46 → 0.0.47

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.
@@ -40,9 +40,17 @@
40
40
 
41
41
  let fieldErrors = $state<Record<string, string>>({});
42
42
  let internalError = $state('');
43
+ let successMessage = $state('');
44
+ let successTimeout: ReturnType<typeof setTimeout> | undefined;
43
45
  let continueCreating = $state(false);
44
46
  let duplicating = $state(false);
45
47
 
48
+ function flashSuccess() {
49
+ successMessage = strings.saveSuccess;
50
+ clearTimeout(successTimeout);
51
+ successTimeout = setTimeout(() => (successMessage = ''), 4000);
52
+ }
53
+
46
54
  let record = $state<Record<string, unknown>>(untrack(() => emptyRecord(fields)));
47
55
 
48
56
  const groups = $derived(groupFields(fields));
@@ -72,6 +80,15 @@
72
80
  ]}
73
81
  />
74
82
 
83
+ {#if successMessage}
84
+ <div role="alert" class="alert alert-success">
85
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
86
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
87
+ </svg>
88
+ <span class="text-sm">{successMessage}</span>
89
+ </div>
90
+ {/if}
91
+
75
92
  {#if errorEntries.length > 0}
76
93
  <div role="alert" class="alert alert-error">
77
94
  <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
@@ -93,6 +110,8 @@
93
110
  use:enhance={({ formData, cancel }) => {
94
111
  fieldErrors = {};
95
112
  internalError = '';
113
+ successMessage = '';
114
+ clearTimeout(successTimeout);
96
115
  const errs = validateAll(fields, formData, strings);
97
116
  if (Object.keys(errs).length > 0) {
98
117
  fieldErrors = errs;
@@ -106,9 +125,11 @@
106
125
  record = emptyRecord(fields);
107
126
  fieldErrors = {};
108
127
  internalError = '';
128
+ flashSuccess();
109
129
  } else if (duplicating) {
110
130
  fieldErrors = {};
111
131
  internalError = '';
132
+ flashSuccess();
112
133
  } else {
113
134
  onSuccess?.();
114
135
  }
package/dist/i18n/en.js CHANGED
@@ -28,6 +28,7 @@ export const en = {
28
28
  duplicate: 'Duplicate',
29
29
  cancel: 'Cancel',
30
30
  back: 'Back',
31
+ saveSuccess: 'Saved successfully.',
31
32
  add: 'Add',
32
33
  remove: 'Remove',
33
34
  noItems: 'No items added',
package/dist/i18n/es.js CHANGED
@@ -28,6 +28,7 @@ export const es = {
28
28
  duplicate: 'Duplicar',
29
29
  cancel: 'Cancelar',
30
30
  back: 'Volver',
31
+ saveSuccess: 'Guardado correctamente.',
31
32
  add: 'Agregar',
32
33
  remove: 'Quitar',
33
34
  noItems: 'Sin elementos agregados',
@@ -28,6 +28,10 @@ export interface RuneforgeStrings {
28
28
  duplicate: string;
29
29
  cancel: string;
30
30
  back: string;
31
+ /** Create form only: shown after "Save and continue"/"Duplicate" save
32
+ * successfully but keep the user on the form (unlike a plain Save, which
33
+ * navigates away and needs no extra confirmation). */
34
+ saveSuccess: string;
31
35
  add: string;
32
36
  remove: string;
33
37
  noItems: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runeforge",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "description": "SvelteKit toolkit for building metadata-driven CRUD interfaces with tables, forms, and actions",
5
5
  "license": "MIT",
6
6
  "author": "Ezequiel Puerta",