@krak-stack/registry 0.11.1 → 0.11.2

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 (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/agent/react.js +29 -183
  3. package/dist/components/animated-list/react.js +16 -168
  4. package/dist/components/animated-number/react.js +8 -162
  5. package/dist/components/async-action-button/react.js +10 -164
  6. package/dist/components/audit-log-table/react.js +59 -213
  7. package/dist/components/code-block/react.js +10 -164
  8. package/dist/components/copy-button/react.js +10 -164
  9. package/dist/components/copy-value/html.js +4 -4
  10. package/dist/components/copy-value/react.js +20 -172
  11. package/dist/components/danger-confirmation/react.js +13 -167
  12. package/dist/components/data-table/react.js +59 -213
  13. package/dist/components/editable-text/react.js +14 -168
  14. package/dist/components/email-composer/react.js +25 -174
  15. package/dist/components/email-editor/react.js +34 -186
  16. package/dist/components/error-component/react.js +15 -169
  17. package/dist/components/icon-input/react.js +7 -161
  18. package/dist/components/image-crop-editor/react.js +19 -173
  19. package/dist/components/markdown/react.js +10 -164
  20. package/dist/components/presence-transition/react.js +9 -163
  21. package/dist/components/registry-previews/component-example.js +10 -164
  22. package/dist/components/rich-text-editor/react.js +9 -161
  23. package/dist/components/search-menu/react.js +11 -165
  24. package/dist/components/sidebar-layout/react.js +3 -157
  25. package/dist/components/support/react.js +14 -168
  26. package/dist/components/timezone-input/react.js +9 -163
  27. package/dist/components/webhook-delivery-table/react.js +74 -226
  28. package/dist/lib/docs.integrations.server.js +16 -35
  29. package/dist/lib/docs.js +31 -183
  30. package/dist/lib/docs.server.js +16 -35
  31. package/dist/lib/documentation-toolkit.js +19 -38
  32. package/dist/lib/effect-ui-adapter/use-model.js +158 -0
  33. package/dist/services/agent/client/index.js +29 -183
  34. package/package.json +5 -1
@@ -1,8 +1,8 @@
1
1
  // ../../src/components/editable-text/react.tsx
2
- import { Effect as Effect3, Redacted as Redacted2 } from "effect";
3
- import { Component as Component2, View as View2 } from "effect/ui";
2
+ import { Effect as Effect2, Redacted as Redacted2 } from "effect";
3
+ import { Component as Component2, View } from "effect/ui";
4
4
  import { LoaderCircle, Pencil, RotateCcw } from "lucide-react";
5
- import { useEffect as useEffect2, useId, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
5
+ import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
6
6
 
7
7
  // ../../src/components/ui/button.tsx
8
8
  import { Button as ButtonPrimitive } from "@base-ui/react/button";
@@ -77,161 +77,7 @@ function Label({ className, ...props }) {
77
77
 
78
78
  // ../../src/components/editable-text/react.tsx
79
79
  import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
80
-
81
- // ../../src/lib/effect-ui-adapter/use-model.ts
82
- import { MessageLog as MessageLog2 } from "effect/ui";
83
- import {
84
- createContext,
85
- useCallback,
86
- useContext,
87
- useEffect,
88
- useLayoutEffect,
89
- useRef,
90
- useState,
91
- useSyncExternalStore
92
- } from "react";
93
-
94
- // ../../src/lib/effect-ui-adapter/model-runtime.ts
95
- import { MessageLog, Renderer, View } from "effect/ui";
96
- import { BrowserHost, Html } from "effect/ui/html";
97
- import { Cause, Effect, Fiber } from "effect";
98
- var node = () => ({ children: [] });
99
- var modelHost = (commit) => {
100
- const remove = (child) => {
101
- if (!child.parent)
102
- return;
103
- child.parent.children.splice(child.parent.children.indexOf(child), 1);
104
- delete child.parent;
105
- };
106
- return {
107
- createElement: node,
108
- createText: node,
109
- setText: () => {},
110
- setAttr: () => {},
111
- setProp: () => {},
112
- setEvents: () => {},
113
- insertBefore: (parent, child, before) => {
114
- if (child === before)
115
- return;
116
- remove(child);
117
- const index = before ? parent.children.indexOf(before) : parent.children.length;
118
- parent.children.splice(index, 0, child);
119
- child.parent = parent;
120
- },
121
- remove,
122
- parentOf: (child) => child.parent,
123
- nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
124
- elements: ["html"],
125
- controlled: new Set,
126
- runsMounts: false,
127
- commit
128
- };
129
- };
130
- var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
131
- let currentProps = props;
132
- let root;
133
- let active = true;
134
- let failure;
135
- const publish = () => {
136
- if (!active)
137
- return;
138
- if (failure) {
139
- publishSnapshot({ error: failure });
140
- return;
141
- }
142
- const current = root?.model();
143
- if (current !== undefined)
144
- publishSnapshot({ model: current });
145
- };
146
- const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
147
- const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
148
- head: false,
149
- onEmit,
150
- fallback: ({ cause }) => {
151
- failure = new Error("Effect UI root failed", {
152
- cause: Cause.squash(cause)
153
- });
154
- return View.text("");
155
- }
156
- });
157
- if (!active)
158
- return;
159
- root = mounted;
160
- if (props !== currentProps)
161
- mounted.setProps(currentProps);
162
- publish();
163
- return yield* Effect.never;
164
- }).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
165
- return {
166
- send: (message) => {
167
- root?.send(message);
168
- publish();
169
- },
170
- setProps: (next) => {
171
- currentProps = next;
172
- root?.setProps(next);
173
- },
174
- dispose: () => {
175
- active = false;
176
- root = undefined;
177
- Effect.runFork(Fiber.interrupt(fiber));
178
- }
179
- };
180
- };
181
-
182
- // ../../src/lib/effect-ui-adapter/use-model.ts
183
- "use client";
184
- var ModelMessageLogContext = createContext(undefined);
185
- var useModel = (component, props, options = {}) => {
186
- const contextLog = useContext(ModelMessageLogContext);
187
- const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
188
- const [store] = useState(() => {
189
- const initial = { model: component.init(props).model };
190
- let snapshot = initial;
191
- const listeners = new Set;
192
- return {
193
- subscribe: (listener) => {
194
- listeners.add(listener);
195
- return () => {
196
- listeners.delete(listener);
197
- };
198
- },
199
- getSnapshot: () => snapshot,
200
- getServerSnapshot: () => initial,
201
- publish: (next) => {
202
- if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
203
- return;
204
- if ("error" in snapshot && "error" in next && snapshot.error === next.error)
205
- return;
206
- snapshot = next;
207
- listeners.forEach((listener) => listener());
208
- }
209
- };
210
- });
211
- const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
212
- const committed = useRef(props);
213
- const onEmit = useRef(options.onEmit);
214
- const runtime = useRef(undefined);
215
- const send = useCallback((message) => runtime.current?.send(message), []);
216
- useLayoutEffect(() => {
217
- onEmit.current = options.onEmit;
218
- committed.current = props;
219
- runtime.current?.setProps(props);
220
- }, [props, options.onEmit]);
221
- useEffect(() => {
222
- if (messageLog === null)
223
- return;
224
- const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
225
- runtime.current = mounted;
226
- return () => {
227
- runtime.current = undefined;
228
- mounted.dispose();
229
- };
230
- }, [component, messageLog, store]);
231
- if ("error" in snapshot)
232
- throw snapshot.error;
233
- return { model: snapshot.model, send };
234
- };
80
+ import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
235
81
 
236
82
  // ../../src/components/editable-text/classes.ts
237
83
  var editableTextClasses = {
@@ -248,7 +94,7 @@ var resolveEditableTextClasses = (overrides) => ({
248
94
  });
249
95
 
250
96
  // ../../src/components/editable-text/index.ts
251
- import { Effect as Effect2, Redacted, Schema as Schema2 } from "effect";
97
+ import { Effect, Redacted, Schema as Schema2 } from "effect";
252
98
  import { Command, Component, UiSchema } from "effect/ui";
253
99
 
254
100
  // ../../src/components/editable-text/schema.ts
@@ -320,7 +166,7 @@ var EditableTextEvents = UiSchema.TaggedEnum({
320
166
  }).annotate({ identifier: "EditableTextEvents" });
321
167
 
322
168
  class SaveEditableText extends Command.Service()("editable-text/SaveEditableText", { args: { value: Draft }, success: EditableTextMessage }) {
323
- static layerFromEffect = (save) => SaveEditableText.toLayer(({ value }) => Effect2.suspend(() => save(Redacted.value(value))).pipe(Effect2.match({
169
+ static layerFromEffect = (save) => SaveEditableText.toLayer(({ value }) => Effect.suspend(() => save(Redacted.value(value))).pipe(Effect.match({
324
170
  onSuccess: () => EditableTextMessage.Finished({ value, success: true }),
325
171
  onFailure: () => EditableTextMessage.Finished({ value, success: false })
326
172
  })));
@@ -378,25 +224,25 @@ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
378
224
  "use client";
379
225
  var EditableTextModel = Component2.define(editableTextOptions).make({
380
226
  ...editableTextBehaviours,
381
- view: () => View2.text("")
227
+ view: () => View.text("")
382
228
  });
383
229
  var EditableText = ({ onSave, ...props }) => {
384
230
  const editableTextClasses = resolveEditableTextClasses(props.classes);
385
231
  const copy = editableTextMessages(useKrakstackLocale(props.locale), props.messages);
386
- const callback = useRef2(onSave);
387
- useLayoutEffect2(() => {
232
+ const callback = useRef(onSave);
233
+ useLayoutEffect(() => {
388
234
  callback.current = onSave;
389
235
  }, [onSave]);
390
- const [component] = useState2(() => EditableTextModel.pipe(Component2.provide(SaveEditableText.layerFromEffect((value) => Effect3.tryPromise(() => callback.current(value))))));
236
+ const [component] = useState(() => EditableTextModel.pipe(Component2.provide(SaveEditableText.layerFromEffect((value) => Effect2.tryPromise(() => callback.current(value))))));
391
237
  const { model, send } = useModel(component, props);
392
238
  const editing = model.status !== "idle";
393
239
  const pending = model.status === "pending";
394
240
  const failed = model.status === "error";
395
- const trigger = useRef2(null);
396
- const input = useRef2(null);
397
- const wasEditing = useRef2(false);
241
+ const trigger = useRef(null);
242
+ const input = useRef(null);
243
+ const wasEditing = useRef(false);
398
244
  const id = useId();
399
- useEffect2(() => {
245
+ useEffect(() => {
400
246
  if (editing) {
401
247
  input.current?.focus();
402
248
  input.current?.select();
@@ -1,13 +1,13 @@
1
1
  // ../../src/components/email-composer/react.tsx
2
- import { Effect as Effect3 } from "effect";
3
- import { useEffect as useEffect3, useEffectEvent as useEffectEvent2, useState as useState2 } from "react";
2
+ import { Effect as Effect2 } from "effect";
3
+ import { useEffect as useEffect2, useEffectEvent as useEffectEvent2, useState } from "react";
4
4
 
5
5
  // ../../src/components/rich-text-editor/react.tsx
6
6
  import { Schema as Schema6 } from "effect";
7
7
  import { EditorContent, useEditor } from "@tiptap/react";
8
8
  import { renderToReactElement } from "@tiptap/static-renderer/pm/react";
9
9
  import {
10
- useEffect as useEffect2,
10
+ useEffect,
11
11
  useEffectEvent,
12
12
  useId
13
13
  } from "react";
@@ -349,160 +349,8 @@ var richTextValidation = ({
349
349
  ]
350
350
  });
351
351
 
352
- // ../../src/lib/effect-ui-adapter/use-model.ts
353
- import { MessageLog as MessageLog2 } from "effect/ui";
354
- import {
355
- createContext,
356
- useCallback,
357
- useContext,
358
- useEffect,
359
- useLayoutEffect,
360
- useRef,
361
- useState,
362
- useSyncExternalStore
363
- } from "react";
364
-
365
- // ../../src/lib/effect-ui-adapter/model-runtime.ts
366
- import { MessageLog, Renderer, View } from "effect/ui";
367
- import { BrowserHost, Html } from "effect/ui/html";
368
- import { Cause, Effect, Fiber } from "effect";
369
- var node = () => ({ children: [] });
370
- var modelHost = (commit) => {
371
- const remove = (child) => {
372
- if (!child.parent)
373
- return;
374
- child.parent.children.splice(child.parent.children.indexOf(child), 1);
375
- delete child.parent;
376
- };
377
- return {
378
- createElement: node,
379
- createText: node,
380
- setText: () => {},
381
- setAttr: () => {},
382
- setProp: () => {},
383
- setEvents: () => {},
384
- insertBefore: (parent, child, before) => {
385
- if (child === before)
386
- return;
387
- remove(child);
388
- const index = before ? parent.children.indexOf(before) : parent.children.length;
389
- parent.children.splice(index, 0, child);
390
- child.parent = parent;
391
- },
392
- remove,
393
- parentOf: (child) => child.parent,
394
- nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
395
- elements: ["html"],
396
- controlled: new Set,
397
- runsMounts: false,
398
- commit
399
- };
400
- };
401
- var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
402
- let currentProps = props;
403
- let root;
404
- let active = true;
405
- let failure;
406
- const publish = () => {
407
- if (!active)
408
- return;
409
- if (failure) {
410
- publishSnapshot({ error: failure });
411
- return;
412
- }
413
- const current = root?.model();
414
- if (current !== undefined)
415
- publishSnapshot({ model: current });
416
- };
417
- const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
418
- const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
419
- head: false,
420
- onEmit,
421
- fallback: ({ cause }) => {
422
- failure = new Error("Effect UI root failed", {
423
- cause: Cause.squash(cause)
424
- });
425
- return View.text("");
426
- }
427
- });
428
- if (!active)
429
- return;
430
- root = mounted;
431
- if (props !== currentProps)
432
- mounted.setProps(currentProps);
433
- publish();
434
- return yield* Effect.never;
435
- }).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
436
- return {
437
- send: (message) => {
438
- root?.send(message);
439
- publish();
440
- },
441
- setProps: (next) => {
442
- currentProps = next;
443
- root?.setProps(next);
444
- },
445
- dispose: () => {
446
- active = false;
447
- root = undefined;
448
- Effect.runFork(Fiber.interrupt(fiber));
449
- }
450
- };
451
- };
452
-
453
- // ../../src/lib/effect-ui-adapter/use-model.ts
454
- "use client";
455
- var ModelMessageLogContext = createContext(undefined);
456
- var useModel = (component, props, options = {}) => {
457
- const contextLog = useContext(ModelMessageLogContext);
458
- const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
459
- const [store] = useState(() => {
460
- const initial = { model: component.init(props).model };
461
- let snapshot = initial;
462
- const listeners = new Set;
463
- return {
464
- subscribe: (listener) => {
465
- listeners.add(listener);
466
- return () => {
467
- listeners.delete(listener);
468
- };
469
- },
470
- getSnapshot: () => snapshot,
471
- getServerSnapshot: () => initial,
472
- publish: (next) => {
473
- if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
474
- return;
475
- if ("error" in snapshot && "error" in next && snapshot.error === next.error)
476
- return;
477
- snapshot = next;
478
- listeners.forEach((listener) => listener());
479
- }
480
- };
481
- });
482
- const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
483
- const committed = useRef(props);
484
- const onEmit = useRef(options.onEmit);
485
- const runtime = useRef(undefined);
486
- const send = useCallback((message) => runtime.current?.send(message), []);
487
- useLayoutEffect(() => {
488
- onEmit.current = options.onEmit;
489
- committed.current = props;
490
- runtime.current?.setProps(props);
491
- }, [props, options.onEmit]);
492
- useEffect(() => {
493
- if (messageLog === null)
494
- return;
495
- const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
496
- runtime.current = mounted;
497
- return () => {
498
- runtime.current = undefined;
499
- mounted.dispose();
500
- };
501
- }, [component, messageLog, store]);
502
- if ("error" in snapshot)
503
- throw snapshot.error;
504
- return { model: snapshot.model, send };
505
- };
352
+ // ../../src/components/rich-text-editor/react.tsx
353
+ import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
506
354
 
507
355
  // ../../src/components/rich-text-editor/classes.ts
508
356
  var richTextEditorClasses = {
@@ -519,7 +367,7 @@ var resolveRichTextEditorClasses = (overrides) => ({
519
367
 
520
368
  // ../../src/components/rich-text-editor/index.ts
521
369
  import { Schema as Schema4 } from "effect";
522
- import { Component, UiSchema, View as View2 } from "effect/ui";
370
+ import { Component, UiSchema, View } from "effect/ui";
523
371
 
524
372
  // ../../src/components/rich-text-editor/schema.ts
525
373
  import { Schema as Schema3, Struct } from "effect";
@@ -749,7 +597,7 @@ var richTextEditorBehaviours = {
749
597
  };
750
598
  var RichTextEditorModel = Component.define(modelOptions).make({
751
599
  ...richTextEditorBehaviours,
752
- view: () => View2.text("")
600
+ view: () => View.text("")
753
601
  });
754
602
 
755
603
  // ../../src/components/rich-text-editor/engine.ts
@@ -932,15 +780,15 @@ var RichTextEditor = ({
932
780
  editor?.view.focus();
933
781
  return false;
934
782
  };
935
- useEffect2(() => {
783
+ useEffect(() => {
936
784
  if (!editor)
937
785
  return;
938
786
  replaceRichText(editor, value);
939
787
  }, [editor, value]);
940
- useEffect2(() => {
788
+ useEffect(() => {
941
789
  editor?.setEditable(!disabled, false);
942
790
  }, [editor, disabled]);
943
- useEffect2(() => {
791
+ useEffect(() => {
944
792
  if (!editor)
945
793
  return;
946
794
  refreshMentionLabels(editor, variables);
@@ -949,7 +797,7 @@ var RichTextEditor = ({
949
797
  if (editor)
950
798
  runEditorAction(editor, action, variables);
951
799
  });
952
- useEffect2(() => {
800
+ useEffect(() => {
953
801
  if (request)
954
802
  applyAction(request.action);
955
803
  }, [request]);
@@ -1163,7 +1011,7 @@ import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/
1163
1011
  // ../../src/lib/email-composer/index.ts
1164
1012
  import { composeReactEmail, EmailNode } from "@react-email/editor/core";
1165
1013
  import { StarterKit as StarterKit2 } from "@react-email/editor/extensions";
1166
- import { Effect as Effect2, Schema as Schema8 } from "effect";
1014
+ import { Effect, Schema as Schema8 } from "effect";
1167
1015
 
1168
1016
  // ../../src/lib/email-composer/schema.ts
1169
1017
  import { Schema as Schema7 } from "effect";
@@ -1192,22 +1040,25 @@ var createEmailComposerExtensions = (resolveVariable = (key) => `{{${key}}}`) =>
1192
1040
  EmailNode.from(richTextMention(), ({ node }) => resolveVariable(Schema8.decodeUnknownSync(RichTextVariable.fields.key)(node.attrs?.id)))
1193
1041
  ];
1194
1042
  var emailComposerExtensions = createEmailComposerExtensions();
1195
- var exportEmail = Effect2.fn("EmailComposer.export")(function* ({
1043
+ var exportEmail = Effect.fn("EmailComposer.export")(function* ({
1196
1044
  editor
1197
1045
  }) {
1198
- const result = yield* Effect2.tryPromise({
1046
+ const result = yield* Effect.tryPromise({
1199
1047
  try: () => composeReactEmail({ editor, pretty: false }),
1200
1048
  catch: (cause) => new EmailComposerExportError({ cause })
1201
1049
  });
1202
1050
  return yield* Schema8.decodeEffect(EmailExport)({
1203
1051
  html: result.unformattedHtml,
1204
1052
  text: result.text
1205
- }).pipe(Effect2.mapError((cause) => new EmailComposerExportError({ cause })));
1053
+ }).pipe(Effect.mapError((cause) => new EmailComposerExportError({ cause })));
1206
1054
  });
1207
1055
 
1056
+ // ../../src/components/email-composer/react.tsx
1057
+ import { useModel as useModel2 } from "@krak-stack/registry/effect-ui-adapter/react";
1058
+
1208
1059
  // ../../src/components/email-composer/index.ts
1209
1060
  import { Schema as Schema10 } from "effect";
1210
- import { Component as Component2, UiSchema as UiSchema2, View as View3 } from "effect/ui";
1061
+ import { Component as Component2, UiSchema as UiSchema2, View as View2 } from "effect/ui";
1211
1062
 
1212
1063
  // ../../src/components/email-composer/schema.ts
1213
1064
  import { Schema as Schema9 } from "effect";
@@ -1275,7 +1126,7 @@ var emailComposerBehaviours = {
1275
1126
  };
1276
1127
  var EmailComposerModel = Component2.define(emailComposerOptions).make({
1277
1128
  ...emailComposerBehaviours,
1278
- view: () => View3.text("")
1129
+ view: () => View2.text("")
1279
1130
  });
1280
1131
  var emailComposerHtmlOptions = {
1281
1132
  ...emailComposerOptions,
@@ -1290,18 +1141,18 @@ var EmailComposer = ({
1290
1141
  }) => {
1291
1142
  const locale = useKrakstackLocale2(props.locale);
1292
1143
  const copy = emailComposerMessages(locale, previewMessages);
1293
- const [editor, setEditor] = useState2(null);
1144
+ const [editor, setEditor] = useState(null);
1294
1145
  const {
1295
1146
  model: { email, previewError },
1296
1147
  send
1297
- } = useModel(EmailComposerModel, props);
1148
+ } = useModel2(EmailComposerModel, props);
1298
1149
  const resolveVariable = useEffectEvent2((key) => resolveVariableSample(props.variables ?? [], key));
1299
- const [extensions] = useState2(() => createEmailComposerExtensions((key) => resolveVariable(key)));
1300
- useEffect3(() => {
1150
+ const [extensions] = useState(() => createEmailComposerExtensions((key) => resolveVariable(key)));
1151
+ useEffect2(() => {
1301
1152
  if (!editor || editor.isDestroyed)
1302
1153
  return;
1303
1154
  let current = true;
1304
- Effect3.runPromise(exportEmail({ editor }).pipe(Effect3.match({
1155
+ Effect2.runPromise(exportEmail({ editor }).pipe(Effect2.match({
1305
1156
  onFailure: () => {
1306
1157
  if (current)
1307
1158
  send(EmailComposerMessage.Failed());