@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
|
@@ -2,107 +2,7 @@
|
|
|
2
2
|
import { Schema as Schema2 } from "effect";
|
|
3
3
|
import { Component, UiSchema } from "effect/ui";
|
|
4
4
|
import { Html } from "effect/ui/html";
|
|
5
|
-
|
|
6
|
-
// ../../src/lib/lucide-effect.ts
|
|
7
|
-
import {
|
|
8
|
-
ArrowDown as arrowDown,
|
|
9
|
-
ArrowUp as arrowUp,
|
|
10
|
-
ListFilter as listFilter,
|
|
11
|
-
Check as check,
|
|
12
|
-
ChevronLeft as chevronLeft,
|
|
13
|
-
ChevronDown as chevronDown,
|
|
14
|
-
ChevronRight as chevronRight,
|
|
15
|
-
ChevronsLeft as chevronsLeft,
|
|
16
|
-
ChevronsRight as chevronsRight,
|
|
17
|
-
ChevronsUpDown as chevronsUpDown,
|
|
18
|
-
Copy as copy,
|
|
19
|
-
Download as download,
|
|
20
|
-
Eye as eye,
|
|
21
|
-
EyeOff as eyeOff,
|
|
22
|
-
Ellipsis as ellipsis,
|
|
23
|
-
FileJson as fileJson,
|
|
24
|
-
FileText as fileText,
|
|
25
|
-
GripVertical as gripVertical,
|
|
26
|
-
Image as image,
|
|
27
|
-
LayoutGrid as layoutGrid,
|
|
28
|
-
LoaderCircle as loaderCircle,
|
|
29
|
-
Mail as mail,
|
|
30
|
-
Paperclip as paperclip,
|
|
31
|
-
RefreshCw as refreshCw,
|
|
32
|
-
RotateCcw as rotateCcw,
|
|
33
|
-
Rows3 as rows3,
|
|
34
|
-
Search as search,
|
|
35
|
-
Settings2 as settings2,
|
|
36
|
-
TriangleAlert as triangleAlert,
|
|
37
|
-
X as x
|
|
38
|
-
} from "lucide";
|
|
39
|
-
var createLucideIcon = (icon) => (h, {
|
|
40
|
-
size = 24,
|
|
41
|
-
color = "currentColor",
|
|
42
|
-
strokeWidth = 2,
|
|
43
|
-
className
|
|
44
|
-
} = {}) => h.svg.attrs({
|
|
45
|
-
class: className,
|
|
46
|
-
width: String(size),
|
|
47
|
-
height: String(size),
|
|
48
|
-
viewBox: "0 0 24 24",
|
|
49
|
-
fill: "none",
|
|
50
|
-
stroke: color,
|
|
51
|
-
"stroke-width": String(strokeWidth),
|
|
52
|
-
"stroke-linecap": "round",
|
|
53
|
-
"stroke-linejoin": "round",
|
|
54
|
-
"aria-hidden": "true"
|
|
55
|
-
}).children(...icon.map(([tag, attributes]) => {
|
|
56
|
-
const attrs = Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => value === undefined ? [] : [[name, String(value)]]));
|
|
57
|
-
switch (tag) {
|
|
58
|
-
case "path":
|
|
59
|
-
return h.path.attrs(attrs);
|
|
60
|
-
case "circle":
|
|
61
|
-
return h.circle.attrs(attrs);
|
|
62
|
-
case "ellipse":
|
|
63
|
-
return h.ellipse.attrs(attrs);
|
|
64
|
-
case "line":
|
|
65
|
-
return h.line.attrs(attrs);
|
|
66
|
-
case "polyline":
|
|
67
|
-
return h.polyline.attrs(attrs);
|
|
68
|
-
case "polygon":
|
|
69
|
-
return h.polygon.attrs(attrs);
|
|
70
|
-
case "rect":
|
|
71
|
-
return h.rect.attrs(attrs);
|
|
72
|
-
default:
|
|
73
|
-
throw new Error(`Unsupported Lucide SVG element: ${tag}`);
|
|
74
|
-
}
|
|
75
|
-
}));
|
|
76
|
-
var Check = createLucideIcon(check);
|
|
77
|
-
var ArrowDown = createLucideIcon(arrowDown);
|
|
78
|
-
var ArrowUp = createLucideIcon(arrowUp);
|
|
79
|
-
var ListFilter = createLucideIcon(listFilter);
|
|
80
|
-
var ChevronLeft = createLucideIcon(chevronLeft);
|
|
81
|
-
var ChevronDown = createLucideIcon(chevronDown);
|
|
82
|
-
var ChevronRight = createLucideIcon(chevronRight);
|
|
83
|
-
var ChevronsLeft = createLucideIcon(chevronsLeft);
|
|
84
|
-
var ChevronsRight = createLucideIcon(chevronsRight);
|
|
85
|
-
var ChevronsUpDown = createLucideIcon(chevronsUpDown);
|
|
86
|
-
var Copy = createLucideIcon(copy);
|
|
87
|
-
var Download = createLucideIcon(download);
|
|
88
|
-
var Eye = createLucideIcon(eye);
|
|
89
|
-
var EyeOff = createLucideIcon(eyeOff);
|
|
90
|
-
var Ellipsis = createLucideIcon(ellipsis);
|
|
91
|
-
var FileJson = createLucideIcon(fileJson);
|
|
92
|
-
var FileText = createLucideIcon(fileText);
|
|
93
|
-
var GripVertical = createLucideIcon(gripVertical);
|
|
94
|
-
var Image = createLucideIcon(image);
|
|
95
|
-
var LayoutGrid = createLucideIcon(layoutGrid);
|
|
96
|
-
var LoaderCircle = createLucideIcon(loaderCircle);
|
|
97
|
-
var Mail = createLucideIcon(mail);
|
|
98
|
-
var Paperclip = createLucideIcon(paperclip);
|
|
99
|
-
var RefreshCw = createLucideIcon(refreshCw);
|
|
100
|
-
var RotateCcw = createLucideIcon(rotateCcw);
|
|
101
|
-
var Rows3 = createLucideIcon(rows3);
|
|
102
|
-
var Search = createLucideIcon(search);
|
|
103
|
-
var Settings2 = createLucideIcon(settings2);
|
|
104
|
-
var TriangleAlert = createLucideIcon(triangleAlert);
|
|
105
|
-
var X = createLucideIcon(x);
|
|
5
|
+
import { createLucideIcon } from "@krak-stack/registry/lucide-effect";
|
|
106
6
|
|
|
107
7
|
// ../../src/lib/utils.ts
|
|
108
8
|
import { cn } from "cn";
|
|
@@ -44,107 +44,7 @@ var Button = (h, options = {}) => KitButton(h, {
|
|
|
44
44
|
|
|
45
45
|
// ../../src/components/copy-button/html.ts
|
|
46
46
|
import { krakstackLocaleRead } from "@krak-stack/registry/krakstack-provider/html";
|
|
47
|
-
|
|
48
|
-
// ../../src/lib/lucide-effect.ts
|
|
49
|
-
import {
|
|
50
|
-
ArrowDown as arrowDown,
|
|
51
|
-
ArrowUp as arrowUp,
|
|
52
|
-
ListFilter as listFilter,
|
|
53
|
-
Check as check,
|
|
54
|
-
ChevronLeft as chevronLeft,
|
|
55
|
-
ChevronDown as chevronDown,
|
|
56
|
-
ChevronRight as chevronRight,
|
|
57
|
-
ChevronsLeft as chevronsLeft,
|
|
58
|
-
ChevronsRight as chevronsRight,
|
|
59
|
-
ChevronsUpDown as chevronsUpDown,
|
|
60
|
-
Copy as copy,
|
|
61
|
-
Download as download,
|
|
62
|
-
Eye as eye,
|
|
63
|
-
EyeOff as eyeOff,
|
|
64
|
-
Ellipsis as ellipsis,
|
|
65
|
-
FileJson as fileJson,
|
|
66
|
-
FileText as fileText,
|
|
67
|
-
GripVertical as gripVertical,
|
|
68
|
-
Image as image,
|
|
69
|
-
LayoutGrid as layoutGrid,
|
|
70
|
-
LoaderCircle as loaderCircle,
|
|
71
|
-
Mail as mail,
|
|
72
|
-
Paperclip as paperclip,
|
|
73
|
-
RefreshCw as refreshCw,
|
|
74
|
-
RotateCcw as rotateCcw,
|
|
75
|
-
Rows3 as rows3,
|
|
76
|
-
Search as search,
|
|
77
|
-
Settings2 as settings2,
|
|
78
|
-
TriangleAlert as triangleAlert,
|
|
79
|
-
X as x
|
|
80
|
-
} from "lucide";
|
|
81
|
-
var createLucideIcon = (icon) => (h, {
|
|
82
|
-
size = 24,
|
|
83
|
-
color = "currentColor",
|
|
84
|
-
strokeWidth = 2,
|
|
85
|
-
className
|
|
86
|
-
} = {}) => h.svg.attrs({
|
|
87
|
-
class: className,
|
|
88
|
-
width: String(size),
|
|
89
|
-
height: String(size),
|
|
90
|
-
viewBox: "0 0 24 24",
|
|
91
|
-
fill: "none",
|
|
92
|
-
stroke: color,
|
|
93
|
-
"stroke-width": String(strokeWidth),
|
|
94
|
-
"stroke-linecap": "round",
|
|
95
|
-
"stroke-linejoin": "round",
|
|
96
|
-
"aria-hidden": "true"
|
|
97
|
-
}).children(...icon.map(([tag, attributes]) => {
|
|
98
|
-
const attrs = Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => value === undefined ? [] : [[name, String(value)]]));
|
|
99
|
-
switch (tag) {
|
|
100
|
-
case "path":
|
|
101
|
-
return h.path.attrs(attrs);
|
|
102
|
-
case "circle":
|
|
103
|
-
return h.circle.attrs(attrs);
|
|
104
|
-
case "ellipse":
|
|
105
|
-
return h.ellipse.attrs(attrs);
|
|
106
|
-
case "line":
|
|
107
|
-
return h.line.attrs(attrs);
|
|
108
|
-
case "polyline":
|
|
109
|
-
return h.polyline.attrs(attrs);
|
|
110
|
-
case "polygon":
|
|
111
|
-
return h.polygon.attrs(attrs);
|
|
112
|
-
case "rect":
|
|
113
|
-
return h.rect.attrs(attrs);
|
|
114
|
-
default:
|
|
115
|
-
throw new Error(`Unsupported Lucide SVG element: ${tag}`);
|
|
116
|
-
}
|
|
117
|
-
}));
|
|
118
|
-
var Check = createLucideIcon(check);
|
|
119
|
-
var ArrowDown = createLucideIcon(arrowDown);
|
|
120
|
-
var ArrowUp = createLucideIcon(arrowUp);
|
|
121
|
-
var ListFilter = createLucideIcon(listFilter);
|
|
122
|
-
var ChevronLeft = createLucideIcon(chevronLeft);
|
|
123
|
-
var ChevronDown = createLucideIcon(chevronDown);
|
|
124
|
-
var ChevronRight = createLucideIcon(chevronRight);
|
|
125
|
-
var ChevronsLeft = createLucideIcon(chevronsLeft);
|
|
126
|
-
var ChevronsRight = createLucideIcon(chevronsRight);
|
|
127
|
-
var ChevronsUpDown = createLucideIcon(chevronsUpDown);
|
|
128
|
-
var Copy = createLucideIcon(copy);
|
|
129
|
-
var Download = createLucideIcon(download);
|
|
130
|
-
var Eye = createLucideIcon(eye);
|
|
131
|
-
var EyeOff = createLucideIcon(eyeOff);
|
|
132
|
-
var Ellipsis = createLucideIcon(ellipsis);
|
|
133
|
-
var FileJson = createLucideIcon(fileJson);
|
|
134
|
-
var FileText = createLucideIcon(fileText);
|
|
135
|
-
var GripVertical = createLucideIcon(gripVertical);
|
|
136
|
-
var Image = createLucideIcon(image);
|
|
137
|
-
var LayoutGrid = createLucideIcon(layoutGrid);
|
|
138
|
-
var LoaderCircle = createLucideIcon(loaderCircle);
|
|
139
|
-
var Mail = createLucideIcon(mail);
|
|
140
|
-
var Paperclip = createLucideIcon(paperclip);
|
|
141
|
-
var RefreshCw = createLucideIcon(refreshCw);
|
|
142
|
-
var RotateCcw = createLucideIcon(rotateCcw);
|
|
143
|
-
var Rows3 = createLucideIcon(rows3);
|
|
144
|
-
var Search = createLucideIcon(search);
|
|
145
|
-
var Settings2 = createLucideIcon(settings2);
|
|
146
|
-
var TriangleAlert = createLucideIcon(triangleAlert);
|
|
147
|
-
var X = createLucideIcon(x);
|
|
47
|
+
import { Check, Copy, TriangleAlert } from "@krak-stack/registry/lucide-effect";
|
|
148
48
|
|
|
149
49
|
// ../../src/components/copy-button/index.ts
|
|
150
50
|
import { Effect, Redacted, Schema as Schema2 } from "effect";
|
|
@@ -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);
|
|
@@ -39,10 +39,10 @@ export declare const CopyButton: Component.Component<"CopyButton", {
|
|
|
39
39
|
}, {
|
|
40
40
|
readonly status: "copied" | "failed" | "idle";
|
|
41
41
|
}, {
|
|
42
|
+
readonly _tag: "Reset";
|
|
43
|
+
} | {
|
|
42
44
|
readonly _tag: "Finished";
|
|
43
45
|
readonly success: boolean;
|
|
44
46
|
} | {
|
|
45
47
|
readonly _tag: "Pressed";
|
|
46
|
-
} | {
|
|
47
|
-
readonly _tag: "Reset";
|
|
48
48
|
}, never, never, Html.Elements, {}, never>;
|
|
@@ -38,107 +38,7 @@ var Button = (h, options = {}) => KitButton(h, {
|
|
|
38
38
|
|
|
39
39
|
// ../../src/components/copy-button/html.ts
|
|
40
40
|
import { krakstackLocaleRead } from "@krak-stack/registry/krakstack-provider/html";
|
|
41
|
-
|
|
42
|
-
// ../../src/lib/lucide-effect.ts
|
|
43
|
-
import {
|
|
44
|
-
ArrowDown as arrowDown,
|
|
45
|
-
ArrowUp as arrowUp,
|
|
46
|
-
ListFilter as listFilter,
|
|
47
|
-
Check as check,
|
|
48
|
-
ChevronLeft as chevronLeft,
|
|
49
|
-
ChevronDown as chevronDown,
|
|
50
|
-
ChevronRight as chevronRight,
|
|
51
|
-
ChevronsLeft as chevronsLeft,
|
|
52
|
-
ChevronsRight as chevronsRight,
|
|
53
|
-
ChevronsUpDown as chevronsUpDown,
|
|
54
|
-
Copy as copy,
|
|
55
|
-
Download as download,
|
|
56
|
-
Eye as eye,
|
|
57
|
-
EyeOff as eyeOff,
|
|
58
|
-
Ellipsis as ellipsis,
|
|
59
|
-
FileJson as fileJson,
|
|
60
|
-
FileText as fileText,
|
|
61
|
-
GripVertical as gripVertical,
|
|
62
|
-
Image as image,
|
|
63
|
-
LayoutGrid as layoutGrid,
|
|
64
|
-
LoaderCircle as loaderCircle,
|
|
65
|
-
Mail as mail,
|
|
66
|
-
Paperclip as paperclip,
|
|
67
|
-
RefreshCw as refreshCw,
|
|
68
|
-
RotateCcw as rotateCcw,
|
|
69
|
-
Rows3 as rows3,
|
|
70
|
-
Search as search,
|
|
71
|
-
Settings2 as settings2,
|
|
72
|
-
TriangleAlert as triangleAlert,
|
|
73
|
-
X as x
|
|
74
|
-
} from "lucide";
|
|
75
|
-
var createLucideIcon = (icon) => (h, {
|
|
76
|
-
size = 24,
|
|
77
|
-
color = "currentColor",
|
|
78
|
-
strokeWidth = 2,
|
|
79
|
-
className
|
|
80
|
-
} = {}) => h.svg.attrs({
|
|
81
|
-
class: className,
|
|
82
|
-
width: String(size),
|
|
83
|
-
height: String(size),
|
|
84
|
-
viewBox: "0 0 24 24",
|
|
85
|
-
fill: "none",
|
|
86
|
-
stroke: color,
|
|
87
|
-
"stroke-width": String(strokeWidth),
|
|
88
|
-
"stroke-linecap": "round",
|
|
89
|
-
"stroke-linejoin": "round",
|
|
90
|
-
"aria-hidden": "true"
|
|
91
|
-
}).children(...icon.map(([tag, attributes]) => {
|
|
92
|
-
const attrs = Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => value === undefined ? [] : [[name, String(value)]]));
|
|
93
|
-
switch (tag) {
|
|
94
|
-
case "path":
|
|
95
|
-
return h.path.attrs(attrs);
|
|
96
|
-
case "circle":
|
|
97
|
-
return h.circle.attrs(attrs);
|
|
98
|
-
case "ellipse":
|
|
99
|
-
return h.ellipse.attrs(attrs);
|
|
100
|
-
case "line":
|
|
101
|
-
return h.line.attrs(attrs);
|
|
102
|
-
case "polyline":
|
|
103
|
-
return h.polyline.attrs(attrs);
|
|
104
|
-
case "polygon":
|
|
105
|
-
return h.polygon.attrs(attrs);
|
|
106
|
-
case "rect":
|
|
107
|
-
return h.rect.attrs(attrs);
|
|
108
|
-
default:
|
|
109
|
-
throw new Error(`Unsupported Lucide SVG element: ${tag}`);
|
|
110
|
-
}
|
|
111
|
-
}));
|
|
112
|
-
var Check = createLucideIcon(check);
|
|
113
|
-
var ArrowDown = createLucideIcon(arrowDown);
|
|
114
|
-
var ArrowUp = createLucideIcon(arrowUp);
|
|
115
|
-
var ListFilter = createLucideIcon(listFilter);
|
|
116
|
-
var ChevronLeft = createLucideIcon(chevronLeft);
|
|
117
|
-
var ChevronDown = createLucideIcon(chevronDown);
|
|
118
|
-
var ChevronRight = createLucideIcon(chevronRight);
|
|
119
|
-
var ChevronsLeft = createLucideIcon(chevronsLeft);
|
|
120
|
-
var ChevronsRight = createLucideIcon(chevronsRight);
|
|
121
|
-
var ChevronsUpDown = createLucideIcon(chevronsUpDown);
|
|
122
|
-
var Copy = createLucideIcon(copy);
|
|
123
|
-
var Download = createLucideIcon(download);
|
|
124
|
-
var Eye = createLucideIcon(eye);
|
|
125
|
-
var EyeOff = createLucideIcon(eyeOff);
|
|
126
|
-
var Ellipsis = createLucideIcon(ellipsis);
|
|
127
|
-
var FileJson = createLucideIcon(fileJson);
|
|
128
|
-
var FileText = createLucideIcon(fileText);
|
|
129
|
-
var GripVertical = createLucideIcon(gripVertical);
|
|
130
|
-
var Image = createLucideIcon(image);
|
|
131
|
-
var LayoutGrid = createLucideIcon(layoutGrid);
|
|
132
|
-
var LoaderCircle = createLucideIcon(loaderCircle);
|
|
133
|
-
var Mail = createLucideIcon(mail);
|
|
134
|
-
var Paperclip = createLucideIcon(paperclip);
|
|
135
|
-
var RefreshCw = createLucideIcon(refreshCw);
|
|
136
|
-
var RotateCcw = createLucideIcon(rotateCcw);
|
|
137
|
-
var Rows3 = createLucideIcon(rows3);
|
|
138
|
-
var Search = createLucideIcon(search);
|
|
139
|
-
var Settings2 = createLucideIcon(settings2);
|
|
140
|
-
var TriangleAlert = createLucideIcon(triangleAlert);
|
|
141
|
-
var X = createLucideIcon(x);
|
|
41
|
+
import { Check, Copy, TriangleAlert } from "@krak-stack/registry/lucide-effect";
|
|
142
42
|
|
|
143
43
|
// ../../src/components/copy-button/index.ts
|
|
144
44
|
import { Effect, Redacted, Schema as Schema2 } from "effect";
|