@krak-stack/registry 0.11.1 → 0.11.3
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 +14 -0
- package/README.md +22 -0
- package/dist/components/agent/react.js +29 -183
- package/dist/components/animated-list/html.js +1 -105
- package/dist/components/animated-list/react.js +16 -168
- package/dist/components/animated-number/react.js +8 -162
- package/dist/components/app-switcher/html.js +1 -103
- package/dist/components/async-action-button/html.js +1 -101
- package/dist/components/async-action-button/react.js +10 -164
- package/dist/components/audit-log-table/react.js +59 -213
- package/dist/components/bulk-list-input/html.js +2 -102
- package/dist/components/choice-cards/html.js +1 -101
- package/dist/components/code-block/html.js +1 -101
- package/dist/components/code-block/react.js +10 -164
- package/dist/components/copy-button/html.d.ts +2 -2
- package/dist/components/copy-button/html.js +1 -101
- package/dist/components/copy-button/react.js +10 -164
- package/dist/components/copy-value/html.js +6 -105
- package/dist/components/copy-value/react.js +20 -172
- package/dist/components/danger-confirmation/react.js +13 -167
- package/dist/components/data-table/html.d.ts +51 -51
- package/dist/components/data-table/html.js +28 -101
- package/dist/components/data-table/react.js +59 -213
- package/dist/components/date-input/html.js +2 -105
- package/dist/components/editable-text/html.d.ts +2 -2
- package/dist/components/editable-text/html.js +4 -102
- package/dist/components/editable-text/react.js +14 -168
- package/dist/components/editing-locale-switcher/html.js +2 -102
- package/dist/components/email-composer/react.js +25 -174
- package/dist/components/email-editor/html.js +8 -107
- package/dist/components/email-editor/react.js +34 -186
- package/dist/components/error-component/html.d.ts +4 -4
- package/dist/components/error-component/html.js +10 -107
- package/dist/components/error-component/react.js +15 -169
- package/dist/components/file-input/html.js +6 -106
- package/dist/components/icon-input/html.js +3 -103
- package/dist/components/icon-input/react.js +7 -161
- package/dist/components/image-crop-editor/html.js +1 -101
- package/dist/components/image-crop-editor/react.js +19 -173
- package/dist/components/loading/html.js +1 -101
- package/dist/components/locale-switcher/html.js +1 -103
- package/dist/components/map-menu/html.d.ts +8 -8
- package/dist/components/map-menu/html.js +7 -106
- package/dist/components/markdown/html.js +1 -101
- package/dist/components/markdown/react.js +10 -164
- package/dist/components/notification-menu/html.js +7 -114
- package/dist/components/pagination/html.js +5 -100
- package/dist/components/presence-transition/react.js +9 -163
- package/dist/components/registry-previews/component-example.js +10 -164
- package/dist/components/rich-text-editor/html.js +14 -108
- package/dist/components/rich-text-editor/react.js +9 -161
- package/dist/components/search-menu/html.js +1 -103
- package/dist/components/search-menu/react.js +11 -165
- package/dist/components/sidebar-layout/html.js +2 -102
- package/dist/components/sidebar-layout/react.js +3 -157
- package/dist/components/stepper/html.js +4 -102
- package/dist/components/support/html.js +1 -101
- package/dist/components/support/react.js +14 -168
- package/dist/components/theme-switcher/html.js +4 -105
- package/dist/components/time-input/html.d.ts +2 -2
- package/dist/components/time-input/html.js +1 -103
- package/dist/components/timezone-input/react.js +9 -163
- package/dist/components/toast/html.js +11 -104
- package/dist/components/upload-attachment/html.d.ts +4 -4
- package/dist/components/upload-attachment/html.js +7 -102
- package/dist/components/webhook-delivery-table/html.js +28 -101
- package/dist/components/webhook-delivery-table/react.js +74 -226
- package/dist/lib/docs.integrations.server.js +16 -35
- package/dist/lib/docs.js +31 -183
- package/dist/lib/docs.server.js +16 -35
- package/dist/lib/documentation-toolkit.js +19 -38
- package/dist/lib/effect-ui-adapter/use-model.js +158 -0
- package/dist/lib/lucide-effect.d.ts +2432 -0
- package/dist/lib/lucide-effect.js +7428 -0
- package/dist/services/agent/client/index.js +29 -183
- package/package.json +10 -2
|
@@ -50,167 +50,13 @@ function Button({
|
|
|
50
50
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
51
51
|
import { Redacted as Redacted2 } from "effect";
|
|
52
52
|
import { Component as Component2 } from "effect/ui";
|
|
53
|
-
import { useLayoutEffect
|
|
53
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
54
54
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
55
|
-
|
|
56
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
57
|
-
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
58
|
-
import {
|
|
59
|
-
createContext,
|
|
60
|
-
useCallback,
|
|
61
|
-
useContext,
|
|
62
|
-
useEffect,
|
|
63
|
-
useLayoutEffect,
|
|
64
|
-
useRef,
|
|
65
|
-
useState,
|
|
66
|
-
useSyncExternalStore
|
|
67
|
-
} from "react";
|
|
68
|
-
|
|
69
|
-
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
70
|
-
import { MessageLog, Renderer, View } from "effect/ui";
|
|
71
|
-
import { BrowserHost, Html } from "effect/ui/html";
|
|
72
|
-
import { Cause, Effect, Fiber } from "effect";
|
|
73
|
-
var node = () => ({ children: [] });
|
|
74
|
-
var modelHost = (commit) => {
|
|
75
|
-
const remove = (child) => {
|
|
76
|
-
if (!child.parent)
|
|
77
|
-
return;
|
|
78
|
-
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
79
|
-
delete child.parent;
|
|
80
|
-
};
|
|
81
|
-
return {
|
|
82
|
-
createElement: node,
|
|
83
|
-
createText: node,
|
|
84
|
-
setText: () => {},
|
|
85
|
-
setAttr: () => {},
|
|
86
|
-
setProp: () => {},
|
|
87
|
-
setEvents: () => {},
|
|
88
|
-
insertBefore: (parent, child, before) => {
|
|
89
|
-
if (child === before)
|
|
90
|
-
return;
|
|
91
|
-
remove(child);
|
|
92
|
-
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
93
|
-
parent.children.splice(index, 0, child);
|
|
94
|
-
child.parent = parent;
|
|
95
|
-
},
|
|
96
|
-
remove,
|
|
97
|
-
parentOf: (child) => child.parent,
|
|
98
|
-
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
99
|
-
elements: ["html"],
|
|
100
|
-
controlled: new Set,
|
|
101
|
-
runsMounts: false,
|
|
102
|
-
commit
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
106
|
-
let currentProps = props;
|
|
107
|
-
let root;
|
|
108
|
-
let active = true;
|
|
109
|
-
let failure;
|
|
110
|
-
const publish = () => {
|
|
111
|
-
if (!active)
|
|
112
|
-
return;
|
|
113
|
-
if (failure) {
|
|
114
|
-
publishSnapshot({ error: failure });
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const current = root?.model();
|
|
118
|
-
if (current !== undefined)
|
|
119
|
-
publishSnapshot({ model: current });
|
|
120
|
-
};
|
|
121
|
-
const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
|
|
122
|
-
const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
|
|
123
|
-
head: false,
|
|
124
|
-
onEmit,
|
|
125
|
-
fallback: ({ cause }) => {
|
|
126
|
-
failure = new Error("Effect UI root failed", {
|
|
127
|
-
cause: Cause.squash(cause)
|
|
128
|
-
});
|
|
129
|
-
return View.text("");
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
if (!active)
|
|
133
|
-
return;
|
|
134
|
-
root = mounted;
|
|
135
|
-
if (props !== currentProps)
|
|
136
|
-
mounted.setProps(currentProps);
|
|
137
|
-
publish();
|
|
138
|
-
return yield* Effect.never;
|
|
139
|
-
}).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
|
|
140
|
-
return {
|
|
141
|
-
send: (message) => {
|
|
142
|
-
root?.send(message);
|
|
143
|
-
publish();
|
|
144
|
-
},
|
|
145
|
-
setProps: (next) => {
|
|
146
|
-
currentProps = next;
|
|
147
|
-
root?.setProps(next);
|
|
148
|
-
},
|
|
149
|
-
dispose: () => {
|
|
150
|
-
active = false;
|
|
151
|
-
root = undefined;
|
|
152
|
-
Effect.runFork(Fiber.interrupt(fiber));
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
158
|
-
"use client";
|
|
159
|
-
var ModelMessageLogContext = createContext(undefined);
|
|
160
|
-
var useModel = (component, props, options = {}) => {
|
|
161
|
-
const contextLog = useContext(ModelMessageLogContext);
|
|
162
|
-
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
163
|
-
const [store] = useState(() => {
|
|
164
|
-
const initial = { model: component.init(props).model };
|
|
165
|
-
let snapshot = initial;
|
|
166
|
-
const listeners = new Set;
|
|
167
|
-
return {
|
|
168
|
-
subscribe: (listener) => {
|
|
169
|
-
listeners.add(listener);
|
|
170
|
-
return () => {
|
|
171
|
-
listeners.delete(listener);
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
getSnapshot: () => snapshot,
|
|
175
|
-
getServerSnapshot: () => initial,
|
|
176
|
-
publish: (next) => {
|
|
177
|
-
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
178
|
-
return;
|
|
179
|
-
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
180
|
-
return;
|
|
181
|
-
snapshot = next;
|
|
182
|
-
listeners.forEach((listener) => listener());
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
187
|
-
const committed = useRef(props);
|
|
188
|
-
const onEmit = useRef(options.onEmit);
|
|
189
|
-
const runtime = useRef(undefined);
|
|
190
|
-
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
191
|
-
useLayoutEffect(() => {
|
|
192
|
-
onEmit.current = options.onEmit;
|
|
193
|
-
committed.current = props;
|
|
194
|
-
runtime.current?.setProps(props);
|
|
195
|
-
}, [props, options.onEmit]);
|
|
196
|
-
useEffect(() => {
|
|
197
|
-
if (messageLog === null)
|
|
198
|
-
return;
|
|
199
|
-
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
200
|
-
runtime.current = mounted;
|
|
201
|
-
return () => {
|
|
202
|
-
runtime.current = undefined;
|
|
203
|
-
mounted.dispose();
|
|
204
|
-
};
|
|
205
|
-
}, [component, messageLog, store]);
|
|
206
|
-
if ("error" in snapshot)
|
|
207
|
-
throw snapshot.error;
|
|
208
|
-
return { model: snapshot.model, send };
|
|
209
|
-
};
|
|
55
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
210
56
|
|
|
211
57
|
// ../../src/components/copy-button/index.ts
|
|
212
|
-
import { Effect
|
|
213
|
-
import { Command, Component, UiSchema, View
|
|
58
|
+
import { Effect, Redacted, Schema as Schema2 } from "effect";
|
|
59
|
+
import { Command, Component, UiSchema, View } from "effect/ui";
|
|
214
60
|
|
|
215
61
|
// ../../src/components/copy-button/schema.ts
|
|
216
62
|
import { Schema } from "effect";
|
|
@@ -265,13 +111,13 @@ class WriteClipboard extends Command.Service()("copy-button/WriteClipboard", {
|
|
|
265
111
|
},
|
|
266
112
|
success: CopyButtonMessage
|
|
267
113
|
}) {
|
|
268
|
-
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) =>
|
|
114
|
+
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect.tryPromise(() => write(Redacted.value(value))).pipe(Effect.match({
|
|
269
115
|
onSuccess: () => CopyButtonMessage.Finished({ success: true }),
|
|
270
116
|
onFailure: () => CopyButtonMessage.Finished({ success: false })
|
|
271
117
|
})));
|
|
272
118
|
static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
|
|
273
119
|
}
|
|
274
|
-
var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema2.Number }, mode: "switch" }, ({ delay }) =>
|
|
120
|
+
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())));
|
|
275
121
|
var copyButtonOptions = {
|
|
276
122
|
name: "CopyButton",
|
|
277
123
|
props: CopyButtonModelProps,
|
|
@@ -293,7 +139,7 @@ var copyButtonBehaviours = {
|
|
|
293
139
|
};
|
|
294
140
|
var CopyButtonModel = Definition.make({
|
|
295
141
|
...copyButtonBehaviours,
|
|
296
|
-
view: () =>
|
|
142
|
+
view: () => View.text("")
|
|
297
143
|
});
|
|
298
144
|
var copyButtonStatus = (status, copy, description) => {
|
|
299
145
|
if (status === "idle")
|
|
@@ -321,19 +167,19 @@ function CopyButton({
|
|
|
321
167
|
}) {
|
|
322
168
|
const locale = useKrakstackLocale(localeOverride);
|
|
323
169
|
const labels = copyButtonMessages(locale, messages);
|
|
324
|
-
const callbacks =
|
|
170
|
+
const callbacks = useRef({
|
|
325
171
|
onCopied,
|
|
326
172
|
onCopyError,
|
|
327
173
|
failureLabel: labels.copyFailed
|
|
328
174
|
});
|
|
329
|
-
|
|
175
|
+
useLayoutEffect(() => {
|
|
330
176
|
callbacks.current = {
|
|
331
177
|
onCopied,
|
|
332
178
|
onCopyError,
|
|
333
179
|
failureLabel: labels.copyFailed
|
|
334
180
|
};
|
|
335
181
|
}, [onCopied, onCopyError, labels.copyFailed]);
|
|
336
|
-
const [component] =
|
|
182
|
+
const [component] = useState(() => CopyButtonModel.pipe(Component2.provide(WriteClipboard.layerFromWrite(async (text) => {
|
|
337
183
|
const { onCopied, onCopyError, failureLabel } = callbacks.current;
|
|
338
184
|
try {
|
|
339
185
|
await navigator.clipboard.writeText(text);
|
|
@@ -55,107 +55,7 @@ import { Schema as Schema3 } from "effect";
|
|
|
55
55
|
import { Component as Component2 } from "effect/ui";
|
|
56
56
|
import { Html } from "effect/ui/html";
|
|
57
57
|
import { krakstackLocaleRead } from "@krak-stack/registry/krakstack-provider/html";
|
|
58
|
-
|
|
59
|
-
// ../../src/lib/lucide-effect.ts
|
|
60
|
-
import {
|
|
61
|
-
ArrowDown as arrowDown,
|
|
62
|
-
ArrowUp as arrowUp,
|
|
63
|
-
ListFilter as listFilter,
|
|
64
|
-
Check as check,
|
|
65
|
-
ChevronLeft as chevronLeft,
|
|
66
|
-
ChevronDown as chevronDown,
|
|
67
|
-
ChevronRight as chevronRight,
|
|
68
|
-
ChevronsLeft as chevronsLeft,
|
|
69
|
-
ChevronsRight as chevronsRight,
|
|
70
|
-
ChevronsUpDown as chevronsUpDown,
|
|
71
|
-
Copy as copy,
|
|
72
|
-
Download as download,
|
|
73
|
-
Eye as eye,
|
|
74
|
-
EyeOff as eyeOff,
|
|
75
|
-
Ellipsis as ellipsis,
|
|
76
|
-
FileJson as fileJson,
|
|
77
|
-
FileText as fileText,
|
|
78
|
-
GripVertical as gripVertical,
|
|
79
|
-
Image as image,
|
|
80
|
-
LayoutGrid as layoutGrid,
|
|
81
|
-
LoaderCircle as loaderCircle,
|
|
82
|
-
Mail as mail,
|
|
83
|
-
Paperclip as paperclip,
|
|
84
|
-
RefreshCw as refreshCw,
|
|
85
|
-
RotateCcw as rotateCcw,
|
|
86
|
-
Rows3 as rows3,
|
|
87
|
-
Search as search,
|
|
88
|
-
Settings2 as settings2,
|
|
89
|
-
TriangleAlert as triangleAlert,
|
|
90
|
-
X as x
|
|
91
|
-
} from "lucide";
|
|
92
|
-
var createLucideIcon = (icon) => (h, {
|
|
93
|
-
size = 24,
|
|
94
|
-
color = "currentColor",
|
|
95
|
-
strokeWidth = 2,
|
|
96
|
-
className
|
|
97
|
-
} = {}) => h.svg.attrs({
|
|
98
|
-
class: className,
|
|
99
|
-
width: String(size),
|
|
100
|
-
height: String(size),
|
|
101
|
-
viewBox: "0 0 24 24",
|
|
102
|
-
fill: "none",
|
|
103
|
-
stroke: color,
|
|
104
|
-
"stroke-width": String(strokeWidth),
|
|
105
|
-
"stroke-linecap": "round",
|
|
106
|
-
"stroke-linejoin": "round",
|
|
107
|
-
"aria-hidden": "true"
|
|
108
|
-
}).children(...icon.map(([tag, attributes]) => {
|
|
109
|
-
const attrs = Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => value === undefined ? [] : [[name, String(value)]]));
|
|
110
|
-
switch (tag) {
|
|
111
|
-
case "path":
|
|
112
|
-
return h.path.attrs(attrs);
|
|
113
|
-
case "circle":
|
|
114
|
-
return h.circle.attrs(attrs);
|
|
115
|
-
case "ellipse":
|
|
116
|
-
return h.ellipse.attrs(attrs);
|
|
117
|
-
case "line":
|
|
118
|
-
return h.line.attrs(attrs);
|
|
119
|
-
case "polyline":
|
|
120
|
-
return h.polyline.attrs(attrs);
|
|
121
|
-
case "polygon":
|
|
122
|
-
return h.polygon.attrs(attrs);
|
|
123
|
-
case "rect":
|
|
124
|
-
return h.rect.attrs(attrs);
|
|
125
|
-
default:
|
|
126
|
-
throw new Error(`Unsupported Lucide SVG element: ${tag}`);
|
|
127
|
-
}
|
|
128
|
-
}));
|
|
129
|
-
var Check = createLucideIcon(check);
|
|
130
|
-
var ArrowDown = createLucideIcon(arrowDown);
|
|
131
|
-
var ArrowUp = createLucideIcon(arrowUp);
|
|
132
|
-
var ListFilter = createLucideIcon(listFilter);
|
|
133
|
-
var ChevronLeft = createLucideIcon(chevronLeft);
|
|
134
|
-
var ChevronDown = createLucideIcon(chevronDown);
|
|
135
|
-
var ChevronRight = createLucideIcon(chevronRight);
|
|
136
|
-
var ChevronsLeft = createLucideIcon(chevronsLeft);
|
|
137
|
-
var ChevronsRight = createLucideIcon(chevronsRight);
|
|
138
|
-
var ChevronsUpDown = createLucideIcon(chevronsUpDown);
|
|
139
|
-
var Copy = createLucideIcon(copy);
|
|
140
|
-
var Download = createLucideIcon(download);
|
|
141
|
-
var Eye = createLucideIcon(eye);
|
|
142
|
-
var EyeOff = createLucideIcon(eyeOff);
|
|
143
|
-
var Ellipsis = createLucideIcon(ellipsis);
|
|
144
|
-
var FileJson = createLucideIcon(fileJson);
|
|
145
|
-
var FileText = createLucideIcon(fileText);
|
|
146
|
-
var GripVertical = createLucideIcon(gripVertical);
|
|
147
|
-
var Image = createLucideIcon(image);
|
|
148
|
-
var LayoutGrid = createLucideIcon(layoutGrid);
|
|
149
|
-
var LoaderCircle = createLucideIcon(loaderCircle);
|
|
150
|
-
var Mail = createLucideIcon(mail);
|
|
151
|
-
var Paperclip = createLucideIcon(paperclip);
|
|
152
|
-
var RefreshCw = createLucideIcon(refreshCw);
|
|
153
|
-
var RotateCcw = createLucideIcon(rotateCcw);
|
|
154
|
-
var Rows3 = createLucideIcon(rows3);
|
|
155
|
-
var Search = createLucideIcon(search);
|
|
156
|
-
var Settings2 = createLucideIcon(settings2);
|
|
157
|
-
var TriangleAlert = createLucideIcon(triangleAlert);
|
|
158
|
-
var X = createLucideIcon(x);
|
|
58
|
+
import { Check, Copy, TriangleAlert } from "@krak-stack/registry/lucide-effect";
|
|
159
59
|
|
|
160
60
|
// ../../src/components/copy-button/index.ts
|
|
161
61
|
import { Effect, Redacted, Schema as Schema2 } from "effect";
|
|
@@ -280,6 +180,7 @@ var CopyButton = Html.component({
|
|
|
280
180
|
|
|
281
181
|
// ../../src/components/copy-value/html.ts
|
|
282
182
|
import { krakstackLocaleRead as krakstackLocaleRead2 } from "@krak-stack/registry/krakstack-provider/html";
|
|
183
|
+
import { Eye, EyeOff } from "@krak-stack/registry/lucide-effect";
|
|
283
184
|
|
|
284
185
|
// ../../src/components/copy-value/index.ts
|
|
285
186
|
import { Effect as Effect2, Redacted as Redacted2, Schema as Schema5, Stream } from "effect";
|
|
@@ -388,13 +289,13 @@ var CopyValue = Html2.component({
|
|
|
388
289
|
const masked = props.secret === true && !revealed;
|
|
389
290
|
const id = h.id("value");
|
|
390
291
|
return h.div.class("grid min-w-0 gap-2").children(showLabel && h.label.class("text-sm font-medium").attr("for", id).children(label), InputGroup(h, {
|
|
391
|
-
class: cn("min-w-0 gap-1 pe-1", props.variant === "ghost" && "border-transparent bg-transparent shadow-none", props.className)
|
|
392
|
-
}).attr("role", "group").children(h.span.class("
|
|
292
|
+
class: cn("min-w-0 gap-1 [&>span:not(:empty)+input]:ps-1", (props.secret || props.copyable !== false) && "pe-1", props.variant === "ghost" && "border-transparent bg-transparent shadow-none", props.className)
|
|
293
|
+
}).attr("role", "group").children(h.span.class(cn("text-muted-foreground inline-flex shrink-0 empty:hidden [&_svg]:size-[15px]", props.variant !== "ghost" && "ms-2")).attr("aria-hidden", "true").children(h.slots.icon), Input(h, {
|
|
393
294
|
props: {
|
|
394
295
|
value: Redacted3.value(props.value),
|
|
395
296
|
disabled: props.disabled
|
|
396
297
|
},
|
|
397
|
-
class: cn("[&[readonly]]:bg-transparent", props.variant === "ghost" && "ps-0 font-mono")
|
|
298
|
+
class: cn("[&[readonly]]:text-foreground [&[readonly]]:bg-transparent", props.variant === "ghost" && "ps-0 font-mono")
|
|
398
299
|
}).ref(Input2).attrs({
|
|
399
300
|
id,
|
|
400
301
|
type: masked ? "password" : "text",
|
|
@@ -413,7 +314,7 @@ var CopyValue = Html2.component({
|
|
|
413
314
|
props: {
|
|
414
315
|
value: props.value,
|
|
415
316
|
valueDescription: label,
|
|
416
|
-
copyVariant: props.variant === "ghost" ? "
|
|
317
|
+
copyVariant: props.variant === "ghost" ? "sm" : "large",
|
|
417
318
|
locale,
|
|
418
319
|
disabled: props.disabled ?? false,
|
|
419
320
|
messages: props.copyMessages ?? {}
|
|
@@ -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
|
|
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
|
|
310
|
-
import { Command, Component, UiSchema, View
|
|
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 }) =>
|
|
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 }) =>
|
|
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: () =>
|
|
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 =
|
|
267
|
+
const callbacks = useRef({
|
|
422
268
|
onCopied,
|
|
423
269
|
onCopyError,
|
|
424
270
|
failureLabel: labels.copyFailed
|
|
425
271
|
});
|
|
426
|
-
|
|
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] =
|
|
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
|
|
502
|
-
import { Component as Component3, Subscription, UiSchema as UiSchema2, View as
|
|
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(
|
|
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: () =>
|
|
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 } =
|
|
464
|
+
const { model, send } = useModel2(CopyValueModel, props);
|
|
616
465
|
const revealed = isCopyValueRevealed(model, props);
|
|
617
466
|
const input = /* @__PURE__ */ jsxs2(InputGroup, {
|
|
618
|
-
className: cn(
|
|
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",
|