@brett_lamy/ui 3.0.0 → 3.1.0
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/README.md +9 -2
- package/dist/components/markdown-editor.d.ts.map +1 -1
- package/dist/components/markdown-editor.js +138 -116
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -79
- package/dist/lib/append-stream.d.ts +43 -0
- package/dist/lib/append-stream.d.ts.map +1 -0
- package/dist/lib/append-stream.js +128 -0
- package/dist/lib/durable-streams.d.ts +102 -0
- package/dist/lib/durable-streams.d.ts.map +1 -0
- package/dist/lib/durable-streams.js +280 -0
- package/dist/lib/session-recorder.d.ts +87 -0
- package/dist/lib/session-recorder.d.ts.map +1 -0
- package/dist/lib/session-recorder.js +257 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
# @brett_lamy/ui
|
|
2
2
|
|
|
3
|
-
Touch-first React components inspired by UIKit container patterns. Colors come from your shadcn theme (CSS variables); the iOS look ships as an optional theme. The
|
|
3
|
+
Touch-first React components inspired by UIKit container patterns, built on react-aria-components and Tailwind v4. Colors, radius and font come from your shadcn theme (CSS variables); the iOS look ships as an optional theme. The library has lists, navigation, adaptive split views, drawers, sheets, a reusable jump rail, the Composer (a Markdown prompt box), PencilKit drawing and the message scroller. Product-specific compositions (an IDE workbench, a team-chat shell, a map chat, …) are **blocks**, installed from the shadcn registry rather than this package.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
+
Two ways, from the same source files. The docs explain both: [Installation](https://blamy.github.io/ui/#/installation) and [Optimization](https://blamy.github.io/ui/#/optimization).
|
|
8
|
+
|
|
9
|
+
- **shadcn registry (recommended for products).** `npx shadcn add https://blamy.github.io/ui/r/split-view.json` copies the source of one component and what it imports into your app (`components/ui/…`, `lib/…`), so you own the files and only ship what you use.
|
|
10
|
+
- **npm.** One dependency with everything in it:
|
|
11
|
+
|
|
7
12
|
```sh
|
|
8
13
|
npm i @brett_lamy/ui
|
|
9
14
|
```
|
|
10
15
|
|
|
11
|
-
Import the stylesheet once — and, for the iOS palette, the bl-theme (it sets shadcn's CSS variables; leave it out to use your own shadcn theme). `BLProvider` picks light/dark and a tint for a subtree:
|
|
16
|
+
Import the stylesheet once — and, for the iOS palette, the bl-theme (it sets shadcn's CSS variables; leave it out to use your own shadcn theme). `BLProvider` picks light/dark and a tint for a subtree, and `ThemeScope` scopes any set of variables to a subtree:
|
|
12
17
|
|
|
13
18
|
```css
|
|
14
19
|
@import '@brett_lamy/ui/styles.css';
|
|
@@ -27,6 +32,8 @@ export function App() {
|
|
|
27
32
|
}
|
|
28
33
|
```
|
|
29
34
|
|
|
35
|
+
The package is ESM with one output module per source module (`sideEffects` is limited to CSS), so bundlers drop what you don't import; component modules start with `'use client'` for Next.js.
|
|
36
|
+
|
|
30
37
|
React 18 and 19 are supported peer dependencies.
|
|
31
38
|
|
|
32
39
|
## IndexBar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-editor.d.ts","sourceRoot":"","sources":["../../src/components/markdown-editor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAYlE,0DAA0D;AAC1D,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClH,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAgBxD,yGAAyG;AACzG,wBAAgB,iBAAiB,CAAC,IAAI,E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) => e ? e.split(/\s+/).filter(Boolean) : [];
|
|
65
|
-
function m(e
|
|
66
|
-
|
|
65
|
+
function m(e) {
|
|
66
|
+
try {
|
|
67
|
+
return e.view.dom;
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function h(e, t) {
|
|
73
|
+
let n, r = !1, i = () => {
|
|
74
|
+
r || (r = !0, e.off("mount", i), n = t());
|
|
75
|
+
};
|
|
76
|
+
return m(e) ? i() : e.on("mount", i), () => {
|
|
77
|
+
e.off("mount", i), n?.();
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function g(e, t, n) {
|
|
81
|
+
let r = m(e);
|
|
82
|
+
if (!r) return;
|
|
83
|
+
let i = e.view, a = r.closest(".gb") ?? r.parentElement;
|
|
67
84
|
if (!a) return;
|
|
68
85
|
let o = /* @__PURE__ */ new Map(), s = (e, t) => {
|
|
69
86
|
let n = p(t);
|
|
70
87
|
!e || !n.length || o.set(e, [...o.get(e) ?? [], ...n]);
|
|
71
88
|
};
|
|
72
|
-
s(a, t.editor), s(
|
|
89
|
+
s(a, t.editor), s(r, t.content), s(r.firstElementChild, t.title);
|
|
73
90
|
for (let [e, n] of Object.entries(f)) {
|
|
74
91
|
let r = t[e];
|
|
75
92
|
r && a.querySelectorAll(n).forEach((e) => s(e, r));
|
|
@@ -82,7 +99,7 @@ function m(e, t, n) {
|
|
|
82
99
|
}
|
|
83
100
|
}
|
|
84
101
|
if (l) {
|
|
85
|
-
|
|
102
|
+
i.domObserver?.stop();
|
|
86
103
|
try {
|
|
87
104
|
for (let [e, t] of n) o.has(e) || e.classList.remove(...t);
|
|
88
105
|
for (let [e, t] of o) {
|
|
@@ -90,13 +107,13 @@ function m(e, t, n) {
|
|
|
90
107
|
r && e.classList.remove(...r.filter((e) => !t.includes(e))), e.classList.add(...t);
|
|
91
108
|
}
|
|
92
109
|
} finally {
|
|
93
|
-
|
|
110
|
+
i.domObserver?.start();
|
|
94
111
|
}
|
|
95
112
|
n.clear();
|
|
96
113
|
for (let [e, t] of o) n.set(e, t);
|
|
97
114
|
}
|
|
98
115
|
}
|
|
99
|
-
var
|
|
116
|
+
var _ = (e) => typeof e == "number" ? `${e}px` : e, v = [
|
|
100
117
|
"--popover",
|
|
101
118
|
"--popover-foreground",
|
|
102
119
|
"--card",
|
|
@@ -109,7 +126,7 @@ var h = (e) => typeof e == "number" ? `${e}px` : e, g = [
|
|
|
109
126
|
"--accent-foreground",
|
|
110
127
|
"--primary"
|
|
111
128
|
];
|
|
112
|
-
function
|
|
129
|
+
function y(e) {
|
|
113
130
|
t.useEffect(() => {
|
|
114
131
|
if (typeof MutationObserver > "u") return;
|
|
115
132
|
let t = new MutationObserver((t) => {
|
|
@@ -118,7 +135,7 @@ function _(e) {
|
|
|
118
135
|
let r = getComputedStyle(n);
|
|
119
136
|
for (let e of t) e.addedNodes.forEach((e) => {
|
|
120
137
|
if (!(!(e instanceof HTMLElement) || !e.matches(".react-renderer, .gb-attachment-card"))) {
|
|
121
|
-
for (let t of
|
|
138
|
+
for (let t of v) e.style.setProperty(t, r.getPropertyValue(t));
|
|
122
139
|
e.style.colorScheme = r.colorScheme, e.dataset.scheme = /dark/.test(r.colorScheme) && !/light/.test(r.colorScheme) ? "dark" : "light", e.style.fontFamily = r.fontFamily, e.dataset.markdownEditorPortal = "";
|
|
123
140
|
}
|
|
124
141
|
});
|
|
@@ -126,77 +143,79 @@ function _(e) {
|
|
|
126
143
|
return t.observe(document.body, { childList: !0 }), () => t.disconnect();
|
|
127
144
|
}, [e]);
|
|
128
145
|
}
|
|
129
|
-
var
|
|
130
|
-
let
|
|
131
|
-
markdown:
|
|
146
|
+
var b = t.forwardRef(function({ value: i, defaultValue: c = "", onValueChange: f, onSubmit: p, placeholder: v, readOnly: b = !1, disabled: x = !1, invalid: S = !1, autoFocus: ee = !1, toolbar: C = !1, slashMenu: te = !0, references: ne = !1, pasteMarkdown: w = !0, imagePaste: re = "inline", attachments: T, onAttachmentAdd: E, onAttachmentRemove: D, onAttachmentOpen: O, onKeyDown: k, onPaste: A, onFocus: j, onBlur: M, onEditorReady: N, minHeight: P, maxHeight: F, name: I, id: L, "aria-label": R, "aria-labelledby": z, "aria-describedby": B, variant: V, size: H, className: ie, contentClassName: U, classNames: W, style: ae }, G) {
|
|
147
|
+
let K = i !== void 0, [q, oe] = t.useState(c), J = K ? i : q, [Y, se] = t.useState(null), X = t.useRef(null), Z = !b && !x, Q = t.useRef({
|
|
148
|
+
markdown: J,
|
|
132
149
|
onValueChange: f,
|
|
133
150
|
onSubmit: p,
|
|
134
|
-
onKeyDown:
|
|
135
|
-
onPaste:
|
|
136
|
-
pasteMarkdown:
|
|
137
|
-
onReady:
|
|
138
|
-
controlled:
|
|
151
|
+
onKeyDown: k,
|
|
152
|
+
onPaste: A,
|
|
153
|
+
pasteMarkdown: w,
|
|
154
|
+
onReady: N,
|
|
155
|
+
controlled: K
|
|
139
156
|
});
|
|
140
|
-
|
|
141
|
-
markdown:
|
|
157
|
+
Q.current = {
|
|
158
|
+
markdown: J,
|
|
142
159
|
onValueChange: f,
|
|
143
160
|
onSubmit: p,
|
|
144
|
-
onKeyDown:
|
|
145
|
-
onPaste:
|
|
146
|
-
pasteMarkdown:
|
|
147
|
-
onReady:
|
|
148
|
-
controlled:
|
|
161
|
+
onKeyDown: k,
|
|
162
|
+
onPaste: A,
|
|
163
|
+
pasteMarkdown: w,
|
|
164
|
+
onReady: N,
|
|
165
|
+
controlled: K
|
|
149
166
|
};
|
|
150
|
-
let
|
|
151
|
-
|
|
152
|
-
}, []),
|
|
153
|
-
if (
|
|
167
|
+
let ce = t.useCallback((e) => {
|
|
168
|
+
Q.current.markdown = e, Q.current.controlled || oe(e), Q.current.onValueChange?.(e);
|
|
169
|
+
}, []), le = t.useCallback((e) => Q.current.onKeyDown?.(e) ? !0 : e.key === "Enter" && (e.metaKey || e.ctrlKey) && Q.current.onSubmit ? (Q.current.onSubmit(Q.current.markdown), !0) : !1, []), $ = t.useRef(null), ue = t.useCallback((e) => {
|
|
170
|
+
if (Q.current.onPaste?.(e)) return !0;
|
|
154
171
|
let t = $.current;
|
|
155
|
-
if (!
|
|
172
|
+
if (!Q.current.pasteMarkdown || !t) return !1;
|
|
156
173
|
let n = e.clipboardData;
|
|
157
174
|
if (n && Array.from(n.files ?? []).some((e) => e.type.startsWith("image/")) || t.state.selection.$from.parent.type.spec.code) return !1;
|
|
158
175
|
let r = n?.getData("text/plain") ?? "";
|
|
159
176
|
return l(r) ? u(t, r) : !1;
|
|
160
|
-
}, []),
|
|
161
|
-
$.current = e,
|
|
177
|
+
}, []), de = t.useCallback((e) => {
|
|
178
|
+
$.current = e, se(e), Q.current.onReady?.(e);
|
|
162
179
|
}, []);
|
|
163
180
|
t.useEffect(() => {
|
|
164
|
-
|
|
165
|
-
}, [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
Y && !Y.isDestroyed && Y.isEditable !== Z && Y.setEditable(Z, !1);
|
|
182
|
+
}, [Y, Z]), t.useEffect(() => {
|
|
183
|
+
if (Y) return h(Y, () => {
|
|
184
|
+
let e = m(Y);
|
|
185
|
+
if (!e) return;
|
|
186
|
+
let t = {
|
|
187
|
+
id: L,
|
|
188
|
+
"aria-label": R,
|
|
189
|
+
"aria-labelledby": z,
|
|
190
|
+
"aria-describedby": B,
|
|
191
|
+
"aria-invalid": S ? "true" : void 0,
|
|
192
|
+
"aria-readonly": b ? "true" : void 0,
|
|
193
|
+
"aria-disabled": x ? "true" : void 0,
|
|
194
|
+
"aria-placeholder": v
|
|
195
|
+
};
|
|
196
|
+
for (let [n, r] of Object.entries(t)) r === void 0 ? e.removeAttribute(n) : e.setAttribute(n, r);
|
|
197
|
+
});
|
|
179
198
|
}, [
|
|
180
|
-
|
|
181
|
-
I,
|
|
199
|
+
Y,
|
|
182
200
|
L,
|
|
183
201
|
R,
|
|
184
202
|
z,
|
|
203
|
+
B,
|
|
204
|
+
S,
|
|
185
205
|
b,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
g
|
|
206
|
+
x,
|
|
207
|
+
v
|
|
189
208
|
]), t.useEffect(() => {
|
|
190
|
-
if (!
|
|
191
|
-
let e = () =>
|
|
192
|
-
return
|
|
193
|
-
|
|
209
|
+
if (!Y) return;
|
|
210
|
+
let e = () => j?.(), t = () => M?.();
|
|
211
|
+
return Y.on("focus", e), Y.on("blur", t), () => {
|
|
212
|
+
Y.off("focus", e), Y.off("blur", t);
|
|
194
213
|
};
|
|
195
214
|
}, [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
]), t.useImperativeHandle(
|
|
215
|
+
Y,
|
|
216
|
+
j,
|
|
217
|
+
M
|
|
218
|
+
]), t.useImperativeHandle(G, () => ({
|
|
200
219
|
get editor() {
|
|
201
220
|
return $.current;
|
|
202
221
|
},
|
|
@@ -210,7 +229,7 @@ var v = t.forwardRef(function({ value: i, defaultValue: c = "", onValueChange: f
|
|
|
210
229
|
blur: () => {
|
|
211
230
|
$.current?.commands.blur();
|
|
212
231
|
},
|
|
213
|
-
getMarkdown: () =>
|
|
232
|
+
getMarkdown: () => Q.current.markdown,
|
|
214
233
|
setMarkdown: (e) => {
|
|
215
234
|
let t = $.current;
|
|
216
235
|
t && t.commands.setContent(o(s(e)), { emitUpdate: !0 });
|
|
@@ -222,79 +241,82 @@ var v = t.forwardRef(function({ value: i, defaultValue: c = "", onValueChange: f
|
|
|
222
241
|
clear: () => {
|
|
223
242
|
$.current?.commands.clearContent(!0);
|
|
224
243
|
},
|
|
225
|
-
isEmpty: () => $.current?.isEmpty ?? !
|
|
226
|
-
}), []),
|
|
227
|
-
let
|
|
244
|
+
isEmpty: () => $.current?.isEmpty ?? !Q.current.markdown.trim()
|
|
245
|
+
}), []), y(X);
|
|
246
|
+
let fe = JSON.stringify([U, W ?? null]);
|
|
228
247
|
return t.useEffect(() => {
|
|
229
|
-
if (
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
248
|
+
if (Y) return h(Y, () => {
|
|
249
|
+
let t = {
|
|
250
|
+
...W,
|
|
251
|
+
content: e(W?.content, U) || void 0
|
|
252
|
+
}, n = /* @__PURE__ */ new Map(), r = m(Y);
|
|
253
|
+
if (!r) return;
|
|
254
|
+
let i = () => {
|
|
255
|
+
Y.isDestroyed || g(Y, t, n);
|
|
256
|
+
};
|
|
257
|
+
i();
|
|
258
|
+
let a, o = () => {
|
|
259
|
+
clearTimeout(a), a = setTimeout(i, 16);
|
|
260
|
+
}, s = () => {
|
|
261
|
+
i(), o();
|
|
262
|
+
};
|
|
263
|
+
Y.on("transaction", s);
|
|
264
|
+
let c = r.closest(".gb") ?? r, l = typeof MutationObserver > "u" ? null : new MutationObserver(() => {
|
|
265
|
+
i(), o();
|
|
266
|
+
});
|
|
267
|
+
return l?.observe(c, {
|
|
268
|
+
childList: !0,
|
|
269
|
+
subtree: !0
|
|
270
|
+
}), () => {
|
|
271
|
+
Y.off("transaction", s), l?.disconnect(), clearTimeout(a), !Y.isDestroyed && g(Y, {}, n);
|
|
272
|
+
};
|
|
245
273
|
});
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
subtree: !0
|
|
249
|
-
}), () => {
|
|
250
|
-
J.off("transaction", o), c?.disconnect(), clearTimeout(i), !J.isDestroyed && m(J, {}, n);
|
|
251
|
-
};
|
|
252
|
-
}, [J, ue]), /* @__PURE__ */ r("div", {
|
|
253
|
-
ref: Y,
|
|
274
|
+
}, [Y, fe]), /* @__PURE__ */ r("div", {
|
|
275
|
+
ref: X,
|
|
254
276
|
"data-slot": "markdown-editor",
|
|
255
|
-
"data-variant":
|
|
256
|
-
"data-readonly":
|
|
257
|
-
"data-disabled":
|
|
258
|
-
"data-invalid":
|
|
259
|
-
"data-toolbar":
|
|
277
|
+
"data-variant": V ?? "default",
|
|
278
|
+
"data-readonly": b || void 0,
|
|
279
|
+
"data-disabled": x || void 0,
|
|
280
|
+
"data-invalid": S || void 0,
|
|
281
|
+
"data-toolbar": C && Z || void 0,
|
|
260
282
|
className: e(d({
|
|
261
|
-
variant:
|
|
262
|
-
size:
|
|
263
|
-
}),
|
|
283
|
+
variant: V,
|
|
284
|
+
size: H
|
|
285
|
+
}), ie),
|
|
264
286
|
style: {
|
|
265
|
-
...
|
|
266
|
-
...
|
|
267
|
-
...
|
|
287
|
+
...P === void 0 ? {} : { "--mde-min-h": _(P) },
|
|
288
|
+
...F === void 0 ? {} : { "--mde-max-h": _(F) },
|
|
289
|
+
...ae
|
|
268
290
|
},
|
|
269
291
|
onPointerDown: (e) => {
|
|
270
292
|
let t = e.target;
|
|
271
|
-
|
|
293
|
+
Z && (t === e.currentTarget || t.matches(".gb-content, .bl-mde-doc")) && (e.preventDefault(), $.current?.commands.focus("end"));
|
|
272
294
|
},
|
|
273
295
|
children: [/* @__PURE__ */ n(a, {
|
|
274
|
-
markdown:
|
|
275
|
-
onChange:
|
|
276
|
-
toolbar:
|
|
296
|
+
markdown: J,
|
|
297
|
+
onChange: ce,
|
|
298
|
+
toolbar: C && Z,
|
|
277
299
|
slashMenu: te,
|
|
278
300
|
references: ne,
|
|
279
|
-
editable:
|
|
280
|
-
...
|
|
301
|
+
editable: Z,
|
|
302
|
+
...v === void 0 ? {} : { placeholder: v },
|
|
281
303
|
autofocus: ee,
|
|
282
304
|
className: "bl-mde-doc",
|
|
283
|
-
onKeyDown:
|
|
284
|
-
onPaste:
|
|
285
|
-
imagePaste:
|
|
286
|
-
...
|
|
287
|
-
...
|
|
288
|
-
...
|
|
289
|
-
...
|
|
290
|
-
onEditorReady:
|
|
291
|
-
}),
|
|
305
|
+
onKeyDown: le,
|
|
306
|
+
onPaste: ue,
|
|
307
|
+
imagePaste: re,
|
|
308
|
+
...T ? { attachments: T } : {},
|
|
309
|
+
...E ? { onAttachmentAdd: E } : {},
|
|
310
|
+
...D ? { onAttachmentRemove: D } : {},
|
|
311
|
+
...O ? { onAttachmentOpen: O } : {},
|
|
312
|
+
onEditorReady: de
|
|
313
|
+
}), I === void 0 ? null : /* @__PURE__ */ n("input", {
|
|
292
314
|
type: "hidden",
|
|
293
|
-
name:
|
|
294
|
-
value:
|
|
295
|
-
disabled:
|
|
315
|
+
name: I,
|
|
316
|
+
value: J,
|
|
317
|
+
disabled: x
|
|
296
318
|
})]
|
|
297
319
|
});
|
|
298
320
|
});
|
|
299
321
|
//#endregion
|
|
300
|
-
export {
|
|
322
|
+
export { b as MarkdownEditor, u as insertMarkdown, l as looksLikeMarkdown, d as markdownEditorVariants };
|