slack-blocks-to-jsx 0.1.1 → 0.1.3
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 +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +314 -79
- package/dist/index.mjs +314 -79
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/readme.md +4 -0
- package/postcss.config.js +0 -9
package/dist/index.d.mts
CHANGED
|
@@ -478,6 +478,16 @@ type UsersSelectElement = {
|
|
|
478
478
|
* A {@link https://api.slack.com/reference/block-kit/composition-objects#text ***plain_text*** only text object} that defines the placeholder text shown on the menu. Maximum length for the text in this field is 150 characters.
|
|
479
479
|
*/
|
|
480
480
|
placeholder?: TextObject<"plain_text">;
|
|
481
|
+
/**
|
|
482
|
+
* This is custom property for you to pass the list of people to show in the select menu. (This is not a part of the official Slack API)
|
|
483
|
+
*/
|
|
484
|
+
people: {
|
|
485
|
+
id: string;
|
|
486
|
+
name: string;
|
|
487
|
+
image: string;
|
|
488
|
+
online: boolean;
|
|
489
|
+
sleeping: boolean;
|
|
490
|
+
}[];
|
|
481
491
|
};
|
|
482
492
|
type ConversationsSelectElement = {
|
|
483
493
|
type: "conversations_select";
|
|
@@ -841,7 +851,7 @@ type InputBlock = {
|
|
|
841
851
|
/**
|
|
842
852
|
* A plain-text input element, a checkbox element, a radio button element, a select menu element, a multi-select menu element, or a datepicker.
|
|
843
853
|
*/
|
|
844
|
-
element: PlainTextInputElement | CheckboxesElement | RadioButtonsElement | StaticSelectElement | MultiStaticSelectElement | DatePickerElement;
|
|
854
|
+
element: PlainTextInputElement | CheckboxesElement | RadioButtonsElement | StaticSelectElement | MultiStaticSelectElement | DatePickerElement | UsersSelectElement;
|
|
845
855
|
/**
|
|
846
856
|
* A boolean that indicates whether or not the use of elements in this block should dispatch a {@link https://api.slack.com/reference/interaction-payloads/block-actions ***block_actions*** payload}. Defaults to false.
|
|
847
857
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -478,6 +478,16 @@ type UsersSelectElement = {
|
|
|
478
478
|
* A {@link https://api.slack.com/reference/block-kit/composition-objects#text ***plain_text*** only text object} that defines the placeholder text shown on the menu. Maximum length for the text in this field is 150 characters.
|
|
479
479
|
*/
|
|
480
480
|
placeholder?: TextObject<"plain_text">;
|
|
481
|
+
/**
|
|
482
|
+
* This is custom property for you to pass the list of people to show in the select menu. (This is not a part of the official Slack API)
|
|
483
|
+
*/
|
|
484
|
+
people: {
|
|
485
|
+
id: string;
|
|
486
|
+
name: string;
|
|
487
|
+
image: string;
|
|
488
|
+
online: boolean;
|
|
489
|
+
sleeping: boolean;
|
|
490
|
+
}[];
|
|
481
491
|
};
|
|
482
492
|
type ConversationsSelectElement = {
|
|
483
493
|
type: "conversations_select";
|
|
@@ -841,7 +851,7 @@ type InputBlock = {
|
|
|
841
851
|
/**
|
|
842
852
|
* A plain-text input element, a checkbox element, a radio button element, a select menu element, a multi-select menu element, or a datepicker.
|
|
843
853
|
*/
|
|
844
|
-
element: PlainTextInputElement | CheckboxesElement | RadioButtonsElement | StaticSelectElement | MultiStaticSelectElement | DatePickerElement;
|
|
854
|
+
element: PlainTextInputElement | CheckboxesElement | RadioButtonsElement | StaticSelectElement | MultiStaticSelectElement | DatePickerElement | UsersSelectElement;
|
|
845
855
|
/**
|
|
846
856
|
* A boolean that indicates whether or not the use of elements in this block should dispatch a {@link https://api.slack.com/reference/interaction-payloads/block-actions ***block_actions*** payload}. Defaults to false.
|
|
847
857
|
*/
|
package/dist/index.js
CHANGED
|
@@ -479,7 +479,14 @@ var Header = (props) => {
|
|
|
479
479
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
480
480
|
var ImageElement = (props) => {
|
|
481
481
|
const { alt_text, image_url } = props.data;
|
|
482
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "relative
|
|
482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
483
|
+
"img",
|
|
484
|
+
{
|
|
485
|
+
src: image_url,
|
|
486
|
+
alt: alt_text,
|
|
487
|
+
className: "w-[88px] h-[88px] rounded-lg overflow-hidden object-cover"
|
|
488
|
+
}
|
|
489
|
+
) });
|
|
483
490
|
};
|
|
484
491
|
|
|
485
492
|
// src/components/composition_objects/text_object.tsx
|
|
@@ -500,6 +507,7 @@ var ButtonElement = (props) => {
|
|
|
500
507
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
501
508
|
"button",
|
|
502
509
|
{
|
|
510
|
+
type: "button",
|
|
503
511
|
id: action_id,
|
|
504
512
|
"aria-label": accessibility_label,
|
|
505
513
|
className: `px-2 pt-0 pb-[1px] text-small h-[28px] min-w-[56px] border rounded whitespace-nowrap font-semibold slack_blocks_to_jsx__button ${style === "primary" ? "border-green-primary.3 text-green-primary" : style === "danger" ? "border-red-primary.3 text-red-primary" : "border-black-primary.3 text-black-primary"}`,
|
|
@@ -602,6 +610,7 @@ var StaticSelectElement = (props) => {
|
|
|
602
610
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
603
611
|
"button",
|
|
604
612
|
{
|
|
613
|
+
type: "button",
|
|
605
614
|
className: "absolute right-1 top-1/2 flex justify-center items-center w-5 -translate-y-1/2 text-black-secondary z-10 h-full",
|
|
606
615
|
id: "static_select_dropdown_button",
|
|
607
616
|
onClick: () => {
|
|
@@ -676,53 +685,243 @@ var CheckboxesElement = (props) => {
|
|
|
676
685
|
}) }) });
|
|
677
686
|
};
|
|
678
687
|
|
|
679
|
-
// src/components/
|
|
688
|
+
// src/components/elements/plain_text_input.tsx
|
|
689
|
+
var import_react3 = require("react");
|
|
680
690
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
691
|
+
var PlaintTextInput = (props) => {
|
|
692
|
+
const {
|
|
693
|
+
action_id,
|
|
694
|
+
dispatch_action_config,
|
|
695
|
+
focus_on_load,
|
|
696
|
+
initial_value,
|
|
697
|
+
max_length,
|
|
698
|
+
min_length,
|
|
699
|
+
multiline,
|
|
700
|
+
placeholder
|
|
701
|
+
} = props.data;
|
|
702
|
+
const [visible, setVisible] = (0, import_react3.useState)(focus_on_load != null ? focus_on_load : false);
|
|
703
|
+
const [value, setValue] = (0, import_react3.useState)(initial_value || "");
|
|
704
|
+
(0, import_react3.useEffect)(() => {
|
|
705
|
+
const handleClickOutside = (e) => {
|
|
706
|
+
var _a, _b;
|
|
707
|
+
const target = e.target;
|
|
708
|
+
console.log({ target });
|
|
709
|
+
console.log(target.id);
|
|
710
|
+
if (target.id !== "static_select_popup" && target.id !== "static_select_dropdown_button" && ((_a = target.parentElement) == null ? void 0 : _a.id) !== "static_select_popup" && ((_b = target.parentElement) == null ? void 0 : _b.id) !== "static_select_dropdown_button")
|
|
711
|
+
setVisible(false);
|
|
712
|
+
};
|
|
713
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
714
|
+
return () => {
|
|
715
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
716
|
+
};
|
|
717
|
+
}, []);
|
|
718
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { id: action_id, className: "relative text-small w-full", tabIndex: 0, children: [
|
|
719
|
+
!value && placeholder && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "absolute left-2 top-2 text-black-primary.3", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TextObject, { data: placeholder }) }),
|
|
720
|
+
!value && !placeholder && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "absolute left-2 top-2 text-black-primary.3", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
721
|
+
TextObject,
|
|
722
|
+
{
|
|
723
|
+
data: {
|
|
724
|
+
type: "plain_text",
|
|
725
|
+
text: "Write something"
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
) }),
|
|
729
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
730
|
+
"textarea",
|
|
731
|
+
{
|
|
732
|
+
value,
|
|
733
|
+
onChange: (e) => setValue(e.target.value),
|
|
734
|
+
className: "w-full focus:outline-none rounded border border-black-primary.3 p-2",
|
|
735
|
+
minLength: min_length,
|
|
736
|
+
maxLength: max_length,
|
|
737
|
+
style: {
|
|
738
|
+
maxHeight: "200px",
|
|
739
|
+
minHeight: "80px",
|
|
740
|
+
height: "100px"
|
|
741
|
+
},
|
|
742
|
+
"aria-label": "Select an item"
|
|
743
|
+
}
|
|
744
|
+
)
|
|
745
|
+
] });
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
// src/components/elements/users_select_element.tsx
|
|
749
|
+
var import_react4 = require("react");
|
|
750
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
751
|
+
var UsersSelectElement = (props) => {
|
|
752
|
+
const { action_id, focus_on_load, placeholder, type, confirm, initial_user, people } = props.data;
|
|
753
|
+
const [visible, setVisible] = (0, import_react4.useState)(focus_on_load || false);
|
|
754
|
+
const [search, setSearch] = (0, import_react4.useState)("");
|
|
755
|
+
const [selected, setSelected] = (0, import_react4.useState)("");
|
|
756
|
+
(0, import_react4.useEffect)(() => {
|
|
757
|
+
const handleClickOutside = (e) => {
|
|
758
|
+
var _a, _b;
|
|
759
|
+
const target = e.target;
|
|
760
|
+
console.log({ target });
|
|
761
|
+
console.log(target.id);
|
|
762
|
+
if (target.id !== "static_select_popup" && target.id !== "static_select_dropdown_button" && ((_a = target.parentElement) == null ? void 0 : _a.id) !== "static_select_popup" && ((_b = target.parentElement) == null ? void 0 : _b.id) !== "static_select_dropdown_button")
|
|
763
|
+
setVisible(false);
|
|
764
|
+
};
|
|
765
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
766
|
+
return () => {
|
|
767
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
768
|
+
};
|
|
769
|
+
}, []);
|
|
770
|
+
const filteredOptions = people.filter((person) => {
|
|
771
|
+
const search_query = search.toLowerCase().trim();
|
|
772
|
+
if (!search_query)
|
|
773
|
+
return true;
|
|
774
|
+
const name = person.name.toLowerCase();
|
|
775
|
+
return name.includes(search_query);
|
|
776
|
+
}, []);
|
|
777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
778
|
+
"div",
|
|
779
|
+
{
|
|
780
|
+
id: action_id,
|
|
781
|
+
className: "py-1 px-2 h-7 min-h-[28px] relative flex items-center justify-between rounded text-small w-[190px] border border-black-primary.3",
|
|
782
|
+
tabIndex: 0,
|
|
783
|
+
children: [
|
|
784
|
+
visible && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
785
|
+
"div",
|
|
786
|
+
{
|
|
787
|
+
className: "absolute top-[24px] -left-3 bg-white-secondary border border-gray-primary rounded-[6px] shadow-custom_shadow-1 w-[322px] max-w-[322px] max-h-[240px] overflow-auto py-3 z-20",
|
|
788
|
+
id: "static_select_popup",
|
|
789
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex flex-col", children: filteredOptions.map((option, i) => {
|
|
790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
791
|
+
"button",
|
|
792
|
+
{
|
|
793
|
+
className: "h-7 px-6 flex group items-center gap-2 select-none cursor-pointer hover:bg-blue-primary hover:text-white-primary",
|
|
794
|
+
tabIndex: 0,
|
|
795
|
+
type: "button",
|
|
796
|
+
onClick: () => {
|
|
797
|
+
setVisible(false);
|
|
798
|
+
setSelected(option.id);
|
|
799
|
+
},
|
|
800
|
+
children: [
|
|
801
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { src: option.image, alt: option.name, className: "w-5 h-5 rounded-md" }),
|
|
802
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
803
|
+
TextObject,
|
|
804
|
+
{
|
|
805
|
+
data: {
|
|
806
|
+
type: "mrkdwn",
|
|
807
|
+
text: `*${option.name}*`
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
),
|
|
811
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative", children: [
|
|
812
|
+
option.online && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
813
|
+
"div",
|
|
814
|
+
{
|
|
815
|
+
className: `bg-green-secondary w-[9px] h-[9px] rounded-full shrink-0`
|
|
816
|
+
}
|
|
817
|
+
),
|
|
818
|
+
!option.online && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "w-[9px] h-[9px] rounded-full border-[1.5px] shrink-0 border-black-secondary group-hover:border-white-primary" }),
|
|
819
|
+
option.sleeping && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "absolute -top-[5px] -right-[5px] h-[10px] w-[10px] rounded-full bg-white-secondary flex justify-center z-[10] text-[8px] leading-[8px] font-semibold group-hover:bg-blue-primary", children: "z" })
|
|
820
|
+
] }),
|
|
821
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-black-primary group-hover:text-white-primary", children: option.name })
|
|
822
|
+
]
|
|
823
|
+
},
|
|
824
|
+
i
|
|
825
|
+
);
|
|
826
|
+
}) })
|
|
827
|
+
}
|
|
828
|
+
),
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
830
|
+
"input",
|
|
831
|
+
{
|
|
832
|
+
type: "text",
|
|
833
|
+
value: search,
|
|
834
|
+
onClick: () => setVisible(true),
|
|
835
|
+
onChange: (e) => setSearch(e.currentTarget.value),
|
|
836
|
+
className: "w-full py-1 pr-7 focus:outline-none",
|
|
837
|
+
tabIndex: -1,
|
|
838
|
+
"aria-label": "Select an item"
|
|
839
|
+
}
|
|
840
|
+
),
|
|
841
|
+
!search && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "absolute w-full h-full pointer-events-none flex items-center text-black-primary.3", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
842
|
+
TextObject,
|
|
843
|
+
{
|
|
844
|
+
data: placeholder != null ? placeholder : {
|
|
845
|
+
type: "plain_text",
|
|
846
|
+
text: "Pick an option"
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
) }),
|
|
850
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
851
|
+
"button",
|
|
852
|
+
{
|
|
853
|
+
type: "button",
|
|
854
|
+
className: "absolute right-1 top-1/2 flex justify-center items-center w-5 -translate-y-1/2 text-black-secondary z-10 h-full",
|
|
855
|
+
id: "static_select_dropdown_button",
|
|
856
|
+
onClick: () => {
|
|
857
|
+
setVisible((prev) => !prev);
|
|
858
|
+
},
|
|
859
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
860
|
+
"svg",
|
|
861
|
+
{
|
|
862
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
863
|
+
fill: "none",
|
|
864
|
+
viewBox: "0 0 24 24",
|
|
865
|
+
strokeWidth: "3",
|
|
866
|
+
stroke: "currentColor",
|
|
867
|
+
className: "w-3 h-3",
|
|
868
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
|
|
869
|
+
}
|
|
870
|
+
)
|
|
871
|
+
}
|
|
872
|
+
)
|
|
873
|
+
]
|
|
874
|
+
}
|
|
875
|
+
);
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
// src/components/blocks/actions.tsx
|
|
879
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
681
880
|
var Actions = (props) => {
|
|
682
881
|
const { elements, block_id } = props.data;
|
|
683
|
-
return /* @__PURE__ */ (0,
|
|
882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
684
883
|
"div",
|
|
685
884
|
{
|
|
686
885
|
id: block_id,
|
|
687
886
|
className: "mb-2 text-primary flex w-full text-black-primary items-center slack_blocks_to_jsx__actions",
|
|
688
|
-
children: /* @__PURE__ */ (0,
|
|
887
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap", children: elements.map((element, i) => {
|
|
689
888
|
if (element.type === "button") {
|
|
690
|
-
return /* @__PURE__ */ (0,
|
|
889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2 mr-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ButtonElement, { data: element }) }, i);
|
|
691
890
|
}
|
|
692
891
|
if (element.type === "static_select") {
|
|
693
|
-
return /* @__PURE__ */ (0,
|
|
892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2 mr-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StaticSelectElement, { data: element }) }, i);
|
|
694
893
|
}
|
|
695
|
-
return /* @__PURE__ */ (0,
|
|
894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2 mr-2" }, i);
|
|
696
895
|
}) })
|
|
697
896
|
}
|
|
698
897
|
);
|
|
699
898
|
};
|
|
700
899
|
|
|
701
900
|
// src/components/blocks/context.tsx
|
|
702
|
-
var
|
|
901
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
703
902
|
var Context = (props) => {
|
|
704
903
|
const { elements, block_id } = props.data;
|
|
705
|
-
return /* @__PURE__ */ (0,
|
|
904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
706
905
|
"div",
|
|
707
906
|
{
|
|
708
907
|
id: block_id,
|
|
709
908
|
className: "my-1 text-primary flex w-full text-black-primary flex-wrap items-center overflow-hidden slack_blocks_to_jsx__context",
|
|
710
909
|
children: elements.slice(0, 10).map((element, i) => {
|
|
711
910
|
if (element.type !== "image") {
|
|
712
|
-
return /* @__PURE__ */ (0,
|
|
911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-black-secondary text-small pr-3 flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TextObject, { data: element }) }, i);
|
|
713
912
|
}
|
|
714
|
-
return /* @__PURE__ */ (0,
|
|
913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ImageElement, { data: element }) }, i);
|
|
715
914
|
})
|
|
716
915
|
}
|
|
717
916
|
);
|
|
718
917
|
};
|
|
719
918
|
|
|
720
919
|
// src/components/blocks/divider.tsx
|
|
721
|
-
var
|
|
920
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
722
921
|
var Divider = (props) => {
|
|
723
922
|
const { data } = props;
|
|
724
923
|
const { block_id } = data;
|
|
725
|
-
return /* @__PURE__ */ (0,
|
|
924
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
726
925
|
"div",
|
|
727
926
|
{
|
|
728
927
|
id: block_id,
|
|
@@ -744,45 +943,53 @@ var Header2 = (props) => {
|
|
|
744
943
|
};
|
|
745
944
|
|
|
746
945
|
// src/components/blocks/image.tsx
|
|
747
|
-
var
|
|
748
|
-
var
|
|
946
|
+
var import_react5 = require("react");
|
|
947
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
749
948
|
var Image = (props) => {
|
|
750
949
|
const { block_id, alt_text, image_url, image_bytes, image_height, image_width } = props.data;
|
|
751
|
-
const [showImage, setShowImage] = (0,
|
|
752
|
-
return /* @__PURE__ */ (0,
|
|
753
|
-
/* @__PURE__ */ (0,
|
|
754
|
-
/* @__PURE__ */ (0,
|
|
950
|
+
const [showImage, setShowImage] = (0, import_react5.useState)(true);
|
|
951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { id: block_id, className: "my-2 flex flex-col gap-2 slack_blocks_to_jsx__image", children: [
|
|
952
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "text-black-secondary text-small flex gap-1 items-center", children: [
|
|
953
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { children: [
|
|
755
954
|
alt_text,
|
|
756
955
|
image_bytes && ` (${Math.round(image_bytes / 1e3)} kB)`
|
|
757
956
|
] }),
|
|
758
|
-
/* @__PURE__ */ (0,
|
|
759
|
-
"
|
|
957
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
958
|
+
"button",
|
|
760
959
|
{
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
shapeRendering: "geometricPrecision",
|
|
767
|
-
textRendering: "geometricPrecision",
|
|
768
|
-
viewBox: "0 0 512 336.36",
|
|
769
|
-
width: 6,
|
|
770
|
-
height: 6,
|
|
771
|
-
style: {
|
|
772
|
-
transform: showImage ? "rotate(0deg)" : "rotate(-90deg)"
|
|
773
|
-
},
|
|
774
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
775
|
-
"path",
|
|
960
|
+
type: "button",
|
|
961
|
+
className: "w-[15px] h-[15px]",
|
|
962
|
+
onClick: () => setShowImage((prev) => !prev),
|
|
963
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
964
|
+
"svg",
|
|
776
965
|
{
|
|
777
|
-
|
|
778
|
-
fillRule: "
|
|
779
|
-
|
|
966
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
967
|
+
fillRule: "evenodd",
|
|
968
|
+
clipRule: "evenodd",
|
|
969
|
+
className: "text-blue-primary",
|
|
970
|
+
imageRendering: "optimizeQuality",
|
|
971
|
+
shapeRendering: "geometricPrecision",
|
|
972
|
+
textRendering: "geometricPrecision",
|
|
973
|
+
viewBox: "0 0 512 336.36",
|
|
974
|
+
width: 6,
|
|
975
|
+
height: 6,
|
|
976
|
+
style: {
|
|
977
|
+
transform: showImage ? "rotate(0deg)" : "rotate(-90deg)"
|
|
978
|
+
},
|
|
979
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
980
|
+
"path",
|
|
981
|
+
{
|
|
982
|
+
fill: "currentColor",
|
|
983
|
+
fillRule: "nonzero",
|
|
984
|
+
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"
|
|
985
|
+
}
|
|
986
|
+
)
|
|
780
987
|
}
|
|
781
988
|
)
|
|
782
989
|
}
|
|
783
|
-
)
|
|
990
|
+
)
|
|
784
991
|
] }),
|
|
785
|
-
showImage && /* @__PURE__ */ (0,
|
|
992
|
+
showImage && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "rounded-md overflow-hidden relative max-w-max", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
786
993
|
"img",
|
|
787
994
|
{
|
|
788
995
|
src: image_url,
|
|
@@ -797,9 +1004,37 @@ var Image = (props) => {
|
|
|
797
1004
|
};
|
|
798
1005
|
|
|
799
1006
|
// src/components/blocks/input.tsx
|
|
1007
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
800
1008
|
var Input = (props) => {
|
|
801
|
-
const { type } = props.data;
|
|
802
|
-
|
|
1009
|
+
const { element: given_element, label, block_id, hint, optional, type } = props.data;
|
|
1010
|
+
const element = given_element ? getElementComponent(given_element) : null;
|
|
1011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1012
|
+
"div",
|
|
1013
|
+
{
|
|
1014
|
+
id: block_id,
|
|
1015
|
+
className: `mt-2 mb-1 text-primary slack_blocks_to_jsx__input flex w-full text-black-primary`,
|
|
1016
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "grow", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
1017
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1018
|
+
TextObject,
|
|
1019
|
+
{
|
|
1020
|
+
data: {
|
|
1021
|
+
type: "mrkdwn",
|
|
1022
|
+
text: `*${label.text}*`,
|
|
1023
|
+
emoji: label.emoji,
|
|
1024
|
+
verbatim: label.verbatim
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
),
|
|
1028
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "mb-1 flex flex-col gap-1", children: [
|
|
1029
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "relative shrink-0", children: element }),
|
|
1030
|
+
(hint || given_element.type === "plain_text_input") && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "text-black-secondary text-small flex gap-1", children: [
|
|
1031
|
+
hint && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "inline", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TextObject, { data: hint }) }),
|
|
1032
|
+
given_element.type === "plain_text_input" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: "\u21B5 Please 'enter' to submit" })
|
|
1033
|
+
] })
|
|
1034
|
+
] })
|
|
1035
|
+
] }) })
|
|
1036
|
+
}
|
|
1037
|
+
);
|
|
803
1038
|
};
|
|
804
1039
|
|
|
805
1040
|
// src/components/blocks/rich-text.tsx
|
|
@@ -809,24 +1044,24 @@ var RichText = (props) => {
|
|
|
809
1044
|
};
|
|
810
1045
|
|
|
811
1046
|
// src/components/blocks/section.tsx
|
|
812
|
-
var
|
|
1047
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
813
1048
|
var Section = (props) => {
|
|
814
1049
|
const { accessory, fields, text, block_id } = props.data;
|
|
815
1050
|
const element = accessory ? getElementComponent(accessory) : null;
|
|
816
1051
|
const is_stacked = accessory ? is_accessory_stacked(accessory) : false;
|
|
817
|
-
return /* @__PURE__ */ (0,
|
|
1052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
818
1053
|
"div",
|
|
819
1054
|
{
|
|
820
1055
|
id: block_id,
|
|
821
1056
|
className: `mt-2 mb-1 text-primary slack_blocks_to_jsx__section flex w-full text-black-primary ${is_stacked ? "flex-col" : ""}`,
|
|
822
1057
|
children: [
|
|
823
|
-
/* @__PURE__ */ (0,
|
|
824
|
-
text && /* @__PURE__ */ (0,
|
|
825
|
-
fields && /* @__PURE__ */ (0,
|
|
826
|
-
return /* @__PURE__ */ (0,
|
|
1058
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "grow", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-col gap-3", children: [
|
|
1059
|
+
text && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TextObject, { data: text }),
|
|
1060
|
+
fields && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "grid grid-col-2 w-full", children: fields.map((field, i) => {
|
|
1061
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TextObject, { data: field }, i);
|
|
827
1062
|
}) })
|
|
828
1063
|
] }) }),
|
|
829
|
-
element && is_stacked ? element : /* @__PURE__ */ (0,
|
|
1064
|
+
element && is_stacked ? element : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "ml-2 mb-1 relative shrink-0", children: element })
|
|
830
1065
|
]
|
|
831
1066
|
}
|
|
832
1067
|
);
|
|
@@ -839,43 +1074,47 @@ var Video = (props) => {
|
|
|
839
1074
|
};
|
|
840
1075
|
|
|
841
1076
|
// src/components/index.tsx
|
|
842
|
-
var
|
|
1077
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
843
1078
|
var getBlockComponent = (block) => {
|
|
844
1079
|
if (block.type === "divider")
|
|
845
|
-
return /* @__PURE__ */ (0,
|
|
1080
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Divider, { data: block });
|
|
846
1081
|
if (block.type === "section")
|
|
847
|
-
return /* @__PURE__ */ (0,
|
|
1082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Section, { data: block });
|
|
848
1083
|
if (block.type === "image")
|
|
849
|
-
return /* @__PURE__ */ (0,
|
|
1084
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Image, { data: block });
|
|
850
1085
|
if (block.type === "context")
|
|
851
|
-
return /* @__PURE__ */ (0,
|
|
1086
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Context, { data: block });
|
|
852
1087
|
if (block.type === "actions")
|
|
853
|
-
return /* @__PURE__ */ (0,
|
|
1088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Actions, { data: block });
|
|
854
1089
|
if (block.type === "file")
|
|
855
|
-
return /* @__PURE__ */ (0,
|
|
1090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(File, { data: block });
|
|
856
1091
|
if (block.type === "header")
|
|
857
|
-
return /* @__PURE__ */ (0,
|
|
1092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Header2, { data: block });
|
|
858
1093
|
if (block.type === "input")
|
|
859
|
-
return /* @__PURE__ */ (0,
|
|
1094
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Input, { data: block });
|
|
860
1095
|
if (block.type === "video")
|
|
861
|
-
return /* @__PURE__ */ (0,
|
|
1096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Video, { data: block });
|
|
862
1097
|
if (block.type === "rich_text")
|
|
863
|
-
return /* @__PURE__ */ (0,
|
|
1098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RichText, { data: block });
|
|
864
1099
|
return null;
|
|
865
1100
|
};
|
|
866
1101
|
var getElementComponent = (element) => {
|
|
867
1102
|
if (element.type === "button")
|
|
868
|
-
return /* @__PURE__ */ (0,
|
|
1103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ButtonElement, { data: element });
|
|
869
1104
|
if (element.type === "checkboxes")
|
|
870
|
-
return /* @__PURE__ */ (0,
|
|
1105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CheckboxesElement, { data: element });
|
|
1106
|
+
if (element.type === "image")
|
|
1107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageElement, { data: element });
|
|
1108
|
+
if (element.type === "plain_text_input")
|
|
1109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PlaintTextInput, { data: element });
|
|
1110
|
+
if (element.type === "users_select")
|
|
1111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(UsersSelectElement, { data: element });
|
|
871
1112
|
if (element.type === "datepicker")
|
|
872
1113
|
return null;
|
|
873
1114
|
if (element.type === "datetimepicker")
|
|
874
1115
|
return null;
|
|
875
1116
|
if (element.type === "email_text_input")
|
|
876
1117
|
return null;
|
|
877
|
-
if (element.type === "image")
|
|
878
|
-
return null;
|
|
879
1118
|
if (element.type === "multi_static_select")
|
|
880
1119
|
return null;
|
|
881
1120
|
if (element.type === "multi_external_select")
|
|
@@ -890,16 +1129,12 @@ var getElementComponent = (element) => {
|
|
|
890
1129
|
return null;
|
|
891
1130
|
if (element.type === "overflow")
|
|
892
1131
|
return null;
|
|
893
|
-
if (element.type === "plain_text_input")
|
|
894
|
-
return null;
|
|
895
1132
|
if (element.type === "radio_buttons")
|
|
896
1133
|
return null;
|
|
897
1134
|
if (element.type === "static_select")
|
|
898
1135
|
return null;
|
|
899
1136
|
if (element.type === "external_select")
|
|
900
1137
|
return null;
|
|
901
|
-
if (element.type === "users_select")
|
|
902
|
-
return null;
|
|
903
1138
|
if (element.type === "conversations_select")
|
|
904
1139
|
return null;
|
|
905
1140
|
if (element.type === "channels_select")
|
|
@@ -912,14 +1147,14 @@ var getElementComponent = (element) => {
|
|
|
912
1147
|
};
|
|
913
1148
|
|
|
914
1149
|
// src/block_wrapper.tsx
|
|
915
|
-
var
|
|
1150
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
916
1151
|
var BlockWrapper = (props) => {
|
|
917
1152
|
const { children } = props;
|
|
918
|
-
return /* @__PURE__ */ (0,
|
|
1153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "text-base break-words font-normal", children });
|
|
919
1154
|
};
|
|
920
1155
|
|
|
921
1156
|
// src/message.tsx
|
|
922
|
-
var
|
|
1157
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
923
1158
|
var Message = (props) => {
|
|
924
1159
|
const {
|
|
925
1160
|
blocks,
|
|
@@ -930,13 +1165,13 @@ var Message = (props) => {
|
|
|
930
1165
|
style,
|
|
931
1166
|
showBlockKitDebug = false
|
|
932
1167
|
} = props;
|
|
933
|
-
return /* @__PURE__ */ (0,
|
|
1168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { id: "slack_blocks_to_jsx", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
934
1169
|
"section",
|
|
935
1170
|
{
|
|
936
1171
|
className: `flex gap-2 w-full max-w-[600px] slack_blocks_to_jsx relative ${className}`,
|
|
937
1172
|
style,
|
|
938
1173
|
children: [
|
|
939
|
-
showBlockKitDebug && /* @__PURE__ */ (0,
|
|
1174
|
+
showBlockKitDebug && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
940
1175
|
"a",
|
|
941
1176
|
{
|
|
942
1177
|
target: "_blank",
|
|
@@ -948,14 +1183,14 @@ var Message = (props) => {
|
|
|
948
1183
|
children: "Open in Slack Block Kit Builder"
|
|
949
1184
|
}
|
|
950
1185
|
),
|
|
951
|
-
/* @__PURE__ */ (0,
|
|
952
|
-
/* @__PURE__ */ (0,
|
|
953
|
-
/* @__PURE__ */ (0,
|
|
954
|
-
/* @__PURE__ */ (0,
|
|
1186
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", { src: logo, className: "w-9 h-9", alt: name }) }),
|
|
1187
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col w-full", children: [
|
|
1188
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Header, { name, time }),
|
|
1189
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: blocks.map((block, i) => {
|
|
955
1190
|
const element = getBlockComponent(block);
|
|
956
1191
|
if (!element)
|
|
957
1192
|
return null;
|
|
958
|
-
return /* @__PURE__ */ (0,
|
|
1193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(BlockWrapper, { children: element }, i);
|
|
959
1194
|
}) })
|
|
960
1195
|
] })
|
|
961
1196
|
]
|