@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.
- package/CHANGELOG.md +6 -0
- package/dist/components/agent/react.js +29 -183
- package/dist/components/animated-list/react.js +16 -168
- package/dist/components/animated-number/react.js +8 -162
- package/dist/components/async-action-button/react.js +10 -164
- package/dist/components/audit-log-table/react.js +59 -213
- package/dist/components/code-block/react.js +10 -164
- package/dist/components/copy-button/react.js +10 -164
- package/dist/components/copy-value/html.js +4 -4
- package/dist/components/copy-value/react.js +20 -172
- package/dist/components/danger-confirmation/react.js +13 -167
- package/dist/components/data-table/react.js +59 -213
- package/dist/components/editable-text/react.js +14 -168
- package/dist/components/email-composer/react.js +25 -174
- package/dist/components/email-editor/react.js +34 -186
- package/dist/components/error-component/react.js +15 -169
- package/dist/components/icon-input/react.js +7 -161
- package/dist/components/image-crop-editor/react.js +19 -173
- package/dist/components/markdown/react.js +10 -164
- 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/react.js +9 -161
- package/dist/components/search-menu/react.js +11 -165
- package/dist/components/sidebar-layout/react.js +3 -157
- package/dist/components/support/react.js +14 -168
- package/dist/components/timezone-input/react.js +9 -163
- 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/services/agent/client/index.js +29 -183
- package/package.json +5 -1
|
@@ -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);
|
|
@@ -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);
|
|
@@ -388,13 +388,13 @@ var CopyValue = Html2.component({
|
|
|
388
388
|
const masked = props.secret === true && !revealed;
|
|
389
389
|
const id = h.id("value");
|
|
390
390
|
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("
|
|
391
|
+
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)
|
|
392
|
+
}).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
393
|
props: {
|
|
394
394
|
value: Redacted3.value(props.value),
|
|
395
395
|
disabled: props.disabled
|
|
396
396
|
},
|
|
397
|
-
class: cn("[&[readonly]]:bg-transparent", props.variant === "ghost" && "ps-0 font-mono")
|
|
397
|
+
class: cn("[&[readonly]]:text-foreground [&[readonly]]:bg-transparent", props.variant === "ghost" && "ps-0 font-mono")
|
|
398
398
|
}).ref(Input2).attrs({
|
|
399
399
|
id,
|
|
400
400
|
type: masked ? "password" : "text",
|
|
@@ -413,7 +413,7 @@ var CopyValue = Html2.component({
|
|
|
413
413
|
props: {
|
|
414
414
|
value: props.value,
|
|
415
415
|
valueDescription: label,
|
|
416
|
-
copyVariant: props.variant === "ghost" ? "
|
|
416
|
+
copyVariant: props.variant === "ghost" ? "sm" : "large",
|
|
417
417
|
locale,
|
|
418
418
|
disabled: props.disabled ?? false,
|
|
419
419
|
messages: props.copyMessages ?? {}
|