From 4b74ced804e19fafa0f6df700e6242e8683a59d0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 23:18:33 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/JSONSchemaForm.js | 9 ++-- src/renderer/src/stories/JSONSchemaInput.js | 43 ++++++++----------- src/renderer/src/stories/Search.js | 41 +++++++++--------- .../guided-mode/data/GuidedPathExpansion.js | 1 - .../src/stories/pages/uploads/UploadsPage.js | 8 ++-- 5 files changed, 46 insertions(+), 56 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index d86562bd4..c7a12424a 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -125,7 +125,7 @@ const componentCSS = ` border: 1px solid black; border-radius: 4px; position: relative; - + } .link > div { @@ -818,14 +818,13 @@ export class JSONSchemaForm extends LitElement { const value = parent[name]; - const skipValidation = this.validateEmptyValues === null && value === undefined; const validateArgs = input.pattern || skipValidation ? [] : [value, schema]; // Run validation functions const jsonSchemaErrors = validateArgs.length === 2 ? this.validateSchema(...validateArgs, name) : []; - const valid = skipValidation ? true : await this.validateOnChange(name, parent, pathToValidate, value); + const valid = skipValidation ? true : await this.validateOnChange(name, parent, pathToValidate, value); if (valid === null) return null; // Skip validation / data change if the value is null @@ -882,9 +881,7 @@ export class JSONSchemaForm extends LitElement { type: "error", missing: true, }); - } - - else if (this.validateEmptyValues === null) { + } else if (this.validateEmptyValues === null) { warnings.push({ message: `${schema.title ?? header(name)} is a suggested property.`, type: "warning", diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js index 0e16f0429..f1738717a 100644 --- a/src/renderer/src/stories/JSONSchemaInput.js +++ b/src/renderer/src/stories/JSONSchemaInput.js @@ -858,12 +858,11 @@ export class JSONSchemaInput extends LitElement { } const itemSchema = this.form?.getSchema ? this.form.getSchema("items", schema) : schema["items"]; - + const fileSystemFormat = isFilesystemSelector(name, itemSchema?.format); if (fileSystemFormat) return createFilesystemSelector(fileSystemFormat); // Create tables if possible else if (itemSchema?.type === "string" && !itemSchema.properties) { - const list = new List({ items: this.value, emptyMessage: "No items", @@ -873,10 +872,9 @@ export class JSONSchemaInput extends LitElement { }, }); - console.log(list) + console.log(list); if (itemSchema.enum) { - const search = new Search({ options: itemSchema.enum.map((v) => { return { @@ -889,45 +887,41 @@ export class JSONSchemaInput extends LitElement { }; }), value: this.value, - listMode: schema.strict === false ? 'click' : "append", + listMode: schema.strict === false ? "click" : "append", showAllWhenEmpty: false, onSelect: async ({ label, value }) => { - if (!value) return - if (schema.uniqueItems && this.value && this.value.includes(value)) return - list.add({ content: label, value }) + if (!value) return; + if (schema.uniqueItems && this.value && this.value.includes(value)) return; + list.add({ content: label, value }); }, }); search.style.height = "auto"; return html`
${search}${list}
`; - - } - - else { + } else { const input = document.createElement("input"); input.classList.add("guided--input"); - input.placeholder = "Provide an item for the list" + input.placeholder = "Provide an item for the list"; const submitButton = new Button({ label: "Submit", primary: true, size: "small", onClick: () => { - const value = input.value - if (!value) return - if (schema.uniqueItems && this.value && this.value.includes(value)) return - list.add({ value }) - input.value = "" - } + const value = input.value; + if (!value) return; + if (schema.uniqueItems && this.value && this.value.includes(value)) return; + list.add({ value }); + input.value = ""; + }, }); - - - return html`
${input}${submitButton}
${list}
`; + return html`
+
${input}${submitButton}
+ ${list} +
`; } - } else if (itemSchema?.type === "object" && this.renderTable) { - const instanceThis = this; function updateFunction(path, value = this.data) { @@ -964,7 +958,6 @@ export class JSONSchemaInput extends LitElement { }); }; - const list = (this.#list = new List({ items: this.#mapToList(), diff --git a/src/renderer/src/stories/Search.js b/src/renderer/src/stories/Search.js index 5a7abb119..bee4fba5f 100644 --- a/src/renderer/src/stories/Search.js +++ b/src/renderer/src/stories/Search.js @@ -6,7 +6,6 @@ import searchSVG from "./assets/search.svg?raw"; import tippy from "tippy.js"; import { unsafeHTML } from "lit/directives/unsafe-html.js"; - const ALTERNATIVE_MODES = ["input", "append"]; export class Search extends LitElement { @@ -35,7 +34,7 @@ export class Search extends LitElement { if (this.listMode === "input" && this.getAttribute("interacted") === "true") { this.setAttribute("interacted", false); this.#onSelect(this.getSelectedOption()); - } else if (this.listMode !== 'list') { + } else if (this.listMode !== "list") { this.setAttribute("active", false); } }; @@ -109,7 +108,8 @@ export class Search extends LitElement { overflow: auto; } - :host([listmode="input"]) ul, :host([listmode="append"]) ul { + :host([listmode="input"]) ul, + :host([listmode="append"]) ul { position: absolute; top: 38px; left: 0; @@ -140,7 +140,8 @@ export class Search extends LitElement { font-size: 60%; } - :host([listmode="input"]) svg, :host([listmode="append"]) svg { + :host([listmode="input"]) svg, + :host([listmode="append"]) svg { position: absolute; top: 50%; padding: 0px; @@ -319,7 +320,7 @@ export class Search extends LitElement { this.setAttribute("interacted", true); }; - #ignore = false + #ignore = false; render() { this.categories = {}; @@ -370,7 +371,7 @@ export class Search extends LitElement { listItemElement.addEventListener("click", (clickEvent) => { clickEvent.stopPropagation(); - if (this.#ignore) return this.#ignore = false + if (this.#ignore) return (this.#ignore = false); this.#onSelect(option); }); @@ -382,9 +383,8 @@ export class Search extends LitElement { label.classList.add("label"); label.innerText = option.label; - if (option.description || option.link) { - const info = option.link ? document.createElement('a') : document.createElement("span"); + const info = option.link ? document.createElement("a") : document.createElement("span"); if (option.link) { info.setAttribute("data-link", true); info.href = option.link; @@ -394,11 +394,12 @@ export class Search extends LitElement { info.innerText = "ℹ️"; label.append(info); - if (option.description) tippy(info, { - content: `

${option.description}

`, - allowHTML: true, - placement: "right", - }); + if (option.description) + tippy(info, { + content: `

${option.description}

`, + allowHTML: true, + placement: "right", + }); } container.appendChild(label); @@ -482,14 +483,14 @@ export class Search extends LitElement { @blur=${(blurEvent) => { const relatedTarget = blurEvent.relatedTarget; if (relatedTarget) { - if (relatedTarget.classList.contains("option")) return; - if (relatedTarget.hasAttribute("data-link")) { - this.#ignore = true - return - } - } + if (relatedTarget.classList.contains("option")) return; + if (relatedTarget.hasAttribute("data-link")) { + this.#ignore = true; + return; + } + } - this.#close(); + this.#close(); }} > diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js index b815e3554..77a0bb0fc 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js @@ -115,7 +115,6 @@ export async function autocompleteFormatString(path) { } } } else { - if (!parent.path) return; if (!value) return; diff --git a/src/renderer/src/stories/pages/uploads/UploadsPage.js b/src/renderer/src/stories/pages/uploads/UploadsPage.js index 3cae6925f..408d1a7f4 100644 --- a/src/renderer/src/stories/pages/uploads/UploadsPage.js +++ b/src/renderer/src/stories/pages/uploads/UploadsPage.js @@ -56,7 +56,7 @@ export async function createDandiset(results = {}) { }); const updateNIHInput = (embargoed) => { - const nihInput = form.getFormElement([ "nih_award_number" ]); + const nihInput = form.getFormElement(["nih_award_number"]); // Show the NIH input if embargo is set if (embargoed) nihInput.removeAttribute("hidden"); @@ -64,7 +64,7 @@ export async function createDandiset(results = {}) { // Make the NIH input required if embargo is set nihInput.required = embargoed; - } + }; const form = new JSONSchemaForm({ schema: dandiCreateSchema, @@ -73,7 +73,7 @@ export async function createDandiset(results = {}) { validateOnChange: async (name, parent) => { const value = parent[name]; - if (name === 'embargo_status') return updateNIHInput(value); + if (name === "embargo_status") return updateNIHInput(value); if (name === "nih_award_number") { if (value) @@ -97,7 +97,7 @@ export async function createDandiset(results = {}) { content.append(form); modal.append(content); - + modal.onClose = async () => notify("Dandiset was not created.", "error"); return new Promise((resolve) => {