react-blockkit 0.3.3 → 0.5.0
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 +13 -6
- package/dist/blocks/AdvancedBlocks.d.ts.map +1 -1
- package/dist/blocks/BasicBlocks.d.ts.map +1 -1
- package/dist/blocks/InteractiveBlocks.d.ts.map +1 -1
- package/dist/elements/Elements.d.ts.map +1 -1
- package/dist/errors.d.ts +5 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +268 -249
- package/dist/index.js.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/package.json +3 -3
- package/docs/coverage-matrix.md +0 -80
- package/docs/parity/chart-bar-3-w580-dark.png +0 -0
- package/docs/parity/chart-bar-3-w580-light.png +0 -0
- package/docs/parity/chart-line-3-w580-light.png +0 -0
- package/docs/parity/chart-pie-12-w400-light.png +0 -0
- package/docs/parity/chart-pie-5-w580-light.png +0 -0
- package/docs/parity/data-table-w580-dark.png +0 -0
- package/docs/parity/data-table-w580-light.png +0 -0
- package/docs/parity/headers-levels-w580-light.png +0 -0
- package/docs/parity/icons-alert-info.png +0 -0
- package/docs/parity/icons-card-slack-icon.png +0 -0
- package/docs/parity/icons-context-actions.png +0 -0
- package/docs/parity/icons-data-table-header.png +0 -0
- package/docs/parity/icons-datepicker.png +0 -0
- package/docs/parity/icons-overflow.png +0 -0
- package/docs/parity/icons-pagination.png +0 -0
- package/docs/parity/icons-select-chevron.png +0 -0
- package/docs/parity/rich-text-full-w580-light.png +0 -0
- package/docs/parity/spacing-rhythm-w580-light.png +0 -0
- package/docs/parity/table-align-wrap-w580-light.png +0 -0
- package/docs/parity/table-basic-w580-light.png +0 -0
package/dist/index.js
CHANGED
|
@@ -2417,9 +2417,9 @@ function ct(e) {
|
|
|
2417
2417
|
case "url_text_input":
|
|
2418
2418
|
case "number_input": return at(e);
|
|
2419
2419
|
case "datepicker": return $e(e.initial_date);
|
|
2420
|
-
case "file_input": return e.filetypes === void 0 ||
|
|
2420
|
+
case "file_input": return e.filetypes === void 0 || nt(e.filetypes);
|
|
2421
|
+
case "timepicker": return $e(e.initial_time);
|
|
2421
2422
|
case "datetimepicker":
|
|
2422
|
-
case "timepicker":
|
|
2423
2423
|
case "rich_text_input": return !0;
|
|
2424
2424
|
default: return !1;
|
|
2425
2425
|
}
|
|
@@ -3308,11 +3308,11 @@ function Kt(e) {
|
|
|
3308
3308
|
return w(e) && e.type === "image";
|
|
3309
3309
|
}
|
|
3310
3310
|
function R({ blockId: e, blockType: t, children: n, className: r }) {
|
|
3311
|
-
let i = g(O.block);
|
|
3311
|
+
let i = g(O.block), a = e;
|
|
3312
3312
|
return /* @__PURE__ */ u("div", {
|
|
3313
3313
|
...i,
|
|
3314
3314
|
className: A(i.className, r),
|
|
3315
|
-
"data-block-id":
|
|
3315
|
+
"data-block-id": typeof a == "string" ? a : void 0,
|
|
3316
3316
|
"data-block-type": t,
|
|
3317
3317
|
children: n
|
|
3318
3318
|
});
|
|
@@ -3442,7 +3442,7 @@ function tn({ block: e, className: t }) {
|
|
|
3442
3442
|
children: /* @__PURE__ */ u(fe, { size: 20 })
|
|
3443
3443
|
}), /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("strong", { children: "Remote file" }), /* @__PURE__ */ u("div", {
|
|
3444
3444
|
...g(O.smallText),
|
|
3445
|
-
children: e.external_id
|
|
3445
|
+
children: typeof e.external_id == "string" ? e.external_id : E(e, "remote file")
|
|
3446
3446
|
})] })]
|
|
3447
3447
|
})
|
|
3448
3448
|
});
|
|
@@ -3489,7 +3489,10 @@ function nn({ block: e, className: t }) {
|
|
|
3489
3489
|
}
|
|
3490
3490
|
//#endregion
|
|
3491
3491
|
//#region src/blocks/AdvancedBlocks.tsx
|
|
3492
|
-
function rn(
|
|
3492
|
+
function rn(e) {
|
|
3493
|
+
return typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : void 0;
|
|
3494
|
+
}
|
|
3495
|
+
function an({ align: e = "left", cell: t, className: n, firstColumn: r = !1, header: i = !1, path: a = "cell", scope: o = "col", wrapped: s = !1 }) {
|
|
3493
3496
|
let c = g(O.tableCell, i && O.tableHeader, r && O.tableCellFirstColumn, s && O.tableCellWrapped), l;
|
|
3494
3497
|
if (!w(t)) l = E(t, "table cell");
|
|
3495
3498
|
else switch (t.type) {
|
|
@@ -3500,10 +3503,10 @@ function rn({ align: e = "left", cell: t, className: n, firstColumn: r = !1, hea
|
|
|
3500
3503
|
});
|
|
3501
3504
|
break;
|
|
3502
3505
|
case "raw_number":
|
|
3503
|
-
l = t.text ??
|
|
3506
|
+
l = rn(t.text) ?? rn(t.value) ?? E(t, "table cell");
|
|
3504
3507
|
break;
|
|
3505
3508
|
case "raw_text":
|
|
3506
|
-
l = t.text;
|
|
3509
|
+
l = rn(t.text) ?? E(t, "table cell");
|
|
3507
3510
|
break;
|
|
3508
3511
|
default: l = E(t, "table cell");
|
|
3509
3512
|
}
|
|
@@ -3520,11 +3523,11 @@ function rn({ align: e = "left", cell: t, className: n, firstColumn: r = !1, hea
|
|
|
3520
3523
|
children: l
|
|
3521
3524
|
});
|
|
3522
3525
|
}
|
|
3523
|
-
function
|
|
3526
|
+
function on(e) {
|
|
3524
3527
|
return Array.isArray(e);
|
|
3525
3528
|
}
|
|
3526
|
-
function
|
|
3527
|
-
let r = Array.isArray(e.rows) ? e.rows.filter(
|
|
3529
|
+
function sn({ block: e, className: t, path: n = "block" }) {
|
|
3530
|
+
let r = Array.isArray(e.rows) ? e.rows.filter(on) : [], i = e.column_settings;
|
|
3528
3531
|
return /* @__PURE__ */ u(R, {
|
|
3529
3532
|
blockId: e.block_id,
|
|
3530
3533
|
blockType: e.type,
|
|
@@ -3533,14 +3536,14 @@ function on({ block: e, className: t, path: n = "block" }) {
|
|
|
3533
3536
|
...g(O.tableScroller),
|
|
3534
3537
|
children: /* @__PURE__ */ d("table", {
|
|
3535
3538
|
...g(O.table),
|
|
3536
|
-
children: [/* @__PURE__ */ u("thead", { children: /* @__PURE__ */ u("tr", { children: (r[0] ?? []).map((e, t) => /* @__PURE__ */ u(
|
|
3539
|
+
children: [/* @__PURE__ */ u("thead", { children: /* @__PURE__ */ u("tr", { children: (r[0] ?? []).map((e, t) => /* @__PURE__ */ u(an, {
|
|
3537
3540
|
align: i?.[t]?.align,
|
|
3538
3541
|
cell: e,
|
|
3539
3542
|
firstColumn: t === 0,
|
|
3540
3543
|
header: !0,
|
|
3541
3544
|
path: `${n}.rows[0][${String(t)}]`,
|
|
3542
3545
|
wrapped: i?.[t]?.is_wrapped
|
|
3543
|
-
}, `header-${String(t)}`)) }) }), /* @__PURE__ */ u("tbody", { children: r.slice(1).map((e, t) => /* @__PURE__ */ u("tr", { children: e.map((e, r) => /* @__PURE__ */ u(
|
|
3546
|
+
}, `header-${String(t)}`)) }) }), /* @__PURE__ */ u("tbody", { children: r.slice(1).map((e, t) => /* @__PURE__ */ u("tr", { children: e.map((e, r) => /* @__PURE__ */ u(an, {
|
|
3544
3547
|
align: i?.[r]?.align,
|
|
3545
3548
|
cell: e,
|
|
3546
3549
|
firstColumn: r === 0,
|
|
@@ -3551,19 +3554,19 @@ function on({ block: e, className: t, path: n = "block" }) {
|
|
|
3551
3554
|
})
|
|
3552
3555
|
});
|
|
3553
3556
|
}
|
|
3554
|
-
function
|
|
3557
|
+
function cn({ cell: e, path: t }) {
|
|
3555
3558
|
if (!w(e)) return E(e, "table cell");
|
|
3556
3559
|
switch (e.type) {
|
|
3557
3560
|
case "rich_text": return /* @__PURE__ */ u(N, {
|
|
3558
3561
|
block: e,
|
|
3559
3562
|
path: t
|
|
3560
3563
|
});
|
|
3561
|
-
case "raw_number": return e.text ??
|
|
3562
|
-
case "raw_text": return e.text;
|
|
3564
|
+
case "raw_number": return rn(e.text) ?? rn(e.value) ?? E(e, "table cell");
|
|
3565
|
+
case "raw_text": return rn(e.text) ?? E(e, "table cell");
|
|
3563
3566
|
default: return E(e, "table cell");
|
|
3564
3567
|
}
|
|
3565
3568
|
}
|
|
3566
|
-
function
|
|
3569
|
+
function ln(e) {
|
|
3567
3570
|
let t = e;
|
|
3568
3571
|
if (!w(t)) return "";
|
|
3569
3572
|
if (e.type === "raw_text") {
|
|
@@ -3582,8 +3585,8 @@ function cn(e) {
|
|
|
3582
3585
|
}
|
|
3583
3586
|
return "";
|
|
3584
3587
|
}
|
|
3585
|
-
function
|
|
3586
|
-
let i = e.page_size ?? 5, a = Number.isFinite(i) && i > 0 ? Math.max(1, Math.trunc(i)) : 5, o = Array.isArray(e.rows) ? e.rows.filter(
|
|
3588
|
+
function un({ block: e, className: n, path: r = "block" }) {
|
|
3589
|
+
let i = e.page_size ?? 5, a = Number.isFinite(i) && i > 0 ? Math.max(1, Math.trunc(i)) : 5, o = Array.isArray(e.rows) ? e.rows.filter(on) : [], s = e.row_header_column_index ?? 0, l = typeof e.caption == "string" ? e.caption : void 0, [f, p] = c(0), [m, h] = c(""), _ = o[0] ?? [], v = m.trim().toLowerCase(), y = v === "" ? o.slice(1) : o.slice(1).filter((e) => e.some((e) => ln(e).toLowerCase().includes(v))), b = Math.max(1, Math.ceil(y.length / a)), x = Math.min(f, b - 1), S = y.slice(x * a, (x + 1) * a), C = S.length - 1;
|
|
3587
3590
|
return /* @__PURE__ */ u(R, {
|
|
3588
3591
|
blockId: e.block_id,
|
|
3589
3592
|
blockType: e.type,
|
|
@@ -3640,14 +3643,14 @@ function ln({ block: e, className: n, path: r = "block" }) {
|
|
|
3640
3643
|
...g(O.dataTableTh),
|
|
3641
3644
|
key: `header-${String(n)}`,
|
|
3642
3645
|
scope: "col"
|
|
3643
|
-
}, /* @__PURE__ */ u(
|
|
3646
|
+
}, /* @__PURE__ */ u(cn, {
|
|
3644
3647
|
cell: e,
|
|
3645
3648
|
path: `${r}.rows[0][${String(n)}]`
|
|
3646
3649
|
}))) }) }),
|
|
3647
3650
|
/* @__PURE__ */ u("tbody", { children: S.map((e, n) => {
|
|
3648
3651
|
let i = x * a + n + 1, o = e.length - 1;
|
|
3649
3652
|
return /* @__PURE__ */ u("tr", { children: e.map((e, a) => {
|
|
3650
|
-
let c = g(O.dataTableTd, n === 0 && a === 0 && O.dataTableRadiusTopStart, n === 0 && a === o && O.dataTableRadiusTopEnd, n === C && a === 0 && O.dataTableRadiusBottomStart, n === C && a === o && O.dataTableRadiusBottomEnd), l = /* @__PURE__ */ u(
|
|
3653
|
+
let c = g(O.dataTableTd, n === 0 && a === 0 && O.dataTableRadiusTopStart, n === 0 && a === o && O.dataTableRadiusTopEnd, n === C && a === 0 && O.dataTableRadiusBottomStart, n === C && a === o && O.dataTableRadiusBottomEnd), l = /* @__PURE__ */ u(cn, {
|
|
3651
3654
|
cell: e,
|
|
3652
3655
|
path: `${r}.rows[${String(i)}][${String(a)}]`
|
|
3653
3656
|
});
|
|
@@ -3700,7 +3703,7 @@ function ln({ block: e, className: n, path: r = "block" }) {
|
|
|
3700
3703
|
})
|
|
3701
3704
|
});
|
|
3702
3705
|
}
|
|
3703
|
-
function
|
|
3706
|
+
function dn({ name: e }) {
|
|
3704
3707
|
let t = typeof e == "string" ? be[e] : void 0;
|
|
3705
3708
|
return /* @__PURE__ */ u("span", {
|
|
3706
3709
|
...g(O.iconSlot),
|
|
@@ -3709,7 +3712,7 @@ function un({ name: e }) {
|
|
|
3709
3712
|
children: u(t === void 0 ? le : t, { size: 24 })
|
|
3710
3713
|
});
|
|
3711
3714
|
}
|
|
3712
|
-
function
|
|
3715
|
+
function fn({ block: e, className: t }) {
|
|
3713
3716
|
let n = Array.isArray(e.actions) ? e.actions : void 0;
|
|
3714
3717
|
return /* @__PURE__ */ u(R, {
|
|
3715
3718
|
blockId: e.block_id,
|
|
@@ -3727,7 +3730,7 @@ function dn({ block: e, className: t }) {
|
|
|
3727
3730
|
children: [
|
|
3728
3731
|
e.icon === void 0 && e.slack_icon === void 0 && e.title === void 0 && e.subtitle === void 0 ? null : /* @__PURE__ */ d("div", {
|
|
3729
3732
|
...g(O.cardHeading),
|
|
3730
|
-
children: [e.icon === void 0 ? e.slack_icon === void 0 ? null : /* @__PURE__ */ u(
|
|
3733
|
+
children: [e.icon === void 0 ? e.slack_icon === void 0 ? null : /* @__PURE__ */ u(dn, { name: w(e.slack_icon) ? e.slack_icon.name : void 0 }) : /* @__PURE__ */ u(F, {
|
|
3731
3734
|
element: e.icon,
|
|
3732
3735
|
variant: "cardIcon"
|
|
3733
3736
|
}), /* @__PURE__ */ d("div", { children: [e.title === void 0 ? null : /* @__PURE__ */ u(L, {
|
|
@@ -3756,10 +3759,10 @@ function dn({ block: e, className: t }) {
|
|
|
3756
3759
|
})
|
|
3757
3760
|
});
|
|
3758
3761
|
}
|
|
3759
|
-
function
|
|
3762
|
+
function pn(e) {
|
|
3760
3763
|
return w(e) && e.type === "card";
|
|
3761
3764
|
}
|
|
3762
|
-
function
|
|
3765
|
+
function mn({ block: e, className: n, path: r = "block" }) {
|
|
3763
3766
|
let i = e.elements;
|
|
3764
3767
|
return /* @__PURE__ */ u(R, {
|
|
3765
3768
|
blockId: e.block_id,
|
|
@@ -3767,7 +3770,7 @@ function pn({ block: e, className: n, path: r = "block" }) {
|
|
|
3767
3770
|
className: n,
|
|
3768
3771
|
children: /* @__PURE__ */ u("div", {
|
|
3769
3772
|
...g(O.carousel),
|
|
3770
|
-
children: Array.isArray(i) ? i.map((e, n) =>
|
|
3773
|
+
children: Array.isArray(i) ? i.map((e, n) => pn(e) ? /* @__PURE__ */ u(fn, {
|
|
3771
3774
|
block: e,
|
|
3772
3775
|
className: g(O.carouselCard).className,
|
|
3773
3776
|
path: `${r}.elements[${String(n)}]`
|
|
@@ -3779,7 +3782,7 @@ function pn({ block: e, className: n, path: r = "block" }) {
|
|
|
3779
3782
|
})
|
|
3780
3783
|
});
|
|
3781
3784
|
}
|
|
3782
|
-
function
|
|
3785
|
+
function hn({ block: e, className: t }) {
|
|
3783
3786
|
let n = e.level ?? "default";
|
|
3784
3787
|
return /* @__PURE__ */ u(R, {
|
|
3785
3788
|
blockId: e.block_id,
|
|
@@ -3795,7 +3798,7 @@ function mn({ block: e, className: t }) {
|
|
|
3795
3798
|
})
|
|
3796
3799
|
});
|
|
3797
3800
|
}
|
|
3798
|
-
function
|
|
3801
|
+
function gn({ block: e, className: n, path: r = "block" }) {
|
|
3799
3802
|
let i = e.sources, a = typeof e.status == "string" ? e.status : "unknown", o = typeof e.title == "string" ? e.title : E(e, "task");
|
|
3800
3803
|
return /* @__PURE__ */ u(R, {
|
|
3801
3804
|
blockId: e.block_id,
|
|
@@ -3847,10 +3850,10 @@ function hn({ block: e, className: n, path: r = "block" }) {
|
|
|
3847
3850
|
})
|
|
3848
3851
|
});
|
|
3849
3852
|
}
|
|
3850
|
-
function
|
|
3853
|
+
function _n(e) {
|
|
3851
3854
|
return w(e) && e.type === "task_card";
|
|
3852
3855
|
}
|
|
3853
|
-
function
|
|
3856
|
+
function vn({ block: e, className: n, path: r = "block" }) {
|
|
3854
3857
|
let i = e.tasks, a = typeof e.title == "string" ? e.title : E(e, "plan");
|
|
3855
3858
|
return /* @__PURE__ */ u(R, {
|
|
3856
3859
|
blockId: e.block_id,
|
|
@@ -3858,7 +3861,7 @@ function _n({ block: e, className: n, path: r = "block" }) {
|
|
|
3858
3861
|
className: n,
|
|
3859
3862
|
children: /* @__PURE__ */ d("div", {
|
|
3860
3863
|
...g(O.plan),
|
|
3861
|
-
children: [/* @__PURE__ */ u("strong", { children: a }), Array.isArray(i) ? i.map((e, n) =>
|
|
3864
|
+
children: [/* @__PURE__ */ u("strong", { children: a }), Array.isArray(i) ? i.map((e, n) => _n(e) ? /* @__PURE__ */ u(gn, {
|
|
3862
3865
|
block: e,
|
|
3863
3866
|
path: `${r}.tasks[${String(n)}]`
|
|
3864
3867
|
}, `${typeof e.task_id == "string" ? e.task_id : "task"}-${String(n)}`) : /* @__PURE__ */ t("div", {
|
|
@@ -3871,7 +3874,7 @@ function _n({ block: e, className: n, path: r = "block" }) {
|
|
|
3871
3874
|
}
|
|
3872
3875
|
//#endregion
|
|
3873
3876
|
//#region src/constants.ts
|
|
3874
|
-
var
|
|
3877
|
+
var yn = 3e3, bn = 3e3, xn = 2e3, Sn = 3e3, Cn = 2e3, wn = 2e3, Tn = 12e3, En = 3e3, Dn = 2e3, On = 1e4, kn = 2e4, An = [
|
|
3875
3878
|
"actions",
|
|
3876
3879
|
"alert",
|
|
3877
3880
|
"card",
|
|
@@ -3893,9 +3896,9 @@ var vn = 3e3, yn = 3e3, bn = 2e3, xn = 3e3, Sn = 2e3, Cn = 2e3, wn = 12e3, Tn =
|
|
|
3893
3896
|
"table",
|
|
3894
3897
|
"task_card",
|
|
3895
3898
|
"video"
|
|
3896
|
-
],
|
|
3897
|
-
function
|
|
3898
|
-
let [e, t] = c(
|
|
3899
|
+
], jn = 554;
|
|
3900
|
+
function Mn() {
|
|
3901
|
+
let [e, t] = c(jn + 26), r = s(void 0), a = n((e) => {
|
|
3899
3902
|
if (r.current?.disconnect(), r.current = void 0, e === null) return;
|
|
3900
3903
|
let n = () => {
|
|
3901
3904
|
let n = e.getBoundingClientRect().width;
|
|
@@ -3910,22 +3913,22 @@ function jn() {
|
|
|
3910
3913
|
width: e
|
|
3911
3914
|
};
|
|
3912
3915
|
}
|
|
3913
|
-
function
|
|
3916
|
+
function Nn(e, t) {
|
|
3914
3917
|
let n = e / Math.max(1, t), r = 10 ** Math.floor(Math.log10(n)), i = n / r;
|
|
3915
3918
|
return i >= Math.sqrt(50) ? r * 10 : i >= Math.sqrt(10) ? r * 5 : i >= Math.SQRT2 ? r * 2 : r;
|
|
3916
3919
|
}
|
|
3917
|
-
function
|
|
3918
|
-
let n = Math.min(0, e), r = t > n ? t : n + 1, i =
|
|
3920
|
+
function Pn(e, t) {
|
|
3921
|
+
let n = Math.min(0, e), r = t > n ? t : n + 1, i = Nn(r - n, 4), a = Math.floor(n / i), o = Math.ceil(r / i), s = [];
|
|
3919
3922
|
for (let e = a; e <= o; e += 1) s.push(e * i);
|
|
3920
3923
|
return s;
|
|
3921
3924
|
}
|
|
3922
|
-
function
|
|
3925
|
+
function Fn(e) {
|
|
3923
3926
|
return Math.ceil(e - .5) + .5;
|
|
3924
3927
|
}
|
|
3925
|
-
function
|
|
3928
|
+
function In(e, t) {
|
|
3926
3929
|
let n = 0, r = 0;
|
|
3927
3930
|
for (let e of t) n = Math.min(n, e), r = Math.max(r, e);
|
|
3928
|
-
let i =
|
|
3931
|
+
let i = Pn(n, r), a = i[0] ?? 0, o = (i[i.length - 1] ?? 1) - a || 1;
|
|
3929
3932
|
return {
|
|
3930
3933
|
plotLeft: 74,
|
|
3931
3934
|
plotRight: e,
|
|
@@ -3934,14 +3937,14 @@ function Fn(e, t) {
|
|
|
3934
3937
|
y: (e) => 334 - (e - a) / o * 325
|
|
3935
3938
|
};
|
|
3936
3939
|
}
|
|
3937
|
-
function
|
|
3940
|
+
function Ln(e) {
|
|
3938
3941
|
return Ee[e % Ee.length] ?? Te;
|
|
3939
3942
|
}
|
|
3940
|
-
function
|
|
3943
|
+
function Rn(e, t) {
|
|
3941
3944
|
let n = new Map(e.data.map((e) => [e.label, e]));
|
|
3942
3945
|
return t.map((e) => n.get(e));
|
|
3943
3946
|
}
|
|
3944
|
-
function
|
|
3947
|
+
function zn(e, t, n, r) {
|
|
3945
3948
|
let i = Math.min(4, t / 2, Math.abs(r - n)), a = e, o = e + t;
|
|
3946
3949
|
return [
|
|
3947
3950
|
`M${String(a + i)} ${String(n)}`,
|
|
@@ -3954,7 +3957,7 @@ function Rn(e, t, n, r) {
|
|
|
3954
3957
|
"Z"
|
|
3955
3958
|
].join("");
|
|
3956
3959
|
}
|
|
3957
|
-
function
|
|
3960
|
+
function Bn(e) {
|
|
3958
3961
|
if (e.length === 0) return "";
|
|
3959
3962
|
let t = e[0];
|
|
3960
3963
|
if (t === void 0) return "";
|
|
@@ -3981,10 +3984,10 @@ function zn(e) {
|
|
|
3981
3984
|
}
|
|
3982
3985
|
return r.join("");
|
|
3983
3986
|
}
|
|
3984
|
-
function
|
|
3987
|
+
function Vn({ geometry: e }) {
|
|
3985
3988
|
let { plotLeft: n, plotRight: r, ticks: i, y: a } = e;
|
|
3986
3989
|
return /* @__PURE__ */ d(l, { children: [i.map((e) => {
|
|
3987
|
-
let i =
|
|
3990
|
+
let i = Fn(a(e));
|
|
3988
3991
|
return /* @__PURE__ */ t("path", {
|
|
3989
3992
|
...g(O.chartGridline),
|
|
3990
3993
|
d: `M${String(n)} ${String(i)}L${String(r)} ${String(i)}`,
|
|
@@ -4000,7 +4003,7 @@ function Bn({ geometry: e }) {
|
|
|
4000
4003
|
y: a(e)
|
|
4001
4004
|
}, e))] });
|
|
4002
4005
|
}
|
|
4003
|
-
function
|
|
4006
|
+
function Hn({ categories: e, tickX: n }) {
|
|
4004
4007
|
return /* @__PURE__ */ u(l, { children: e.map((e, r) => /* @__PURE__ */ t("text", {
|
|
4005
4008
|
...g(O.chartTickText),
|
|
4006
4009
|
key: `${e}-${String(r)}`,
|
|
@@ -4009,26 +4012,26 @@ function Vn({ categories: e, tickX: n }) {
|
|
|
4009
4012
|
y: 351
|
|
4010
4013
|
}, e)) });
|
|
4011
4014
|
}
|
|
4012
|
-
function
|
|
4015
|
+
function Un(e, t) {
|
|
4013
4016
|
let n = e * Math.min(.155, Math.max(.075, .175 - .02 * t));
|
|
4014
4017
|
return {
|
|
4015
4018
|
barWidth: (e - 2 * n) / (1.1 * t - .1),
|
|
4016
4019
|
outer: n
|
|
4017
4020
|
};
|
|
4018
4021
|
}
|
|
4019
|
-
function
|
|
4022
|
+
function Wn({ chart: e, svgWidth: n, title: r }) {
|
|
4020
4023
|
let i = e.axis_config.categories, a = e.series.map((e) => ({
|
|
4021
|
-
points:
|
|
4024
|
+
points: Rn(e, i),
|
|
4022
4025
|
series: e
|
|
4023
|
-
})), o =
|
|
4026
|
+
})), o = In(n, a.flatMap(({ points: e }) => e.flatMap((e) => e === void 0 ? [] : [e.value]))), { plotLeft: s, plotRight: c, y: l } = o, f, p;
|
|
4024
4027
|
if (e.type === "bar") {
|
|
4025
|
-
let n = (c - s) / Math.max(1, i.length), { barWidth: r, outer: o } =
|
|
4028
|
+
let n = (c - s) / Math.max(1, i.length), { barWidth: r, outer: o } = Un(n, Math.max(1, e.series.length));
|
|
4026
4029
|
p = (e) => s + n * (e + .5), f = a.map(({ points: e, series: i }, a) => e.map((e, c) => {
|
|
4027
4030
|
if (e === void 0) return null;
|
|
4028
4031
|
let u = s + c * n + o + 1.1 * r * a;
|
|
4029
4032
|
return /* @__PURE__ */ t("path", {
|
|
4030
|
-
...g(
|
|
4031
|
-
d:
|
|
4033
|
+
...g(Ln(a).fill),
|
|
4034
|
+
d: zn(u, r, l(e.value), 334),
|
|
4032
4035
|
"data-category": e.label,
|
|
4033
4036
|
"data-series": i.name,
|
|
4034
4037
|
key: `${i.name}-${String(a)}-${e.label}-${String(c)}`
|
|
@@ -4040,15 +4043,15 @@ function Un({ chart: e, svgWidth: n, title: r }) {
|
|
|
4040
4043
|
let a = t.flatMap((e, t) => e === void 0 ? [] : [{
|
|
4041
4044
|
x: n(t),
|
|
4042
4045
|
y: l(e.value)
|
|
4043
|
-
}]), o =
|
|
4046
|
+
}]), o = Bn(a);
|
|
4044
4047
|
if (o === "") return null;
|
|
4045
4048
|
let s = a[a.length - 1], c = a[0];
|
|
4046
4049
|
return /* @__PURE__ */ d("g", { children: [e.type === "area" && c !== void 0 && s !== void 0 ? /* @__PURE__ */ u("path", {
|
|
4047
|
-
...g(
|
|
4050
|
+
...g(Ln(i).tint, O.chartAreaFill, i >= 6 && O.chartAreaFallbackFill),
|
|
4048
4051
|
d: `${o}L${String(s.x)} 334L${String(c.x)} 334Z`,
|
|
4049
4052
|
"data-series-area": r.name
|
|
4050
4053
|
}) : null, /* @__PURE__ */ u("path", {
|
|
4051
|
-
...g(
|
|
4054
|
+
...g(Ln(i).stroke, O.chartLinePath),
|
|
4052
4055
|
d: o,
|
|
4053
4056
|
"data-series": r.name,
|
|
4054
4057
|
fill: "none"
|
|
@@ -4062,22 +4065,22 @@ function Un({ chart: e, svgWidth: n, title: r }) {
|
|
|
4062
4065
|
role: "img",
|
|
4063
4066
|
width: n,
|
|
4064
4067
|
children: [
|
|
4065
|
-
/* @__PURE__ */ u(
|
|
4068
|
+
/* @__PURE__ */ u(Vn, { geometry: o }),
|
|
4066
4069
|
f,
|
|
4067
|
-
/* @__PURE__ */ u(
|
|
4070
|
+
/* @__PURE__ */ u(Hn, {
|
|
4068
4071
|
categories: i,
|
|
4069
4072
|
tickX: p
|
|
4070
4073
|
})
|
|
4071
4074
|
]
|
|
4072
4075
|
});
|
|
4073
4076
|
}
|
|
4074
|
-
function
|
|
4077
|
+
function Gn(e, t, n, r) {
|
|
4075
4078
|
return {
|
|
4076
4079
|
x: e + n * Math.sin(r),
|
|
4077
4080
|
y: t - n * Math.cos(r)
|
|
4078
4081
|
};
|
|
4079
4082
|
}
|
|
4080
|
-
function
|
|
4083
|
+
function Kn({ chart: e, svgWidth: n, title: r }) {
|
|
4081
4084
|
let i = e.segments.map((e) => Number.isFinite(e.value) ? Math.max(0, e.value) : 0), a = i.reduce((e, t) => e + t, 0);
|
|
4082
4085
|
if (a <= 0) return /* @__PURE__ */ u("div", {
|
|
4083
4086
|
...g(O.unhandled),
|
|
@@ -4089,9 +4092,9 @@ function Gn({ chart: e, svgWidth: n, title: r }) {
|
|
|
4089
4092
|
let o = n / 2, s = 0, c = e.segments.map((e, n) => {
|
|
4090
4093
|
let r = (i[n] ?? 0) / a, c = s * 2 * Math.PI;
|
|
4091
4094
|
s += r;
|
|
4092
|
-
let l = s * 2 * Math.PI, u =
|
|
4095
|
+
let l = s * 2 * Math.PI, u = Gn(o, 180, 144, c), d = Gn(o, 180, 144, l), f = +(l - c > Math.PI), p = r >= 1 ? `M${String(o)} 36A144 144 0 1 1 ${String(o)} 324A144 144 0 1 1 ${String(o)} 36Z` : `M${String(u.x)} ${String(u.y)}A144 144 0 ${String(f)} 1 ${String(d.x)} ${String(d.y)}L${String(o)} 180Z`;
|
|
4093
4096
|
return r <= 0 ? null : /* @__PURE__ */ t("path", {
|
|
4094
|
-
...g(
|
|
4097
|
+
...g(Ln(n).fill, O.pieSlice),
|
|
4095
4098
|
d: p,
|
|
4096
4099
|
"data-segment": e.label,
|
|
4097
4100
|
key: `${e.label}-${String(n)}`
|
|
@@ -4106,41 +4109,41 @@ function Gn({ chart: e, svgWidth: n, title: r }) {
|
|
|
4106
4109
|
children: c
|
|
4107
4110
|
});
|
|
4108
4111
|
}
|
|
4109
|
-
var
|
|
4112
|
+
var qn = {
|
|
4110
4113
|
area: !0,
|
|
4111
4114
|
bar: !0,
|
|
4112
4115
|
line: !0
|
|
4113
4116
|
};
|
|
4114
|
-
function qn(e) {
|
|
4115
|
-
return w(e) && typeof e.label == "string" && typeof e.value == "number" && Number.isFinite(e.value);
|
|
4116
|
-
}
|
|
4117
4117
|
function Jn(e) {
|
|
4118
4118
|
return w(e) && typeof e.label == "string" && typeof e.value == "number" && Number.isFinite(e.value);
|
|
4119
4119
|
}
|
|
4120
4120
|
function Yn(e) {
|
|
4121
|
-
return w(e) && typeof e.
|
|
4121
|
+
return w(e) && typeof e.label == "string" && typeof e.value == "number" && Number.isFinite(e.value);
|
|
4122
4122
|
}
|
|
4123
4123
|
function Xn(e) {
|
|
4124
|
-
return w(e) && e.
|
|
4124
|
+
return w(e) && typeof e.name == "string" && Array.isArray(e.data) && e.data.every(Yn);
|
|
4125
4125
|
}
|
|
4126
4126
|
function Zn(e) {
|
|
4127
|
+
return w(e) && e.type === "pie" && Array.isArray(e.segments) && e.segments.every(Jn);
|
|
4128
|
+
}
|
|
4129
|
+
function Qn(e) {
|
|
4127
4130
|
if (!w(e)) return !1;
|
|
4128
4131
|
let t = e.type;
|
|
4129
|
-
if (typeof t != "string" || !(t in
|
|
4132
|
+
if (typeof t != "string" || !(t in qn)) return !1;
|
|
4130
4133
|
let n = e.axis_config;
|
|
4131
|
-
return Array.isArray(e.series) && e.series.every(
|
|
4134
|
+
return Array.isArray(e.series) && e.series.every(Xn) && w(n) && Array.isArray(n.categories) && n.categories.every((e) => typeof e == "string");
|
|
4132
4135
|
}
|
|
4133
|
-
function
|
|
4134
|
-
let r = e.chart, i = typeof e.title == "string" ? e.title : E(e, "chart"), { ref: a, width: o } =
|
|
4136
|
+
function $n({ block: e, className: n }) {
|
|
4137
|
+
let r = e.chart, i = typeof e.title == "string" ? e.title : E(e, "chart"), { ref: a, width: o } = Mn(), s = Math.min(624, Math.max(400, o)) - 26, c = Qn(r) ? r : void 0, l = c === void 0 && Zn(r) ? r : void 0, f, p;
|
|
4135
4138
|
l === void 0 ? c === void 0 ? (f = /* @__PURE__ */ u("div", {
|
|
4136
4139
|
...g(O.unhandled),
|
|
4137
4140
|
"data-unhandled-chart-type": T(r) ?? "unknown",
|
|
4138
4141
|
children: E(r, "chart")
|
|
4139
|
-
}), p = []) : (f = /* @__PURE__ */ u(
|
|
4142
|
+
}), p = []) : (f = /* @__PURE__ */ u(Wn, {
|
|
4140
4143
|
chart: c,
|
|
4141
4144
|
svgWidth: s,
|
|
4142
4145
|
title: i
|
|
4143
|
-
}), p = c.series.map((e) => e.name)) : (f = /* @__PURE__ */ u(
|
|
4146
|
+
}), p = c.series.map((e) => e.name)) : (f = /* @__PURE__ */ u(Kn, {
|
|
4144
4147
|
chart: l,
|
|
4145
4148
|
svgWidth: s,
|
|
4146
4149
|
title: i
|
|
@@ -4183,7 +4186,7 @@ function Qn({ block: e, className: n }) {
|
|
|
4183
4186
|
...g(O.chartLegendItem),
|
|
4184
4187
|
key: `${e}-${String(n)}`
|
|
4185
4188
|
}, /* @__PURE__ */ u("span", {
|
|
4186
|
-
...g(O.chartLegendSwatch,
|
|
4189
|
+
...g(O.chartLegendSwatch, Ln(n).swatch),
|
|
4187
4190
|
"aria-hidden": "true"
|
|
4188
4191
|
}), e))
|
|
4189
4192
|
})
|
|
@@ -4196,21 +4199,21 @@ function Qn({ block: e, className: n }) {
|
|
|
4196
4199
|
}
|
|
4197
4200
|
//#endregion
|
|
4198
4201
|
//#region src/blocks/InteractiveBlocks.tsx
|
|
4199
|
-
function $n(e) {
|
|
4200
|
-
return w(e) && w(e.text) && typeof e.text.text == "string";
|
|
4201
|
-
}
|
|
4202
4202
|
function er(e) {
|
|
4203
|
-
return w(e) && e.
|
|
4203
|
+
return w(e) && w(e.text) && typeof e.text.text == "string";
|
|
4204
4204
|
}
|
|
4205
4205
|
function tr(e) {
|
|
4206
|
-
return w(e) && e.type === "
|
|
4206
|
+
return w(e) && e.type === "feedback_buttons" && er(e.positive_button) && er(e.negative_button);
|
|
4207
|
+
}
|
|
4208
|
+
function nr(e) {
|
|
4209
|
+
return w(e) && e.type === "icon_button" && er(e) && typeof e.icon == "string";
|
|
4207
4210
|
}
|
|
4208
|
-
function
|
|
4211
|
+
function rr({ block: e, className: t, path: n = "block" }) {
|
|
4209
4212
|
let r = g(O.block, O.actions), i = Array.isArray(e.elements) ? e.elements : [];
|
|
4210
4213
|
return /* @__PURE__ */ u("div", {
|
|
4211
4214
|
...r,
|
|
4212
4215
|
className: A(r.className, t),
|
|
4213
|
-
"data-block-id": e
|
|
4216
|
+
"data-block-id": xe(e),
|
|
4214
4217
|
"data-block-type": e.type,
|
|
4215
4218
|
children: i.map((t, r) => /* @__PURE__ */ u(Dt, {
|
|
4216
4219
|
blockId: e.block_id,
|
|
@@ -4219,12 +4222,12 @@ function nr({ block: e, className: t, path: n = "block" }) {
|
|
|
4219
4222
|
}, `${T(t) ?? "unknown"}-${w(t) && typeof t.action_id == "string" ? t.action_id : "action"}-${String(r)}`))
|
|
4220
4223
|
});
|
|
4221
4224
|
}
|
|
4222
|
-
function
|
|
4225
|
+
function ir({ block: e, className: t, path: n = "block" }) {
|
|
4223
4226
|
let r = g(O.block, O.inputBlock), i = e.label;
|
|
4224
4227
|
return /* @__PURE__ */ d("div", {
|
|
4225
4228
|
...r,
|
|
4226
4229
|
className: A(r.className, t),
|
|
4227
|
-
"data-block-id": e
|
|
4230
|
+
"data-block-id": xe(e),
|
|
4228
4231
|
"data-block-type": e.type,
|
|
4229
4232
|
children: [
|
|
4230
4233
|
/* @__PURE__ */ d("div", {
|
|
@@ -4247,18 +4250,18 @@ function rr({ block: e, className: t, path: n = "block" }) {
|
|
|
4247
4250
|
]
|
|
4248
4251
|
});
|
|
4249
4252
|
}
|
|
4250
|
-
function
|
|
4253
|
+
function ar(e, t) {
|
|
4251
4254
|
return t === "positive" ? e.positive_button.text.text : e.negative_button.text.text;
|
|
4252
4255
|
}
|
|
4253
|
-
function
|
|
4256
|
+
function or({ block: e, className: n }) {
|
|
4254
4257
|
let { onAction: r } = x(), i = g(O.block, O.actions), a = e.elements;
|
|
4255
4258
|
return /* @__PURE__ */ u("div", {
|
|
4256
4259
|
...i,
|
|
4257
4260
|
className: A(i.className, n),
|
|
4258
|
-
"data-block-id": e
|
|
4261
|
+
"data-block-id": xe(e),
|
|
4259
4262
|
"data-block-type": e.type,
|
|
4260
4263
|
children: Array.isArray(a) ? a.map((n, i) => {
|
|
4261
|
-
if (
|
|
4264
|
+
if (nr(n)) {
|
|
4262
4265
|
let a = g(O.button, O.iconButton), o = be[n.icon];
|
|
4263
4266
|
return /* @__PURE__ */ t("button", {
|
|
4264
4267
|
...a,
|
|
@@ -4276,12 +4279,12 @@ function ar({ block: e, className: n }) {
|
|
|
4276
4279
|
type: "button"
|
|
4277
4280
|
}, o === void 0 ? n.icon : /* @__PURE__ */ u(o, { size: 16 }));
|
|
4278
4281
|
}
|
|
4279
|
-
return
|
|
4282
|
+
return tr(n) ? /* @__PURE__ */ t("div", {
|
|
4280
4283
|
...g(O.actions),
|
|
4281
4284
|
key: `${n.type}-${n.action_id ?? "feedback"}-${String(i)}`
|
|
4282
4285
|
}, /* @__PURE__ */ u("button", {
|
|
4283
4286
|
...g(O.button, O.iconButton),
|
|
4284
|
-
"aria-label":
|
|
4287
|
+
"aria-label": ar(n, "positive"),
|
|
4285
4288
|
onClick: () => {
|
|
4286
4289
|
n.action_id !== void 0 && r?.({
|
|
4287
4290
|
actionId: n.action_id,
|
|
@@ -4294,7 +4297,7 @@ function ar({ block: e, className: n }) {
|
|
|
4294
4297
|
children: /* @__PURE__ */ u(_e, { size: 16 })
|
|
4295
4298
|
}), /* @__PURE__ */ u("button", {
|
|
4296
4299
|
...g(O.button, O.iconButton),
|
|
4297
|
-
"aria-label":
|
|
4300
|
+
"aria-label": ar(n, "negative"),
|
|
4298
4301
|
onClick: () => {
|
|
4299
4302
|
n.action_id !== void 0 && r?.({
|
|
4300
4303
|
actionId: n.action_id,
|
|
@@ -4319,14 +4322,14 @@ function ar({ block: e, className: n }) {
|
|
|
4319
4322
|
}
|
|
4320
4323
|
//#endregion
|
|
4321
4324
|
//#region src/Block.tsx
|
|
4322
|
-
var
|
|
4323
|
-
function
|
|
4325
|
+
var sr = new Set(An);
|
|
4326
|
+
function cr(e) {
|
|
4324
4327
|
let t = T(e);
|
|
4325
|
-
return t !== void 0 &&
|
|
4328
|
+
return t !== void 0 && sr.has(t);
|
|
4326
4329
|
}
|
|
4327
|
-
function
|
|
4330
|
+
function lr({ block: e, className: t, path: n = "block" }) {
|
|
4328
4331
|
let r = T(e);
|
|
4329
|
-
if (!
|
|
4332
|
+
if (!cr(e)) {
|
|
4330
4333
|
let n = g(O.block, O.unhandled);
|
|
4331
4334
|
return /* @__PURE__ */ u("div", {
|
|
4332
4335
|
...n,
|
|
@@ -4338,27 +4341,27 @@ function cr({ block: e, className: t, path: n = "block" }) {
|
|
|
4338
4341
|
});
|
|
4339
4342
|
}
|
|
4340
4343
|
switch (e.type) {
|
|
4341
|
-
case "actions": return /* @__PURE__ */ u(
|
|
4344
|
+
case "actions": return /* @__PURE__ */ u(rr, {
|
|
4342
4345
|
block: e,
|
|
4343
4346
|
className: t,
|
|
4344
4347
|
path: n
|
|
4345
4348
|
});
|
|
4346
|
-
case "alert": return /* @__PURE__ */ u(
|
|
4349
|
+
case "alert": return /* @__PURE__ */ u(hn, {
|
|
4347
4350
|
block: e,
|
|
4348
4351
|
className: t,
|
|
4349
4352
|
path: n
|
|
4350
4353
|
});
|
|
4351
|
-
case "card": return /* @__PURE__ */ u(
|
|
4354
|
+
case "card": return /* @__PURE__ */ u(fn, {
|
|
4352
4355
|
block: e,
|
|
4353
4356
|
className: t,
|
|
4354
4357
|
path: n
|
|
4355
4358
|
});
|
|
4356
|
-
case "carousel": return /* @__PURE__ */ u(
|
|
4359
|
+
case "carousel": return /* @__PURE__ */ u(mn, {
|
|
4357
4360
|
block: e,
|
|
4358
4361
|
className: t,
|
|
4359
4362
|
path: n
|
|
4360
4363
|
});
|
|
4361
|
-
case "container": return /* @__PURE__ */ u(
|
|
4364
|
+
case "container": return /* @__PURE__ */ u(hr, {
|
|
4362
4365
|
block: e,
|
|
4363
4366
|
className: t,
|
|
4364
4367
|
path: n
|
|
@@ -4368,17 +4371,17 @@ function cr({ block: e, className: t, path: n = "block" }) {
|
|
|
4368
4371
|
className: t,
|
|
4369
4372
|
path: n
|
|
4370
4373
|
});
|
|
4371
|
-
case "context_actions": return /* @__PURE__ */ u(
|
|
4374
|
+
case "context_actions": return /* @__PURE__ */ u(or, {
|
|
4372
4375
|
block: e,
|
|
4373
4376
|
className: t,
|
|
4374
4377
|
path: n
|
|
4375
4378
|
});
|
|
4376
|
-
case "data_table": return /* @__PURE__ */ u(
|
|
4379
|
+
case "data_table": return /* @__PURE__ */ u(un, {
|
|
4377
4380
|
block: e,
|
|
4378
4381
|
className: t,
|
|
4379
4382
|
path: n
|
|
4380
4383
|
});
|
|
4381
|
-
case "data_visualization": return /* @__PURE__ */ u(
|
|
4384
|
+
case "data_visualization": return /* @__PURE__ */ u($n, {
|
|
4382
4385
|
block: e,
|
|
4383
4386
|
className: t,
|
|
4384
4387
|
path: n
|
|
@@ -4403,7 +4406,7 @@ function cr({ block: e, className: t, path: n = "block" }) {
|
|
|
4403
4406
|
className: t,
|
|
4404
4407
|
path: n
|
|
4405
4408
|
});
|
|
4406
|
-
case "input": return /* @__PURE__ */ u(
|
|
4409
|
+
case "input": return /* @__PURE__ */ u(ir, {
|
|
4407
4410
|
block: e,
|
|
4408
4411
|
className: t,
|
|
4409
4412
|
path: n
|
|
@@ -4413,7 +4416,7 @@ function cr({ block: e, className: t, path: n = "block" }) {
|
|
|
4413
4416
|
className: t,
|
|
4414
4417
|
path: n
|
|
4415
4418
|
});
|
|
4416
|
-
case "plan": return /* @__PURE__ */ u(
|
|
4419
|
+
case "plan": return /* @__PURE__ */ u(vn, {
|
|
4417
4420
|
block: e,
|
|
4418
4421
|
className: t,
|
|
4419
4422
|
path: n
|
|
@@ -4428,12 +4431,12 @@ function cr({ block: e, className: t, path: n = "block" }) {
|
|
|
4428
4431
|
className: t,
|
|
4429
4432
|
path: n
|
|
4430
4433
|
});
|
|
4431
|
-
case "table": return /* @__PURE__ */ u(
|
|
4434
|
+
case "table": return /* @__PURE__ */ u(sn, {
|
|
4432
4435
|
block: e,
|
|
4433
4436
|
className: t,
|
|
4434
4437
|
path: n
|
|
4435
4438
|
});
|
|
4436
|
-
case "task_card": return /* @__PURE__ */ u(
|
|
4439
|
+
case "task_card": return /* @__PURE__ */ u(gn, {
|
|
4437
4440
|
block: e,
|
|
4438
4441
|
className: t,
|
|
4439
4442
|
path: n
|
|
@@ -4446,10 +4449,10 @@ function cr({ block: e, className: t, path: n = "block" }) {
|
|
|
4446
4449
|
default: return _(e);
|
|
4447
4450
|
}
|
|
4448
4451
|
}
|
|
4449
|
-
function
|
|
4450
|
-
return /* @__PURE__ */ u(
|
|
4452
|
+
function ur(e) {
|
|
4453
|
+
return /* @__PURE__ */ u(lr, { ...e });
|
|
4451
4454
|
}
|
|
4452
|
-
var
|
|
4455
|
+
var dr = {
|
|
4453
4456
|
actions: !0,
|
|
4454
4457
|
context: !0,
|
|
4455
4458
|
divider: !0,
|
|
@@ -4462,11 +4465,11 @@ var ur = {
|
|
|
4462
4465
|
table: !0,
|
|
4463
4466
|
video: !0
|
|
4464
4467
|
};
|
|
4465
|
-
function
|
|
4468
|
+
function fr(e) {
|
|
4466
4469
|
let t = T(e);
|
|
4467
|
-
return t !== void 0 && t in
|
|
4470
|
+
return t !== void 0 && t in dr;
|
|
4468
4471
|
}
|
|
4469
|
-
function
|
|
4472
|
+
function pr({ block: e, path: t }) {
|
|
4470
4473
|
let n = e.title, r = e.subtitle;
|
|
4471
4474
|
return /* @__PURE__ */ d(l, { children: [e.icon === void 0 ? null : /* @__PURE__ */ u(F, {
|
|
4472
4475
|
element: e.icon,
|
|
@@ -4479,11 +4482,11 @@ function fr({ block: e, path: t }) {
|
|
|
4479
4482
|
children: w(r) && typeof r.text == "string" ? r.text : E(r, "container subtitle")
|
|
4480
4483
|
})] })] });
|
|
4481
4484
|
}
|
|
4482
|
-
function
|
|
4485
|
+
function mr({ block: e, path: n }) {
|
|
4483
4486
|
let r = e.child_blocks;
|
|
4484
4487
|
return /* @__PURE__ */ u("div", {
|
|
4485
4488
|
...g(O.containerBody),
|
|
4486
|
-
children: Array.isArray(r) ? r.map((e, r) =>
|
|
4489
|
+
children: Array.isArray(r) ? r.map((e, r) => fr(e) ? /* @__PURE__ */ u(lr, {
|
|
4487
4490
|
block: e,
|
|
4488
4491
|
path: `${n}.child_blocks[${String(r)}]`
|
|
4489
4492
|
}, `${T(e) ?? "unknown"}-${xe(e) ?? "block"}-${String(r)}`) : /* @__PURE__ */ t("div", {
|
|
@@ -4494,7 +4497,7 @@ function pr({ block: e, path: n }) {
|
|
|
4494
4497
|
}, E(e, "Slack block"))) : null
|
|
4495
4498
|
});
|
|
4496
4499
|
}
|
|
4497
|
-
function
|
|
4500
|
+
function hr({ block: e, className: t, path: n = "block" }) {
|
|
4498
4501
|
return /* @__PURE__ */ u(R, {
|
|
4499
4502
|
blockId: e.block_id,
|
|
4500
4503
|
blockType: e.type,
|
|
@@ -4509,11 +4512,11 @@ function mr({ block: e, className: t, path: n = "block" }) {
|
|
|
4509
4512
|
"aria-hidden": "true",
|
|
4510
4513
|
"data-container-chevron": !0,
|
|
4511
4514
|
children: /* @__PURE__ */ u(ne, { size: 16 })
|
|
4512
|
-
}), /* @__PURE__ */ u(
|
|
4515
|
+
}), /* @__PURE__ */ u(pr, {
|
|
4513
4516
|
block: e,
|
|
4514
4517
|
path: n
|
|
4515
4518
|
})]
|
|
4516
|
-
}), /* @__PURE__ */ u(
|
|
4519
|
+
}), /* @__PURE__ */ u(mr, {
|
|
4517
4520
|
block: e,
|
|
4518
4521
|
path: n
|
|
4519
4522
|
})]
|
|
@@ -4521,11 +4524,11 @@ function mr({ block: e, className: t, path: n = "block" }) {
|
|
|
4521
4524
|
...g(O.container),
|
|
4522
4525
|
children: [/* @__PURE__ */ u("div", {
|
|
4523
4526
|
...g(O.containerHeader, e.has_header_divider === !0 && O.containerHeaderDivider),
|
|
4524
|
-
children: /* @__PURE__ */ u(
|
|
4527
|
+
children: /* @__PURE__ */ u(pr, {
|
|
4525
4528
|
block: e,
|
|
4526
4529
|
path: n
|
|
4527
4530
|
})
|
|
4528
|
-
}), /* @__PURE__ */ u(
|
|
4531
|
+
}), /* @__PURE__ */ u(mr, {
|
|
4529
4532
|
block: e,
|
|
4530
4533
|
path: n
|
|
4531
4534
|
})]
|
|
@@ -4534,7 +4537,15 @@ function mr({ block: e, className: t, path: n = "block" }) {
|
|
|
4534
4537
|
}
|
|
4535
4538
|
//#endregion
|
|
4536
4539
|
//#region src/errors.ts
|
|
4537
|
-
var
|
|
4540
|
+
var gr = Symbol.for("slackmark.error.blockKitInvariant"), _r = class extends Error {
|
|
4541
|
+
static {
|
|
4542
|
+
Object.defineProperty(this.prototype, gr, {
|
|
4543
|
+
configurable: !1,
|
|
4544
|
+
enumerable: !1,
|
|
4545
|
+
value: !0,
|
|
4546
|
+
writable: !1
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4538
4549
|
code;
|
|
4539
4550
|
path;
|
|
4540
4551
|
name;
|
|
@@ -4542,14 +4553,22 @@ var hr = class extends Error {
|
|
|
4542
4553
|
super(`${t.path}: ${e}`), this.code = t.code, this.path = t.path, this.name = "BlockKitInvariantError";
|
|
4543
4554
|
}
|
|
4544
4555
|
};
|
|
4556
|
+
function vr(e) {
|
|
4557
|
+
if (typeof e != "object" || !e) return !1;
|
|
4558
|
+
try {
|
|
4559
|
+
return Reflect.get(e, gr) === !0;
|
|
4560
|
+
} catch {
|
|
4561
|
+
return !1;
|
|
4562
|
+
}
|
|
4563
|
+
}
|
|
4545
4564
|
//#endregion
|
|
4546
4565
|
//#region src/BlockKit.tsx
|
|
4547
|
-
function
|
|
4566
|
+
function yr(e) {
|
|
4548
4567
|
let t = e;
|
|
4549
4568
|
if (typeof e == "string") try {
|
|
4550
4569
|
t = JSON.parse(e);
|
|
4551
4570
|
} catch {
|
|
4552
|
-
throw new
|
|
4571
|
+
throw new _r("data: expected valid JSON", {
|
|
4553
4572
|
code: "invalid_json",
|
|
4554
4573
|
path: "data"
|
|
4555
4574
|
});
|
|
@@ -4565,8 +4584,8 @@ function gr(e) {
|
|
|
4565
4584
|
blocks: [t]
|
|
4566
4585
|
};
|
|
4567
4586
|
}
|
|
4568
|
-
function
|
|
4569
|
-
let c = o(() =>
|
|
4587
|
+
function br({ "aria-label": e = "Slack Block Kit preview", className: t, data: n, onAction: r, resolvers: i, surface: a = "message", theme: s = "light" }) {
|
|
4588
|
+
let c = o(() => yr(n), [n]), l = g(s === "dark" ? we : Ce, O.root, s === "dark" ? O.rootDark : O.rootLight);
|
|
4570
4589
|
return /* @__PURE__ */ u(b, {
|
|
4571
4590
|
onAction: r,
|
|
4572
4591
|
resolvers: i,
|
|
@@ -4579,7 +4598,7 @@ function _r({ "aria-label": e = "Slack Block Kit preview", className: t, data: n
|
|
|
4579
4598
|
"data-surface": a,
|
|
4580
4599
|
"data-theme": s,
|
|
4581
4600
|
role: "article",
|
|
4582
|
-
children: c.blocks.map((e, t) => /* @__PURE__ */ u(
|
|
4601
|
+
children: c.blocks.map((e, t) => /* @__PURE__ */ u(lr, {
|
|
4583
4602
|
block: e,
|
|
4584
4603
|
path: `${c.blockListPath}[${String(t)}]`
|
|
4585
4604
|
}, `${T(e) ?? "unknown"}-${xe(e) ?? "block"}-${String(t)}`))
|
|
@@ -4588,14 +4607,14 @@ function _r({ "aria-label": e = "Slack Block Kit preview", className: t, data: n
|
|
|
4588
4607
|
}
|
|
4589
4608
|
//#endregion
|
|
4590
4609
|
//#region src/validation.ts
|
|
4591
|
-
function
|
|
4592
|
-
throw new
|
|
4610
|
+
function xr(e, t, n) {
|
|
4611
|
+
throw new _r(n, {
|
|
4593
4612
|
code: e,
|
|
4594
4613
|
path: t
|
|
4595
4614
|
});
|
|
4596
4615
|
}
|
|
4597
4616
|
function z(e, t, n, r) {
|
|
4598
|
-
e ||
|
|
4617
|
+
e || xr(t, n, r);
|
|
4599
4618
|
}
|
|
4600
4619
|
function B(e, t) {
|
|
4601
4620
|
z(w(e), "invalid_type", t, "expected an object");
|
|
@@ -4624,67 +4643,67 @@ function q(e, t, n) {
|
|
|
4624
4643
|
function J(e, t) {
|
|
4625
4644
|
H(e.type, `${t}.type`), U(e.block_id, `${t}.block_id`, { max: 255 });
|
|
4626
4645
|
}
|
|
4627
|
-
function Y(e, t, n =
|
|
4646
|
+
function Y(e, t, n = yn) {
|
|
4628
4647
|
B(e, t), q(e.type, ["plain_text", "mrkdwn"], `${t}.type`), H(e.text, `${t}.text`, { max: n }), e.type === "plain_text" ? (G(e.emoji, `${t}.emoji`), z(e.verbatim === void 0, "invalid_value", `${t}.verbatim`, "verbatim is only legal on mrkdwn text")) : (G(e.verbatim, `${t}.verbatim`), z(e.emoji === void 0, "invalid_value", `${t}.emoji`, "emoji is only legal on plain_text"));
|
|
4629
4648
|
}
|
|
4630
|
-
function
|
|
4649
|
+
function Sr(e, t = "text", n = yn) {
|
|
4631
4650
|
Y(e, t, n);
|
|
4632
4651
|
}
|
|
4633
|
-
function X(e, t, n =
|
|
4652
|
+
function X(e, t, n = yn) {
|
|
4634
4653
|
Y(e, t, n), z(w(e) && e.type === "plain_text", "invalid_value", `${t}.type`, "expected \"plain_text\"");
|
|
4635
4654
|
}
|
|
4636
|
-
function
|
|
4655
|
+
function Cr(e, t) {
|
|
4637
4656
|
B(e, t);
|
|
4638
4657
|
let n = e.id !== void 0, r = e.url !== void 0;
|
|
4639
|
-
z(n !== r, "invalid_value", t, "must contain exactly one of id or url"), n && H(e.id, `${t}.id`), r && H(e.url, `${t}.url`, { max:
|
|
4658
|
+
z(n !== r, "invalid_value", t, "must contain exactly one of id or url"), n && H(e.id, `${t}.id`), r && H(e.url, `${t}.url`, { max: Sn });
|
|
4640
4659
|
}
|
|
4641
4660
|
function Z(e, t) {
|
|
4642
|
-
B(e, t), K(e, "image", t), H(e.alt_text, `${t}.alt_text`, { max:
|
|
4661
|
+
B(e, t), K(e, "image", t), H(e.alt_text, `${t}.alt_text`, { max: Cn });
|
|
4643
4662
|
let n = e.image_url !== void 0, r = e.slack_file !== void 0;
|
|
4644
|
-
z(n !== r, "invalid_value", t, "must contain exactly one of image_url or slack_file"), n && H(e.image_url, `${t}.image_url`, { max:
|
|
4663
|
+
z(n !== r, "invalid_value", t, "must contain exactly one of image_url or slack_file"), n && H(e.image_url, `${t}.image_url`, { max: Sn }), r && Cr(e.slack_file, `${t}.slack_file`);
|
|
4645
4664
|
}
|
|
4646
|
-
function
|
|
4665
|
+
function wr(e, t = "element") {
|
|
4647
4666
|
Z(e, t);
|
|
4648
4667
|
}
|
|
4649
|
-
function
|
|
4650
|
-
B(e, t), Y(e.text, `${t}.text`, 75), U(e.value, `${t}.value`, { max: 75 }), U(e.url, `${t}.url`, { max:
|
|
4668
|
+
function Tr(e, t) {
|
|
4669
|
+
B(e, t), Y(e.text, `${t}.text`, 75), U(e.value, `${t}.value`, { max: 75 }), U(e.url, `${t}.url`, { max: En }), e.description !== void 0 && X(e.description, `${t}.description`, 75);
|
|
4651
4670
|
}
|
|
4652
|
-
function
|
|
4671
|
+
function Er(e, t, n) {
|
|
4653
4672
|
V(e, t), z(e.length > 0, "missing_field", t, "must contain at least one option"), z(e.length <= n, "limit_exceeded", t, `must contain at most ${String(n)} options`), e.forEach((e, n) => {
|
|
4654
|
-
|
|
4673
|
+
Tr(e, `${t}[${String(n)}]`);
|
|
4655
4674
|
});
|
|
4656
4675
|
}
|
|
4657
|
-
function
|
|
4676
|
+
function Dr(e, t) {
|
|
4658
4677
|
U(e.action_id, `${t}.action_id`, { max: 255 });
|
|
4659
4678
|
}
|
|
4660
|
-
function
|
|
4679
|
+
function Or(e, t) {
|
|
4661
4680
|
e.placeholder !== void 0 && X(e.placeholder, `${t}.placeholder`, 150);
|
|
4662
4681
|
}
|
|
4663
|
-
function
|
|
4664
|
-
B(e, t), K(e, "button", t),
|
|
4682
|
+
function kr(e, t) {
|
|
4683
|
+
B(e, t), K(e, "button", t), Dr(e, t), X(e.text, `${t}.text`, 75), U(e.url, `${t}.url`, { max: En }), U(e.value, `${t}.value`, { max: Dn }), U(e.accessibility_label, `${t}.accessibility_label`, { max: 75 }), e.style !== void 0 && q(e.style, ["primary", "danger"], `${t}.style`);
|
|
4665
4684
|
}
|
|
4666
|
-
function
|
|
4685
|
+
function Ar(e, t) {
|
|
4667
4686
|
let n = e.options !== void 0, r = e.option_groups !== void 0;
|
|
4668
|
-
z(n !== r, "invalid_value", t, "must contain exactly one of options or option_groups"), n &&
|
|
4687
|
+
z(n !== r, "invalid_value", t, "must contain exactly one of options or option_groups"), n && Er(e.options, `${t}.options`, 100), r && (V(e.option_groups, `${t}.option_groups`), z(e.option_groups.length <= 100, "limit_exceeded", `${t}.option_groups`, "must contain at most 100 groups"), e.option_groups.forEach((e, n) => {
|
|
4669
4688
|
let r = `${t}.option_groups[${String(n)}]`;
|
|
4670
|
-
B(e, r), X(e.label, `${r}.label`, 75),
|
|
4689
|
+
B(e, r), X(e.label, `${r}.label`, 75), Er(e.options, `${r}.options`, 100);
|
|
4671
4690
|
}));
|
|
4672
4691
|
}
|
|
4673
|
-
function
|
|
4674
|
-
switch (B(e, t), H(e.type, `${t}.type`),
|
|
4692
|
+
function jr(e, t) {
|
|
4693
|
+
switch (B(e, t), H(e.type, `${t}.type`), Dr(e, t), Or(e, t), e.type) {
|
|
4675
4694
|
case "button":
|
|
4676
|
-
|
|
4695
|
+
kr(e, t);
|
|
4677
4696
|
return;
|
|
4678
4697
|
case "checkboxes":
|
|
4679
4698
|
case "radio_buttons":
|
|
4680
|
-
|
|
4699
|
+
Er(e.options, `${t}.options`, 10);
|
|
4681
4700
|
return;
|
|
4682
4701
|
case "overflow":
|
|
4683
|
-
|
|
4702
|
+
Er(e.options, `${t}.options`, 5);
|
|
4684
4703
|
return;
|
|
4685
4704
|
case "static_select":
|
|
4686
4705
|
case "multi_static_select":
|
|
4687
|
-
|
|
4706
|
+
Ar(e, t);
|
|
4688
4707
|
return;
|
|
4689
4708
|
case "external_select":
|
|
4690
4709
|
case "multi_external_select":
|
|
@@ -4730,13 +4749,13 @@ function Or(e, t) {
|
|
|
4730
4749
|
case "workflow_button":
|
|
4731
4750
|
X(e.text, `${t}.text`, 75), B(e.workflow, `${t}.workflow`), B(e.workflow.trigger, `${t}.workflow.trigger`), H(e.workflow.trigger.url, `${t}.workflow.trigger.url`);
|
|
4732
4751
|
return;
|
|
4733
|
-
default:
|
|
4752
|
+
default: xr("unsupported_element", `${t}.type`, `unsupported element "${e.type}"`);
|
|
4734
4753
|
}
|
|
4735
4754
|
}
|
|
4736
|
-
function
|
|
4737
|
-
|
|
4755
|
+
function Mr(e, t = "element") {
|
|
4756
|
+
jr(e, t);
|
|
4738
4757
|
}
|
|
4739
|
-
function
|
|
4758
|
+
function Nr(e, t) {
|
|
4740
4759
|
if (e !== void 0) {
|
|
4741
4760
|
B(e, t);
|
|
4742
4761
|
for (let n of [
|
|
@@ -4748,8 +4767,8 @@ function Ar(e, t) {
|
|
|
4748
4767
|
]) G(e[n], `${t}.${n}`);
|
|
4749
4768
|
}
|
|
4750
4769
|
}
|
|
4751
|
-
function
|
|
4752
|
-
switch (B(e, t), H(e.type, `${t}.type`),
|
|
4770
|
+
function Pr(e, t) {
|
|
4771
|
+
switch (B(e, t), H(e.type, `${t}.type`), Nr(e.style, `${t}.style`), e.type) {
|
|
4753
4772
|
case "text":
|
|
4754
4773
|
H(e.text, `${t}.text`, { allowEmpty: !0 });
|
|
4755
4774
|
return;
|
|
@@ -4803,12 +4822,12 @@ function jr(e, t) {
|
|
|
4803
4822
|
case "workflow_mention":
|
|
4804
4823
|
z(Object.keys(e).length > 1, "missing_field", t, `${e.type} must contain its reference fields`);
|
|
4805
4824
|
return;
|
|
4806
|
-
default:
|
|
4825
|
+
default: xr("unsupported_element", `${t}.type`, `unsupported rich text element "${e.type}"`);
|
|
4807
4826
|
}
|
|
4808
4827
|
}
|
|
4809
|
-
function
|
|
4828
|
+
function Fr(e, t) {
|
|
4810
4829
|
V(e, t), e.forEach((e, n) => {
|
|
4811
|
-
|
|
4830
|
+
Pr(e, `${t}[${String(n)}]`);
|
|
4812
4831
|
});
|
|
4813
4832
|
}
|
|
4814
4833
|
function Q(e, t) {
|
|
@@ -4817,7 +4836,7 @@ function Q(e, t) {
|
|
|
4817
4836
|
switch (B(e, r), H(e.type, `${r}.type`), e.type) {
|
|
4818
4837
|
case "rich_text_section":
|
|
4819
4838
|
case "rich_text_quote":
|
|
4820
|
-
|
|
4839
|
+
Fr(e.elements, `${r}.elements`);
|
|
4821
4840
|
return;
|
|
4822
4841
|
case "rich_text_list":
|
|
4823
4842
|
q(e.style, ["bullet", "ordered"], `${r}.style`), e.indent !== void 0 && W(e.indent, `${r}.indent`, {
|
|
@@ -4829,25 +4848,25 @@ function Q(e, t) {
|
|
|
4829
4848
|
min: 0
|
|
4830
4849
|
}), V(e.elements, `${r}.elements`), e.elements.forEach((e, t) => {
|
|
4831
4850
|
let n = `${r}.elements[${String(t)}]`;
|
|
4832
|
-
B(e, n), K(e, "rich_text_section", n),
|
|
4851
|
+
B(e, n), K(e, "rich_text_section", n), Fr(e.elements, `${n}.elements`);
|
|
4833
4852
|
});
|
|
4834
4853
|
return;
|
|
4835
4854
|
case "rich_text_preformatted":
|
|
4836
|
-
|
|
4855
|
+
Fr(e.elements, `${r}.elements`), U(e.language, `${r}.language`);
|
|
4837
4856
|
return;
|
|
4838
|
-
default:
|
|
4857
|
+
default: xr("unsupported_element", `${r}.type`, `unsupported rich text container "${e.type}"`);
|
|
4839
4858
|
}
|
|
4840
4859
|
});
|
|
4841
4860
|
}
|
|
4842
|
-
function
|
|
4861
|
+
function Ir(e, t = "block") {
|
|
4843
4862
|
Q(e, t);
|
|
4844
4863
|
}
|
|
4845
|
-
function
|
|
4864
|
+
function Lr(e, t) {
|
|
4846
4865
|
B(e, t), K(e, "section", t), J(e, t);
|
|
4847
4866
|
let n = e.text !== void 0, r = e.fields !== void 0;
|
|
4848
|
-
z(n || r, "missing_field", t, "requires text or fields"), n && Y(e.text, `${t}.text`,
|
|
4849
|
-
Y(e, `${t}.fields[${String(n)}]`,
|
|
4850
|
-
})), e.accessory !== void 0 && (B(e.accessory, `${t}.accessory`), e.accessory.type === "image" ? Z(e.accessory, `${t}.accessory`) : (
|
|
4867
|
+
z(n || r, "missing_field", t, "requires text or fields"), n && Y(e.text, `${t}.text`, bn), r && (V(e.fields, `${t}.fields`), z(e.fields.length > 0 && e.fields.length <= 10, "limit_exceeded", `${t}.fields`, "must contain 1–10 text objects"), e.fields.forEach((e, n) => {
|
|
4868
|
+
Y(e, `${t}.fields[${String(n)}]`, xn);
|
|
4869
|
+
})), e.accessory !== void 0 && (B(e.accessory, `${t}.accessory`), e.accessory.type === "image" ? Z(e.accessory, `${t}.accessory`) : (jr(e.accessory, `${t}.accessory`), z(![
|
|
4851
4870
|
"datetimepicker",
|
|
4852
4871
|
"file_input",
|
|
4853
4872
|
"plain_text_input",
|
|
@@ -4857,26 +4876,26 @@ function Pr(e, t) {
|
|
|
4857
4876
|
"rich_text_input"
|
|
4858
4877
|
].includes(String(e.accessory.type)), "invalid_value", `${t}.accessory.type`, "element is not legal as a section accessory"))), G(e.expand, `${t}.expand`);
|
|
4859
4878
|
}
|
|
4860
|
-
function
|
|
4879
|
+
function Rr(e, t) {
|
|
4861
4880
|
B(e, t), K(e, "header", t), J(e, t), X(e.text, `${t}.text`, 150), e.level !== void 0 && W(e.level, `${t}.level`, {
|
|
4862
4881
|
integer: !0,
|
|
4863
4882
|
min: 1,
|
|
4864
4883
|
max: 4
|
|
4865
4884
|
});
|
|
4866
4885
|
}
|
|
4867
|
-
function
|
|
4868
|
-
Z(e, t), B(e, t), J(e, t), e.title !== void 0 && X(e.title, `${t}.title`,
|
|
4886
|
+
function zr(e, t) {
|
|
4887
|
+
Z(e, t), B(e, t), J(e, t), e.title !== void 0 && X(e.title, `${t}.title`, wn);
|
|
4869
4888
|
}
|
|
4870
|
-
function
|
|
4889
|
+
function Br(e, t) {
|
|
4871
4890
|
B(e, t), K(e, "context", t), J(e, t), V(e.elements, `${t}.elements`), z(e.elements.length > 0 && e.elements.length <= 10, "limit_exceeded", `${t}.elements`, "must contain 1–10 elements"), e.elements.forEach((e, n) => {
|
|
4872
4891
|
let r = `${t}.elements[${String(n)}]`;
|
|
4873
4892
|
B(e, r), e.type === "image" ? Z(e, r) : Y(e, r);
|
|
4874
4893
|
});
|
|
4875
4894
|
}
|
|
4876
|
-
function
|
|
4895
|
+
function Vr(e, t) {
|
|
4877
4896
|
B(e, t), K(e, "actions", t), J(e, t), V(e.elements, `${t}.elements`), z(e.elements.length > 0 && e.elements.length <= 25, "limit_exceeded", `${t}.elements`, "must contain 1–25 elements"), e.elements.forEach((e, n) => {
|
|
4878
4897
|
let r = `${t}.elements[${String(n)}]`;
|
|
4879
|
-
|
|
4898
|
+
jr(e, r), B(e, r), z([
|
|
4880
4899
|
"button",
|
|
4881
4900
|
"checkboxes",
|
|
4882
4901
|
"datepicker",
|
|
@@ -4899,16 +4918,16 @@ function Rr(e, t) {
|
|
|
4899
4918
|
].includes(String(e.type)), "invalid_value", `${r}.type`, "element is not legal inside an actions block");
|
|
4900
4919
|
});
|
|
4901
4920
|
}
|
|
4902
|
-
function
|
|
4903
|
-
B(e,
|
|
4921
|
+
function Hr(e, t, n) {
|
|
4922
|
+
B(e, n), K(e, "input", n), J(e, n), z(t !== "message", "surface_mismatch", n, "input blocks are only legal on modal and home surfaces"), X(e.label, `${n}.label`, 2e3), e.hint !== void 0 && X(e.hint, `${n}.hint`, 2e3), G(e.optional, `${n}.optional`), G(e.dispatch_action, `${n}.dispatch_action`), jr(e.element, `${n}.element`), B(e.element, `${n}.element`), z(![
|
|
4904
4923
|
"button",
|
|
4905
4924
|
"overflow",
|
|
4906
4925
|
"workflow_button",
|
|
4907
4926
|
"icon_button",
|
|
4908
4927
|
"feedback_buttons"
|
|
4909
|
-
].includes(String(e.element.type)), "invalid_value", `${
|
|
4928
|
+
].includes(String(e.element.type)), "invalid_value", `${n}.element.type`, "element is not legal inside an input block"), z(!(e.dispatch_action === !0 && e.element.type === "file_input"), "invalid_value", `${n}.dispatch_action`, "dispatch_action is incompatible with file_input");
|
|
4910
4929
|
}
|
|
4911
|
-
function
|
|
4930
|
+
function Ur(e) {
|
|
4912
4931
|
if (!w(e)) return 0;
|
|
4913
4932
|
if (e.type === "raw_text") return typeof e.text == "string" ? e.text.length : 0;
|
|
4914
4933
|
if (e.type === "raw_number") return typeof e.text == "string" ? e.text.length : typeof e.value == "number" ? String(e.value).length : 0;
|
|
@@ -4919,7 +4938,7 @@ function Br(e) {
|
|
|
4919
4938
|
}
|
|
4920
4939
|
return 0;
|
|
4921
4940
|
}
|
|
4922
|
-
function
|
|
4941
|
+
function Wr(e, t, n) {
|
|
4923
4942
|
switch (B(e, t), H(e.type, `${t}.type`), e.type) {
|
|
4924
4943
|
case "raw_text":
|
|
4925
4944
|
H(e.text, `${t}.text`);
|
|
@@ -4930,21 +4949,21 @@ function Vr(e, t, n) {
|
|
|
4930
4949
|
case "rich_text":
|
|
4931
4950
|
z(n, "invalid_value", t, "rich_text is not legal in this row"), Q(e, t);
|
|
4932
4951
|
return;
|
|
4933
|
-
default:
|
|
4952
|
+
default: xr("invalid_value", `${t}.type`, `unsupported table cell "${e.type}"`);
|
|
4934
4953
|
}
|
|
4935
4954
|
}
|
|
4936
|
-
function
|
|
4955
|
+
function Gr(e, t, n, r, i) {
|
|
4937
4956
|
V(e, t), z(e.length > 0, "missing_field", t, "must contain at least one row"), z(e.length <= n, "limit_exceeded", t, `must contain at most ${String(n)} rows`);
|
|
4938
4957
|
let a, o = 0;
|
|
4939
4958
|
return e.forEach((e, n) => {
|
|
4940
4959
|
let r = `${t}[${String(n)}]`;
|
|
4941
4960
|
V(e, r), z(e.length > 0 && e.length <= 20, "limit_exceeded", r, "must contain 1–20 cells"), a === void 0 ? a = e.length : z(e.length === a, "invalid_value", r, "all table rows must contain the same number of cells"), e.forEach((e, t) => {
|
|
4942
|
-
|
|
4961
|
+
Wr(e, `${r}[${String(t)}]`, i || n !== 0), o += Ur(e);
|
|
4943
4962
|
});
|
|
4944
4963
|
}), z(o <= r, "limit_exceeded", t, `cell content must contain at most ${String(r)} characters`), a ?? 0;
|
|
4945
4964
|
}
|
|
4946
|
-
function
|
|
4947
|
-
B(e, t), K(e, "table", t), J(e, t),
|
|
4965
|
+
function Kr(e, t) {
|
|
4966
|
+
B(e, t), K(e, "table", t), J(e, t), Gr(e.rows, `${t}.rows`, 100, On, !0), e.column_settings !== void 0 && (V(e.column_settings, `${t}.column_settings`), z(e.column_settings.length <= 20, "limit_exceeded", `${t}.column_settings`, "must contain at most 20 entries"), e.column_settings.forEach((e, n) => {
|
|
4948
4967
|
if (e === null) return;
|
|
4949
4968
|
let r = `${t}.column_settings[${String(n)}]`;
|
|
4950
4969
|
B(e, r), e.align !== void 0 && q(e.align, [
|
|
@@ -4954,9 +4973,9 @@ function Ur(e, t) {
|
|
|
4954
4973
|
], `${r}.align`), G(e.is_wrapped, `${r}.is_wrapped`);
|
|
4955
4974
|
}));
|
|
4956
4975
|
}
|
|
4957
|
-
function
|
|
4976
|
+
function qr(e, t) {
|
|
4958
4977
|
B(e, t), K(e, "data_table", t), J(e, t), H(e.caption, `${t}.caption`);
|
|
4959
|
-
let n =
|
|
4978
|
+
let n = Gr(e.rows, `${t}.rows`, 201, kn, !1);
|
|
4960
4979
|
V(e.rows, `${t}.rows`), z(e.rows.length >= 2, "invalid_value", `${t}.rows`, "requires a header row and at least one data row"), e.page_size !== void 0 && W(e.page_size, `${t}.page_size`, {
|
|
4961
4980
|
integer: !0,
|
|
4962
4981
|
min: 1,
|
|
@@ -4967,7 +4986,7 @@ function Wr(e, t) {
|
|
|
4967
4986
|
max: n - 1
|
|
4968
4987
|
});
|
|
4969
4988
|
}
|
|
4970
|
-
function
|
|
4989
|
+
function Jr(e, t) {
|
|
4971
4990
|
if (B(e, t), K(e, "data_visualization", t), J(e, t), H(e.title, `${t}.title`, { max: 50 }), B(e.chart, `${t}.chart`), H(e.chart.type, `${t}.chart.type`), e.chart.type === "pie") {
|
|
4972
4991
|
V(e.chart.segments, `${t}.chart.segments`), z(e.chart.segments.length > 0 && e.chart.segments.length <= 12, "limit_exceeded", `${t}.chart.segments`, "must contain 1–12 segments"), e.chart.segments.forEach((e, n) => {
|
|
4973
4992
|
let r = `${t}.chart.segments[${String(n)}]`;
|
|
@@ -4996,20 +5015,20 @@ function Gr(e, t) {
|
|
|
4996
5015
|
});
|
|
4997
5016
|
});
|
|
4998
5017
|
}
|
|
4999
|
-
function
|
|
5018
|
+
function Yr(e, t) {
|
|
5000
5019
|
B(e, t), K(e, "card", t), J(e, t), z(e.hero_image !== void 0 || e.title !== void 0 || e.actions !== void 0 || e.body !== void 0, "missing_field", t, "requires at least one of hero_image, title, actions, or body"), e.hero_image !== void 0 && Z(e.hero_image, `${t}.hero_image`), e.icon !== void 0 && Z(e.icon, `${t}.icon`), z(!(e.icon !== void 0 && e.slack_icon !== void 0), "invalid_value", t, "icon and slack_icon are mutually exclusive"), e.slack_icon !== void 0 && (B(e.slack_icon, `${t}.slack_icon`), K(e.slack_icon, "icon", `${t}.slack_icon`), H(e.slack_icon.name, `${t}.slack_icon.name`));
|
|
5001
5020
|
for (let n of ["title", "subtitle"]) e[n] !== void 0 && Y(e[n], `${t}.${n}`, 150);
|
|
5002
5021
|
for (let n of ["body", "subtext"]) e[n] !== void 0 && Y(e[n], `${t}.${n}`, 200);
|
|
5003
5022
|
e.actions !== void 0 && (V(e.actions, `${t}.actions`), z(e.actions.length > 0 && e.actions.length <= 3, "limit_exceeded", `${t}.actions`, "must contain 1–3 buttons"), e.actions.forEach((e, n) => {
|
|
5004
|
-
|
|
5023
|
+
kr(e, `${t}.actions[${String(n)}]`);
|
|
5005
5024
|
}));
|
|
5006
5025
|
}
|
|
5007
|
-
function
|
|
5026
|
+
function Xr(e, t) {
|
|
5008
5027
|
B(e, t), K(e, "carousel", t), J(e, t), V(e.elements, `${t}.elements`), z(e.elements.length > 0 && e.elements.length <= 10, "limit_exceeded", `${t}.elements`, "must contain 1–10 cards"), e.elements.forEach((e, n) => {
|
|
5009
|
-
|
|
5028
|
+
Yr(e, `${t}.elements[${String(n)}]`);
|
|
5010
5029
|
});
|
|
5011
5030
|
}
|
|
5012
|
-
function
|
|
5031
|
+
function Zr(e, t, n) {
|
|
5013
5032
|
B(e, n), K(e, "alert", n), J(e, n), z(t === "modal", "surface_mismatch", n, "alert blocks are only legal on modal surfaces"), Y(e.text, `${n}.text`, 200), e.level !== void 0 && q(e.level, [
|
|
5014
5033
|
"default",
|
|
5015
5034
|
"info",
|
|
@@ -5018,21 +5037,21 @@ function Jr(e, t, n) {
|
|
|
5018
5037
|
"success"
|
|
5019
5038
|
], `${n}.level`);
|
|
5020
5039
|
}
|
|
5021
|
-
function
|
|
5040
|
+
function Qr(e, t) {
|
|
5022
5041
|
B(e, t), K(e, "context_actions", t), J(e, t), V(e.elements, `${t}.elements`), z(e.elements.length > 0 && e.elements.length <= 5, "limit_exceeded", `${t}.elements`, "must contain 1–5 elements"), e.elements.forEach((e, n) => {
|
|
5023
5042
|
let r = `${t}.elements[${String(n)}]`;
|
|
5024
|
-
if (B(e, r),
|
|
5025
|
-
q(e.icon, ["trash"], `${r}.icon`), X(e.text, `${r}.text`, 75), U(e.value, `${r}.value`, { max:
|
|
5043
|
+
if (B(e, r), Dr(e, r), e.type === "icon_button") {
|
|
5044
|
+
q(e.icon, ["trash"], `${r}.icon`), X(e.text, `${r}.text`, 75), U(e.value, `${r}.value`, { max: Dn });
|
|
5026
5045
|
return;
|
|
5027
5046
|
}
|
|
5028
5047
|
z(e.type === "feedback_buttons", "unsupported_element", `${r}.type`, "context_actions only accepts icon_button or feedback_buttons");
|
|
5029
5048
|
for (let t of ["positive_button", "negative_button"]) {
|
|
5030
5049
|
let n = `${r}.${t}`;
|
|
5031
|
-
B(e[t], n), X(e[t].text, `${n}.text`, 75), H(e[t].value, `${n}.value`, { max:
|
|
5050
|
+
B(e[t], n), X(e[t].text, `${n}.text`, 75), H(e[t].value, `${n}.value`, { max: Dn });
|
|
5032
5051
|
}
|
|
5033
5052
|
});
|
|
5034
5053
|
}
|
|
5035
|
-
function
|
|
5054
|
+
function $r(e, t) {
|
|
5036
5055
|
B(e, t), K(e, "task_card", t), J(e, t), H(e.task_id, `${t}.task_id`), H(e.title, `${t}.title`), q(e.status, [
|
|
5037
5056
|
"pending",
|
|
5038
5057
|
"in_progress",
|
|
@@ -5043,12 +5062,12 @@ function Xr(e, t) {
|
|
|
5043
5062
|
B(e, r), K(e, "url", r), H(e.url, `${r}.url`), H(e.text, `${r}.text`);
|
|
5044
5063
|
}));
|
|
5045
5064
|
}
|
|
5046
|
-
function
|
|
5065
|
+
function ei(e, t) {
|
|
5047
5066
|
B(e, t), K(e, "plan", t), J(e, t), H(e.title, `${t}.title`), e.tasks !== void 0 && (V(e.tasks, `${t}.tasks`), e.tasks.forEach((e, n) => {
|
|
5048
|
-
|
|
5067
|
+
$r(e, `${t}.tasks[${String(n)}]`);
|
|
5049
5068
|
}));
|
|
5050
5069
|
}
|
|
5051
|
-
function
|
|
5070
|
+
function ti(e, t) {
|
|
5052
5071
|
B(e, t), K(e, "container", t), J(e, t), z(e.title !== void 0 || e.rich_text_title !== void 0, "missing_field", t, "requires title or rich_text_title"), e.title !== void 0 && X(e.title, `${t}.title`, 150), e.rich_text_title !== void 0 && Q(e.rich_text_title, `${t}.rich_text_title`), e.subtitle !== void 0 && X(e.subtitle, `${t}.subtitle`, 150), e.icon !== void 0 && Z(e.icon, `${t}.icon`), e.width !== void 0 && q(e.width, [
|
|
5053
5072
|
"narrow",
|
|
5054
5073
|
"standard",
|
|
@@ -5070,122 +5089,122 @@ function Qr(e, t) {
|
|
|
5070
5089
|
];
|
|
5071
5090
|
e.child_blocks.forEach((e, r) => {
|
|
5072
5091
|
let i = `${t}.child_blocks[${String(r)}]`;
|
|
5073
|
-
B(e, i), H(e.type, `${i}.type`), z(n.includes(e.type), "invalid_value", `${i}.type`, `"${e.type}" is not legal inside a container`),
|
|
5092
|
+
B(e, i), H(e.type, `${i}.type`), z(n.includes(e.type), "invalid_value", `${i}.type`, `"${e.type}" is not legal inside a container`), ii(e, "message", i);
|
|
5074
5093
|
});
|
|
5075
5094
|
}
|
|
5076
|
-
function
|
|
5095
|
+
function ni(e, t) {
|
|
5077
5096
|
B(e, t), K(e, "file", t), J(e, t), z(e.source === "remote", "invalid_value", `${t}.source`, "expected \"remote\""), H(e.external_id, `${t}.external_id`);
|
|
5078
5097
|
}
|
|
5079
|
-
function
|
|
5080
|
-
B(e, t), K(e, "video", t), J(e, t), H(e.video_url, `${t}.video_url`), H(e.thumbnail_url, `${t}.thumbnail_url`), H(e.alt_text, `${t}.alt_text`, { max:
|
|
5098
|
+
function ri(e, t) {
|
|
5099
|
+
B(e, t), K(e, "video", t), J(e, t), H(e.video_url, `${t}.video_url`), H(e.thumbnail_url, `${t}.thumbnail_url`), H(e.alt_text, `${t}.alt_text`, { max: Cn }), X(e.title, `${t}.title`, 199), e.description !== void 0 && X(e.description, `${t}.description`, 199), U(e.author_name, `${t}.author_name`, { max: 49 });
|
|
5081
5100
|
}
|
|
5082
5101
|
function $(e, t, n) {
|
|
5083
5102
|
z(e === "message", "surface_mismatch", t, `${n} blocks are only documented for message surfaces`);
|
|
5084
5103
|
}
|
|
5085
|
-
function
|
|
5104
|
+
function ii(e, t = "message", n = "block") {
|
|
5086
5105
|
switch (B(e, n), J(e, n), e.type) {
|
|
5087
5106
|
case "actions":
|
|
5088
|
-
|
|
5107
|
+
Vr(e, n);
|
|
5089
5108
|
return;
|
|
5090
5109
|
case "alert":
|
|
5091
|
-
|
|
5110
|
+
Zr(e, t, n);
|
|
5092
5111
|
return;
|
|
5093
5112
|
case "card":
|
|
5094
|
-
$(t, n, e.type),
|
|
5113
|
+
$(t, n, e.type), Yr(e, n);
|
|
5095
5114
|
return;
|
|
5096
5115
|
case "carousel":
|
|
5097
|
-
$(t, n, e.type),
|
|
5116
|
+
$(t, n, e.type), Xr(e, n);
|
|
5098
5117
|
return;
|
|
5099
5118
|
case "container":
|
|
5100
|
-
$(t, n, e.type),
|
|
5119
|
+
$(t, n, e.type), ti(e, n);
|
|
5101
5120
|
return;
|
|
5102
5121
|
case "context":
|
|
5103
|
-
|
|
5122
|
+
Br(e, n);
|
|
5104
5123
|
return;
|
|
5105
5124
|
case "context_actions":
|
|
5106
|
-
$(t, n, e.type),
|
|
5125
|
+
$(t, n, e.type), Qr(e, n);
|
|
5107
5126
|
return;
|
|
5108
5127
|
case "data_table":
|
|
5109
|
-
$(t, n, e.type),
|
|
5128
|
+
$(t, n, e.type), qr(e, n);
|
|
5110
5129
|
return;
|
|
5111
5130
|
case "data_visualization":
|
|
5112
|
-
$(t, n, e.type),
|
|
5131
|
+
$(t, n, e.type), Jr(e, n);
|
|
5113
5132
|
return;
|
|
5114
5133
|
case "divider":
|
|
5115
5134
|
K(e, "divider", n);
|
|
5116
5135
|
return;
|
|
5117
5136
|
case "file":
|
|
5118
|
-
$(t, n, e.type),
|
|
5137
|
+
$(t, n, e.type), ni(e, n);
|
|
5119
5138
|
return;
|
|
5120
5139
|
case "header":
|
|
5121
|
-
|
|
5140
|
+
Rr(e, n);
|
|
5122
5141
|
return;
|
|
5123
5142
|
case "image":
|
|
5124
|
-
|
|
5143
|
+
zr(e, n);
|
|
5125
5144
|
return;
|
|
5126
5145
|
case "input":
|
|
5127
|
-
|
|
5146
|
+
Hr(e, t, n);
|
|
5128
5147
|
return;
|
|
5129
5148
|
case "markdown":
|
|
5130
|
-
$(t, n, e.type), H(e.text, `${n}.text`, { max:
|
|
5149
|
+
$(t, n, e.type), H(e.text, `${n}.text`, { max: Tn });
|
|
5131
5150
|
return;
|
|
5132
5151
|
case "plan":
|
|
5133
|
-
$(t, n, e.type),
|
|
5152
|
+
$(t, n, e.type), ei(e, n);
|
|
5134
5153
|
return;
|
|
5135
5154
|
case "rich_text":
|
|
5136
5155
|
Q(e, n);
|
|
5137
5156
|
return;
|
|
5138
5157
|
case "section":
|
|
5139
|
-
|
|
5158
|
+
Lr(e, n);
|
|
5140
5159
|
return;
|
|
5141
5160
|
case "table":
|
|
5142
|
-
$(t, n, e.type),
|
|
5161
|
+
$(t, n, e.type), Kr(e, n);
|
|
5143
5162
|
return;
|
|
5144
5163
|
case "task_card":
|
|
5145
|
-
$(t, n, e.type),
|
|
5164
|
+
$(t, n, e.type), $r(e, n);
|
|
5146
5165
|
return;
|
|
5147
5166
|
case "video":
|
|
5148
|
-
|
|
5167
|
+
ri(e, n);
|
|
5149
5168
|
return;
|
|
5150
|
-
default:
|
|
5169
|
+
default: xr("unsupported_block", `${n}.type`, `unsupported block "${String(e.type)}"`);
|
|
5151
5170
|
}
|
|
5152
5171
|
}
|
|
5153
|
-
function
|
|
5154
|
-
|
|
5172
|
+
function ai(e, t, n = "message", r = "block") {
|
|
5173
|
+
ii(e, n, r), z(e.type === t, "invalid_value", `${r}.type`, `expected "${t}"`);
|
|
5155
5174
|
}
|
|
5156
|
-
function
|
|
5175
|
+
function oi(e, t) {
|
|
5157
5176
|
return Array.isArray(e) ? e : (B(e, t), V(e.blocks, `${t}.blocks`), e.blocks);
|
|
5158
5177
|
}
|
|
5159
|
-
function
|
|
5160
|
-
let r = Array.isArray(e) ? n : `${n}.blocks`, i =
|
|
5178
|
+
function si(e, t = "message", n = "data") {
|
|
5179
|
+
let r = Array.isArray(e) ? n : `${n}.blocks`, i = oi(e, n), a = t === "message" ? 50 : 100;
|
|
5161
5180
|
z(i.length <= a, "limit_exceeded", r, `${t} surfaces accept at most ${String(a)} blocks`);
|
|
5162
5181
|
let o = 0, s = 0, c = 0, l = /* @__PURE__ */ new Set();
|
|
5163
5182
|
i.forEach((e, n) => {
|
|
5164
5183
|
let i = `${r}[${String(n)}]`;
|
|
5165
|
-
if (
|
|
5166
|
-
else if (e.type === "table") for (let t of e.rows) for (let e of t) s +=
|
|
5167
|
-
else if (e.type === "data_table") for (let t of e.rows) for (let e of t) c +=
|
|
5168
|
-
}), z(o <=
|
|
5184
|
+
if (ii(e, t, i), e.block_id !== void 0 && (z(!l.has(e.block_id), "duplicate_id", `${i}.block_id`, `"${e.block_id}" is already used in this payload`), l.add(e.block_id)), e.type === "markdown") o += e.text.length;
|
|
5185
|
+
else if (e.type === "table") for (let t of e.rows) for (let e of t) s += Ur(e);
|
|
5186
|
+
else if (e.type === "data_table") for (let t of e.rows) for (let e of t) c += Ur(e);
|
|
5187
|
+
}), z(o <= Tn, "limit_exceeded", r, `markdown blocks exceed the cumulative ${String(Tn)} character limit`), z(s <= On, "limit_exceeded", r, `table cells exceed the cumulative ${String(On)} character limit`), z(c <= kn, "limit_exceeded", r, `data_table cells exceed the cumulative ${String(kn)} character limit`);
|
|
5169
5188
|
}
|
|
5170
|
-
function
|
|
5189
|
+
function ci(e, t = "message") {
|
|
5171
5190
|
let n = e;
|
|
5172
5191
|
if (typeof e == "string") try {
|
|
5173
5192
|
n = JSON.parse(e);
|
|
5174
5193
|
} catch {
|
|
5175
|
-
throw new
|
|
5194
|
+
throw new _r("expected valid JSON", {
|
|
5176
5195
|
code: "invalid_json",
|
|
5177
5196
|
path: "data"
|
|
5178
5197
|
});
|
|
5179
5198
|
}
|
|
5180
|
-
return
|
|
5199
|
+
return si(n, t), n;
|
|
5181
5200
|
}
|
|
5182
|
-
function
|
|
5183
|
-
return
|
|
5201
|
+
function li(e) {
|
|
5202
|
+
return ui(e) ? e.blocks : e;
|
|
5184
5203
|
}
|
|
5185
|
-
function
|
|
5204
|
+
function ui(e) {
|
|
5186
5205
|
return !Array.isArray(e);
|
|
5187
5206
|
}
|
|
5188
5207
|
//#endregion
|
|
5189
|
-
export {
|
|
5208
|
+
export { rr as ActionsBlock, hn as AlertBlock, ur as Block, br as BlockKit, _r as BlockKitInvariantError, b as BlockKitProvider, lt as ButtonElement, fn as CardBlock, mn as CarouselBlock, pt as ChoiceGroup, hr as ContainerBlock, or as ContextActionsBlock, Qt as ContextBlock, un as DataTableBlock, $n as DataVisualizationBlock, Yt as DividerBlock, tn as FileBlock, Jt as HeaderBlock, Xt as ImageBlock, F as ImageElement, ir as InputBlock, Et as InputElement, Dt as InteractiveElement, Gt as Markdown, en as MarkdownBlock, I as Mrkdwn, ut as OverflowElement, vn as PlanBlock, N as RichText, $t as RichTextBlock, qt as SectionBlock, xt as SelectElement, sn as TableBlock, an as TableCell, gn as TaskCardBlock, L as Text, nn as VideoBlock, si as assertBlockKitData, ai as assertBlockType, wr as assertImageElementData, Mr as assertInteractiveElementData, ii as assertRenderableBlock, Ir as assertRichTextBlockData, Sr as assertTextObjectData, li as blocksOf, we as darkTheme, vr as isBlockKitInvariantError, Ce as lightTheme, ci as parseBlockKitData, Vt as tokenizeMarkdown, Ft as tokenizeMrkdwn, Se as tokens, x as useBlockKitContext };
|
|
5190
5209
|
|
|
5191
5210
|
//# sourceMappingURL=index.js.map
|