@d1vij/jassm 0.1.15 → 0.1.16
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 +41 -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,33 @@ function getTableJsonAsMarkdown(json) {
|
|
|
303
314
|
function Table(props) {
|
|
304
315
|
const styles = useStyles();
|
|
305
316
|
const ref = useRef2(null);
|
|
317
|
+
const [open, setOpen] = useState3(false);
|
|
306
318
|
const { copy } = useClipboardText2();
|
|
307
|
-
|
|
319
|
+
useEffect2(() => {
|
|
320
|
+
const elm = ref.current;
|
|
321
|
+
if (!elm)
|
|
322
|
+
return;
|
|
323
|
+
function handleMouseLeave() {
|
|
324
|
+
setOpen(false);
|
|
325
|
+
}
|
|
326
|
+
function handleMouseEnter() {
|
|
327
|
+
setOpen(true);
|
|
328
|
+
}
|
|
329
|
+
elm.addEventListener("mouseenter", handleMouseEnter);
|
|
330
|
+
elm.addEventListener("mouseleave", handleMouseLeave);
|
|
331
|
+
return () => {
|
|
332
|
+
elm.removeEventListener("mouseenter", handleMouseEnter);
|
|
333
|
+
elm.removeEventListener("mouseleave", handleMouseLeave);
|
|
334
|
+
};
|
|
335
|
+
}, []);
|
|
336
|
+
const copyAs = useCallback((format) => {
|
|
308
337
|
return async () => {
|
|
309
338
|
const elm = ref.current;
|
|
310
339
|
if (!elm)
|
|
311
340
|
return;
|
|
312
341
|
const json = getTableAsJson(elm);
|
|
313
342
|
let extractedText;
|
|
314
|
-
switch (
|
|
343
|
+
switch (format) {
|
|
315
344
|
case "html":
|
|
316
345
|
extractedText = getTableJsonAsHtml(json);
|
|
317
346
|
break;
|
|
@@ -329,7 +358,7 @@ function Table(props) {
|
|
|
329
358
|
}
|
|
330
359
|
await copy(extractedText);
|
|
331
360
|
};
|
|
332
|
-
}
|
|
361
|
+
}, [copy]);
|
|
333
362
|
return /* @__PURE__ */ jsxs("div", {
|
|
334
363
|
className: cn13(styles.table_container),
|
|
335
364
|
children: [
|
|
@@ -340,24 +369,29 @@ function Table(props) {
|
|
|
340
369
|
}),
|
|
341
370
|
/* @__PURE__ */ jsxs("details", {
|
|
342
371
|
className: cn13(styles.table_action_buttons_details),
|
|
372
|
+
open,
|
|
343
373
|
children: [
|
|
344
374
|
/* @__PURE__ */ jsx13("summary", {
|
|
345
375
|
className: cn13(styles.table_action_buttons_summary),
|
|
346
376
|
children: "Copy"
|
|
347
377
|
}),
|
|
348
378
|
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
379
|
+
setOpen,
|
|
349
380
|
label: "HTML",
|
|
350
381
|
onClick: copyAs("html")
|
|
351
382
|
}),
|
|
352
383
|
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
384
|
+
setOpen,
|
|
353
385
|
label: "CSV",
|
|
354
386
|
onClick: copyAs("csv")
|
|
355
387
|
}),
|
|
356
388
|
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
389
|
+
setOpen,
|
|
357
390
|
label: "Json",
|
|
358
391
|
onClick: copyAs("json")
|
|
359
392
|
}),
|
|
360
393
|
/* @__PURE__ */ jsx13(TableActionButton, {
|
|
394
|
+
setOpen,
|
|
361
395
|
label: "Markdown",
|
|
362
396
|
onClick: copyAs("markdown")
|
|
363
397
|
})
|
package/package.json
CHANGED