@krak-stack/registry 0.10.19 → 0.10.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/CHANGELOG.md +25 -0
- package/README.md +18 -0
- package/dist/components/ui/code-block.js +7 -7
- package/dist/components/ui/copy-button.js +7 -7
- package/dist/components/ui/copy-value.js +7 -7
- package/dist/components/ui/data-table.d.ts +3 -3
- package/dist/components/ui/data-table.js +23 -17
- package/dist/components/ui/editing-locale-switcher.js +7 -7
- package/dist/components/ui/effect-form.js +8 -8
- package/dist/components/ui/email-composer.js +871 -0
- package/dist/components/ui/email-editor.d.ts +3 -1
- package/dist/components/ui/email-editor.js +294 -471
- package/dist/components/ui/error-component.js +7 -7
- package/dist/components/ui/form.d.ts +7 -7
- package/dist/components/ui/form.js +18 -14
- package/dist/components/ui/icon-input.js +1 -1
- package/dist/components/ui/map-menu.d.ts +1 -1
- package/dist/components/ui/map-menu.js +183 -60
- package/dist/components/ui/pagination.js +7 -7
- package/dist/components/ui/phone-number-input.js +1 -1
- package/dist/components/ui/rich-text-editor.d.ts +15 -13
- package/dist/components/ui/rich-text-editor.js +280 -661
- package/dist/components/ui/select-with-custom-input.js +7 -7
- package/dist/components/ui/select.js +159 -0
- package/dist/components/ui/timezone-select.js +1 -1
- package/dist/components/ui/virtualized-combobox.js +1 -1
- package/dist/lib/docs.js +7 -7
- package/dist/lib/email-composer/index.js +110 -0
- package/dist/lib/email-composer/schema.js +13 -0
- package/dist/lib/email-document/legacy-rich-text/editor.d.ts +70 -0
- package/dist/lib/email-document/legacy-rich-text/schema.d.ts +65 -0
- package/dist/lib/email-document/legacy-rich-text/tiptap.d.ts +39 -0
- package/dist/lib/email-document/model.d.ts +1 -1
- package/dist/lib/email-document/model.js +2 -2
- package/dist/lib/email-document/render.js +2 -2
- package/dist/lib/email-document/schema.js +1 -1
- package/dist/lib/rich-text/model.js +79 -111
- package/dist/lib/rich-text/schema.d.ts +5 -55
- package/dist/lib/rich-text/schema.js +17 -36
- package/dist/lib/rich-text/tiptap.d.ts +12 -0
- package/dist/services/agent/client/index.js +7 -7
- package/dist/services/events/client/audit-log-table.js +23 -17
- package/dist/services/webhooks/client/delivery-table.js +30 -24
- package/package.json +24 -1
- package/dist/lib/rich-text/dom.d.ts +0 -40
- /package/dist/lib/{rich-text → email-document/legacy-rich-text}/model.d.ts +0 -0
|
@@ -40,7 +40,7 @@ function SelectTrigger({
|
|
|
40
40
|
return /* @__PURE__ */ jsxs(SelectPrimitive.Trigger, {
|
|
41
41
|
"data-slot": "select-trigger",
|
|
42
42
|
"data-size": size,
|
|
43
|
-
className: cn("flex w-fit items-center justify-between gap-1.5 rounded-md border
|
|
43
|
+
className: cn("border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 flex w-fit items-center justify-between gap-1.5 rounded-md border bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
44
44
|
...props,
|
|
45
45
|
children: [
|
|
46
46
|
children,
|
|
@@ -57,9 +57,9 @@ function SelectContent({
|
|
|
57
57
|
children,
|
|
58
58
|
side = "bottom",
|
|
59
59
|
sideOffset = 4,
|
|
60
|
-
align = "
|
|
60
|
+
align = "start",
|
|
61
61
|
alignOffset = 0,
|
|
62
|
-
alignItemWithTrigger =
|
|
62
|
+
alignItemWithTrigger = false,
|
|
63
63
|
...props
|
|
64
64
|
}) {
|
|
65
65
|
return /* @__PURE__ */ jsx2(SelectPrimitive.Portal, {
|
|
@@ -73,7 +73,7 @@ function SelectContent({
|
|
|
73
73
|
children: /* @__PURE__ */ jsxs(SelectPrimitive.Popup, {
|
|
74
74
|
"data-slot": "select-content",
|
|
75
75
|
"data-align-trigger": alignItemWithTrigger,
|
|
76
|
-
className: cn("
|
|
76
|
+
className: cn("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md shadow-md ring-1 duration-100 data-[align-trigger=true]:animate-none", className),
|
|
77
77
|
...props,
|
|
78
78
|
children: [
|
|
79
79
|
/* @__PURE__ */ jsx2(SelectScrollUpButton, {}),
|
|
@@ -93,7 +93,7 @@ function SelectItem({
|
|
|
93
93
|
}) {
|
|
94
94
|
return /* @__PURE__ */ jsxs(SelectPrimitive.Item, {
|
|
95
95
|
"data-slot": "select-item",
|
|
96
|
-
className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none
|
|
96
|
+
className: cn("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
|
|
97
97
|
...props,
|
|
98
98
|
children: [
|
|
99
99
|
/* @__PURE__ */ jsx2(SelectPrimitive.ItemText, {
|
|
@@ -117,7 +117,7 @@ function SelectScrollUpButton({
|
|
|
117
117
|
}) {
|
|
118
118
|
return /* @__PURE__ */ jsx2(SelectPrimitive.ScrollUpArrow, {
|
|
119
119
|
"data-slot": "select-scroll-up-button",
|
|
120
|
-
className: cn("top-0 z-10 flex w-full cursor-default items-center justify-center
|
|
120
|
+
className: cn("bg-popover top-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
121
121
|
...props,
|
|
122
122
|
children: /* @__PURE__ */ jsx2(ChevronUpIcon, {})
|
|
123
123
|
});
|
|
@@ -128,7 +128,7 @@ function SelectScrollDownButton({
|
|
|
128
128
|
}) {
|
|
129
129
|
return /* @__PURE__ */ jsx2(SelectPrimitive.ScrollDownArrow, {
|
|
130
130
|
"data-slot": "select-scroll-down-button",
|
|
131
|
-
className: cn("bottom-0 z-10 flex w-full cursor-default items-center justify-center
|
|
131
|
+
className: cn("bg-popover bottom-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
132
132
|
...props,
|
|
133
133
|
children: /* @__PURE__ */ jsx2(ChevronDownIcon, {})
|
|
134
134
|
});
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// ../../src/components/ui/select.tsx
|
|
2
|
+
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
3
|
+
|
|
4
|
+
// ../../src/lib/utils.ts
|
|
5
|
+
import { cn } from "cn";
|
|
6
|
+
|
|
7
|
+
// ../../src/components/ui/select.tsx
|
|
8
|
+
import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
"use client";
|
|
11
|
+
var Select = SelectPrimitive.Root;
|
|
12
|
+
function SelectGroup({ className, ...props }) {
|
|
13
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Group, {
|
|
14
|
+
"data-slot": "select-group",
|
|
15
|
+
className: cn("scroll-my-1 p-1", className),
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function SelectValue({ className, ...props }) {
|
|
20
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Value, {
|
|
21
|
+
"data-slot": "select-value",
|
|
22
|
+
className: cn("flex flex-1 text-left", className),
|
|
23
|
+
...props
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function SelectTrigger({
|
|
27
|
+
className,
|
|
28
|
+
size = "default",
|
|
29
|
+
children,
|
|
30
|
+
...props
|
|
31
|
+
}) {
|
|
32
|
+
return /* @__PURE__ */ jsxs(SelectPrimitive.Trigger, {
|
|
33
|
+
"data-slot": "select-trigger",
|
|
34
|
+
"data-size": size,
|
|
35
|
+
className: cn("border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 flex w-fit items-center justify-between gap-1.5 rounded-md border bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
36
|
+
...props,
|
|
37
|
+
children: [
|
|
38
|
+
children,
|
|
39
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Icon, {
|
|
40
|
+
render: /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
41
|
+
className: "text-muted-foreground pointer-events-none size-4"
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function SelectContent({
|
|
48
|
+
className,
|
|
49
|
+
children,
|
|
50
|
+
side = "bottom",
|
|
51
|
+
sideOffset = 4,
|
|
52
|
+
align = "start",
|
|
53
|
+
alignOffset = 0,
|
|
54
|
+
alignItemWithTrigger = false,
|
|
55
|
+
...props
|
|
56
|
+
}) {
|
|
57
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Portal, {
|
|
58
|
+
children: /* @__PURE__ */ jsx(SelectPrimitive.Positioner, {
|
|
59
|
+
side,
|
|
60
|
+
sideOffset,
|
|
61
|
+
align,
|
|
62
|
+
alignOffset,
|
|
63
|
+
alignItemWithTrigger,
|
|
64
|
+
className: "isolate z-50",
|
|
65
|
+
children: /* @__PURE__ */ jsxs(SelectPrimitive.Popup, {
|
|
66
|
+
"data-slot": "select-content",
|
|
67
|
+
"data-align-trigger": alignItemWithTrigger,
|
|
68
|
+
className: cn("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md shadow-md ring-1 duration-100 data-[align-trigger=true]:animate-none", className),
|
|
69
|
+
...props,
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
72
|
+
/* @__PURE__ */ jsx(SelectPrimitive.List, {
|
|
73
|
+
children
|
|
74
|
+
}),
|
|
75
|
+
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
76
|
+
]
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function SelectLabel({
|
|
82
|
+
className,
|
|
83
|
+
...props
|
|
84
|
+
}) {
|
|
85
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.GroupLabel, {
|
|
86
|
+
"data-slot": "select-label",
|
|
87
|
+
className: cn("text-muted-foreground px-2 py-1.5 text-xs", className),
|
|
88
|
+
...props
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function SelectItem({
|
|
92
|
+
className,
|
|
93
|
+
children,
|
|
94
|
+
...props
|
|
95
|
+
}) {
|
|
96
|
+
return /* @__PURE__ */ jsxs(SelectPrimitive.Item, {
|
|
97
|
+
"data-slot": "select-item",
|
|
98
|
+
className: cn("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
|
|
99
|
+
...props,
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, {
|
|
102
|
+
className: "flex flex-1 shrink-0 gap-2 whitespace-nowrap",
|
|
103
|
+
children
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, {
|
|
106
|
+
render: /* @__PURE__ */ jsx("span", {
|
|
107
|
+
className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center"
|
|
108
|
+
}),
|
|
109
|
+
children: /* @__PURE__ */ jsx(CheckIcon, {
|
|
110
|
+
className: "pointer-events-none"
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function SelectSeparator({
|
|
117
|
+
className,
|
|
118
|
+
...props
|
|
119
|
+
}) {
|
|
120
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Separator, {
|
|
121
|
+
"data-slot": "select-separator",
|
|
122
|
+
className: cn("bg-border pointer-events-none -mx-1 my-1 h-px", className),
|
|
123
|
+
...props
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function SelectScrollUpButton({
|
|
127
|
+
className,
|
|
128
|
+
...props
|
|
129
|
+
}) {
|
|
130
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.ScrollUpArrow, {
|
|
131
|
+
"data-slot": "select-scroll-up-button",
|
|
132
|
+
className: cn("bg-popover top-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
133
|
+
...props,
|
|
134
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, {})
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function SelectScrollDownButton({
|
|
138
|
+
className,
|
|
139
|
+
...props
|
|
140
|
+
}) {
|
|
141
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.ScrollDownArrow, {
|
|
142
|
+
"data-slot": "select-scroll-down-button",
|
|
143
|
+
className: cn("bg-popover bottom-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
144
|
+
...props,
|
|
145
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
Select,
|
|
150
|
+
SelectContent,
|
|
151
|
+
SelectGroup,
|
|
152
|
+
SelectItem,
|
|
153
|
+
SelectLabel,
|
|
154
|
+
SelectScrollDownButton,
|
|
155
|
+
SelectScrollUpButton,
|
|
156
|
+
SelectSeparator,
|
|
157
|
+
SelectTrigger,
|
|
158
|
+
SelectValue
|
|
159
|
+
};
|
|
@@ -337,7 +337,7 @@ var defaultClear = (label) => /* @__PURE__ */ jsx4(ComboboxPrimitive.Clear, {
|
|
|
337
337
|
})
|
|
338
338
|
});
|
|
339
339
|
var selectedLabel = (value, placeholder) => {
|
|
340
|
-
if (
|
|
340
|
+
if (value && !("label" in value)) {
|
|
341
341
|
return value.length > 0 ? value.map(({ label }) => label).join(", ") : placeholder;
|
|
342
342
|
}
|
|
343
343
|
return value && "label" in value ? value.label : placeholder;
|
|
@@ -331,7 +331,7 @@ var defaultClear = (label) => /* @__PURE__ */ jsx4(ComboboxPrimitive.Clear, {
|
|
|
331
331
|
})
|
|
332
332
|
});
|
|
333
333
|
var selectedLabel = (value, placeholder) => {
|
|
334
|
-
if (
|
|
334
|
+
if (value && !("label" in value)) {
|
|
335
335
|
return value.length > 0 ? value.map(({ label }) => label).join(", ") : placeholder;
|
|
336
336
|
}
|
|
337
337
|
return value && "label" in value ? value.label : placeholder;
|
package/dist/lib/docs.js
CHANGED
|
@@ -261,16 +261,16 @@ function CopyButton({
|
|
|
261
261
|
clearTimeout(copyTimeout.current);
|
|
262
262
|
copyTimeout.current = setTimeout(() => setCopyState("idle"), resetDelay);
|
|
263
263
|
};
|
|
264
|
-
const copy =
|
|
265
|
-
|
|
266
|
-
await navigator.clipboard.writeText(value);
|
|
264
|
+
const copy = () => {
|
|
265
|
+
Promise.resolve().then(() => navigator.clipboard.writeText(value)).then(() => {
|
|
267
266
|
setCopyState("copied");
|
|
268
267
|
onCopied?.();
|
|
269
|
-
|
|
268
|
+
resetCopyState();
|
|
269
|
+
}).catch((cause) => {
|
|
270
270
|
setCopyState("failed");
|
|
271
|
-
onCopyError?.(
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
onCopyError?.(cause instanceof Error ? cause : new Error(labels.copyFailed, { cause }));
|
|
272
|
+
resetCopyState();
|
|
273
|
+
});
|
|
274
274
|
};
|
|
275
275
|
const status = copyState === "copied" ? valueDescription ? `${labels.copied}: ${valueDescription}` : labels.copied : copyState === "failed" ? valueDescription ? `${labels.copyFailed}: ${valueDescription}` : labels.copyFailed : "";
|
|
276
276
|
return /* @__PURE__ */ jsxs2(Button, {
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// ../../src/lib/email-composer/index.ts
|
|
2
|
+
import { composeReactEmail, EmailNode } from "@react-email/editor/core";
|
|
3
|
+
import { StarterKit as StarterKit2 } from "@react-email/editor/extensions";
|
|
4
|
+
import { Effect, Schema as Schema4 } from "effect";
|
|
5
|
+
|
|
6
|
+
// ../../src/lib/rich-text/tiptap.ts
|
|
7
|
+
import { Extension } from "@tiptap/core";
|
|
8
|
+
import Mention from "@tiptap/extension-mention";
|
|
9
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
10
|
+
import { Plugin } from "@tiptap/pm/state";
|
|
11
|
+
import { Schema as Schema2 } from "effect";
|
|
12
|
+
|
|
13
|
+
// ../../src/lib/rich-text/schema.ts
|
|
14
|
+
import { Schema } from "effect";
|
|
15
|
+
var RichTextLink = Schema.String.check(Schema.isMaxLength(2000), Schema.makeFilter((value) => {
|
|
16
|
+
if (/[\s\p{Cc}\\{}]/u.test(value))
|
|
17
|
+
return false;
|
|
18
|
+
const url = URL.parse(value);
|
|
19
|
+
return url !== null && ["https:", "mailto:"].includes(url.protocol) && !url.username && !url.password;
|
|
20
|
+
})).annotate({ identifier: "RichTextLink" });
|
|
21
|
+
var attributes = Schema.Record(Schema.String, Schema.Json);
|
|
22
|
+
var variableKey = Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/));
|
|
23
|
+
var mark = Schema.Struct({
|
|
24
|
+
type: Schema.String,
|
|
25
|
+
attrs: Schema.optional(attributes)
|
|
26
|
+
}).check(Schema.makeFilter((value) => value.type !== "link" || Schema.is(RichTextLink)(value.attrs?.href)));
|
|
27
|
+
var TiptapNode = Schema.Struct({
|
|
28
|
+
type: Schema.String,
|
|
29
|
+
attrs: Schema.optional(attributes),
|
|
30
|
+
content: Schema.optional(Schema.mutable(Schema.Array(Schema.suspend(() => TiptapNode)))),
|
|
31
|
+
marks: Schema.optional(Schema.mutable(Schema.Array(mark))),
|
|
32
|
+
text: Schema.optional(Schema.String)
|
|
33
|
+
}).check(Schema.makeFilter((node) => node.type !== "mention" || Schema.is(variableKey)(node.attrs?.id))).annotate({ identifier: "TiptapNode" });
|
|
34
|
+
var RichTextDocument = TiptapNode.check(Schema.makeFilter((node) => node.type === "doc")).annotate({ identifier: "TiptapDocument" });
|
|
35
|
+
var RichTextVariable = Schema.Struct({
|
|
36
|
+
key: variableKey,
|
|
37
|
+
label: Schema.String,
|
|
38
|
+
type: Schema.Literals(["text", "url"]),
|
|
39
|
+
sample: Schema.String
|
|
40
|
+
}).annotate({ identifier: "RichTextVariable" });
|
|
41
|
+
|
|
42
|
+
// ../../src/lib/rich-text/tiptap.ts
|
|
43
|
+
var richTextMention = (variables = () => []) => Mention.configure({
|
|
44
|
+
deleteTriggerWithBackspace: true,
|
|
45
|
+
HTMLAttributes: {
|
|
46
|
+
class: "rounded bg-primary/10 px-1 font-mono text-primary",
|
|
47
|
+
contenteditable: "false"
|
|
48
|
+
},
|
|
49
|
+
renderText: ({ node }) => `{{${node.attrs.id}}}`,
|
|
50
|
+
renderHTML: ({ node }) => {
|
|
51
|
+
const id = Schema2.decodeUnknownSync(RichTextVariable.fields.key)(node.attrs.id);
|
|
52
|
+
const label = variables().find((variable) => variable.key === id)?.label ?? node.attrs.label ?? id;
|
|
53
|
+
return [
|
|
54
|
+
"span",
|
|
55
|
+
{
|
|
56
|
+
"data-type": "mention",
|
|
57
|
+
"data-id": id,
|
|
58
|
+
contenteditable: "false",
|
|
59
|
+
class: "rounded bg-primary/10 px-1 font-mono text-primary"
|
|
60
|
+
},
|
|
61
|
+
`{{${label}}}`
|
|
62
|
+
];
|
|
63
|
+
},
|
|
64
|
+
suggestion: { items: () => [] }
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// ../../src/lib/email-composer/schema.ts
|
|
68
|
+
import { Schema as Schema3 } from "effect";
|
|
69
|
+
var EmailExport = Schema3.Struct({
|
|
70
|
+
html: Schema3.String,
|
|
71
|
+
text: Schema3.String
|
|
72
|
+
}).annotate({ identifier: "EmailExport" });
|
|
73
|
+
|
|
74
|
+
class EmailComposerExportError extends Schema3.TaggedError()("EmailComposerExportError", { cause: Schema3.Defect() }) {
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ../../src/lib/email-composer/index.ts
|
|
78
|
+
var createEmailComposerExtensions = (resolveVariable = (key) => `{{${key}}}`) => [
|
|
79
|
+
StarterKit2.configure({
|
|
80
|
+
Link: {
|
|
81
|
+
openOnClick: false,
|
|
82
|
+
autolink: false,
|
|
83
|
+
linkOnPaste: false,
|
|
84
|
+
isAllowedUri: (url) => Schema4.is(RichTextLink)(url)
|
|
85
|
+
},
|
|
86
|
+
TwoColumns: false,
|
|
87
|
+
ThreeColumns: false,
|
|
88
|
+
FourColumns: false,
|
|
89
|
+
ColumnsColumn: false
|
|
90
|
+
}),
|
|
91
|
+
EmailNode.from(richTextMention(), ({ node }) => resolveVariable(Schema4.decodeUnknownSync(RichTextVariable.fields.key)(node.attrs?.id)))
|
|
92
|
+
];
|
|
93
|
+
var emailComposerExtensions = createEmailComposerExtensions();
|
|
94
|
+
var exportEmail = Effect.fn("EmailComposer.export")(function* ({
|
|
95
|
+
editor
|
|
96
|
+
}) {
|
|
97
|
+
const result = yield* Effect.tryPromise({
|
|
98
|
+
try: () => composeReactEmail({ editor, pretty: false }),
|
|
99
|
+
catch: (cause) => new EmailComposerExportError({ cause })
|
|
100
|
+
});
|
|
101
|
+
return yield* Schema4.decodeEffect(EmailExport)({
|
|
102
|
+
html: result.unformattedHtml,
|
|
103
|
+
text: result.text
|
|
104
|
+
}).pipe(Effect.mapError((cause) => new EmailComposerExportError({ cause })));
|
|
105
|
+
});
|
|
106
|
+
export {
|
|
107
|
+
createEmailComposerExtensions,
|
|
108
|
+
emailComposerExtensions,
|
|
109
|
+
exportEmail
|
|
110
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// ../../src/lib/email-composer/schema.ts
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
var EmailExport = Schema.Struct({
|
|
4
|
+
html: Schema.String,
|
|
5
|
+
text: Schema.String
|
|
6
|
+
}).annotate({ identifier: "EmailExport" });
|
|
7
|
+
|
|
8
|
+
class EmailComposerExportError extends Schema.TaggedError()("EmailComposerExportError", { cause: Schema.Defect() }) {
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
EmailComposerExportError,
|
|
12
|
+
EmailExport
|
|
13
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
2
|
+
import { RichTextDocument, type RichTextVariable } from "./schema.js";
|
|
3
|
+
declare const labels: {
|
|
4
|
+
en: {
|
|
5
|
+
bold: string;
|
|
6
|
+
italic: string;
|
|
7
|
+
underline: string;
|
|
8
|
+
undo: string;
|
|
9
|
+
redo: string;
|
|
10
|
+
link: string;
|
|
11
|
+
unlink: string;
|
|
12
|
+
linkUrl: string;
|
|
13
|
+
apply: string;
|
|
14
|
+
variable: string;
|
|
15
|
+
paragraph: string;
|
|
16
|
+
heading: string;
|
|
17
|
+
bullet: string;
|
|
18
|
+
numbered: string;
|
|
19
|
+
toolbar: string;
|
|
20
|
+
invalid: string;
|
|
21
|
+
invalidLink: string;
|
|
22
|
+
cancel: string;
|
|
23
|
+
};
|
|
24
|
+
fr: {
|
|
25
|
+
bold: string;
|
|
26
|
+
italic: string;
|
|
27
|
+
underline: string;
|
|
28
|
+
undo: string;
|
|
29
|
+
redo: string;
|
|
30
|
+
link: string;
|
|
31
|
+
unlink: string;
|
|
32
|
+
linkUrl: string;
|
|
33
|
+
apply: string;
|
|
34
|
+
variable: string;
|
|
35
|
+
paragraph: string;
|
|
36
|
+
heading: string;
|
|
37
|
+
bullet: string;
|
|
38
|
+
numbered: string;
|
|
39
|
+
toolbar: string;
|
|
40
|
+
invalid: string;
|
|
41
|
+
invalidLink: string;
|
|
42
|
+
cancel: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export type RichTextEditorMessages = {
|
|
46
|
+
[K in keyof typeof labels.en]: string;
|
|
47
|
+
};
|
|
48
|
+
export type RichTextEditorProps = {
|
|
49
|
+
value: RichTextDocument;
|
|
50
|
+
onChange: (value: RichTextDocument) => void;
|
|
51
|
+
label: string;
|
|
52
|
+
variables?: readonly RichTextVariable[];
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
locale?: string;
|
|
55
|
+
messages?: Partial<Record<string, Partial<RichTextEditorMessages>>>;
|
|
56
|
+
className?: string;
|
|
57
|
+
contentStyle?: CSSProperties;
|
|
58
|
+
/** Plain single-line text with atomic variables, suitable for email headers. */
|
|
59
|
+
singleLine?: boolean;
|
|
60
|
+
/** Limit serialized text, including {{variable}} tokens. */
|
|
61
|
+
maxLength?: number;
|
|
62
|
+
};
|
|
63
|
+
export declare const RichTextContent: ({ value, variables, values, }: {
|
|
64
|
+
value: RichTextDocument;
|
|
65
|
+
variables?: readonly RichTextVariable[];
|
|
66
|
+
values?: Readonly<Record<string, string>>;
|
|
67
|
+
}) => import("react").JSX.Element;
|
|
68
|
+
/** Tiptap owns editing; the public value remains a constrained, HTML-free document. */
|
|
69
|
+
export declare const RichTextEditor: ({ value, onChange, label, variables, disabled, locale: override, messages, className, contentStyle, singleLine, maxLength, }: RichTextEditorProps) => import("react").JSX.Element;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** @deprecated Frozen version 1 format for the deprecated canvas Email Editor only. */
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
export declare const RichTextLink: Schema.String;
|
|
4
|
+
export declare const RichTextMarks: Schema.Struct<{
|
|
5
|
+
readonly bold: Schema.optional<Schema.Boolean>;
|
|
6
|
+
readonly italic: Schema.optional<Schema.Boolean>;
|
|
7
|
+
readonly underline: Schema.optional<Schema.Boolean>;
|
|
8
|
+
readonly href: Schema.optional<Schema.String>;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const RichTextInline: Schema.Union<readonly [Schema.Struct<{
|
|
11
|
+
readonly type: Schema.Literal<"text">;
|
|
12
|
+
readonly text: Schema.String;
|
|
13
|
+
readonly marks: Schema.optional<Schema.Struct<{
|
|
14
|
+
readonly bold: Schema.optional<Schema.Boolean>;
|
|
15
|
+
readonly italic: Schema.optional<Schema.Boolean>;
|
|
16
|
+
readonly underline: Schema.optional<Schema.Boolean>;
|
|
17
|
+
readonly href: Schema.optional<Schema.String>;
|
|
18
|
+
}>>;
|
|
19
|
+
}>, Schema.Struct<{
|
|
20
|
+
readonly type: Schema.Literal<"variable">;
|
|
21
|
+
readonly key: Schema.String;
|
|
22
|
+
readonly marks: Schema.optional<Schema.Struct<{
|
|
23
|
+
readonly bold: Schema.optional<Schema.Boolean>;
|
|
24
|
+
readonly italic: Schema.optional<Schema.Boolean>;
|
|
25
|
+
readonly underline: Schema.optional<Schema.Boolean>;
|
|
26
|
+
readonly href: Schema.optional<Schema.String>;
|
|
27
|
+
}>>;
|
|
28
|
+
}>]>;
|
|
29
|
+
export declare const RichTextBlockKind: Schema.Literals<readonly ["paragraph", "heading", "bullet", "numbered"]>;
|
|
30
|
+
export declare const RichTextDocument: Schema.Struct<{
|
|
31
|
+
readonly version: Schema.Literal<1>;
|
|
32
|
+
readonly blocks: Schema.$Array<Schema.Struct<{
|
|
33
|
+
readonly type: Schema.Literals<readonly ["paragraph", "heading", "bullet", "numbered"]>;
|
|
34
|
+
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
35
|
+
readonly type: Schema.Literal<"text">;
|
|
36
|
+
readonly text: Schema.String;
|
|
37
|
+
readonly marks: Schema.optional<Schema.Struct<{
|
|
38
|
+
readonly bold: Schema.optional<Schema.Boolean>;
|
|
39
|
+
readonly italic: Schema.optional<Schema.Boolean>;
|
|
40
|
+
readonly underline: Schema.optional<Schema.Boolean>;
|
|
41
|
+
readonly href: Schema.optional<Schema.String>;
|
|
42
|
+
}>>;
|
|
43
|
+
}>, Schema.Struct<{
|
|
44
|
+
readonly type: Schema.Literal<"variable">;
|
|
45
|
+
readonly key: Schema.String;
|
|
46
|
+
readonly marks: Schema.optional<Schema.Struct<{
|
|
47
|
+
readonly bold: Schema.optional<Schema.Boolean>;
|
|
48
|
+
readonly italic: Schema.optional<Schema.Boolean>;
|
|
49
|
+
readonly underline: Schema.optional<Schema.Boolean>;
|
|
50
|
+
readonly href: Schema.optional<Schema.String>;
|
|
51
|
+
}>>;
|
|
52
|
+
}>]>>;
|
|
53
|
+
}>>;
|
|
54
|
+
}>;
|
|
55
|
+
export declare const RichTextVariable: Schema.Struct<{
|
|
56
|
+
readonly key: Schema.String;
|
|
57
|
+
readonly label: Schema.String;
|
|
58
|
+
readonly type: Schema.Literals<readonly ["text", "url"]>;
|
|
59
|
+
readonly sample: Schema.String;
|
|
60
|
+
}>;
|
|
61
|
+
export type RichTextDocument = typeof RichTextDocument.Type;
|
|
62
|
+
export type RichTextInline = typeof RichTextInline.Type;
|
|
63
|
+
export type RichTextMarks = typeof RichTextMarks.Type;
|
|
64
|
+
export type RichTextBlockKind = typeof RichTextBlockKind.Type;
|
|
65
|
+
export type RichTextVariable = typeof RichTextVariable.Type;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @deprecated Frozen adapter for the deprecated canvas Email Editor only. */
|
|
2
|
+
import { Extension, Node, type JSONContent } from "@tiptap/core";
|
|
3
|
+
import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
|
|
4
|
+
import { Option } from "effect";
|
|
5
|
+
import { RichTextDocument, type RichTextVariable } from "./schema.js";
|
|
6
|
+
/** Only this adapter knows about Tiptap; persisted documents remain version 1. */
|
|
7
|
+
export declare const toTiptapDocument: (value: RichTextDocument, singleLine?: boolean) => JSONContent;
|
|
8
|
+
export declare const fromTiptapDocument: (doc: ProseMirrorNode) => Option.Option<{
|
|
9
|
+
readonly version: 1;
|
|
10
|
+
readonly blocks: readonly {
|
|
11
|
+
readonly type: "bullet" | "heading" | "numbered" | "paragraph";
|
|
12
|
+
readonly content: readonly ({
|
|
13
|
+
readonly type: "text";
|
|
14
|
+
readonly text: string;
|
|
15
|
+
readonly marks?: {
|
|
16
|
+
readonly bold?: boolean | undefined;
|
|
17
|
+
readonly italic?: boolean | undefined;
|
|
18
|
+
readonly underline?: boolean | undefined;
|
|
19
|
+
readonly href?: string | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: "variable";
|
|
23
|
+
readonly key: string;
|
|
24
|
+
readonly marks?: {
|
|
25
|
+
readonly bold?: boolean | undefined;
|
|
26
|
+
readonly italic?: boolean | undefined;
|
|
27
|
+
readonly underline?: boolean | undefined;
|
|
28
|
+
readonly href?: string | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
})[];
|
|
31
|
+
}[];
|
|
32
|
+
}>;
|
|
33
|
+
export type RichTextEditingOptions = {
|
|
34
|
+
singleLine?: boolean;
|
|
35
|
+
maxLength?: () => number | undefined;
|
|
36
|
+
variables?: () => readonly RichTextVariable[];
|
|
37
|
+
onInvalid?: (invalid: boolean) => void;
|
|
38
|
+
};
|
|
39
|
+
export declare const richTextExtensions: ({ singleLine, maxLength, variables, onInvalid, }?: RichTextEditingOptions) => (Extension<any, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | Node<any, any>)[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RichTextVariable, type RichTextDocument } from "
|
|
1
|
+
import { type RichTextVariable, type RichTextDocument } from "./legacy-rich-text/schema.js";
|
|
2
2
|
import { EmailDocument, type EmailElement } from "./schema.js";
|
|
3
3
|
export declare const emailElementTypes: readonly ["text", "button", "code", "logo", "image", "divider", "spacer"];
|
|
4
4
|
export type EmailElementType = (typeof emailElementTypes)[number];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ../../src/lib/email-document/model.ts
|
|
2
2
|
import { Schema as Schema4 } from "effect";
|
|
3
3
|
|
|
4
|
-
// ../../src/lib/rich-text/schema.ts
|
|
4
|
+
// ../../src/lib/email-document/legacy-rich-text/schema.ts
|
|
5
5
|
import { Schema } from "effect";
|
|
6
6
|
var RichTextLink = Schema.String.check(Schema.isMaxLength(2000), Schema.makeFilter((value) => {
|
|
7
7
|
if (/[\s\p{Cc}\\{}]/u.test(value))
|
|
@@ -47,7 +47,7 @@ var RichTextVariable = Schema.Struct({
|
|
|
47
47
|
sample: Schema.String
|
|
48
48
|
}).annotate({ identifier: "RichTextVariable" });
|
|
49
49
|
|
|
50
|
-
// ../../src/lib/rich-text/model.ts
|
|
50
|
+
// ../../src/lib/email-document/legacy-rich-text/model.ts
|
|
51
51
|
import { Schema as Schema2 } from "effect";
|
|
52
52
|
var sameMarks = Schema2.toEquivalence(RichTextMarks);
|
|
53
53
|
var richTextFromString = (text) => ({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Effect, Schema as Schema5 } from "effect";
|
|
3
3
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
4
|
|
|
5
|
-
// ../../src/lib/rich-text/schema.ts
|
|
5
|
+
// ../../src/lib/email-document/legacy-rich-text/schema.ts
|
|
6
6
|
import { Schema } from "effect";
|
|
7
7
|
var RichTextLink = Schema.String.check(Schema.isMaxLength(2000), Schema.makeFilter((value) => {
|
|
8
8
|
if (/[\s\p{Cc}\\{}]/u.test(value))
|
|
@@ -48,7 +48,7 @@ var RichTextVariable = Schema.Struct({
|
|
|
48
48
|
sample: Schema.String
|
|
49
49
|
}).annotate({ identifier: "RichTextVariable" });
|
|
50
50
|
|
|
51
|
-
// ../../src/lib/rich-text/model.ts
|
|
51
|
+
// ../../src/lib/email-document/legacy-rich-text/model.ts
|
|
52
52
|
import { Schema as Schema2 } from "effect";
|
|
53
53
|
var sameMarks = Schema2.toEquivalence(RichTextMarks);
|
|
54
54
|
var richTextPlainText = (value, variables) => value.blocks.map((block) => block.content.map((inline) => inline.type === "text" ? inline.text : variables?.[inline.key] ?? `{{${inline.key}}}`).join("")).join(`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ../../src/lib/email-document/schema.ts
|
|
2
2
|
import { Schema as Schema2 } from "effect";
|
|
3
3
|
|
|
4
|
-
// ../../src/lib/rich-text/schema.ts
|
|
4
|
+
// ../../src/lib/email-document/legacy-rich-text/schema.ts
|
|
5
5
|
import { Schema } from "effect";
|
|
6
6
|
var RichTextLink = Schema.String.check(Schema.isMaxLength(2000), Schema.makeFilter((value) => {
|
|
7
7
|
if (/[\s\p{Cc}\\{}]/u.test(value))
|