buildSeoChecklistWorkflowPlanNodes function
Implementation
List<SeoNode> buildSeoChecklistWorkflowPlanNodes(
SeoChecklistWorkflowComponentPlan plan) {
final id = plan.interactionId;
final state = plan.initial.state;
final view = plan.initial.view;
final labels = plan.labels;
final level = (plan.headingLevel + 1).clamp(1, 6);
final checkedCount = seoApprovalChecklistCheckedCount(state.checklist);
return [
SeoNode(tag: 'section', attributes: {
'class': 'esen-seo-checklist-workflow',
if (id != null) ...{
'id': id,
'data-esen-component': 'checklist-workflow',
'data-esen-layout-stable': 'true',
'data-esen-initial-checked':
state.checklist.checked.map((v) => v ? '1' : '0').join(','),
'data-esen-initial-stage': '${state.workflow.stage.index}',
'data-esen-initial-history':
state.workflow.history.map((v) => v.index).join(','),
},
}, children: [
SeoNode(tag: 'h${plan.headingLevel}', text: labels[0]),
_placeholder('checks', plan.items.map((v) => v.label).toList(),
checked: state.checklist.checked),
SeoNode(tag: 'p', children: [
SeoNode(tag: 'strong', text: '${labels[1]}: '),
SeoNode(tag: 'span', text: view.statusText)
]),
SeoNode(
tag: 'p', children: [SeoNode(tag: 'span', text: view.summaryText)]),
SeoNode(tag: 'div', attributes: {
'class': 'esen-seo-checklist-workflow-progress',
'role': 'progressbar',
'aria-label': labels[2],
'aria-valuemin': '0',
'aria-valuemax': '${plan.items.length}',
'aria-valuenow': '$checkedCount',
}, children: [
SeoNode(tag: 'span', text: '$checkedCount / ${plan.items.length}')
]),
SeoNode(tag: 'ol', attributes: const {
'class': 'esen-seo-checklist-workflow-items'
}, children: [
for (final (index, item) in plan.items.indexed)
SeoNode(tag: 'li', children: [
SeoNode(tag: 'h$level', text: item.label, attributes: {
if (id != null) 'id': '$id-item-$index-label',
}),
SeoNode(tag: 'div', children: item.nodes),
]),
]),
SeoNode(tag: 'ol', attributes: const {
'class': 'esen-seo-checklist-workflow-stages'
}, children: [
for (final (index, stage) in plan.stages.indexed)
SeoNode(tag: 'li', text: stage.label, attributes: {
if (index == state.workflow.stage.index) 'aria-current': 'step',
}),
]),
for (final (index, stage) in plan.stages.indexed)
SeoNode(tag: 'section', attributes: {
'data-esen-composite-stage': '$index'
}, children: [
SeoNode(tag: 'h$level', text: stage.label),
SeoNode(tag: 'div', children: stage.nodes)
]),
SeoNode(tag: 'h$level', text: labels[3]),
SeoNode(tag: 'ol', attributes: const {
'class': 'esen-seo-checklist-workflow-history'
}, children: [
for (final stage in state.workflow.history)
SeoNode(tag: 'li', text: plan.stages[stage.index].label, attributes: {
'data-esen-composite-history-stage': '${stage.index}'
})
]),
_placeholder('actions', labels.skip(4).toList()),
SeoNode(tag: 'div', attributes: const {
'class': 'esen-seo-checklist-workflow-announcement',
'role': 'status',
'aria-live': 'polite',
'aria-atomic': 'true',
}),
])
];
}