@d1vij/jassm 0.1.15 → 0.1.17
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/dist/index.js +43 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -229,13 +229,24 @@ function Striked(props) {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
// src/components/Elements/Table.tsx
|
|
232
|
-
import {
|
|
233
|
-
|
|
232
|
+
import {
|
|
233
|
+
cn as cn13,
|
|
234
|
+
useClipboardText as useClipboardText2
|
|
235
|
+
} from "@d1vij/shit-i-always-use";
|
|
236
|
+
import { useCallback, useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
|
|
234
237
|
import { jsx as jsx13, jsxs } from "react/jsx-runtime";
|
|
235
|
-
function TableActionButton({
|
|
238
|
+
function TableActionButton({
|
|
239
|
+
label,
|
|
240
|
+
onClick,
|
|
241
|
+
setOpen
|
|
242
|
+
}) {
|
|
236
243
|
const styles = useStyles();
|
|
244
|
+
function handleClick(e) {
|
|
245
|
+
setOpen(false);
|
|
246
|
+
onClick(e);
|
|
247
|
+
}
|
|
237
248
|
return /* @__PURE__ */ jsx13("button", {
|
|
238
|
-
onClick,
|
|
249
|
+
onClick: handleClick,
|
|
239
250
|
className: cn13(styles.table_action_button),
|
|
240
251
|
type: "button",
|
|
241
252
|
children: label
|
|
@@ -303,15 +314,34 @@ function getTableJsonAsMarkdown(json) {
|
|
|
303
314
|
function Table(props) {
|
|
304
315
|
const styles = useStyles();
|
|
305
316
|
const ref = useRef2(null);
|
|
317
|
+
const detailsRef = useRef2(null);
|
|
318
|
+
const [open, setOpen] = useState3(false);
|
|
306
319
|
const { copy } = useClipboardText2();
|
|
307
|
-
|
|
320
|
+
useEffect2(() => {
|
|
321
|
+
const elm = detailsRef.current;
|
|
322
|
+
if (!elm)
|
|
323
|
+
return;
|
|
324
|
+
function handleMouseLeave() {
|
|
325
|
+
setOpen(false);
|
|
326
|
+
}
|
|
327
|
+
function handleMouseEnter() {
|
|
328
|
+
setOpen(true);
|
|
329
|
+
}
|
|
330
|
+
elm.addEventListener("mouseenter", handleMouseEnter);
|
|
331
|
+
elm.addEventListener("mouseleave", handleMouseLeave);
|
|
332
|
+
return () => {
|
|
333
|
+
elm.removeEventListener("mouseenter", handleMouseEnter);
|
|
334
|
+
elm.removeEventListener("mouseleave", handleMouseLeave);
|
|
335
|
+
};
|
|
336
|
+
}, []);
|
|
337
|
+
const copyAs = useCallback((format) => {
|
|
308
338
|
return async () => {
|
|
309
339
|
const elm = ref.current;
|
|
310
340
|
if (!elm)
|
|
311
341
|
return;
|
|
312
342
|
const json = getTableAsJson(elm);
|
|
313
343
|
let extractedText;
|
|
314
|
-
switch (
|
|
344
|
+
switch (format) {
|
|
315
345
|
case "html":
|
|
316
346
|
extractedText = getTableJsonAsHtml(json);
|
|
317
347
|
break;
|
|
@@ -329,7 +359,7 @@ function Table(props) {
|
|
|
329
359
|
}
|
|
330
360
|
await copy(extractedText);
|
|
331
361
|
};
|
|
332
|
-
}
|
|
362
|
+
}, [copy]);
|
|
333
363
|
return /* @__PURE__ */ jsxs("div", {
|
|
334
364
|
className: cn13(styles.table_container),
|
|
335
365
|
children: [
|
|
@@ -339,25 +369,31 @@ function Table(props) {
|
|
|
339
369
|
children: props.children
|
|
340
370
|
}),
|
|
341
371
|
/* @__PURE__ */ jsxs("details", {
|
|
372
|
+
ref: detailsRef,
|
|
342
373
|
className: cn13(styles.table_action_buttons_details),
|
|
374
|
+
open,
|
|
343
375
|
children: [
|
|
344
376
|
/* @__PURE__ */ jsx13("summary", {
|
|
345
377
|
className: cn13(styles.table_action_buttons_summary),
|
|
346
378
|
children: "Copy"
|
|
347
379
|
}),
|
|
348
380
|
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
381
|
+
setOpen,
|
|
349
382
|
label: "HTML",
|
|
350
383
|
onClick: copyAs("html")
|
|
351
384
|
}),
|
|
352
385
|
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
386
|
+
setOpen,
|
|
353
387
|
label: "CSV",
|
|
354
388
|
onClick: copyAs("csv")
|
|
355
389
|
}),
|
|
356
390
|
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
391
|
+
setOpen,
|
|
357
392
|
label: "Json",
|
|
358
393
|
onClick: copyAs("json")
|
|
359
394
|
}),
|
|
360
395
|
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
396
|
+
setOpen,
|
|
361
397
|
label: "Markdown",
|
|
362
398
|
onClick: copyAs("markdown")
|
|
363
399
|
})
|
package/package.json
CHANGED