@tightknitai/block-kitchen 0.9.8 → 0.9.10
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 +176 -5
- package/dist/helpers.d.cts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/index.cjs +190 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +83 -3
- package/dist/index.d.ts +83 -3
- package/dist/index.js +190 -61
- package/dist/index.js.map +1 -1
- package/dist/{palette-CKP8CK5Z.d.cts → palette-Duj901T6.d.cts} +188 -27
- package/dist/{palette-CKP8CK5Z.d.ts → palette-Duj901T6.d.ts} +188 -27
- package/dist/palette.d.cts +1 -1
- package/dist/palette.d.ts +1 -1
- package/dist/styles.css +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2045,6 +2045,7 @@ function computeValidation(blocks, surface) {
|
|
|
2045
2045
|
const grouped = groupValidatorErrors(result.errors, blocks);
|
|
2046
2046
|
return {
|
|
2047
2047
|
valid: result.valid,
|
|
2048
|
+
errors: result.errors,
|
|
2048
2049
|
byBlockId: grouped.byBlockId,
|
|
2049
2050
|
general: grouped.general,
|
|
2050
2051
|
total: grouped.total
|
|
@@ -2640,6 +2641,38 @@ function unwrapBlocksInput(parsed) {
|
|
|
2640
2641
|
}
|
|
2641
2642
|
return null;
|
|
2642
2643
|
}
|
|
2644
|
+
var buttonVariants = classVarianceAuthority.cva(
|
|
2645
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
2646
|
+
{
|
|
2647
|
+
variants: {
|
|
2648
|
+
variant: {
|
|
2649
|
+
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
2650
|
+
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
2651
|
+
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
2652
|
+
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
2653
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
2654
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
2655
|
+
},
|
|
2656
|
+
size: {
|
|
2657
|
+
default: "h-9 px-4 py-2",
|
|
2658
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
2659
|
+
lg: "h-10 rounded-md px-8",
|
|
2660
|
+
icon: "h-9 w-9"
|
|
2661
|
+
}
|
|
2662
|
+
},
|
|
2663
|
+
defaultVariants: {
|
|
2664
|
+
variant: "default",
|
|
2665
|
+
size: "default"
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
);
|
|
2669
|
+
var Button = React__namespace.forwardRef(
|
|
2670
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
2671
|
+
const Comp = asChild ? reactSlot.Slot : "button";
|
|
2672
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
|
|
2673
|
+
}
|
|
2674
|
+
);
|
|
2675
|
+
Button.displayName = "Button";
|
|
2643
2676
|
var MAX_JSON_BYTES = 1024 * 1024;
|
|
2644
2677
|
function JsonDrawer({
|
|
2645
2678
|
open,
|
|
@@ -2651,19 +2684,23 @@ function JsonDrawer({
|
|
|
2651
2684
|
const [parseError, setParseError] = React.useState(null);
|
|
2652
2685
|
const [validationErrors, setValidationErrors] = React.useState([]);
|
|
2653
2686
|
const [copied, setCopied] = React.useState(false);
|
|
2687
|
+
const [accepted, setAccepted] = React.useState(false);
|
|
2654
2688
|
const textareaRef = React.useRef(null);
|
|
2655
2689
|
const gutterRef = React.useRef(null);
|
|
2656
2690
|
const copyResetRef = React.useRef(null);
|
|
2691
|
+
const acceptResetRef = React.useRef(null);
|
|
2657
2692
|
const blocksRef = React.useRef(blocks);
|
|
2658
2693
|
React.useEffect(() => {
|
|
2659
2694
|
blocksRef.current = blocks;
|
|
2660
2695
|
});
|
|
2661
2696
|
React.useEffect(() => {
|
|
2662
2697
|
if (open) {
|
|
2663
|
-
|
|
2698
|
+
const current = blocksRef.current;
|
|
2699
|
+
setValue(current.length === 0 ? "" : JSON.stringify(current, null, 2));
|
|
2664
2700
|
setParseError(null);
|
|
2665
2701
|
setValidationErrors([]);
|
|
2666
2702
|
setCopied(false);
|
|
2703
|
+
setAccepted(false);
|
|
2667
2704
|
}
|
|
2668
2705
|
}, [open]);
|
|
2669
2706
|
React.useEffect(
|
|
@@ -2671,6 +2708,9 @@ function JsonDrawer({
|
|
|
2671
2708
|
if (copyResetRef.current) {
|
|
2672
2709
|
clearTimeout(copyResetRef.current);
|
|
2673
2710
|
}
|
|
2711
|
+
if (acceptResetRef.current) {
|
|
2712
|
+
clearTimeout(acceptResetRef.current);
|
|
2713
|
+
}
|
|
2674
2714
|
},
|
|
2675
2715
|
[]
|
|
2676
2716
|
);
|
|
@@ -2691,6 +2731,17 @@ function JsonDrawer({
|
|
|
2691
2731
|
setValidationErrors([]);
|
|
2692
2732
|
return;
|
|
2693
2733
|
}
|
|
2734
|
+
if (next.trim() === "") {
|
|
2735
|
+
setParseError(null);
|
|
2736
|
+
setValidationErrors([]);
|
|
2737
|
+
onApply([]);
|
|
2738
|
+
setAccepted(true);
|
|
2739
|
+
if (acceptResetRef.current) {
|
|
2740
|
+
clearTimeout(acceptResetRef.current);
|
|
2741
|
+
}
|
|
2742
|
+
acceptResetRef.current = setTimeout(() => setAccepted(false), 1800);
|
|
2743
|
+
return;
|
|
2744
|
+
}
|
|
2694
2745
|
let parsed;
|
|
2695
2746
|
try {
|
|
2696
2747
|
parsed = JSON.parse(next);
|
|
@@ -2707,6 +2758,11 @@ function JsonDrawer({
|
|
|
2707
2758
|
}
|
|
2708
2759
|
setParseError(null);
|
|
2709
2760
|
onApply(blocks2);
|
|
2761
|
+
setAccepted(true);
|
|
2762
|
+
if (acceptResetRef.current) {
|
|
2763
|
+
clearTimeout(acceptResetRef.current);
|
|
2764
|
+
}
|
|
2765
|
+
acceptResetRef.current = setTimeout(() => setAccepted(false), 1800);
|
|
2710
2766
|
const result = slackBlockKitValidator.validateBlockKit(blocks2, {
|
|
2711
2767
|
target: "blocks",
|
|
2712
2768
|
surface: "message"
|
|
@@ -2731,16 +2787,30 @@ function JsonDrawer({
|
|
|
2731
2787
|
/* @__PURE__ */ jsxRuntime.jsx(SheetDescription, { children: "Edits update the preview as you type. Parse errors show below." })
|
|
2732
2788
|
] }),
|
|
2733
2789
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex flex-1 overflow-hidden rounded-md border border-input bg-muted/30 shadow-sm focus-within:ring-1 focus-within:ring-ring", children: [
|
|
2734
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2790
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute right-2 top-2 z-10 flex items-center gap-1.5", children: [
|
|
2791
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2792
|
+
"div",
|
|
2793
|
+
{
|
|
2794
|
+
role: "status",
|
|
2795
|
+
"aria-hidden": !accepted,
|
|
2796
|
+
className: `pointer-events-none flex items-center justify-center rounded-md bg-background/80 p-1.5 shadow-sm backdrop-blur transition-opacity duration-300 ${accepted ? "opacity-100" : "opacity-0"}`,
|
|
2797
|
+
children: [
|
|
2798
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-emerald-600" }),
|
|
2799
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Input accepted" })
|
|
2800
|
+
]
|
|
2801
|
+
}
|
|
2802
|
+
),
|
|
2803
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2804
|
+
"button",
|
|
2805
|
+
{
|
|
2806
|
+
type: "button",
|
|
2807
|
+
onClick: handleCopy,
|
|
2808
|
+
"aria-label": copied ? "Copied to clipboard" : "Copy JSON",
|
|
2809
|
+
className: "inline-flex items-center justify-center rounded-md border border-input bg-background/80 p-1.5 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
2810
|
+
children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-emerald-600" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-3.5 w-3.5" })
|
|
2811
|
+
}
|
|
2812
|
+
)
|
|
2813
|
+
] }),
|
|
2744
2814
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2745
2815
|
"div",
|
|
2746
2816
|
{
|
|
@@ -2777,41 +2847,10 @@ function JsonDrawer({
|
|
|
2777
2847
|
" more"
|
|
2778
2848
|
] })
|
|
2779
2849
|
] })
|
|
2780
|
-
] })
|
|
2850
|
+
] }),
|
|
2851
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", onClick: () => onOpenChange(false), children: "Done" }) })
|
|
2781
2852
|
] }) });
|
|
2782
2853
|
}
|
|
2783
|
-
var buttonVariants = classVarianceAuthority.cva(
|
|
2784
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
2785
|
-
{
|
|
2786
|
-
variants: {
|
|
2787
|
-
variant: {
|
|
2788
|
-
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
2789
|
-
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
2790
|
-
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
2791
|
-
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
2792
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
2793
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
2794
|
-
},
|
|
2795
|
-
size: {
|
|
2796
|
-
default: "h-9 px-4 py-2",
|
|
2797
|
-
sm: "h-8 rounded-md px-3 text-xs",
|
|
2798
|
-
lg: "h-10 rounded-md px-8",
|
|
2799
|
-
icon: "h-9 w-9"
|
|
2800
|
-
}
|
|
2801
|
-
},
|
|
2802
|
-
defaultVariants: {
|
|
2803
|
-
variant: "default",
|
|
2804
|
-
size: "default"
|
|
2805
|
-
}
|
|
2806
|
-
}
|
|
2807
|
-
);
|
|
2808
|
-
var Button = React__namespace.forwardRef(
|
|
2809
|
-
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
2810
|
-
const Comp = asChild ? reactSlot.Slot : "button";
|
|
2811
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
|
|
2812
|
-
}
|
|
2813
|
-
);
|
|
2814
|
-
Button.displayName = "Button";
|
|
2815
2854
|
var Dialog = DialogPrimitive__namespace.Root;
|
|
2816
2855
|
var DialogPortal = DialogPrimitive__namespace.Portal;
|
|
2817
2856
|
var DialogOverlay = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3524,6 +3563,7 @@ function SendDialog({
|
|
|
3524
3563
|
loadChannels,
|
|
3525
3564
|
loadSendAsUserStatus,
|
|
3526
3565
|
onSend,
|
|
3566
|
+
renderSendExtras,
|
|
3527
3567
|
confirmSendLabel = "Send",
|
|
3528
3568
|
errorCount,
|
|
3529
3569
|
onShowIssues
|
|
@@ -3533,6 +3573,10 @@ function SendDialog({
|
|
|
3533
3573
|
const [channelId, setChannelId] = React.useState("");
|
|
3534
3574
|
const [sendAs, setSendAs] = React.useState("bot");
|
|
3535
3575
|
const [status, setStatus] = React.useState({ kind: "idle" });
|
|
3576
|
+
const [extras, setExtrasState] = React.useState({});
|
|
3577
|
+
const setExtras = React.useCallback((patch) => {
|
|
3578
|
+
setExtrasState((prev) => ({ ...prev, ...patch }));
|
|
3579
|
+
}, []);
|
|
3536
3580
|
const { userStatus, polling, startSignIn } = useSlackSignIn(loadSendAsUserStatus, { open, enabled: true });
|
|
3537
3581
|
const loadChannelsRef = React.useRef(loadChannels);
|
|
3538
3582
|
React.useEffect(() => {
|
|
@@ -3547,6 +3591,7 @@ function SendDialog({
|
|
|
3547
3591
|
setChannelsError(null);
|
|
3548
3592
|
setChannelId("");
|
|
3549
3593
|
setSendAs("bot");
|
|
3594
|
+
setExtrasState({});
|
|
3550
3595
|
let cancelled = false;
|
|
3551
3596
|
loadChannelsRef.current().then((list) => {
|
|
3552
3597
|
if (cancelled) {
|
|
@@ -3574,7 +3619,10 @@ function SendDialog({
|
|
|
3574
3619
|
const result = await onSend({
|
|
3575
3620
|
channelId,
|
|
3576
3621
|
blocks: toSlackBlocks(blocks),
|
|
3577
|
-
sendAsUser: sendAs === "user"
|
|
3622
|
+
sendAsUser: sendAs === "user",
|
|
3623
|
+
// Only introduce the key when the extras slot is wired, so existing
|
|
3624
|
+
// consumers never see a new payload field.
|
|
3625
|
+
...renderSendExtras ? { extras } : {}
|
|
3578
3626
|
});
|
|
3579
3627
|
if (result.ok) {
|
|
3580
3628
|
setStatus({ kind: "idle" });
|
|
@@ -3641,6 +3689,12 @@ function SendDialog({
|
|
|
3641
3689
|
}
|
|
3642
3690
|
)
|
|
3643
3691
|
] }),
|
|
3692
|
+
renderSendExtras ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1.5", children: renderSendExtras({
|
|
3693
|
+
channelId: channelId || null,
|
|
3694
|
+
sendAsUser: sendAs === "user",
|
|
3695
|
+
extras,
|
|
3696
|
+
setExtras
|
|
3697
|
+
}) }) : null,
|
|
3644
3698
|
errorCount > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3645
3699
|
"button",
|
|
3646
3700
|
{
|
|
@@ -9387,6 +9441,8 @@ function Toolbar2({
|
|
|
9387
9441
|
showThemeControl = true,
|
|
9388
9442
|
docsLink,
|
|
9389
9443
|
errorCount,
|
|
9444
|
+
showSend = true,
|
|
9445
|
+
primaryAction,
|
|
9390
9446
|
sendButtonLabel = "Review & send",
|
|
9391
9447
|
editingEnabled = false,
|
|
9392
9448
|
editBadge,
|
|
@@ -9521,7 +9577,24 @@ function Toolbar2({
|
|
|
9521
9577
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Code2, { className: "h-3.5 w-3.5" }),
|
|
9522
9578
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "hidden md:inline", children: "View JSON" })
|
|
9523
9579
|
] }),
|
|
9524
|
-
|
|
9580
|
+
!showSend ? primaryAction ? (
|
|
9581
|
+
// Compose-only mode with a host-owned primary action: same
|
|
9582
|
+
// placement and styling as the built-in send button. No icon —
|
|
9583
|
+
// the action's meaning is the host's, so the label always shows
|
|
9584
|
+
// (the send button can collapse to its icon on small screens;
|
|
9585
|
+
// an icon-less button can't).
|
|
9586
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9587
|
+
Button,
|
|
9588
|
+
{
|
|
9589
|
+
type: "button",
|
|
9590
|
+
size: "sm",
|
|
9591
|
+
onClick: primaryAction.onClick,
|
|
9592
|
+
disabled: primaryAction.disabled,
|
|
9593
|
+
"aria-label": primaryAction.label,
|
|
9594
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: primaryAction.label })
|
|
9595
|
+
}
|
|
9596
|
+
)
|
|
9597
|
+
) : null : editBadge ? (
|
|
9525
9598
|
// A message is loaded: split button. Main action updates it in
|
|
9526
9599
|
// place; the menu also offers posting the blocks as a new message.
|
|
9527
9600
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-stretch", children: [
|
|
@@ -9764,12 +9837,15 @@ function BlockKitchen(props) {
|
|
|
9764
9837
|
workspaceName,
|
|
9765
9838
|
initialBlocks,
|
|
9766
9839
|
onChange,
|
|
9840
|
+
onValidationChange,
|
|
9767
9841
|
previewHooks,
|
|
9768
9842
|
customEmojis,
|
|
9769
9843
|
loadChannels,
|
|
9770
9844
|
loadSendAsUserStatus,
|
|
9771
9845
|
onSend,
|
|
9846
|
+
renderSendExtras,
|
|
9772
9847
|
editing,
|
|
9848
|
+
primaryAction,
|
|
9773
9849
|
loadButtonLabel,
|
|
9774
9850
|
updateButtonLabel,
|
|
9775
9851
|
confirmUpdateLabel,
|
|
@@ -9786,6 +9862,13 @@ function BlockKitchen(props) {
|
|
|
9786
9862
|
sendButtonLabel,
|
|
9787
9863
|
confirmSendLabel,
|
|
9788
9864
|
theme
|
|
9865
|
+
// Widen the all-or-nothing union so the branch-specific props
|
|
9866
|
+
// destructure as independent optionals: untyped JS consumers can still
|
|
9867
|
+
// pass partial wiring (handled by the runtime guards below), and the
|
|
9868
|
+
// correlated-union narrowing would otherwise flag those guards as
|
|
9869
|
+
// "always true". `primaryAction` is pulled from the compose-only branch
|
|
9870
|
+
// (where it carries a real type) rather than the send branch's
|
|
9871
|
+
// `undefined` pin, which would collapse the intersection to `undefined`.
|
|
9789
9872
|
} = props;
|
|
9790
9873
|
const paletteSections = React.useMemo(() => {
|
|
9791
9874
|
const sections = palette ?? defaultPalette;
|
|
@@ -9804,13 +9887,36 @@ function BlockKitchen(props) {
|
|
|
9804
9887
|
}, [palette, disabledBlockTypes]);
|
|
9805
9888
|
const variantById = React.useMemo(() => buildVariantById(paletteSections), [paletteSections]);
|
|
9806
9889
|
const allowedSurfaces = allowedSurfacesProp && allowedSurfacesProp.length > 0 ? allowedSurfacesProp : ["message"];
|
|
9807
|
-
const
|
|
9890
|
+
const sendEnabled = Boolean(loadChannels && loadSendAsUserStatus && onSend);
|
|
9891
|
+
const editingConfig = sendEnabled ? editing : void 0;
|
|
9892
|
+
const seededBlocks = editingConfig?.initialTarget?.blocks ?? initialBlocks;
|
|
9808
9893
|
React.useEffect(() => {
|
|
9809
|
-
if (
|
|
9894
|
+
if (editingConfig?.initialTarget && initialBlocks) {
|
|
9810
9895
|
console.warn(
|
|
9811
9896
|
"[BlockKitchen] Both `initialBlocks` and `editing.initialTarget` were provided; using the target\u2019s blocks and ignoring `initialBlocks`."
|
|
9812
9897
|
);
|
|
9813
9898
|
}
|
|
9899
|
+
const sendPropsProvided = [loadChannels, loadSendAsUserStatus, onSend].filter(Boolean).length;
|
|
9900
|
+
if (sendPropsProvided > 0 && sendPropsProvided < 3) {
|
|
9901
|
+
console.warn(
|
|
9902
|
+
"[BlockKitchen] Partial send wiring: `loadChannels`, `loadSendAsUserStatus`, and `onSend` are all-or-nothing. The send button is hidden until all three are provided."
|
|
9903
|
+
);
|
|
9904
|
+
}
|
|
9905
|
+
if (editing && !sendEnabled) {
|
|
9906
|
+
console.warn(
|
|
9907
|
+
"[BlockKitchen] `editing` requires the send integration (`loadChannels`, `loadSendAsUserStatus`, `onSend`); ignoring `editing`."
|
|
9908
|
+
);
|
|
9909
|
+
}
|
|
9910
|
+
if (renderSendExtras && !sendEnabled) {
|
|
9911
|
+
console.warn(
|
|
9912
|
+
"[BlockKitchen] `renderSendExtras` extends the built-in send dialog, which requires the send integration (`loadChannels`, `loadSendAsUserStatus`, `onSend`); ignoring `renderSendExtras`."
|
|
9913
|
+
);
|
|
9914
|
+
}
|
|
9915
|
+
if (primaryAction && sendEnabled) {
|
|
9916
|
+
console.warn(
|
|
9917
|
+
"[BlockKitchen] `primaryAction` is only available in compose-only mode \u2014 with the send integration wired, the built-in Send/Update flow owns the toolbar\u2019s primary action; ignoring `primaryAction`."
|
|
9918
|
+
);
|
|
9919
|
+
}
|
|
9814
9920
|
}, []);
|
|
9815
9921
|
const { blocks, addBlock, addChild, updateBlock, removeBlock, duplicateBlock, reorderBlock, moveBlock, replaceAll } = useBlockKitchenState({ initialBlocks: seededBlocks, onChange });
|
|
9816
9922
|
const childParentById = React.useMemo(() => {
|
|
@@ -9828,8 +9934,8 @@ function BlockKitchen(props) {
|
|
|
9828
9934
|
const [sendOpen, setSendOpen] = React.useState(false);
|
|
9829
9935
|
const [updateOpen, setUpdateOpen] = React.useState(false);
|
|
9830
9936
|
const [loadOpen, setLoadOpen] = React.useState(false);
|
|
9831
|
-
const [editTarget, setEditTarget] = React.useState(() =>
|
|
9832
|
-
const activeEditTarget =
|
|
9937
|
+
const [editTarget, setEditTarget] = React.useState(() => editingConfig?.initialTarget ?? null);
|
|
9938
|
+
const activeEditTarget = editingConfig ? editTarget : null;
|
|
9833
9939
|
const [issuesOpen, setIssuesOpen] = React.useState(false);
|
|
9834
9940
|
const [paletteOpen, setPaletteOpen] = React.useState(false);
|
|
9835
9941
|
const [openBlockId, setOpenBlockId] = React.useState(null);
|
|
@@ -9847,6 +9953,22 @@ function BlockKitchen(props) {
|
|
|
9847
9953
|
return { emoji: makeEmojiHook(byName), ...previewHooks };
|
|
9848
9954
|
}, [customEmojis, previewHooks]);
|
|
9849
9955
|
const validation = useBlockKitValidation(blocks, "message");
|
|
9956
|
+
const validationSummary = React.useMemo(
|
|
9957
|
+
() => ({ valid: validation.valid, errorCount: validation.total, errors: validation.errors }),
|
|
9958
|
+
[validation]
|
|
9959
|
+
);
|
|
9960
|
+
const lastNotifiedValidationRef = React.useRef(null);
|
|
9961
|
+
React.useEffect(() => {
|
|
9962
|
+
if (!onValidationChange) {
|
|
9963
|
+
return;
|
|
9964
|
+
}
|
|
9965
|
+
const key = JSON.stringify([validationSummary.valid, validationSummary.errorCount, ...validationSummary.errors]);
|
|
9966
|
+
if (lastNotifiedValidationRef.current === key) {
|
|
9967
|
+
return;
|
|
9968
|
+
}
|
|
9969
|
+
lastNotifiedValidationRef.current = key;
|
|
9970
|
+
onValidationChange(validationSummary);
|
|
9971
|
+
}, [validationSummary, onValidationChange]);
|
|
9850
9972
|
const sensors = core.useSensors(
|
|
9851
9973
|
core.useSensor(core.PointerSensor, { activationConstraint: { distance: 4 } }),
|
|
9852
9974
|
core.useSensor(core.TouchSensor, { activationConstraint: { delay: 150, tolerance: 8 } }),
|
|
@@ -9950,8 +10072,14 @@ function BlockKitchen(props) {
|
|
|
9950
10072
|
allowedSurfaces,
|
|
9951
10073
|
showThemeControl: isPreviewThemeControlled ? false : showThemeControl,
|
|
9952
10074
|
docsLink,
|
|
10075
|
+
showSend: sendEnabled,
|
|
10076
|
+
primaryAction: !sendEnabled && primaryAction ? {
|
|
10077
|
+
label: primaryAction.label,
|
|
10078
|
+
onClick: () => primaryAction.onClick({ blocks: blockPayloads, validation: validationSummary }),
|
|
10079
|
+
disabled: primaryAction.disableWhenInvalid ? !validationSummary.valid : false
|
|
10080
|
+
} : null,
|
|
9953
10081
|
sendButtonLabel,
|
|
9954
|
-
editingEnabled: !!
|
|
10082
|
+
editingEnabled: !!editingConfig,
|
|
9955
10083
|
editBadge: activeEditTarget ? {
|
|
9956
10084
|
channelLabel: activeEditTarget.channelName ? `#${activeEditTarget.channelName}` : activeEditTarget.channelId,
|
|
9957
10085
|
ts: activeEditTarget.ts
|
|
@@ -10033,7 +10161,7 @@ function BlockKitchen(props) {
|
|
|
10033
10161
|
}
|
|
10034
10162
|
) }),
|
|
10035
10163
|
/* @__PURE__ */ jsxRuntime.jsx(JsonDrawer, { open: jsonOpen, onOpenChange: setJsonOpen, blocks: blockPayloads, onApply: replaceAll }),
|
|
10036
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10164
|
+
loadChannels && loadSendAsUserStatus && onSend ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10037
10165
|
SendDialog,
|
|
10038
10166
|
{
|
|
10039
10167
|
open: sendOpen,
|
|
@@ -10042,6 +10170,7 @@ function BlockKitchen(props) {
|
|
|
10042
10170
|
loadChannels,
|
|
10043
10171
|
loadSendAsUserStatus,
|
|
10044
10172
|
onSend,
|
|
10173
|
+
renderSendExtras,
|
|
10045
10174
|
confirmSendLabel,
|
|
10046
10175
|
errorCount: validation.total,
|
|
10047
10176
|
onShowIssues: () => {
|
|
@@ -10049,8 +10178,8 @@ function BlockKitchen(props) {
|
|
|
10049
10178
|
setIssuesOpen(true);
|
|
10050
10179
|
}
|
|
10051
10180
|
}
|
|
10052
|
-
),
|
|
10053
|
-
activeEditTarget &&
|
|
10181
|
+
) : null,
|
|
10182
|
+
activeEditTarget && editingConfig && loadSendAsUserStatus ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10054
10183
|
UpdateDialog,
|
|
10055
10184
|
{
|
|
10056
10185
|
open: updateOpen,
|
|
@@ -10058,7 +10187,7 @@ function BlockKitchen(props) {
|
|
|
10058
10187
|
target: activeEditTarget,
|
|
10059
10188
|
blocks: blockPayloads,
|
|
10060
10189
|
loadSendAsUserStatus,
|
|
10061
|
-
onUpdate:
|
|
10190
|
+
onUpdate: editingConfig.onUpdate,
|
|
10062
10191
|
confirmUpdateLabel,
|
|
10063
10192
|
errorCount: validation.total,
|
|
10064
10193
|
onShowIssues: () => {
|
|
@@ -10067,13 +10196,13 @@ function BlockKitchen(props) {
|
|
|
10067
10196
|
}
|
|
10068
10197
|
}
|
|
10069
10198
|
) : null,
|
|
10070
|
-
|
|
10199
|
+
editingConfig && loadChannels ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10071
10200
|
LoadMessageDialog,
|
|
10072
10201
|
{
|
|
10073
10202
|
open: loadOpen,
|
|
10074
10203
|
onOpenChange: setLoadOpen,
|
|
10075
|
-
onLoadMessage:
|
|
10076
|
-
loadRecentMessages:
|
|
10204
|
+
onLoadMessage: editingConfig.onLoadMessage,
|
|
10205
|
+
loadRecentMessages: editingConfig.loadRecentMessages,
|
|
10077
10206
|
loadChannels,
|
|
10078
10207
|
onLoaded: (result) => {
|
|
10079
10208
|
replaceAll(result.blocks);
|
|
@@ -10268,6 +10397,8 @@ function fromBase64Url(b64url) {
|
|
|
10268
10397
|
}
|
|
10269
10398
|
|
|
10270
10399
|
exports.BlockKitchen = BlockKitchen;
|
|
10400
|
+
exports.SendDialog = SendDialog;
|
|
10401
|
+
exports.SlackSignInButton = SlackSignInButton;
|
|
10271
10402
|
exports.TemplatePicker = TemplatePicker;
|
|
10272
10403
|
exports.decodeBlocksFromString = decodeBlocksFromString;
|
|
10273
10404
|
exports.defaultPalette = defaultPalette;
|
|
@@ -10275,5 +10406,6 @@ exports.encodeBlocksToString = encodeBlocksToString;
|
|
|
10275
10406
|
exports.extraAlertVariant = extraAlertVariant;
|
|
10276
10407
|
exports.legacyInputVariants = legacyInputVariants;
|
|
10277
10408
|
exports.toSlackBlocks = toSlackBlocks;
|
|
10409
|
+
exports.useSlackSignIn = useSlackSignIn;
|
|
10278
10410
|
//# sourceMappingURL=index.cjs.map
|
|
10279
10411
|
//# sourceMappingURL=index.cjs.map
|