@nkootstra/block-kit 0.3.0 → 0.3.1

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
@@ -9872,6 +9872,24 @@ function DotIcon({ status }) {
9872
9872
  children: /* @__PURE__ */ jsx("path", { d: "M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0" })
9873
9873
  });
9874
9874
  }
9875
+ /** How a status reads aloud. The icons are hidden from assistive technology, so this stands in. */
9876
+ const STATUS_LABELS = {
9877
+ complete: "complete",
9878
+ in_progress: "in progress",
9879
+ pending: "pending",
9880
+ error: "failed"
9881
+ };
9882
+ /**
9883
+ * A status as text that only screen readers get, set after a title (", in progress"), so a toggle
9884
+ * or task header is announced with the state its icon shows. An unknown status says nothing.
9885
+ */
9886
+ function StatusText({ status }) {
9887
+ const label = STATUS_LABELS[status];
9888
+ return label ? /* @__PURE__ */ jsx("span", {
9889
+ className: "sbk-visually-hidden",
9890
+ children: `, ${label}`
9891
+ }) : null;
9892
+ }
9875
9893
  /** The glyph on a toggle bar (the plan's or a task_card's): check, warning or spinner. */
9876
9894
  function StatusIcon({ status }) {
9877
9895
  if (status === "complete") return /* @__PURE__ */ jsx(CheckCircleIcon, {});
@@ -9898,7 +9916,8 @@ function aggregateStatus(statuses) {
9898
9916
  /**
9899
9917
  * One step of the plan. As in Slack, a thin line joins each step's icon to the next, its details
9900
9918
  * start open, and the title is a button that hides and shows them instantly; a task with nothing
9901
- * to reveal gets a disabled header and no caret.
9919
+ * to reveal gets the same header as plain text, with no caret. The status, shown as an icon, is
9920
+ * also in the header as text for screen readers.
9902
9921
  */
9903
9922
  function TaskRow({ task }) {
9904
9923
  const [open, setOpen] = useState(true);
@@ -9919,21 +9938,28 @@ function TaskRow({ task }) {
9919
9938
  ]
9920
9939
  }), /* @__PURE__ */ jsxs("div", {
9921
9940
  className: "sbk-plan__task-content",
9922
- children: [/* @__PURE__ */ jsxs("button", {
9941
+ children: [expandable ? /* @__PURE__ */ jsxs("button", {
9923
9942
  type: "button",
9924
9943
  className: "sbk-plan__task-header",
9925
9944
  "aria-expanded": open,
9926
- "aria-disabled": expandable ? void 0 : true,
9927
- onClick: () => {
9928
- if (expandable) setOpen((value) => !value);
9929
- },
9945
+ onClick: () => setOpen((value) => !value),
9946
+ children: [
9947
+ /* @__PURE__ */ jsx("span", {
9948
+ className: "sbk-plan__task-title",
9949
+ children: task.title
9950
+ }),
9951
+ /* @__PURE__ */ jsx(StatusText, { status: task.status }),
9952
+ /* @__PURE__ */ jsx("span", {
9953
+ className: "sbk-plan__task-caret",
9954
+ children: /* @__PURE__ */ jsx(CaretIcon, { direction: open ? "down" : "right" })
9955
+ })
9956
+ ]
9957
+ }) : /* @__PURE__ */ jsxs("div", {
9958
+ className: "sbk-plan__task-header",
9930
9959
  children: [/* @__PURE__ */ jsx("span", {
9931
9960
  className: "sbk-plan__task-title",
9932
9961
  children: task.title
9933
- }), expandable ? /* @__PURE__ */ jsx("span", {
9934
- className: "sbk-plan__task-caret",
9935
- children: /* @__PURE__ */ jsx(CaretIcon, { direction: open ? "down" : "right" })
9936
- }) : null]
9962
+ }), /* @__PURE__ */ jsx(StatusText, { status: task.status })]
9937
9963
  }), open && expandable ? /* @__PURE__ */ jsxs("div", {
9938
9964
  className: "sbk-plan__task-body",
9939
9965
  children: [
@@ -9982,6 +10008,7 @@ function Plan({ block }) {
9982
10008
  className: "sbk-plan__pill-title",
9983
10009
  children: block.title
9984
10010
  }),
10011
+ /* @__PURE__ */ jsx(StatusText, { status }),
9985
10012
  /* @__PURE__ */ jsx("span", {
9986
10013
  className: "sbk-plan__pill-chevron",
9987
10014
  children: /* @__PURE__ */ jsx(CaretIcon, { direction: expanded ? "down" : "right" })
@@ -10395,33 +10422,35 @@ function TaskCard({ block }) {
10395
10422
  const [expanded, setExpanded] = useState(false);
10396
10423
  const sources = Array.isArray(block.sources) ? block.sources : [];
10397
10424
  const expandable = Boolean(block.details || block.output || sources.length > 0);
10425
+ const pillContent = /* @__PURE__ */ jsxs("span", {
10426
+ className: "sbk-task-card__pill-content",
10427
+ children: [
10428
+ /* @__PURE__ */ jsx("span", {
10429
+ className: "sbk-task-card__pill-icon",
10430
+ children: /* @__PURE__ */ jsx(StatusIcon, { status: block.status })
10431
+ }),
10432
+ /* @__PURE__ */ jsx("span", {
10433
+ className: "sbk-task-card__pill-title",
10434
+ children: block.title
10435
+ }),
10436
+ /* @__PURE__ */ jsx(StatusText, { status: block.status }),
10437
+ expandable ? /* @__PURE__ */ jsx("span", {
10438
+ className: "sbk-task-card__pill-chevron",
10439
+ children: /* @__PURE__ */ jsx(CaretIcon, { direction: expanded ? "down" : "right" })
10440
+ }) : null
10441
+ ]
10442
+ });
10398
10443
  return /* @__PURE__ */ jsxs("div", {
10399
10444
  className: "sbk-task-card",
10400
- children: [/* @__PURE__ */ jsx("button", {
10445
+ children: [expandable ? /* @__PURE__ */ jsx("button", {
10401
10446
  type: "button",
10402
10447
  className: "sbk-task-card__pill",
10403
10448
  "aria-expanded": expanded,
10404
- "aria-disabled": expandable ? void 0 : true,
10405
- onClick: () => {
10406
- if (expandable) setExpanded((value) => !value);
10407
- },
10408
- children: /* @__PURE__ */ jsxs("span", {
10409
- className: "sbk-task-card__pill-content",
10410
- children: [
10411
- /* @__PURE__ */ jsx("span", {
10412
- className: "sbk-task-card__pill-icon",
10413
- children: /* @__PURE__ */ jsx(StatusIcon, { status: block.status })
10414
- }),
10415
- /* @__PURE__ */ jsx("span", {
10416
- className: "sbk-task-card__pill-title",
10417
- children: block.title
10418
- }),
10419
- expandable ? /* @__PURE__ */ jsx("span", {
10420
- className: "sbk-task-card__pill-chevron",
10421
- children: /* @__PURE__ */ jsx(CaretIcon, { direction: expanded ? "down" : "right" })
10422
- }) : null
10423
- ]
10424
- })
10449
+ onClick: () => setExpanded((value) => !value),
10450
+ children: pillContent
10451
+ }) : /* @__PURE__ */ jsx("div", {
10452
+ className: "sbk-task-card__pill",
10453
+ children: pillContent
10425
10454
  }), /* @__PURE__ */ jsx(Collapse, {
10426
10455
  open: expanded,
10427
10456
  children: /* @__PURE__ */ jsxs("div", {