@glyphjs/components 0.2.0 → 0.3.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/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { accordionSchema, annotateSchema, architectureSchema, calloutSchema, cardSchema, chartSchema, codediffSchema, comparisonSchema, equationSchema, filetreeSchema, flowchartSchema, formSchema, graphSchema, infographicSchema, kanbanSchema, kpiSchema, matrixSchema, mindmapSchema, pollSchema, quizSchema, rankerSchema, ratingSchema, relationSchema, sequenceSchema, sliderSchema, stepsSchema, tableSchema, tabsSchema, timelineSchema } from '@glyphjs/schemas';
2
+ import { RichText } from '@glyphjs/runtime';
2
3
  import { jsxs, jsx } from 'react/jsx-runtime';
3
4
  import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
4
5
  import * as d32 from 'd3';
@@ -50,7 +51,7 @@ function Callout({ data }) {
50
51
  /* @__PURE__ */ jsx("span", { style: iconStyle, "aria-hidden": "true", children: CALLOUT_ICONS[type] }),
51
52
  /* @__PURE__ */ jsxs("div", { style: bodyStyle3, children: [
52
53
  title && /* @__PURE__ */ jsx("div", { style: titleStyle2, children: title }),
53
- /* @__PURE__ */ jsx("div", { children: content })
54
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(RichText, { content }) })
54
55
  ] })
55
56
  ] });
56
57
  }
@@ -528,7 +529,7 @@ function Steps({ data }) {
528
529
  /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: indicatorStyle(status), children: status === "completed" ? "\u2713" : "" }),
529
530
  /* @__PURE__ */ jsxs("div", { style: bodyStyle, children: [
530
531
  /* @__PURE__ */ jsx("div", { style: titleStyle(status), children: step.title }),
531
- /* @__PURE__ */ jsx("div", { style: contentStyle(status), children: step.content })
532
+ /* @__PURE__ */ jsx("div", { style: contentStyle(status), children: /* @__PURE__ */ jsx(RichText, { content: step.content }) })
532
533
  ] })
533
534
  ]
534
535
  },
@@ -1187,7 +1188,7 @@ function Timeline({ data }) {
1187
1188
  fontWeight: 700,
1188
1189
  marginTop: 2
1189
1190
  },
1190
- children: pe.event.title
1191
+ children: /* @__PURE__ */ jsx(RichText, { content: pe.event.title })
1191
1192
  }
1192
1193
  ),
1193
1194
  pe.event.description && /* @__PURE__ */ jsx(
@@ -1198,7 +1199,7 @@ function Timeline({ data }) {
1198
1199
  color: "var(--glyph-timeline-desc-color, #7a8599)",
1199
1200
  marginTop: 2
1200
1201
  },
1201
- children: pe.event.description
1202
+ children: /* @__PURE__ */ jsx(RichText, { content: pe.event.description })
1202
1203
  }
1203
1204
  )
1204
1205
  ] })
@@ -1216,12 +1217,16 @@ function Timeline({ data }) {
1216
1217
  clipPath: "inset(50%)",
1217
1218
  whiteSpace: "nowrap"
1218
1219
  },
1219
- children: sorted.map((e, idx) => /* @__PURE__ */ jsxs("li", { children: [
1220
- /* @__PURE__ */ jsx("time", { dateTime: isoDate(e.date), children: formatDate(e.date) }),
1221
- " \u2014 ",
1222
- /* @__PURE__ */ jsx("strong", { children: e.title }),
1223
- e.description ? `: ${e.description}` : ""
1224
- ] }, idx))
1220
+ children: sorted.map((e, idx) => {
1221
+ const titleText = typeof e.title === "string" ? e.title : "Event";
1222
+ const descText = typeof e.description === "string" ? e.description : "";
1223
+ return /* @__PURE__ */ jsxs("li", { children: [
1224
+ /* @__PURE__ */ jsx("time", { dateTime: isoDate(e.date), children: formatDate(e.date) }),
1225
+ " \u2014 ",
1226
+ /* @__PURE__ */ jsx("strong", { children: titleText }),
1227
+ descText ? `: ${descText}` : ""
1228
+ ] }, idx);
1229
+ })
1225
1230
  }
1226
1231
  )
1227
1232
  ]
@@ -1893,7 +1898,8 @@ function resolveSentiment(metric) {
1893
1898
  return "neutral";
1894
1899
  }
1895
1900
  function buildAriaLabel(metric) {
1896
- let label = `${metric.label}: ${metric.value}`;
1901
+ const labelText = typeof metric.label === "string" ? metric.label : "Metric";
1902
+ let label = `${labelText}: ${metric.value}`;
1897
1903
  if (metric.unit) label += ` ${metric.unit}`;
1898
1904
  if (metric.delta && metric.trend) {
1899
1905
  label += `, ${metric.trend} ${metric.delta}`;
@@ -1965,7 +1971,7 @@ function Kpi({ data, block, container }) {
1965
1971
  color: `var(--glyph-kpi-${sentiment}, inherit)`
1966
1972
  };
1967
1973
  return /* @__PURE__ */ jsxs("div", { role: "group", "aria-label": buildAriaLabel(metric), style: cardStyle2, children: [
1968
- /* @__PURE__ */ jsx("div", { style: labelStyle4, children: metric.label }),
1974
+ /* @__PURE__ */ jsx("div", { style: labelStyle4, children: /* @__PURE__ */ jsx(RichText, { content: metric.label }) }),
1969
1975
  /* @__PURE__ */ jsxs("div", { style: valueStyle, children: [
1970
1976
  metric.value,
1971
1977
  metric.unit && /* @__PURE__ */ jsx("span", { style: { fontSize: "0.875rem", fontWeight: 400, marginLeft: "0.25rem" }, children: metric.unit })
@@ -2079,7 +2085,7 @@ function Accordion({
2079
2085
  /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { fontSize: "0.75rem", width: "1rem", flexShrink: 0 }, children: "\u25B8" }),
2080
2086
  section.title
2081
2087
  ] }),
2082
- /* @__PURE__ */ jsx("div", { style: contentStyle2, children: section.content })
2088
+ /* @__PURE__ */ jsx("div", { style: contentStyle2, children: /* @__PURE__ */ jsx(RichText, { content: section.content }) })
2083
2089
  ]
2084
2090
  },
2085
2091
  i
@@ -2098,6 +2104,7 @@ var accordionDefinition = {
2098
2104
  var YES_VALUES = /* @__PURE__ */ new Set(["yes", "true", "full"]);
2099
2105
  var NO_VALUES = /* @__PURE__ */ new Set(["no", "false", "none"]);
2100
2106
  function classifyValue(value) {
2107
+ if (typeof value !== "string") return "text";
2101
2108
  const lower = value.toLowerCase().trim();
2102
2109
  if (YES_VALUES.has(lower)) return "yes";
2103
2110
  if (NO_VALUES.has(lower)) return "no";
@@ -2135,7 +2142,7 @@ function renderValue(value) {
2135
2142
  }
2136
2143
  );
2137
2144
  default:
2138
- return /* @__PURE__ */ jsx("span", { children: value });
2145
+ return /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(RichText, { content: value }) });
2139
2146
  }
2140
2147
  }
2141
2148
  function Comparison({
@@ -2231,7 +2238,7 @@ function Comparison({
2231
2238
  fontSize: "0.75rem",
2232
2239
  color: "var(--glyph-text-muted, #6b7a94)"
2233
2240
  },
2234
- children: option.description
2241
+ children: /* @__PURE__ */ jsx(RichText, { content: option.description })
2235
2242
  }
2236
2243
  )
2237
2244
  ]
@@ -2252,8 +2259,8 @@ function Comparison({
2252
2259
  }
2253
2260
  ),
2254
2261
  options.map((_, colIndex) => {
2255
- const value = feature.values[colIndex] ?? "";
2256
- return /* @__PURE__ */ jsx("td", { style: cellStyle2(rowIndex), children: value ? renderValue(value) : null }, colIndex);
2262
+ const value = feature.values[colIndex];
2263
+ return /* @__PURE__ */ jsx("td", { style: cellStyle2(rowIndex), children: value !== void 0 && value !== "" ? renderValue(value) : null }, colIndex);
2257
2264
  })
2258
2265
  ] }, rowIndex)) })
2259
2266
  ] }) })
@@ -4204,7 +4211,8 @@ function isCorrect(question, selected) {
4204
4211
  }
4205
4212
  function renderMultipleChoice(question, qIndex, state, updateState, baseId) {
4206
4213
  const selected = typeof state.selected === "number" ? state.selected : null;
4207
- return /* @__PURE__ */ jsx("div", { role: "radiogroup", "aria-label": question.question, children: question.options.map((option, oIndex) => {
4214
+ const ariaLabel = typeof question.question === "string" ? question.question : "Question";
4215
+ return /* @__PURE__ */ jsx("div", { role: "radiogroup", "aria-label": ariaLabel, children: question.options.map((option, oIndex) => {
4208
4216
  const isSelected = selected === oIndex;
4209
4217
  const isCorrectOption = state.submitted && oIndex === question.answer;
4210
4218
  const isIncorrectSelection = state.submitted && isSelected && oIndex !== question.answer;
@@ -4230,7 +4238,7 @@ function renderMultipleChoice(question, qIndex, state, updateState, baseId) {
4230
4238
  "aria-checked": isSelected
4231
4239
  }
4232
4240
  ),
4233
- option
4241
+ /* @__PURE__ */ jsx(RichText, { content: option })
4234
4242
  ]
4235
4243
  },
4236
4244
  oIndex
@@ -4239,7 +4247,8 @@ function renderMultipleChoice(question, qIndex, state, updateState, baseId) {
4239
4247
  }
4240
4248
  function renderTrueFalse(question, qIndex, state, updateState, baseId) {
4241
4249
  const selected = typeof state.selected === "boolean" ? state.selected : null;
4242
- return /* @__PURE__ */ jsx("div", { role: "radiogroup", "aria-label": question.question, children: [true, false].map((value) => {
4250
+ const ariaLabel = typeof question.question === "string" ? question.question : "Question";
4251
+ return /* @__PURE__ */ jsx("div", { role: "radiogroup", "aria-label": ariaLabel, children: [true, false].map((value) => {
4243
4252
  const isSelected = selected === value;
4244
4253
  const isCorrectOption = state.submitted && value === question.answer;
4245
4254
  const isIncorrectSelection = state.submitted && isSelected && value !== question.answer;
@@ -4303,7 +4312,7 @@ function renderMultiSelect(question, qIndex, state, updateState) {
4303
4312
  "aria-checked": isSelected
4304
4313
  }
4305
4314
  ),
4306
- option
4315
+ /* @__PURE__ */ jsx(RichText, { content: option })
4307
4316
  ]
4308
4317
  },
4309
4318
  oIndex
@@ -4342,7 +4351,7 @@ function Quiz({ data, block, onInteraction }) {
4342
4351
  children: [
4343
4352
  /* @__PURE__ */ jsxs("div", { style: questionTextStyle, children: [
4344
4353
  questions.length > 1 ? `${String(qIndex + 1)}. ` : "",
4345
- question.question
4354
+ /* @__PURE__ */ jsx(RichText, { content: question.question })
4346
4355
  ] }),
4347
4356
  question.type === "multiple-choice" && renderMultipleChoice(question, qIndex, state, updateState, baseId),
4348
4357
  question.type === "true-false" && renderTrueFalse(question, qIndex, state, updateState, baseId),
@@ -4366,15 +4375,24 @@ function Quiz({ data, block, onInteraction }) {
4366
4375
  let selected;
4367
4376
  switch (question.type) {
4368
4377
  case "multiple-choice":
4369
- selected = typeof state.selected === "number" ? [question.options[state.selected] ?? String(state.selected)] : [];
4378
+ if (typeof state.selected === "number") {
4379
+ const opt = question.options[state.selected];
4380
+ selected = [typeof opt === "string" ? opt : String(state.selected)];
4381
+ } else {
4382
+ selected = [];
4383
+ }
4370
4384
  break;
4371
4385
  case "true-false":
4372
4386
  selected = typeof state.selected === "boolean" ? [state.selected ? "True" : "False"] : [];
4373
4387
  break;
4374
4388
  case "multi-select":
4375
- selected = Array.isArray(state.selected) ? state.selected.map((idx) => question.options[idx] ?? String(idx)) : [];
4389
+ selected = Array.isArray(state.selected) ? state.selected.map((idx) => {
4390
+ const opt = question.options[idx];
4391
+ return typeof opt === "string" ? opt : String(idx);
4392
+ }) : [];
4376
4393
  break;
4377
4394
  }
4395
+ const questionText = typeof question.question === "string" ? question.question : "Question";
4378
4396
  onInteraction({
4379
4397
  kind: "quiz-submit",
4380
4398
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -4382,7 +4400,7 @@ function Quiz({ data, block, onInteraction }) {
4382
4400
  blockType: block.type,
4383
4401
  payload: {
4384
4402
  questionIndex: qIndex,
4385
- question: question.question,
4403
+ question: questionText,
4386
4404
  selected,
4387
4405
  correct: correct2,
4388
4406
  score: { correct: newScore, total: questions.length }
@@ -4395,7 +4413,7 @@ function Quiz({ data, block, onInteraction }) {
4395
4413
  ),
4396
4414
  /* @__PURE__ */ jsxs("div", { "aria-live": "polite", children: [
4397
4415
  state.submitted && /* @__PURE__ */ jsx("div", { style: feedbackStyle(correct), children: correct ? "Correct!" : "Incorrect" }),
4398
- state.submitted && question.explanation && /* @__PURE__ */ jsx("div", { style: explanationStyle, children: question.explanation })
4416
+ state.submitted && question.explanation && /* @__PURE__ */ jsx("div", { style: explanationStyle, children: /* @__PURE__ */ jsx(RichText, { content: question.explanation }) })
4399
4417
  ] })
4400
4418
  ]
4401
4419
  },
@@ -4533,8 +4551,8 @@ function Card({ data, block, container }) {
4533
4551
  /* @__PURE__ */ jsxs("div", { style: cardBodyStyle, children: [
4534
4552
  card.icon && /* @__PURE__ */ jsx("div", { style: iconStyle, children: card.icon }),
4535
4553
  /* @__PURE__ */ jsx("h3", { style: titleStyle2, children: card.title }),
4536
- card.subtitle && /* @__PURE__ */ jsx("div", { style: subtitleStyle, children: card.subtitle }),
4537
- card.body && /* @__PURE__ */ jsx("div", { style: bodyStyle3, children: card.body }),
4554
+ card.subtitle && /* @__PURE__ */ jsx("div", { style: subtitleStyle, children: /* @__PURE__ */ jsx(RichText, { content: card.subtitle }) }),
4555
+ card.body && /* @__PURE__ */ jsx("div", { style: bodyStyle3, children: /* @__PURE__ */ jsx(RichText, { content: card.body }) }),
4538
4556
  card.actions && card.actions.length > 0 && /* @__PURE__ */ jsx("div", { style: actionsStyle, children: card.actions.map((action, j) => /* @__PURE__ */ jsx(
4539
4557
  "a",
4540
4558
  {
@@ -4641,7 +4659,7 @@ function renderStatGroup(items, keyPrefix) {
4641
4659
  return /* @__PURE__ */ jsx("div", { style: rowStyle, "data-group": "stat", children: items.map((item, i) => /* @__PURE__ */ jsxs("div", { style: statStyle, children: [
4642
4660
  /* @__PURE__ */ jsx("div", { style: valueStyle, children: item.value }),
4643
4661
  /* @__PURE__ */ jsx("div", { style: labelStyle4, children: item.label }),
4644
- item.description && /* @__PURE__ */ jsx("div", { style: descStyle, children: item.description })
4662
+ item.description && /* @__PURE__ */ jsx("div", { style: descStyle, children: /* @__PURE__ */ jsx(RichText, { content: item.description }) })
4645
4663
  ] }, `${keyPrefix}-${String(i)}`)) }, keyPrefix);
4646
4664
  }
4647
4665
  function renderProgressGroup(items, keyPrefix, colorOffset) {
@@ -4734,7 +4752,7 @@ function renderFactGroup(items, keyPrefix) {
4734
4752
  children: item.icon
4735
4753
  }
4736
4754
  ),
4737
- item.text
4755
+ /* @__PURE__ */ jsx(RichText, { content: item.text })
4738
4756
  ] }, `${keyPrefix}-${String(i)}`)) }, keyPrefix);
4739
4757
  }
4740
4758
  function renderTextGroup(items, keyPrefix) {
@@ -5216,17 +5234,21 @@ function Poll({ data, block, onInteraction }) {
5216
5234
  blockId: block.id,
5217
5235
  blockType: block.type,
5218
5236
  payload: {
5219
- selectedOptions: selected.map((i) => options[i] ?? String(i)),
5237
+ selectedOptions: selected.map((i) => {
5238
+ const opt = options[i];
5239
+ return typeof opt === "string" ? opt : String(i);
5240
+ }),
5220
5241
  selectedIndices: [...selected]
5221
5242
  }
5222
5243
  });
5223
5244
  }
5224
5245
  };
5225
5246
  const totalVotes = votes.reduce((a, b) => a + b, 0);
5247
+ const questionAriaLabel = typeof question === "string" ? question : "Poll question";
5226
5248
  return /* @__PURE__ */ jsxs("div", { id: baseId, role: "region", "aria-label": title ?? "Poll", style: containerStyle3, children: [
5227
5249
  title && /* @__PURE__ */ jsx("div", { style: headerStyle2, children: title }),
5228
- /* @__PURE__ */ jsx("div", { style: questionStyle, children: question }),
5229
- /* @__PURE__ */ jsx("div", { role: "group", "aria-label": question, style: optionsStyle, children: options.map((option, index) => /* @__PURE__ */ jsxs("label", { style: optionLabelStyle2(selected.includes(index)), children: [
5250
+ /* @__PURE__ */ jsx("div", { style: questionStyle, children: /* @__PURE__ */ jsx(RichText, { content: question }) }),
5251
+ /* @__PURE__ */ jsx("div", { role: "group", "aria-label": questionAriaLabel, style: optionsStyle, children: options.map((option, index) => /* @__PURE__ */ jsxs("label", { style: optionLabelStyle2(selected.includes(index)), children: [
5230
5252
  /* @__PURE__ */ jsx(
5231
5253
  "input",
5232
5254
  {
@@ -5238,7 +5260,7 @@ function Poll({ data, block, onInteraction }) {
5238
5260
  "aria-checked": selected.includes(index)
5239
5261
  }
5240
5262
  ),
5241
- option
5263
+ /* @__PURE__ */ jsx(RichText, { content: option })
5242
5264
  ] }, index)) }),
5243
5265
  !hasVoted && /* @__PURE__ */ jsx(
5244
5266
  "button",
@@ -5257,9 +5279,10 @@ function Poll({ data, block, onInteraction }) {
5257
5279
  showResults && hasVoted && /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", style: resultsStyle, children: options.map((option, index) => {
5258
5280
  const count = votes[index] ?? 0;
5259
5281
  const percentage = totalVotes > 0 ? count / totalVotes * 100 : 0;
5282
+ const optionLabel = typeof option === "string" ? option : "Option";
5260
5283
  return /* @__PURE__ */ jsxs("div", { style: resultRowStyle, children: [
5261
5284
  /* @__PURE__ */ jsxs("div", { style: resultLabelStyle, children: [
5262
- /* @__PURE__ */ jsx("span", { children: option }),
5285
+ /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(RichText, { content: option }) }),
5263
5286
  /* @__PURE__ */ jsxs("span", { children: [
5264
5287
  String(count),
5265
5288
  " vote",
@@ -5277,7 +5300,7 @@ function Poll({ data, block, onInteraction }) {
5277
5300
  "aria-valuenow": percentage,
5278
5301
  "aria-valuemin": 0,
5279
5302
  "aria-valuemax": 100,
5280
- "aria-label": `${option}: ${String(Math.round(percentage))}%`,
5303
+ "aria-label": `${optionLabel}: ${String(Math.round(percentage))}%`,
5281
5304
  children: /* @__PURE__ */ jsx("div", { style: barFillStyle(percentage) })
5282
5305
  }
5283
5306
  )
@@ -5379,6 +5402,8 @@ function Rating({
5379
5402
  newRatings[itemIndex] = value;
5380
5403
  setRatings(newRatings);
5381
5404
  if (onInteraction) {
5405
+ const item = items[itemIndex];
5406
+ const itemLabel = item ? typeof item.label === "string" ? item.label : "Item" : "";
5382
5407
  onInteraction({
5383
5408
  kind: "rating-change",
5384
5409
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -5386,10 +5411,10 @@ function Rating({
5386
5411
  blockType: block.type,
5387
5412
  payload: {
5388
5413
  itemIndex,
5389
- itemLabel: items[itemIndex]?.label ?? "",
5414
+ itemLabel,
5390
5415
  value,
5391
- allRatings: items.map((item, i) => ({
5392
- label: item.label,
5416
+ allRatings: items.map((item2, i) => ({
5417
+ label: typeof item2.label === "string" ? item2.label : "Item",
5393
5418
  value: i === itemIndex ? value : newRatings[i] ?? null
5394
5419
  }))
5395
5420
  }
@@ -5401,10 +5426,11 @@ function Rating({
5401
5426
  items.map((item, itemIndex) => {
5402
5427
  const currentRating = ratings[itemIndex] ?? null;
5403
5428
  const isLast = itemIndex === items.length - 1;
5429
+ const itemLabelText = typeof item.label === "string" ? item.label : "Item";
5404
5430
  return /* @__PURE__ */ jsxs("div", { style: itemStyle2(isLast), children: [
5405
- /* @__PURE__ */ jsx("div", { style: itemLabelStyle, children: item.label }),
5406
- item.description && /* @__PURE__ */ jsx("div", { style: itemDescriptionStyle, children: item.description }),
5407
- /* @__PURE__ */ jsx("div", { role: "radiogroup", "aria-label": `Rate ${item.label}`, style: starsContainerStyle, children: Array.from({ length: scale }, (_, starIndex) => {
5431
+ /* @__PURE__ */ jsx("div", { style: itemLabelStyle, children: /* @__PURE__ */ jsx(RichText, { content: item.label }) }),
5432
+ item.description && /* @__PURE__ */ jsx("div", { style: itemDescriptionStyle, children: /* @__PURE__ */ jsx(RichText, { content: item.description }) }),
5433
+ /* @__PURE__ */ jsx("div", { role: "radiogroup", "aria-label": `Rate ${itemLabelText}`, style: starsContainerStyle, children: Array.from({ length: scale }, (_, starIndex) => {
5408
5434
  const value = starIndex + 1;
5409
5435
  const isHovered = hoveredStar !== null && hoveredStar.itemIndex === itemIndex && value <= hoveredStar.value;
5410
5436
  const isFilled = currentRating !== null && value <= currentRating;
@@ -5458,7 +5484,7 @@ function Rating({
5458
5484
  whiteSpace: "nowrap",
5459
5485
  border: 0
5460
5486
  },
5461
- children: currentRating !== null && `${item.label} rated ${String(currentRating)} out of ${String(scale)}`
5487
+ children: currentRating !== null && `${itemLabelText} rated ${String(currentRating)} out of ${String(scale)}`
5462
5488
  }
5463
5489
  )
5464
5490
  ] }, itemIndex);
@@ -5565,12 +5591,12 @@ function Ranker({
5565
5591
  payload: {
5566
5592
  orderedItems: newItems.map((item, i) => ({
5567
5593
  id: item.id,
5568
- label: item.label,
5594
+ label: typeof item.label === "string" ? item.label : "Item",
5569
5595
  rank: i + 1
5570
5596
  })),
5571
5597
  movedItem: {
5572
5598
  id: moved.id,
5573
- label: moved.label,
5599
+ label: typeof moved.label === "string" ? moved.label : "Item",
5574
5600
  fromRank: fromIndex + 1,
5575
5601
  toRank: toIndex + 1
5576
5602
  }
@@ -5608,26 +5634,29 @@ function Ranker({
5608
5634
  };
5609
5635
  return /* @__PURE__ */ jsxs("div", { id: baseId, role: "region", "aria-label": title ?? "Ranker", style: containerStyle5, children: [
5610
5636
  title && /* @__PURE__ */ jsx("div", { style: headerStyle4, children: title }),
5611
- /* @__PURE__ */ jsx("ul", { role: "list", "aria-label": title ?? "Rank items", style: listStyle, children: items.map((item, index) => /* @__PURE__ */ jsxs(
5612
- "li",
5613
- {
5614
- role: "listitem",
5615
- "aria-grabbed": grabbedIndex === index,
5616
- "aria-label": `${item.label}, rank ${String(index + 1)}`,
5617
- tabIndex: 0,
5618
- style: itemStyle3(false, grabbedIndex === index),
5619
- onKeyDown: (e) => handleKeyDown(e, index),
5620
- children: [
5621
- /* @__PURE__ */ jsx("span", { style: gripStyle, "aria-hidden": "true", children: "\u283F" }),
5622
- /* @__PURE__ */ jsx("span", { style: rankBadgeStyle, children: String(index + 1) }),
5623
- /* @__PURE__ */ jsxs("div", { style: itemContentStyle, children: [
5624
- /* @__PURE__ */ jsx("div", { style: itemLabelStyle2, children: item.label }),
5625
- item.description && /* @__PURE__ */ jsx("div", { style: itemDescriptionStyle2, children: item.description })
5626
- ] })
5627
- ]
5628
- },
5629
- item.id
5630
- )) }),
5637
+ /* @__PURE__ */ jsx("ul", { role: "list", "aria-label": title ?? "Rank items", style: listStyle, children: items.map((item, index) => {
5638
+ const itemLabelText = typeof item.label === "string" ? item.label : "Item";
5639
+ return /* @__PURE__ */ jsxs(
5640
+ "li",
5641
+ {
5642
+ role: "listitem",
5643
+ "aria-grabbed": grabbedIndex === index,
5644
+ "aria-label": `${itemLabelText}, rank ${String(index + 1)}`,
5645
+ tabIndex: 0,
5646
+ style: itemStyle3(false, grabbedIndex === index),
5647
+ onKeyDown: (e) => handleKeyDown(e, index),
5648
+ children: [
5649
+ /* @__PURE__ */ jsx("span", { style: gripStyle, "aria-hidden": "true", children: "\u283F" }),
5650
+ /* @__PURE__ */ jsx("span", { style: rankBadgeStyle, children: String(index + 1) }),
5651
+ /* @__PURE__ */ jsxs("div", { style: itemContentStyle, children: [
5652
+ /* @__PURE__ */ jsx("div", { style: itemLabelStyle2, children: /* @__PURE__ */ jsx(RichText, { content: item.label }) }),
5653
+ item.description && /* @__PURE__ */ jsx("div", { style: itemDescriptionStyle2, children: item.description })
5654
+ ] })
5655
+ ]
5656
+ },
5657
+ item.id
5658
+ );
5659
+ }) }),
5631
5660
  /* @__PURE__ */ jsx(
5632
5661
  "div",
5633
5662
  {
@@ -5643,7 +5672,7 @@ function Ranker({
5643
5672
  whiteSpace: "nowrap",
5644
5673
  border: 0
5645
5674
  },
5646
- children: grabbedIndex !== null && `${items[grabbedIndex]?.label ?? ""} grabbed, rank ${String(grabbedIndex + 1)} of ${String(items.length)}. Use arrow keys to move.`
5675
+ children: grabbedIndex !== null && items[grabbedIndex] !== void 0 ? `${typeof items[grabbedIndex].label === "string" ? items[grabbedIndex].label : "Item"} grabbed, rank ${String(grabbedIndex + 1)} of ${String(items.length)}. Use arrow keys to move.` : ""
5647
5676
  }
5648
5677
  )
5649
5678
  ] });
@@ -5729,11 +5758,11 @@ function Slider({
5729
5758
  blockType: block.type,
5730
5759
  payload: {
5731
5760
  parameterId: param.id,
5732
- parameterLabel: param.label,
5761
+ parameterLabel: typeof param.label === "string" ? param.label : "Parameter",
5733
5762
  value: newValue,
5734
5763
  allValues: parameters.map((p, i) => ({
5735
5764
  id: p.id,
5736
- label: p.label,
5765
+ label: typeof p.label === "string" ? p.label : "Parameter",
5737
5766
  value: i === paramIndex ? newValue : newValues[i] ?? 0
5738
5767
  }))
5739
5768
  }
@@ -5753,7 +5782,7 @@ function Slider({
5753
5782
  const isLast = index === parameters.length - 1;
5754
5783
  return /* @__PURE__ */ jsxs("div", { style: parameterStyle(isLast), children: [
5755
5784
  /* @__PURE__ */ jsxs("div", { style: parameterHeaderStyle, children: [
5756
- /* @__PURE__ */ jsx("label", { htmlFor: `${baseId}-${param.id}`, style: parameterLabelStyle, children: param.label }),
5785
+ /* @__PURE__ */ jsx("label", { htmlFor: `${baseId}-${param.id}`, style: parameterLabelStyle, children: /* @__PURE__ */ jsx(RichText, { content: param.label }) }),
5757
5786
  /* @__PURE__ */ jsx("span", { style: parameterValueStyle, "aria-live": "polite", children: formatValue(currentValue, param.unit) })
5758
5787
  ] }),
5759
5788
  /* @__PURE__ */ jsx(
@@ -5866,7 +5895,8 @@ function computeWeightedTotals(rows, columns, values) {
5866
5895
  const weight = col.weight ?? 1;
5867
5896
  total += score * weight;
5868
5897
  }
5869
- return { rowId: row.id, rowLabel: row.label, total: Math.round(total * 100) / 100 };
5898
+ const rowLabel = typeof row.label === "string" ? row.label : "Row";
5899
+ return { rowId: row.id, rowLabel, total: Math.round(total * 100) / 100 };
5870
5900
  });
5871
5901
  }
5872
5902
  function Matrix({
@@ -5909,9 +5939,9 @@ function Matrix({
5909
5939
  blockType: block.type,
5910
5940
  payload: {
5911
5941
  rowId,
5912
- rowLabel: row.label,
5942
+ rowLabel: typeof row.label === "string" ? row.label : "Row",
5913
5943
  columnId,
5914
- columnLabel: col.label,
5944
+ columnLabel: typeof col.label === "string" ? col.label : "Column",
5915
5945
  value: clamped,
5916
5946
  allValues: payloadValues,
5917
5947
  weightedTotals: computeWeightedTotals(rows, columns, newValues)
@@ -5930,7 +5960,7 @@ function Matrix({
5930
5960
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
5931
5961
  /* @__PURE__ */ jsx("th", { style: thStyle }),
5932
5962
  columns.map((col) => /* @__PURE__ */ jsxs("th", { style: thStyle, children: [
5933
- col.label,
5963
+ /* @__PURE__ */ jsx(RichText, { content: col.label }),
5934
5964
  (col.weight ?? 1) !== 1 && /* @__PURE__ */ jsxs("div", { style: weightStyle, children: [
5935
5965
  "\xD7",
5936
5966
  String(col.weight)
@@ -5940,10 +5970,12 @@ function Matrix({
5940
5970
  ] }) }),
5941
5971
  /* @__PURE__ */ jsx("tbody", { children: rows.map((row) => {
5942
5972
  const rowTotal = totals.find((t) => t.rowId === row.id)?.total ?? 0;
5973
+ const rowLabelText = typeof row.label === "string" ? row.label : "Row";
5943
5974
  return /* @__PURE__ */ jsxs("tr", { children: [
5944
- /* @__PURE__ */ jsx("th", { scope: "row", style: rowHeaderStyle, children: row.label }),
5975
+ /* @__PURE__ */ jsx("th", { scope: "row", style: rowHeaderStyle, children: /* @__PURE__ */ jsx(RichText, { content: row.label }) }),
5945
5976
  columns.map((col) => {
5946
5977
  const cellValue = values[row.id]?.[col.id] ?? 0;
5978
+ const colLabelText = typeof col.label === "string" ? col.label : "Column";
5947
5979
  return /* @__PURE__ */ jsx("td", { style: cellStyle, children: /* @__PURE__ */ jsx(
5948
5980
  "input",
5949
5981
  {
@@ -5952,7 +5984,7 @@ function Matrix({
5952
5984
  max: scale,
5953
5985
  value: cellValue,
5954
5986
  onChange: (e) => handleChange(row.id, col.id, Number(e.target.value)),
5955
- "aria-label": `Score for ${row.label} on ${col.label}`,
5987
+ "aria-label": `Score for ${rowLabelText} on ${colLabelText}`,
5956
5988
  style: inputStyle
5957
5989
  }
5958
5990
  ) }, col.id);
@@ -6246,7 +6278,7 @@ function Form({ data, block, onInteraction }) {
6246
6278
  };
6247
6279
  return /* @__PURE__ */ jsxs("div", { id: baseId, role: "region", "aria-label": title ?? "Form", style: containerStyle8, children: [
6248
6280
  title && /* @__PURE__ */ jsx("div", { style: headerStyle7, children: title }),
6249
- description && /* @__PURE__ */ jsx("div", { style: descriptionStyle, children: description }),
6281
+ description && /* @__PURE__ */ jsx("div", { style: descriptionStyle, children: /* @__PURE__ */ jsx(RichText, { content: description }) }),
6250
6282
  /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: formStyle, noValidate: true, children: [
6251
6283
  fields.map(
6252
6284
  (field) => renderField({ field, baseId, values, validation, submitted, updateValue })
@@ -6633,6 +6665,9 @@ var annotationNoteStyle = {
6633
6665
  marginTop: "0.125rem"
6634
6666
  };
6635
6667
  function computeSegments(text, annotations) {
6668
+ if (typeof text !== "string") {
6669
+ return [{ text: "", start: 0, annotation: null }];
6670
+ }
6636
6671
  if (annotations.length === 0) {
6637
6672
  return [{ text, start: 0, annotation: null }];
6638
6673
  }
@@ -6712,7 +6747,7 @@ function Annotate({
6712
6747
  allAnnotations: newAnnotations.map((a) => ({
6713
6748
  start: a.start,
6714
6749
  end: a.end,
6715
- text: text.slice(a.start, a.end),
6750
+ text: typeof text === "string" ? text.slice(a.start, a.end) : "",
6716
6751
  label: a.label
6717
6752
  }))
6718
6753
  }
@@ -6738,7 +6773,7 @@ function Annotate({
6738
6773
  title && /* @__PURE__ */ jsx("div", { style: headerStyle9, children: title }),
6739
6774
  /* @__PURE__ */ jsxs("div", { style: bodyStyle2, children: [
6740
6775
  /* @__PURE__ */ jsxs("div", { ref: textRef, role: "document", style: textPaneStyle, onMouseUp: handleMouseUp, children: [
6741
- segments.map((seg, i) => {
6776
+ typeof text === "string" ? segments.map((seg, i) => {
6742
6777
  if (seg.annotation) {
6743
6778
  const color3 = labelColorMap.get(seg.annotation.label) ?? "#888";
6744
6779
  return /* @__PURE__ */ jsx(
@@ -6756,7 +6791,7 @@ function Annotate({
6756
6791
  );
6757
6792
  }
6758
6793
  return /* @__PURE__ */ jsx("span", { children: seg.text }, i);
6759
- }),
6794
+ }) : /* @__PURE__ */ jsx(RichText, { content: text }),
6760
6795
  pickerPos && /* @__PURE__ */ jsx(
6761
6796
  "div",
6762
6797
  {
@@ -6795,12 +6830,13 @@ function Annotate({
6795
6830
  /* @__PURE__ */ jsxs("div", { role: "list", children: [
6796
6831
  annotations.map((ann, i) => {
6797
6832
  const color3 = labelColorMap.get(ann.label) ?? "#888";
6833
+ const annotatedText = typeof text === "string" ? text.slice(ann.start, ann.end) : "";
6798
6834
  return /* @__PURE__ */ jsxs("div", { role: "listitem", style: annotationItemStyle(color3), children: [
6799
6835
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
6800
6836
  /* @__PURE__ */ jsx("span", { style: colorDotStyle(color3) }),
6801
6837
  /* @__PURE__ */ jsx("strong", { style: { fontSize: "0.75rem" }, children: ann.label })
6802
6838
  ] }),
6803
- /* @__PURE__ */ jsx("div", { style: annotationTextStyle, children: text.slice(ann.start, ann.end) }),
6839
+ /* @__PURE__ */ jsx("div", { style: annotationTextStyle, children: annotatedText }),
6804
6840
  ann.note && /* @__PURE__ */ jsx("div", { style: annotationNoteStyle, children: ann.note })
6805
6841
  ] }, i);
6806
6842
  }),