@krak-stack/registry 0.10.4 → 0.10.6

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/ui/animated-list.d.ts +6 -7
  3. package/dist/components/ui/animated-list.js +329 -139
  4. package/dist/components/ui/animated-number.js +47 -24
  5. package/dist/components/ui/auto-height.js +56 -15
  6. package/dist/components/ui/data-table.js +16 -13
  7. package/dist/components/ui/email-editor.d.ts +124 -0
  8. package/dist/components/ui/email-editor.js +2651 -0
  9. package/dist/components/ui/form.d.ts +5 -5
  10. package/dist/components/ui/presence-transition.d.ts +1 -1
  11. package/dist/components/ui/presence-transition.js +79 -26
  12. package/dist/components/ui/rich-text-editor.d.ts +70 -0
  13. package/dist/components/ui/rich-text-editor.js +1135 -0
  14. package/dist/components/ui/time-picker.d.ts +13 -4
  15. package/dist/components/ui/time-picker.js +141 -47
  16. package/dist/components/ui/time-picker.schema.d.ts +16 -2
  17. package/dist/lib/email-document/model.d.ts +26 -0
  18. package/dist/lib/email-document/model.js +253 -0
  19. package/dist/lib/email-document/render.d.ts +115 -0
  20. package/dist/lib/email-document/render.js +469 -0
  21. package/dist/lib/email-document/schema.d.ts +285 -0
  22. package/dist/lib/email-document/schema.js +139 -0
  23. package/dist/lib/krakmotion.d.ts +27 -0
  24. package/dist/lib/rich-text/dom.d.ts +40 -0
  25. package/dist/lib/rich-text/model.d.ts +19 -0
  26. package/dist/lib/rich-text/model.js +141 -0
  27. package/dist/lib/rich-text/schema.d.ts +64 -0
  28. package/dist/lib/rich-text/schema.js +53 -0
  29. package/dist/services/events/client/audit-log-table.js +16 -13
  30. package/dist/services/webhooks/client/delivery-table.js +16 -13
  31. package/package.json +29 -5
@@ -0,0 +1,285 @@
1
+ import { Schema } from "effect";
2
+ export declare const EmailImageUrl: Schema.String;
3
+ export declare const EmailColor: Schema.String;
4
+ export declare const EmailAlignment: Schema.Literals<readonly ["left", "center", "right"]>;
5
+ export declare const EmailFont: Schema.Literals<readonly ["sans", "serif", "mono"]>;
6
+ export declare const EmailDestination: Schema.Union<readonly [Schema.Struct<{
7
+ readonly type: Schema.Literal<"url">;
8
+ readonly url: Schema.String;
9
+ }>, Schema.Struct<{
10
+ readonly type: Schema.Literal<"variable">;
11
+ readonly key: Schema.String;
12
+ }>]>;
13
+ export declare const EmailElement: Schema.Union<readonly [Schema.Struct<{
14
+ readonly id: Schema.NonEmptyString;
15
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
16
+ readonly paddingTop: Schema.Int;
17
+ readonly paddingBottom: Schema.Int;
18
+ readonly type: Schema.Literal<"text">;
19
+ readonly content: Schema.Struct<{
20
+ readonly version: Schema.Literal<1>;
21
+ readonly blocks: Schema.$Array<Schema.Struct<{
22
+ readonly type: Schema.Literals<readonly ["paragraph", "heading", "bullet", "numbered"]>;
23
+ readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
24
+ readonly type: Schema.Literal<"text">;
25
+ readonly text: Schema.String;
26
+ readonly marks: Schema.optional<Schema.Struct<{
27
+ readonly bold: Schema.optional<Schema.Boolean>;
28
+ readonly italic: Schema.optional<Schema.Boolean>;
29
+ readonly underline: Schema.optional<Schema.Boolean>;
30
+ readonly href: Schema.optional<Schema.String>;
31
+ }>>;
32
+ }>, Schema.Struct<{
33
+ readonly type: Schema.Literal<"variable">;
34
+ readonly key: Schema.String;
35
+ readonly marks: Schema.optional<Schema.Struct<{
36
+ readonly bold: Schema.optional<Schema.Boolean>;
37
+ readonly italic: Schema.optional<Schema.Boolean>;
38
+ readonly underline: Schema.optional<Schema.Boolean>;
39
+ readonly href: Schema.optional<Schema.String>;
40
+ }>>;
41
+ }>]>>;
42
+ }>>;
43
+ }>;
44
+ }>, Schema.Struct<{
45
+ readonly id: Schema.NonEmptyString;
46
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
47
+ readonly paddingTop: Schema.Int;
48
+ readonly paddingBottom: Schema.Int;
49
+ readonly type: Schema.Literal<"button">;
50
+ readonly label: Schema.String;
51
+ readonly destination: Schema.Union<readonly [Schema.Struct<{
52
+ readonly type: Schema.Literal<"url">;
53
+ readonly url: Schema.String;
54
+ }>, Schema.Struct<{
55
+ readonly type: Schema.Literal<"variable">;
56
+ readonly key: Schema.String;
57
+ }>]>;
58
+ }>, Schema.Struct<{
59
+ readonly id: Schema.NonEmptyString;
60
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
61
+ readonly paddingTop: Schema.Int;
62
+ readonly paddingBottom: Schema.Int;
63
+ readonly type: Schema.Literal<"code">;
64
+ readonly variable: Schema.String;
65
+ }>, Schema.Struct<{
66
+ readonly id: Schema.NonEmptyString;
67
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
68
+ readonly paddingTop: Schema.Int;
69
+ readonly paddingBottom: Schema.Int;
70
+ readonly type: Schema.Literals<readonly ["logo", "image"]>;
71
+ readonly src: Schema.String;
72
+ readonly alt: Schema.String;
73
+ readonly width: Schema.Int;
74
+ }>, Schema.Struct<{
75
+ readonly id: Schema.NonEmptyString;
76
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
77
+ readonly paddingTop: Schema.Int;
78
+ readonly paddingBottom: Schema.Int;
79
+ readonly type: Schema.Literal<"divider">;
80
+ }>, Schema.Struct<{
81
+ readonly id: Schema.NonEmptyString;
82
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
83
+ readonly paddingTop: Schema.Int;
84
+ readonly paddingBottom: Schema.Int;
85
+ readonly type: Schema.Literal<"spacer">;
86
+ readonly height: Schema.Int;
87
+ }>]>;
88
+ export declare const EmailDocument: Schema.Struct<{
89
+ readonly version: Schema.Literal<1>;
90
+ readonly subject: Schema.String;
91
+ readonly preview: Schema.String;
92
+ readonly appearance: Schema.Struct<{
93
+ readonly background: Schema.String;
94
+ readonly surface: Schema.String;
95
+ readonly text: Schema.String;
96
+ readonly primary: Schema.String;
97
+ readonly primaryText: Schema.String;
98
+ readonly font: Schema.Literals<readonly ["sans", "serif", "mono"]>;
99
+ readonly radius: Schema.Int;
100
+ }>;
101
+ readonly elements: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
102
+ readonly id: Schema.NonEmptyString;
103
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
104
+ readonly paddingTop: Schema.Int;
105
+ readonly paddingBottom: Schema.Int;
106
+ readonly type: Schema.Literal<"text">;
107
+ readonly content: Schema.Struct<{
108
+ readonly version: Schema.Literal<1>;
109
+ readonly blocks: Schema.$Array<Schema.Struct<{
110
+ readonly type: Schema.Literals<readonly ["paragraph", "heading", "bullet", "numbered"]>;
111
+ readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
112
+ readonly type: Schema.Literal<"text">;
113
+ readonly text: Schema.String;
114
+ readonly marks: Schema.optional<Schema.Struct<{
115
+ readonly bold: Schema.optional<Schema.Boolean>;
116
+ readonly italic: Schema.optional<Schema.Boolean>;
117
+ readonly underline: Schema.optional<Schema.Boolean>;
118
+ readonly href: Schema.optional<Schema.String>;
119
+ }>>;
120
+ }>, Schema.Struct<{
121
+ readonly type: Schema.Literal<"variable">;
122
+ readonly key: Schema.String;
123
+ readonly marks: Schema.optional<Schema.Struct<{
124
+ readonly bold: Schema.optional<Schema.Boolean>;
125
+ readonly italic: Schema.optional<Schema.Boolean>;
126
+ readonly underline: Schema.optional<Schema.Boolean>;
127
+ readonly href: Schema.optional<Schema.String>;
128
+ }>>;
129
+ }>]>>;
130
+ }>>;
131
+ }>;
132
+ }>, Schema.Struct<{
133
+ readonly id: Schema.NonEmptyString;
134
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
135
+ readonly paddingTop: Schema.Int;
136
+ readonly paddingBottom: Schema.Int;
137
+ readonly type: Schema.Literal<"button">;
138
+ readonly label: Schema.String;
139
+ readonly destination: Schema.Union<readonly [Schema.Struct<{
140
+ readonly type: Schema.Literal<"url">;
141
+ readonly url: Schema.String;
142
+ }>, Schema.Struct<{
143
+ readonly type: Schema.Literal<"variable">;
144
+ readonly key: Schema.String;
145
+ }>]>;
146
+ }>, Schema.Struct<{
147
+ readonly id: Schema.NonEmptyString;
148
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
149
+ readonly paddingTop: Schema.Int;
150
+ readonly paddingBottom: Schema.Int;
151
+ readonly type: Schema.Literal<"code">;
152
+ readonly variable: Schema.String;
153
+ }>, Schema.Struct<{
154
+ readonly id: Schema.NonEmptyString;
155
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
156
+ readonly paddingTop: Schema.Int;
157
+ readonly paddingBottom: Schema.Int;
158
+ readonly type: Schema.Literals<readonly ["logo", "image"]>;
159
+ readonly src: Schema.String;
160
+ readonly alt: Schema.String;
161
+ readonly width: Schema.Int;
162
+ }>, Schema.Struct<{
163
+ readonly id: Schema.NonEmptyString;
164
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
165
+ readonly paddingTop: Schema.Int;
166
+ readonly paddingBottom: Schema.Int;
167
+ readonly type: Schema.Literal<"divider">;
168
+ }>, Schema.Struct<{
169
+ readonly id: Schema.NonEmptyString;
170
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
171
+ readonly paddingTop: Schema.Int;
172
+ readonly paddingBottom: Schema.Int;
173
+ readonly type: Schema.Literal<"spacer">;
174
+ readonly height: Schema.Int;
175
+ }>]>>;
176
+ }>;
177
+ export declare const EmailRenderInput: Schema.Struct<{
178
+ readonly document: Schema.Struct<{
179
+ readonly version: Schema.Literal<1>;
180
+ readonly subject: Schema.String;
181
+ readonly preview: Schema.String;
182
+ readonly appearance: Schema.Struct<{
183
+ readonly background: Schema.String;
184
+ readonly surface: Schema.String;
185
+ readonly text: Schema.String;
186
+ readonly primary: Schema.String;
187
+ readonly primaryText: Schema.String;
188
+ readonly font: Schema.Literals<readonly ["sans", "serif", "mono"]>;
189
+ readonly radius: Schema.Int;
190
+ }>;
191
+ readonly elements: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
192
+ readonly id: Schema.NonEmptyString;
193
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
194
+ readonly paddingTop: Schema.Int;
195
+ readonly paddingBottom: Schema.Int;
196
+ readonly type: Schema.Literal<"text">;
197
+ readonly content: Schema.Struct<{
198
+ readonly version: Schema.Literal<1>;
199
+ readonly blocks: Schema.$Array<Schema.Struct<{
200
+ readonly type: Schema.Literals<readonly ["paragraph", "heading", "bullet", "numbered"]>;
201
+ readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
202
+ readonly type: Schema.Literal<"text">;
203
+ readonly text: Schema.String;
204
+ readonly marks: Schema.optional<Schema.Struct<{
205
+ readonly bold: Schema.optional<Schema.Boolean>;
206
+ readonly italic: Schema.optional<Schema.Boolean>;
207
+ readonly underline: Schema.optional<Schema.Boolean>;
208
+ readonly href: Schema.optional<Schema.String>;
209
+ }>>;
210
+ }>, Schema.Struct<{
211
+ readonly type: Schema.Literal<"variable">;
212
+ readonly key: Schema.String;
213
+ readonly marks: Schema.optional<Schema.Struct<{
214
+ readonly bold: Schema.optional<Schema.Boolean>;
215
+ readonly italic: Schema.optional<Schema.Boolean>;
216
+ readonly underline: Schema.optional<Schema.Boolean>;
217
+ readonly href: Schema.optional<Schema.String>;
218
+ }>>;
219
+ }>]>>;
220
+ }>>;
221
+ }>;
222
+ }>, Schema.Struct<{
223
+ readonly id: Schema.NonEmptyString;
224
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
225
+ readonly paddingTop: Schema.Int;
226
+ readonly paddingBottom: Schema.Int;
227
+ readonly type: Schema.Literal<"button">;
228
+ readonly label: Schema.String;
229
+ readonly destination: Schema.Union<readonly [Schema.Struct<{
230
+ readonly type: Schema.Literal<"url">;
231
+ readonly url: Schema.String;
232
+ }>, Schema.Struct<{
233
+ readonly type: Schema.Literal<"variable">;
234
+ readonly key: Schema.String;
235
+ }>]>;
236
+ }>, Schema.Struct<{
237
+ readonly id: Schema.NonEmptyString;
238
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
239
+ readonly paddingTop: Schema.Int;
240
+ readonly paddingBottom: Schema.Int;
241
+ readonly type: Schema.Literal<"code">;
242
+ readonly variable: Schema.String;
243
+ }>, Schema.Struct<{
244
+ readonly id: Schema.NonEmptyString;
245
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
246
+ readonly paddingTop: Schema.Int;
247
+ readonly paddingBottom: Schema.Int;
248
+ readonly type: Schema.Literals<readonly ["logo", "image"]>;
249
+ readonly src: Schema.String;
250
+ readonly alt: Schema.String;
251
+ readonly width: Schema.Int;
252
+ }>, Schema.Struct<{
253
+ readonly id: Schema.NonEmptyString;
254
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
255
+ readonly paddingTop: Schema.Int;
256
+ readonly paddingBottom: Schema.Int;
257
+ readonly type: Schema.Literal<"divider">;
258
+ }>, Schema.Struct<{
259
+ readonly id: Schema.NonEmptyString;
260
+ readonly alignment: Schema.Literals<readonly ["left", "center", "right"]>;
261
+ readonly paddingTop: Schema.Int;
262
+ readonly paddingBottom: Schema.Int;
263
+ readonly type: Schema.Literal<"spacer">;
264
+ readonly height: Schema.Int;
265
+ }>]>>;
266
+ }>;
267
+ readonly variables: Schema.$Array<Schema.Struct<{
268
+ readonly key: Schema.String;
269
+ readonly label: Schema.String;
270
+ readonly type: Schema.Literals<readonly ["text", "url"]>;
271
+ readonly sample: Schema.String;
272
+ }>>;
273
+ readonly values: Schema.$Record<Schema.String, Schema.String>;
274
+ readonly requiredVariables: Schema.optional<Schema.$Array<Schema.String>>;
275
+ }>;
276
+ export declare const EmailRenderResult: Schema.Struct<{
277
+ readonly subject: Schema.String;
278
+ readonly html: Schema.String;
279
+ readonly text: Schema.String;
280
+ }>;
281
+ export type EmailDocument = typeof EmailDocument.Type;
282
+ export type EmailElement = typeof EmailElement.Type;
283
+ export type EmailDestination = typeof EmailDestination.Type;
284
+ export type EmailRenderInput = typeof EmailRenderInput.Type;
285
+ export type EmailRenderResult = typeof EmailRenderResult.Type;
@@ -0,0 +1,139 @@
1
+ // ../../src/lib/email-document/schema.ts
2
+ import { Schema as Schema2 } from "effect";
3
+
4
+ // ../../src/lib/rich-text/schema.ts
5
+ import { Schema } from "effect";
6
+ var RichTextLink = Schema.String.check(Schema.isMaxLength(2000), Schema.makeFilter((value) => {
7
+ if (/[\s\p{Cc}\\{}]/u.test(value))
8
+ return false;
9
+ const url = URL.parse(value);
10
+ return url !== null && ["https:", "mailto:"].includes(url.protocol) && !url.username && !url.password;
11
+ })).annotate({ identifier: "RichTextLink" });
12
+ var RichTextMarks = Schema.Struct({
13
+ bold: Schema.optional(Schema.Boolean),
14
+ italic: Schema.optional(Schema.Boolean),
15
+ underline: Schema.optional(Schema.Boolean),
16
+ href: Schema.optional(RichTextLink)
17
+ }).annotate({ identifier: "RichTextMarks" });
18
+ var RichTextInline = Schema.Union([
19
+ Schema.Struct({
20
+ type: Schema.Literal("text"),
21
+ text: Schema.String.check(Schema.isMaxLength(20000)),
22
+ marks: Schema.optional(RichTextMarks)
23
+ }),
24
+ Schema.Struct({
25
+ type: Schema.Literal("variable"),
26
+ key: Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
27
+ marks: Schema.optional(RichTextMarks)
28
+ })
29
+ ]).annotate({ identifier: "RichTextInline" });
30
+ var RichTextBlockKind = Schema.Literals([
31
+ "paragraph",
32
+ "heading",
33
+ "bullet",
34
+ "numbered"
35
+ ]).annotate({ identifier: "RichTextBlockKind" });
36
+ var RichTextDocument = Schema.Struct({
37
+ version: Schema.Literal(1),
38
+ blocks: Schema.Array(Schema.Struct({
39
+ type: RichTextBlockKind,
40
+ content: Schema.Array(RichTextInline).check(Schema.isMaxLength(2000))
41
+ })).check(Schema.isMinLength(1), Schema.isMaxLength(100))
42
+ }).check(Schema.makeFilter((value) => value.blocks.reduce((size, block) => size + block.content.reduce((count, inline) => count + (inline.type === "text" ? inline.text.length : 1), 0), 0) <= 20000)).annotate({ identifier: "RichTextDocument" });
43
+ var RichTextVariable = Schema.Struct({
44
+ key: Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
45
+ label: Schema.String,
46
+ type: Schema.Literals(["text", "url"]),
47
+ sample: Schema.String
48
+ }).annotate({ identifier: "RichTextVariable" });
49
+
50
+ // ../../src/lib/email-document/schema.ts
51
+ var EmailImageUrl = RichTextLink.check(Schema2.isPattern(/^https:\/\//)).annotate({ identifier: "EmailImageUrl" });
52
+ var EmailColor = Schema2.String.check(Schema2.isPattern(/^#[0-9a-fA-F]{6}$/)).annotate({ identifier: "EmailColor" });
53
+ var EmailAlignment = Schema2.Literals([
54
+ "left",
55
+ "center",
56
+ "right"
57
+ ]).annotate({ identifier: "EmailAlignment" });
58
+ var EmailFont = Schema2.Literals(["sans", "serif", "mono"]).annotate({
59
+ identifier: "EmailFont"
60
+ });
61
+ var spacing = Schema2.Int.check(Schema2.isBetween({ minimum: 0, maximum: 96 }));
62
+ var common = {
63
+ id: Schema2.NonEmptyString.check(Schema2.isMaxLength(80)),
64
+ alignment: EmailAlignment,
65
+ paddingTop: spacing,
66
+ paddingBottom: spacing
67
+ };
68
+ var EmailDestination = Schema2.Union([
69
+ Schema2.Struct({ type: Schema2.Literal("url"), url: RichTextLink }),
70
+ Schema2.Struct({
71
+ type: Schema2.Literal("variable"),
72
+ key: RichTextVariable.fields.key
73
+ })
74
+ ]).annotate({ identifier: "EmailDestination" });
75
+ var EmailElement = Schema2.Union([
76
+ Schema2.Struct({
77
+ ...common,
78
+ type: Schema2.Literal("text"),
79
+ content: RichTextDocument
80
+ }),
81
+ Schema2.Struct({
82
+ ...common,
83
+ type: Schema2.Literal("button"),
84
+ label: Schema2.String.check(Schema2.isMaxLength(200)),
85
+ destination: EmailDestination
86
+ }),
87
+ Schema2.Struct({
88
+ ...common,
89
+ type: Schema2.Literal("code"),
90
+ variable: RichTextVariable.fields.key
91
+ }),
92
+ Schema2.Struct({
93
+ ...common,
94
+ type: Schema2.Literals(["logo", "image"]),
95
+ src: EmailImageUrl,
96
+ alt: Schema2.String.check(Schema2.isMaxLength(200)),
97
+ width: Schema2.Int.check(Schema2.isBetween({ minimum: 32, maximum: 560 }))
98
+ }),
99
+ Schema2.Struct({ ...common, type: Schema2.Literal("divider") }),
100
+ Schema2.Struct({ ...common, type: Schema2.Literal("spacer"), height: spacing })
101
+ ]).annotate({ identifier: "EmailElement" });
102
+ var subject = Schema2.String.check(Schema2.isMaxLength(200), Schema2.isPattern(/^[^\r\n]*$/));
103
+ var EmailDocument = Schema2.Struct({
104
+ version: Schema2.Literal(1),
105
+ subject,
106
+ preview: subject,
107
+ appearance: Schema2.Struct({
108
+ background: EmailColor,
109
+ surface: EmailColor,
110
+ text: EmailColor,
111
+ primary: EmailColor,
112
+ primaryText: EmailColor,
113
+ font: EmailFont,
114
+ radius: Schema2.Int.check(Schema2.isBetween({ minimum: 0, maximum: 32 }))
115
+ }),
116
+ elements: Schema2.Array(EmailElement).check(Schema2.isMaxLength(40))
117
+ }).check(Schema2.makeFilter((document) => new Set(document.elements.map((element) => element.id)).size === document.elements.length)).annotate({ identifier: "EmailDocument" });
118
+ var EmailRenderInput = Schema2.Struct({
119
+ document: EmailDocument,
120
+ variables: Schema2.Array(RichTextVariable),
121
+ values: Schema2.Record(Schema2.String, Schema2.String),
122
+ requiredVariables: Schema2.optional(Schema2.Array(Schema2.String))
123
+ }).annotate({ identifier: "EmailRenderInput" });
124
+ var EmailRenderResult = Schema2.Struct({
125
+ subject: Schema2.String,
126
+ html: Schema2.String,
127
+ text: Schema2.String
128
+ }).annotate({ identifier: "EmailRenderResult" });
129
+ export {
130
+ EmailAlignment,
131
+ EmailColor,
132
+ EmailDestination,
133
+ EmailDocument,
134
+ EmailElement,
135
+ EmailFont,
136
+ EmailImageUrl,
137
+ EmailRenderInput,
138
+ EmailRenderResult
139
+ };
@@ -0,0 +1,27 @@
1
+ import { type PointerEvent as ReactPointerEvent, type RefObject } from "react";
2
+ export declare const useReducedMotion: () => boolean;
3
+ /** Cancellation never completes an obsolete transition. Missing WAAPI settles immediately. */
4
+ export declare const animateElement: (element: HTMLElement, frames: Keyframe[], duration: number, complete?: () => void) => () => void;
5
+ export declare const usePresence: (open: boolean, duration: number) => {
6
+ ref: RefObject<HTMLDivElement | null>;
7
+ mounted: boolean;
8
+ };
9
+ /** Retain removed keyed children in flow until their exit finishes. */
10
+ export declare const useKeyedPresence: <T>(items: readonly T[], getKey: (item: T) => string) => {
11
+ items: readonly T[];
12
+ present: Set<string>;
13
+ remove: (key: string) => void;
14
+ };
15
+ /** FLIP position transitions leave layout and React's keyed children intact. */
16
+ export declare const useListLayout: (ref: RefObject<HTMLUListElement | null>, duration: number) => void;
17
+ export declare const useNumberTransition: (value: number, duration: number) => number;
18
+ /** Pointer-only mechanics. The caller owns order, keyboard controls and announcements. */
19
+ export declare const useVerticalDrag: ({ ref, container, enabled, overflow, onMove, }: {
20
+ ref: RefObject<HTMLLIElement | null>;
21
+ container: RefObject<HTMLUListElement | null>;
22
+ enabled: boolean;
23
+ overflow: number;
24
+ onMove: (target: number) => void;
25
+ }) => {
26
+ onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;
27
+ };
@@ -0,0 +1,40 @@
1
+ import { RichTextDocument, type RichTextVariable } from "./schema.js";
2
+ import { type TextSelection } from "./model.js";
3
+ type Point = {
4
+ node: Node;
5
+ offset: number;
6
+ };
7
+ /** Normalize browser editing DOM to the allowlisted model; never retain arbitrary HTML. */
8
+ export declare const readRichTextDOM: (root: HTMLElement) => {
9
+ value: {
10
+ readonly version: 1;
11
+ readonly blocks: readonly {
12
+ readonly type: "bullet" | "heading" | "numbered" | "paragraph";
13
+ readonly content: readonly ({
14
+ readonly type: "text";
15
+ readonly text: string;
16
+ readonly marks?: {
17
+ readonly bold?: boolean | undefined;
18
+ readonly italic?: boolean | undefined;
19
+ readonly underline?: boolean | undefined;
20
+ readonly href?: string | undefined;
21
+ } | undefined;
22
+ } | {
23
+ readonly type: "variable";
24
+ readonly key: string;
25
+ readonly marks?: {
26
+ readonly bold?: boolean | undefined;
27
+ readonly italic?: boolean | undefined;
28
+ readonly underline?: boolean | undefined;
29
+ readonly href?: string | undefined;
30
+ } | undefined;
31
+ })[];
32
+ }[];
33
+ } | undefined;
34
+ points: Point[];
35
+ };
36
+ export declare const readEditorSelection: (root: HTMLElement, points: readonly Point[]) => TextSelection | undefined;
37
+ export declare const restoreRichTextSelection: (root: HTMLElement, selection: TextSelection) => void;
38
+ /** DOM creation, not HTML interpolation, keeps variable values and text escaped. */
39
+ export declare const writeRichTextDOM: (root: HTMLElement, value: RichTextDocument, variables: readonly RichTextVariable[]) => void;
40
+ export {};
@@ -0,0 +1,19 @@
1
+ import { RichTextDocument, RichTextMarks, type RichTextInline, type RichTextBlockKind } from "./schema.js";
2
+ export type TextSelection = {
3
+ from: number;
4
+ to: number;
5
+ };
6
+ export type RichTextEdit = {
7
+ value: RichTextDocument;
8
+ selection: TextSelection;
9
+ };
10
+ export declare const emptyRichText: () => RichTextDocument;
11
+ export declare const richTextFromString: (text: string) => RichTextDocument;
12
+ export declare const richTextPlainText: (value: RichTextDocument, variables?: Readonly<Record<string, string>>) => string;
13
+ /** Convert plain template tokens to atomic variables without changing their keys. */
14
+ export declare const richTextFromTemplate: (text: string) => RichTextDocument;
15
+ export declare const replaceRichText: (value: RichTextDocument, selection: TextSelection, inserted: RichTextInline) => RichTextEdit;
16
+ export declare const formatRichText: (value: RichTextDocument, selection: TextSelection, mark: keyof RichTextMarks, setting: string | boolean | undefined) => RichTextDocument;
17
+ export declare const setRichTextBlock: (value: RichTextDocument, selection: TextSelection, type: RichTextBlockKind) => RichTextDocument;
18
+ export declare const richTextLength: (value: RichTextDocument) => number;
19
+ export declare const richTextMarksAt: (value: RichTextDocument, position: number) => RichTextMarks;
@@ -0,0 +1,141 @@
1
+ // ../../src/lib/rich-text/model.ts
2
+ import { Schema as Schema2 } from "effect";
3
+
4
+ // ../../src/lib/rich-text/schema.ts
5
+ import { Schema } from "effect";
6
+ var RichTextLink = Schema.String.check(Schema.isMaxLength(2000), Schema.makeFilter((value) => {
7
+ if (/[\s\p{Cc}\\{}]/u.test(value))
8
+ return false;
9
+ const url = URL.parse(value);
10
+ return url !== null && ["https:", "mailto:"].includes(url.protocol) && !url.username && !url.password;
11
+ })).annotate({ identifier: "RichTextLink" });
12
+ var RichTextMarks = Schema.Struct({
13
+ bold: Schema.optional(Schema.Boolean),
14
+ italic: Schema.optional(Schema.Boolean),
15
+ underline: Schema.optional(Schema.Boolean),
16
+ href: Schema.optional(RichTextLink)
17
+ }).annotate({ identifier: "RichTextMarks" });
18
+ var RichTextInline = Schema.Union([
19
+ Schema.Struct({
20
+ type: Schema.Literal("text"),
21
+ text: Schema.String.check(Schema.isMaxLength(20000)),
22
+ marks: Schema.optional(RichTextMarks)
23
+ }),
24
+ Schema.Struct({
25
+ type: Schema.Literal("variable"),
26
+ key: Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
27
+ marks: Schema.optional(RichTextMarks)
28
+ })
29
+ ]).annotate({ identifier: "RichTextInline" });
30
+ var RichTextBlockKind = Schema.Literals([
31
+ "paragraph",
32
+ "heading",
33
+ "bullet",
34
+ "numbered"
35
+ ]).annotate({ identifier: "RichTextBlockKind" });
36
+ var RichTextDocument = Schema.Struct({
37
+ version: Schema.Literal(1),
38
+ blocks: Schema.Array(Schema.Struct({
39
+ type: RichTextBlockKind,
40
+ content: Schema.Array(RichTextInline).check(Schema.isMaxLength(2000))
41
+ })).check(Schema.isMinLength(1), Schema.isMaxLength(100))
42
+ }).check(Schema.makeFilter((value) => value.blocks.reduce((size, block) => size + block.content.reduce((count, inline) => count + (inline.type === "text" ? inline.text.length : 1), 0), 0) <= 20000)).annotate({ identifier: "RichTextDocument" });
43
+ var RichTextVariable = Schema.Struct({
44
+ key: Schema.String.check(Schema.isPattern(/^[a-zA-Z][a-zA-Z0-9_.]{0,79}$/)),
45
+ label: Schema.String,
46
+ type: Schema.Literals(["text", "url"]),
47
+ sample: Schema.String
48
+ }).annotate({ identifier: "RichTextVariable" });
49
+
50
+ // ../../src/lib/rich-text/model.ts
51
+ var sameMarks = Schema2.toEquivalence(RichTextMarks);
52
+ var emptyRichText = () => ({
53
+ version: 1,
54
+ blocks: [{ type: "paragraph", content: [] }]
55
+ });
56
+ var richTextFromString = (text) => ({
57
+ version: 1,
58
+ blocks: text.split(/\r\n?|\n/).map((line) => ({
59
+ type: "paragraph",
60
+ content: line ? [{ type: "text", text: line }] : []
61
+ }))
62
+ });
63
+ var richTextPlainText = (value, variables) => value.blocks.map((block) => block.content.map((inline) => inline.type === "text" ? inline.text : variables?.[inline.key] ?? `{{${inline.key}}}`).join("")).join(`
64
+ `);
65
+ var richTextFromTemplate = (text) => ({
66
+ version: 1,
67
+ blocks: [{
68
+ type: "paragraph",
69
+ content: text.split(/(\{\{[a-zA-Z][a-zA-Z0-9_.]*\}\})/g).filter(Boolean).map((part) => /^\{\{[a-zA-Z][a-zA-Z0-9_.]*\}\}$/.test(part) ? { type: "variable", key: part.slice(2, -2) } : { type: "text", text: part })
70
+ }]
71
+ });
72
+ var units = (value) => value.blocks.flatMap((block, index) => [
73
+ ...index ? [{ type: "break", next: block.type }] : [],
74
+ ...block.content.flatMap((inline) => inline.type === "text" ? inline.text.split("").map((text) => ({ ...inline, text })) : [inline])
75
+ ]);
76
+ var fromUnits = (content, first) => {
77
+ const blocks = [{ type: first, content: [] }];
78
+ for (const unit of content) {
79
+ if (unit.type === "break") {
80
+ blocks.push({ type: unit.next, content: [] });
81
+ continue;
82
+ }
83
+ const target = blocks.at(-1);
84
+ if (!target)
85
+ continue;
86
+ const previous = target.content.at(-1);
87
+ if (unit.type === "text" && previous?.type === "text" && sameMarks(previous.marks ?? {}, unit.marks ?? {})) {
88
+ target.content[target.content.length - 1] = {
89
+ ...previous,
90
+ text: previous.text + unit.text
91
+ };
92
+ } else
93
+ target.content.push(unit);
94
+ }
95
+ return { version: 1, blocks };
96
+ };
97
+ var replaceRichText = (value, selection, inserted) => {
98
+ const content = units(value);
99
+ const from = Math.max(0, Math.min(selection.from, content.length));
100
+ const to = Math.max(from, Math.min(selection.to, content.length));
101
+ const additions = inserted.type === "text" ? inserted.text.replace(/\r\n?/g, `
102
+ `).split("").map((text) => text === `
103
+ ` ? { type: "break", next: "paragraph" } : { type: "text", text, marks: inserted.marks }) : [inserted];
104
+ const next = fromUnits([...content.slice(0, from), ...additions, ...content.slice(to)], value.blocks[0]?.type ?? "paragraph");
105
+ const position = from + additions.length;
106
+ return { value: next, selection: { from: position, to: position } };
107
+ };
108
+ var formatRichText = (value, selection, mark, setting) => fromUnits(units(value).map((unit, index) => {
109
+ if (unit.type === "break" || index < selection.from || index >= selection.to)
110
+ return unit;
111
+ const marks = { ...unit.marks, [mark]: setting };
112
+ return { ...unit, marks };
113
+ }), value.blocks[0]?.type ?? "paragraph");
114
+ var setRichTextBlock = (value, selection, type) => {
115
+ let offset = 0;
116
+ return {
117
+ ...value,
118
+ blocks: value.blocks.map((block) => {
119
+ const start = offset;
120
+ offset += block.content.reduce((size, inline) => size + (inline.type === "text" ? inline.text.length : 1), 0) + 1;
121
+ return selection.from < offset && selection.to >= start ? { ...block, type } : block;
122
+ })
123
+ };
124
+ };
125
+ var richTextLength = (value) => units(value).length;
126
+ var richTextMarksAt = (value, position) => {
127
+ const content = units(value);
128
+ const unit = content[Math.max(0, position - 1)];
129
+ return unit && unit.type !== "break" ? unit.marks ?? {} : {};
130
+ };
131
+ export {
132
+ emptyRichText,
133
+ formatRichText,
134
+ replaceRichText,
135
+ richTextFromString,
136
+ richTextFromTemplate,
137
+ richTextLength,
138
+ richTextMarksAt,
139
+ richTextPlainText,
140
+ setRichTextBlock
141
+ };