// create and apply a custom list style

import {
    CreateDocx,
    ListNested,
    OptionsList,
    OptionsNumPr,
} from "../../../build";
import * as fs from "fs";

const docx = new CreateDocx();

// create custom list style with name "myliststyle1"
const listStyle: OptionsNumPr[] = [
    {
        type: "lowerLetter",
        format: "%1.",
    },
    {
        type: "lowerRoman",
        format: "%1.%2.",
        indentation: {
            hanging: 540,
        },
    },
];
docx.createListStyle("myliststyle1", listStyle);

const items: ListNested = [
    "Item 1",
    "Item 2",
    ["Item A", "Item B", "Item C"],
    "Item 3",
    "Item 4",
    "Item 5",
];
// set the custom list style as type
const optionsList: OptionsList = {
    type: "myliststyle1",
};
docx.addList(items, optionsList);

docx.save().then(contents => {
    fs.writeFileSync("createListStyle_1.docx", Buffer.from(contents));
});
