@tightknitai/block-kitchen 0.8.9 → 0.8.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/dist/index.cjs CHANGED
@@ -3425,12 +3425,16 @@ function AlertEditor({ block, onChange }) {
3425
3425
  ) })
3426
3426
  ] });
3427
3427
  }
3428
- function CardEditor({ block, onChange }) {
3428
+ function CardEditor({
3429
+ block,
3430
+ onChange,
3431
+ idPrefix = "card"
3432
+ }) {
3429
3433
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
3430
- /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Title", help: "Up to 150 characters. Supports mrkdwn formatting.", htmlFor: "card-title", children: /* @__PURE__ */ jsxRuntime.jsx(
3434
+ /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Title", help: "Up to 150 characters. Supports mrkdwn formatting.", htmlFor: `${idPrefix}-title`, children: /* @__PURE__ */ jsxRuntime.jsx(
3431
3435
  Input,
3432
3436
  {
3433
- id: "card-title",
3437
+ id: `${idPrefix}-title`,
3434
3438
  value: block.title?.text ?? "",
3435
3439
  maxLength: 150,
3436
3440
  placeholder: "e.g. New launch update",
@@ -3440,10 +3444,10 @@ function CardEditor({ block, onChange }) {
3440
3444
  })
3441
3445
  }
3442
3446
  ) }),
3443
- /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Subtitle", help: "Up to 150 characters.", htmlFor: "card-subtitle", children: /* @__PURE__ */ jsxRuntime.jsx(
3447
+ /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Subtitle", help: "Up to 150 characters.", htmlFor: `${idPrefix}-subtitle`, children: /* @__PURE__ */ jsxRuntime.jsx(
3444
3448
  Input,
3445
3449
  {
3446
- id: "card-subtitle",
3450
+ id: `${idPrefix}-subtitle`,
3447
3451
  value: block.subtitle?.text ?? "",
3448
3452
  maxLength: 150,
3449
3453
  placeholder: "e.g. Released April 28",
@@ -3453,10 +3457,10 @@ function CardEditor({ block, onChange }) {
3453
3457
  })
3454
3458
  }
3455
3459
  ) }),
3456
- /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Body", help: "Up to 200 characters. Supports mrkdwn formatting.", htmlFor: "card-body", children: /* @__PURE__ */ jsxRuntime.jsx(
3460
+ /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Body", help: "Up to 200 characters. Supports mrkdwn formatting.", htmlFor: `${idPrefix}-body`, children: /* @__PURE__ */ jsxRuntime.jsx(
3457
3461
  Textarea,
3458
3462
  {
3459
- id: "card-body",
3463
+ id: `${idPrefix}-body`,
3460
3464
  value: block.body?.text ?? "",
3461
3465
  maxLength: 200,
3462
3466
  rows: 3,
@@ -3472,7 +3476,7 @@ function CardEditor({ block, onChange }) {
3472
3476
  {
3473
3477
  label: "Hero image",
3474
3478
  help: "Wide image displayed at the top of the card.",
3475
- idPrefix: "card-hero",
3479
+ idPrefix: `${idPrefix}-hero`,
3476
3480
  image: block.hero_image,
3477
3481
  onChange: (next) => onChange({ ...block, hero_image: next })
3478
3482
  }
@@ -3482,7 +3486,7 @@ function CardEditor({ block, onChange }) {
3482
3486
  {
3483
3487
  label: "Icon",
3484
3488
  help: "Small image shown next to the title.",
3485
- idPrefix: "card-icon",
3489
+ idPrefix: `${idPrefix}-icon`,
3486
3490
  image: block.icon,
3487
3491
  onChange: (next) => onChange({ ...block, icon: next })
3488
3492
  }
@@ -3490,6 +3494,7 @@ function CardEditor({ block, onChange }) {
3490
3494
  /* @__PURE__ */ jsxRuntime.jsx(
3491
3495
  ButtonsField,
3492
3496
  {
3497
+ idPrefix,
3493
3498
  buttons: block.actions ?? [],
3494
3499
  onChange: (next) => onChange({ ...block, actions: next.length > 0 ? next : void 0 })
3495
3500
  }
@@ -3546,7 +3551,11 @@ function ImageFields({
3546
3551
  ) })
3547
3552
  ] });
3548
3553
  }
3549
- function ButtonsField({ buttons, onChange }) {
3554
+ function ButtonsField({
3555
+ buttons,
3556
+ onChange,
3557
+ idPrefix = "card"
3558
+ }) {
3550
3559
  const update = (idx, change) => {
3551
3560
  onChange(buttons.map((b, i) => i === idx ? { ...b, ...change } : b));
3552
3561
  };
@@ -3589,10 +3598,10 @@ function ButtonsField({ buttons, onChange }) {
3589
3598
  }
3590
3599
  )
3591
3600
  ] }),
3592
- /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Label", htmlFor: `card-btn-label-${idx}`, children: /* @__PURE__ */ jsxRuntime.jsx(
3601
+ /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Label", htmlFor: `${idPrefix}-btn-label-${idx}`, children: /* @__PURE__ */ jsxRuntime.jsx(
3593
3602
  Input,
3594
3603
  {
3595
- id: `card-btn-label-${idx}`,
3604
+ id: `${idPrefix}-btn-label-${idx}`,
3596
3605
  value: label,
3597
3606
  placeholder: "e.g. Open",
3598
3607
  onChange: (e) => update(idx, {
@@ -3609,11 +3618,11 @@ function ButtonsField({ buttons, onChange }) {
3609
3618
  {
3610
3619
  label: "Link URL",
3611
3620
  help: "Optional. If set, the button opens this link.",
3612
- htmlFor: `card-btn-url-${idx}`,
3621
+ htmlFor: `${idPrefix}-btn-url-${idx}`,
3613
3622
  children: /* @__PURE__ */ jsxRuntime.jsx(
3614
3623
  Input,
3615
3624
  {
3616
- id: `card-btn-url-${idx}`,
3625
+ id: `${idPrefix}-btn-url-${idx}`,
3617
3626
  type: "url",
3618
3627
  value: url,
3619
3628
  placeholder: "e.g. https://example.com",
@@ -3632,8 +3641,8 @@ function ButtonsField({ buttons, onChange }) {
3632
3641
  },
3633
3642
  className: "flex flex-row gap-3",
3634
3643
  children: ["default", "primary", "danger"].map((s) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
3635
- /* @__PURE__ */ jsxRuntime.jsx(RadioGroupItem, { value: s, id: `card-btn-style-${idx}-${s}` }),
3636
- /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `card-btn-style-${idx}-${s}`, className: "text-xs capitalize", children: s })
3644
+ /* @__PURE__ */ jsxRuntime.jsx(RadioGroupItem, { value: s, id: `${idPrefix}-btn-style-${idx}-${s}` }),
3645
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${idPrefix}-btn-style-${idx}-${s}`, className: "text-xs capitalize", children: s })
3637
3646
  ] }, s))
3638
3647
  }
3639
3648
  ) })
@@ -3682,8 +3691,8 @@ function CarouselEditor({ block, onChange }) {
3682
3691
  });
3683
3692
  };
3684
3693
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
3685
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[11px] leading-snug text-muted-foreground", children: "Carousels hold 1-10 cards. For icon, hero image, or action edits, use the View JSON drawer." }),
3686
- elements.map((card, idx) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 rounded-md border bg-muted/20 p-3", children: [
3694
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[11px] leading-snug text-muted-foreground", children: "Carousels hold 1-10 cards." }),
3695
+ elements.map((card, idx) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 rounded-md border bg-muted/20 p-3", children: [
3687
3696
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
3688
3697
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-foreground", children: [
3689
3698
  "Card ",
@@ -3701,33 +3710,7 @@ function CarouselEditor({ block, onChange }) {
3701
3710
  }
3702
3711
  )
3703
3712
  ] }),
3704
- /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Title", htmlFor: `carousel-card-title-${idx}`, children: /* @__PURE__ */ jsxRuntime.jsx(
3705
- Input,
3706
- {
3707
- id: `carousel-card-title-${idx}`,
3708
- value: card.title?.text ?? "",
3709
- maxLength: 150,
3710
- placeholder: "e.g. Card title",
3711
- onChange: (e) => updateCard(idx, {
3712
- ...card,
3713
- title: e.target.value ? { type: "mrkdwn", text: e.target.value } : void 0
3714
- })
3715
- }
3716
- ) }),
3717
- /* @__PURE__ */ jsxRuntime.jsx(EditorField, { label: "Body", htmlFor: `carousel-card-body-${idx}`, children: /* @__PURE__ */ jsxRuntime.jsx(
3718
- Textarea,
3719
- {
3720
- id: `carousel-card-body-${idx}`,
3721
- value: card.body?.text ?? "",
3722
- maxLength: 200,
3723
- rows: 2,
3724
- placeholder: "e.g. Short card description.",
3725
- onChange: (e) => updateCard(idx, {
3726
- ...card,
3727
- body: e.target.value ? { type: "mrkdwn", text: e.target.value } : void 0
3728
- })
3729
- }
3730
- ) })
3713
+ /* @__PURE__ */ jsxRuntime.jsx(CardEditor, { block: card, idPrefix: `carousel-card-${idx}`, onChange: (next) => updateCard(idx, next) })
3731
3714
  ] }, idx)),
3732
3715
  /* @__PURE__ */ jsxRuntime.jsxs(Button, { type: "button", size: "sm", onClick: addCard, disabled: elements.length >= MAX_CARDS, className: "self-start", children: [
3733
3716
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-3.5 w-3.5" }),