Principia Documentation
allInputsEmpty
Checks if all input fields in the '#principia-table' are empty.
allInputsEmpty(): boolean
Returns
boolean:
True if all input fields are empty, otherwise false.
findLabel
Finds the labels for a given chapter number from the provided data and labels.
This function attempts to locate the correct labels for a chapter by its number. If the chapter number ends with '.0', it increments the suffix until it finds a match or exceeds a limit. Once found, it retrieves the corresponding labels from the provided labels object.
Parameters
chapterNumber
(string) The chapter number to find labels for. If it ends in '.0', the function will try to find a suffix that matches.data
(Object) The data object containing chapter information. It is expected to be structured with nested objects containing properties.labels
(Object) The labels object containing titles for volumes, parts, sections, and chapters.Returns
(Object | null): An object containing the part, section, and chapter labels if found, otherwise null.
Example
const chapterNumber = "1.0"
const data = {
volume1: [{ properties: { number: "1.1", volume: 1, part: 1, section: 1, chapter: 1 } }]
}
const labels = {
default: {
"Volume I": {
"Part I": {
title: "Part 1 Title",
sections: {
1: {
title: "Section 1 Title",
chapters: {
1: { title: "Chapter 1 Title" }
}
}
}
}
}
}
}
const result = findLabel(chapterNumber, data, labels)
console.log(result) // Outputs: { "part-label": "Part 1 Title", "sect-label": "Section 1 Title", "chap-label": "Chapter 1 Title" }