@tightknitai/block-kitchen 0.9.8 → 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
@@ -2610,6 +2610,38 @@ function unwrapBlocksInput(parsed) {
2610
2610
  }
2611
2611
  return null;
2612
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";
2613
2645
  var MAX_JSON_BYTES = 1024 * 1024;
2614
2646
  function JsonDrawer({
2615
2647
  open,
@@ -2621,19 +2653,23 @@ function JsonDrawer({
2621
2653
  const [parseError, setParseError] = useState(null);
2622
2654
  const [validationErrors, setValidationErrors] = useState([]);
2623
2655
  const [copied, setCopied] = useState(false);
2656
+ const [accepted, setAccepted] = useState(false);
2624
2657
  const textareaRef = useRef(null);
2625
2658
  const gutterRef = useRef(null);
2626
2659
  const copyResetRef = useRef(null);
2660
+ const acceptResetRef = useRef(null);
2627
2661
  const blocksRef = useRef(blocks);
2628
2662
  useEffect(() => {
2629
2663
  blocksRef.current = blocks;
2630
2664
  });
2631
2665
  useEffect(() => {
2632
2666
  if (open) {
2633
- setValue(JSON.stringify(blocksRef.current, null, 2));
2667
+ const current = blocksRef.current;
2668
+ setValue(current.length === 0 ? "" : JSON.stringify(current, null, 2));
2634
2669
  setParseError(null);
2635
2670
  setValidationErrors([]);
2636
2671
  setCopied(false);
2672
+ setAccepted(false);
2637
2673
  }
2638
2674
  }, [open]);
2639
2675
  useEffect(
@@ -2641,6 +2677,9 @@ function JsonDrawer({
2641
2677
  if (copyResetRef.current) {
2642
2678
  clearTimeout(copyResetRef.current);
2643
2679
  }
2680
+ if (acceptResetRef.current) {
2681
+ clearTimeout(acceptResetRef.current);
2682
+ }
2644
2683
  },
2645
2684
  []
2646
2685
  );
@@ -2661,6 +2700,17 @@ function JsonDrawer({
2661
2700
  setValidationErrors([]);
2662
2701
  return;
2663
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
+ }
2664
2714
  let parsed;
2665
2715
  try {
2666
2716
  parsed = JSON.parse(next);
@@ -2677,6 +2727,11 @@ function JsonDrawer({
2677
2727
  }
2678
2728
  setParseError(null);
2679
2729
  onApply(blocks2);
2730
+ setAccepted(true);
2731
+ if (acceptResetRef.current) {
2732
+ clearTimeout(acceptResetRef.current);
2733
+ }
2734
+ acceptResetRef.current = setTimeout(() => setAccepted(false), 1800);
2680
2735
  const result = validateBlockKit(blocks2, {
2681
2736
  target: "blocks",
2682
2737
  surface: "message"
@@ -2701,16 +2756,30 @@ function JsonDrawer({
2701
2756
  /* @__PURE__ */ jsx(SheetDescription, { children: "Edits update the preview as you type. Parse errors show below." })
2702
2757
  ] }),
2703
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: [
2704
- /* @__PURE__ */ jsx(
2705
- "button",
2706
- {
2707
- type: "button",
2708
- onClick: handleCopy,
2709
- "aria-label": copied ? "Copied to clipboard" : "Copy JSON",
2710
- 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",
2711
- 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" })
2712
- }
2713
- ),
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
+ ] }),
2714
2783
  /* @__PURE__ */ jsx(
2715
2784
  "div",
2716
2785
  {
@@ -2747,41 +2816,10 @@ function JsonDrawer({
2747
2816
  " more"
2748
2817
  ] })
2749
2818
  ] })
2750
- ] })
2819
+ ] }),
2820
+ /* @__PURE__ */ jsx("div", { className: "flex shrink-0 justify-end", children: /* @__PURE__ */ jsx(Button, { type: "button", onClick: () => onOpenChange(false), children: "Done" }) })
2751
2821
  ] }) });
2752
2822
  }
2753
- var buttonVariants = cva(
2754
- "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",
2755
- {
2756
- variants: {
2757
- variant: {
2758
- default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
2759
- destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
2760
- outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
2761
- secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
2762
- ghost: "hover:bg-accent hover:text-accent-foreground",
2763
- link: "text-primary underline-offset-4 hover:underline"
2764
- },
2765
- size: {
2766
- default: "h-9 px-4 py-2",
2767
- sm: "h-8 rounded-md px-3 text-xs",
2768
- lg: "h-10 rounded-md px-8",
2769
- icon: "h-9 w-9"
2770
- }
2771
- },
2772
- defaultVariants: {
2773
- variant: "default",
2774
- size: "default"
2775
- }
2776
- }
2777
- );
2778
- var Button = React.forwardRef(
2779
- ({ className, variant, size, asChild = false, ...props }, ref) => {
2780
- const Comp = asChild ? Slot : "button";
2781
- return /* @__PURE__ */ jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
2782
- }
2783
- );
2784
- Button.displayName = "Button";
2785
2823
  var Dialog = DialogPrimitive.Root;
2786
2824
  var DialogPortal = DialogPrimitive.Portal;
2787
2825
  var DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(