MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / multiPrompt

Function multiPrompt

src/dialogs/multiPrompt.js:34–306  ·  view source on GitHub ↗
(message, inputs, help)

Source from the content-addressed store, hash-verified

32 * @returns {Promise<Strings>}
33 */
34export default function multiPrompt(message, inputs, help) {
35 return new Promise((resolve, reject) => {
36 const $title = tag("div", {
37 className: "title",
38 child: tag("span", {
39 textContent: message,
40 }),
41 style: {
42 justifyContent: "space-between",
43 },
44 });
45 const $body = tag("div", {
46 className: "message scroll",
47 style: {
48 fontSize: "1rem",
49 },
50 });
51 const okBtn = tag("button", {
52 type: "submit",
53 textContent: strings.ok,
54 onclick: function (e) {
55 e.preventDefault();
56 e.stopPropagation();
57 const inputAr = [...$body.getAll("input")];
58
59 for (let $input of inputAr) {
60 if ($input.isRequired && !$input.value) {
61 $errorMessage.textContent = strings.required.capitalize();
62 const $sibling = $input.nextElementSibling;
63 const $parent = $input.parentElement;
64 if ($sibling) $parent.insertBefore($errorMessage, $sibling);
65 else $parent.append($errorMessage);
66 return;
67 }
68 }
69 hide();
70 resolve(getValue());
71 },
72 });
73 const cancelBtn = tag("button", {
74 textContent: strings.cancel,
75 type: "button",
76 onclick: function () {
77 reject();
78 hide();
79 },
80 });
81 const $errorMessage = (
82 <span className="error-msg" style={{ display: "block" }} />
83 );
84 const $mask = <span className="mask" />;
85 const $promptDiv = tag("form", {
86 action: "#",
87 className: "prompt multi",
88 onsubmit: (e) => {
89 e.preventDefault();
90 if (!okBtn.disabled) {
91 resolve(getValue());

Callers 4

addPathFunction · 0.85
sponsor.jsFile · 0.85
promptFunction · 0.85
multiPromptMethod · 0.85

Calls 13

resolveFunction · 0.85
getValueFunction · 0.85
alertFunction · 0.85
createGroupFunction · 0.85
createInputFunction · 0.85
restoreThemeFunction · 0.85
capitalizeMethod · 0.80
appendMethod · 0.80
setInputTypeMethod · 0.80
focusMethod · 0.80
hideFunction · 0.70
preventDefaultMethod · 0.45

Tested by

no test coverage detected