@rimelight/ui 0.0.1 → 0.0.3
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 +53 -49
- package/src/components/carousel/carousel-script.ts +188 -188
- package/src/components/carousel/index.ts +1 -1
- package/src/components/input-otp/InputOtpTypes.ts +6 -6
- package/src/components/radio-group/RadioGroupTypes.ts +6 -6
- package/src/components/select/SelectTypes.ts +13 -13
- package/src/components/switch/SwitchTypes.ts +6 -6
- package/src/components/toast/index.ts +1 -1
- package/src/components/toast/toast-manager.ts +234 -234
- package/src/components/toggle/ToggleTypes.ts +14 -14
- package/src/config/cookies.ts +5 -5
- package/src/config/index.ts +3 -3
- package/src/config/links.ts +4 -4
- package/src/config/site.config.ts +45 -45
- package/src/domain/cms/index.ts +1 -1
- package/src/domain/cms/types.ts +20 -20
- package/src/domain/i18n/constants.ts +21 -21
- package/src/domain/i18n/cookie-storage.ts +13 -13
- package/src/domain/i18n/country-to-locale-map.ts +67 -67
- package/src/domain/i18n/fetcher.ts +268 -268
- package/src/domain/i18n/flags.ts +16 -16
- package/src/domain/i18n/format.ts +90 -90
- package/src/domain/i18n/index.ts +10 -10
- package/src/domain/i18n/middleware/i18n.ts +160 -160
- package/src/domain/i18n/resolve-locale.ts +55 -55
- package/src/domain/i18n/schema.ts +29 -29
- package/src/domain/index.ts +4 -4
- package/src/domain/seo/constants.ts +20 -20
- package/src/domain/seo/index.ts +3 -3
- package/src/domain/seo/services/index.ts +3 -3
- package/src/domain/seo/services/llms.ts +53 -53
- package/src/domain/seo/services/robots.ts +12 -12
- package/src/domain/seo/services/sitemap.ts +56 -56
- package/src/domain/seo/utils.ts +37 -37
- package/src/domain/theme/constants.ts +6 -6
- package/src/domain/theme/index.ts +2 -2
- package/src/domain/theme/schema.ts +10 -10
- package/src/env.d.ts +49 -49
- package/src/integrations/index.ts +1 -0
- package/src/integrations/sri.ts +92 -0
- package/src/lib/component-preview.ts +73 -73
- package/src/lib/index.ts +6 -6
- package/src/lib/remark/remark-modified-time.ts +13 -13
- package/src/lib/showcase-preview-elements.ts +408 -408
- package/src/lib/showcase-renderer.ts +218 -218
- package/src/lib/showcase-utils.ts +189 -189
- package/src/lib/turnstile.ts +35 -35
- package/src/lib/utils/starwind/positioning.ts +318 -318
- package/src/locales/de/blog.json +9 -9
- package/src/locales/de/common.json +19 -19
- package/src/locales/de/errors.json +6 -6
- package/src/locales/de/home.json +20 -20
- package/src/locales/de/messages.json +8 -8
- package/src/locales/de/nav.json +13 -13
- package/src/locales/de/projects.json +9 -9
- package/src/locales/de/services.json +43 -43
- package/src/locales/en/blog.json +9 -9
- package/src/locales/en/chat.json +29 -29
- package/src/locales/en/common.json +19 -19
- package/src/locales/en/cookie_notice.json +11 -11
- package/src/locales/en/editor.json +24 -24
- package/src/locales/en/errors.json +6 -6
- package/src/locales/en/home.json +20 -20
- package/src/locales/en/messages.json +8 -8
- package/src/locales/en/nav.json +13 -13
- package/src/locales/en/projects.json +9 -9
- package/src/locales/en/services.json +43 -43
- package/src/locales/es/blog.json +9 -9
- package/src/locales/es/common.json +19 -19
- package/src/locales/es/errors.json +6 -6
- package/src/locales/es/home.json +20 -20
- package/src/locales/es/messages.json +8 -8
- package/src/locales/es/nav.json +13 -13
- package/src/locales/es/projects.json +9 -9
- package/src/locales/es/services.json +43 -43
- package/src/locales/ja/blog.json +9 -9
- package/src/locales/ja/common.json +19 -19
- package/src/locales/ja/errors.json +6 -6
- package/src/locales/ja/home.json +20 -20
- package/src/locales/ja/messages.json +8 -8
- package/src/locales/ja/nav.json +13 -13
- package/src/locales/ja/projects.json +9 -9
- package/src/locales/ja/services.json +43 -43
- package/src/locales/pt/blog.json +9 -9
- package/src/locales/pt/chat.json +29 -29
- package/src/locales/pt/common.json +19 -19
- package/src/locales/pt/cookie_notice.json +11 -11
- package/src/locales/pt/editor.json +24 -24
- package/src/locales/pt/errors.json +6 -6
- package/src/locales/pt/home.json +20 -20
- package/src/locales/pt/messages.json +8 -8
- package/src/locales/pt/nav.json +13 -13
- package/src/locales/pt/projects.json +9 -9
- package/src/locales/pt/services.json +43 -43
- package/src/middleware/index.ts +1 -0
- package/src/middleware/sri.ts +76 -0
- package/src/utils/index.ts +2 -2
- package/src/utils/server/cookies.ts +98 -98
- package/src/utils/server/index.ts +1 -1
- package/src/utils/shared/deep-merge.ts +36 -36
- package/src/utils/shared/embed.ts +105 -105
- package/src/utils/shared/index.ts +3 -3
- package/src/utils/shared/parse-boolean.ts +14 -14
|
@@ -1,234 +1,234 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Starwind Toast API
|
|
3
|
-
*
|
|
4
|
-
* A simple, framework-agnostic toast notification system.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ;```ts
|
|
8
|
-
* import { toast } from "./toast/toast-manager"
|
|
9
|
-
*
|
|
10
|
-
* // Simple usage
|
|
11
|
-
* toast("Hello world")
|
|
12
|
-
* toast({ title: "Success", description: "Item saved" })
|
|
13
|
-
*
|
|
14
|
-
* // Variant shortcuts
|
|
15
|
-
* toast.success("Saved successfully")
|
|
16
|
-
* toast.error("Something went wrong")
|
|
17
|
-
* toast.warning("Please check your input")
|
|
18
|
-
* toast.info("New update available")
|
|
19
|
-
* toast.loading("Processing...")
|
|
20
|
-
*
|
|
21
|
-
* // Promise handling
|
|
22
|
-
* toast.promise(saveData(), {
|
|
23
|
-
* loading: "Saving...",
|
|
24
|
-
* success: "Saved!",
|
|
25
|
-
* error: "Failed to save"
|
|
26
|
-
* })
|
|
27
|
-
*
|
|
28
|
-
* // Management
|
|
29
|
-
* const id = toast("Processing...")
|
|
30
|
-
* toast.update(id, { title: "Almost done..." })
|
|
31
|
-
* toast.dismiss(id)
|
|
32
|
-
* toast.dismiss() // dismiss all
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
export type Variant = "default" | "success" | "error" | "warning" | "info" | "loading"
|
|
37
|
-
|
|
38
|
-
export interface ToastOptions {
|
|
39
|
-
id?: string
|
|
40
|
-
title?: string
|
|
41
|
-
description?: string
|
|
42
|
-
variant?: Variant
|
|
43
|
-
/**
|
|
44
|
-
* Duration in ms. Set to 0 for infinite (no auto-dismiss).
|
|
45
|
-
*/
|
|
46
|
-
duration?: number
|
|
47
|
-
/**
|
|
48
|
-
* Callback when toast close animation starts
|
|
49
|
-
*/
|
|
50
|
-
onClose?: () => void
|
|
51
|
-
/**
|
|
52
|
-
* Callback when toast is removed from DOM
|
|
53
|
-
*/
|
|
54
|
-
onRemove?: () => void
|
|
55
|
-
action?: {
|
|
56
|
-
label: string
|
|
57
|
-
onClick: () => void
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
declare global {
|
|
62
|
-
interface Window {
|
|
63
|
-
__starwind__: {
|
|
64
|
-
toast?: ToastManager
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface PromiseStateOption {
|
|
70
|
-
title?: string
|
|
71
|
-
description?: string
|
|
72
|
-
duration?: number
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export type PromiseStateValue<T> =
|
|
76
|
-
| string
|
|
77
|
-
| PromiseStateOption
|
|
78
|
-
| ((data: T) => string | PromiseStateOption)
|
|
79
|
-
|
|
80
|
-
export interface PromiseOptions<T, E = Error> {
|
|
81
|
-
loading: string | PromiseStateOption
|
|
82
|
-
success: PromiseStateValue<T>
|
|
83
|
-
error: PromiseStateValue<E>
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface ToastManager {
|
|
87
|
-
add(options: ToastOptions): string
|
|
88
|
-
update(id: string, options: Partial<ToastOptions>): void
|
|
89
|
-
close(id: string): void
|
|
90
|
-
closeAll(): void
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Get the toast manager instance from the window
|
|
95
|
-
*/
|
|
96
|
-
function getManager(): ToastManager | null {
|
|
97
|
-
if (typeof window === "undefined") return null
|
|
98
|
-
return window.__starwind__?.toast ?? null
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Normalize a string or options object to ToastOptions
|
|
103
|
-
*/
|
|
104
|
-
function normalizeOption<T>(
|
|
105
|
-
value: string | PromiseStateOption | ((data: T) => string | PromiseStateOption),
|
|
106
|
-
data?: T
|
|
107
|
-
): Omit<ToastOptions, "variant"> {
|
|
108
|
-
// We use a cast here because T is generic and can't be automatically matched internally
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
110
|
-
const resolved = typeof value === "function" ? value(data as T) : value
|
|
111
|
-
if (typeof resolved === "string") {
|
|
112
|
-
return { title: resolved }
|
|
113
|
-
}
|
|
114
|
-
return resolved
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Create a toast notification
|
|
119
|
-
*/
|
|
120
|
-
function createToast(
|
|
121
|
-
messageOrOptions: string | ToastOptions,
|
|
122
|
-
extraOptions?: Omit<ToastOptions, "title">
|
|
123
|
-
): string {
|
|
124
|
-
let options: ToastOptions
|
|
125
|
-
if (typeof messageOrOptions === "string") {
|
|
126
|
-
options = { title: messageOrOptions, ...extraOptions }
|
|
127
|
-
} else {
|
|
128
|
-
options = messageOrOptions
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const manager = getManager()
|
|
132
|
-
if (manager) {
|
|
133
|
-
return manager.add(options)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
console.warn("Toast: No Toaster found. Add <Toaster /> to your layout.")
|
|
137
|
-
return ""
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Create a toast with a specific variant
|
|
142
|
-
*/
|
|
143
|
-
function createVariantToast(
|
|
144
|
-
variant: Variant,
|
|
145
|
-
message: string,
|
|
146
|
-
options?: Omit<ToastOptions, "variant">
|
|
147
|
-
): string {
|
|
148
|
-
return createToast({ ...options, title: message, variant })
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Toast API interface
|
|
153
|
-
*/
|
|
154
|
-
interface ToastAPI {
|
|
155
|
-
(message: string, options?: Omit<ToastOptions, "title">): string
|
|
156
|
-
(options: ToastOptions): string
|
|
157
|
-
success(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
158
|
-
error(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
159
|
-
warning(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
160
|
-
info(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
161
|
-
loading(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
162
|
-
promise<T, E = Error>(promise: Promise<T>, options: PromiseOptions<T, E>): Promise<T>
|
|
163
|
-
update(id: string, options: Partial<ToastOptions>): void
|
|
164
|
-
dismiss(id?: string): void
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Main toast function with variant methods attached
|
|
169
|
-
*/
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
171
|
-
const toast = createToast as unknown as ToastAPI
|
|
172
|
-
|
|
173
|
-
toast.success = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
174
|
-
createVariantToast("success", message, options)
|
|
175
|
-
|
|
176
|
-
toast.error = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
177
|
-
createVariantToast("error", message, options)
|
|
178
|
-
|
|
179
|
-
toast.warning = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
180
|
-
createVariantToast("warning", message, options)
|
|
181
|
-
|
|
182
|
-
toast.info = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
183
|
-
createVariantToast("info", message, options)
|
|
184
|
-
|
|
185
|
-
toast.loading = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
186
|
-
createVariantToast("loading", message, { ...options, duration: 0 })
|
|
187
|
-
|
|
188
|
-
toast.promise = async <T, E = Error>(
|
|
189
|
-
promise: Promise<T>,
|
|
190
|
-
options: PromiseOptions<T, E>
|
|
191
|
-
): Promise<T> => {
|
|
192
|
-
const loadingOpts = normalizeOption(options.loading)
|
|
193
|
-
const id = createToast({
|
|
194
|
-
...loadingOpts,
|
|
195
|
-
variant: "loading",
|
|
196
|
-
duration: 0 // Don't auto-dismiss while loading
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
try {
|
|
200
|
-
const data = await promise
|
|
201
|
-
const successOpts = normalizeOption(options.success, data)
|
|
202
|
-
toast.update(id, { ...successOpts, variant: "success" })
|
|
203
|
-
return data
|
|
204
|
-
} catch (error) {
|
|
205
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
206
|
-
const errorOpts = normalizeOption(options.error, error as E)
|
|
207
|
-
toast.update(id, { ...errorOpts, variant: "error" })
|
|
208
|
-
throw error
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
toast.update = (id: string, options: Partial<ToastOptions>): void => {
|
|
213
|
-
const manager = getManager()
|
|
214
|
-
if (manager) {
|
|
215
|
-
manager.update(id, options)
|
|
216
|
-
} else {
|
|
217
|
-
console.warn("Toast: No Toaster found. Add <Toaster /> to your layout.")
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
toast.dismiss = (id?: string): void => {
|
|
222
|
-
const manager = getManager()
|
|
223
|
-
if (!manager) {
|
|
224
|
-
// Can't dismiss if manager isn't ready
|
|
225
|
-
return
|
|
226
|
-
}
|
|
227
|
-
if (id) {
|
|
228
|
-
manager.close(id)
|
|
229
|
-
} else {
|
|
230
|
-
manager.closeAll()
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export { toast }
|
|
1
|
+
/**
|
|
2
|
+
* Starwind Toast API
|
|
3
|
+
*
|
|
4
|
+
* A simple, framework-agnostic toast notification system.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ;```ts
|
|
8
|
+
* import { toast } from "./toast/toast-manager"
|
|
9
|
+
*
|
|
10
|
+
* // Simple usage
|
|
11
|
+
* toast("Hello world")
|
|
12
|
+
* toast({ title: "Success", description: "Item saved" })
|
|
13
|
+
*
|
|
14
|
+
* // Variant shortcuts
|
|
15
|
+
* toast.success("Saved successfully")
|
|
16
|
+
* toast.error("Something went wrong")
|
|
17
|
+
* toast.warning("Please check your input")
|
|
18
|
+
* toast.info("New update available")
|
|
19
|
+
* toast.loading("Processing...")
|
|
20
|
+
*
|
|
21
|
+
* // Promise handling
|
|
22
|
+
* toast.promise(saveData(), {
|
|
23
|
+
* loading: "Saving...",
|
|
24
|
+
* success: "Saved!",
|
|
25
|
+
* error: "Failed to save"
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* // Management
|
|
29
|
+
* const id = toast("Processing...")
|
|
30
|
+
* toast.update(id, { title: "Almost done..." })
|
|
31
|
+
* toast.dismiss(id)
|
|
32
|
+
* toast.dismiss() // dismiss all
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
export type Variant = "default" | "success" | "error" | "warning" | "info" | "loading"
|
|
37
|
+
|
|
38
|
+
export interface ToastOptions {
|
|
39
|
+
id?: string
|
|
40
|
+
title?: string
|
|
41
|
+
description?: string
|
|
42
|
+
variant?: Variant
|
|
43
|
+
/**
|
|
44
|
+
* Duration in ms. Set to 0 for infinite (no auto-dismiss).
|
|
45
|
+
*/
|
|
46
|
+
duration?: number
|
|
47
|
+
/**
|
|
48
|
+
* Callback when toast close animation starts
|
|
49
|
+
*/
|
|
50
|
+
onClose?: () => void
|
|
51
|
+
/**
|
|
52
|
+
* Callback when toast is removed from DOM
|
|
53
|
+
*/
|
|
54
|
+
onRemove?: () => void
|
|
55
|
+
action?: {
|
|
56
|
+
label: string
|
|
57
|
+
onClick: () => void
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare global {
|
|
62
|
+
interface Window {
|
|
63
|
+
__starwind__: {
|
|
64
|
+
toast?: ToastManager
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface PromiseStateOption {
|
|
70
|
+
title?: string
|
|
71
|
+
description?: string
|
|
72
|
+
duration?: number
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type PromiseStateValue<T> =
|
|
76
|
+
| string
|
|
77
|
+
| PromiseStateOption
|
|
78
|
+
| ((data: T) => string | PromiseStateOption)
|
|
79
|
+
|
|
80
|
+
export interface PromiseOptions<T, E = Error> {
|
|
81
|
+
loading: string | PromiseStateOption
|
|
82
|
+
success: PromiseStateValue<T>
|
|
83
|
+
error: PromiseStateValue<E>
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface ToastManager {
|
|
87
|
+
add(options: ToastOptions): string
|
|
88
|
+
update(id: string, options: Partial<ToastOptions>): void
|
|
89
|
+
close(id: string): void
|
|
90
|
+
closeAll(): void
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get the toast manager instance from the window
|
|
95
|
+
*/
|
|
96
|
+
function getManager(): ToastManager | null {
|
|
97
|
+
if (typeof window === "undefined") return null
|
|
98
|
+
return window.__starwind__?.toast ?? null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Normalize a string or options object to ToastOptions
|
|
103
|
+
*/
|
|
104
|
+
function normalizeOption<T>(
|
|
105
|
+
value: string | PromiseStateOption | ((data: T) => string | PromiseStateOption),
|
|
106
|
+
data?: T
|
|
107
|
+
): Omit<ToastOptions, "variant"> {
|
|
108
|
+
// We use a cast here because T is generic and can't be automatically matched internally
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
110
|
+
const resolved = typeof value === "function" ? value(data as T) : value
|
|
111
|
+
if (typeof resolved === "string") {
|
|
112
|
+
return { title: resolved }
|
|
113
|
+
}
|
|
114
|
+
return resolved
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Create a toast notification
|
|
119
|
+
*/
|
|
120
|
+
function createToast(
|
|
121
|
+
messageOrOptions: string | ToastOptions,
|
|
122
|
+
extraOptions?: Omit<ToastOptions, "title">
|
|
123
|
+
): string {
|
|
124
|
+
let options: ToastOptions
|
|
125
|
+
if (typeof messageOrOptions === "string") {
|
|
126
|
+
options = { title: messageOrOptions, ...extraOptions }
|
|
127
|
+
} else {
|
|
128
|
+
options = messageOrOptions
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const manager = getManager()
|
|
132
|
+
if (manager) {
|
|
133
|
+
return manager.add(options)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
console.warn("Toast: No Toaster found. Add <Toaster /> to your layout.")
|
|
137
|
+
return ""
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Create a toast with a specific variant
|
|
142
|
+
*/
|
|
143
|
+
function createVariantToast(
|
|
144
|
+
variant: Variant,
|
|
145
|
+
message: string,
|
|
146
|
+
options?: Omit<ToastOptions, "variant">
|
|
147
|
+
): string {
|
|
148
|
+
return createToast({ ...options, title: message, variant })
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Toast API interface
|
|
153
|
+
*/
|
|
154
|
+
interface ToastAPI {
|
|
155
|
+
(message: string, options?: Omit<ToastOptions, "title">): string
|
|
156
|
+
(options: ToastOptions): string
|
|
157
|
+
success(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
158
|
+
error(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
159
|
+
warning(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
160
|
+
info(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
161
|
+
loading(message: string, options?: Omit<ToastOptions, "variant">): string
|
|
162
|
+
promise<T, E = Error>(promise: Promise<T>, options: PromiseOptions<T, E>): Promise<T>
|
|
163
|
+
update(id: string, options: Partial<ToastOptions>): void
|
|
164
|
+
dismiss(id?: string): void
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Main toast function with variant methods attached
|
|
169
|
+
*/
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
171
|
+
const toast = createToast as unknown as ToastAPI
|
|
172
|
+
|
|
173
|
+
toast.success = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
174
|
+
createVariantToast("success", message, options)
|
|
175
|
+
|
|
176
|
+
toast.error = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
177
|
+
createVariantToast("error", message, options)
|
|
178
|
+
|
|
179
|
+
toast.warning = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
180
|
+
createVariantToast("warning", message, options)
|
|
181
|
+
|
|
182
|
+
toast.info = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
183
|
+
createVariantToast("info", message, options)
|
|
184
|
+
|
|
185
|
+
toast.loading = (message: string, options?: Omit<ToastOptions, "variant">) =>
|
|
186
|
+
createVariantToast("loading", message, { ...options, duration: 0 })
|
|
187
|
+
|
|
188
|
+
toast.promise = async <T, E = Error>(
|
|
189
|
+
promise: Promise<T>,
|
|
190
|
+
options: PromiseOptions<T, E>
|
|
191
|
+
): Promise<T> => {
|
|
192
|
+
const loadingOpts = normalizeOption(options.loading)
|
|
193
|
+
const id = createToast({
|
|
194
|
+
...loadingOpts,
|
|
195
|
+
variant: "loading",
|
|
196
|
+
duration: 0 // Don't auto-dismiss while loading
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
const data = await promise
|
|
201
|
+
const successOpts = normalizeOption(options.success, data)
|
|
202
|
+
toast.update(id, { ...successOpts, variant: "success" })
|
|
203
|
+
return data
|
|
204
|
+
} catch (error) {
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
206
|
+
const errorOpts = normalizeOption(options.error, error as E)
|
|
207
|
+
toast.update(id, { ...errorOpts, variant: "error" })
|
|
208
|
+
throw error
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
toast.update = (id: string, options: Partial<ToastOptions>): void => {
|
|
213
|
+
const manager = getManager()
|
|
214
|
+
if (manager) {
|
|
215
|
+
manager.update(id, options)
|
|
216
|
+
} else {
|
|
217
|
+
console.warn("Toast: No Toaster found. Add <Toaster /> to your layout.")
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
toast.dismiss = (id?: string): void => {
|
|
222
|
+
const manager = getManager()
|
|
223
|
+
if (!manager) {
|
|
224
|
+
// Can't dismiss if manager isn't ready
|
|
225
|
+
return
|
|
226
|
+
}
|
|
227
|
+
if (id) {
|
|
228
|
+
manager.close(id)
|
|
229
|
+
} else {
|
|
230
|
+
manager.closeAll()
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export { toast }
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export interface ToggleChangeEvent extends CustomEvent {
|
|
2
|
-
detail: {
|
|
3
|
-
pressed: boolean
|
|
4
|
-
toggleId: string
|
|
5
|
-
syncGroup?: string
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface ToggleSyncEvent extends CustomEvent {
|
|
10
|
-
detail: {
|
|
11
|
-
pressed: boolean
|
|
12
|
-
sourceId: string
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
export interface ToggleChangeEvent extends CustomEvent {
|
|
2
|
+
detail: {
|
|
3
|
+
pressed: boolean
|
|
4
|
+
toggleId: string
|
|
5
|
+
syncGroup?: string
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ToggleSyncEvent extends CustomEvent {
|
|
10
|
+
detail: {
|
|
11
|
+
pressed: boolean
|
|
12
|
+
sourceId: string
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/config/cookies.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Cookies / runtime-policy
|
|
2
|
-
|
|
3
|
-
export const COOKIE_TTL = {
|
|
4
|
-
oneYear: 60 * 60 * 24 * 365
|
|
5
|
-
} as const
|
|
1
|
+
// Cookies / runtime-policy
|
|
2
|
+
|
|
3
|
+
export const COOKIE_TTL = {
|
|
4
|
+
oneYear: 60 * 60 * 24 * 365
|
|
5
|
+
} as const
|
package/src/config/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./site.config"
|
|
2
|
-
export * from "./links"
|
|
3
|
-
export * from "./cookies"
|
|
1
|
+
export * from "./site.config"
|
|
2
|
+
export * from "./links"
|
|
3
|
+
export * from "./cookies"
|
package/src/config/links.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const LINKS = {
|
|
2
|
-
edgeKitsSite: "https://edgekits.dev",
|
|
3
|
-
twitter: `https://x.com/GaryEdgeKits`
|
|
4
|
-
} as const
|
|
1
|
+
export const LINKS = {
|
|
2
|
+
edgeKitsSite: "https://edgekits.dev",
|
|
3
|
+
twitter: `https://x.com/GaryEdgeKits`
|
|
4
|
+
} as const
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
export interface SiteConfig {
|
|
2
|
-
id: string
|
|
3
|
-
name: string
|
|
4
|
-
description: string
|
|
5
|
-
url: string
|
|
6
|
-
ogImage: string
|
|
7
|
-
author: string
|
|
8
|
-
email: string
|
|
9
|
-
branding: {
|
|
10
|
-
logo: {
|
|
11
|
-
alt: string
|
|
12
|
-
}
|
|
13
|
-
favicon: {
|
|
14
|
-
svg: string
|
|
15
|
-
}
|
|
16
|
-
colors: {
|
|
17
|
-
themeColor: string
|
|
18
|
-
backgroundColor: string
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const SITE_CONFIG: SiteConfig = {
|
|
24
|
-
id: "danielmarchi.dev",
|
|
25
|
-
name: "Daniel Marchi",
|
|
26
|
-
description: "A portfolio website built with Astro.",
|
|
27
|
-
url: "https://danielmarchi.dev",
|
|
28
|
-
ogImage: "/og-default.png",
|
|
29
|
-
author: "Daniel Marchi",
|
|
30
|
-
email: "hello@danielmarchi.dev",
|
|
31
|
-
branding: {
|
|
32
|
-
logo: {
|
|
33
|
-
alt: "Daniel Marchi"
|
|
34
|
-
},
|
|
35
|
-
favicon: {
|
|
36
|
-
svg: "/favicon.svg"
|
|
37
|
-
},
|
|
38
|
-
colors: {
|
|
39
|
-
themeColor: "#F94C10",
|
|
40
|
-
backgroundColor: "#ffffff"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default SITE_CONFIG
|
|
1
|
+
export interface SiteConfig {
|
|
2
|
+
id: string
|
|
3
|
+
name: string
|
|
4
|
+
description: string
|
|
5
|
+
url: string
|
|
6
|
+
ogImage: string
|
|
7
|
+
author: string
|
|
8
|
+
email: string
|
|
9
|
+
branding: {
|
|
10
|
+
logo: {
|
|
11
|
+
alt: string
|
|
12
|
+
}
|
|
13
|
+
favicon: {
|
|
14
|
+
svg: string
|
|
15
|
+
}
|
|
16
|
+
colors: {
|
|
17
|
+
themeColor: string
|
|
18
|
+
backgroundColor: string
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const SITE_CONFIG: SiteConfig = {
|
|
24
|
+
id: "danielmarchi.dev",
|
|
25
|
+
name: "Daniel Marchi",
|
|
26
|
+
description: "A portfolio website built with Astro.",
|
|
27
|
+
url: "https://danielmarchi.dev",
|
|
28
|
+
ogImage: "/og-default.png",
|
|
29
|
+
author: "Daniel Marchi",
|
|
30
|
+
email: "hello@danielmarchi.dev",
|
|
31
|
+
branding: {
|
|
32
|
+
logo: {
|
|
33
|
+
alt: "Daniel Marchi"
|
|
34
|
+
},
|
|
35
|
+
favicon: {
|
|
36
|
+
svg: "/favicon.svg"
|
|
37
|
+
},
|
|
38
|
+
colors: {
|
|
39
|
+
themeColor: "#F94C10",
|
|
40
|
+
backgroundColor: "#ffffff"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default SITE_CONFIG
|
package/src/domain/cms/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./types"
|
|
1
|
+
export * from "./types"
|
package/src/domain/cms/types.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal shape of an Astro Content Collection entry. Explicitly allowing undefined for all common
|
|
3
|
-
* SEO fields to resolve monorepo type clashes.
|
|
4
|
-
*/
|
|
5
|
-
export interface BaseCMSContentEntry {
|
|
6
|
-
id: string
|
|
7
|
-
data: {
|
|
8
|
-
title?: string | undefined | null
|
|
9
|
-
description?: string | undefined | null
|
|
10
|
-
publishedDate?: Date | undefined | null
|
|
11
|
-
[key: string]: unknown
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Type guard to safely identify a content entry that satisfies the base library requirements.
|
|
17
|
-
*/
|
|
18
|
-
export function isBaseCMSContentEntry(entry: unknown): entry is BaseCMSContentEntry {
|
|
19
|
-
return !!entry && typeof entry === "object" && entry !== null && "id" in entry && "data" in entry
|
|
20
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Minimal shape of an Astro Content Collection entry. Explicitly allowing undefined for all common
|
|
3
|
+
* SEO fields to resolve monorepo type clashes.
|
|
4
|
+
*/
|
|
5
|
+
export interface BaseCMSContentEntry {
|
|
6
|
+
id: string
|
|
7
|
+
data: {
|
|
8
|
+
title?: string | undefined | null
|
|
9
|
+
description?: string | undefined | null
|
|
10
|
+
publishedDate?: Date | undefined | null
|
|
11
|
+
[key: string]: unknown
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to safely identify a content entry that satisfies the base library requirements.
|
|
17
|
+
*/
|
|
18
|
+
export function isBaseCMSContentEntry(entry: unknown): entry is BaseCMSContentEntry {
|
|
19
|
+
return !!entry && typeof entry === "object" && entry !== null && "id" in entry && "data" in entry
|
|
20
|
+
}
|