slack-blocks-to-jsx 0.3.0 → 0.3.2
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.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +173 -108
- package/dist/index.mjs +155 -90
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/readme.md +14 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
type Element = ButtonElement | CheckboxesElement | DatePickerElement | DateTimePickerElement | EmailInputElement | ImageElement | MultiStaticSelectElement | MultiExternalSelectElement | MultiUsersSelectElement | MultiConversationsSelectElement | MultiChannelsSelectElement | NumberInputElement | OverflowMenuElement | PlainTextInputElement | RadioButtonsElement | StaticSelectElement | ExternalSelectElement | UsersSelectElement | ConversationsSelectElement | ChannelsSelectElement | TimePickerElement | UrlTextInputElement | RichTextBlockElement;
|
|
5
5
|
type ButtonElement = {
|
|
@@ -965,6 +965,10 @@ type VideoBlock = {
|
|
|
965
965
|
* The URL to be embedded. Must match any existing {@link https://api.slack.com/reference/messaging/link-unfurling#configuring_domains unfurl domains} within the app and point to a HTTPS URL.
|
|
966
966
|
*/
|
|
967
967
|
video_url: string;
|
|
968
|
+
/**
|
|
969
|
+
* This is a custom property added by slack-block-to-jsx library to more control over iframe
|
|
970
|
+
*/
|
|
971
|
+
iframeProps?: ComponentPropsWithoutRef<"iframe">;
|
|
968
972
|
};
|
|
969
973
|
type RichTextBlock = {
|
|
970
974
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
type Element = ButtonElement | CheckboxesElement | DatePickerElement | DateTimePickerElement | EmailInputElement | ImageElement | MultiStaticSelectElement | MultiExternalSelectElement | MultiUsersSelectElement | MultiConversationsSelectElement | MultiChannelsSelectElement | NumberInputElement | OverflowMenuElement | PlainTextInputElement | RadioButtonsElement | StaticSelectElement | ExternalSelectElement | UsersSelectElement | ConversationsSelectElement | ChannelsSelectElement | TimePickerElement | UrlTextInputElement | RichTextBlockElement;
|
|
5
5
|
type ButtonElement = {
|
|
@@ -965,6 +965,10 @@ type VideoBlock = {
|
|
|
965
965
|
* The URL to be embedded. Must match any existing {@link https://api.slack.com/reference/messaging/link-unfurling#configuring_domains unfurl domains} within the app and point to a HTTPS URL.
|
|
966
966
|
*/
|
|
967
967
|
video_url: string;
|
|
968
|
+
/**
|
|
969
|
+
* This is a custom property added by slack-block-to-jsx library to more control over iframe
|
|
970
|
+
*/
|
|
971
|
+
iframeProps?: ComponentPropsWithoutRef<"iframe">;
|
|
968
972
|
};
|
|
969
973
|
type RichTextBlock = {
|
|
970
974
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1316,30 +1316,31 @@ var File = (props) => {
|
|
|
1316
1316
|
};
|
|
1317
1317
|
|
|
1318
1318
|
// src/components/blocks/header.tsx
|
|
1319
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1319
1320
|
var Header2 = (props) => {
|
|
1320
|
-
const {
|
|
1321
|
-
return
|
|
1321
|
+
const { text, block_id } = props.data;
|
|
1322
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { id: block_id, className: "mt-1 slack_blocks_to_jsx__header", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h3", { className: "text-header font-bold slack_blocks_to_jsx__header_heading", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TextObject, { data: text }) }) });
|
|
1322
1323
|
};
|
|
1323
1324
|
|
|
1324
1325
|
// src/components/blocks/image.tsx
|
|
1325
1326
|
var import_react5 = require("react");
|
|
1326
|
-
var
|
|
1327
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1327
1328
|
var Image = (props) => {
|
|
1328
1329
|
const { block_id, alt_text, image_url, image_bytes, image_height, image_width } = props.data;
|
|
1329
1330
|
const [showImage, setShowImage] = (0, import_react5.useState)(true);
|
|
1330
|
-
return /* @__PURE__ */ (0,
|
|
1331
|
-
/* @__PURE__ */ (0,
|
|
1332
|
-
/* @__PURE__ */ (0,
|
|
1331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { id: block_id, className: "my-2 flex flex-col gap-2 slack_blocks_to_jsx__image", children: [
|
|
1332
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "text-black-secondary text-small flex gap-1 items-center", children: [
|
|
1333
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { children: [
|
|
1333
1334
|
alt_text,
|
|
1334
1335
|
image_bytes && ` (${Math.round(image_bytes / 1e3)} kB)`
|
|
1335
1336
|
] }),
|
|
1336
|
-
/* @__PURE__ */ (0,
|
|
1337
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1337
1338
|
"button",
|
|
1338
1339
|
{
|
|
1339
1340
|
type: "button",
|
|
1340
1341
|
className: "w-[15px] h-[15px]",
|
|
1341
1342
|
onClick: () => setShowImage((prev) => !prev),
|
|
1342
|
-
children: /* @__PURE__ */ (0,
|
|
1343
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1343
1344
|
"svg",
|
|
1344
1345
|
{
|
|
1345
1346
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1355,7 +1356,7 @@ var Image = (props) => {
|
|
|
1355
1356
|
style: {
|
|
1356
1357
|
transform: showImage ? "rotate(0deg)" : "rotate(-90deg)"
|
|
1357
1358
|
},
|
|
1358
|
-
children: /* @__PURE__ */ (0,
|
|
1359
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1359
1360
|
"path",
|
|
1360
1361
|
{
|
|
1361
1362
|
fill: "currentColor",
|
|
@@ -1368,7 +1369,7 @@ var Image = (props) => {
|
|
|
1368
1369
|
}
|
|
1369
1370
|
)
|
|
1370
1371
|
] }),
|
|
1371
|
-
showImage && /* @__PURE__ */ (0,
|
|
1372
|
+
showImage && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "rounded-md overflow-hidden relative max-w-max", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1372
1373
|
"img",
|
|
1373
1374
|
{
|
|
1374
1375
|
src: image_url,
|
|
@@ -1383,17 +1384,17 @@ var Image = (props) => {
|
|
|
1383
1384
|
};
|
|
1384
1385
|
|
|
1385
1386
|
// src/components/blocks/input.tsx
|
|
1386
|
-
var
|
|
1387
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1387
1388
|
var Input = (props) => {
|
|
1388
1389
|
const { element: given_element, label, block_id, hint, optional, type } = props.data;
|
|
1389
1390
|
const element = given_element ? getElementComponent(given_element) : null;
|
|
1390
|
-
return /* @__PURE__ */ (0,
|
|
1391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1391
1392
|
"div",
|
|
1392
1393
|
{
|
|
1393
1394
|
id: block_id,
|
|
1394
1395
|
className: `mt-2 mb-1 text-primary slack_blocks_to_jsx__input flex w-full text-black-primary`,
|
|
1395
|
-
children: /* @__PURE__ */ (0,
|
|
1396
|
-
/* @__PURE__ */ (0,
|
|
1396
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "grow", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
1397
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1397
1398
|
TextObject,
|
|
1398
1399
|
{
|
|
1399
1400
|
data: {
|
|
@@ -1404,11 +1405,11 @@ var Input = (props) => {
|
|
|
1404
1405
|
}
|
|
1405
1406
|
}
|
|
1406
1407
|
),
|
|
1407
|
-
/* @__PURE__ */ (0,
|
|
1408
|
-
/* @__PURE__ */ (0,
|
|
1409
|
-
(hint || given_element.type === "plain_text_input") && /* @__PURE__ */ (0,
|
|
1410
|
-
hint && /* @__PURE__ */ (0,
|
|
1411
|
-
given_element.type === "plain_text_input" && /* @__PURE__ */ (0,
|
|
1408
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mb-1 flex flex-col gap-1", children: [
|
|
1409
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "relative shrink-0", children: element }),
|
|
1410
|
+
(hint || given_element.type === "plain_text_input") && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "text-black-secondary text-small flex gap-1", children: [
|
|
1411
|
+
hint && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "inline", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TextObject, { data: hint }) }),
|
|
1412
|
+
given_element.type === "plain_text_input" && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { children: "\u21B5 Please 'enter' to submit" })
|
|
1412
1413
|
] })
|
|
1413
1414
|
] })
|
|
1414
1415
|
] }) })
|
|
@@ -1417,27 +1418,27 @@ var Input = (props) => {
|
|
|
1417
1418
|
};
|
|
1418
1419
|
|
|
1419
1420
|
// src/components/blocks/rich_text/rich_text_list_wrapper.tsx
|
|
1420
|
-
var
|
|
1421
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1421
1422
|
var RichTextListWrapper = (props) => {
|
|
1422
1423
|
const _a = props, { element, children } = _a, rest = __objRest(_a, ["element", "children"]);
|
|
1423
1424
|
if (element.style === "bullet") {
|
|
1424
|
-
return /* @__PURE__ */ (0,
|
|
1425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("ul", __spreadProps(__spreadValues({}, rest), { children }));
|
|
1425
1426
|
}
|
|
1426
|
-
return /* @__PURE__ */ (0,
|
|
1427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("ol", __spreadProps(__spreadValues({}, rest), { children }));
|
|
1427
1428
|
};
|
|
1428
1429
|
|
|
1429
1430
|
// src/components/blocks/rich_text/rich_text_section_broadcast.tsx
|
|
1430
|
-
var
|
|
1431
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1431
1432
|
var RichTextSectionBroadcast = (props) => {
|
|
1432
1433
|
const { range, style } = props;
|
|
1433
1434
|
const { hooks } = useGlobalData();
|
|
1434
1435
|
if (range === "channel" && hooks.atChannel)
|
|
1435
|
-
return /* @__PURE__ */ (0,
|
|
1436
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: hooks.atChannel() });
|
|
1436
1437
|
if (range === "everyone" && hooks.atEveryone)
|
|
1437
|
-
return /* @__PURE__ */ (0,
|
|
1438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: hooks.atEveryone() });
|
|
1438
1439
|
if (range === "here" && hooks.atHere)
|
|
1439
|
-
return /* @__PURE__ */ (0,
|
|
1440
|
-
return /* @__PURE__ */ (0,
|
|
1440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: hooks.atHere() });
|
|
1441
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
1441
1442
|
"span",
|
|
1442
1443
|
{
|
|
1443
1444
|
className: `
|
|
@@ -1456,15 +1457,15 @@ var RichTextSectionBroadcast = (props) => {
|
|
|
1456
1457
|
};
|
|
1457
1458
|
|
|
1458
1459
|
// src/components/blocks/rich_text/rich_text_section_channel.tsx
|
|
1459
|
-
var
|
|
1460
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1460
1461
|
var RichTextSectionChannel = (props) => {
|
|
1461
1462
|
const { channel_id, style } = props;
|
|
1462
1463
|
const { channels, hooks } = useGlobalData();
|
|
1463
1464
|
const channel = channels.find((u) => u.id === channel_id || u.name === channel_id);
|
|
1464
1465
|
const label = (channel == null ? void 0 : channel.name) || channel_id;
|
|
1465
1466
|
if (hooks.channel)
|
|
1466
|
-
return /* @__PURE__ */ (0,
|
|
1467
|
-
return /* @__PURE__ */ (0,
|
|
1467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: hooks.channel(channel || { id: channel_id, name: label }) });
|
|
1468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
1468
1469
|
"span",
|
|
1469
1470
|
{
|
|
1470
1471
|
"data-channel-id": (channel == null ? void 0 : channel.id) || channel_id,
|
|
@@ -1484,23 +1485,23 @@ var RichTextSectionChannel = (props) => {
|
|
|
1484
1485
|
};
|
|
1485
1486
|
|
|
1486
1487
|
// src/components/blocks/rich_text/rich_text_section_emoji.tsx
|
|
1487
|
-
var
|
|
1488
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1488
1489
|
var RichTextSectionEmoji = (props) => {
|
|
1489
1490
|
const { name } = props;
|
|
1490
1491
|
const { hooks } = useGlobalData();
|
|
1491
|
-
return /* @__PURE__ */ (0,
|
|
1492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "slack_blocks_to_jsx__rich_text_section_element_emoji", children: hooks.emoji ? hooks.emoji(name) : parseEmojis(`:${name}:`) });
|
|
1492
1493
|
};
|
|
1493
1494
|
|
|
1494
1495
|
// src/components/blocks/rich_text/rich_text_section_user.tsx
|
|
1495
|
-
var
|
|
1496
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1496
1497
|
var RichTextSectionUser = (props) => {
|
|
1497
1498
|
const { user_id, style } = props;
|
|
1498
1499
|
const { users, hooks } = useGlobalData();
|
|
1499
1500
|
const user = users.find((u) => u.id === user_id || u.name === user_id);
|
|
1500
1501
|
const label = (user == null ? void 0 : user.name) || user_id;
|
|
1501
1502
|
if (hooks.user)
|
|
1502
|
-
return /* @__PURE__ */ (0,
|
|
1503
|
-
return /* @__PURE__ */ (0,
|
|
1503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: hooks.user(user || { id: user_id, name: label }) });
|
|
1504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
1504
1505
|
"span",
|
|
1505
1506
|
{
|
|
1506
1507
|
"data-user-id": (user == null ? void 0 : user.id) || user_id,
|
|
@@ -1520,15 +1521,15 @@ var RichTextSectionUser = (props) => {
|
|
|
1520
1521
|
};
|
|
1521
1522
|
|
|
1522
1523
|
// src/components/blocks/rich_text/rich_text_section_user_group.tsx
|
|
1523
|
-
var
|
|
1524
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1524
1525
|
var RichTextSectionUserGroup = (props) => {
|
|
1525
1526
|
const { usergroup_id, style } = props;
|
|
1526
1527
|
const { user_groups, hooks } = useGlobalData();
|
|
1527
1528
|
const group = user_groups.find((u) => u.id === usergroup_id || u.name === usergroup_id);
|
|
1528
1529
|
const label = (group == null ? void 0 : group.name) || usergroup_id;
|
|
1529
1530
|
if (hooks.usergroup)
|
|
1530
|
-
return /* @__PURE__ */ (0,
|
|
1531
|
-
return /* @__PURE__ */ (0,
|
|
1531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: hooks.usergroup(group || { id: usergroup_id, name: label }) });
|
|
1532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
1532
1533
|
"span",
|
|
1533
1534
|
{
|
|
1534
1535
|
"data-usergroup-id": (group == null ? void 0 : group.id) || usergroup_id,
|
|
@@ -1548,22 +1549,22 @@ var RichTextSectionUserGroup = (props) => {
|
|
|
1548
1549
|
};
|
|
1549
1550
|
|
|
1550
1551
|
// src/components/blocks/rich_text/rich_text_section.tsx
|
|
1551
|
-
var
|
|
1552
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
1552
1553
|
var RichTextSectionElement = (props) => {
|
|
1553
1554
|
const { element } = props;
|
|
1554
1555
|
if (element.type === "user")
|
|
1555
|
-
return /* @__PURE__ */ (0,
|
|
1556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RichTextSectionUser, __spreadValues({}, element));
|
|
1556
1557
|
if (element.type === "channel")
|
|
1557
|
-
return /* @__PURE__ */ (0,
|
|
1558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RichTextSectionChannel, __spreadValues({}, element));
|
|
1558
1559
|
if (element.type === "broadcast")
|
|
1559
|
-
return /* @__PURE__ */ (0,
|
|
1560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RichTextSectionBroadcast, __spreadValues({}, element));
|
|
1560
1561
|
if (element.type === "emoji")
|
|
1561
|
-
return /* @__PURE__ */ (0,
|
|
1562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RichTextSectionEmoji, __spreadValues({}, element));
|
|
1562
1563
|
if (element.type === "usergroup")
|
|
1563
|
-
return /* @__PURE__ */ (0,
|
|
1564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RichTextSectionUserGroup, __spreadValues({}, element));
|
|
1564
1565
|
if (element.type === "text") {
|
|
1565
1566
|
const { text, style } = element;
|
|
1566
|
-
return /* @__PURE__ */ (0,
|
|
1567
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
1567
1568
|
"span",
|
|
1568
1569
|
{
|
|
1569
1570
|
className: `
|
|
@@ -1579,7 +1580,7 @@ var RichTextSectionElement = (props) => {
|
|
|
1579
1580
|
}
|
|
1580
1581
|
if (element.type === "link") {
|
|
1581
1582
|
const { url, style, text } = element;
|
|
1582
|
-
return /* @__PURE__ */ (0,
|
|
1583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
1583
1584
|
"a",
|
|
1584
1585
|
{
|
|
1585
1586
|
target: "_blank",
|
|
@@ -1601,21 +1602,21 @@ var RichTextSectionElement = (props) => {
|
|
|
1601
1602
|
};
|
|
1602
1603
|
|
|
1603
1604
|
// src/components/blocks/rich_text/rich_text.tsx
|
|
1604
|
-
var
|
|
1605
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1605
1606
|
var RichText = (props) => {
|
|
1606
1607
|
const { elements, block_id } = props.data;
|
|
1607
|
-
return /* @__PURE__ */ (0,
|
|
1608
|
-
return /* @__PURE__ */ (0,
|
|
1608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { id: block_id, className: "slack_blocks_to_jsx__rich_text", children: elements.map((element, i) => {
|
|
1609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Element, { element }, `${element.type}__${i}`);
|
|
1609
1610
|
}) });
|
|
1610
1611
|
};
|
|
1611
1612
|
var Element = (props) => {
|
|
1612
1613
|
const { element } = props;
|
|
1613
1614
|
if (element.type === "rich_text_list") {
|
|
1614
1615
|
const { elements, style, border = 0, indent, offset } = element;
|
|
1615
|
-
return /* @__PURE__ */ (0,
|
|
1616
|
-
border === 1 && /* @__PURE__ */ (0,
|
|
1617
|
-
/* @__PURE__ */ (0,
|
|
1618
|
-
return /* @__PURE__ */ (0,
|
|
1616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex gap-2 slack_blocks_to_jsx__rich_text_list_element", children: [
|
|
1617
|
+
border === 1 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "w-1 rounded bg-gray-primary self-stretch" }),
|
|
1618
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(RichTextListWrapper, { element, className: `list-none`, children: elements.map((el, i) => {
|
|
1619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
1619
1620
|
"li",
|
|
1620
1621
|
{
|
|
1621
1622
|
className: "flex",
|
|
@@ -1623,22 +1624,22 @@ var Element = (props) => {
|
|
|
1623
1624
|
marginLeft: indent ? indent > 5 ? 0 : indent * 28 + 6 + 28 : 0
|
|
1624
1625
|
},
|
|
1625
1626
|
children: [
|
|
1626
|
-
style === "ordered" && /* @__PURE__ */ (0,
|
|
1627
|
+
style === "ordered" && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "w-[22px] h-[22px] shrink-0 flex items-center justify-center", children: [
|
|
1627
1628
|
i + 1,
|
|
1628
1629
|
"."
|
|
1629
1630
|
] }),
|
|
1630
|
-
style === "bullet" && /* @__PURE__ */ (0,
|
|
1631
|
-
(indent === void 0 || indent === 0 || indent === 3 || indent === 6) && /* @__PURE__ */ (0,
|
|
1632
|
-
(indent === 1 || indent === 4 || indent === 7) && /* @__PURE__ */ (0,
|
|
1633
|
-
(indent === 2 || indent === 5 || indent === 8) && /* @__PURE__ */ (0,
|
|
1631
|
+
style === "bullet" && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "w-[22px] h-[22px] shrink-0 flex items-center justify-center", children: [
|
|
1632
|
+
(indent === void 0 || indent === 0 || indent === 3 || indent === 6) && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "w-1.5 h-1.5 rounded-full bg-current" }),
|
|
1633
|
+
(indent === 1 || indent === 4 || indent === 7) && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "w-1.5 h-1.5 rounded-full border border-current" }),
|
|
1634
|
+
(indent === 2 || indent === 5 || indent === 8) && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "w-1.5 h-1.5 rounded-[1.5px] bg-current" })
|
|
1634
1635
|
] }),
|
|
1635
|
-
/* @__PURE__ */ (0,
|
|
1636
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
1636
1637
|
"div",
|
|
1637
1638
|
{
|
|
1638
1639
|
style: {
|
|
1639
1640
|
marginLeft: 6
|
|
1640
1641
|
},
|
|
1641
|
-
children: /* @__PURE__ */ (0,
|
|
1642
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Element, { element: el }, `${element.type}__${i}`)
|
|
1642
1643
|
}
|
|
1643
1644
|
)
|
|
1644
1645
|
]
|
|
@@ -1650,9 +1651,9 @@ var Element = (props) => {
|
|
|
1650
1651
|
}
|
|
1651
1652
|
if (element.type === "rich_text_preformatted") {
|
|
1652
1653
|
const { elements, border } = element;
|
|
1653
|
-
return /* @__PURE__ */ (0,
|
|
1654
|
-
border === 1 && /* @__PURE__ */ (0,
|
|
1655
|
-
/* @__PURE__ */ (0,
|
|
1654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("code", { className: "flex gap-2 w-full slack_blocks_to_jsx__rich_text_preformatted_element", children: [
|
|
1655
|
+
border === 1 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "w-1 rounded bg-gray-primary self-stretch" }),
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
1656
1657
|
"pre",
|
|
1657
1658
|
{
|
|
1658
1659
|
className: "p-2 rounded my-1 whitespace-pre-wrap bg-gray-secondary text-xs leading-[1.50001] border grow",
|
|
@@ -1661,7 +1662,7 @@ var Element = (props) => {
|
|
|
1661
1662
|
wordBreak: "normal"
|
|
1662
1663
|
},
|
|
1663
1664
|
children: elements.map((el, i) => {
|
|
1664
|
-
return /* @__PURE__ */ (0,
|
|
1665
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(RichTextSectionElement, { element: el }, `${el.type}__${i}`);
|
|
1665
1666
|
})
|
|
1666
1667
|
}
|
|
1667
1668
|
)
|
|
@@ -1669,88 +1670,152 @@ var Element = (props) => {
|
|
|
1669
1670
|
}
|
|
1670
1671
|
if (element.type === "rich_text_quote") {
|
|
1671
1672
|
const { elements, border } = element;
|
|
1672
|
-
return /* @__PURE__ */ (0,
|
|
1673
|
-
border === 1 && /* @__PURE__ */ (0,
|
|
1673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("blockquote", { className: "flex gap-2 slack_blocks_to_jsx__rich_text_quote_element", children: [
|
|
1674
|
+
border === 1 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "w-1 rounded bg-gray-primary self-stretch" }),
|
|
1674
1675
|
elements.map((el, i) => {
|
|
1675
|
-
return /* @__PURE__ */ (0,
|
|
1676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(RichTextSectionElement, { element: el }, `${el.type}__${i}`);
|
|
1676
1677
|
})
|
|
1677
1678
|
] });
|
|
1678
1679
|
}
|
|
1679
1680
|
if (element.type === "rich_text_section") {
|
|
1680
1681
|
const { elements } = element;
|
|
1681
|
-
return /* @__PURE__ */ (0,
|
|
1682
|
-
return /* @__PURE__ */ (0,
|
|
1682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "inline-block slack_blocks_to_jsx__rich_text_section_element", children: elements.map((el, i) => {
|
|
1683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(RichTextSectionElement, { element: el }, `${el.type}__${i}`);
|
|
1683
1684
|
}) });
|
|
1684
1685
|
}
|
|
1685
1686
|
return null;
|
|
1686
1687
|
};
|
|
1687
1688
|
|
|
1688
1689
|
// src/components/blocks/section.tsx
|
|
1689
|
-
var
|
|
1690
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
1690
1691
|
var Section = (props) => {
|
|
1691
1692
|
const { accessory, fields, text, block_id } = props.data;
|
|
1692
1693
|
const element = accessory ? getElementComponent(accessory) : null;
|
|
1693
1694
|
const is_stacked = accessory ? is_accessory_stacked(accessory) : false;
|
|
1694
|
-
return /* @__PURE__ */ (0,
|
|
1695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
1695
1696
|
"div",
|
|
1696
1697
|
{
|
|
1697
1698
|
id: block_id,
|
|
1698
1699
|
className: `mt-2 mb-1 text-primary slack_blocks_to_jsx__section flex w-full text-black-primary ${is_stacked ? "flex-col" : ""}`,
|
|
1699
1700
|
children: [
|
|
1700
|
-
/* @__PURE__ */ (0,
|
|
1701
|
-
text && /* @__PURE__ */ (0,
|
|
1702
|
-
fields && /* @__PURE__ */ (0,
|
|
1703
|
-
return /* @__PURE__ */ (0,
|
|
1701
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "grow", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex flex-col gap-3", children: [
|
|
1702
|
+
text && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TextObject, { data: text }),
|
|
1703
|
+
fields && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "grid grid-col-2 w-full", children: fields.map((field, i) => {
|
|
1704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TextObject, { data: field }, i);
|
|
1704
1705
|
}) })
|
|
1705
1706
|
] }) }),
|
|
1706
|
-
element && is_stacked ? element : /* @__PURE__ */ (0,
|
|
1707
|
+
element && is_stacked ? element : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "ml-2 mb-1 relative shrink-0", children: element })
|
|
1707
1708
|
]
|
|
1708
1709
|
}
|
|
1709
1710
|
);
|
|
1710
1711
|
};
|
|
1711
1712
|
|
|
1712
1713
|
// src/components/blocks/video.tsx
|
|
1714
|
+
var import_react6 = require("react");
|
|
1715
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
1713
1716
|
var Video = (props) => {
|
|
1714
|
-
const {
|
|
1715
|
-
|
|
1717
|
+
const {
|
|
1718
|
+
// thumbnail_url,
|
|
1719
|
+
// provider_icon_url,
|
|
1720
|
+
// provider_name,
|
|
1721
|
+
//
|
|
1722
|
+
alt_text,
|
|
1723
|
+
title,
|
|
1724
|
+
video_url,
|
|
1725
|
+
author_name,
|
|
1726
|
+
block_id,
|
|
1727
|
+
description,
|
|
1728
|
+
title_url,
|
|
1729
|
+
iframeProps = {}
|
|
1730
|
+
} = props.data;
|
|
1731
|
+
const [showVideo, setShowVideo] = (0, import_react6.useState)(true);
|
|
1732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "py-2 slack_blocks_to_jsx__video", id: block_id, children: [
|
|
1733
|
+
author_name && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "slack_blocks_to_jsx__video_author", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "font-bold", children: "Manish Panwar" }) }),
|
|
1734
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "slack_blocks_to_jsx__video_description", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TextObject, { data: description }) }),
|
|
1735
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-wrap items-center gap-1 slack_blocks_to_jsx__video_title", children: [
|
|
1736
|
+
title_url ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("a", { href: title_url, className: "text-blue-primary", target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TextObject, { data: title }) }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TextObject, { data: title }) }),
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
1738
|
+
"button",
|
|
1739
|
+
{
|
|
1740
|
+
type: "button",
|
|
1741
|
+
className: "w-[15px] h-[15px]",
|
|
1742
|
+
onClick: () => setShowVideo((prev) => !prev),
|
|
1743
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
1744
|
+
"svg",
|
|
1745
|
+
{
|
|
1746
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1747
|
+
fillRule: "evenodd",
|
|
1748
|
+
clipRule: "evenodd",
|
|
1749
|
+
className: "text-blue-primary",
|
|
1750
|
+
imageRendering: "optimizeQuality",
|
|
1751
|
+
shapeRendering: "geometricPrecision",
|
|
1752
|
+
textRendering: "geometricPrecision",
|
|
1753
|
+
viewBox: "0 0 512 336.36",
|
|
1754
|
+
width: 6,
|
|
1755
|
+
height: 6,
|
|
1756
|
+
style: {
|
|
1757
|
+
transform: showVideo ? "rotate(0deg)" : "rotate(-90deg)"
|
|
1758
|
+
},
|
|
1759
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
1760
|
+
"path",
|
|
1761
|
+
{
|
|
1762
|
+
fill: "currentColor",
|
|
1763
|
+
fillRule: "nonzero",
|
|
1764
|
+
d: "M42.47.01L469.5 0C492.96 0 512 19.04 512 42.5c0 11.07-4.23 21.15-11.17 28.72L294.18 320.97c-14.93 18.06-41.7 20.58-59.76 5.65-1.8-1.49-3.46-3.12-4.97-4.83L10.43 70.39C-4.97 52.71-3.1 25.86 14.58 10.47 22.63 3.46 32.57.02 42.47.01z"
|
|
1765
|
+
}
|
|
1766
|
+
)
|
|
1767
|
+
}
|
|
1768
|
+
)
|
|
1769
|
+
}
|
|
1770
|
+
)
|
|
1771
|
+
] }),
|
|
1772
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "slack_blocks_to_jsx__video_container max-w-max", children: showVideo && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
1773
|
+
"iframe",
|
|
1774
|
+
__spreadValues({
|
|
1775
|
+
title: alt_text,
|
|
1776
|
+
className: "max-w-[360px] bg-gray-100 w-full aspect-video",
|
|
1777
|
+
src: video_url
|
|
1778
|
+
}, iframeProps)
|
|
1779
|
+
) })
|
|
1780
|
+
] });
|
|
1716
1781
|
};
|
|
1717
1782
|
|
|
1718
1783
|
// src/components/index.tsx
|
|
1719
|
-
var
|
|
1784
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
1720
1785
|
var getBlockComponent = (block) => {
|
|
1721
1786
|
if (block.type === "divider")
|
|
1722
|
-
return /* @__PURE__ */ (0,
|
|
1787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Divider, { data: block });
|
|
1723
1788
|
if (block.type === "section")
|
|
1724
|
-
return /* @__PURE__ */ (0,
|
|
1789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Section, { data: block });
|
|
1725
1790
|
if (block.type === "image")
|
|
1726
|
-
return /* @__PURE__ */ (0,
|
|
1791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Image, { data: block });
|
|
1727
1792
|
if (block.type === "context")
|
|
1728
|
-
return /* @__PURE__ */ (0,
|
|
1793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Context, { data: block });
|
|
1729
1794
|
if (block.type === "actions")
|
|
1730
|
-
return /* @__PURE__ */ (0,
|
|
1795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Actions, { data: block });
|
|
1731
1796
|
if (block.type === "file")
|
|
1732
|
-
return /* @__PURE__ */ (0,
|
|
1797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(File, { data: block });
|
|
1733
1798
|
if (block.type === "header")
|
|
1734
|
-
return /* @__PURE__ */ (0,
|
|
1799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Header2, { data: block });
|
|
1735
1800
|
if (block.type === "input")
|
|
1736
|
-
return /* @__PURE__ */ (0,
|
|
1801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Input, { data: block });
|
|
1737
1802
|
if (block.type === "video")
|
|
1738
|
-
return /* @__PURE__ */ (0,
|
|
1803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Video, { data: block });
|
|
1739
1804
|
if (block.type === "rich_text")
|
|
1740
|
-
return /* @__PURE__ */ (0,
|
|
1805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(RichText, { data: block });
|
|
1741
1806
|
return null;
|
|
1742
1807
|
};
|
|
1743
1808
|
var getElementComponent = (element) => {
|
|
1744
1809
|
if (element.type === "button")
|
|
1745
|
-
return /* @__PURE__ */ (0,
|
|
1810
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ButtonElement, { data: element });
|
|
1746
1811
|
if (element.type === "checkboxes")
|
|
1747
|
-
return /* @__PURE__ */ (0,
|
|
1812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CheckboxesElement, { data: element });
|
|
1748
1813
|
if (element.type === "image")
|
|
1749
|
-
return /* @__PURE__ */ (0,
|
|
1814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ImageElement, { data: element });
|
|
1750
1815
|
if (element.type === "plain_text_input")
|
|
1751
|
-
return /* @__PURE__ */ (0,
|
|
1816
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PlaintTextInput, { data: element });
|
|
1752
1817
|
if (element.type === "users_select")
|
|
1753
|
-
return /* @__PURE__ */ (0,
|
|
1818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(UsersSelectElement, { data: element });
|
|
1754
1819
|
if (element.type === "datepicker")
|
|
1755
1820
|
return null;
|
|
1756
1821
|
if (element.type === "datetimepicker")
|
|
@@ -1789,15 +1854,15 @@ var getElementComponent = (element) => {
|
|
|
1789
1854
|
};
|
|
1790
1855
|
|
|
1791
1856
|
// src/block_wrapper.tsx
|
|
1792
|
-
var
|
|
1857
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
1793
1858
|
var BlockWrapper = (props) => {
|
|
1794
1859
|
const { children } = props;
|
|
1795
|
-
return /* @__PURE__ */ (0,
|
|
1860
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "text-base slack_blocks_to_jsx--block_wrapper break-words font-normal", children });
|
|
1796
1861
|
};
|
|
1797
1862
|
|
|
1798
1863
|
// src/message.tsx
|
|
1799
|
-
var
|
|
1800
|
-
var
|
|
1864
|
+
var import_react7 = require("react");
|
|
1865
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
1801
1866
|
var Message = (props) => {
|
|
1802
1867
|
const {
|
|
1803
1868
|
blocks,
|
|
@@ -1813,7 +1878,7 @@ var Message = (props) => {
|
|
|
1813
1878
|
withoutWrapper = false
|
|
1814
1879
|
} = props;
|
|
1815
1880
|
const { setChannels, setUsers, setHooks, setUserGroups } = useGlobalData();
|
|
1816
|
-
(0,
|
|
1881
|
+
(0, import_react7.useEffect)(() => {
|
|
1817
1882
|
if (data == null ? void 0 : data.users)
|
|
1818
1883
|
setUsers(data.users);
|
|
1819
1884
|
if (data == null ? void 0 : data.channels)
|
|
@@ -1824,7 +1889,7 @@ var Message = (props) => {
|
|
|
1824
1889
|
setHooks(hooks);
|
|
1825
1890
|
}, [data, hooks]);
|
|
1826
1891
|
if (withoutWrapper) {
|
|
1827
|
-
return /* @__PURE__ */ (0,
|
|
1892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
1828
1893
|
"div",
|
|
1829
1894
|
{
|
|
1830
1895
|
id: "slack_blocks_to_jsx",
|
|
@@ -1834,18 +1899,18 @@ var Message = (props) => {
|
|
|
1834
1899
|
const element = getBlockComponent(block);
|
|
1835
1900
|
if (!element)
|
|
1836
1901
|
return null;
|
|
1837
|
-
return /* @__PURE__ */ (0,
|
|
1902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(BlockWrapper, { children: element }, i);
|
|
1838
1903
|
})
|
|
1839
1904
|
}
|
|
1840
1905
|
);
|
|
1841
1906
|
}
|
|
1842
|
-
return /* @__PURE__ */ (0,
|
|
1907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "slack_blocks_to_jsx", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
1843
1908
|
"section",
|
|
1844
1909
|
{
|
|
1845
1910
|
className: `flex gap-2 w-full max-w-[600px] slack_blocks_to_jsx relative ${unstyled ? "styles_disabled" : "styles_enabled"} ${className}`,
|
|
1846
1911
|
style,
|
|
1847
1912
|
children: [
|
|
1848
|
-
showBlockKitDebug && /* @__PURE__ */ (0,
|
|
1913
|
+
showBlockKitDebug && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
1849
1914
|
"a",
|
|
1850
1915
|
{
|
|
1851
1916
|
target: "_blank",
|
|
@@ -1857,14 +1922,14 @@ var Message = (props) => {
|
|
|
1857
1922
|
children: "Open in Slack Block Kit Builder"
|
|
1858
1923
|
}
|
|
1859
1924
|
),
|
|
1860
|
-
/* @__PURE__ */ (0,
|
|
1861
|
-
/* @__PURE__ */ (0,
|
|
1862
|
-
/* @__PURE__ */ (0,
|
|
1863
|
-
/* @__PURE__ */ (0,
|
|
1925
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("img", { src: logo, className: "w-9 h-9", alt: name }) }),
|
|
1926
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-col w-full", children: [
|
|
1927
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Header, { name, time }),
|
|
1928
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "slack_blocks_to_jsx--blocks", children: blocks.map((block, i) => {
|
|
1864
1929
|
const element = getBlockComponent(block);
|
|
1865
1930
|
if (!element)
|
|
1866
1931
|
return null;
|
|
1867
|
-
return /* @__PURE__ */ (0,
|
|
1932
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(BlockWrapper, { children: element }, i);
|
|
1868
1933
|
}) })
|
|
1869
1934
|
] })
|
|
1870
1935
|
]
|