@ansiversa/components 0.0.19 → 0.0.20
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/index.ts +1 -0
- package/package.json +3 -2
- package/src/alpine/BaseStore.ts +28 -0
- package/src/alpine/index.ts +1 -0
package/index.ts
CHANGED
|
@@ -25,3 +25,4 @@ export { default as AvChipList } from './src/AvChipList.astro';
|
|
|
25
25
|
export { default as AvTemplateCard } from './src/AvTemplateCard.astro';
|
|
26
26
|
export { default as AvTemplateGrid } from './src/AvTemplateGrid.astro';
|
|
27
27
|
export { default as AvDrawer } from './src/AvDrawer.astro';
|
|
28
|
+
export * from "./src/alpine";
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ansiversa/components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "Shared UI components and layouts for the Ansiversa ecosystem",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./index.ts",
|
|
8
|
+
"./alpine": "./src/alpine/index.ts",
|
|
8
9
|
"./styles/global.css": "./src/styles/global.css"
|
|
9
10
|
},
|
|
10
11
|
"files": [
|
|
@@ -21,4 +22,4 @@
|
|
|
21
22
|
"peerDependencies": {
|
|
22
23
|
"astro": "^4.0.0 || ^5.0.0"
|
|
23
24
|
}
|
|
24
|
-
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class AvBaseStore {
|
|
2
|
+
isLoading = false;
|
|
3
|
+
error: string | null = null;
|
|
4
|
+
toast: { type: "success" | "error"; message: string } | null = null;
|
|
5
|
+
|
|
6
|
+
setLoading(v: boolean) { this.isLoading = v; }
|
|
7
|
+
setError(msg: string | null) { this.error = msg; }
|
|
8
|
+
clearError() { this.error = null; }
|
|
9
|
+
|
|
10
|
+
notify(type: "success" | "error", message: string) {
|
|
11
|
+
this.toast = { type, message };
|
|
12
|
+
window.setTimeout(() => {
|
|
13
|
+
if (this.toast?.message === message) this.toast = null;
|
|
14
|
+
}, 2500);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
confirm(message: string) {
|
|
18
|
+
return window.confirm(message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function safeErrorMessage(err: unknown, fallback = "Something went wrong.") {
|
|
23
|
+
if (err && typeof err === "object" && "message" in err) {
|
|
24
|
+
const msg = (err as any).message;
|
|
25
|
+
if (typeof msg === "string" && msg.trim()) return msg;
|
|
26
|
+
}
|
|
27
|
+
return fallback;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./BaseStore";
|