@opencode-ai/ui 0.0.0-next-17078 → 0.0.0-next-17080
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/dist/context/i18n.d.ts +10 -1
- package/dist/context/marked-parser.d.ts +2 -0
- package/dist/context/marked-theme-register.d.ts +1 -0
- package/dist/context/marked-theme.d.ts +2 -0
- package/dist/context/marked.d.ts +2 -9
- package/dist/i18n/am.d.ts +1 -0
- package/dist/i18n/ar.d.ts +38 -0
- package/dist/i18n/az.d.ts +1 -0
- package/dist/i18n/bg.d.ts +193 -0
- package/dist/i18n/bn.d.ts +1 -0
- package/dist/i18n/br.d.ts +26 -0
- package/dist/i18n/bs.d.ts +26 -0
- package/dist/i18n/ca.d.ts +1 -0
- package/dist/i18n/cs.d.ts +1 -0
- package/dist/i18n/da.d.ts +22 -0
- package/dist/i18n/de.d.ts +22 -0
- package/dist/i18n/dv.d.ts +1 -0
- package/dist/i18n/dz.d.ts +1 -0
- package/dist/i18n/el.d.ts +1 -0
- package/dist/i18n/es.d.ts +26 -0
- package/dist/i18n/et.d.ts +1 -0
- package/dist/i18n/fa.d.ts +1 -0
- package/dist/i18n/fi.d.ts +1 -0
- package/dist/i18n/fo.d.ts +1 -0
- package/dist/i18n/fr.d.ts +26 -0
- package/dist/i18n/hi.d.ts +1 -0
- package/dist/i18n/hr.d.ts +1 -0
- package/dist/i18n/hu.d.ts +1 -0
- package/dist/i18n/hy.d.ts +1 -0
- package/dist/i18n/id.d.ts +1 -0
- package/dist/i18n/is.d.ts +1 -0
- package/dist/i18n/it.d.ts +1 -0
- package/dist/i18n/ja.d.ts +22 -0
- package/dist/i18n/ka.d.ts +1 -0
- package/dist/i18n/km.d.ts +193 -0
- package/dist/i18n/ko.d.ts +22 -0
- package/dist/i18n/lo.d.ts +193 -0
- package/dist/i18n/lt.d.ts +1 -0
- package/dist/i18n/lv.d.ts +1 -0
- package/dist/i18n/mk.d.ts +193 -0
- package/dist/i18n/mn.d.ts +193 -0
- package/dist/i18n/ms.d.ts +1 -0
- package/dist/i18n/my.d.ts +193 -0
- package/dist/i18n/ne.d.ts +1 -0
- package/dist/i18n/nl.d.ts +1 -0
- package/dist/i18n/pa.d.ts +1 -0
- package/dist/i18n/pl.d.ts +30 -0
- package/dist/i18n/ro.d.ts +1 -0
- package/dist/i18n/ru.d.ts +30 -0
- package/dist/i18n/si.d.ts +1 -0
- package/dist/i18n/sk.d.ts +1 -0
- package/dist/i18n/sl.d.ts +1 -0
- package/dist/i18n/sq.d.ts +1 -0
- package/dist/i18n/sr.d.ts +197 -0
- package/dist/i18n/sv.d.ts +1 -0
- package/dist/i18n/tg.d.ts +193 -0
- package/dist/i18n/th.d.ts +22 -0
- package/dist/i18n/tk.d.ts +1 -0
- package/dist/i18n/tr.d.ts +22 -0
- package/dist/i18n/ur.d.ts +1 -0
- package/dist/i18n/uz.d.ts +1 -0
- package/dist/i18n/vi.d.ts +1 -0
- package/dist/i18n/zh.d.ts +22 -0
- package/dist/i18n/zht.d.ts +22 -0
- package/dist/v2/components/toast-v2.d.ts +19 -10
- package/package.json +3 -3
- package/src/components/diff-changes.css +2 -0
- package/src/components/dropdown-menu.css +2 -2
- package/src/components/icon.css +5 -0
- package/src/components/icon.tsx +12 -1
- package/src/components/provider-icons/sprite.svg +2 -27
- package/src/components/resize-handle.css +14 -2
- package/src/components/resize-handle.tsx +5 -1
- package/src/components/scroll-view.css +1 -1
- package/src/components/select.css +5 -3
- package/src/components/switch.css +4 -0
- package/src/components/tabs.css +54 -26
- package/src/components/tabs.tsx +1 -0
- package/src/components/text-field.css +2 -2
- package/src/components/toast.css +1 -1
- package/src/context/i18n.tsx +38 -2
- package/src/context/marked-parser.tsx +68 -0
- package/src/context/marked-theme-register.tsx +10 -0
- package/src/context/marked-theme.tsx +372 -0
- package/src/context/marked.tsx +20 -562
- package/src/i18n/am.ts +194 -0
- package/src/i18n/ar.ts +62 -22
- package/src/i18n/az.ts +195 -0
- package/src/i18n/bg.ts +195 -0
- package/src/i18n/bn.ts +197 -0
- package/src/i18n/br.ts +34 -6
- package/src/i18n/bs.ts +51 -23
- package/src/i18n/ca.ts +199 -0
- package/src/i18n/cs.ts +203 -0
- package/src/i18n/da.ts +36 -12
- package/src/i18n/de.ts +58 -36
- package/src/i18n/dv.ts +196 -0
- package/src/i18n/dz.ts +197 -0
- package/src/i18n/el.ts +195 -0
- package/src/i18n/en.ts +24 -0
- package/src/i18n/es.ts +45 -17
- package/src/i18n/et.ts +195 -0
- package/src/i18n/fa.ts +195 -0
- package/src/i18n/fi.ts +195 -0
- package/src/i18n/fo.ts +195 -0
- package/src/i18n/fr.ts +51 -21
- package/src/i18n/hi.ts +197 -0
- package/src/i18n/hr.ts +200 -0
- package/src/i18n/hu.ts +197 -0
- package/src/i18n/hy.ts +195 -0
- package/src/i18n/id.ts +217 -0
- package/src/i18n/is.ts +195 -0
- package/src/i18n/it.ts +200 -0
- package/src/i18n/ja.ts +29 -5
- package/src/i18n/ka.ts +195 -0
- package/src/i18n/km.ts +196 -0
- package/src/i18n/ko.ts +36 -12
- package/src/i18n/lo.ts +195 -0
- package/src/i18n/lt.ts +203 -0
- package/src/i18n/lv.ts +199 -0
- package/src/i18n/mk.ts +195 -0
- package/src/i18n/mn.ts +195 -0
- package/src/i18n/ms.ts +195 -0
- package/src/i18n/my.ts +196 -0
- package/src/i18n/ne.ts +197 -0
- package/src/i18n/nl.ts +195 -0
- package/src/i18n/no.ts +47 -23
- package/src/i18n/pa.ts +196 -0
- package/src/i18n/pl.ts +57 -24
- package/src/i18n/ro.ts +199 -0
- package/src/i18n/ru.ts +55 -23
- package/src/i18n/si.ts +195 -0
- package/src/i18n/sk.ts +203 -0
- package/src/i18n/sl.ts +204 -0
- package/src/i18n/sq.ts +195 -0
- package/src/i18n/sr.ts +200 -0
- package/src/i18n/sv.ts +195 -0
- package/src/i18n/tg.ts +195 -0
- package/src/i18n/th.ts +44 -21
- package/src/i18n/tk.ts +195 -0
- package/src/i18n/tr.ts +49 -25
- package/src/i18n/uk.ts +47 -15
- package/src/i18n/ur.ts +196 -0
- package/src/i18n/uz.ts +198 -0
- package/src/i18n/vi.ts +195 -0
- package/src/i18n/zh.ts +52 -29
- package/src/i18n/zht.ts +45 -22
- package/src/theme/themes/oc-2.json +4 -2
- package/src/v2/components/button-v2.css +2 -2
- package/src/v2/components/dialog-v2.css +2 -2
- package/src/v2/components/dialog-v2.tsx +3 -1
- package/src/v2/components/diff-changes-v2.css +2 -0
- package/src/v2/components/file-tree-v2.css +6 -2
- package/src/v2/components/inline-input-v2.tsx +3 -1
- package/src/v2/components/line-comment-v2.css +1 -1
- package/src/v2/components/line-comment-v2.tsx +6 -4
- package/src/v2/components/select-v2.css +16 -5
- package/src/v2/components/switch-v2.css +8 -0
- package/src/v2/components/tabs-v2.css +4 -6
- package/src/v2/components/tabs-v2.tsx +4 -2
- package/src/v2/components/text-input-v2.css +7 -5
- package/src/v2/components/text-input-v2.tsx +7 -1
- package/src/v2/components/toast-v2.css +132 -122
- package/src/v2/components/toast-v2.tsx +208 -73
- package/dist/context/marked-code-span.d.ts +0 -10
- package/src/context/marked-code-span.ts +0 -17
|
@@ -1,40 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Toaster, toast, type ToasterProps } from "solid-sonner"
|
|
2
|
+
import { isRTL } from "@kobalte/core/i18n"
|
|
3
3
|
import type { ComponentProps, JSX } from "solid-js"
|
|
4
|
-
import {
|
|
4
|
+
import { createContext, onCleanup, onMount, splitProps, useContext } from "solid-js"
|
|
5
5
|
import { Portal } from "solid-js/web"
|
|
6
|
-
import {
|
|
6
|
+
import { useI18n } from "../../context/i18n"
|
|
7
|
+
import "./button-v2.css"
|
|
7
8
|
import "./toast-v2.css"
|
|
8
9
|
|
|
9
|
-
export interface ToastV2RegionProps extends
|
|
10
|
+
export interface ToastV2RegionProps extends ToasterProps {}
|
|
10
11
|
|
|
11
12
|
function ToastV2Region(props: ToastV2RegionProps) {
|
|
13
|
+
const i18n = useI18n()
|
|
14
|
+
const [local, rest] = splitProps(props, ["class", "className", "style", "toastOptions", "swipeDirections"])
|
|
15
|
+
onMount(() => {
|
|
16
|
+
const sync = () => {
|
|
17
|
+
document.querySelectorAll<HTMLElement>(".toast-v2-region .toast-v2").forEach((element) => {
|
|
18
|
+
const hidden = element.dataset.visible === "false"
|
|
19
|
+
element.inert = hidden
|
|
20
|
+
element.tabIndex = hidden ? -1 : 0
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
let connected = false
|
|
24
|
+
const connect = () => {
|
|
25
|
+
const regions = document.querySelectorAll(".toast-v2-region")
|
|
26
|
+
if (!regions.length) return
|
|
27
|
+
observer.disconnect()
|
|
28
|
+
regions.forEach((region) => {
|
|
29
|
+
observer.observe(region, {
|
|
30
|
+
subtree: true,
|
|
31
|
+
childList: true,
|
|
32
|
+
attributes: true,
|
|
33
|
+
attributeFilter: ["data-visible"],
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
connected = true
|
|
37
|
+
sync()
|
|
38
|
+
}
|
|
39
|
+
const observer = new MutationObserver(() => {
|
|
40
|
+
if (!connected) connect()
|
|
41
|
+
else sync()
|
|
42
|
+
})
|
|
43
|
+
observer.observe(document.body, { subtree: true, childList: true })
|
|
44
|
+
queueMicrotask(connect)
|
|
45
|
+
onCleanup(() => observer.disconnect())
|
|
46
|
+
})
|
|
12
47
|
return (
|
|
13
48
|
<Portal>
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
49
|
+
<Toaster
|
|
50
|
+
position={isRTL(i18n.locale()) ? "bottom-left" : "bottom-right"}
|
|
51
|
+
offset={isRTL(i18n.locale()) ? { left: 32, bottom: 48 } : { right: 32, bottom: 48 }}
|
|
52
|
+
mobileOffset={16}
|
|
53
|
+
gap={12}
|
|
54
|
+
duration={5000}
|
|
55
|
+
swipeDirections={["bottom"]}
|
|
56
|
+
className={["toast-v2-region", local.className, local.class].filter(Boolean).join(" ")}
|
|
57
|
+
style={{ "--width": "320px", ...local.style } as JSX.CSSProperties}
|
|
58
|
+
toastOptions={{
|
|
59
|
+
...local.toastOptions,
|
|
60
|
+
unstyled: true,
|
|
61
|
+
closeButton: true,
|
|
62
|
+
closeButtonAriaLabel: local.toastOptions?.closeButtonAriaLabel ?? i18n.t("ui.common.dismiss"),
|
|
63
|
+
}}
|
|
64
|
+
{...rest}
|
|
65
|
+
/>
|
|
17
66
|
</Portal>
|
|
18
67
|
)
|
|
19
68
|
}
|
|
20
69
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
70
|
+
const ToastV2Context = createContext<number>()
|
|
71
|
+
|
|
72
|
+
export interface ToastV2RootComponentProps {
|
|
73
|
+
toastId: number
|
|
24
74
|
children?: JSX.Element
|
|
25
75
|
}
|
|
26
76
|
|
|
27
77
|
function ToastV2Root(props: ToastV2RootComponentProps) {
|
|
28
|
-
return
|
|
29
|
-
<Kobalte
|
|
30
|
-
data-component="toast-v2"
|
|
31
|
-
classList={{
|
|
32
|
-
...props.classList,
|
|
33
|
-
[props.class ?? ""]: !!props.class,
|
|
34
|
-
}}
|
|
35
|
-
{...props}
|
|
36
|
-
/>
|
|
37
|
-
)
|
|
78
|
+
return <ToastV2Context.Provider value={props.toastId}>{props.children}</ToastV2Context.Provider>
|
|
38
79
|
}
|
|
39
80
|
|
|
40
81
|
function ToastV2Icon(props: ComponentProps<"div">) {
|
|
@@ -45,26 +86,44 @@ function ToastV2Content(props: ComponentProps<"div">) {
|
|
|
45
86
|
return <div data-slot="toast-v2-content" {...props} />
|
|
46
87
|
}
|
|
47
88
|
|
|
48
|
-
function ToastV2Title(props:
|
|
49
|
-
return <
|
|
89
|
+
function ToastV2Title(props: ComponentProps<"div">) {
|
|
90
|
+
return <div data-slot="toast-v2-title" {...props} />
|
|
50
91
|
}
|
|
51
92
|
|
|
52
|
-
function ToastV2Description(props:
|
|
53
|
-
return <
|
|
93
|
+
function ToastV2Description(props: ComponentProps<"div">) {
|
|
94
|
+
return <div data-slot="toast-v2-description" {...props} />
|
|
54
95
|
}
|
|
55
96
|
|
|
56
97
|
function ToastV2Actions(props: ComponentProps<"div">) {
|
|
57
98
|
return <div data-slot="toast-v2-actions" {...props} />
|
|
58
99
|
}
|
|
59
100
|
|
|
60
|
-
function ToastV2CloseButton(props:
|
|
101
|
+
function ToastV2CloseButton(props: ComponentProps<"button">) {
|
|
102
|
+
const i18n = useI18n()
|
|
103
|
+
const toastId = useContext(ToastV2Context)
|
|
104
|
+
const [local, rest] = splitProps(props, ["children", "onClick"])
|
|
61
105
|
return (
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
data-slot="toast-v2-close-button"
|
|
109
|
+
aria-label={i18n.t("ui.common.dismiss")}
|
|
110
|
+
{...rest}
|
|
111
|
+
onClick={(event) => {
|
|
112
|
+
if (typeof local.onClick === "function") local.onClick(event)
|
|
113
|
+
if (!event.defaultPrevented && toastId !== undefined) toasterV2.dismiss(toastId)
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
{local.children ?? <CloseIcon />}
|
|
117
|
+
</button>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function CloseIcon() {
|
|
122
|
+
return (
|
|
123
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
124
|
+
<path d="M4.25 11.75L11.75 4.25" stroke="currentColor" />
|
|
125
|
+
<path d="M11.75 11.75L4.25 4.25" stroke="currentColor" />
|
|
126
|
+
</svg>
|
|
68
127
|
)
|
|
69
128
|
}
|
|
70
129
|
|
|
@@ -78,7 +137,29 @@ export const ToastV2 = Object.assign(ToastV2Root, {
|
|
|
78
137
|
CloseButton: ToastV2CloseButton,
|
|
79
138
|
})
|
|
80
139
|
|
|
81
|
-
|
|
140
|
+
let toastV2Id = 0
|
|
141
|
+
|
|
142
|
+
export const toasterV2 = {
|
|
143
|
+
show(render: (props: { toastId: number }) => JSX.Element, options?: { duration?: number; persistent?: boolean }) {
|
|
144
|
+
const toastId = --toastV2Id
|
|
145
|
+
toast.custom((id) => render({ toastId: Number(id) }), {
|
|
146
|
+
id: toastId,
|
|
147
|
+
className: "toast-v2",
|
|
148
|
+
duration: options?.persistent ? Number.POSITIVE_INFINITY : options?.duration,
|
|
149
|
+
unstyled: true,
|
|
150
|
+
})
|
|
151
|
+
return toastId
|
|
152
|
+
},
|
|
153
|
+
dismiss(toastId?: number) {
|
|
154
|
+
if (toastId === undefined) {
|
|
155
|
+
activeToastV2ByKey.clear()
|
|
156
|
+
activeToastV2ById.clear()
|
|
157
|
+
} else {
|
|
158
|
+
releaseToastV2(activeToastV2ById.get(toastId))
|
|
159
|
+
}
|
|
160
|
+
return toast.dismiss(toastId)
|
|
161
|
+
},
|
|
162
|
+
}
|
|
82
163
|
|
|
83
164
|
export interface ToastV2Action {
|
|
84
165
|
label: string
|
|
@@ -90,53 +171,107 @@ export interface ToastV2Options {
|
|
|
90
171
|
title?: string
|
|
91
172
|
description?: string
|
|
92
173
|
icon?: JSX.Element
|
|
174
|
+
variant?: "default" | "success" | "error" | "loading"
|
|
93
175
|
duration?: number
|
|
94
176
|
persistent?: boolean
|
|
95
177
|
actions?: ToastV2Action[]
|
|
96
178
|
}
|
|
97
179
|
|
|
180
|
+
interface ActiveToastV2 {
|
|
181
|
+
id: number
|
|
182
|
+
key: string
|
|
183
|
+
options: ToastV2Options
|
|
184
|
+
actions?: JSX.Element
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const activeToastV2ByKey = new Map<string, ActiveToastV2>()
|
|
188
|
+
const activeToastV2ById = new Map<number, ActiveToastV2>()
|
|
189
|
+
|
|
98
190
|
export function showToastV2(options: ToastV2Options | string) {
|
|
99
|
-
const opts = typeof options === "string" ? { description: options } : options
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
</Show>
|
|
108
|
-
<ToastV2.Content>
|
|
109
|
-
<Show when={opts.title}>
|
|
110
|
-
<ToastV2.Title>{opts.title}</ToastV2.Title>
|
|
111
|
-
</Show>
|
|
112
|
-
<Show when={opts.description}>
|
|
113
|
-
<ToastV2.Description>{opts.description}</ToastV2.Description>
|
|
114
|
-
</Show>
|
|
115
|
-
</ToastV2.Content>
|
|
116
|
-
<ToastV2.CloseButton />
|
|
117
|
-
</div>
|
|
118
|
-
<Show when={opts.actions?.length}>
|
|
119
|
-
<ToastV2.Actions>
|
|
120
|
-
{opts.actions!.map((action) => (
|
|
121
|
-
<ButtonV2
|
|
122
|
-
variant={action.variant === "secondary" ? "ghost" : "neutral"}
|
|
123
|
-
size="small"
|
|
124
|
-
data-action-variant={action.variant ?? "primary"}
|
|
125
|
-
onClick={() => {
|
|
126
|
-
if (typeof action.onClick === "function") {
|
|
127
|
-
action.onClick()
|
|
128
|
-
}
|
|
129
|
-
toaster.dismiss(props.toastId)
|
|
130
|
-
}}
|
|
131
|
-
>
|
|
132
|
-
{action.label}
|
|
133
|
-
</ButtonV2>
|
|
134
|
-
))}
|
|
135
|
-
</ToastV2.Actions>
|
|
136
|
-
</Show>
|
|
137
|
-
</ToastV2>
|
|
138
|
-
)
|
|
191
|
+
const opts: ToastV2Options = typeof options === "string" ? { description: options } : options
|
|
192
|
+
const key = JSON.stringify({
|
|
193
|
+
title: opts.title,
|
|
194
|
+
description: opts.description,
|
|
195
|
+
variant: opts.variant,
|
|
196
|
+
duration: opts.duration,
|
|
197
|
+
persistent: opts.persistent,
|
|
198
|
+
actions: opts.actions?.map((action) => [action.label, action.variant]),
|
|
139
199
|
})
|
|
200
|
+
const active = activeToastV2ByKey.get(key)
|
|
201
|
+
const toasts = toast.getToasts()
|
|
202
|
+
|
|
203
|
+
if (active && toasts.at(-1)?.id === active.id) {
|
|
204
|
+
active.options = opts
|
|
205
|
+
publishToastV2(active)
|
|
206
|
+
pulseToastV2(active.id)
|
|
207
|
+
return active.id
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (active && toasts.some((item) => item.id === active.id)) toasterV2.dismiss(active.id)
|
|
211
|
+
releaseToastV2(active)
|
|
212
|
+
|
|
213
|
+
const entry: ActiveToastV2 = { id: --toastV2Id, key, options: opts }
|
|
214
|
+
entry.actions = createToastV2Actions(entry)
|
|
215
|
+
activeToastV2ByKey.set(key, entry)
|
|
216
|
+
activeToastV2ById.set(entry.id, entry)
|
|
217
|
+
publishToastV2(entry)
|
|
218
|
+
return entry.id
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function publishToastV2(entry: ActiveToastV2) {
|
|
222
|
+
const release = () => releaseToastV2(entry)
|
|
223
|
+
toast(entry.options.title ?? "", {
|
|
224
|
+
id: entry.id,
|
|
225
|
+
description: entry.options.description,
|
|
226
|
+
icon: entry.options.icon,
|
|
227
|
+
action: entry.actions,
|
|
228
|
+
closeButton: true,
|
|
229
|
+
duration: entry.options.persistent ? Number.POSITIVE_INFINITY : entry.options.duration,
|
|
230
|
+
className: `toast-v2 toast-v2--${entry.options.variant ?? "default"}`,
|
|
231
|
+
testId: `toast-v2-${entry.id}`,
|
|
232
|
+
unstyled: true,
|
|
233
|
+
onDismiss: release,
|
|
234
|
+
onAutoClose: release,
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function createToastV2Actions(entry: ActiveToastV2) {
|
|
239
|
+
if (!entry.options.actions?.length) return undefined
|
|
240
|
+
return (
|
|
241
|
+
<ToastV2.Actions>
|
|
242
|
+
{entry.options.actions.map((action, index) => (
|
|
243
|
+
<button
|
|
244
|
+
type="button"
|
|
245
|
+
data-component="button-v2"
|
|
246
|
+
data-variant={action.variant === "secondary" ? "ghost" : "neutral"}
|
|
247
|
+
data-size="small"
|
|
248
|
+
data-action-variant={action.variant ?? "primary"}
|
|
249
|
+
onClick={() => {
|
|
250
|
+
const onClick = entry.options.actions?.[index]?.onClick
|
|
251
|
+
if (typeof onClick === "function") onClick()
|
|
252
|
+
toasterV2.dismiss(entry.id)
|
|
253
|
+
}}
|
|
254
|
+
>
|
|
255
|
+
{action.label}
|
|
256
|
+
</button>
|
|
257
|
+
))}
|
|
258
|
+
</ToastV2.Actions>
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function pulseToastV2(toastId: number) {
|
|
263
|
+
if (typeof document === "undefined" || typeof requestAnimationFrame === "undefined") return
|
|
264
|
+
requestAnimationFrame(() => {
|
|
265
|
+
const element = document.querySelector<HTMLElement>(`[data-testid="toast-v2-${toastId}"]`)
|
|
266
|
+
if (!element || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return
|
|
267
|
+
element.animate([{ scale: 1 }, { scale: 1.025 }, { scale: 1 }], { duration: 160, easing: "ease-out" })
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function releaseToastV2(entry: ActiveToastV2 | undefined) {
|
|
272
|
+
if (!entry) return
|
|
273
|
+
if (activeToastV2ByKey.get(entry.key) === entry) activeToastV2ByKey.delete(entry.key)
|
|
274
|
+
if (activeToastV2ById.get(entry.id) === entry) activeToastV2ById.delete(entry.id)
|
|
140
275
|
}
|
|
141
276
|
|
|
142
277
|
export interface ToastV2PromiseOptions<T, U = unknown> {
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { MarkedExtension } from "marked"
|
|
2
|
-
|
|
3
|
-
// Keep adjacent tilde and backtick runs separate until markedjs/marked#4011 is released.
|
|
4
|
-
export const markedCodeSpanBoundary = {
|
|
5
|
-
tokenizer: {
|
|
6
|
-
inlineText(src) {
|
|
7
|
-
const match = /^(`+(?=~)|~+(?=`))/.exec(src)
|
|
8
|
-
if (!match) return false
|
|
9
|
-
return {
|
|
10
|
-
type: "text",
|
|
11
|
-
raw: match[0],
|
|
12
|
-
text: match[0],
|
|
13
|
-
escaped: this.lexer.state.inRawBlock,
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
} satisfies MarkedExtension
|