@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
@@ -147,167 +147,13 @@ function InputGroupInput({
147
147
  import { Check, Copy, TriangleAlert } from "lucide-react";
148
148
  import { Redacted as Redacted2 } from "effect";
149
149
  import { Component as Component2 } from "effect/ui";
150
- import { useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
150
+ import { useLayoutEffect, useRef, useState } from "react";
151
151
  import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
152
-
153
- // ../../src/lib/effect-ui-adapter/use-model.ts
154
- import { MessageLog as MessageLog2 } from "effect/ui";
155
- import {
156
- createContext,
157
- useCallback,
158
- useContext,
159
- useEffect,
160
- useLayoutEffect,
161
- useRef,
162
- useState,
163
- useSyncExternalStore
164
- } from "react";
165
-
166
- // ../../src/lib/effect-ui-adapter/model-runtime.ts
167
- import { MessageLog, Renderer, View } from "effect/ui";
168
- import { BrowserHost, Html } from "effect/ui/html";
169
- import { Cause, Effect, Fiber } from "effect";
170
- var node = () => ({ children: [] });
171
- var modelHost = (commit) => {
172
- const remove = (child) => {
173
- if (!child.parent)
174
- return;
175
- child.parent.children.splice(child.parent.children.indexOf(child), 1);
176
- delete child.parent;
177
- };
178
- return {
179
- createElement: node,
180
- createText: node,
181
- setText: () => {},
182
- setAttr: () => {},
183
- setProp: () => {},
184
- setEvents: () => {},
185
- insertBefore: (parent, child, before) => {
186
- if (child === before)
187
- return;
188
- remove(child);
189
- const index = before ? parent.children.indexOf(before) : parent.children.length;
190
- parent.children.splice(index, 0, child);
191
- child.parent = parent;
192
- },
193
- remove,
194
- parentOf: (child) => child.parent,
195
- nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
196
- elements: ["html"],
197
- controlled: new Set,
198
- runsMounts: false,
199
- commit
200
- };
201
- };
202
- var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
203
- let currentProps = props;
204
- let root;
205
- let active = true;
206
- let failure;
207
- const publish = () => {
208
- if (!active)
209
- return;
210
- if (failure) {
211
- publishSnapshot({ error: failure });
212
- return;
213
- }
214
- const current = root?.model();
215
- if (current !== undefined)
216
- publishSnapshot({ model: current });
217
- };
218
- const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
219
- const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
220
- head: false,
221
- onEmit,
222
- fallback: ({ cause }) => {
223
- failure = new Error("Effect UI root failed", {
224
- cause: Cause.squash(cause)
225
- });
226
- return View.text("");
227
- }
228
- });
229
- if (!active)
230
- return;
231
- root = mounted;
232
- if (props !== currentProps)
233
- mounted.setProps(currentProps);
234
- publish();
235
- return yield* Effect.never;
236
- }).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
237
- return {
238
- send: (message) => {
239
- root?.send(message);
240
- publish();
241
- },
242
- setProps: (next) => {
243
- currentProps = next;
244
- root?.setProps(next);
245
- },
246
- dispose: () => {
247
- active = false;
248
- root = undefined;
249
- Effect.runFork(Fiber.interrupt(fiber));
250
- }
251
- };
252
- };
253
-
254
- // ../../src/lib/effect-ui-adapter/use-model.ts
255
- "use client";
256
- var ModelMessageLogContext = createContext(undefined);
257
- var useModel = (component, props, options = {}) => {
258
- const contextLog = useContext(ModelMessageLogContext);
259
- const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
260
- const [store] = useState(() => {
261
- const initial = { model: component.init(props).model };
262
- let snapshot = initial;
263
- const listeners = new Set;
264
- return {
265
- subscribe: (listener) => {
266
- listeners.add(listener);
267
- return () => {
268
- listeners.delete(listener);
269
- };
270
- },
271
- getSnapshot: () => snapshot,
272
- getServerSnapshot: () => initial,
273
- publish: (next) => {
274
- if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
275
- return;
276
- if ("error" in snapshot && "error" in next && snapshot.error === next.error)
277
- return;
278
- snapshot = next;
279
- listeners.forEach((listener) => listener());
280
- }
281
- };
282
- });
283
- const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
284
- const committed = useRef(props);
285
- const onEmit = useRef(options.onEmit);
286
- const runtime = useRef(undefined);
287
- const send = useCallback((message) => runtime.current?.send(message), []);
288
- useLayoutEffect(() => {
289
- onEmit.current = options.onEmit;
290
- committed.current = props;
291
- runtime.current?.setProps(props);
292
- }, [props, options.onEmit]);
293
- useEffect(() => {
294
- if (messageLog === null)
295
- return;
296
- const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
297
- runtime.current = mounted;
298
- return () => {
299
- runtime.current = undefined;
300
- mounted.dispose();
301
- };
302
- }, [component, messageLog, store]);
303
- if ("error" in snapshot)
304
- throw snapshot.error;
305
- return { model: snapshot.model, send };
306
- };
152
+ import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
307
153
 
308
154
  // ../../src/components/copy-button/index.ts
309
- import { Effect as Effect2, Redacted, Schema as Schema2 } from "effect";
310
- import { Command, Component, UiSchema, View as View2 } from "effect/ui";
155
+ import { Effect, Redacted, Schema as Schema2 } from "effect";
156
+ import { Command, Component, UiSchema, View } from "effect/ui";
311
157
 
312
158
  // ../../src/components/copy-button/schema.ts
313
159
  import { Schema } from "effect";
@@ -362,13 +208,13 @@ class WriteClipboard extends Command.Service()("copy-button/WriteClipboard", {
362
208
  },
363
209
  success: CopyButtonMessage
364
210
  }) {
365
- static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect2.tryPromise(() => write(Redacted.value(value))).pipe(Effect2.match({
211
+ static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect.tryPromise(() => write(Redacted.value(value))).pipe(Effect.match({
366
212
  onSuccess: () => CopyButtonMessage.Finished({ success: true }),
367
213
  onFailure: () => CopyButtonMessage.Finished({ success: false })
368
214
  })));
369
215
  static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
370
216
  }
371
- var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema2.Number }, mode: "switch" }, ({ delay }) => Effect2.sleep(Math.max(0, delay)).pipe(Effect2.as(CopyButtonMessage.Reset())));
217
+ var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema2.Number }, mode: "switch" }, ({ delay }) => Effect.sleep(Math.max(0, delay)).pipe(Effect.as(CopyButtonMessage.Reset())));
372
218
  var copyButtonOptions = {
373
219
  name: "CopyButton",
374
220
  props: CopyButtonModelProps,
@@ -390,7 +236,7 @@ var copyButtonBehaviours = {
390
236
  };
391
237
  var CopyButtonModel = Definition.make({
392
238
  ...copyButtonBehaviours,
393
- view: () => View2.text("")
239
+ view: () => View.text("")
394
240
  });
395
241
  var copyButtonStatus = (status, copy, description) => {
396
242
  if (status === "idle")
@@ -418,19 +264,19 @@ function CopyButton({
418
264
  }) {
419
265
  const locale = useKrakstackLocale(localeOverride);
420
266
  const labels = copyButtonMessages(locale, messages);
421
- const callbacks = useRef2({
267
+ const callbacks = useRef({
422
268
  onCopied,
423
269
  onCopyError,
424
270
  failureLabel: labels.copyFailed
425
271
  });
426
- useLayoutEffect2(() => {
272
+ useLayoutEffect(() => {
427
273
  callbacks.current = {
428
274
  onCopied,
429
275
  onCopyError,
430
276
  failureLabel: labels.copyFailed
431
277
  };
432
278
  }, [onCopied, onCopyError, labels.copyFailed]);
433
- const [component] = useState2(() => CopyButtonModel.pipe(Component2.provide(WriteClipboard.layerFromWrite(async (text) => {
279
+ const [component] = useState(() => CopyButtonModel.pipe(Component2.provide(WriteClipboard.layerFromWrite(async (text) => {
434
280
  const { onCopied, onCopyError, failureLabel } = callbacks.current;
435
281
  try {
436
282
  await navigator.clipboard.writeText(text);
@@ -497,9 +343,12 @@ function Label({ className, ...props }) {
497
343
  });
498
344
  }
499
345
 
346
+ // ../../src/components/copy-value/react.tsx
347
+ import { useModel as useModel2 } from "@krak-stack/registry/effect-ui-adapter/react";
348
+
500
349
  // ../../src/components/copy-value/index.ts
501
- import { Effect as Effect3, Redacted as Redacted3, Schema as Schema4, Stream } from "effect";
502
- import { Component as Component3, Subscription, UiSchema as UiSchema2, View as View3 } from "effect/ui";
350
+ import { Effect as Effect2, Redacted as Redacted3, Schema as Schema4, Stream } from "effect";
351
+ import { Component as Component3, Subscription, UiSchema as UiSchema2, View as View2 } from "effect/ui";
503
352
 
504
353
  // ../../src/components/copy-value/schema.ts
505
354
  import { Schema as Schema3 } from "effect";
@@ -576,13 +425,13 @@ var copyValueBehaviours = {
576
425
  }
577
426
  const delay = props.autoHideDelay ?? 0;
578
427
  return delay > 0 && Number.isFinite(delay) ? [
579
- Subscription.make("auto-hide-value", delay, (ms) => Stream.fromEffect(Effect3.sleep(ms).pipe(Effect3.as(CopyValueMessage.Hidden()))))
428
+ Subscription.make("auto-hide-value", delay, (ms) => Stream.fromEffect(Effect2.sleep(ms).pipe(Effect2.as(CopyValueMessage.Hidden()))))
580
429
  ] : [];
581
430
  }
582
431
  };
583
432
  var CopyValueModel = Definition2.make({
584
433
  ...copyValueBehaviours,
585
- view: () => View3.text("")
434
+ view: () => View2.text("")
586
435
  });
587
436
 
588
437
  // ../../src/components/copy-value/react.tsx
@@ -612,10 +461,10 @@ var CopyValue = ({
612
461
  secret,
613
462
  autoHideDelay
614
463
  };
615
- const { model, send } = useModel(CopyValueModel, props);
464
+ const { model, send } = useModel2(CopyValueModel, props);
616
465
  const revealed = isCopyValueRevealed(model, props);
617
466
  const input = /* @__PURE__ */ jsxs2(InputGroup, {
618
- className: cn("min-w-0", variant === "ghost" && "border-0 bg-transparent shadow-none dark:bg-transparent", className),
467
+ className: cn(variant === "ghost" && "border-0 bg-transparent shadow-none dark:bg-transparent", className),
619
468
  children: [
620
469
  /* @__PURE__ */ jsx6(InputGroupInput, {
621
470
  id: showLabel ? inputId : undefined,
@@ -634,9 +483,8 @@ var CopyValue = ({
634
483
  "aria-hidden": "true"
635
484
  })
636
485
  }),
637
- /* @__PURE__ */ jsxs2(InputGroupAddon, {
486
+ (secret || copyable) && /* @__PURE__ */ jsxs2(InputGroupAddon, {
638
487
  align: "inline-end",
639
- className: "gap-0",
640
488
  children: [
641
489
  secret ? /* @__PURE__ */ jsx6(InputGroupButton, {
642
490
  type: "button",
@@ -1,11 +1,11 @@
1
1
  // ../../src/components/danger-confirmation/react.tsx
2
2
  import { Component as Component2 } from "effect/ui";
3
3
  import {
4
- useEffect as useEffect2,
4
+ useEffect,
5
5
  useId,
6
- useLayoutEffect as useLayoutEffect2,
7
- useRef as useRef2,
8
- useState as useState2
6
+ useLayoutEffect,
7
+ useRef,
8
+ useState
9
9
  } from "react";
10
10
 
11
11
  // ../../src/components/ui/alert-dialog.tsx
@@ -181,161 +181,7 @@ function Label({ className, ...props }) {
181
181
 
182
182
  // ../../src/components/danger-confirmation/react.tsx
183
183
  import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
184
-
185
- // ../../src/lib/effect-ui-adapter/use-model.ts
186
- import { MessageLog as MessageLog2 } from "effect/ui";
187
- import {
188
- createContext,
189
- useCallback,
190
- useContext,
191
- useEffect,
192
- useLayoutEffect,
193
- useRef,
194
- useState,
195
- useSyncExternalStore
196
- } from "react";
197
-
198
- // ../../src/lib/effect-ui-adapter/model-runtime.ts
199
- import { MessageLog, Renderer, View } from "effect/ui";
200
- import { BrowserHost, Html } from "effect/ui/html";
201
- import { Cause, Effect, Fiber } from "effect";
202
- var node = () => ({ children: [] });
203
- var modelHost = (commit) => {
204
- const remove = (child) => {
205
- if (!child.parent)
206
- return;
207
- child.parent.children.splice(child.parent.children.indexOf(child), 1);
208
- delete child.parent;
209
- };
210
- return {
211
- createElement: node,
212
- createText: node,
213
- setText: () => {},
214
- setAttr: () => {},
215
- setProp: () => {},
216
- setEvents: () => {},
217
- insertBefore: (parent, child, before) => {
218
- if (child === before)
219
- return;
220
- remove(child);
221
- const index = before ? parent.children.indexOf(before) : parent.children.length;
222
- parent.children.splice(index, 0, child);
223
- child.parent = parent;
224
- },
225
- remove,
226
- parentOf: (child) => child.parent,
227
- nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
228
- elements: ["html"],
229
- controlled: new Set,
230
- runsMounts: false,
231
- commit
232
- };
233
- };
234
- var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
235
- let currentProps = props;
236
- let root;
237
- let active = true;
238
- let failure;
239
- const publish = () => {
240
- if (!active)
241
- return;
242
- if (failure) {
243
- publishSnapshot({ error: failure });
244
- return;
245
- }
246
- const current = root?.model();
247
- if (current !== undefined)
248
- publishSnapshot({ model: current });
249
- };
250
- const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
251
- const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
252
- head: false,
253
- onEmit,
254
- fallback: ({ cause }) => {
255
- failure = new Error("Effect UI root failed", {
256
- cause: Cause.squash(cause)
257
- });
258
- return View.text("");
259
- }
260
- });
261
- if (!active)
262
- return;
263
- root = mounted;
264
- if (props !== currentProps)
265
- mounted.setProps(currentProps);
266
- publish();
267
- return yield* Effect.never;
268
- }).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
269
- return {
270
- send: (message) => {
271
- root?.send(message);
272
- publish();
273
- },
274
- setProps: (next) => {
275
- currentProps = next;
276
- root?.setProps(next);
277
- },
278
- dispose: () => {
279
- active = false;
280
- root = undefined;
281
- Effect.runFork(Fiber.interrupt(fiber));
282
- }
283
- };
284
- };
285
-
286
- // ../../src/lib/effect-ui-adapter/use-model.ts
287
- "use client";
288
- var ModelMessageLogContext = createContext(undefined);
289
- var useModel = (component, props, options = {}) => {
290
- const contextLog = useContext(ModelMessageLogContext);
291
- const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
292
- const [store] = useState(() => {
293
- const initial = { model: component.init(props).model };
294
- let snapshot = initial;
295
- const listeners = new Set;
296
- return {
297
- subscribe: (listener) => {
298
- listeners.add(listener);
299
- return () => {
300
- listeners.delete(listener);
301
- };
302
- },
303
- getSnapshot: () => snapshot,
304
- getServerSnapshot: () => initial,
305
- publish: (next) => {
306
- if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
307
- return;
308
- if ("error" in snapshot && "error" in next && snapshot.error === next.error)
309
- return;
310
- snapshot = next;
311
- listeners.forEach((listener) => listener());
312
- }
313
- };
314
- });
315
- const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
316
- const committed = useRef(props);
317
- const onEmit = useRef(options.onEmit);
318
- const runtime = useRef(undefined);
319
- const send = useCallback((message) => runtime.current?.send(message), []);
320
- useLayoutEffect(() => {
321
- onEmit.current = options.onEmit;
322
- committed.current = props;
323
- runtime.current?.setProps(props);
324
- }, [props, options.onEmit]);
325
- useEffect(() => {
326
- if (messageLog === null)
327
- return;
328
- const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
329
- runtime.current = mounted;
330
- return () => {
331
- runtime.current = undefined;
332
- mounted.dispose();
333
- };
334
- }, [component, messageLog, store]);
335
- if ("error" in snapshot)
336
- throw snapshot.error;
337
- return { model: snapshot.model, send };
338
- };
184
+ import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
339
185
 
340
186
  // ../../src/components/danger-confirmation/classes.ts
341
187
  var dangerConfirmationClasses = {
@@ -347,8 +193,8 @@ var resolveDangerConfirmationClasses = (overrides) => ({
347
193
  });
348
194
 
349
195
  // ../../src/components/danger-confirmation/index.ts
350
- import { Effect as Effect2, Schema as Schema2 } from "effect";
351
- import { Command, Component, UiSchema, View as View2 } from "effect/ui";
196
+ import { Effect, Schema as Schema2 } from "effect";
197
+ import { Command, Component, UiSchema, View } from "effect/ui";
352
198
 
353
199
  // ../../src/components/danger-confirmation/schema.ts
354
200
  import { Schema, Struct } from "effect";
@@ -406,7 +252,7 @@ var DangerConfirmationMessage = UiSchema.TaggedEnum({
406
252
  }).annotate({ identifier: "DangerConfirmationMessage" });
407
253
 
408
254
  class RunConfirmation extends Command.Service()("danger-confirmation/RunConfirmation", { args: {}, success: DangerConfirmationMessage }) {
409
- static layerFromConfirm = (confirm) => RunConfirmation.toLayer(() => Effect2.tryPromise(async () => confirm()).pipe(Effect2.match({
255
+ static layerFromConfirm = (confirm) => RunConfirmation.toLayer(() => Effect.tryPromise(async () => confirm()).pipe(Effect.match({
410
256
  onSuccess: () => DangerConfirmationMessage.Finished({ success: true }),
411
257
  onFailure: () => DangerConfirmationMessage.Finished({ success: false })
412
258
  })));
@@ -443,7 +289,7 @@ var dangerConfirmationBehaviours = {
443
289
  };
444
290
  var DangerConfirmationModel = Definition.make({
445
291
  ...dangerConfirmationBehaviours,
446
- view: () => View2.text("")
292
+ view: () => View.text("")
447
293
  });
448
294
 
449
295
  // ../../src/components/danger-confirmation/react.tsx
@@ -454,18 +300,18 @@ var DangerConfirmation = (props) => {
454
300
  const { open, onOpenChange, onConfirm, title, description, confirmation } = props;
455
301
  const copy = getDangerConfirmationMessages(useKrakstackLocale(props.locale), props.messages);
456
302
  const id = useId();
457
- const confirm = useRef2(onConfirm);
458
- useLayoutEffect2(() => {
303
+ const confirm = useRef(onConfirm);
304
+ useLayoutEffect(() => {
459
305
  confirm.current = onConfirm;
460
306
  }, [onConfirm]);
461
- const [component] = useState2(() => DangerConfirmationModel.pipe(Component2.provide(RunConfirmation.layerFromConfirm(() => confirm.current()))));
307
+ const [component] = useState(() => DangerConfirmationModel.pipe(Component2.provide(RunConfirmation.layerFromConfirm(() => confirm.current()))));
462
308
  const { model, send } = useModel(component, {
463
309
  initiallyOpen: open,
464
310
  ...confirmation !== undefined ? { confirmation } : {}
465
311
  });
466
312
  const { status, text } = model;
467
313
  const pending = status === "pending";
468
- useEffect2(() => {
314
+ useEffect(() => {
469
315
  if (status === "succeeded")
470
316
  onOpenChange(false);
471
317
  if (open && !model.open)