@brett_lamy/ui 3.0.0 → 4.0.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 +12 -5
- package/dist/components/edge-drawer.d.ts.map +1 -1
- package/dist/components/floating-sheet.d.ts +21 -5
- package/dist/components/floating-sheet.d.ts.map +1 -1
- package/dist/components/floating-sheet.js +108 -100
- 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 +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -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/dist/lib/sheet-drag.d.ts +10 -2
- package/dist/lib/sheet-drag.d.ts.map +1 -1
- package/dist/lib/sheet-drag.js +72 -69
- package/package.json +2 -1
- package/dist/components/snap-sheet.d.ts +0 -13
- package/dist/components/snap-sheet.d.ts.map +0 -1
- package/dist/components/snap-sheet.js +0 -100
|
@@ -62,14 +62,31 @@ var d = i([
|
|
|
62
62
|
link: ".ProseMirror a",
|
|
63
63
|
toolbar: ".gb-toolbar"
|
|
64
64
|
}, p = (e) => 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 };
|