@tightknitai/block-kitchen 0.9.7 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1889,7 +1889,10 @@ var HREF_KEYS = /* @__PURE__ */ new Set(["url"]);
1889
1889
  var IMAGE_KEYS = /* @__PURE__ */ new Set(["image_url"]);
1890
1890
  var RETRIEVAL_ONLY_KEYS = /* @__PURE__ */ new Map([
1891
1891
  // Covers both the image block and the image element — both `type: 'image'`.
1892
- ["image", /* @__PURE__ */ new Set(["image_width", "image_height", "image_bytes", "fallback", "is_animated"])]
1892
+ ["image", /* @__PURE__ */ new Set(["image_width", "image_height", "image_bytes", "fallback", "is_animated"])],
1893
+ // Slack renders the chart server-side and attaches the rendered previews on
1894
+ // retrieval; sending them back is rejected as `unknown property 'preview_images'`.
1895
+ ["data_visualization", /* @__PURE__ */ new Set(["preview_images"])]
1893
1896
  ]);
1894
1897
  function sanitizeValue(value) {
1895
1898
  if (value === null || typeof value !== "object") {
@@ -2607,6 +2610,38 @@ function unwrapBlocksInput(parsed) {
2607
2610
  }
2608
2611
  return null;
2609
2612
  }
2613
+ var buttonVariants = cva(
2614
+ "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",
2615
+ {
2616
+ variants: {
2617
+ variant: {
2618
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
2619
+ destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
2620
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
2621
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
2622
+ ghost: "hover:bg-accent hover:text-accent-foreground",
2623
+ link: "text-primary underline-offset-4 hover:underline"
2624
+ },
2625
+ size: {
2626
+ default: "h-9 px-4 py-2",
2627
+ sm: "h-8 rounded-md px-3 text-xs",
2628
+ lg: "h-10 rounded-md px-8",
2629
+ icon: "h-9 w-9"
2630
+ }
2631
+ },
2632
+ defaultVariants: {
2633
+ variant: "default",
2634
+ size: "default"
2635
+ }
2636
+ }
2637
+ );
2638
+ var Button = React.forwardRef(
2639
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
2640
+ const Comp = asChild ? Slot : "button";
2641
+ return /* @__PURE__ */ jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
2642
+ }
2643
+ );
2644
+ Button.displayName = "Button";
2610
2645
  var MAX_JSON_BYTES = 1024 * 1024;
2611
2646
  function JsonDrawer({
2612
2647
  open,
@@ -2618,19 +2653,23 @@ function JsonDrawer({
2618
2653
  const [parseError, setParseError] = useState(null);
2619
2654
  const [validationErrors, setValidationErrors] = useState([]);
2620
2655
  const [copied, setCopied] = useState(false);
2656
+ const [accepted, setAccepted] = useState(false);
2621
2657
  const textareaRef = useRef(null);
2622
2658
  const gutterRef = useRef(null);
2623
2659
  const copyResetRef = useRef(null);
2660
+ const acceptResetRef = useRef(null);
2624
2661
  const blocksRef = useRef(blocks);
2625
2662
  useEffect(() => {
2626
2663
  blocksRef.current = blocks;
2627
2664
  });
2628
2665
  useEffect(() => {
2629
2666
  if (open) {
2630
- setValue(JSON.stringify(blocksRef.current, null, 2));
2667
+ const current = blocksRef.current;
2668
+ setValue(current.length === 0 ? "" : JSON.stringify(current, null, 2));
2631
2669
  setParseError(null);
2632
2670
  setValidationErrors([]);
2633
2671
  setCopied(false);
2672
+ setAccepted(false);
2634
2673
  }
2635
2674
  }, [open]);
2636
2675
  useEffect(
@@ -2638,6 +2677,9 @@ function JsonDrawer({
2638
2677
  if (copyResetRef.current) {
2639
2678
  clearTimeout(copyResetRef.current);
2640
2679
  }
2680
+ if (acceptResetRef.current) {
2681
+ clearTimeout(acceptResetRef.current);
2682
+ }
2641
2683
  },
2642
2684
  []
2643
2685
  );
@@ -2658,6 +2700,17 @@ function JsonDrawer({
2658
2700
  setValidationErrors([]);
2659
2701
  return;
2660
2702
  }
2703
+ if (next.trim() === "") {
2704
+ setParseError(null);
2705
+ setValidationErrors([]);
2706
+ onApply([]);
2707
+ setAccepted(true);
2708
+ if (acceptResetRef.current) {
2709
+ clearTimeout(acceptResetRef.current);
2710
+ }
2711
+ acceptResetRef.current = setTimeout(() => setAccepted(false), 1800);
2712
+ return;
2713
+ }
2661
2714
  let parsed;
2662
2715
  try {
2663
2716
  parsed = JSON.parse(next);
@@ -2674,6 +2727,11 @@ function JsonDrawer({
2674
2727
  }
2675
2728
  setParseError(null);
2676
2729
  onApply(blocks2);
2730
+ setAccepted(true);
2731
+ if (acceptResetRef.current) {
2732
+ clearTimeout(acceptResetRef.current);
2733
+ }
2734
+ acceptResetRef.current = setTimeout(() => setAccepted(false), 1800);
2677
2735
  const result = validateBlockKit(blocks2, {
2678
2736
  target: "blocks",
2679
2737
  surface: "message"
@@ -2698,16 +2756,30 @@ function JsonDrawer({
2698
2756
  /* @__PURE__ */ jsx(SheetDescription, { children: "Edits update the preview as you type. Parse errors show below." })
2699
2757
  ] }),
2700
2758
  /* @__PURE__ */ 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: [
2701
- /* @__PURE__ */ jsx(
2702
- "button",
2703
- {
2704
- type: "button",
2705
- onClick: handleCopy,
2706
- "aria-label": copied ? "Copied to clipboard" : "Copy JSON",
2707
- className: "absolute right-2 top-2 z-10 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",
2708
- children: copied ? /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5 text-emerald-600" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" })
2709
- }
2710
- ),
2759
+ /* @__PURE__ */ jsxs("div", { className: "absolute right-2 top-2 z-10 flex items-center gap-1.5", children: [
2760
+ /* @__PURE__ */ jsxs(
2761
+ "div",
2762
+ {
2763
+ role: "status",
2764
+ "aria-hidden": !accepted,
2765
+ 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"}`,
2766
+ children: [
2767
+ /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5 text-emerald-600" }),
2768
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Input accepted" })
2769
+ ]
2770
+ }
2771
+ ),
2772
+ /* @__PURE__ */ jsx(
2773
+ "button",
2774
+ {
2775
+ type: "button",
2776
+ onClick: handleCopy,
2777
+ "aria-label": copied ? "Copied to clipboard" : "Copy JSON",
2778
+ 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",
2779
+ children: copied ? /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5 text-emerald-600" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" })
2780
+ }
2781
+ )
2782
+ ] }),
2711
2783
  /* @__PURE__ */ jsx(
2712
2784
  "div",
2713
2785
  {
@@ -2744,41 +2816,10 @@ function JsonDrawer({
2744
2816
  " more"
2745
2817
  ] })
2746
2818
  ] })
2747
- ] })
2819
+ ] }),
2820
+ /* @__PURE__ */ jsx("div", { className: "flex shrink-0 justify-end", children: /* @__PURE__ */ jsx(Button, { type: "button", onClick: () => onOpenChange(false), children: "Done" }) })
2748
2821
  ] }) });
2749
2822
  }
2750
- var buttonVariants = cva(
2751
- "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",
2752
- {
2753
- variants: {
2754
- variant: {
2755
- default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
2756
- destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
2757
- outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
2758
- secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
2759
- ghost: "hover:bg-accent hover:text-accent-foreground",
2760
- link: "text-primary underline-offset-4 hover:underline"
2761
- },
2762
- size: {
2763
- default: "h-9 px-4 py-2",
2764
- sm: "h-8 rounded-md px-3 text-xs",
2765
- lg: "h-10 rounded-md px-8",
2766
- icon: "h-9 w-9"
2767
- }
2768
- },
2769
- defaultVariants: {
2770
- variant: "default",
2771
- size: "default"
2772
- }
2773
- }
2774
- );
2775
- var Button = React.forwardRef(
2776
- ({ className, variant, size, asChild = false, ...props }, ref) => {
2777
- const Comp = asChild ? Slot : "button";
2778
- return /* @__PURE__ */ jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
2779
- }
2780
- );
2781
- Button.displayName = "Button";
2782
2823
  var Dialog = DialogPrimitive.Root;
2783
2824
  var DialogPortal = DialogPrimitive.Portal;
2784
2825
  var DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(