@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.cjs +116 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -31
- package/dist/index.d.ts +47 -31
- package/dist/index.js +116 -80
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var schemas = require('@glyphjs/schemas');
|
|
4
|
+
var runtime = require('@glyphjs/runtime');
|
|
4
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
6
|
var react = require('react');
|
|
6
7
|
var d32 = require('d3');
|
|
@@ -75,7 +76,7 @@ function Callout({ data }) {
|
|
|
75
76
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: iconStyle, "aria-hidden": "true", children: CALLOUT_ICONS[type] }),
|
|
76
77
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: bodyStyle3, children: [
|
|
77
78
|
title && /* @__PURE__ */ jsxRuntime.jsx("div", { style: titleStyle2, children: title }),
|
|
78
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: content })
|
|
79
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content }) })
|
|
79
80
|
] })
|
|
80
81
|
] });
|
|
81
82
|
}
|
|
@@ -553,7 +554,7 @@ function Steps({ data }) {
|
|
|
553
554
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", style: indicatorStyle(status), children: status === "completed" ? "\u2713" : "" }),
|
|
554
555
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: bodyStyle, children: [
|
|
555
556
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: titleStyle(status), children: step.title }),
|
|
556
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: contentStyle(status), children: step.content })
|
|
557
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: contentStyle(status), children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: step.content }) })
|
|
557
558
|
] })
|
|
558
559
|
]
|
|
559
560
|
},
|
|
@@ -1212,7 +1213,7 @@ function Timeline({ data }) {
|
|
|
1212
1213
|
fontWeight: 700,
|
|
1213
1214
|
marginTop: 2
|
|
1214
1215
|
},
|
|
1215
|
-
children: pe.event.title
|
|
1216
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: pe.event.title })
|
|
1216
1217
|
}
|
|
1217
1218
|
),
|
|
1218
1219
|
pe.event.description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1223,7 +1224,7 @@ function Timeline({ data }) {
|
|
|
1223
1224
|
color: "var(--glyph-timeline-desc-color, #7a8599)",
|
|
1224
1225
|
marginTop: 2
|
|
1225
1226
|
},
|
|
1226
|
-
children: pe.event.description
|
|
1227
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: pe.event.description })
|
|
1227
1228
|
}
|
|
1228
1229
|
)
|
|
1229
1230
|
] })
|
|
@@ -1241,12 +1242,16 @@ function Timeline({ data }) {
|
|
|
1241
1242
|
clipPath: "inset(50%)",
|
|
1242
1243
|
whiteSpace: "nowrap"
|
|
1243
1244
|
},
|
|
1244
|
-
children: sorted.map((e, idx) =>
|
|
1245
|
-
|
|
1246
|
-
"
|
|
1247
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1248
|
-
|
|
1249
|
-
|
|
1245
|
+
children: sorted.map((e, idx) => {
|
|
1246
|
+
const titleText = typeof e.title === "string" ? e.title : "Event";
|
|
1247
|
+
const descText = typeof e.description === "string" ? e.description : "";
|
|
1248
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
1249
|
+
/* @__PURE__ */ jsxRuntime.jsx("time", { dateTime: isoDate(e.date), children: formatDate(e.date) }),
|
|
1250
|
+
" \u2014 ",
|
|
1251
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: titleText }),
|
|
1252
|
+
descText ? `: ${descText}` : ""
|
|
1253
|
+
] }, idx);
|
|
1254
|
+
})
|
|
1250
1255
|
}
|
|
1251
1256
|
)
|
|
1252
1257
|
]
|
|
@@ -1918,7 +1923,8 @@ function resolveSentiment(metric) {
|
|
|
1918
1923
|
return "neutral";
|
|
1919
1924
|
}
|
|
1920
1925
|
function buildAriaLabel(metric) {
|
|
1921
|
-
|
|
1926
|
+
const labelText = typeof metric.label === "string" ? metric.label : "Metric";
|
|
1927
|
+
let label = `${labelText}: ${metric.value}`;
|
|
1922
1928
|
if (metric.unit) label += ` ${metric.unit}`;
|
|
1923
1929
|
if (metric.delta && metric.trend) {
|
|
1924
1930
|
label += `, ${metric.trend} ${metric.delta}`;
|
|
@@ -1990,7 +1996,7 @@ function Kpi({ data, block, container }) {
|
|
|
1990
1996
|
color: `var(--glyph-kpi-${sentiment}, inherit)`
|
|
1991
1997
|
};
|
|
1992
1998
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "group", "aria-label": buildAriaLabel(metric), style: cardStyle2, children: [
|
|
1993
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: labelStyle4, children: metric.label }),
|
|
1999
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: labelStyle4, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: metric.label }) }),
|
|
1994
2000
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: valueStyle, children: [
|
|
1995
2001
|
metric.value,
|
|
1996
2002
|
metric.unit && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "0.875rem", fontWeight: 400, marginLeft: "0.25rem" }, children: metric.unit })
|
|
@@ -2104,7 +2110,7 @@ function Accordion({
|
|
|
2104
2110
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", style: { fontSize: "0.75rem", width: "1rem", flexShrink: 0 }, children: "\u25B8" }),
|
|
2105
2111
|
section.title
|
|
2106
2112
|
] }),
|
|
2107
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: contentStyle2, children: section.content })
|
|
2113
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: contentStyle2, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: section.content }) })
|
|
2108
2114
|
]
|
|
2109
2115
|
},
|
|
2110
2116
|
i
|
|
@@ -2123,6 +2129,7 @@ var accordionDefinition = {
|
|
|
2123
2129
|
var YES_VALUES = /* @__PURE__ */ new Set(["yes", "true", "full"]);
|
|
2124
2130
|
var NO_VALUES = /* @__PURE__ */ new Set(["no", "false", "none"]);
|
|
2125
2131
|
function classifyValue(value) {
|
|
2132
|
+
if (typeof value !== "string") return "text";
|
|
2126
2133
|
const lower = value.toLowerCase().trim();
|
|
2127
2134
|
if (YES_VALUES.has(lower)) return "yes";
|
|
2128
2135
|
if (NO_VALUES.has(lower)) return "no";
|
|
@@ -2160,7 +2167,7 @@ function renderValue(value) {
|
|
|
2160
2167
|
}
|
|
2161
2168
|
);
|
|
2162
2169
|
default:
|
|
2163
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { children: value });
|
|
2170
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: value }) });
|
|
2164
2171
|
}
|
|
2165
2172
|
}
|
|
2166
2173
|
function Comparison({
|
|
@@ -2256,7 +2263,7 @@ function Comparison({
|
|
|
2256
2263
|
fontSize: "0.75rem",
|
|
2257
2264
|
color: "var(--glyph-text-muted, #6b7a94)"
|
|
2258
2265
|
},
|
|
2259
|
-
children: option.description
|
|
2266
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: option.description })
|
|
2260
2267
|
}
|
|
2261
2268
|
)
|
|
2262
2269
|
]
|
|
@@ -2277,8 +2284,8 @@ function Comparison({
|
|
|
2277
2284
|
}
|
|
2278
2285
|
),
|
|
2279
2286
|
options.map((_, colIndex) => {
|
|
2280
|
-
const value = feature.values[colIndex]
|
|
2281
|
-
return /* @__PURE__ */ jsxRuntime.jsx("td", { style: cellStyle2(rowIndex), children: value ? renderValue(value) : null }, colIndex);
|
|
2287
|
+
const value = feature.values[colIndex];
|
|
2288
|
+
return /* @__PURE__ */ jsxRuntime.jsx("td", { style: cellStyle2(rowIndex), children: value !== void 0 && value !== "" ? renderValue(value) : null }, colIndex);
|
|
2282
2289
|
})
|
|
2283
2290
|
] }, rowIndex)) })
|
|
2284
2291
|
] }) })
|
|
@@ -4229,7 +4236,8 @@ function isCorrect(question, selected) {
|
|
|
4229
4236
|
}
|
|
4230
4237
|
function renderMultipleChoice(question, qIndex, state, updateState, baseId) {
|
|
4231
4238
|
const selected = typeof state.selected === "number" ? state.selected : null;
|
|
4232
|
-
|
|
4239
|
+
const ariaLabel = typeof question.question === "string" ? question.question : "Question";
|
|
4240
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "radiogroup", "aria-label": ariaLabel, children: question.options.map((option, oIndex) => {
|
|
4233
4241
|
const isSelected = selected === oIndex;
|
|
4234
4242
|
const isCorrectOption = state.submitted && oIndex === question.answer;
|
|
4235
4243
|
const isIncorrectSelection = state.submitted && isSelected && oIndex !== question.answer;
|
|
@@ -4255,7 +4263,7 @@ function renderMultipleChoice(question, qIndex, state, updateState, baseId) {
|
|
|
4255
4263
|
"aria-checked": isSelected
|
|
4256
4264
|
}
|
|
4257
4265
|
),
|
|
4258
|
-
option
|
|
4266
|
+
/* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: option })
|
|
4259
4267
|
]
|
|
4260
4268
|
},
|
|
4261
4269
|
oIndex
|
|
@@ -4264,7 +4272,8 @@ function renderMultipleChoice(question, qIndex, state, updateState, baseId) {
|
|
|
4264
4272
|
}
|
|
4265
4273
|
function renderTrueFalse(question, qIndex, state, updateState, baseId) {
|
|
4266
4274
|
const selected = typeof state.selected === "boolean" ? state.selected : null;
|
|
4267
|
-
|
|
4275
|
+
const ariaLabel = typeof question.question === "string" ? question.question : "Question";
|
|
4276
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "radiogroup", "aria-label": ariaLabel, children: [true, false].map((value) => {
|
|
4268
4277
|
const isSelected = selected === value;
|
|
4269
4278
|
const isCorrectOption = state.submitted && value === question.answer;
|
|
4270
4279
|
const isIncorrectSelection = state.submitted && isSelected && value !== question.answer;
|
|
@@ -4328,7 +4337,7 @@ function renderMultiSelect(question, qIndex, state, updateState) {
|
|
|
4328
4337
|
"aria-checked": isSelected
|
|
4329
4338
|
}
|
|
4330
4339
|
),
|
|
4331
|
-
option
|
|
4340
|
+
/* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: option })
|
|
4332
4341
|
]
|
|
4333
4342
|
},
|
|
4334
4343
|
oIndex
|
|
@@ -4367,7 +4376,7 @@ function Quiz({ data, block, onInteraction }) {
|
|
|
4367
4376
|
children: [
|
|
4368
4377
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: questionTextStyle, children: [
|
|
4369
4378
|
questions.length > 1 ? `${String(qIndex + 1)}. ` : "",
|
|
4370
|
-
question.question
|
|
4379
|
+
/* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: question.question })
|
|
4371
4380
|
] }),
|
|
4372
4381
|
question.type === "multiple-choice" && renderMultipleChoice(question, qIndex, state, updateState, baseId),
|
|
4373
4382
|
question.type === "true-false" && renderTrueFalse(question, qIndex, state, updateState, baseId),
|
|
@@ -4391,15 +4400,24 @@ function Quiz({ data, block, onInteraction }) {
|
|
|
4391
4400
|
let selected;
|
|
4392
4401
|
switch (question.type) {
|
|
4393
4402
|
case "multiple-choice":
|
|
4394
|
-
|
|
4403
|
+
if (typeof state.selected === "number") {
|
|
4404
|
+
const opt = question.options[state.selected];
|
|
4405
|
+
selected = [typeof opt === "string" ? opt : String(state.selected)];
|
|
4406
|
+
} else {
|
|
4407
|
+
selected = [];
|
|
4408
|
+
}
|
|
4395
4409
|
break;
|
|
4396
4410
|
case "true-false":
|
|
4397
4411
|
selected = typeof state.selected === "boolean" ? [state.selected ? "True" : "False"] : [];
|
|
4398
4412
|
break;
|
|
4399
4413
|
case "multi-select":
|
|
4400
|
-
selected = Array.isArray(state.selected) ? state.selected.map((idx) =>
|
|
4414
|
+
selected = Array.isArray(state.selected) ? state.selected.map((idx) => {
|
|
4415
|
+
const opt = question.options[idx];
|
|
4416
|
+
return typeof opt === "string" ? opt : String(idx);
|
|
4417
|
+
}) : [];
|
|
4401
4418
|
break;
|
|
4402
4419
|
}
|
|
4420
|
+
const questionText = typeof question.question === "string" ? question.question : "Question";
|
|
4403
4421
|
onInteraction({
|
|
4404
4422
|
kind: "quiz-submit",
|
|
4405
4423
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -4407,7 +4425,7 @@ function Quiz({ data, block, onInteraction }) {
|
|
|
4407
4425
|
blockType: block.type,
|
|
4408
4426
|
payload: {
|
|
4409
4427
|
questionIndex: qIndex,
|
|
4410
|
-
question:
|
|
4428
|
+
question: questionText,
|
|
4411
4429
|
selected,
|
|
4412
4430
|
correct: correct2,
|
|
4413
4431
|
score: { correct: newScore, total: questions.length }
|
|
@@ -4420,7 +4438,7 @@ function Quiz({ data, block, onInteraction }) {
|
|
|
4420
4438
|
),
|
|
4421
4439
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "aria-live": "polite", children: [
|
|
4422
4440
|
state.submitted && /* @__PURE__ */ jsxRuntime.jsx("div", { style: feedbackStyle(correct), children: correct ? "Correct!" : "Incorrect" }),
|
|
4423
|
-
state.submitted && question.explanation && /* @__PURE__ */ jsxRuntime.jsx("div", { style: explanationStyle, children: question.explanation })
|
|
4441
|
+
state.submitted && question.explanation && /* @__PURE__ */ jsxRuntime.jsx("div", { style: explanationStyle, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: question.explanation }) })
|
|
4424
4442
|
] })
|
|
4425
4443
|
]
|
|
4426
4444
|
},
|
|
@@ -4558,8 +4576,8 @@ function Card({ data, block, container }) {
|
|
|
4558
4576
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: cardBodyStyle, children: [
|
|
4559
4577
|
card.icon && /* @__PURE__ */ jsxRuntime.jsx("div", { style: iconStyle, children: card.icon }),
|
|
4560
4578
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: titleStyle2, children: card.title }),
|
|
4561
|
-
card.subtitle && /* @__PURE__ */ jsxRuntime.jsx("div", { style: subtitleStyle, children: card.subtitle }),
|
|
4562
|
-
card.body && /* @__PURE__ */ jsxRuntime.jsx("div", { style: bodyStyle3, children: card.body }),
|
|
4579
|
+
card.subtitle && /* @__PURE__ */ jsxRuntime.jsx("div", { style: subtitleStyle, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: card.subtitle }) }),
|
|
4580
|
+
card.body && /* @__PURE__ */ jsxRuntime.jsx("div", { style: bodyStyle3, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: card.body }) }),
|
|
4563
4581
|
card.actions && card.actions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: actionsStyle, children: card.actions.map((action, j) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4564
4582
|
"a",
|
|
4565
4583
|
{
|
|
@@ -4666,7 +4684,7 @@ function renderStatGroup(items, keyPrefix) {
|
|
|
4666
4684
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: rowStyle, "data-group": "stat", children: items.map((item, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: statStyle, children: [
|
|
4667
4685
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: valueStyle, children: item.value }),
|
|
4668
4686
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: labelStyle4, children: item.label }),
|
|
4669
|
-
item.description && /* @__PURE__ */ jsxRuntime.jsx("div", { style: descStyle, children: item.description })
|
|
4687
|
+
item.description && /* @__PURE__ */ jsxRuntime.jsx("div", { style: descStyle, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: item.description }) })
|
|
4670
4688
|
] }, `${keyPrefix}-${String(i)}`)) }, keyPrefix);
|
|
4671
4689
|
}
|
|
4672
4690
|
function renderProgressGroup(items, keyPrefix, colorOffset) {
|
|
@@ -4759,7 +4777,7 @@ function renderFactGroup(items, keyPrefix) {
|
|
|
4759
4777
|
children: item.icon
|
|
4760
4778
|
}
|
|
4761
4779
|
),
|
|
4762
|
-
item.text
|
|
4780
|
+
/* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: item.text })
|
|
4763
4781
|
] }, `${keyPrefix}-${String(i)}`)) }, keyPrefix);
|
|
4764
4782
|
}
|
|
4765
4783
|
function renderTextGroup(items, keyPrefix) {
|
|
@@ -5241,17 +5259,21 @@ function Poll({ data, block, onInteraction }) {
|
|
|
5241
5259
|
blockId: block.id,
|
|
5242
5260
|
blockType: block.type,
|
|
5243
5261
|
payload: {
|
|
5244
|
-
selectedOptions: selected.map((i) =>
|
|
5262
|
+
selectedOptions: selected.map((i) => {
|
|
5263
|
+
const opt = options[i];
|
|
5264
|
+
return typeof opt === "string" ? opt : String(i);
|
|
5265
|
+
}),
|
|
5245
5266
|
selectedIndices: [...selected]
|
|
5246
5267
|
}
|
|
5247
5268
|
});
|
|
5248
5269
|
}
|
|
5249
5270
|
};
|
|
5250
5271
|
const totalVotes = votes.reduce((a, b) => a + b, 0);
|
|
5272
|
+
const questionAriaLabel = typeof question === "string" ? question : "Poll question";
|
|
5251
5273
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { id: baseId, role: "region", "aria-label": title ?? "Poll", style: containerStyle3, children: [
|
|
5252
5274
|
title && /* @__PURE__ */ jsxRuntime.jsx("div", { style: headerStyle2, children: title }),
|
|
5253
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: questionStyle, children: question }),
|
|
5254
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { role: "group", "aria-label":
|
|
5275
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: questionStyle, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: question }) }),
|
|
5276
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { role: "group", "aria-label": questionAriaLabel, style: optionsStyle, children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs("label", { style: optionLabelStyle2(selected.includes(index)), children: [
|
|
5255
5277
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5256
5278
|
"input",
|
|
5257
5279
|
{
|
|
@@ -5263,7 +5285,7 @@ function Poll({ data, block, onInteraction }) {
|
|
|
5263
5285
|
"aria-checked": selected.includes(index)
|
|
5264
5286
|
}
|
|
5265
5287
|
),
|
|
5266
|
-
option
|
|
5288
|
+
/* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: option })
|
|
5267
5289
|
] }, index)) }),
|
|
5268
5290
|
!hasVoted && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5269
5291
|
"button",
|
|
@@ -5282,9 +5304,10 @@ function Poll({ data, block, onInteraction }) {
|
|
|
5282
5304
|
showResults && hasVoted && /* @__PURE__ */ jsxRuntime.jsx("div", { role: "status", "aria-live": "polite", style: resultsStyle, children: options.map((option, index) => {
|
|
5283
5305
|
const count = votes[index] ?? 0;
|
|
5284
5306
|
const percentage = totalVotes > 0 ? count / totalVotes * 100 : 0;
|
|
5307
|
+
const optionLabel = typeof option === "string" ? option : "Option";
|
|
5285
5308
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: resultRowStyle, children: [
|
|
5286
5309
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: resultLabelStyle, children: [
|
|
5287
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: option }),
|
|
5310
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: option }) }),
|
|
5288
5311
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
5289
5312
|
String(count),
|
|
5290
5313
|
" vote",
|
|
@@ -5302,7 +5325,7 @@ function Poll({ data, block, onInteraction }) {
|
|
|
5302
5325
|
"aria-valuenow": percentage,
|
|
5303
5326
|
"aria-valuemin": 0,
|
|
5304
5327
|
"aria-valuemax": 100,
|
|
5305
|
-
"aria-label": `${
|
|
5328
|
+
"aria-label": `${optionLabel}: ${String(Math.round(percentage))}%`,
|
|
5306
5329
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: barFillStyle(percentage) })
|
|
5307
5330
|
}
|
|
5308
5331
|
)
|
|
@@ -5404,6 +5427,8 @@ function Rating({
|
|
|
5404
5427
|
newRatings[itemIndex] = value;
|
|
5405
5428
|
setRatings(newRatings);
|
|
5406
5429
|
if (onInteraction) {
|
|
5430
|
+
const item = items[itemIndex];
|
|
5431
|
+
const itemLabel = item ? typeof item.label === "string" ? item.label : "Item" : "";
|
|
5407
5432
|
onInteraction({
|
|
5408
5433
|
kind: "rating-change",
|
|
5409
5434
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -5411,10 +5436,10 @@ function Rating({
|
|
|
5411
5436
|
blockType: block.type,
|
|
5412
5437
|
payload: {
|
|
5413
5438
|
itemIndex,
|
|
5414
|
-
itemLabel
|
|
5439
|
+
itemLabel,
|
|
5415
5440
|
value,
|
|
5416
|
-
allRatings: items.map((
|
|
5417
|
-
label:
|
|
5441
|
+
allRatings: items.map((item2, i) => ({
|
|
5442
|
+
label: typeof item2.label === "string" ? item2.label : "Item",
|
|
5418
5443
|
value: i === itemIndex ? value : newRatings[i] ?? null
|
|
5419
5444
|
}))
|
|
5420
5445
|
}
|
|
@@ -5426,10 +5451,11 @@ function Rating({
|
|
|
5426
5451
|
items.map((item, itemIndex) => {
|
|
5427
5452
|
const currentRating = ratings[itemIndex] ?? null;
|
|
5428
5453
|
const isLast = itemIndex === items.length - 1;
|
|
5454
|
+
const itemLabelText = typeof item.label === "string" ? item.label : "Item";
|
|
5429
5455
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: itemStyle2(isLast), children: [
|
|
5430
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: itemLabelStyle, children: item.label }),
|
|
5431
|
-
item.description && /* @__PURE__ */ jsxRuntime.jsx("div", { style: itemDescriptionStyle, children: item.description }),
|
|
5432
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { role: "radiogroup", "aria-label": `Rate ${
|
|
5456
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: itemLabelStyle, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: item.label }) }),
|
|
5457
|
+
item.description && /* @__PURE__ */ jsxRuntime.jsx("div", { style: itemDescriptionStyle, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: item.description }) }),
|
|
5458
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { role: "radiogroup", "aria-label": `Rate ${itemLabelText}`, style: starsContainerStyle, children: Array.from({ length: scale }, (_, starIndex) => {
|
|
5433
5459
|
const value = starIndex + 1;
|
|
5434
5460
|
const isHovered = hoveredStar !== null && hoveredStar.itemIndex === itemIndex && value <= hoveredStar.value;
|
|
5435
5461
|
const isFilled = currentRating !== null && value <= currentRating;
|
|
@@ -5483,7 +5509,7 @@ function Rating({
|
|
|
5483
5509
|
whiteSpace: "nowrap",
|
|
5484
5510
|
border: 0
|
|
5485
5511
|
},
|
|
5486
|
-
children: currentRating !== null && `${
|
|
5512
|
+
children: currentRating !== null && `${itemLabelText} rated ${String(currentRating)} out of ${String(scale)}`
|
|
5487
5513
|
}
|
|
5488
5514
|
)
|
|
5489
5515
|
] }, itemIndex);
|
|
@@ -5590,12 +5616,12 @@ function Ranker({
|
|
|
5590
5616
|
payload: {
|
|
5591
5617
|
orderedItems: newItems.map((item, i) => ({
|
|
5592
5618
|
id: item.id,
|
|
5593
|
-
label: item.label,
|
|
5619
|
+
label: typeof item.label === "string" ? item.label : "Item",
|
|
5594
5620
|
rank: i + 1
|
|
5595
5621
|
})),
|
|
5596
5622
|
movedItem: {
|
|
5597
5623
|
id: moved.id,
|
|
5598
|
-
label: moved.label,
|
|
5624
|
+
label: typeof moved.label === "string" ? moved.label : "Item",
|
|
5599
5625
|
fromRank: fromIndex + 1,
|
|
5600
5626
|
toRank: toIndex + 1
|
|
5601
5627
|
}
|
|
@@ -5633,26 +5659,29 @@ function Ranker({
|
|
|
5633
5659
|
};
|
|
5634
5660
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { id: baseId, role: "region", "aria-label": title ?? "Ranker", style: containerStyle5, children: [
|
|
5635
5661
|
title && /* @__PURE__ */ jsxRuntime.jsx("div", { style: headerStyle4, children: title }),
|
|
5636
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { role: "list", "aria-label": title ?? "Rank items", style: listStyle, children: items.map((item, index) =>
|
|
5637
|
-
"
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5662
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { role: "list", "aria-label": title ?? "Rank items", style: listStyle, children: items.map((item, index) => {
|
|
5663
|
+
const itemLabelText = typeof item.label === "string" ? item.label : "Item";
|
|
5664
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5665
|
+
"li",
|
|
5666
|
+
{
|
|
5667
|
+
role: "listitem",
|
|
5668
|
+
"aria-grabbed": grabbedIndex === index,
|
|
5669
|
+
"aria-label": `${itemLabelText}, rank ${String(index + 1)}`,
|
|
5670
|
+
tabIndex: 0,
|
|
5671
|
+
style: itemStyle3(false, grabbedIndex === index),
|
|
5672
|
+
onKeyDown: (e) => handleKeyDown(e, index),
|
|
5673
|
+
children: [
|
|
5674
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: gripStyle, "aria-hidden": "true", children: "\u283F" }),
|
|
5675
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: rankBadgeStyle, children: String(index + 1) }),
|
|
5676
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: itemContentStyle, children: [
|
|
5677
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: itemLabelStyle2, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: item.label }) }),
|
|
5678
|
+
item.description && /* @__PURE__ */ jsxRuntime.jsx("div", { style: itemDescriptionStyle2, children: item.description })
|
|
5679
|
+
] })
|
|
5680
|
+
]
|
|
5681
|
+
},
|
|
5682
|
+
item.id
|
|
5683
|
+
);
|
|
5684
|
+
}) }),
|
|
5656
5685
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5657
5686
|
"div",
|
|
5658
5687
|
{
|
|
@@ -5668,7 +5697,7 @@ function Ranker({
|
|
|
5668
5697
|
whiteSpace: "nowrap",
|
|
5669
5698
|
border: 0
|
|
5670
5699
|
},
|
|
5671
|
-
children: grabbedIndex !== null && `${items[grabbedIndex]
|
|
5700
|
+
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.` : ""
|
|
5672
5701
|
}
|
|
5673
5702
|
)
|
|
5674
5703
|
] });
|
|
@@ -5754,11 +5783,11 @@ function Slider({
|
|
|
5754
5783
|
blockType: block.type,
|
|
5755
5784
|
payload: {
|
|
5756
5785
|
parameterId: param.id,
|
|
5757
|
-
parameterLabel: param.label,
|
|
5786
|
+
parameterLabel: typeof param.label === "string" ? param.label : "Parameter",
|
|
5758
5787
|
value: newValue,
|
|
5759
5788
|
allValues: parameters.map((p, i) => ({
|
|
5760
5789
|
id: p.id,
|
|
5761
|
-
label: p.label,
|
|
5790
|
+
label: typeof p.label === "string" ? p.label : "Parameter",
|
|
5762
5791
|
value: i === paramIndex ? newValue : newValues[i] ?? 0
|
|
5763
5792
|
}))
|
|
5764
5793
|
}
|
|
@@ -5778,7 +5807,7 @@ function Slider({
|
|
|
5778
5807
|
const isLast = index === parameters.length - 1;
|
|
5779
5808
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: parameterStyle(isLast), children: [
|
|
5780
5809
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: parameterHeaderStyle, children: [
|
|
5781
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: `${baseId}-${param.id}`, style: parameterLabelStyle, children: param.label }),
|
|
5810
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: `${baseId}-${param.id}`, style: parameterLabelStyle, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: param.label }) }),
|
|
5782
5811
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: parameterValueStyle, "aria-live": "polite", children: formatValue(currentValue, param.unit) })
|
|
5783
5812
|
] }),
|
|
5784
5813
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5891,7 +5920,8 @@ function computeWeightedTotals(rows, columns, values) {
|
|
|
5891
5920
|
const weight = col.weight ?? 1;
|
|
5892
5921
|
total += score * weight;
|
|
5893
5922
|
}
|
|
5894
|
-
|
|
5923
|
+
const rowLabel = typeof row.label === "string" ? row.label : "Row";
|
|
5924
|
+
return { rowId: row.id, rowLabel, total: Math.round(total * 100) / 100 };
|
|
5895
5925
|
});
|
|
5896
5926
|
}
|
|
5897
5927
|
function Matrix({
|
|
@@ -5934,9 +5964,9 @@ function Matrix({
|
|
|
5934
5964
|
blockType: block.type,
|
|
5935
5965
|
payload: {
|
|
5936
5966
|
rowId,
|
|
5937
|
-
rowLabel: row.label,
|
|
5967
|
+
rowLabel: typeof row.label === "string" ? row.label : "Row",
|
|
5938
5968
|
columnId,
|
|
5939
|
-
columnLabel: col.label,
|
|
5969
|
+
columnLabel: typeof col.label === "string" ? col.label : "Column",
|
|
5940
5970
|
value: clamped,
|
|
5941
5971
|
allValues: payloadValues,
|
|
5942
5972
|
weightedTotals: computeWeightedTotals(rows, columns, newValues)
|
|
@@ -5955,7 +5985,7 @@ function Matrix({
|
|
|
5955
5985
|
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
5956
5986
|
/* @__PURE__ */ jsxRuntime.jsx("th", { style: thStyle }),
|
|
5957
5987
|
columns.map((col) => /* @__PURE__ */ jsxRuntime.jsxs("th", { style: thStyle, children: [
|
|
5958
|
-
col.label,
|
|
5988
|
+
/* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: col.label }),
|
|
5959
5989
|
(col.weight ?? 1) !== 1 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: weightStyle, children: [
|
|
5960
5990
|
"\xD7",
|
|
5961
5991
|
String(col.weight)
|
|
@@ -5965,10 +5995,12 @@ function Matrix({
|
|
|
5965
5995
|
] }) }),
|
|
5966
5996
|
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((row) => {
|
|
5967
5997
|
const rowTotal = totals.find((t) => t.rowId === row.id)?.total ?? 0;
|
|
5998
|
+
const rowLabelText = typeof row.label === "string" ? row.label : "Row";
|
|
5968
5999
|
return /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
5969
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "row", style: rowHeaderStyle, children: row.label }),
|
|
6000
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "row", style: rowHeaderStyle, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: row.label }) }),
|
|
5970
6001
|
columns.map((col) => {
|
|
5971
6002
|
const cellValue = values[row.id]?.[col.id] ?? 0;
|
|
6003
|
+
const colLabelText = typeof col.label === "string" ? col.label : "Column";
|
|
5972
6004
|
return /* @__PURE__ */ jsxRuntime.jsx("td", { style: cellStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5973
6005
|
"input",
|
|
5974
6006
|
{
|
|
@@ -5977,7 +6009,7 @@ function Matrix({
|
|
|
5977
6009
|
max: scale,
|
|
5978
6010
|
value: cellValue,
|
|
5979
6011
|
onChange: (e) => handleChange(row.id, col.id, Number(e.target.value)),
|
|
5980
|
-
"aria-label": `Score for ${
|
|
6012
|
+
"aria-label": `Score for ${rowLabelText} on ${colLabelText}`,
|
|
5981
6013
|
style: inputStyle
|
|
5982
6014
|
}
|
|
5983
6015
|
) }, col.id);
|
|
@@ -6271,7 +6303,7 @@ function Form({ data, block, onInteraction }) {
|
|
|
6271
6303
|
};
|
|
6272
6304
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { id: baseId, role: "region", "aria-label": title ?? "Form", style: containerStyle8, children: [
|
|
6273
6305
|
title && /* @__PURE__ */ jsxRuntime.jsx("div", { style: headerStyle7, children: title }),
|
|
6274
|
-
description && /* @__PURE__ */ jsxRuntime.jsx("div", { style: descriptionStyle, children: description }),
|
|
6306
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("div", { style: descriptionStyle, children: /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: description }) }),
|
|
6275
6307
|
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: formStyle, noValidate: true, children: [
|
|
6276
6308
|
fields.map(
|
|
6277
6309
|
(field) => renderField({ field, baseId, values, validation, submitted, updateValue })
|
|
@@ -6658,6 +6690,9 @@ var annotationNoteStyle = {
|
|
|
6658
6690
|
marginTop: "0.125rem"
|
|
6659
6691
|
};
|
|
6660
6692
|
function computeSegments(text, annotations) {
|
|
6693
|
+
if (typeof text !== "string") {
|
|
6694
|
+
return [{ text: "", start: 0, annotation: null }];
|
|
6695
|
+
}
|
|
6661
6696
|
if (annotations.length === 0) {
|
|
6662
6697
|
return [{ text, start: 0, annotation: null }];
|
|
6663
6698
|
}
|
|
@@ -6737,7 +6772,7 @@ function Annotate({
|
|
|
6737
6772
|
allAnnotations: newAnnotations.map((a) => ({
|
|
6738
6773
|
start: a.start,
|
|
6739
6774
|
end: a.end,
|
|
6740
|
-
text: text.slice(a.start, a.end),
|
|
6775
|
+
text: typeof text === "string" ? text.slice(a.start, a.end) : "",
|
|
6741
6776
|
label: a.label
|
|
6742
6777
|
}))
|
|
6743
6778
|
}
|
|
@@ -6763,7 +6798,7 @@ function Annotate({
|
|
|
6763
6798
|
title && /* @__PURE__ */ jsxRuntime.jsx("div", { style: headerStyle9, children: title }),
|
|
6764
6799
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: bodyStyle2, children: [
|
|
6765
6800
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: textRef, role: "document", style: textPaneStyle, onMouseUp: handleMouseUp, children: [
|
|
6766
|
-
segments.map((seg, i) => {
|
|
6801
|
+
typeof text === "string" ? segments.map((seg, i) => {
|
|
6767
6802
|
if (seg.annotation) {
|
|
6768
6803
|
const color3 = labelColorMap.get(seg.annotation.label) ?? "#888";
|
|
6769
6804
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6781,7 +6816,7 @@ function Annotate({
|
|
|
6781
6816
|
);
|
|
6782
6817
|
}
|
|
6783
6818
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { children: seg.text }, i);
|
|
6784
|
-
}),
|
|
6819
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(runtime.RichText, { content: text }),
|
|
6785
6820
|
pickerPos && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6786
6821
|
"div",
|
|
6787
6822
|
{
|
|
@@ -6820,12 +6855,13 @@ function Annotate({
|
|
|
6820
6855
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { role: "list", children: [
|
|
6821
6856
|
annotations.map((ann, i) => {
|
|
6822
6857
|
const color3 = labelColorMap.get(ann.label) ?? "#888";
|
|
6858
|
+
const annotatedText = typeof text === "string" ? text.slice(ann.start, ann.end) : "";
|
|
6823
6859
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "listitem", style: annotationItemStyle(color3), children: [
|
|
6824
6860
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.375rem" }, children: [
|
|
6825
6861
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: colorDotStyle(color3) }),
|
|
6826
6862
|
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { fontSize: "0.75rem" }, children: ann.label })
|
|
6827
6863
|
] }),
|
|
6828
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: annotationTextStyle, children:
|
|
6864
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: annotationTextStyle, children: annotatedText }),
|
|
6829
6865
|
ann.note && /* @__PURE__ */ jsxRuntime.jsx("div", { style: annotationNoteStyle, children: ann.note })
|
|
6830
6866
|
] }, i);
|
|
6831
6867
|
}),
|