@herdingbits/trailhead-core 0.2.0 → 0.3.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/package.json +1 -1
- package/dist/lib/feedback.d.ts +0 -58
- package/dist/lib/feedback.d.ts.map +0 -1
- package/dist/lib/feedback.js +0 -145
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herdingbits/trailhead-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Simple application shell that orchestrates multiple SPAs. No webpack magic, just the browser's native module system.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/dist/lib/feedback.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Feedback system - imperative API for user feedback
|
|
3
|
-
* No React, pure DOM manipulation
|
|
4
|
-
*/
|
|
5
|
-
import type { AlertVariant } from "../types/shell-api";
|
|
6
|
-
/**
|
|
7
|
-
* Show blocking busy overlay with spinner
|
|
8
|
-
*/
|
|
9
|
-
export declare function busy(message: string): void;
|
|
10
|
-
/**
|
|
11
|
-
* Clear busy overlay
|
|
12
|
-
*/
|
|
13
|
-
export declare function clear(): void;
|
|
14
|
-
/**
|
|
15
|
-
* Show toast notification
|
|
16
|
-
*/
|
|
17
|
-
export declare function alert(message: string, variant?: AlertVariant, duration?: number): void;
|
|
18
|
-
/**
|
|
19
|
-
* Show success toast
|
|
20
|
-
*/
|
|
21
|
-
export declare function success(message: string, duration?: number): void;
|
|
22
|
-
/**
|
|
23
|
-
* Show error toast
|
|
24
|
-
*/
|
|
25
|
-
export declare function error(message: string, duration?: number): void;
|
|
26
|
-
/**
|
|
27
|
-
* Show warning toast
|
|
28
|
-
*/
|
|
29
|
-
export declare function warning(message: string, duration?: number): void;
|
|
30
|
-
/**
|
|
31
|
-
* Show info toast
|
|
32
|
-
*/
|
|
33
|
-
export declare function info(message: string, duration?: number): void;
|
|
34
|
-
/**
|
|
35
|
-
* Show dialog with custom buttons
|
|
36
|
-
*/
|
|
37
|
-
export declare function custom<T extends string>(message: string, title: string, buttons: Array<{
|
|
38
|
-
label: string;
|
|
39
|
-
value: T;
|
|
40
|
-
variant?: string;
|
|
41
|
-
}>): Promise<T | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Show confirm dialog (Cancel/Confirm)
|
|
44
|
-
*/
|
|
45
|
-
export declare function confirm(message: string, title?: string): Promise<boolean>;
|
|
46
|
-
/**
|
|
47
|
-
* Show OK dialog
|
|
48
|
-
*/
|
|
49
|
-
export declare function ok(message: string, title?: string): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Show Yes/No dialog
|
|
52
|
-
*/
|
|
53
|
-
export declare function yesNo(message: string, title?: string): Promise<boolean>;
|
|
54
|
-
/**
|
|
55
|
-
* Show Yes/No/Cancel dialog
|
|
56
|
-
*/
|
|
57
|
-
export declare function yesNoCancel(message: string, title?: string): Promise<"yes" | "no" | "cancel">;
|
|
58
|
-
//# sourceMappingURL=feedback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../../src/lib/feedback.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAkB1C;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAI5B;AAED;;GAEG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,YAAqB,EAC9B,QAAQ,GAAE,MAAa,GACtB,IAAI,CAiBN;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAEhE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-
* Show blocking busy overlay with spinner
|
|
5
|
-
*/
|
|
6
|
-
export function busy(message) {
|
|
7
|
-
if (!busyOverlay) {
|
|
8
|
-
busyOverlay = document.createElement("div");
|
|
9
|
-
busyOverlay.id = "shell-busy-overlay";
|
|
10
|
-
busyOverlay.innerHTML = `
|
|
11
|
-
<div class="shell-busy-content">
|
|
12
|
-
<div class="shell-spinner"></div>
|
|
13
|
-
<div class="shell-busy-message"></div>
|
|
14
|
-
</div>
|
|
15
|
-
`;
|
|
16
|
-
document.body.appendChild(busyOverlay);
|
|
17
|
-
}
|
|
18
|
-
const messageEl = busyOverlay.querySelector(".shell-busy-message");
|
|
19
|
-
if (messageEl) {
|
|
20
|
-
messageEl.textContent = message;
|
|
21
|
-
}
|
|
22
|
-
busyOverlay.style.display = "flex";
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Clear busy overlay
|
|
26
|
-
*/
|
|
27
|
-
export function clear() {
|
|
28
|
-
if (busyOverlay) {
|
|
29
|
-
busyOverlay.style.display = "none";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Show toast notification
|
|
34
|
-
*/
|
|
35
|
-
export function alert(message, variant = "info", duration = 3000) {
|
|
36
|
-
if (!toastContainer) {
|
|
37
|
-
toastContainer = document.createElement("div");
|
|
38
|
-
toastContainer.id = "shell-toast-container";
|
|
39
|
-
document.body.appendChild(toastContainer);
|
|
40
|
-
}
|
|
41
|
-
const toast = document.createElement("div");
|
|
42
|
-
toast.className = `shell-toast shell-toast-${variant}`;
|
|
43
|
-
toast.textContent = message;
|
|
44
|
-
toastContainer.appendChild(toast);
|
|
45
|
-
setTimeout(() => toast.classList.add("shell-toast-show"), 10);
|
|
46
|
-
setTimeout(() => {
|
|
47
|
-
toast.classList.remove("shell-toast-show");
|
|
48
|
-
setTimeout(() => toast.remove(), 300);
|
|
49
|
-
}, duration);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Show success toast
|
|
53
|
-
*/
|
|
54
|
-
export function success(message, duration) {
|
|
55
|
-
alert(message, "success", duration);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Show error toast
|
|
59
|
-
*/
|
|
60
|
-
export function error(message, duration) {
|
|
61
|
-
alert(message, "error", duration || 5000);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Show warning toast
|
|
65
|
-
*/
|
|
66
|
-
export function warning(message, duration) {
|
|
67
|
-
alert(message, "warning", duration || 4000);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Show info toast
|
|
71
|
-
*/
|
|
72
|
-
export function info(message, duration) {
|
|
73
|
-
alert(message, "info", duration);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Show dialog with custom buttons
|
|
77
|
-
*/
|
|
78
|
-
export function custom(message, title, buttons) {
|
|
79
|
-
return new Promise((resolve) => {
|
|
80
|
-
const dialog = document.createElement("div");
|
|
81
|
-
dialog.className = "shell-dialog-overlay";
|
|
82
|
-
dialog.innerHTML = `
|
|
83
|
-
<div class="shell-dialog">
|
|
84
|
-
<div class="shell-dialog-title">${title}</div>
|
|
85
|
-
<div class="shell-dialog-message">${message}</div>
|
|
86
|
-
<div class="shell-dialog-buttons">
|
|
87
|
-
${buttons
|
|
88
|
-
.map((btn) => `<button class="shell-btn shell-btn-${btn.variant || "default"}" data-value="${btn.value}">${btn.label}</button>`)
|
|
89
|
-
.join("")}
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
`;
|
|
93
|
-
dialog.querySelectorAll("button").forEach((btn) => {
|
|
94
|
-
btn.onclick = () => {
|
|
95
|
-
const value = btn.getAttribute("data-value");
|
|
96
|
-
dialog.remove();
|
|
97
|
-
resolve(value);
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
// Click outside to cancel
|
|
101
|
-
dialog.onclick = (e) => {
|
|
102
|
-
if (e.target === dialog) {
|
|
103
|
-
dialog.remove();
|
|
104
|
-
resolve(null);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
document.body.appendChild(dialog);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Show confirm dialog (Cancel/Confirm)
|
|
112
|
-
*/
|
|
113
|
-
export function confirm(message, title = "Confirm") {
|
|
114
|
-
return custom(message, title, [
|
|
115
|
-
{ label: "Cancel", value: "cancel", variant: "secondary" },
|
|
116
|
-
{ label: "Confirm", value: "confirm", variant: "primary" },
|
|
117
|
-
]).then((result) => result === "confirm");
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Show OK dialog
|
|
121
|
-
*/
|
|
122
|
-
export function ok(message, title = "Information") {
|
|
123
|
-
return custom(message, title, [
|
|
124
|
-
{ label: "OK", value: "ok", variant: "primary" },
|
|
125
|
-
]).then(() => undefined);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Show Yes/No dialog
|
|
129
|
-
*/
|
|
130
|
-
export function yesNo(message, title = "Confirm") {
|
|
131
|
-
return custom(message, title, [
|
|
132
|
-
{ label: "No", value: "no", variant: "secondary" },
|
|
133
|
-
{ label: "Yes", value: "yes", variant: "primary" },
|
|
134
|
-
]).then((result) => result === "yes");
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Show Yes/No/Cancel dialog
|
|
138
|
-
*/
|
|
139
|
-
export function yesNoCancel(message, title = "Confirm") {
|
|
140
|
-
return custom(message, title, [
|
|
141
|
-
{ label: "Cancel", value: "cancel", variant: "secondary" },
|
|
142
|
-
{ label: "No", value: "no", variant: "secondary" },
|
|
143
|
-
{ label: "Yes", value: "yes", variant: "primary" },
|
|
144
|
-
]).then((result) => result || "cancel");
|
|
145
|
-
}
|